From dbf52792b3f2f9e98fc543158b4b5a12f6b6fc38 Mon Sep 17 00:00:00 2001 From: pahimar Date: Tue, 7 May 2013 15:44:39 -0400 Subject: [PATCH] Net sync for item rendering in the Glass Bell. Light levels still not immediately synced though. Working on that. --- build_number.properties | 4 +- .../com/pahimar/ee3/block/BlockGlassBell.java | 7 +- .../com/pahimar/ee3/block/ModBlocks.java | 1 - .../TileEntityGlassBellRenderer.java | 24 +++++- .../handlers/DrawBlockHighlightHandler.java | 2 +- .../core/handlers/EntityLivingHandler.java | 6 +- .../TransmutationTargetOverlayHandler.java | 2 +- .../ee3/core/helper/ItemDropHelper.java | 32 -------- .../pahimar/ee3/core/helper/ItemHelper.java | 76 +++++++++++++++++++ .../pahimar/ee3/core/proxy/ClientProxy.java | 16 +++- .../pahimar/ee3/core/proxy/CommonProxy.java | 2 +- .../pahimar/ee3/item/ItemAlchemicalBag.java | 30 +------- .../ee3/network/PacketTypeHandler.java | 11 ++- .../ee3/network/packet/PacketTileUpdate.java | 1 + .../packet/PacketTileWithItemUpdate.java | 30 ++++++-- .../com/pahimar/ee3/tileentity/TileEE.java | 6 +- .../pahimar/ee3/tileentity/TileGlassBell.java | 27 +++++++ 17 files changed, 189 insertions(+), 88 deletions(-) delete mode 100644 ee3_common/com/pahimar/ee3/core/helper/ItemDropHelper.java create mode 100644 ee3_common/com/pahimar/ee3/core/helper/ItemHelper.java diff --git a/build_number.properties b/build_number.properties index beff438a..f2aa0d99 100644 --- a/build_number.properties +++ b/build_number.properties @@ -1,3 +1,3 @@ -#Tue, 16 Apr 2013 14:01:55 -0400 +#Tue, 07 May 2013 09:17:43 -0400 -build_number=6 +build_number=10 diff --git a/ee3_common/com/pahimar/ee3/block/BlockGlassBell.java b/ee3_common/com/pahimar/ee3/block/BlockGlassBell.java index 2a2e00d3..1e7d6e17 100644 --- a/ee3_common/com/pahimar/ee3/block/BlockGlassBell.java +++ b/ee3_common/com/pahimar/ee3/block/BlockGlassBell.java @@ -2,8 +2,6 @@ package com.pahimar.ee3.block; import java.util.Random; -import org.lwjgl.opengl.GL11; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLiving; @@ -13,7 +11,6 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; @@ -116,7 +113,6 @@ public class BlockGlassBell extends BlockEE { public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) { int metaData = world.getBlockMetadata(x, y, z) & 7; - float f = 0.15F; switch (ForgeDirection.getOrientation(metaData)) { case DOWN: { @@ -143,6 +139,9 @@ public class BlockGlassBell extends BlockEE { this.setBlockBounds(0.33F, 0.125F, 0.125F, 1.0F, 0.875F, 0.875F); break; } + case UNKNOWN: { + break; + } } return super.collisionRayTrace(world, x, y, z, startVec, endVec); diff --git a/ee3_common/com/pahimar/ee3/block/ModBlocks.java b/ee3_common/com/pahimar/ee3/block/ModBlocks.java index 65d16d23..4368aa4c 100644 --- a/ee3_common/com/pahimar/ee3/block/ModBlocks.java +++ b/ee3_common/com/pahimar/ee3/block/ModBlocks.java @@ -45,7 +45,6 @@ public class ModBlocks { //GameRegistry.registerBlock(redWaterFlowing, Strings.RED_WATER_FLOWING_NAME); initBlockRecipes(); - } private static void initBlockRecipes() { diff --git a/ee3_common/com/pahimar/ee3/client/renderer/tileentity/TileEntityGlassBellRenderer.java b/ee3_common/com/pahimar/ee3/client/renderer/tileentity/TileEntityGlassBellRenderer.java index 6dd20394..54771a76 100644 --- a/ee3_common/com/pahimar/ee3/client/renderer/tileentity/TileEntityGlassBellRenderer.java +++ b/ee3_common/com/pahimar/ee3/client/renderer/tileentity/TileEntityGlassBellRenderer.java @@ -76,10 +76,11 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer { * Render the ghost item inside of the Glass Bell, slowly spinning */ GL11.glPushMatrix(); - + for (int i = 0; i < tileGlassBell.getSizeInventory(); i++) { + if (tileGlassBell.getStackInSlot(i) != null) { - + float scaleFactor = getGhostItemScaleFactor(tileGlassBell.getStackInSlot(i)); float rotationAngle = (float) (720.0 * (double) (System.currentTimeMillis() & 0x3FFFL) / (double) 0x3FFFL); @@ -93,7 +94,6 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer { customRenderItem.doRenderItem(ghostEntityItem, 0, 0, 0, 0, 0); } - } GL11.glPopMatrix(); @@ -143,6 +143,12 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer { GL11.glRotatef(-90F, 1F, 0F, 0F); return; } + case UNKNOWN: { + return; + } + default: { + return; + } } } @@ -175,6 +181,12 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer { GL11.glTranslatef((float) x + 0.70F, (float) y + 0.5F, (float) z + 0.5F); return; } + case UNKNOWN: { + return; + } + default: { + return; + } } } else { @@ -203,6 +215,12 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer { GL11.glTranslatef((float) x + 0.70F, (float) y + 0.4F, (float) z + 0.5F); return; } + case UNKNOWN: { + return; + } + default: { + return; + } } } } diff --git a/ee3_common/com/pahimar/ee3/core/handlers/DrawBlockHighlightHandler.java b/ee3_common/com/pahimar/ee3/core/handlers/DrawBlockHighlightHandler.java index 92e0f188..daaff7b5 100644 --- a/ee3_common/com/pahimar/ee3/core/handlers/DrawBlockHighlightHandler.java +++ b/ee3_common/com/pahimar/ee3/core/handlers/DrawBlockHighlightHandler.java @@ -45,7 +45,7 @@ public class DrawBlockHighlightHandler { if (event.target.typeOfHit == EnumMovingObjectType.TILE) { TransmutationHelper.updateTargetBlock(event.player.worldObj, event.target.blockX, event.target.blockY, event.target.blockZ); - if (minecraft.isGuiEnabled() && minecraft.inGameHasFocus) { + if (Minecraft.isGuiEnabled() && minecraft.inGameHasFocus) { if (ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION) { drawInWorldTransmutationOverlay(event); } diff --git a/ee3_common/com/pahimar/ee3/core/handlers/EntityLivingHandler.java b/ee3_common/com/pahimar/ee3/core/handlers/EntityLivingHandler.java index 90d92095..3e6989a9 100644 --- a/ee3_common/com/pahimar/ee3/core/handlers/EntityLivingHandler.java +++ b/ee3_common/com/pahimar/ee3/core/handlers/EntityLivingHandler.java @@ -6,7 +6,7 @@ import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; -import com.pahimar.ee3.core.helper.ItemDropHelper; +import com.pahimar.ee3.core.helper.ItemHelper; /** * Equivalent-Exchange-3 @@ -28,12 +28,12 @@ public class EntityLivingHandler { public void onEntityLivingDeath(LivingDeathEvent event) { if (event.source.getDamageType().equals("player")) { - ItemDropHelper.dropMiniumShard((EntityPlayer) event.source.getSourceOfDamage(), event.entityLiving); + ItemHelper.dropMiniumShard((EntityPlayer) event.source.getSourceOfDamage(), event.entityLiving); } if (event.source.getSourceOfDamage() instanceof EntityArrow) { if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity != null) { if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity instanceof EntityPlayer) { - ItemDropHelper.dropMiniumShard((EntityPlayer) ((EntityArrow) event.source.getSourceOfDamage()).shootingEntity, event.entityLiving); + ItemHelper.dropMiniumShard((EntityPlayer) ((EntityArrow) event.source.getSourceOfDamage()).shootingEntity, event.entityLiving); } } } diff --git a/ee3_common/com/pahimar/ee3/core/handlers/TransmutationTargetOverlayHandler.java b/ee3_common/com/pahimar/ee3/core/handlers/TransmutationTargetOverlayHandler.java index 4ba75b71..632a2b25 100644 --- a/ee3_common/com/pahimar/ee3/core/handlers/TransmutationTargetOverlayHandler.java +++ b/ee3_common/com/pahimar/ee3/core/handlers/TransmutationTargetOverlayHandler.java @@ -52,7 +52,7 @@ public class TransmutationTargetOverlayHandler implements ITickHandler { if (player != null) { currentItemStack = player.inventory.getCurrentItem(); - if (minecraft.isGuiEnabled() && minecraft.inGameHasFocus) { + if (Minecraft.isGuiEnabled() && minecraft.inGameHasFocus) { if (currentItemStack != null && currentItemStack.getItem() instanceof ITransmutationStone && ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION) { renderStoneHUD(minecraft, player, currentItemStack, (Float) tickData[0]); } diff --git a/ee3_common/com/pahimar/ee3/core/helper/ItemDropHelper.java b/ee3_common/com/pahimar/ee3/core/helper/ItemDropHelper.java deleted file mode 100644 index 22c773dd..00000000 --- a/ee3_common/com/pahimar/ee3/core/helper/ItemDropHelper.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.pahimar.ee3.core.helper; - -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.player.EntityPlayer; - -import com.pahimar.ee3.item.ModItems; - -/** - * Equivalent-Exchange-3 - * - * ItemDropHelper - * - * @author pahimar - * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) - * - */ -public class ItemDropHelper { - - private static double rand; - - public static void dropMiniumShard(EntityPlayer player, EntityLiving entity) { - - if (GeneralHelper.isHostileEntity(entity)) { - rand = Math.random(); - - if (rand < 0.15d) { - entity.dropItem(ModItems.miniumShard.itemID, 1); - } - } - } - -} diff --git a/ee3_common/com/pahimar/ee3/core/helper/ItemHelper.java b/ee3_common/com/pahimar/ee3/core/helper/ItemHelper.java new file mode 100644 index 00000000..0edaa9e3 --- /dev/null +++ b/ee3_common/com/pahimar/ee3/core/helper/ItemHelper.java @@ -0,0 +1,76 @@ +package com.pahimar.ee3.core.helper; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import com.pahimar.ee3.item.ModItems; +import com.pahimar.ee3.lib.Colours; +import com.pahimar.ee3.lib.Strings; + +/** + * Equivalent-Exchange-3 + * + * ItemDropHelper + * + * @author pahimar + * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) + * + */ +public class ItemHelper { + + private static double rand; + + public static boolean hasColor(ItemStack itemStack) { + + return !itemStack.hasTagCompound() ? false : !itemStack.getTagCompound().hasKey(Strings.NBT_ITEM_DISPLAY) ? false : itemStack.getTagCompound().getCompoundTag(Strings.NBT_ITEM_DISPLAY).hasKey(Strings.NBT_ITEM_COLOR); + } + + public static int getColor(ItemStack itemStack) { + + NBTTagCompound nbtTagCompound = itemStack.getTagCompound(); + + if (nbtTagCompound == null) + return Integer.parseInt(Colours.PURE_WHITE, 16); + else { + + NBTTagCompound displayTagCompound = nbtTagCompound.getCompoundTag(Strings.NBT_ITEM_DISPLAY); + return displayTagCompound == null ? Integer.parseInt(Colours.PURE_WHITE, 16) : displayTagCompound.hasKey(Strings.NBT_ITEM_COLOR) ? displayTagCompound.getInteger(Strings.NBT_ITEM_COLOR) : Integer.parseInt(Colours.PURE_WHITE, 16); + } + } + + public static void setColor(ItemStack itemStack, int color) { + + if (itemStack != null) { + + NBTTagCompound nbtTagCompound = itemStack.getTagCompound(); + + if (nbtTagCompound == null) { + + nbtTagCompound = new NBTTagCompound(); + itemStack.setTagCompound(nbtTagCompound); + } + + NBTTagCompound colourTagCompound = nbtTagCompound.getCompoundTag(Strings.NBT_ITEM_DISPLAY); + + if (!nbtTagCompound.hasKey(Strings.NBT_ITEM_DISPLAY)) { + nbtTagCompound.setCompoundTag(Strings.NBT_ITEM_DISPLAY, colourTagCompound); + } + + colourTagCompound.setInteger(Strings.NBT_ITEM_COLOR, color); + } + } + + public static void dropMiniumShard(EntityPlayer player, EntityLiving entity) { + + if (GeneralHelper.isHostileEntity(entity)) { + rand = Math.random(); + + if (rand < 0.15d) { + entity.dropItem(ModItems.miniumShard.itemID, 1); + } + } + } + +} diff --git a/ee3_common/com/pahimar/ee3/core/proxy/ClientProxy.java b/ee3_common/com/pahimar/ee3/core/proxy/ClientProxy.java index 660e8c52..f0a11467 100644 --- a/ee3_common/com/pahimar/ee3/core/proxy/ClientProxy.java +++ b/ee3_common/com/pahimar/ee3/core/proxy/ClientProxy.java @@ -21,6 +21,7 @@ import com.pahimar.ee3.client.renderer.tileentity.TileEntityGlassBellRenderer; import com.pahimar.ee3.core.handlers.DrawBlockHighlightHandler; import com.pahimar.ee3.core.handlers.KeyBindingHandler; import com.pahimar.ee3.core.handlers.TransmutationTargetOverlayHandler; +import com.pahimar.ee3.core.helper.ItemHelper; import com.pahimar.ee3.core.helper.KeyBindingHelper; import com.pahimar.ee3.core.helper.TransmutationHelper; import com.pahimar.ee3.item.IChargeable; @@ -131,8 +132,21 @@ public class ClientProxy extends CommonProxy { } @Override - public void handleTileWithItemPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData) { + public void handleTileWithItemPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData, int stackSize, int color) { + TileEntity tileEntity = FMLClientHandler.instance().getClient().theWorld.getBlockTileEntity(x, y, z); + + this.handleTileEntityPacket(x, y, z, orientation, state, customName); + + if (tileEntity != null) { + if (tileEntity instanceof TileGlassBell) { + + ItemStack itemStack = new ItemStack(itemID, stackSize, metaData); + ItemHelper.setColor(itemStack, color); + + ((TileGlassBell) tileEntity).setInventorySlotContents(0, itemStack); + } + } } @Override diff --git a/ee3_common/com/pahimar/ee3/core/proxy/CommonProxy.java b/ee3_common/com/pahimar/ee3/core/proxy/CommonProxy.java index c57421ae..e454fbd4 100644 --- a/ee3_common/com/pahimar/ee3/core/proxy/CommonProxy.java +++ b/ee3_common/com/pahimar/ee3/core/proxy/CommonProxy.java @@ -84,7 +84,7 @@ public class CommonProxy implements IGuiHandler { } - public void handleTileWithItemPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData) { + public void handleTileWithItemPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData, int stackSize, int color) { } diff --git a/ee3_common/com/pahimar/ee3/item/ItemAlchemicalBag.java b/ee3_common/com/pahimar/ee3/item/ItemAlchemicalBag.java index 66f26e6d..117e8cc1 100644 --- a/ee3_common/com/pahimar/ee3/item/ItemAlchemicalBag.java +++ b/ee3_common/com/pahimar/ee3/item/ItemAlchemicalBag.java @@ -8,6 +8,7 @@ import net.minecraft.util.Icon; import net.minecraft.world.World; import com.pahimar.ee3.EquivalentExchange3; +import com.pahimar.ee3.core.helper.ItemHelper; import com.pahimar.ee3.core.helper.NBTHelper; import com.pahimar.ee3.lib.Colours; import com.pahimar.ee3.lib.GuiIds; @@ -113,20 +114,12 @@ public class ItemAlchemicalBag extends ItemEE { public boolean hasColor(ItemStack itemStack) { - return !itemStack.hasTagCompound() ? false : !itemStack.getTagCompound().hasKey(Strings.NBT_ITEM_DISPLAY) ? false : itemStack.getTagCompound().getCompoundTag(Strings.NBT_ITEM_DISPLAY).hasKey(Strings.NBT_ITEM_COLOR); + return ItemHelper.hasColor(itemStack); } public int getColor(ItemStack itemStack) { - NBTTagCompound nbtTagCompound = itemStack.getTagCompound(); - - if (nbtTagCompound == null) - return Integer.parseInt(Colours.PURE_WHITE, 16); - else { - - NBTTagCompound displayTagCompound = nbtTagCompound.getCompoundTag(Strings.NBT_ITEM_DISPLAY); - return displayTagCompound == null ? Integer.parseInt(Colours.PURE_WHITE, 16) : displayTagCompound.hasKey(Strings.NBT_ITEM_COLOR) ? displayTagCompound.getInteger(Strings.NBT_ITEM_COLOR) : Integer.parseInt(Colours.PURE_WHITE, 16); - } + return ItemHelper.getColor(itemStack); } public void setColor(ItemStack itemStack, int color) { @@ -136,22 +129,7 @@ public class ItemAlchemicalBag extends ItemEE { // TODO Localize throw new UnsupportedOperationException("Can\'t dye non-bags!"); else { - - NBTTagCompound nbtTagCompound = itemStack.getTagCompound(); - - if (nbtTagCompound == null) { - - nbtTagCompound = new NBTTagCompound(); - itemStack.setTagCompound(nbtTagCompound); - } - - NBTTagCompound colourTagCompound = nbtTagCompound.getCompoundTag(Strings.NBT_ITEM_DISPLAY); - - if (!nbtTagCompound.hasKey(Strings.NBT_ITEM_DISPLAY)) { - nbtTagCompound.setCompoundTag(Strings.NBT_ITEM_DISPLAY, colourTagCompound); - } - - colourTagCompound.setInteger(Strings.NBT_ITEM_COLOR, color); + ItemHelper.setColor(itemStack, color); } } } diff --git a/ee3_common/com/pahimar/ee3/network/PacketTypeHandler.java b/ee3_common/com/pahimar/ee3/network/PacketTypeHandler.java index f4bc215a..22b91922 100644 --- a/ee3_common/com/pahimar/ee3/network/PacketTypeHandler.java +++ b/ee3_common/com/pahimar/ee3/network/PacketTypeHandler.java @@ -14,6 +14,7 @@ import com.pahimar.ee3.network.packet.PacketRequestEvent; import com.pahimar.ee3.network.packet.PacketSoundEvent; import com.pahimar.ee3.network.packet.PacketSpawnParticle; import com.pahimar.ee3.network.packet.PacketTileUpdate; +import com.pahimar.ee3.network.packet.PacketTileWithItemUpdate; /** * Equivalent-Exchange-3 @@ -25,9 +26,13 @@ import com.pahimar.ee3.network.packet.PacketTileUpdate; * */ public enum PacketTypeHandler { - KEY(PacketKeyPressed.class), TILE(PacketTileUpdate.class), REQUEST_EVENT( - PacketRequestEvent.class), SPAWN_PARTICLE(PacketSpawnParticle.class), SOUND_EVENT( - PacketSoundEvent.class), ITEM_UPDATE(PacketItemUpdate.class); + KEY(PacketKeyPressed.class), + TILE(PacketTileUpdate.class), + REQUEST_EVENT(PacketRequestEvent.class), + SPAWN_PARTICLE(PacketSpawnParticle.class), + SOUND_EVENT(PacketSoundEvent.class), + ITEM_UPDATE(PacketItemUpdate.class), + TILE_WITH_ITEM(PacketTileWithItemUpdate.class); private Class clazz; diff --git a/ee3_common/com/pahimar/ee3/network/packet/PacketTileUpdate.java b/ee3_common/com/pahimar/ee3/network/packet/PacketTileUpdate.java index 266137f2..f8f4a8a3 100644 --- a/ee3_common/com/pahimar/ee3/network/packet/PacketTileUpdate.java +++ b/ee3_common/com/pahimar/ee3/network/packet/PacketTileUpdate.java @@ -69,6 +69,7 @@ public class PacketTileUpdate extends PacketEE { @Override public void execute(INetworkManager manager, Player player) { + System.out.println("PacketTileUpdate - Execute"); EquivalentExchange3.proxy.handleTileEntityPacket(x, y, z, ForgeDirection.getOrientation(orientation), state, customName); } diff --git a/ee3_common/com/pahimar/ee3/network/packet/PacketTileWithItemUpdate.java b/ee3_common/com/pahimar/ee3/network/packet/PacketTileWithItemUpdate.java index aeb37602..1b0b4426 100644 --- a/ee3_common/com/pahimar/ee3/network/packet/PacketTileWithItemUpdate.java +++ b/ee3_common/com/pahimar/ee3/network/packet/PacketTileWithItemUpdate.java @@ -13,21 +13,32 @@ import com.pahimar.ee3.network.PacketTypeHandler; import cpw.mods.fml.common.network.Player; -public class PacketTileWithItemUpdate extends PacketTileUpdate { +public class PacketTileWithItemUpdate extends PacketEE { - public int itemID; - public int metaData; + public int x, y, z; + public byte orientation; + public byte state; + public String customName; + public int itemID, metaData, stackSize, color; public PacketTileWithItemUpdate() { - super(); + super(PacketTypeHandler.TILE_WITH_ITEM, true); } - public PacketTileWithItemUpdate(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData) { + public PacketTileWithItemUpdate(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData, int stackSize, int color) { - super(x, y, z, orientation, state, customName); + super(PacketTypeHandler.TILE_WITH_ITEM, true); + this.x = x; + this.y = y; + this.z = z; + this.orientation = (byte) orientation.ordinal(); + this.state = state; + this.customName = customName; this.itemID = itemID; this.metaData = metaData; + this.stackSize = stackSize; + this.color = color; } @Override @@ -41,6 +52,8 @@ public class PacketTileWithItemUpdate extends PacketTileUpdate { data.writeUTF(customName); data.writeInt(itemID); data.writeInt(metaData); + data.writeInt(stackSize); + data.writeInt(color); } @Override @@ -54,11 +67,14 @@ public class PacketTileWithItemUpdate extends PacketTileUpdate { customName = data.readUTF(); itemID = data.readInt(); metaData = data.readInt(); + stackSize = data.readInt(); + color = data.readInt(); } @Override public void execute(INetworkManager manager, Player player) { - EquivalentExchange3.proxy.handleTileWithItemPacket(x, y, z, ForgeDirection.getOrientation(orientation), state, customName, itemID, metaData); + System.out.println("PacketTileWithItemUpdate - Execute"); + EquivalentExchange3.proxy.handleTileWithItemPacket(x, y, z, ForgeDirection.getOrientation(orientation), state, customName, itemID, metaData, stackSize, color); } } diff --git a/ee3_common/com/pahimar/ee3/tileentity/TileEE.java b/ee3_common/com/pahimar/ee3/tileentity/TileEE.java index cb684654..ac92bf06 100644 --- a/ee3_common/com/pahimar/ee3/tileentity/TileEE.java +++ b/ee3_common/com/pahimar/ee3/tileentity/TileEE.java @@ -21,9 +21,9 @@ import com.pahimar.ee3.network.packet.PacketTileUpdate; */ public class TileEE extends TileEntity { - private ForgeDirection orientation; - private byte state; - private String customName; + protected ForgeDirection orientation; + protected byte state; + protected String customName; public TileEE() { diff --git a/ee3_common/com/pahimar/ee3/tileentity/TileGlassBell.java b/ee3_common/com/pahimar/ee3/tileentity/TileGlassBell.java index b1af9738..fcfc24c6 100644 --- a/ee3_common/com/pahimar/ee3/tileentity/TileGlassBell.java +++ b/ee3_common/com/pahimar/ee3/tileentity/TileGlassBell.java @@ -4,8 +4,12 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.packet.Packet; +import com.pahimar.ee3.core.helper.ItemHelper; import com.pahimar.ee3.lib.Strings; +import com.pahimar.ee3.network.PacketTypeHandler; +import com.pahimar.ee3.network.packet.PacketTileWithItemUpdate; public class TileGlassBell extends TileEE implements IInventory { @@ -13,6 +17,7 @@ public class TileGlassBell extends TileEE implements IInventory { * The ItemStacks that hold the items currently being used in the Glass Bell */ private ItemStack[] inventory; + private ItemStack ghostItemStack; private final int INVENTORY_SIZE = 1; @@ -21,6 +26,7 @@ public class TileGlassBell extends TileEE implements IInventory { public TileGlassBell() { inventory = new ItemStack[INVENTORY_SIZE]; + ghostItemStack = null; } @Override @@ -94,6 +100,16 @@ public class TileGlassBell extends TileEE implements IInventory { public void closeChest() { } + + public ItemStack getGhostItemStack() { + + return ghostItemStack; + } + + public void setGhostItemStack(ItemStack ghostItemStack) { + + this.ghostItemStack = ghostItemStack; + } @Override public void readFromNBT(NBTTagCompound nbtTagCompound) { @@ -141,4 +157,15 @@ public class TileGlassBell extends TileEE implements IInventory { return true; } + + @Override + public Packet getDescriptionPacket() { + + if ((inventory[0] != null) && (inventory[0].stackSize > 0)) { + return PacketTypeHandler.populatePacket(new PacketTileWithItemUpdate(xCoord, yCoord, zCoord, orientation, state, customName, inventory[0].itemID, inventory[0].getItemDamage(), inventory[0].stackSize, ItemHelper.getColor(inventory[0]))); + } + else { + return super.getDescriptionPacket(); + } + } }