From 7b938c28b4bb3fcb52967e913de4bcc067e16a58 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Mon, 7 Dec 2020 09:09:50 -0500 Subject: [PATCH] Added more to the upgrades Added a lot of the regular upgrades, as well as added the recipe for the Binding Reagent. The rituals used for upgrading/removing upgrades for the Living Armour were also added, as well as the Ellipsoid ritual. Complete for BM 3.0.2 --- changelog.txt | 20 +- src/generated/resources/.cache/cache | 3 +- .../assets/bloodmagic/lang/en_us.json | 26 +- .../recipes/soulforge/reagent_binding.json | 20 ++ .../common/data/GeneratorLanguage.java | 27 +- .../common/item/ItemLivingArmor.java | 27 ++ .../recipe/TartaricForgeRecipeProvider.java | 1 + .../bloodmagic/core/LivingArmorRegistrar.java | 33 ++- .../bloodmagic/core/living/LivingStats.java | 13 + .../ritual/types/RitualArmourEvolve.java | 110 +++++++ .../ritual/types/RitualEllipsoid.java | 272 ++++++++++++++++++ .../ritual/types/RitualUpgradeRemove.java | 170 +++++++++++ .../util/handler/event/GenericHandler.java | 66 ++++- .../data/bloodmagic/living_armor/jump.json | 20 +- 14 files changed, 766 insertions(+), 42 deletions(-) create mode 100644 src/generated/resources/data/bloodmagic/recipes/soulforge/reagent_binding.json create mode 100644 src/main/java/wayoftime/bloodmagic/ritual/types/RitualArmourEvolve.java create mode 100644 src/main/java/wayoftime/bloodmagic/ritual/types/RitualEllipsoid.java create mode 100644 src/main/java/wayoftime/bloodmagic/ritual/types/RitualUpgradeRemove.java diff --git a/changelog.txt b/changelog.txt index f7202627..fa2027ab 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,13 +1,31 @@ ------------------------------------------------------ -Version 3.0.1 +Version 3.0.2 ------------------------------------------------------ +Readded the Living Armour. Currently only with a few upgrades, and no downgrades. + - Pin Cushion + - Soft Fall + - Tough + - Strong Legs (Now can be temporarily deactivated when jumping by sneaking) + - Healthy + - Experienced + - Charging Strike + - Tough Palms + - Quick Feet + - Poison Resistance + - Gift of Ignis + - Dwarven Might + - Body Builder + Reimplemented the following rituals: - Resonance of the Faceted Crystal - Crack of the Fractured Crystal - Reap of the Harvest Moon - Ritual of the Shepherd - Ritual of the Green Grove + - Focus of the Ellipsoid + - Sound of the Cleansing Soul + - Ritual of Living Evolution ------------------------------------------------------ Version 3.0.1 diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 5c7fc244..78c7ba78 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -56,7 +56,7 @@ e6d9cf699667aaa47efff37b2b033895dee29c15 assets/bloodmagic/blockstates/waterritu 42f26f715bddd16c069f9b51e3767b36477c8908 assets/bloodmagic/blockstates/woodtilepath.json 3c6ce233dae6c1307d9016406c324bbe844b4e1e assets/bloodmagic/blockstates/wornstonebrickpath.json d59655f12d1724b73b77c373fb6864fcff69db12 assets/bloodmagic/blockstates/wornstonetilepath.json -173699095ea3249b38b9dfa43e3480cd1fa209f4 assets/bloodmagic/lang/en_us.json +d25f91dea344a12e9de700a711d4ca0a42053173 assets/bloodmagic/lang/en_us.json 34445195b9f2459475cde53454bc8e37d32865d7 assets/bloodmagic/models/block/accelerationrune.json bcdbccc49d4509571be6988762ab87126275a4c8 assets/bloodmagic/models/block/airritualstone.json adf6c0b1e25451609486dc8c8cfbd9cf0f8c67f4 assets/bloodmagic/models/block/alchemicalreactionchamber.json @@ -631,6 +631,7 @@ d6e06747c75fc06e708a15358911f1c63eee86b1 data/bloodmagic/recipes/soulforge/petty 2468dd785e301732b1be8108caa468bdd5008e46 data/bloodmagic/recipes/soulforge/primitive_crystalline_resonator.json 535a9ec33a425bde205dffc3254635741d1c82d6 data/bloodmagic/recipes/soulforge/raw_crystal_block.json 42f6af3a4c723c6a6b2a6e1d680a875e15664e4f data/bloodmagic/recipes/soulforge/reagent_air.json +16cccf4c7332b1689298da1e242498f5821d9285 data/bloodmagic/recipes/soulforge/reagent_binding.json cba99433d18bd61a0a7c2f5ef9f97cad91028f16 data/bloodmagic/recipes/soulforge/reagent_blood_light.json 6b59a7e95e596997b7bbb894b6fbaf5015b213b5 data/bloodmagic/recipes/soulforge/reagent_fastminer.json ae3a6a760e9f793d5a62e2f0f6c45219b0017816 data/bloodmagic/recipes/soulforge/reagent_growth.json diff --git a/src/generated/resources/assets/bloodmagic/lang/en_us.json b/src/generated/resources/assets/bloodmagic/lang/en_us.json index d628877b..5a112fa8 100644 --- a/src/generated/resources/assets/bloodmagic/lang/en_us.json +++ b/src/generated/resources/assets/bloodmagic/lang/en_us.json @@ -177,28 +177,28 @@ "jei.bloodmagic.recipe.requiredtier": "Tier: %d", "jei.bloodmagic.recipe.soulforge": "Hellfire Forge", "jei.bloodmagic.recipe.soulsdrained": "Drained: %s Will", - "living_upgrade.bloodmagic.arrowShot": "Trick Shot", "living_upgrade.bloodmagic.arrow_protect": "Pin Cushion", + "living_upgrade.bloodmagic.arrow_shot": "Trick Shot", "living_upgrade.bloodmagic.battleHunger": "Battle Hungry", "living_upgrade.bloodmagic.crippledArm": "Crippled Arm", - "living_upgrade.bloodmagic.criticalStrike": "True Strike", + "living_upgrade.bloodmagic.critical_strike": "True Strike", "living_upgrade.bloodmagic.digSlowdown": "Weakened Pick", "living_upgrade.bloodmagic.digging": "Dwarven Might", "living_upgrade.bloodmagic.disoriented": "Disoriented", "living_upgrade.bloodmagic.elytra": "Elytra", "living_upgrade.bloodmagic.experienced": "Experienced", - "living_upgrade.bloodmagic.fallProtect": "Soft Fall", - "living_upgrade.bloodmagic.fireResist": "Gift of Ignis", - "living_upgrade.bloodmagic.graveDigger": "Grave Digger", - "living_upgrade.bloodmagic.grimReaper": "Grim Reaper's Sprint", + "living_upgrade.bloodmagic.fall_protect": "Soft Fall", + "living_upgrade.bloodmagic.fire_resist": "Gift of Ignis", + "living_upgrade.bloodmagic.grave_digger": "Grave Digger", + "living_upgrade.bloodmagic.grim_reaper": "Grim Reaper's Sprint", "living_upgrade.bloodmagic.health": "Healthy", "living_upgrade.bloodmagic.jump": "Strong Legs", - "living_upgrade.bloodmagic.knockback": "Body Builder", - "living_upgrade.bloodmagic.meleeDamage": "Fierce Strike", + "living_upgrade.bloodmagic.knockback_resist": "Body Builder", "living_upgrade.bloodmagic.meleeDecrease": "Dulled Blade", - "living_upgrade.bloodmagic.nightSight": "Nocturnal Prowess", - "living_upgrade.bloodmagic.physicalProtect": "Tough", - "living_upgrade.bloodmagic.poisonResist": "Poison Resistance", + "living_upgrade.bloodmagic.melee_damage": "Fierce Strike", + "living_upgrade.bloodmagic.night_sight": "Nocturnal Prowess", + "living_upgrade.bloodmagic.physical_protect": "Tough", + "living_upgrade.bloodmagic.poison_resist": "Poison Resistance", "living_upgrade.bloodmagic.quenched": "Quenched", "living_upgrade.bloodmagic.repair": "Repairing", "living_upgrade.bloodmagic.revealing": "Revealing", @@ -206,10 +206,10 @@ "living_upgrade.bloodmagic.slippery": "Loose Traction", "living_upgrade.bloodmagic.slowHeal": "Diseased", "living_upgrade.bloodmagic.slowness": "Limp Leg", - "living_upgrade.bloodmagic.solarPowered": "Solar Powered", + "living_upgrade.bloodmagic.solar_powered": "Solar Powered", "living_upgrade.bloodmagic.speed": "Quick Feet", "living_upgrade.bloodmagic.sprint_attack": "Charging Strike", - "living_upgrade.bloodmagic.stepAssist": "Step Assist", + "living_upgrade.bloodmagic.step_assist": "Step Assist", "living_upgrade.bloodmagic.stormTrooper": "Storm Trooper", "living_upgrade.bloodmagic.thaumRunicShielding": "Runic Shielding", "ritual.bloodmagic.altarBuilderRitual": "The Assembly of the High Altar", diff --git a/src/generated/resources/data/bloodmagic/recipes/soulforge/reagent_binding.json b/src/generated/resources/data/bloodmagic/recipes/soulforge/reagent_binding.json new file mode 100644 index 00000000..27cd2147 --- /dev/null +++ b/src/generated/resources/data/bloodmagic/recipes/soulforge/reagent_binding.json @@ -0,0 +1,20 @@ +{ + "type": "bloodmagic:soulforge", + "input0": { + "tag": "forge:dusts/glowstone" + }, + "input1": { + "tag": "forge:dusts/redstone" + }, + "input2": { + "tag": "forge:gunpowder" + }, + "input3": { + "tag": "forge:nuggets/gold" + }, + "output": { + "item": "bloodmagic:reagentbinding" + }, + "minimumDrain": 400.0, + "drain": 10.0 +} \ No newline at end of file diff --git a/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java b/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java index aeb7b1cb..a5f6c71a 100644 --- a/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java +++ b/src/main/java/wayoftime/bloodmagic/common/data/GeneratorLanguage.java @@ -162,6 +162,7 @@ public class GeneratorLanguage extends LanguageProvider add("ritual.bloodmagic.crystalHarvestRitual", "Crack of the Fractured Crystal"); add("ritual.bloodmagic.forsakenSoulRitual", "Gathering of the Forsaken Souls"); add("ritual.bloodmagic.crystalSplitRitual", "Resonance of the Faceted Crystal"); + add("ritual.bloodmagic.ellipsoidRitual", "Focus of the Ellipsoid"); add("ritual.bloodmagic.cobblestoneRitual", "Le Vulcanos Frigius"); add("ritual.bloodmagic.placerRitual", "The Filler"); @@ -301,27 +302,27 @@ public class GeneratorLanguage extends LanguageProvider add("living_upgrade.bloodmagic.arrow_protect", "Pin Cushion"); add("living_upgrade.bloodmagic.speed", "Quick Feet"); add("living_upgrade.bloodmagic.digging", "Dwarven Might"); - add("living_upgrade.bloodmagic.poisonResist", "Poison Resistance"); - add("living_upgrade.bloodmagic.fireResist", "Gift of Ignis"); + add("living_upgrade.bloodmagic.poison_resist", "Poison Resistance"); + add("living_upgrade.bloodmagic.fire_resist", "Gift of Ignis"); add("living_upgrade.bloodmagic.self_sacrifice", "Tough Palms"); - add("living_upgrade.bloodmagic.knockback", "Body Builder"); - add("living_upgrade.bloodmagic.physicalProtect", "Tough"); + add("living_upgrade.bloodmagic.knockback_resist", "Body Builder"); + add("living_upgrade.bloodmagic.physical_protect", "Tough"); add("living_upgrade.bloodmagic.health", "Healthy"); - add("living_upgrade.bloodmagic.meleeDamage", "Fierce Strike"); - add("living_upgrade.bloodmagic.arrowShot", "Trick Shot"); - add("living_upgrade.bloodmagic.stepAssist", "Step Assist"); - add("living_upgrade.bloodmagic.grimReaper", "Grim Reaper's Sprint"); - add("living_upgrade.bloodmagic.solarPowered", "Solar Powered"); + add("living_upgrade.bloodmagic.melee_damage", "Fierce Strike"); + add("living_upgrade.bloodmagic.arrow_shot", "Trick Shot"); + add("living_upgrade.bloodmagic.step_assist", "Step Assist"); + add("living_upgrade.bloodmagic.grim_reaper", "Grim Reaper's Sprint"); + add("living_upgrade.bloodmagic.solar_powered", "Solar Powered"); add("living_upgrade.bloodmagic.thaumRunicShielding", "Runic Shielding"); add("living_upgrade.bloodmagic.revealing", "Revealing"); add("living_upgrade.bloodmagic.experienced", "Experienced"); add("living_upgrade.bloodmagic.jump", "Strong Legs"); - add("living_upgrade.bloodmagic.fallProtect", "Soft Fall"); - add("living_upgrade.bloodmagic.graveDigger", "Grave Digger"); + add("living_upgrade.bloodmagic.fall_protect", "Soft Fall"); + add("living_upgrade.bloodmagic.grave_digger", "Grave Digger"); add("living_upgrade.bloodmagic.sprint_attack", "Charging Strike"); - add("living_upgrade.bloodmagic.criticalStrike", "True Strike"); + add("living_upgrade.bloodmagic.critical_strike", "True Strike"); add("living_upgrade.bloodmagic.elytra", "Elytra"); - add("living_upgrade.bloodmagic.nightSight", "Nocturnal Prowess"); + add("living_upgrade.bloodmagic.night_sight", "Nocturnal Prowess"); add("living_upgrade.bloodmagic.repair", "Repairing"); add("living_upgrade.bloodmagic.slowness", "Limp Leg"); diff --git a/src/main/java/wayoftime/bloodmagic/common/item/ItemLivingArmor.java b/src/main/java/wayoftime/bloodmagic/common/item/ItemLivingArmor.java index 5a2cb76c..3830ad32 100644 --- a/src/main/java/wayoftime/bloodmagic/common/item/ItemLivingArmor.java +++ b/src/main/java/wayoftime/bloodmagic/common/item/ItemLivingArmor.java @@ -2,6 +2,7 @@ package wayoftime.bloodmagic.common.item; import java.util.List; import java.util.UUID; +import java.util.function.Consumer; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; @@ -53,6 +54,32 @@ public class ItemLivingArmor extends ArmorItem implements ILivingContainer, Expa } } + @Override + public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) + { + return repair.getItem() == BloodMagicItems.REAGENT_BINDING.get() || super.getIsRepairable(toRepair, repair); + } + +// @Override +// public void setDamage(ItemStack stack, int damage) +// { +// this.damageItem(stack, amount, entity, onBroken) +// if (this.slot != EquipmentSlotType.CHEST) +// { +// return; +// } +// if (damage >= this.getMaxDamage(stack)) +// { +// super.setDamage(stack, this.getMaxDamage(stack) - 1); +// } +// } + + @Override + public int damageItem(ItemStack stack, int amount, T entity, Consumer onBroken) + { + return Math.min((stack.getMaxDamage() - 1) - stack.getDamage() - amount, 0); + } + @Override public Multimap getAttributeModifiers(EquipmentSlotType slot, ItemStack stack) { diff --git a/src/main/java/wayoftime/bloodmagic/common/recipe/TartaricForgeRecipeProvider.java b/src/main/java/wayoftime/bloodmagic/common/recipe/TartaricForgeRecipeProvider.java index 63bd6a20..d7f6c862 100644 --- a/src/main/java/wayoftime/bloodmagic/common/recipe/TartaricForgeRecipeProvider.java +++ b/src/main/java/wayoftime/bloodmagic/common/recipe/TartaricForgeRecipeProvider.java @@ -42,6 +42,7 @@ public class TartaricForgeRecipeProvider implements ISubRecipeProvider TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_FAST_MINER.get()), 128, 20, Ingredient.fromItems(Items.IRON_PICKAXE), Ingredient.fromItems(Items.IRON_AXE), Ingredient.fromItems(Items.IRON_SHOVEL), Ingredient.fromTag(Tags.Items.GUNPOWDER)).build(consumer, BloodMagic.rl(basePath + "reagent_fastminer")); TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_BLOOD_LIGHT.get()), 300, 10, Ingredient.fromTag(Tags.Items.DUSTS_GLOWSTONE), Ingredient.fromItems(Items.TORCH), Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE), Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE)).build(consumer, BloodMagic.rl(basePath + "reagent_blood_light")); TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_SIGHT.get()), 64, 0, Ingredient.fromTag(Tags.Items.DUSTS_GLOWSTONE), Ingredient.fromTag(Tags.Items.GLASS), Ingredient.fromTag(Tags.Items.GLASS), Ingredient.fromItems(BloodMagicItems.DIVINATION_SIGIL.get())).build(consumer, BloodMagic.rl(basePath + "reagent_sight")); + TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_BINDING.get()), 400, 10, Ingredient.fromTag(Tags.Items.DUSTS_GLOWSTONE), Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE), Ingredient.fromTag(Tags.Items.GUNPOWDER), Ingredient.fromTag(Tags.Items.NUGGETS_GOLD)).build(consumer, BloodMagic.rl(basePath + "reagent_binding")); TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicBlocks.DEMON_CRUCIBLE.get()), 400, 100, Ingredient.fromItems(Items.CAULDRON), Ingredient.fromTag(Tags.Items.STONE), Ingredient.fromTag(Tags.Items.GEMS_LAPIS), Ingredient.fromTag(Tags.Items.GEMS_DIAMOND)).build(consumer, BloodMagic.rl(basePath + "demon_crucible")); TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicBlocks.DEMON_CRYSTALLIZER.get()), 500, 100, Ingredient.fromItems(BloodMagicBlocks.SOUL_FORGE.get()), Ingredient.fromTag(Tags.Items.STONE), Ingredient.fromTag(Tags.Items.GEMS_LAPIS), Ingredient.fromTag(Tags.Items.GLASS)).build(consumer, BloodMagic.rl(basePath + "demon_crystallizer")); diff --git a/src/main/java/wayoftime/bloodmagic/core/LivingArmorRegistrar.java b/src/main/java/wayoftime/bloodmagic/core/LivingArmorRegistrar.java index 073bf884..d49a8619 100644 --- a/src/main/java/wayoftime/bloodmagic/core/LivingArmorRegistrar.java +++ b/src/main/java/wayoftime/bloodmagic/core/LivingArmorRegistrar.java @@ -12,6 +12,7 @@ import com.google.gson.GsonBuilder; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.ai.attributes.Attributes; +import net.minecraft.util.DamageSource; import net.minecraft.util.ResourceLocation; import wayoftime.bloodmagic.BloodMagic; import wayoftime.bloodmagic.common.registration.impl.LivingUpgradeDeferredRegister; @@ -77,6 +78,27 @@ public class LivingArmorRegistrar } return 0; })); + public static final LivingUpgradeRegistryObject UPGRADE_FALL_PROTECT = UPGRADES.register("fall_protect", () -> parseDefinition("fall_protect").withArmorProvider((player, stats, source, upgrade, level) -> { + if (source == DamageSource.FALL) + { + return upgrade.getBonusValue("protection", level).doubleValue(); + } + return 0; + })); + public static final LivingUpgradeRegistryObject UPGRADE_PHYSICAL_PROTECT = UPGRADES.register("physical_protect", () -> parseDefinition("physical_protect").withArmorProvider((player, stats, source, upgrade, level) -> { + if (!source.isProjectile()) + { + return upgrade.getBonusValue("protection", level).doubleValue(); + } + return 0; + })); + public static final LivingUpgradeRegistryObject UPGRADE_JUMP = UPGRADES.register("jump", () -> parseDefinition("jump").withArmorProvider((player, stats, source, upgrade, level) -> { + if (source == DamageSource.FALL) + { + return upgrade.getBonusValue("fall", level).doubleValue(); + } + return 0; + })); public static final LivingUpgradeRegistryObject UPGRADE_HEALTH = UPGRADES.register("health", () -> parseDefinition("health").withAttributeProvider((stats, attributeMap, uuid, upgrade, level) -> { attributeMap.put(Attributes.MAX_HEALTH, new AttributeModifier(uuid, "Health Modifier", upgrade.getBonusValue("hp", level).intValue(), AttributeModifier.Operation.ADDITION)); @@ -95,8 +117,12 @@ public class LivingArmorRegistrar attributeMap.put(Attributes.MOVEMENT_SPEED, new AttributeModifier(uuid, "Movement Modifier 2", upgrade.getBonusValue("speed_modifier", level).doubleValue(), AttributeModifier.Operation.MULTIPLY_BASE)); })); public static final LivingUpgradeRegistryObject UPGRADE_POISON_RESIST = UPGRADES.register("poison_resist", () -> parseDefinition("poison_resist")); + public static final LivingUpgradeRegistryObject UPGRADE_FIRE_RESIST = UPGRADES.register("fire_resist", () -> parseDefinition("fire_resist")); public static final LivingUpgradeRegistryObject UPGRADE_DIGGING = UPGRADES.register("digging", () -> parseDefinition("digging")); - + public static final LivingUpgradeRegistryObject UPGRADE_KNOCKBACK_RESIST = UPGRADES.register("knockback_resist", () -> parseDefinition("knockback_resist").withAttributeProvider((stats, attributeMap, uuid, upgrade, level) -> { + attributeMap.put(Attributes.KNOCKBACK_RESISTANCE, new AttributeModifier(uuid, "KB Modifier", upgrade.getBonusValue("kb", level).doubleValue(), AttributeModifier.Operation.ADDITION)); + attributeMap.put(Attributes.MAX_HEALTH, new AttributeModifier(uuid, "Health Modifier 2", upgrade.getBonusValue("hp", level).intValue(), AttributeModifier.Operation.ADDITION)); + })); // public static final LivingUpgrade UPGRADE_ARROW_PROTECT = parseDefinition("arrow_protect").withArmorProvider((player, stats, source, upgrade, level) -> { // if (source.isProjectile()) // { @@ -122,6 +148,11 @@ public class LivingArmorRegistrar registerUpgrade(UPGRADE_SPEED.get()); registerUpgrade(UPGRADE_POISON_RESIST.get()); registerUpgrade(UPGRADE_DIGGING.get()); + registerUpgrade(UPGRADE_FALL_PROTECT.get()); + registerUpgrade(UPGRADE_PHYSICAL_PROTECT.get()); + registerUpgrade(UPGRADE_JUMP.get()); + registerUpgrade(UPGRADE_KNOCKBACK_RESIST.get()); + registerUpgrade(UPGRADE_FIRE_RESIST.get()); // Registry.register(UPGRADES, UPGRADE_ARROW_PROTECT.getKey(), UPGRADE_ARROW_PROTECT); // Registry.register(UPGRADES, UPGRADE_ARROW_SHOT.getKey(), UPGRADE_ARROW_SHOT); // Registry.register(UPGRADES, UPGRADE_CRITICAL_STRIKE.getKey(), UPGRADE_CRITICAL_STRIKE); diff --git a/src/main/java/wayoftime/bloodmagic/core/living/LivingStats.java b/src/main/java/wayoftime/bloodmagic/core/living/LivingStats.java index 3c383b57..3e158c7d 100644 --- a/src/main/java/wayoftime/bloodmagic/core/living/LivingStats.java +++ b/src/main/java/wayoftime/bloodmagic/core/living/LivingStats.java @@ -51,6 +51,19 @@ public class LivingStats return this; } + public LivingStats resetExperience(ResourceLocation key) + { + LivingUpgrade upgrade = LivingArmorRegistrar.UPGRADE_MAP.getOrDefault(key, LivingUpgrade.DUMMY); + double current = upgrades.getOrDefault(upgrade, 0d); + + if (upgrade.getNextRequirement((int) current) == 0) + return this; + + upgrades.put(upgrade, 0d); + + return this; + } + public int getLevel(ResourceLocation key) { LivingUpgrade upgrade = LivingArmorRegistrar.UPGRADE_MAP.getOrDefault(key, LivingUpgrade.DUMMY); diff --git a/src/main/java/wayoftime/bloodmagic/ritual/types/RitualArmourEvolve.java b/src/main/java/wayoftime/bloodmagic/ritual/types/RitualArmourEvolve.java new file mode 100644 index 00000000..c850b3d2 --- /dev/null +++ b/src/main/java/wayoftime/bloodmagic/ritual/types/RitualArmourEvolve.java @@ -0,0 +1,110 @@ +package wayoftime.bloodmagic.ritual.types; + +import java.util.List; +import java.util.function.Consumer; + +import net.minecraft.entity.EntityType; +import net.minecraft.entity.effect.LightningBoltEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.EquipmentSlotType; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import wayoftime.bloodmagic.BloodMagic; +import wayoftime.bloodmagic.core.living.LivingStats; +import wayoftime.bloodmagic.core.living.LivingUtil; +import wayoftime.bloodmagic.ritual.AreaDescriptor; +import wayoftime.bloodmagic.ritual.EnumRuneType; +import wayoftime.bloodmagic.ritual.IMasterRitualStone; +import wayoftime.bloodmagic.ritual.Ritual; +import wayoftime.bloodmagic.ritual.RitualComponent; +import wayoftime.bloodmagic.ritual.RitualRegister; + +@RitualRegister("armour_evolve") +public class RitualArmourEvolve extends Ritual +{ + public static final String CHECK_RANGE = "fillRange"; + + public RitualArmourEvolve() + { + super("ritualArmourEvolve", 2, 50000, "ritual." + BloodMagic.MODID + ".armourEvolveRitual"); + addBlockRange(CHECK_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1, 2, 1)); + } + + @Override + public void performRitual(IMasterRitualStone masterRitualStone) + { + World world = masterRitualStone.getWorldObj(); + + if (world.isRemote) + { + return; + } + + BlockPos pos = masterRitualStone.getBlockPos(); + + AreaDescriptor checkRange = masterRitualStone.getBlockRange(CHECK_RANGE); + + List playerList = world.getEntitiesWithinAABB(PlayerEntity.class, checkRange.getAABB(pos)); + + for (PlayerEntity player : playerList) + { + if (LivingUtil.hasFullSet(player)) + { + ItemStack chestStack = player.getItemStackFromSlot(EquipmentSlotType.CHEST); + LivingStats stats = LivingStats.fromPlayer(player); + + if (stats.getMaxPoints() < 300) + { + stats.setMaxPoints(300); + LivingStats.toPlayer(player, stats); +// ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true); + + masterRitualStone.setActive(false); + + LightningBoltEntity lightningboltentity = EntityType.LIGHTNING_BOLT.create(world); +// LightningBoltEntity lightning = new LightningBoltEntity(world, pos.getX() + dispX, pos.getY(), pos.getZ() + dispZ); + lightningboltentity.setPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); +// lightningboltentity.setEffectOnly(true); + world.addEntity(lightningboltentity); + } + + } + } + } + + @Override + public int getRefreshTime() + { + return 1; + } + + @Override + public int getRefreshCost() + { + return 0; + } + + @Override + public void gatherComponents(Consumer components) + { + addCornerRunes(components, 1, 0, EnumRuneType.DUSK); + addCornerRunes(components, 2, 0, EnumRuneType.FIRE); + addOffsetRunes(components, 1, 2, 0, EnumRuneType.FIRE); + addCornerRunes(components, 1, 1, EnumRuneType.DUSK); + addParallelRunes(components, 4, 0, EnumRuneType.EARTH); + addCornerRunes(components, 1, 3, EnumRuneType.DUSK); + addParallelRunes(components, 1, 4, EnumRuneType.EARTH); + + for (int i = 0; i < 4; i++) + { + addCornerRunes(components, 3, i, EnumRuneType.EARTH); + } + } + + @Override + public Ritual getNewCopy() + { + return new RitualArmourEvolve(); + } +} \ No newline at end of file diff --git a/src/main/java/wayoftime/bloodmagic/ritual/types/RitualEllipsoid.java b/src/main/java/wayoftime/bloodmagic/ritual/types/RitualEllipsoid.java new file mode 100644 index 00000000..1587145d --- /dev/null +++ b/src/main/java/wayoftime/bloodmagic/ritual/types/RitualEllipsoid.java @@ -0,0 +1,272 @@ +package wayoftime.bloodmagic.ritual.types; + +import java.util.function.Consumer; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.item.BlockItem; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Direction; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.IItemHandler; +import wayoftime.bloodmagic.BloodMagic; +import wayoftime.bloodmagic.ritual.AreaDescriptor; +import wayoftime.bloodmagic.ritual.EnumRuneType; +import wayoftime.bloodmagic.ritual.IMasterRitualStone; +import wayoftime.bloodmagic.ritual.Ritual; +import wayoftime.bloodmagic.ritual.RitualComponent; +import wayoftime.bloodmagic.ritual.RitualRegister; + +@RitualRegister("ellipsoid") +public class RitualEllipsoid extends Ritual +{ + public static final String SPHEROID_RANGE = "spheroidRange"; + public static final String CHEST_RANGE = "chest"; + + private boolean cached = false; + private BlockPos currentPos; // Offset + + public RitualEllipsoid() + { + super("ritualEllipsoid", 0, 20000, "ritual." + BloodMagic.MODID + ".ellipseRitual"); + addBlockRange(SPHEROID_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-10, -10, -10), new BlockPos(11, 11, 11))); + addBlockRange(CHEST_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1)); + + setMaximumVolumeAndDistanceOfRange(SPHEROID_RANGE, 0, 32, 32); + setMaximumVolumeAndDistanceOfRange(CHEST_RANGE, 1, 3, 3); + } + + @Override + public void performRitual(IMasterRitualStone masterRitualStone) + { + World world = masterRitualStone.getWorldObj(); + int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); + + BlockPos masterPos = masterRitualStone.getBlockPos(); + AreaDescriptor chestRange = masterRitualStone.getBlockRange(CHEST_RANGE); + TileEntity tileInventory = world.getTileEntity(chestRange.getContainedPositions(masterPos).get(0)); + + if (currentEssence < getRefreshCost()) + { + masterRitualStone.getOwnerNetwork().causeNausea(); + return; + } + + AreaDescriptor sphereRange = masterRitualStone.getBlockRange(SPHEROID_RANGE); + AxisAlignedBB sphereBB = sphereRange.getAABB(masterPos); + int minX = (int) (masterPos.getX() - sphereBB.minX); + int maxX = (int) (sphereBB.maxX - masterPos.getX()) - 1; + int minY = (int) (masterPos.getY() - sphereBB.minY); + int maxY = (int) (sphereBB.maxY - masterPos.getY()) - 1; + int minZ = (int) (masterPos.getZ() - sphereBB.minZ); + int maxZ = (int) (sphereBB.maxZ - masterPos.getZ()) - 1; + + if (tileInventory != null) + { +// System.out.println("Tile"); + if (tileInventory.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN).isPresent()) + { +// System.out.println("Have inv"); + IItemHandler itemHandler = tileInventory.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN).resolve().get(); + + if (itemHandler.getSlots() <= 0) + { + return; + } + + int blockSlot = -1; + for (int invSlot = 0; invSlot < itemHandler.getSlots(); invSlot++) + { + ItemStack stack = itemHandler.extractItem(invSlot, 1, true); + if (stack.isEmpty() || !(stack.getItem() instanceof BlockItem)) + continue; + + blockSlot = invSlot; + break; + } + +// System.out.println("Block slot: " + blockSlot); + + if (blockSlot == -1) + { + return; + } + + int xR = Math.max(maxX, minX); + int yR = Math.max(maxY, minY); + int zR = Math.max(maxZ, minZ); + + int j = -minX; + int i = -minY; + int k = -minZ; + + if (currentPos != null) + { + j = currentPos.getY(); + i = Math.min(xR, Math.max(-minX, currentPos.getX())); + k = Math.min(zR, Math.max(-minZ, currentPos.getZ())); + } + int checks = 0; + int maxChecks = 100; + + while (j <= maxY) + { + while (i <= maxX) + { + while (k <= maxZ) + { + checks++; + if (checks >= maxChecks) + { + this.currentPos = new BlockPos(i, j, k); +// System.out.println(this.currentPos); + return; + } + + if (checkIfEllipsoidShell(xR, yR, zR, i, j, k)) + { + BlockPos newPos = masterPos.add(i, j, k); +// + if (!world.isAirBlock(newPos)) + { + k++; + continue; + } + + BlockState placeState = Block.getBlockFromItem(itemHandler.getStackInSlot(blockSlot).getItem()).getDefaultState(); + world.setBlockState(newPos, placeState); + + itemHandler.extractItem(blockSlot, 1, false); + tileInventory.markDirty(); + // TODO: + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost())); + k++; + this.currentPos = new BlockPos(i, j, k); +// System.out.println(this.currentPos); + return; + } + k++; + } + i++; + k = -minZ; + } + j++; + i = -minX; + this.currentPos = new BlockPos(i, j, k); + return; + } + + j = -minY; + this.currentPos = new BlockPos(i, j, k); + return; + } + } + } + + public boolean checkIfEllipsoidShell(int xR, int yR, int zR, int xOff, int yOff, int zOff) + { + // Checking shell in the x-direction + if (!checkIfEllipsoid(xR, yR, zR, xOff, yOff, zOff)) + { + return false; + } + + return !((checkIfEllipsoid(xR, yR, zR, xOff + 1, yOff, zOff) && checkIfEllipsoid(xR, yR, zR, xOff - 1, yOff, zOff)) && (checkIfEllipsoid(xR, yR, zR, xOff, yOff + 1, zOff) && checkIfEllipsoid(xR, yR, zR, xOff, yOff - 1, zOff)) && (checkIfEllipsoid(xR, yR, zR, xOff, yOff, zOff + 1) && checkIfEllipsoid(xR, yR, zR, xOff, yOff, zOff - 1))); +// if (xOff * xOff + yOff * yOff + zOff * zOff >= (xR - 0.5) * (xR - 0.5) && xOff * xOff + yOff * yOff + zOff * zOff <= (xR + 0.5) * (xR + 0.5)) +// if (checkIfEllipsoid(xR, yR, zR, xOff, yOff, zOff)) +// { +// if (xOff * xOff / ((xR - 0.5) * (xR - 0.5)) + yOff * yOff / ((yR - 0.5) * (yR - 0.5)) >= 1 - zOff * zOff / ((zR + possOffset) * (zR + possOffset))) +// { +// return true; +// } +// +// if (xOff * xOff / ((xR - 0.5) * (xR - 0.5)) + zOff * zOff / ((zR - 0.5) * (zR - 0.5)) >= 1 - yOff * yOff / ((yR + possOffset) * (yR + possOffset))) +// { +// return true; +// } +// +// if (zOff * zOff / ((zR - 0.5) * (zR - 0.5)) + yOff * yOff / ((yR - 0.5) * (yR - 0.5)) >= 1 - xOff * xOff / ((xR + possOffset) * (xR + possOffset))) +// { +// return true; +// } +// } +// return false; + } + + public boolean checkIfEllipsoid(float xR, float yR, float zR, float xOff, float yOff, float zOff) + { + float possOffset = 0.5f; + return xOff * xOff / ((xR + possOffset) * (xR + possOffset)) + yOff * yOff / ((yR + possOffset) * (yR + possOffset)) + zOff * zOff / ((zR + possOffset) * (zR + possOffset)) <= 1; + } + + @Override + public int getRefreshCost() + { + return 10;// Temporary + } + + @Override + public int getRefreshTime() + { + return 1; + } + +// @Override +// public void readFromNBT(NBTTagCompound tag) +// { +// super.readFromNBT(tag); +// tag +// } + + @Override + public void gatherComponents(Consumer components) + { + addCornerRunes(components, 1, 0, EnumRuneType.DUSK); + + addRune(components, 4, 0, 0, EnumRuneType.FIRE); + addRune(components, 5, 0, 0, EnumRuneType.FIRE); + addRune(components, 5, 0, -1, EnumRuneType.FIRE); + addRune(components, 5, 0, -2, EnumRuneType.FIRE); + addRune(components, -4, 0, 0, EnumRuneType.FIRE); + addRune(components, -5, 0, 0, EnumRuneType.FIRE); + addRune(components, -5, 0, 1, EnumRuneType.FIRE); + addRune(components, -5, 0, 2, EnumRuneType.FIRE); + + addRune(components, 0, 0, 4, EnumRuneType.AIR); + addRune(components, 0, 0, 5, EnumRuneType.AIR); + addRune(components, 1, 0, 5, EnumRuneType.AIR); + addRune(components, 2, 0, 5, EnumRuneType.AIR); + addRune(components, 0, 0, -4, EnumRuneType.AIR); + addRune(components, 0, 0, -5, EnumRuneType.AIR); + addRune(components, -1, 0, -5, EnumRuneType.AIR); + addRune(components, -2, 0, -5, EnumRuneType.AIR); + + addRune(components, 3, 0, 1, EnumRuneType.EARTH); + addRune(components, 3, 0, 2, EnumRuneType.EARTH); + addRune(components, 3, 0, 3, EnumRuneType.EARTH); + addRune(components, 2, 0, 3, EnumRuneType.EARTH); + addRune(components, -3, 0, -1, EnumRuneType.EARTH); + addRune(components, -3, 0, -2, EnumRuneType.EARTH); + addRune(components, -3, 0, -3, EnumRuneType.EARTH); + addRune(components, -2, 0, -3, EnumRuneType.EARTH); + + addRune(components, 1, 0, -3, EnumRuneType.WATER); + addRune(components, 2, 0, -3, EnumRuneType.WATER); + addRune(components, 3, 0, -3, EnumRuneType.WATER); + addRune(components, 3, 0, -2, EnumRuneType.WATER); + addRune(components, -1, 0, 3, EnumRuneType.WATER); + addRune(components, -2, 0, 3, EnumRuneType.WATER); + addRune(components, -3, 0, 3, EnumRuneType.WATER); + addRune(components, -3, 0, 2, EnumRuneType.WATER); + } + + @Override + public Ritual getNewCopy() + { + return new RitualEllipsoid(); + } +} diff --git a/src/main/java/wayoftime/bloodmagic/ritual/types/RitualUpgradeRemove.java b/src/main/java/wayoftime/bloodmagic/ritual/types/RitualUpgradeRemove.java new file mode 100644 index 00000000..3d283ead --- /dev/null +++ b/src/main/java/wayoftime/bloodmagic/ritual/types/RitualUpgradeRemove.java @@ -0,0 +1,170 @@ +package wayoftime.bloodmagic.ritual.types; + +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.function.Consumer; + +import net.minecraft.entity.EntityType; +import net.minecraft.entity.effect.LightningBoltEntity; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.EquipmentSlotType; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import wayoftime.bloodmagic.BloodMagic; +import wayoftime.bloodmagic.common.item.BloodMagicItems; +import wayoftime.bloodmagic.core.living.ILivingContainer; +import wayoftime.bloodmagic.core.living.LivingStats; +import wayoftime.bloodmagic.core.living.LivingUpgrade; +import wayoftime.bloodmagic.core.living.LivingUtil; +import wayoftime.bloodmagic.ritual.AreaDescriptor; +import wayoftime.bloodmagic.ritual.EnumRuneType; +import wayoftime.bloodmagic.ritual.IMasterRitualStone; +import wayoftime.bloodmagic.ritual.Ritual; +import wayoftime.bloodmagic.ritual.RitualComponent; +import wayoftime.bloodmagic.ritual.RitualRegister; + +@RitualRegister("upgrade_remove") +public class RitualUpgradeRemove extends Ritual +{ + public static final String CHECK_RANGE = "fillRange"; + + public RitualUpgradeRemove() + { + super("ritualUpgradeRemove", 2, 25000, "ritual." + BloodMagic.MODID + ".upgradeRemoveRitual"); + addBlockRange(CHECK_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1, 2, 1)); + } + + @Override + public void performRitual(IMasterRitualStone masterRitualStone) + { + World world = masterRitualStone.getWorldObj(); + + if (world.isRemote) + { + return; + } + + BlockPos pos = masterRitualStone.getBlockPos(); + + AreaDescriptor checkRange = masterRitualStone.getBlockRange(CHECK_RANGE); + + List playerList = world.getEntitiesWithinAABB(PlayerEntity.class, checkRange.getAABB(pos)); + + for (PlayerEntity player : playerList) + { + if (LivingUtil.hasFullSet(player)) + { + boolean removedUpgrade = false; + + ItemStack chestStack = player.getItemStackFromSlot(EquipmentSlotType.CHEST); + LivingStats stats = LivingStats.fromPlayer(player); + if (stats != null) + { + Map upgrades = stats.getUpgrades(); + + for (Entry entry : upgrades.entrySet()) + { + int exp = entry.getValue().intValue(); + LivingUpgrade upgrade = entry.getKey(); + int level = upgrade.getLevel(exp); + if (level >= 1) + { + ItemStack upgradeStack = new ItemStack(BloodMagicItems.LIVING_TOME.get()); +// int expForLevel = upgrade.getNextRequirement(upgrade.getLevel(exp) - 1); + ((ILivingContainer) BloodMagicItems.LIVING_TOME.get()).updateLivingStats(upgradeStack, new LivingStats().setMaxPoints(upgrade.getLevelCost(exp)).addExperience(upgrade.getKey(), exp)); + ItemEntity item = new ItemEntity(world, player.getPosX(), player.getPosY(), player.getPosZ(), upgradeStack); + world.addEntity(item); + removedUpgrade = true; + } + stats.resetExperience(upgrade.getKey()); + } + +// @SuppressWarnings("unchecked") +// HashMap upgradeMap = (HashMap) armour.upgradeMap.clone(); +// +// for (Entry entry : upgradeMap.entrySet()) +// { +// LivingArmourUpgrade upgrade = entry.getValue(); +// String upgradeKey = entry.getKey(); +// +// ItemStack upgradeStack = new ItemStack(RegistrarBloodMagicItems.UPGRADE_TOME); +// LivingUpgrades.setKey(upgradeStack, upgradeKey); +// LivingUpgrades.setLevel(upgradeStack, upgrade.getUpgradeLevel()); +// +// boolean successful = armour.removeUpgrade(player, upgrade); +// +// if (successful) +// { +// removedUpgrade = true; +// world.spawnEntity(new ItemEntity(world, player.posX, player.posY, player.posZ, upgradeStack)); +// for (Entry trackerEntry : armour.trackerMap.entrySet()) +// { +// StatTracker tracker = trackerEntry.getValue(); +// if (tracker != null) +// { +// if (tracker.providesUpgrade(upgradeKey)) +// { +// tracker.resetTracker(); // Resets the tracker if the upgrade corresponding to it +// // was removed. +// } +// } +// } +// } +// } + + if (removedUpgrade) + { + LivingStats.toPlayer(player, stats); + + masterRitualStone.setActive(false); + + LightningBoltEntity lightningboltentity = EntityType.LIGHTNING_BOLT.create(world); +// LightningBoltEntity lightning = new LightningBoltEntity(world, pos.getX() + dispX, pos.getY(), pos.getZ() + dispZ); + lightningboltentity.setPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); + lightningboltentity.setEffectOnly(true); + world.addEntity(lightningboltentity); + } + + } + } + } + } + + @Override + public int getRefreshTime() + { + return 1; + } + + @Override + public int getRefreshCost() + { + return 0; + } + + @Override + public void gatherComponents(Consumer components) + { + addCornerRunes(components, 1, 0, EnumRuneType.DUSK); + addCornerRunes(components, 2, 0, EnumRuneType.FIRE); + addOffsetRunes(components, 1, 2, 0, EnumRuneType.FIRE); + addCornerRunes(components, 1, 1, EnumRuneType.WATER); + addParallelRunes(components, 4, 0, EnumRuneType.EARTH); + addCornerRunes(components, 1, 3, EnumRuneType.WATER); + addParallelRunes(components, 1, 4, EnumRuneType.AIR); + + for (int i = 0; i < 4; i++) + { + addCornerRunes(components, 3, i, EnumRuneType.EARTH); + } + } + + @Override + public Ritual getNewCopy() + { + return new RitualUpgradeRemove(); + } +} \ No newline at end of file diff --git a/src/main/java/wayoftime/bloodmagic/util/handler/event/GenericHandler.java b/src/main/java/wayoftime/bloodmagic/util/handler/event/GenericHandler.java index 26b70160..e8cb60a0 100644 --- a/src/main/java/wayoftime/bloodmagic/util/handler/event/GenericHandler.java +++ b/src/main/java/wayoftime/bloodmagic/util/handler/event/GenericHandler.java @@ -15,12 +15,14 @@ import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; +import net.minecraft.util.DamageSource; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.Tags; import net.minecraftforge.common.ToolType; import net.minecraftforge.event.entity.living.LivingDamageEvent; import net.minecraftforge.event.entity.living.LivingEvent; +import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.event.entity.living.LivingHealEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; @@ -177,6 +179,10 @@ public class GenericHandler LivingUtil.applyNewExperience(player, LivingArmorRegistrar.UPGRADE_ARROW_PROTECT.get(), event.getAmount()); } + if (event.getSource() == DamageSource.FALL) + { + LivingUtil.applyNewExperience(player, LivingArmorRegistrar.UPGRADE_FALL_PROTECT.get(), event.getAmount()); + } } } } @@ -319,6 +325,7 @@ public class GenericHandler public static Map posXMap = new HashMap<>(); public static Map posZMap = new HashMap<>(); + public static Map foodMap = new HashMap<>(); @SubscribeEvent(priority = EventPriority.HIGHEST) public void onEntityUpdate(LivingEvent.LivingUpdateEvent event) @@ -354,6 +361,13 @@ public class GenericHandler distance = Math.sqrt((player.getPosX() - posXMap.get(player.getUniqueID())) * (player.getPosX() - posXMap.get(player.getUniqueID())) + (player.getPosZ() - posZMap.get(player.getUniqueID())) * (player.getPosZ() - posZMap.get(player.getUniqueID()))); } + int currentFood = player.getFoodStats().getFoodLevel(); + if (foodMap.getOrDefault(player.getUniqueID(), 20) < currentFood) + { + LivingUtil.applyNewExperience(player, LivingArmorRegistrar.UPGRADE_KNOCKBACK_RESIST.get(), currentFood - foodMap.getOrDefault(player.getUniqueID(), 20)); + foodMap.put(player.getUniqueID(), currentFood); + } + // System.out.println("Distance travelled: " + distance); if (player.isOnGround() && distance > 0 && distance < 50) { @@ -361,6 +375,34 @@ public class GenericHandler LivingUtil.applyNewExperience(player, LivingArmorRegistrar.UPGRADE_SPEED.get(), distance); } + if (player.getFireTimer() > 0) + { + LivingUtil.applyNewExperience(player, LivingArmorRegistrar.UPGRADE_FIRE_RESIST.get(), 1); + int fireLevel = stats.getLevel(LivingArmorRegistrar.UPGRADE_FIRE_RESIST.get().getKey()); + if (fireLevel > 0) + { + boolean hasChanged = false; + int fireCooldown = chestStack.getTag().getInt("fire_cooldown"); + if (fireCooldown > 0) + { + fireCooldown--; + hasChanged = true; + } + + if (player.getFireTimer() > 0 && fireCooldown <= 0) + { + fireCooldown = LivingArmorRegistrar.UPGRADE_FIRE_RESIST.get().getBonusValue("cooldown_time", fireLevel).intValue(); + player.addPotionEffect(new EffectInstance(Effects.FIRE_RESISTANCE, LivingArmorRegistrar.UPGRADE_FIRE_RESIST.get().getBonusValue("resist_duration", fireLevel).intValue(), 0, true, false)); + hasChanged = true; + } + + if (hasChanged) + { + chestStack.getTag().putInt("fire_cooldown", fireCooldown); + } + } + } + int poisonLevel = stats.getLevel(LivingArmorRegistrar.UPGRADE_POISON_RESIST.get().getKey()); if (player.isPotionActive(Effects.POISON)) { @@ -376,9 +418,6 @@ public class GenericHandler hasChanged = true; } -// System.out.println("Cooldown: " + poisonCooldown); -// System.out.println(LivingArmorRegistrar.UPGRADE_POISON_RESIST.get().getBonusValue("max_cure", poisonLevel).intValue()); - if (player.isPotionActive(Effects.POISON) && poisonCooldown <= 0 && LivingArmorRegistrar.UPGRADE_POISON_RESIST.get().getBonusValue("max_cure", poisonLevel).intValue() >= player.getActivePotionEffect(Effects.POISON).getAmplifier()) { poisonCooldown = LivingArmorRegistrar.UPGRADE_POISON_RESIST.get().getBonusValue("cooldown", poisonLevel).intValue(); @@ -426,6 +465,7 @@ public class GenericHandler { if (LivingUtil.hasFullSet(player)) { + LivingStats stats = LivingStats.fromPlayer(player); LivingUtil.applyNewExperience(player, LivingArmorRegistrar.UPGRADE_DIGGING.get(), 1); int mineTime = LivingArmorRegistrar.UPGRADE_DIGGING.get().getBonusValue("speed_time", stats.getLevel(LivingArmorRegistrar.UPGRADE_DIGGING.get().getKey())).intValue(); @@ -436,4 +476,24 @@ public class GenericHandler } } } + + @SubscribeEvent + public void onJump(LivingJumpEvent event) + { + if (event.getEntityLiving() instanceof PlayerEntity) + { + PlayerEntity player = (PlayerEntity) event.getEntityLiving(); + + if (LivingUtil.hasFullSet(player)) + { + LivingUtil.applyNewExperience(player, LivingArmorRegistrar.UPGRADE_JUMP.get(), 1); + if (!player.isSneaking()) + { + LivingStats stats = LivingStats.fromPlayer(player); + double jumpModifier = LivingArmorRegistrar.UPGRADE_JUMP.get().getBonusValue("jump", stats.getLevel(LivingArmorRegistrar.UPGRADE_JUMP.get().getKey())).doubleValue(); + player.setMotion(player.getMotion().add(0, jumpModifier, 0)); + } + } + } + } } diff --git a/src/main/resources/data/bloodmagic/living_armor/jump.json b/src/main/resources/data/bloodmagic/living_armor/jump.json index 57865813..65ea0465 100644 --- a/src/main/resources/data/bloodmagic/living_armor/jump.json +++ b/src/main/resources/data/bloodmagic/living_armor/jump.json @@ -1,16 +1,16 @@ { "id": "bloodmagic:jump", "levels": [ - { "xp": 10, "cost": 3 }, - { "xp": 20, "cost": 6 }, - { "xp": 30, "cost": 11 }, - { "xp": 40, "cost": 23 }, - { "xp": 40, "cost": 37 }, - { "xp": 40, "cost": 50 }, - { "xp": 40, "cost": 70 }, - { "xp": 40, "cost": 100 }, - { "xp": 40, "cost": 140 }, - { "xp": 40, "cost": 200 } + { "xp": 30, "cost": 3 }, + { "xp": 200, "cost": 6 }, + { "xp": 400, "cost": 11 }, + { "xp": 700, "cost": 23 }, + { "xp": 1100, "cost": 37 }, + { "xp": 1500, "cost": 50 }, + { "xp": 2000, "cost": 70 }, + { "xp": 2800, "cost": 100 }, + { "xp": 3600, "cost": 140 }, + { "xp": 5000, "cost": 200 } ], "bonuses": { "jump": [