From cea970194e625d738599ee1ba0202a8e1dd03571 Mon Sep 17 00:00:00 2001 From: pahimar Date: Sun, 12 Jan 2014 10:51:26 -0500 Subject: [PATCH] Short of a light update bug, I think the Calcinator is done! --- .../pahimar/ee3/block/BlockCalcinator.java | 9 ++- .../ee3/tileentity/TileCalcinator.java | 79 ++++++++++++++++--- src/main/resources/assets/ee3/lang/en_US.lang | 2 +- 3 files changed, 76 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/pahimar/ee3/block/BlockCalcinator.java b/src/main/java/com/pahimar/ee3/block/BlockCalcinator.java index 01544573..e2bd35ca 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockCalcinator.java +++ b/src/main/java/com/pahimar/ee3/block/BlockCalcinator.java @@ -54,7 +54,14 @@ public class BlockCalcinator extends BlockEE implements ITileEntityProvider @Override public int getLightValue(IBlockAccess world, int x, int y, int z) { - // TODO Vary light levels depending on whether or not we are calcinating something + if (world.getBlockTileEntity(x, y, z) instanceof TileCalcinator) + { + if (((TileCalcinator) world.getBlockTileEntity(x, y, z)).getState() == 1) + { + return 15; + } + } + return super.getLightValue(world, x, y, z); } diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileCalcinator.java b/src/main/java/com/pahimar/ee3/tileentity/TileCalcinator.java index 09b99e39..352a3928 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileCalcinator.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileCalcinator.java @@ -39,8 +39,7 @@ public class TileCalcinator extends TileEE implements IInventory public int fuelBurnTime; // The fuel value for the currently burning fuel public int itemCookTime; // How long the current item has been "cooking" - public int leftStackSize, leftStackColour; - public int rightStackSize, rightStackColour; + public int leftStackSize, leftStackColour, rightStackSize, rightStackColour; public TileCalcinator() { @@ -129,6 +128,26 @@ public class TileCalcinator extends TileEE implements IInventory this.state = (byte) eventData; return true; } + else if (eventId == 2) + { + this.leftStackSize = eventData; + return true; + } + else if (eventId == 3) + { + this.leftStackColour = eventData; + return true; + } + else if (eventId == 4) + { + this.rightStackSize = eventData; + return true; + } + else if (eventId == 5) + { + this.rightStackColour = eventData; + return true; + } else { return super.receiveClientEvent(eventId, eventData); @@ -164,6 +183,10 @@ public class TileCalcinator extends TileEE implements IInventory inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); } } + + deviceCookTime = nbtTagCompound.getInteger("deviceCookTime"); + fuelBurnTime = nbtTagCompound.getInteger("fuelBurnTime"); + itemCookTime = nbtTagCompound.getInteger("itemCookTime"); } @Override @@ -184,6 +207,9 @@ public class TileCalcinator extends TileEE implements IInventory } } nbtTagCompound.setTag("Items", tagList); + nbtTagCompound.setInteger("deviceCookTime", deviceCookTime); + nbtTagCompound.setInteger("fuelBurnTime", fuelBurnTime); + nbtTagCompound.setInteger("itemCookTime", itemCookTime); } @Override @@ -199,6 +225,7 @@ public class TileCalcinator extends TileEE implements IInventory } @Override + // TODO BUG: When Calcinator begins burning at night, client doesn't immediately reflect that the light level has changed public void updateEntity() { boolean isBurning = this.deviceCookTime > 0; @@ -262,7 +289,11 @@ public class TileCalcinator extends TileEE implements IInventory this.onInventoryChanged(); this.state = this.deviceCookTime > 0 ? (byte) 1 : (byte) 0; this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 1, this.state); - // TODO Send stack sizes and colours on update + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 2, getLeftStackSize()); + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 3, getLeftStackColour()); + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 4, getRightStackSize()); + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 5, getRightStackColour()); + this.worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID); } } @@ -372,22 +403,46 @@ public class TileCalcinator extends TileEE implements IInventory @Override public Packet getDescriptionPacket() { - int leftStackSize = 0; - int leftStackColour = Integer.parseInt(Colours.PURE_WHITE, 16); + return PacketTypeHandler.populatePacket(new PacketTileCalcinator(xCoord, yCoord, zCoord, orientation, state, customName, getLeftStackSize(), getLeftStackColour(), getRightStackSize(), getRightStackColour())); + } + + private int getLeftStackSize() + { if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] != null) { - leftStackSize = this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize; - leftStackColour = this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].getItem().getColorFromItemStack(this.inventory[OUTPUT_LEFT_INVENTORY_INDEX], 1); + return leftStackSize = this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize; } - int rightStackSize = 0; - int rightStackColour = Integer.parseInt(Colours.PURE_WHITE, 16); + return 0; + } + + private int getLeftStackColour() + { + if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] != null) + { + return this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].getItem().getColorFromItemStack(this.inventory[OUTPUT_LEFT_INVENTORY_INDEX], 1); + } + + return Integer.parseInt(Colours.PURE_WHITE, 16); + } + + private int getRightStackSize() + { if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] != null) { - rightStackSize = this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize; - rightStackColour = this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].getItem().getColorFromItemStack(this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX], 1); + return leftStackSize = this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize; } - return PacketTypeHandler.populatePacket(new PacketTileCalcinator(xCoord, yCoord, zCoord, orientation, state, customName, leftStackSize, leftStackColour, rightStackSize, rightStackColour)); + return 0; + } + + private int getRightStackColour() + { + if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] != null) + { + return this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].getItem().getColorFromItemStack(this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX], 1); + } + + return Integer.parseInt(Colours.PURE_WHITE, 16); } } diff --git a/src/main/resources/assets/ee3/lang/en_US.lang b/src/main/resources/assets/ee3/lang/en_US.lang index 9bad64c6..84932eec 100644 --- a/src/main/resources/assets/ee3/lang/en_US.lang +++ b/src/main/resources/assets/ee3/lang/en_US.lang @@ -26,7 +26,7 @@ tile.ee3:alchemicalFuelBlock.alchemicalCoal.name=Alchemical Coal tile.ee3:alchemicalFuelBlock.mobiusFuel.name=Mobius Fuel tile.ee3:alchemicalFuelBlock.aeternalisFuel.name=Aeternalis Fuel tile.ee3:aludel.name=Aludel [WIP] -tile.ee3:calcinator.name=Calcinator [WIP] +tile.ee3:calcinator.name=Calcinator tile.ee3:chalk.name=Chalk tile.ee3:glassBell.name=Glass Bell [WIP] tile.ee3:researchStation.name=Research Station [WIP]