Net sync for item rendering in the Glass Bell. Light levels still not immediately synced though. Working on that.
This commit is contained in:
parent
4e5c5ecff1
commit
dbf52792b3
17 changed files with 189 additions and 88 deletions
|
@ -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
|
||||||
|
|
|
@ -2,8 +2,6 @@ package com.pahimar.ee3.block;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
|
@ -13,7 +11,6 @@ import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.IBlockAccess;
|
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)
|
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec)
|
||||||
{
|
{
|
||||||
int metaData = world.getBlockMetadata(x, y, z) & 7;
|
int metaData = world.getBlockMetadata(x, y, z) & 7;
|
||||||
float f = 0.15F;
|
|
||||||
|
|
||||||
switch (ForgeDirection.getOrientation(metaData)) {
|
switch (ForgeDirection.getOrientation(metaData)) {
|
||||||
case DOWN: {
|
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);
|
this.setBlockBounds(0.33F, 0.125F, 0.125F, 1.0F, 0.875F, 0.875F);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case UNKNOWN: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.collisionRayTrace(world, x, y, z, startVec, endVec);
|
return super.collisionRayTrace(world, x, y, z, startVec, endVec);
|
||||||
|
|
|
@ -45,7 +45,6 @@ public class ModBlocks {
|
||||||
//GameRegistry.registerBlock(redWaterFlowing, Strings.RED_WATER_FLOWING_NAME);
|
//GameRegistry.registerBlock(redWaterFlowing, Strings.RED_WATER_FLOWING_NAME);
|
||||||
|
|
||||||
initBlockRecipes();
|
initBlockRecipes();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initBlockRecipes() {
|
private static void initBlockRecipes() {
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
for (int i = 0; i < tileGlassBell.getSizeInventory(); i++) {
|
for (int i = 0; i < tileGlassBell.getSizeInventory(); i++) {
|
||||||
|
|
||||||
if (tileGlassBell.getStackInSlot(i) != null) {
|
if (tileGlassBell.getStackInSlot(i) != null) {
|
||||||
|
|
||||||
float scaleFactor = getGhostItemScaleFactor(tileGlassBell.getStackInSlot(i));
|
float scaleFactor = getGhostItemScaleFactor(tileGlassBell.getStackInSlot(i));
|
||||||
|
@ -93,7 +94,6 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer {
|
||||||
|
|
||||||
customRenderItem.doRenderItem(ghostEntityItem, 0, 0, 0, 0, 0);
|
customRenderItem.doRenderItem(ghostEntityItem, 0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
@ -143,6 +143,12 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer {
|
||||||
GL11.glRotatef(-90F, 1F, 0F, 0F);
|
GL11.glRotatef(-90F, 1F, 0F, 0F);
|
||||||
return;
|
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);
|
GL11.glTranslatef((float) x + 0.70F, (float) y + 0.5F, (float) z + 0.5F);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
case UNKNOWN: {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -203,6 +215,12 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer {
|
||||||
GL11.glTranslatef((float) x + 0.70F, (float) y + 0.4F, (float) z + 0.5F);
|
GL11.glTranslatef((float) x + 0.70F, (float) y + 0.4F, (float) z + 0.5F);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
case UNKNOWN: {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class DrawBlockHighlightHandler {
|
||||||
if (event.target.typeOfHit == EnumMovingObjectType.TILE) {
|
if (event.target.typeOfHit == EnumMovingObjectType.TILE) {
|
||||||
TransmutationHelper.updateTargetBlock(event.player.worldObj, event.target.blockX, event.target.blockY, event.target.blockZ);
|
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) {
|
if (ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION) {
|
||||||
drawInWorldTransmutationOverlay(event);
|
drawInWorldTransmutationOverlay(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import net.minecraftforge.event.ForgeSubscribe;
|
||||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
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
|
* Equivalent-Exchange-3
|
||||||
|
@ -28,12 +28,12 @@ public class EntityLivingHandler {
|
||||||
public void onEntityLivingDeath(LivingDeathEvent event) {
|
public void onEntityLivingDeath(LivingDeathEvent event) {
|
||||||
|
|
||||||
if (event.source.getDamageType().equals("player")) {
|
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 (event.source.getSourceOfDamage() instanceof EntityArrow) {
|
||||||
if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity != null) {
|
if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity != null) {
|
||||||
if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity instanceof EntityPlayer) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class TransmutationTargetOverlayHandler implements ITickHandler {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
currentItemStack = player.inventory.getCurrentItem();
|
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) {
|
if (currentItemStack != null && currentItemStack.getItem() instanceof ITransmutationStone && ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION) {
|
||||||
renderStoneHUD(minecraft, player, currentItemStack, (Float) tickData[0]);
|
renderStoneHUD(minecraft, player, currentItemStack, (Float) tickData[0]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
76
ee3_common/com/pahimar/ee3/core/helper/ItemHelper.java
Normal file
76
ee3_common/com/pahimar/ee3/core/helper/ItemHelper.java
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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.DrawBlockHighlightHandler;
|
||||||
import com.pahimar.ee3.core.handlers.KeyBindingHandler;
|
import com.pahimar.ee3.core.handlers.KeyBindingHandler;
|
||||||
import com.pahimar.ee3.core.handlers.TransmutationTargetOverlayHandler;
|
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.KeyBindingHelper;
|
||||||
import com.pahimar.ee3.core.helper.TransmutationHelper;
|
import com.pahimar.ee3.core.helper.TransmutationHelper;
|
||||||
import com.pahimar.ee3.item.IChargeable;
|
import com.pahimar.ee3.item.IChargeable;
|
||||||
|
@ -131,8 +132,21 @@ public class ClientProxy extends CommonProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
@Override
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.util.Icon;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import com.pahimar.ee3.EquivalentExchange3;
|
import com.pahimar.ee3.EquivalentExchange3;
|
||||||
|
import com.pahimar.ee3.core.helper.ItemHelper;
|
||||||
import com.pahimar.ee3.core.helper.NBTHelper;
|
import com.pahimar.ee3.core.helper.NBTHelper;
|
||||||
import com.pahimar.ee3.lib.Colours;
|
import com.pahimar.ee3.lib.Colours;
|
||||||
import com.pahimar.ee3.lib.GuiIds;
|
import com.pahimar.ee3.lib.GuiIds;
|
||||||
|
@ -113,20 +114,12 @@ public class ItemAlchemicalBag extends ItemEE {
|
||||||
|
|
||||||
public boolean hasColor(ItemStack itemStack) {
|
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) {
|
public int getColor(ItemStack itemStack) {
|
||||||
|
|
||||||
NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
|
return ItemHelper.getColor(itemStack);
|
||||||
|
|
||||||
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 void setColor(ItemStack itemStack, int color) {
|
public void setColor(ItemStack itemStack, int color) {
|
||||||
|
@ -136,22 +129,7 @@ public class ItemAlchemicalBag extends ItemEE {
|
||||||
// TODO Localize
|
// TODO Localize
|
||||||
throw new UnsupportedOperationException("Can\'t dye non-bags!");
|
throw new UnsupportedOperationException("Can\'t dye non-bags!");
|
||||||
else {
|
else {
|
||||||
|
ItemHelper.setColor(itemStack, color);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import com.pahimar.ee3.network.packet.PacketRequestEvent;
|
||||||
import com.pahimar.ee3.network.packet.PacketSoundEvent;
|
import com.pahimar.ee3.network.packet.PacketSoundEvent;
|
||||||
import com.pahimar.ee3.network.packet.PacketSpawnParticle;
|
import com.pahimar.ee3.network.packet.PacketSpawnParticle;
|
||||||
import com.pahimar.ee3.network.packet.PacketTileUpdate;
|
import com.pahimar.ee3.network.packet.PacketTileUpdate;
|
||||||
|
import com.pahimar.ee3.network.packet.PacketTileWithItemUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Equivalent-Exchange-3
|
* Equivalent-Exchange-3
|
||||||
|
@ -25,9 +26,13 @@ import com.pahimar.ee3.network.packet.PacketTileUpdate;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public enum PacketTypeHandler {
|
public enum PacketTypeHandler {
|
||||||
KEY(PacketKeyPressed.class), TILE(PacketTileUpdate.class), REQUEST_EVENT(
|
KEY(PacketKeyPressed.class),
|
||||||
PacketRequestEvent.class), SPAWN_PARTICLE(PacketSpawnParticle.class), SOUND_EVENT(
|
TILE(PacketTileUpdate.class),
|
||||||
PacketSoundEvent.class), ITEM_UPDATE(PacketItemUpdate.class);
|
REQUEST_EVENT(PacketRequestEvent.class),
|
||||||
|
SPAWN_PARTICLE(PacketSpawnParticle.class),
|
||||||
|
SOUND_EVENT(PacketSoundEvent.class),
|
||||||
|
ITEM_UPDATE(PacketItemUpdate.class),
|
||||||
|
TILE_WITH_ITEM(PacketTileWithItemUpdate.class);
|
||||||
|
|
||||||
private Class<? extends PacketEE> clazz;
|
private Class<? extends PacketEE> clazz;
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ public class PacketTileUpdate extends PacketEE {
|
||||||
@Override
|
@Override
|
||||||
public void execute(INetworkManager manager, Player player) {
|
public void execute(INetworkManager manager, Player player) {
|
||||||
|
|
||||||
|
System.out.println("PacketTileUpdate - Execute");
|
||||||
EquivalentExchange3.proxy.handleTileEntityPacket(x, y, z, ForgeDirection.getOrientation(orientation), state, customName);
|
EquivalentExchange3.proxy.handleTileEntityPacket(x, y, z, ForgeDirection.getOrientation(orientation), state, customName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,21 +13,32 @@ import com.pahimar.ee3.network.PacketTypeHandler;
|
||||||
import cpw.mods.fml.common.network.Player;
|
import cpw.mods.fml.common.network.Player;
|
||||||
|
|
||||||
|
|
||||||
public class PacketTileWithItemUpdate extends PacketTileUpdate {
|
public class PacketTileWithItemUpdate extends PacketEE {
|
||||||
|
|
||||||
public int itemID;
|
public int x, y, z;
|
||||||
public int metaData;
|
public byte orientation;
|
||||||
|
public byte state;
|
||||||
|
public String customName;
|
||||||
|
public int itemID, metaData, stackSize, color;
|
||||||
|
|
||||||
public PacketTileWithItemUpdate() {
|
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.itemID = itemID;
|
||||||
this.metaData = metaData;
|
this.metaData = metaData;
|
||||||
|
this.stackSize = stackSize;
|
||||||
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,6 +52,8 @@ public class PacketTileWithItemUpdate extends PacketTileUpdate {
|
||||||
data.writeUTF(customName);
|
data.writeUTF(customName);
|
||||||
data.writeInt(itemID);
|
data.writeInt(itemID);
|
||||||
data.writeInt(metaData);
|
data.writeInt(metaData);
|
||||||
|
data.writeInt(stackSize);
|
||||||
|
data.writeInt(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,11 +67,14 @@ public class PacketTileWithItemUpdate extends PacketTileUpdate {
|
||||||
customName = data.readUTF();
|
customName = data.readUTF();
|
||||||
itemID = data.readInt();
|
itemID = data.readInt();
|
||||||
metaData = data.readInt();
|
metaData = data.readInt();
|
||||||
|
stackSize = data.readInt();
|
||||||
|
color = data.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(INetworkManager manager, Player player) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@ import com.pahimar.ee3.network.packet.PacketTileUpdate;
|
||||||
*/
|
*/
|
||||||
public class TileEE extends TileEntity {
|
public class TileEE extends TileEntity {
|
||||||
|
|
||||||
private ForgeDirection orientation;
|
protected ForgeDirection orientation;
|
||||||
private byte state;
|
protected byte state;
|
||||||
private String customName;
|
protected String customName;
|
||||||
|
|
||||||
public TileEE() {
|
public TileEE() {
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,12 @@ import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
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.lib.Strings;
|
||||||
|
import com.pahimar.ee3.network.PacketTypeHandler;
|
||||||
|
import com.pahimar.ee3.network.packet.PacketTileWithItemUpdate;
|
||||||
|
|
||||||
public class TileGlassBell extends TileEE implements IInventory {
|
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
|
* The ItemStacks that hold the items currently being used in the Glass Bell
|
||||||
*/
|
*/
|
||||||
private ItemStack[] inventory;
|
private ItemStack[] inventory;
|
||||||
|
private ItemStack ghostItemStack;
|
||||||
|
|
||||||
private final int INVENTORY_SIZE = 1;
|
private final int INVENTORY_SIZE = 1;
|
||||||
|
|
||||||
|
@ -21,6 +26,7 @@ public class TileGlassBell extends TileEE implements IInventory {
|
||||||
public TileGlassBell() {
|
public TileGlassBell() {
|
||||||
|
|
||||||
inventory = new ItemStack[INVENTORY_SIZE];
|
inventory = new ItemStack[INVENTORY_SIZE];
|
||||||
|
ghostItemStack = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -95,6 +101,16 @@ public class TileGlassBell extends TileEE implements IInventory {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemStack getGhostItemStack() {
|
||||||
|
|
||||||
|
return ghostItemStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGhostItemStack(ItemStack ghostItemStack) {
|
||||||
|
|
||||||
|
this.ghostItemStack = ghostItemStack;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||||
|
|
||||||
|
@ -141,4 +157,15 @@ public class TileGlassBell extends TileEE implements IInventory {
|
||||||
|
|
||||||
return true;
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue