From 5b4e624d443a76820779960c40e52f4249164f1b Mon Sep 17 00:00:00 2001 From: Tobias Gremeyer Date: Fri, 1 Feb 2019 01:22:00 +0100 Subject: [PATCH] Make Movement & Updraft arrays stronger by adding more of their ingredients! (#1520) * Make Movement & Updraft arrays stronger by adding more of their ingredients! Reduced base motion for Movement & Updraft arrays * Reverted Bound Tool change * Readability & using tailored methods --- .../AlchemyArrayEffectMovement.java | 10 ++++++- .../AlchemyArrayEffectUpdraft.java | 8 +++++- .../bloodmagic/block/BlockAlchemyArray.java | 27 +++++++++++++++++-- .../bloodmagic/tile/TileAlchemyArray.java | 17 +++++++----- 4 files changed, 51 insertions(+), 11 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectMovement.java b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectMovement.java index 3bf96427..92728c9d 100644 --- a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectMovement.java +++ b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectMovement.java @@ -1,6 +1,7 @@ package WayofTime.bloodmagic.alchemyArray; import WayofTime.bloodmagic.iface.IAlchemyArray; +import WayofTime.bloodmagic.tile.TileAlchemyArray; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; @@ -22,8 +23,15 @@ public class AlchemyArrayEffectMovement extends AlchemyArrayEffect { @Override public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) { double motionY = 0.5; - double speed = 3; + double motionYGlowstoneMod = 0.05; + double speed = 1.5; + double speedRedstoneMod = 0.15; + EnumFacing direction = array.getRotation(); + TileAlchemyArray tileArray = (TileAlchemyArray) array; + + motionY += motionYGlowstoneMod * (tileArray.getStackInSlot(0).getCount() - 1); + speed += speedRedstoneMod * (tileArray.getStackInSlot(1).getCount() - 1); entity.motionY = motionY; entity.fallDistance = 0; diff --git a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectUpdraft.java b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectUpdraft.java index f2cb4612..c73d7da1 100644 --- a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectUpdraft.java +++ b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectUpdraft.java @@ -1,6 +1,7 @@ package WayofTime.bloodmagic.alchemyArray; import WayofTime.bloodmagic.iface.IAlchemyArray; +import WayofTime.bloodmagic.tile.TileAlchemyArray; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; @@ -20,9 +21,14 @@ public class AlchemyArrayEffectUpdraft extends AlchemyArrayEffect { @Override public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) { - double motionY = 1.5; + double motionY = 1; + double motionYGlowstoneMod = 0.1; + double motionYFeatherMod = 0.05; entity.fallDistance = 0; + TileAlchemyArray tileArray = (TileAlchemyArray) array; + motionY += motionYGlowstoneMod * (tileArray.getStackInSlot(0).getCount() - 1); // Glowstone Dust + motionY += motionYFeatherMod * (tileArray.getStackInSlot(1).getCount() - 1); // Feathers entity.motionY = motionY; } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyArray.java b/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyArray.java index 1e02ef13..4f706b6f 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyArray.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyArray.java @@ -1,6 +1,8 @@ package WayofTime.bloodmagic.block; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectMovement; +import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectUpdraft; import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import WayofTime.bloodmagic.tile.TileAlchemyArray; import WayofTime.bloodmagic.util.Utils; @@ -9,6 +11,7 @@ import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; @@ -88,11 +91,16 @@ public class BlockAlchemyArray extends Block { @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - //TODO: Right click should rotate it TileAlchemyArray array = (TileAlchemyArray) world.getTileEntity(pos); - if (array == null || player.isSneaking()) + if (array == null) return false; + if (player.isSneaking() && array.rotateCooldown == 0) { + array.setRotation(array.getRotation().rotateY()); + array.rotateCooldown = 5; + world.notifyBlockUpdate(pos, state, state, 3); + return false; + } ItemStack playerItem = player.getHeldItem(hand); @@ -105,6 +113,21 @@ public class BlockAlchemyArray extends Block { } else { return true; } + if (array.arrayEffect instanceof AlchemyArrayEffectMovement && (playerItem.getItem() == Items.REDSTONE || playerItem.getItem() == Items.FEATHER) + || array.arrayEffect instanceof AlchemyArrayEffectUpdraft && (playerItem.getItem() == Items.FEATHER || playerItem.getItem() == Items.GLOWSTONE_DUST)) { + for (int i = 0; i < array.getSizeInventory(); i++) { + ItemStack stack = array.getStackInSlot(i); + if (ItemStack.areItemsEqual(stack, playerItem)) { + if (stack.getCount() < 127) { + stack.setCount(stack.getCount() + 1); + playerItem.shrink(1); + } + break; + } + } + world.notifyBlockUpdate(pos, state, state, 3); + return true; + } } world.notifyBlockUpdate(pos, state, state, 3); diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java b/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java index c1c82c2c..828f2891 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java @@ -1,5 +1,12 @@ package WayofTime.bloodmagic.tile; +import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffect; +import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectCraftingNew; +import WayofTime.bloodmagic.api.impl.BloodMagicAPI; +import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyArray; +import WayofTime.bloodmagic.core.registry.AlchemyArrayRecipeRegistry; +import WayofTime.bloodmagic.iface.IAlchemyArray; +import WayofTime.bloodmagic.util.Constants; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; @@ -9,19 +16,13 @@ import net.minecraft.util.ITickable; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffect; -import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectCraftingNew; -import WayofTime.bloodmagic.api.impl.BloodMagicAPI; -import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyArray; -import WayofTime.bloodmagic.core.registry.AlchemyArrayRecipeRegistry; -import WayofTime.bloodmagic.iface.IAlchemyArray; -import WayofTime.bloodmagic.util.Constants; public class TileAlchemyArray extends TileInventory implements ITickable, IAlchemyArray { public boolean isActive = false; public int activeCounter = 0; public EnumFacing rotation = EnumFacing.HORIZONTALS[0]; + public int rotateCooldown = 0; private String key = "empty"; public AlchemyArrayEffect arrayEffect; @@ -110,6 +111,8 @@ public class TileAlchemyArray extends TileInventory implements ITickable, IAlche arrayEffect = null; key = "empty"; } + if (rotateCooldown > 0) + rotateCooldown--; } /**