modified the updated logic for the crucible to write to nbt state changes

This commit is contained in:
Mohammad-Ali Minaie
2018-08-19 02:21:29 -04:00
parent d77142c6e0
commit 71eaeb1d5d
2 changed files with 8 additions and 9 deletions

View File

@@ -70,7 +70,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider {
if (recipe != null) { if (recipe != null) {
tile.setDrops(recipe.getDropsRaw()); 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)); world.setBlockState(pos, this.getReplacementBlock(world, pos, state));
return true; return true;
} }
@@ -87,6 +87,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider {
tile.ingList.set(i-1, pItem1); tile.ingList.set(i-1, pItem1);
pItem.shrink(1); pItem.shrink(1);
world.setBlockState(pos, state.withProperty(PrimalAPI.States.LAYERS, i), 2); world.setBlockState(pos, state.withProperty(PrimalAPI.States.LAYERS, i), 2);
tile.setHot(i);
tile.update(); tile.update();
tile.markDirty(); tile.markDirty();
return true; return true;
@@ -106,6 +107,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider {
} }
} }
world.setBlockState(pos, state.withProperty(PrimalAPI.States.LAYERS, 0), 2); world.setBlockState(pos, state.withProperty(PrimalAPI.States.LAYERS, 0), 2);
tile.setHot(0);
tile.update(); tile.update();
tile.markDirty(); tile.markDirty();
return true; return true;
@@ -119,6 +121,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider {
PlayerHelper.spawnItemOnPlayer(world, player, tile.getDrops()); PlayerHelper.spawnItemOnPlayer(world, player, tile.getDrops());
tile.setStatus(false); tile.setStatus(false);
world.setBlockState(pos, state.withProperty(PrimalAPI.States.LAYERS, 0), 2); world.setBlockState(pos, state.withProperty(PrimalAPI.States.LAYERS, 0), 2);
tile.setHot(0);
tile.update(); tile.update();
tile.markDirty(); tile.markDirty();
return true; return true;
@@ -143,10 +146,9 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider {
return this.takeBlock(world, pos, state, EnumFacing.UP, player); return this.takeBlock(world, pos, state, EnumFacing.UP, player);
} }
@Override public ItemStack getCrucibleItem(World world, BlockPos pos, IBlockState state, EntityPlayer player)
public ItemStack getItem(World world, BlockPos pos, IBlockState state)
{ {
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) 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) { if (!world.isRemote) {
TileEntity tile = world.getTileEntity(pos); TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileNBTCrucible) { 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)); return world.setBlockState(pos, this.getReplacementBlock(world, pos, state));
} }
} }
@@ -192,7 +194,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider {
ItemStack temp = stack.copy(); ItemStack temp = stack.copy();
int i = temp.getItem().getMetadata(stack.getMetadata()); int i = temp.getItem().getMetadata(stack.getMetadata());
//TODO update this with number instead of the boolean //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);
} }
} }
} }

View File

@@ -276,14 +276,11 @@ public class SlottedTongs extends Item implements IPickup, AnvilHandler{
NBTTagCompound tag = this.slotList.get(0).getSubCompound("BlockEntityTag").copy(); NBTTagCompound tag = this.slotList.get(0).getSubCompound("BlockEntityTag").copy();
NBTTagCompound defaultNBT = this.slotList.get(0).getTagCompound(); NBTTagCompound defaultNBT = this.slotList.get(0).getTagCompound();
if (tag != null) { if (tag != null) {
System.out.println(tag);
System.out.println(defaultNBT);
ItemBlock temp = (ItemBlock) slotList.get(0).getItem(); ItemBlock temp = (ItemBlock) slotList.get(0).getItem();
int i = this.getMetadata(slotList.get(0).getMetadata()); int i = this.getMetadata(slotList.get(0).getMetadata());
IBlockState iblockstate1 = temp.getBlock().getStateForPlacement(world, pos, face, hitx, hity, hitz, i, player, hand); 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); temp.placeBlockAt(slotList.get(0), player, world, pos.up(1), face, hitx, hity, hitz, iblockstate1);
slotList.set(0, ItemStack.EMPTY); slotList.set(0, ItemStack.EMPTY);
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;
} }
} }