From 3787fab416aaf74ec8849c445c0aaea9f16bdd34 Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Mon, 10 Jun 2024 09:48:45 +0200 Subject: [PATCH] Use common code for crucibles --- .../harkenscythe/blocks/HSBloodCrucible.java | 198 +----------------- .../emt/harkenscythe/blocks/HSCrucible.java | 196 +++++++++++++++++ .../harkenscythe/blocks/HSSoulCrucible.java | 198 +----------------- 3 files changed, 218 insertions(+), 374 deletions(-) create mode 100644 src/main/java/mod/emt/harkenscythe/blocks/HSCrucible.java diff --git a/src/main/java/mod/emt/harkenscythe/blocks/HSBloodCrucible.java b/src/main/java/mod/emt/harkenscythe/blocks/HSBloodCrucible.java index fbfd9e3..db4f4c8 100644 --- a/src/main/java/mod/emt/harkenscythe/blocks/HSBloodCrucible.java +++ b/src/main/java/mod/emt/harkenscythe/blocks/HSBloodCrucible.java @@ -1,117 +1,22 @@ package mod.emt.harkenscythe.blocks; -import java.util.List; -import java.util.Random; -import javax.annotation.Nullable; import mod.emt.harkenscythe.init.HSItems; import mod.emt.harkenscythe.items.HSEssenceKeeper; -import net.minecraft.block.Block; import net.minecraft.block.material.MapColor; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.PropertyInteger; -import net.minecraft.block.state.BlockFaceShape; -import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.stats.StatList; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -@SuppressWarnings("deprecation") -public class HSBloodCrucible extends Block +public class HSBloodCrucible extends HSCrucible { - public static final PropertyInteger LEVEL = PropertyInteger.create("level", 0, 10); - protected static final AxisAlignedBB AABB_LEGS = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.3125D, 1.0D); - protected static final AxisAlignedBB AABB_WALL_NORTH = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.125D); - protected static final AxisAlignedBB AABB_WALL_SOUTH = new AxisAlignedBB(0.0D, 0.0D, 0.875D, 1.0D, 1.0D, 1.0D); - protected static final AxisAlignedBB AABB_WALL_EAST = new AxisAlignedBB(0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); - protected static final AxisAlignedBB AABB_WALL_WEST = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D); - public HSBloodCrucible() { - super(Material.IRON, MapColor.RED); - setDefaultState(blockState.getBaseState().withProperty(LEVEL, 0)); - } - - public void setLevel(World world, BlockPos pos, IBlockState state, int level) - { - world.setBlockState(pos, state.withProperty(LEVEL, MathHelper.clamp(level, 0, 10)), 2); - world.updateComparatorOutputLevel(pos, this); - } - - @Override - public IBlockState getStateFromMeta(int meta) - { - return this.getDefaultState().withProperty(LEVEL, meta); - } - - @Override - public int getMetaFromState(IBlockState state) - { - return state.getValue(LEVEL); - } - - @Override - public boolean isFullCube(IBlockState state) - { - return false; - } - - @Override - public boolean isPassable(IBlockAccess world, BlockPos pos) - { - return true; - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { - return FULL_BLOCK_AABB; - } - - @Override - public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) - { - if (face == EnumFacing.UP) - { - return BlockFaceShape.BOWL; - } - else - { - return face == EnumFacing.DOWN ? BlockFaceShape.UNDEFINED : BlockFaceShape.SOLID; - } - } - - @Override - public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entity, boolean isActualState) - { - addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_LEGS); - addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_WEST); - addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_NORTH); - addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_EAST); - addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_SOUTH); - } - - @Override - public boolean isOpaqueCube(IBlockState state) - { - return false; - } - - @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) - { - return Item.getItemFromBlock(this); + super(MapColor.RED); } @Override @@ -119,103 +24,22 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En { if (world.isRemote) return false; - ItemStack stack = player.getHeldItem(hand); - if (stack.isEmpty()) return false; + ItemStack heldStack = player.getHeldItem(hand); + if (heldStack.isEmpty()) return false; - Item item = stack.getItem(); - if (!(item instanceof HSEssenceKeeper)) return false; + Item heldItem = heldStack.getItem(); + if (!(heldItem instanceof HSEssenceKeeper)) return false; - int level = state.getValue(LEVEL); - if (level < 10 && !player.isSneaking() && (item == HSItems.essence_keeper_blood || item == HSItems.essence_vessel_blood)) + int crucibleLevel = state.getValue(LEVEL); + if (crucibleLevel < 10 && !player.isSneaking() && (heldItem == HSItems.essence_keeper_blood || heldItem == HSItems.essence_vessel_blood)) { - fillCrucible(world, pos, state, player, hand, stack, item, level); + fillCrucible(world, pos, state, player, hand, heldStack, heldItem, crucibleLevel, HSItems.essence_keeper_blood, HSItems.essence_vessel_blood); } - else if (level > 0 && player.isSneaking()) + else if (crucibleLevel > 0 && player.isSneaking()) { - emptyCrucible(world, pos, state, player, hand, stack, item, level); + emptyCrucible(world, pos, state, player, hand, heldStack, heldItem, crucibleLevel, HSItems.essence_keeper_blood, HSItems.essence_vessel_blood); } return true; } - - @Override - public ItemStack getItem(World world, BlockPos pos, IBlockState state) - { - return new ItemStack(Item.getItemFromBlock(this)); - } - - @Override - public boolean hasComparatorInputOverride(IBlockState state) - { - return true; - } - - @Override - public int getComparatorInputOverride(IBlockState blockState, World world, BlockPos pos) - { - return blockState.getValue(LEVEL); - } - - @Override - protected BlockStateContainer createBlockState() - { - return new BlockStateContainer(this, LEVEL); - } - - private void fillCrucible(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, Item item, int level) - { - if (!player.capabilities.isCreativeMode) - { - if (stack.getItemDamage() + 10 < stack.getMaxDamage()) - { - stack.setItemDamage(stack.getItemDamage() + 10); - } - else - { - stack.shrink(1); - if (item == HSItems.essence_keeper_blood) - { - player.setHeldItem(hand, new ItemStack(HSItems.essence_keeper)); - } - else if (item == HSItems.essence_vessel_blood) - { - player.setHeldItem(hand, new ItemStack(HSItems.essence_vessel)); - } - } - } - world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); - setLevel(world, pos, state, level + 1); - player.addStat(StatList.getObjectUseStats(item)); - } - - private void emptyCrucible(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, Item item, int level) - { - if (!player.capabilities.isCreativeMode) - { - if (item == HSItems.essence_keeper || item == HSItems.essence_vessel) - { - stack.shrink(1); - ItemStack newStack = item == HSItems.essence_keeper ? new ItemStack(HSItems.essence_keeper_blood) : new ItemStack(HSItems.essence_vessel_blood); - newStack.setItemDamage(newStack.getMaxDamage() - 10); - player.setHeldItem(hand, newStack); - } - else if (item == HSItems.essence_keeper_blood || item == HSItems.essence_vessel_blood) - { - if (stack.getItemDamage() == 0) return; - if (stack.getItemDamage() > 0) - { - stack.setItemDamage(stack.getItemDamage() - 10); - } - if (stack.getItemDamage() <= 0) - { - stack.shrink(1); - ItemStack newStack = item == HSItems.essence_keeper_blood ? new ItemStack(HSItems.essence_keeper_blood) : new ItemStack(HSItems.essence_vessel_blood); - player.setHeldItem(hand, newStack); - } - } - } - world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); - setLevel(world, pos, state, level - 1); - player.addStat(StatList.getObjectUseStats(item)); - } } diff --git a/src/main/java/mod/emt/harkenscythe/blocks/HSCrucible.java b/src/main/java/mod/emt/harkenscythe/blocks/HSCrucible.java new file mode 100644 index 0000000..003de00 --- /dev/null +++ b/src/main/java/mod/emt/harkenscythe/blocks/HSCrucible.java @@ -0,0 +1,196 @@ +package mod.emt.harkenscythe.blocks; + +import java.util.List; +import java.util.Random; +import javax.annotation.Nullable; +import mod.emt.harkenscythe.init.HSItems; +import net.minecraft.block.Block; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.block.properties.PropertyInteger; +import net.minecraft.block.state.BlockFaceShape; +import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.SoundEvents; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatList; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +@SuppressWarnings("deprecation") +public abstract class HSCrucible extends Block +{ + public static final PropertyInteger LEVEL = PropertyInteger.create("level", 0, 10); + protected static final AxisAlignedBB AABB_LEGS = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.3125D, 1.0D); + protected static final AxisAlignedBB AABB_WALL_NORTH = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.125D); + protected static final AxisAlignedBB AABB_WALL_SOUTH = new AxisAlignedBB(0.0D, 0.0D, 0.875D, 1.0D, 1.0D, 1.0D); + protected static final AxisAlignedBB AABB_WALL_EAST = new AxisAlignedBB(0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + protected static final AxisAlignedBB AABB_WALL_WEST = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D); + + protected HSCrucible(MapColor color) + { + super(Material.IRON, color); + setDefaultState(blockState.getBaseState().withProperty(LEVEL, 0)); + } + + public void setLevel(World world, BlockPos pos, IBlockState state, int level) + { + world.setBlockState(pos, state.withProperty(LEVEL, MathHelper.clamp(level, 0, 10)), 2); + world.updateComparatorOutputLevel(pos, this); + } + + @Override + public IBlockState getStateFromMeta(int meta) + { + return this.getDefaultState().withProperty(LEVEL, meta); + } + + @Override + public int getMetaFromState(IBlockState state) + { + return state.getValue(LEVEL); + } + + @Override + public boolean isFullCube(IBlockState state) + { + return false; + } + + @Override + public boolean isPassable(IBlockAccess world, BlockPos pos) + { + return true; + } + + @Override + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) + { + return FULL_BLOCK_AABB; + } + + @Override + public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) + { + if (face == EnumFacing.UP) + { + return BlockFaceShape.BOWL; + } + else + { + return face == EnumFacing.DOWN ? BlockFaceShape.UNDEFINED : BlockFaceShape.SOLID; + } + } + + @Override + public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entity, boolean isActualState) + { + addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_LEGS); + addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_WEST); + addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_NORTH); + addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_EAST); + addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_SOUTH); + } + + @Override + public boolean isOpaqueCube(IBlockState state) + { + return false; + } + + @Override + public Item getItemDropped(IBlockState state, Random rand, int fortune) + { + return Item.getItemFromBlock(this); + } + + @Override + public ItemStack getItem(World world, BlockPos pos, IBlockState state) + { + return new ItemStack(Item.getItemFromBlock(this)); + } + + @Override + public boolean hasComparatorInputOverride(IBlockState state) + { + return true; + } + + @Override + public int getComparatorInputOverride(IBlockState blockState, World world, BlockPos pos) + { + return blockState.getValue(LEVEL); + } + + @Override + protected BlockStateContainer createBlockState() + { + return new BlockStateContainer(this, LEVEL); + } + + protected void fillCrucible(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldStack, Item heldItem, int crucibleLevel, Item keeperType, Item vesselType) + { + if (!player.capabilities.isCreativeMode) + { + if (heldStack.getItemDamage() + 10 < heldStack.getMaxDamage()) + { + heldStack.setItemDamage(heldStack.getItemDamage() + 10); + } + else + { + heldStack.shrink(1); + if (heldItem == keeperType) + { + player.setHeldItem(hand, new ItemStack(HSItems.essence_keeper)); + } + else if (heldItem == vesselType) + { + player.setHeldItem(hand, new ItemStack(HSItems.essence_vessel)); + } + } + } + world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); + setLevel(world, pos, state, crucibleLevel + 1); + player.addStat(StatList.getObjectUseStats(heldItem)); + } + + protected void emptyCrucible(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldStack, Item heldItem, int crucibleLevel, Item keeperType, Item vesselType) + { + if (!player.capabilities.isCreativeMode) + { + if (heldItem == HSItems.essence_keeper || heldItem == HSItems.essence_vessel) + { + heldStack.shrink(1); + ItemStack newStack = heldItem == HSItems.essence_keeper ? new ItemStack(keeperType) : new ItemStack(vesselType); + newStack.setItemDamage(newStack.getMaxDamage() - 10); + player.setHeldItem(hand, newStack); + } + else if (heldItem == keeperType || heldItem == vesselType) + { + if (heldStack.getItemDamage() == 0) return; + if (heldStack.getItemDamage() > 0) + { + heldStack.setItemDamage(heldStack.getItemDamage() - 10); + } + if (heldStack.getItemDamage() <= 0) + { + heldStack.shrink(1); + ItemStack newStack = heldItem == keeperType ? new ItemStack(keeperType) : new ItemStack(vesselType); + player.setHeldItem(hand, newStack); + } + } + } + world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); + setLevel(world, pos, state, crucibleLevel - 1); + player.addStat(StatList.getObjectUseStats(heldItem)); + } +} diff --git a/src/main/java/mod/emt/harkenscythe/blocks/HSSoulCrucible.java b/src/main/java/mod/emt/harkenscythe/blocks/HSSoulCrucible.java index 61d3e08..dee9a4c 100644 --- a/src/main/java/mod/emt/harkenscythe/blocks/HSSoulCrucible.java +++ b/src/main/java/mod/emt/harkenscythe/blocks/HSSoulCrucible.java @@ -1,117 +1,22 @@ package mod.emt.harkenscythe.blocks; -import java.util.List; -import java.util.Random; -import javax.annotation.Nullable; import mod.emt.harkenscythe.init.HSItems; import mod.emt.harkenscythe.items.HSEssenceKeeper; -import net.minecraft.block.Block; import net.minecraft.block.material.MapColor; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.PropertyInteger; -import net.minecraft.block.state.BlockFaceShape; -import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.stats.StatList; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -@SuppressWarnings("deprecation") -public class HSSoulCrucible extends Block +public class HSSoulCrucible extends HSCrucible { - public static final PropertyInteger LEVEL = PropertyInteger.create("level", 0, 10); - protected static final AxisAlignedBB AABB_LEGS = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.3125D, 1.0D); - protected static final AxisAlignedBB AABB_WALL_NORTH = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.125D); - protected static final AxisAlignedBB AABB_WALL_SOUTH = new AxisAlignedBB(0.0D, 0.0D, 0.875D, 1.0D, 1.0D, 1.0D); - protected static final AxisAlignedBB AABB_WALL_EAST = new AxisAlignedBB(0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); - protected static final AxisAlignedBB AABB_WALL_WEST = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D); - public HSSoulCrucible() { - super(Material.IRON, MapColor.BLACK); - setDefaultState(blockState.getBaseState().withProperty(LEVEL, 0)); - } - - public void setLevel(World world, BlockPos pos, IBlockState state, int level) - { - world.setBlockState(pos, state.withProperty(LEVEL, MathHelper.clamp(level, 0, 10)), 2); - world.updateComparatorOutputLevel(pos, this); - } - - @Override - public IBlockState getStateFromMeta(int meta) - { - return this.getDefaultState().withProperty(LEVEL, meta); - } - - @Override - public int getMetaFromState(IBlockState state) - { - return state.getValue(LEVEL); - } - - @Override - public boolean isFullCube(IBlockState state) - { - return false; - } - - @Override - public boolean isPassable(IBlockAccess world, BlockPos pos) - { - return true; - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { - return FULL_BLOCK_AABB; - } - - @Override - public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) - { - if (face == EnumFacing.UP) - { - return BlockFaceShape.BOWL; - } - else - { - return face == EnumFacing.DOWN ? BlockFaceShape.UNDEFINED : BlockFaceShape.SOLID; - } - } - - @Override - public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entity, boolean isActualState) - { - addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_LEGS); - addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_WEST); - addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_NORTH); - addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_EAST); - addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_SOUTH); - } - - @Override - public boolean isOpaqueCube(IBlockState state) - { - return false; - } - - @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) - { - return Item.getItemFromBlock(this); + super(MapColor.BLACK); } @Override @@ -119,103 +24,22 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En { if (world.isRemote) return false; - ItemStack stack = player.getHeldItem(hand); - if (stack.isEmpty()) return false; + ItemStack heldStack = player.getHeldItem(hand); + if (heldStack.isEmpty()) return false; - Item item = stack.getItem(); - if (!(item instanceof HSEssenceKeeper)) return false; + Item heldItem = heldStack.getItem(); + if (!(heldItem instanceof HSEssenceKeeper)) return false; - int level = state.getValue(LEVEL); - if (level < 10 && !player.isSneaking() && (item == HSItems.essence_keeper_soul || item == HSItems.essence_vessel_soul)) + int crucibleLevel = state.getValue(LEVEL); + if (crucibleLevel < 10 && !player.isSneaking() && (heldItem == HSItems.essence_keeper_soul || heldItem == HSItems.essence_vessel_soul)) { - fillCrucible(world, pos, state, player, hand, stack, item, level); + fillCrucible(world, pos, state, player, hand, heldStack, heldItem, crucibleLevel, HSItems.essence_keeper_soul, HSItems.essence_vessel_soul); } - else if (level > 0 && player.isSneaking()) + else if (crucibleLevel > 0 && player.isSneaking()) { - emptyCrucible(world, pos, state, player, hand, stack, item, level); + emptyCrucible(world, pos, state, player, hand, heldStack, heldItem, crucibleLevel, HSItems.essence_keeper_soul, HSItems.essence_vessel_soul); } return true; } - - @Override - public ItemStack getItem(World world, BlockPos pos, IBlockState state) - { - return new ItemStack(Item.getItemFromBlock(this)); - } - - @Override - public boolean hasComparatorInputOverride(IBlockState state) - { - return true; - } - - @Override - public int getComparatorInputOverride(IBlockState blockState, World world, BlockPos pos) - { - return blockState.getValue(LEVEL); - } - - @Override - protected BlockStateContainer createBlockState() - { - return new BlockStateContainer(this, LEVEL); - } - - private void fillCrucible(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, Item item, int level) - { - if (!player.capabilities.isCreativeMode) - { - if (stack.getItemDamage() + 10 < stack.getMaxDamage()) - { - stack.setItemDamage(stack.getItemDamage() + 10); - } - else - { - stack.shrink(1); - if (item == HSItems.essence_keeper_soul) - { - player.setHeldItem(hand, new ItemStack(HSItems.essence_keeper)); - } - else if (item == HSItems.essence_vessel_soul) - { - player.setHeldItem(hand, new ItemStack(HSItems.essence_vessel)); - } - } - } - world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); - setLevel(world, pos, state, level + 1); - player.addStat(StatList.getObjectUseStats(item)); - } - - private void emptyCrucible(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, Item item, int level) - { - if (!player.capabilities.isCreativeMode) - { - if (item == HSItems.essence_keeper || item == HSItems.essence_vessel) - { - stack.shrink(1); - ItemStack newStack = item == HSItems.essence_keeper ? new ItemStack(HSItems.essence_keeper_soul) : new ItemStack(HSItems.essence_vessel_soul); - newStack.setItemDamage(newStack.getMaxDamage() - 10); - player.setHeldItem(hand, newStack); - } - else if (item == HSItems.essence_keeper_soul || item == HSItems.essence_vessel_soul) - { - if (stack.getItemDamage() == 0) return; - if (stack.getItemDamage() > 0) - { - stack.setItemDamage(stack.getItemDamage() - 10); - } - if (stack.getItemDamage() <= 0) - { - stack.shrink(1); - ItemStack newStack = item == HSItems.essence_keeper_soul ? new ItemStack(HSItems.essence_keeper_soul) : new ItemStack(HSItems.essence_vessel_soul); - player.setHeldItem(hand, newStack); - } - } - } - world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); - setLevel(world, pos, state, level - 1); - player.addStat(StatList.getObjectUseStats(item)); - } }