From 71eaeb1d5d215ae086eced8c3adc1efc69f7d35c Mon Sep 17 00:00:00 2001 From: Mohammad-Ali Minaie Date: Sun, 19 Aug 2018 02:21:29 -0400 Subject: [PATCH] modified the updated logic for the crucible to write to nbt state changes --- .../forgecraft/blocks/Crucibles/NBTCrucible.java | 14 ++++++++------ .../nmd/primal/forgecraft/items/SlottedTongs.java | 3 --- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/NBTCrucible.java b/kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/NBTCrucible.java index 0410a0fe..8d28d900 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/NBTCrucible.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/blocks/Crucibles/NBTCrucible.java @@ -70,7 +70,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider { if (recipe != null) { tile.setDrops(recipe.getDropsRaw()); } - PlayerHelper.playerTakeItem(world, pos, EnumFacing.DOWN, player, player.getActiveHand(), this.getItem(world, pos, state)); + PlayerHelper.playerTakeItem(world, pos, EnumFacing.DOWN, player, player.getActiveHand(), this.getCrucibleItem(world, pos, state, player)); world.setBlockState(pos, this.getReplacementBlock(world, pos, state)); return true; } @@ -87,6 +87,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider { tile.ingList.set(i-1, pItem1); pItem.shrink(1); world.setBlockState(pos, state.withProperty(PrimalAPI.States.LAYERS, i), 2); + tile.setHot(i); tile.update(); tile.markDirty(); return true; @@ -106,6 +107,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider { } } world.setBlockState(pos, state.withProperty(PrimalAPI.States.LAYERS, 0), 2); + tile.setHot(0); tile.update(); tile.markDirty(); return true; @@ -119,6 +121,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider { PlayerHelper.spawnItemOnPlayer(world, player, tile.getDrops()); tile.setStatus(false); world.setBlockState(pos, state.withProperty(PrimalAPI.States.LAYERS, 0), 2); + tile.setHot(0); tile.update(); tile.markDirty(); return true; @@ -143,10 +146,9 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider { return this.takeBlock(world, pos, state, EnumFacing.UP, player); } - @Override - public ItemStack getItem(World world, BlockPos pos, IBlockState state) + public ItemStack getCrucibleItem(World world, BlockPos pos, IBlockState state, EntityPlayer player) { - return NBTHelper.getStackBlockNBT(world, pos, state, super.getItem(world, pos, state)); + return NBTHelper.getStackBlockNBT(world, pos, state, super.getPickBlock(state, null, world, pos, player)); } public boolean takeBlock(World world, BlockPos pos, IBlockState state, EnumFacing face, EntityPlayer player) @@ -154,7 +156,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider { if (!world.isRemote) { TileEntity tile = world.getTileEntity(pos); if (tile instanceof TileNBTCrucible) { - PlayerHelper.playerTakeItem(world, pos, EnumFacing.DOWN, player, player.getActiveHand(), this.getItem(world, pos, state)); + PlayerHelper.playerTakeItem(world, pos, EnumFacing.DOWN, player, player.getActiveHand(), this.getCrucibleItem(world, pos, state, player)); return world.setBlockState(pos, this.getReplacementBlock(world, pos, state)); } } @@ -192,7 +194,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider { ItemStack temp = stack.copy(); int i = temp.getItem().getMetadata(stack.getMetadata()); //TODO update this with number instead of the boolean - world.setBlockState(pos, getStateFromMeta(i), 2); + world.setBlockState(pos, state.withProperty(PrimalAPI.States.LAYERS, tile.getHot()), 2); } } } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/items/SlottedTongs.java b/kfc/src/main/java/nmd/primal/forgecraft/items/SlottedTongs.java index f2fbf7c4..3b809502 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/items/SlottedTongs.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/items/SlottedTongs.java @@ -276,14 +276,11 @@ public class SlottedTongs extends Item implements IPickup, AnvilHandler{ NBTTagCompound tag = this.slotList.get(0).getSubCompound("BlockEntityTag").copy(); NBTTagCompound defaultNBT = this.slotList.get(0).getTagCompound(); if (tag != null) { - System.out.println(tag); - System.out.println(defaultNBT); ItemBlock temp = (ItemBlock) slotList.get(0).getItem(); int i = this.getMetadata(slotList.get(0).getMetadata()); IBlockState iblockstate1 = temp.getBlock().getStateForPlacement(world, pos, face, hitx, hity, hitz, i, player, hand); temp.placeBlockAt(slotList.get(0), player, world, pos.up(1), face, hitx, hity, hitz, iblockstate1); slotList.set(0, ItemStack.EMPTY); - return EnumActionResult.SUCCESS; } }