From 953bac92986e00ad3e3aab5fe68fb24b7a5fac84 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Sat, 5 Dec 2020 11:26:01 -0500 Subject: [PATCH] Added a few more upgrades to the Living Armour ... Wait, was I supposed to put something in here? --- src/generated/resources/.cache/cache | 1 + .../bloodmagic/recipes/array/movement.json | 13 +++ .../java/wayoftime/bloodmagic/BloodMagic.java | 2 + .../bloodmagic/client/ClientEvents.java | 3 + .../alchemyarray/AlchemyArrayRenderer.java | 3 +- .../StaticAlchemyCircleRenderer.java | 98 +++++++++++++++++++ .../alchemyarray/AlchemyArrayEffect.java | 8 ++ .../AlchemyArrayEffectBinding.java | 1 - .../AlchemyArrayEffectMovement.java | 96 ++++++++++++++++++ .../common/block/BlockAlchemyArray.java | 11 +++ .../recipe/AlchemyArrayRecipeProvider.java | 2 + .../bloodmagic/core/LivingArmorRegistrar.java | 22 ++++- .../bloodmagic/core/living/LivingStats.java | 2 +- .../bloodmagic/core/living/LivingUtil.java | 2 +- .../core/registry/AlchemyArrayRegistry.java | 6 ++ .../bloodmagic/tile/TileAlchemyArray.java | 11 +++ .../util/handler/event/GenericHandler.java | 78 +++++++++++++-- .../data/bloodmagic/living_armor/digging.json | 18 ++-- .../bloodmagic/living_armor/grave_digger.json | 29 ++++++ .../living_armor/knockback_resist.json | 26 +++++ .../data/bloodmagic/living_armor/melee_damage | 29 ++++++ .../living_armor/physical_protect.json | 29 ++++++ .../living_armor/poison_resist.json | 26 +++++ 23 files changed, 493 insertions(+), 23 deletions(-) create mode 100644 src/generated/resources/data/bloodmagic/recipes/array/movement.json create mode 100644 src/main/java/wayoftime/bloodmagic/client/render/alchemyarray/StaticAlchemyCircleRenderer.java create mode 100644 src/main/java/wayoftime/bloodmagic/common/alchemyarray/AlchemyArrayEffectMovement.java create mode 100644 src/main/resources/data/bloodmagic/living_armor/grave_digger.json create mode 100644 src/main/resources/data/bloodmagic/living_armor/knockback_resist.json create mode 100644 src/main/resources/data/bloodmagic/living_armor/melee_damage create mode 100644 src/main/resources/data/bloodmagic/living_armor/physical_protect.json create mode 100644 src/main/resources/data/bloodmagic/living_armor/poison_resist.json diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index dcf6cb95..5c7fc244 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -577,6 +577,7 @@ f191a3c9982b827b0b2ba93164a81fc4f8cb0959 data/bloodmagic/recipes/array/growthsig 4a48885f110a87505381c7e2f2607d30612a3604 data/bloodmagic/recipes/array/living_leggings.json 5e3c6dd7bfcd16e79f17e963d8c1b59c0d1aebe9 data/bloodmagic/recipes/array/living_plate.json 8b1007de1b7fca5d27b54d7c9839cde9e47ab1c0 data/bloodmagic/recipes/array/magnetismsigil.json +7a674784e0d8d4f6f071a72d26ba677087976970 data/bloodmagic/recipes/array/movement.json 6fd91801759c6a7a018b9d18601fc3db4d3ee3b4 data/bloodmagic/recipes/array/seersigil.json cabe693e7c714203ad708a1068f302b3ee3120b0 data/bloodmagic/recipes/array/voidsigil.json 5e68d933fff631142a8dd819aee235d343d43cff data/bloodmagic/recipes/array/watersigil.json diff --git a/src/generated/resources/data/bloodmagic/recipes/array/movement.json b/src/generated/resources/data/bloodmagic/recipes/array/movement.json new file mode 100644 index 00000000..2d4f6309 --- /dev/null +++ b/src/generated/resources/data/bloodmagic/recipes/array/movement.json @@ -0,0 +1,13 @@ +{ + "type": "bloodmagic:array", + "texture": "bloodmagic:textures/models/alchemyarrays/movementarray.png", + "baseinput": { + "item": "minecraft:feather" + }, + "addedinput": { + "tag": "forge:dusts/redstone" + }, + "output": { + "item": "minecraft:air" + } +} \ No newline at end of file diff --git a/src/main/java/wayoftime/bloodmagic/BloodMagic.java b/src/main/java/wayoftime/bloodmagic/BloodMagic.java index aa513ef7..6334828d 100644 --- a/src/main/java/wayoftime/bloodmagic/BloodMagic.java +++ b/src/main/java/wayoftime/bloodmagic/BloodMagic.java @@ -51,6 +51,7 @@ import wayoftime.bloodmagic.common.registries.BloodMagicEntityTypes; import wayoftime.bloodmagic.common.registries.BloodMagicRecipeSerializers; import wayoftime.bloodmagic.core.LivingArmorRegistrar; import wayoftime.bloodmagic.core.recipe.IngredientBloodOrb; +import wayoftime.bloodmagic.core.registry.AlchemyArrayRegistry; import wayoftime.bloodmagic.core.registry.OrbRegistry; import wayoftime.bloodmagic.impl.BloodMagicAPI; import wayoftime.bloodmagic.impl.BloodMagicCorePlugin; @@ -168,6 +169,7 @@ public class BloodMagic RITUAL_MANAGER.discover(); ModRituals.initHarvestHandlers(); LivingArmorRegistrar.register(); + AlchemyArrayRegistry.registerBaseArrays(); } public void registerTileEntityTypes(RegistryEvent.Register> event) diff --git a/src/main/java/wayoftime/bloodmagic/client/ClientEvents.java b/src/main/java/wayoftime/bloodmagic/client/ClientEvents.java index 961d4ced..48b09e3d 100644 --- a/src/main/java/wayoftime/bloodmagic/client/ClientEvents.java +++ b/src/main/java/wayoftime/bloodmagic/client/ClientEvents.java @@ -21,6 +21,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import wayoftime.bloodmagic.BloodMagic; import wayoftime.bloodmagic.api.compat.IMultiWillTool; import wayoftime.bloodmagic.client.model.MimicColor; +import wayoftime.bloodmagic.client.render.alchemyarray.StaticAlchemyCircleRenderer; import wayoftime.bloodmagic.client.render.block.RenderAlchemyArray; import wayoftime.bloodmagic.client.render.block.RenderAltar; import wayoftime.bloodmagic.client.render.block.RenderDemonCrucible; @@ -35,6 +36,7 @@ import wayoftime.bloodmagic.common.item.ItemSacrificialDagger; import wayoftime.bloodmagic.common.item.sigil.ItemSigilToggleable; import wayoftime.bloodmagic.common.item.soul.ItemSentientSword; import wayoftime.bloodmagic.common.registries.BloodMagicEntityTypes; +import wayoftime.bloodmagic.core.registry.AlchemyArrayRendererRegistry; import wayoftime.bloodmagic.tile.TileAlchemyArray; import wayoftime.bloodmagic.tile.TileAltar; import wayoftime.bloodmagic.tile.TileDemonCrucible; @@ -99,6 +101,7 @@ public class ClientEvents RenderTypeLookup.setRenderLayer(BloodMagicBlocks.MIMIC.get(), (RenderType) -> true); }); + AlchemyArrayRendererRegistry.registerRenderer(BloodMagic.rl("array/movement"), new StaticAlchemyCircleRenderer(BloodMagic.rl("textures/models/alchemyarrays/movementarray.png"))); } public static void registerItemModelProperties(FMLClientSetupEvent event) diff --git a/src/main/java/wayoftime/bloodmagic/client/render/alchemyarray/AlchemyArrayRenderer.java b/src/main/java/wayoftime/bloodmagic/client/render/alchemyarray/AlchemyArrayRenderer.java index 510e51af..3557df32 100644 --- a/src/main/java/wayoftime/bloodmagic/client/render/alchemyarray/AlchemyArrayRenderer.java +++ b/src/main/java/wayoftime/bloodmagic/client/render/alchemyarray/AlchemyArrayRenderer.java @@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.IVertexBuilder; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.vector.Quaternion; @@ -105,7 +106,7 @@ public class AlchemyArrayRenderer matrixStack.scale(size, size, size); - RenderResizableQuadrilateral.INSTANCE.renderSquare(arrayModel, matrixStack, twoDBuffer, 0xFFFFFFFF, combinedLightIn, combinedOverlayIn); + RenderResizableQuadrilateral.INSTANCE.renderSquare(arrayModel, matrixStack, twoDBuffer, 0xFFFFFFFF, 0x00F000F0, OverlayTexture.NO_OVERLAY); matrixStack.pop(); matrixStack.pop(); diff --git a/src/main/java/wayoftime/bloodmagic/client/render/alchemyarray/StaticAlchemyCircleRenderer.java b/src/main/java/wayoftime/bloodmagic/client/render/alchemyarray/StaticAlchemyCircleRenderer.java new file mode 100644 index 00000000..a7650134 --- /dev/null +++ b/src/main/java/wayoftime/bloodmagic/client/render/alchemyarray/StaticAlchemyCircleRenderer.java @@ -0,0 +1,98 @@ +package wayoftime.bloodmagic.client.render.alchemyarray; + +import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.vertex.IVertexBuilder; + +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.util.Direction; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.vector.Quaternion; +import wayoftime.bloodmagic.client.render.BloodMagicRenderer; +import wayoftime.bloodmagic.client.render.BloodMagicRenderer.Model2D; +import wayoftime.bloodmagic.client.render.RenderResizableQuadrilateral; +import wayoftime.bloodmagic.tile.TileAlchemyArray; + +public class StaticAlchemyCircleRenderer extends AlchemyArrayRenderer +{ + public StaticAlchemyCircleRenderer(ResourceLocation arrayResource) + { + super(arrayResource); + } + + public float getRotation(float craftTime) + { + float offset = 50; + if (craftTime >= offset) + { + float modifier = (float) (craftTime - offset) * 5f; + return modifier * 1f; + } + return 0; + } + + public float getSecondaryRotation(float craftTime) + { + return 0; + } + + public float getSizeModifier(float craftTime) + { + return 1.0f; + } + +// public float getVerticalOffset(float craftTime) +// { +// if (craftTime >= 5) +// { +// if (craftTime <= 40) +// { +// return (float) (-0.4 + (0.4) * Math.pow((craftTime - 5) / 35f, 3)); +// } else +// { +// return 0; +// } +// } +// return -0.4f; +// } + + public void renderAt(TileAlchemyArray tileArray, double x, double y, double z, float craftTime, MatrixStack matrixStack, IRenderTypeBuffer renderer, int combinedLightIn, int combinedOverlayIn) + { + matrixStack.push(); + + matrixStack.translate(0.5, 0.5, 0.5); + + float rot = getRotation(craftTime); + float secondaryRot = getSecondaryRotation(craftTime); + + float size = 1.0F * getSizeModifier(craftTime); + Direction rotation = tileArray.getRotation(); + + matrixStack.push(); + matrixStack.translate(0, getVerticalOffset(craftTime), 0); + matrixStack.rotate(new Quaternion(Direction.UP.toVector3f(), -rotation.getHorizontalAngle(), true)); + + matrixStack.push(); + + matrixStack.rotate(new Quaternion(Direction.NORTH.toVector3f(), rot, true)); +// matrixStack.rotate(new Quaternion(Direction.NORTH.toVector3f(), secondaryRot, true)); +// matrixStack.rotate(new Quaternion(Direction.EAST.toVector3f(), secondaryRot * 0.45812f, true)); + + IVertexBuilder twoDBuffer = renderer.getBuffer(RenderType.getEntityTranslucent(arrayResource)); + Model2D arrayModel = new BloodMagicRenderer.Model2D(); + arrayModel.minX = -0.5; + arrayModel.maxX = +0.5; + arrayModel.minY = -0.5; + arrayModel.maxY = +0.5; + arrayModel.resource = arrayResource; + + matrixStack.scale(size, size, size); + + RenderResizableQuadrilateral.INSTANCE.renderSquare(arrayModel, matrixStack, twoDBuffer, 0xFFFFFFFF, 0x00F000F0, OverlayTexture.NO_OVERLAY); + + matrixStack.pop(); + matrixStack.pop(); + matrixStack.pop(); + } +} diff --git a/src/main/java/wayoftime/bloodmagic/common/alchemyarray/AlchemyArrayEffect.java b/src/main/java/wayoftime/bloodmagic/common/alchemyarray/AlchemyArrayEffect.java index 36c6d12e..2219ea52 100644 --- a/src/main/java/wayoftime/bloodmagic/common/alchemyarray/AlchemyArrayEffect.java +++ b/src/main/java/wayoftime/bloodmagic/common/alchemyarray/AlchemyArrayEffect.java @@ -1,6 +1,10 @@ package wayoftime.bloodmagic.common.alchemyarray; +import net.minecraft.block.BlockState; +import net.minecraft.entity.Entity; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; import wayoftime.bloodmagic.tile.TileAlchemyArray; public abstract class AlchemyArrayEffect @@ -12,4 +16,8 @@ public abstract class AlchemyArrayEffect public abstract void writeToNBT(CompoundNBT compound); public abstract boolean update(TileAlchemyArray array, int activeCounter); + + public void onEntityCollidedWithBlock(TileAlchemyArray tileAlchemyArray, World world, BlockPos pos, BlockState state, Entity entity) + { + }; } diff --git a/src/main/java/wayoftime/bloodmagic/common/alchemyarray/AlchemyArrayEffectBinding.java b/src/main/java/wayoftime/bloodmagic/common/alchemyarray/AlchemyArrayEffectBinding.java index eebcf5d2..a1519163 100644 --- a/src/main/java/wayoftime/bloodmagic/common/alchemyarray/AlchemyArrayEffectBinding.java +++ b/src/main/java/wayoftime/bloodmagic/common/alchemyarray/AlchemyArrayEffectBinding.java @@ -44,7 +44,6 @@ public class AlchemyArrayEffectBinding extends AlchemyArrayEffectCrafting ItemEntity outputEntity = new ItemEntity(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output); tile.getWorld().addEntity(outputEntity); -// tile.getWorld().spawnEntity(outputEntity); return true; } diff --git a/src/main/java/wayoftime/bloodmagic/common/alchemyarray/AlchemyArrayEffectMovement.java b/src/main/java/wayoftime/bloodmagic/common/alchemyarray/AlchemyArrayEffectMovement.java new file mode 100644 index 00000000..8037b5b4 --- /dev/null +++ b/src/main/java/wayoftime/bloodmagic/common/alchemyarray/AlchemyArrayEffectMovement.java @@ -0,0 +1,96 @@ +package wayoftime.bloodmagic.common.alchemyarray; + +import net.minecraft.block.BlockState; +import net.minecraft.entity.Entity; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.World; +import wayoftime.bloodmagic.tile.TileAlchemyArray; + +public class AlchemyArrayEffectMovement extends AlchemyArrayEffect +{ + public AlchemyArrayEffectMovement() + { + super(); + } + + @Override + public boolean update(TileAlchemyArray tile, int ticksActive) + { + + return false; + } + + @Override + public void onEntityCollidedWithBlock(TileAlchemyArray array, World world, BlockPos pos, BlockState state, Entity entity) + { + double motionY = 0.5; + double motionYGlowstoneMod = 0.05; + double speed = 1.5; + double speedRedstoneMod = 0.15; + + Direction direction = array.getRotation(); + TileAlchemyArray tileArray = (TileAlchemyArray) array; + + motionY += motionYGlowstoneMod * (tileArray.getStackInSlot(0).getCount() - 1); + speed += speedRedstoneMod * (tileArray.getStackInSlot(1).getCount() - 1); + +// entity.getMotion().y = motionY; + entity.fallDistance = 0; + + switch (direction) + { + case NORTH: +// entity.motionX = 0; +// entity.motionY = motionY; +// entity.motionZ = -speed; + entity.setMotion(new Vector3d(0, motionY, -speed)); + break; + + case SOUTH: +// entity.motionX = 0; +// entity.motionY = motionY; +// entity.motionZ = speed; + entity.setMotion(new Vector3d(0, motionY, speed)); + break; + + case WEST: +// entity.motionX = -speed; +// entity.motionY = motionY; +// entity.motionZ = 0; + entity.setMotion(new Vector3d(-speed, motionY, 0)); + break; + + case EAST: +// entity.motionX = speed; +// entity.motionY = motionY; +// entity.motionZ = 0; + entity.setMotion(new Vector3d(speed, motionY, 0)); + break; + default: + break; + } + } + + @Override + public AlchemyArrayEffect getNewCopy() + { + return new AlchemyArrayEffectMovement(); + } + + @Override + public void readFromNBT(CompoundNBT compound) + { + // TODO Auto-generated method stub + + } + + @Override + public void writeToNBT(CompoundNBT compound) + { + // TODO Auto-generated method stub + + } +} diff --git a/src/main/java/wayoftime/bloodmagic/common/block/BlockAlchemyArray.java b/src/main/java/wayoftime/bloodmagic/common/block/BlockAlchemyArray.java index f4202567..a554ed0a 100644 --- a/src/main/java/wayoftime/bloodmagic/common/block/BlockAlchemyArray.java +++ b/src/main/java/wayoftime/bloodmagic/common/block/BlockAlchemyArray.java @@ -4,6 +4,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -52,6 +53,16 @@ public class BlockAlchemyArray extends Block return BlockRenderType.ENTITYBLOCK_ANIMATED; } + @Override + public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) + { + TileEntity tile = world.getTileEntity(pos); + if (tile instanceof TileAlchemyArray) + { + ((TileAlchemyArray) tile).onEntityCollidedWithBlock(state, entity); + } + } + @Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult) { diff --git a/src/main/java/wayoftime/bloodmagic/common/recipe/AlchemyArrayRecipeProvider.java b/src/main/java/wayoftime/bloodmagic/common/recipe/AlchemyArrayRecipeProvider.java index d058563f..8f78f4b2 100644 --- a/src/main/java/wayoftime/bloodmagic/common/recipe/AlchemyArrayRecipeProvider.java +++ b/src/main/java/wayoftime/bloodmagic/common/recipe/AlchemyArrayRecipeProvider.java @@ -6,6 +6,7 @@ import net.minecraft.data.IFinishedRecipe; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; +import net.minecraftforge.common.Tags; import wayoftime.bloodmagic.BloodMagic; import wayoftime.bloodmagic.common.data.recipe.builder.AlchemyArrayRecipeBuilder; import wayoftime.bloodmagic.common.item.BloodMagicItems; @@ -35,6 +36,7 @@ public class AlchemyArrayRecipeProvider implements ISubRecipeProvider AlchemyArrayRecipeBuilder.array(AlchemyArrayRegistry.BINDING_ARRAY, Ingredient.fromItems(BloodMagicItems.REAGENT_BINDING.get()), Ingredient.fromItems(Items.IRON_LEGGINGS), new ItemStack(BloodMagicItems.LIVING_LEGGINGS.get())).build(consumer, BloodMagic.rl(basePath + "living_leggings")); AlchemyArrayRecipeBuilder.array(AlchemyArrayRegistry.BINDING_ARRAY, Ingredient.fromItems(BloodMagicItems.REAGENT_BINDING.get()), Ingredient.fromItems(Items.IRON_BOOTS), new ItemStack(BloodMagicItems.LIVING_BOOTS.get())).build(consumer, BloodMagic.rl(basePath + "living_boots")); + AlchemyArrayRecipeBuilder.array(BloodMagic.rl("textures/models/alchemyarrays/movementarray.png"), Ingredient.fromItems(Items.FEATHER), Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE), ItemStack.EMPTY).build(consumer, BloodMagic.rl(basePath + "movement")); // AlchemyArrayRecipeBuilder.array(BloodMagic.rl("textures/models/alchemyarrays/fastminersigil.png"), // Ingredient.fromItems(BloodMagicItems.REAGENT_FAST_MINER.get()), // Ingredient.fromItems(BloodMagicItems.REINFORCED_SLATE.get()), new diff --git a/src/main/java/wayoftime/bloodmagic/core/LivingArmorRegistrar.java b/src/main/java/wayoftime/bloodmagic/core/LivingArmorRegistrar.java index c93e8fd9..073bf884 100644 --- a/src/main/java/wayoftime/bloodmagic/core/LivingArmorRegistrar.java +++ b/src/main/java/wayoftime/bloodmagic/core/LivingArmorRegistrar.java @@ -40,12 +40,20 @@ public class LivingArmorRegistrar def.put("arrow_protect", BloodMagic.rl("arrow_protect")); def.put("arrow_shot", BloodMagic.rl("arrow_shot")); def.put("critical_strike", BloodMagic.rl("critical_strike")); - def.put("jump", BloodMagic.rl("jump")); - def.put("health", BloodMagic.rl("health")); + def.put("digging", BloodMagic.rl("digging")); def.put("experience", BloodMagic.rl("experienced")); + def.put("fall_protect", BloodMagic.rl("fall_protect")); + def.put("fire_resist", BloodMagic.rl("fire_resist")); + def.put("grave_digger", BloodMagic.rl("grave_digger")); + def.put("health", BloodMagic.rl("health")); + def.put("jump", BloodMagic.rl("jump")); + def.put("knockback_resist", BloodMagic.rl("knockback_resist")); + def.put("melee_damage", BloodMagic.rl("melee_damage")); + def.put("physical_protect", BloodMagic.rl("physical_protect")); + def.put("poison_resist", BloodMagic.rl("poison_resist")); def.put("sprint_attack", BloodMagic.rl("sprint_attack")); - def.put("self_sacrifice", BloodMagic.rl("self_sacrifice")); def.put("speed", BloodMagic.rl("speed")); + def.put("self_sacrifice", BloodMagic.rl("self_sacrifice")); return def; }).get(); // private static final Map DEFINITIONS = @@ -83,7 +91,11 @@ public class LivingArmorRegistrar return 0; })); public static final LivingUpgradeRegistryObject UPGRADE_SELF_SACRIFICE = UPGRADES.register("self_sacrifice", () -> parseDefinition("self_sacrifice")); - public static final LivingUpgradeRegistryObject UPGRADE_SPEED = UPGRADES.register("speed", () -> parseDefinition("speed")); + public static final LivingUpgradeRegistryObject UPGRADE_SPEED = UPGRADES.register("speed", () -> parseDefinition("speed").withAttributeProvider((stats, attributeMap, uuid, upgrade, level) -> { + 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_DIGGING = UPGRADES.register("digging", () -> parseDefinition("digging")); // public static final LivingUpgrade UPGRADE_ARROW_PROTECT = parseDefinition("arrow_protect").withArmorProvider((player, stats, source, upgrade, level) -> { // if (source.isProjectile()) @@ -108,6 +120,8 @@ public class LivingArmorRegistrar registerUpgrade(UPGRADE_SPRINT_ATTACK.get()); registerUpgrade(UPGRADE_SELF_SACRIFICE.get()); registerUpgrade(UPGRADE_SPEED.get()); + registerUpgrade(UPGRADE_POISON_RESIST.get()); + registerUpgrade(UPGRADE_DIGGING.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 d5089cd9..3c383b57 100644 --- a/src/main/java/wayoftime/bloodmagic/core/living/LivingStats.java +++ b/src/main/java/wayoftime/bloodmagic/core/living/LivingStats.java @@ -42,7 +42,7 @@ public class LivingStats LivingUpgrade upgrade = LivingArmorRegistrar.UPGRADE_MAP.getOrDefault(key, LivingUpgrade.DUMMY); double current = upgrades.getOrDefault(upgrade, 0d); - System.out.println("Upgrade: " + upgrade); +// System.out.println("Upgrade: " + upgrade); if (upgrade.getNextRequirement((int) current) == 0) return this; diff --git a/src/main/java/wayoftime/bloodmagic/core/living/LivingUtil.java b/src/main/java/wayoftime/bloodmagic/core/living/LivingUtil.java index 17698252..9df87d2a 100644 --- a/src/main/java/wayoftime/bloodmagic/core/living/LivingUtil.java +++ b/src/main/java/wayoftime/bloodmagic/core/living/LivingUtil.java @@ -71,7 +71,7 @@ public class LivingUtil player.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.living_upgrade_level_increase", new TranslationTextComponent(upgrade.getTranslationKey()), newLevel), true); } - System.out.println("Adding experience!"); +// System.out.println("Adding experience! Total experience is: " + currentExperience); stats.addExperience(upgrade.getKey(), experience); LivingStats.toPlayer(player, stats); diff --git a/src/main/java/wayoftime/bloodmagic/core/registry/AlchemyArrayRegistry.java b/src/main/java/wayoftime/bloodmagic/core/registry/AlchemyArrayRegistry.java index b88d5723..1c0b9cc1 100644 --- a/src/main/java/wayoftime/bloodmagic/core/registry/AlchemyArrayRegistry.java +++ b/src/main/java/wayoftime/bloodmagic/core/registry/AlchemyArrayRegistry.java @@ -12,6 +12,7 @@ import wayoftime.bloodmagic.BloodMagic; import wayoftime.bloodmagic.common.alchemyarray.AlchemyArrayEffect; import wayoftime.bloodmagic.common.alchemyarray.AlchemyArrayEffectBinding; import wayoftime.bloodmagic.common.alchemyarray.AlchemyArrayEffectCrafting; +import wayoftime.bloodmagic.common.alchemyarray.AlchemyArrayEffectMovement; import wayoftime.bloodmagic.impl.BloodMagicAPI; import wayoftime.bloodmagic.recipe.RecipeAlchemyArray; @@ -29,6 +30,11 @@ public class AlchemyArrayRegistry return hadKey; } + public static void registerBaseArrays() + { + registerEffect(BloodMagic.rl("array/movement"), new AlchemyArrayEffectMovement()); + } + public static AlchemyArrayEffect getEffect(World world, ResourceLocation rl, RecipeAlchemyArray recipe) { if (effectMap.containsKey(rl)) diff --git a/src/main/java/wayoftime/bloodmagic/tile/TileAlchemyArray.java b/src/main/java/wayoftime/bloodmagic/tile/TileAlchemyArray.java index 2d97c292..f5420c93 100644 --- a/src/main/java/wayoftime/bloodmagic/tile/TileAlchemyArray.java +++ b/src/main/java/wayoftime/bloodmagic/tile/TileAlchemyArray.java @@ -1,6 +1,8 @@ package wayoftime.bloodmagic.tile; +import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; @@ -36,6 +38,14 @@ public class TileAlchemyArray extends TileInventory implements ITickableTileEnti this(TYPE); } + public void onEntityCollidedWithBlock(BlockState state, Entity entity) + { + if (arrayEffect != null) + { + arrayEffect.onEntityCollidedWithBlock(this, getWorld(), pos, state, entity); + } + } + @Override public void deserialize(CompoundNBT tagCompound) { @@ -108,6 +118,7 @@ public class TileAlchemyArray extends TileInventory implements ITickableTileEnti } else { AlchemyArrayEffect effect = AlchemyArrayRegistry.getEffect(world, this.getStackInSlot(0), this.getStackInSlot(1)); + System.out.println("Effect: " + effect); if (effect == null) { // key = effect.i 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 5a74b833..26b70160 100644 --- a/src/main/java/wayoftime/bloodmagic/util/handler/event/GenericHandler.java +++ b/src/main/java/wayoftime/bloodmagic/util/handler/event/GenericHandler.java @@ -16,7 +16,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.Tags; import net.minecraftforge.common.ToolType; @@ -25,8 +24,10 @@ import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.event.entity.living.LivingHealEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; +import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerXpEvent; +import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.BlockEvent.BlockToolInteractEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -334,7 +335,8 @@ public class GenericHandler if (LivingUtil.hasFullSet(player)) { LivingStats stats = LivingStats.fromPlayer(player); - percentIncrease += LivingArmorRegistrar.UPGRADE_SPEED.get().getBonusValue("speed_modifier", stats.getLevel(LivingArmorRegistrar.UPGRADE_SPEED.get().getKey())).doubleValue(); + ItemStack chestStack = player.getItemStackFromSlot(EquipmentSlotType.CHEST); +// percentIncrease += LivingArmorRegistrar.UPGRADE_SPEED.get().getBonusValue("speed_modifier", stats.getLevel(LivingArmorRegistrar.UPGRADE_SPEED.get().getKey())).doubleValue(); if (player.isSprinting()) { int speedTime = LivingArmorRegistrar.UPGRADE_SPEED.get().getBonusValue("speed_time", stats.getLevel(LivingArmorRegistrar.UPGRADE_SPEED.get().getKey())).intValue(); @@ -358,16 +360,80 @@ public class GenericHandler distance *= (1 + percentIncrease); LivingUtil.applyNewExperience(player, LivingArmorRegistrar.UPGRADE_SPEED.get(), distance); } + + int poisonLevel = stats.getLevel(LivingArmorRegistrar.UPGRADE_POISON_RESIST.get().getKey()); + if (player.isPotionActive(Effects.POISON)) + { + LivingUtil.applyNewExperience(player, LivingArmorRegistrar.UPGRADE_POISON_RESIST.get(), 1); + } + if (poisonLevel > 0) + { + boolean hasChanged = false; + int poisonCooldown = chestStack.getTag().getInt("poison_cooldown"); + if (poisonCooldown > 0) + { + poisonCooldown--; + 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(); + player.removePotionEffect(Effects.POISON); + hasChanged = true; + } + + if (hasChanged) + { + chestStack.getTag().putInt("poison_cooldown", poisonCooldown); + } + } } - if (percentIncrease > 0 && (player.isOnGround()) && (Math.abs(player.moveForward) > 0 || Math.abs(player.moveStrafing) > 0)) - { - player.travel(new Vector3d(player.moveStrafing * percentIncrease, 0, player.moveForward * percentIncrease)); - } +// if (percentIncrease > 0 && (player.isOnGround()) && (Math.abs(player.moveForward) > 0 || Math.abs(player.moveStrafing) > 0)) +// { +// player.travel(new Vector3d(player.moveStrafing * percentIncrease, 0, player.moveForward * percentIncrease)); +// } posXMap.put(player.getUniqueID(), player.getPosX()); posZMap.put(player.getUniqueID(), player.getPosZ()); } } + @SubscribeEvent + public void onMiningSpeedCheck(PlayerEvent.BreakSpeed event) + { + PlayerEntity player = event.getPlayer(); + float percentIncrease = 0; + + if (LivingUtil.hasFullSet(player)) + { + LivingStats stats = LivingStats.fromPlayer(player); + percentIncrease += LivingArmorRegistrar.UPGRADE_DIGGING.get().getBonusValue("speed_modifier", stats.getLevel(LivingArmorRegistrar.UPGRADE_DIGGING.get().getKey())).doubleValue(); + } + + event.setNewSpeed((1 + percentIncrease) * event.getNewSpeed()); + } + + @SubscribeEvent + public void onBreakBlock(BlockEvent.BreakEvent event) + { + PlayerEntity player = event.getPlayer(); + if (player != null) + { + 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(); + if (mineTime > 0) + { + player.addPotionEffect(new EffectInstance(Effects.HASTE, mineTime, LivingArmorRegistrar.UPGRADE_DIGGING.get().getBonusValue("speed_level", stats.getLevel(LivingArmorRegistrar.UPGRADE_DIGGING.get().getKey())).intValue(), true, false)); + } + } + } + } } diff --git a/src/main/resources/data/bloodmagic/living_armor/digging.json b/src/main/resources/data/bloodmagic/living_armor/digging.json index 4dda13a3..96a24ecb 100644 --- a/src/main/resources/data/bloodmagic/living_armor/digging.json +++ b/src/main/resources/data/bloodmagic/living_armor/digging.json @@ -38,16 +38,16 @@ 2 ], "speed_modifier": [ - 1.1, + 0.1, + 0.2, + 0.3, + 0.4, + 0.5, + 0.6, + 0.8, + 1, 1.2, - 1.3, - 1.4, - 1.5, - 1.6, - 1.8, - 2, - 2.2, - 2.5 + 1.5 ] } } \ No newline at end of file diff --git a/src/main/resources/data/bloodmagic/living_armor/grave_digger.json b/src/main/resources/data/bloodmagic/living_armor/grave_digger.json new file mode 100644 index 00000000..38152a35 --- /dev/null +++ b/src/main/resources/data/bloodmagic/living_armor/grave_digger.json @@ -0,0 +1,29 @@ +{ + "id": "bloodmagic:grave_digger", + "levels": [ + { "xp": 200, "cost": 5 }, + { "xp": 800, "cost": 12 }, + { "xp": 1300, "cost": 20 }, + { "xp": 2500, "cost": 35 }, + { "xp": 3800, "cost": 49 }, + { "xp": 5000, "cost": 78 }, + { "xp": 7000, "cost": 110 }, + { "xp": 9200, "cost": 160 }, + { "xp": 11500, "cost": 215 }, + { "xp": 14000, "cost": 320 } + ], + "bonuses": { + "damage": [ + 1 + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ] + } +} \ No newline at end of file diff --git a/src/main/resources/data/bloodmagic/living_armor/knockback_resist.json b/src/main/resources/data/bloodmagic/living_armor/knockback_resist.json new file mode 100644 index 00000000..e74626ea --- /dev/null +++ b/src/main/resources/data/bloodmagic/living_armor/knockback_resist.json @@ -0,0 +1,26 @@ +{ + "id": "bloodmagic:knockback_resist", + "levels": [ + { "xp": 100, "cost": 3 }, + { "xp": 200, "cost": 7 }, + { "xp": 300, "cost": 13 }, + { "xp": 500, "cost": 26 }, + { "xp": 1000, "cost": 42 } + ], + "bonuses": { + "kb": [ + 0.2, + 0.4, + 0.6, + 0.8, + 1.0 + ], + "hp": [ + 0, + 0, + 0, + 4, + 10 + ] + } +} \ No newline at end of file diff --git a/src/main/resources/data/bloodmagic/living_armor/melee_damage b/src/main/resources/data/bloodmagic/living_armor/melee_damage new file mode 100644 index 00000000..963cc11c --- /dev/null +++ b/src/main/resources/data/bloodmagic/living_armor/melee_damage @@ -0,0 +1,29 @@ +{ + "id": "bloodmagic:melee_damage", + "levels": [ + { "xp": 200, "cost": 5 }, + { "xp": 800, "cost": 12 }, + { "xp": 1300, "cost": 20 }, + { "xp": 2500, "cost": 35 }, + { "xp": 3800, "cost": 49 }, + { "xp": 5000, "cost": 78 }, + { "xp": 7000, "cost": 110 }, + { "xp": 9200, "cost": 160 }, + { "xp": 11500, "cost": 215 }, + { "xp": 14000, "cost": 320 } + ], + "bonuses": { + "damage": [ + 0.5, + 1, + 1.5, + 2, + 2.5, + 3, + 4, + 5, + 6, + 7 + ] + } +} \ No newline at end of file diff --git a/src/main/resources/data/bloodmagic/living_armor/physical_protect.json b/src/main/resources/data/bloodmagic/living_armor/physical_protect.json new file mode 100644 index 00000000..bfb72198 --- /dev/null +++ b/src/main/resources/data/bloodmagic/living_armor/physical_protect.json @@ -0,0 +1,29 @@ +{ + "id": "bloodmagic:physical_protect", + "levels": [ + { "xp": 30, "cost": 5 }, + { "xp": 200, "cost": 10 }, + { "xp": 400, "cost": 18 }, + { "xp": 800, "cost": 35 }, + { "xp": 1500, "cost": 65 }, + { "xp": 2500, "cost": 100 }, + { "xp": 3500, "cost": 140 }, + { "xp": 5000, "cost": 190 }, + { "xp": 7000, "cost": 250 }, + { "xp": 15000, "cost": 300 } + ], + "bonuses": { + "protection": [ + 0.1, + 0.3, + 0.4, + 0.6, + 0.7, + 0.75, + 0.77, + 0.8, + 0.83, + 0.85 + ] + } +} \ No newline at end of file diff --git a/src/main/resources/data/bloodmagic/living_armor/poison_resist.json b/src/main/resources/data/bloodmagic/living_armor/poison_resist.json new file mode 100644 index 00000000..42312197 --- /dev/null +++ b/src/main/resources/data/bloodmagic/living_armor/poison_resist.json @@ -0,0 +1,26 @@ +{ + "id": "bloodmagic:poison_resist", + "levels": [ + { "xp": 1200, "cost": 2 }, + { "xp": 3600, "cost": 6 }, + { "xp": 12000, "cost": 14 }, + { "xp": 24000, "cost": 25 }, + { "xp": 30000, "cost": 40 } + ], + "bonuses": { + "cooldown": [ + 1200, + 800, + 600, + 300, + 100 + ], + "max_cure": [ + 0, + 1, + 2, + 2, + 3 + ] + } +} \ No newline at end of file