Empty commit
This commit is contained in:
parent
88596a9361
commit
142c25603a
3 changed files with 311 additions and 311 deletions
|
@ -1,39 +1,39 @@
|
|||
package assemblyline.client.render;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import assemblyline.common.machine.TileEntityFilterable;
|
||||
import assemblyline.common.machine.filter.ItemFilter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public abstract class RenderFilterable extends TileEntitySpecialRenderer
|
||||
{
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||
{
|
||||
if (tileEntity instanceof TileEntityFilterable)
|
||||
{
|
||||
TileEntityFilterable filterable = (TileEntityFilterable) tileEntity;
|
||||
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
|
||||
double dist = p.getDistance(filterable.xCoord, filterable.yCoord, filterable.zCoord);
|
||||
if (dist < 5)
|
||||
{
|
||||
ItemStack filter = filterable.getFilter();
|
||||
if (filter != null)
|
||||
{
|
||||
ArrayList<ItemStack> filters = ItemFilter.getFilters(filter);
|
||||
for (int i = 0; i < filters.size(); i++)
|
||||
{
|
||||
RenderHelper.renderFloatingText(filters.get(i).getTooltip(p, Minecraft.getMinecraft().gameSettings.advancedItemTooltips).get(0).toString(), (float) x + 0.5f, ((float) y + (i * 0.25f)) - 1f, (float) z + 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package assemblyline.client.render;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import assemblyline.common.machine.TileEntityFilterable;
|
||||
import assemblyline.common.machine.filter.ItemFilter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public abstract class RenderFilterable extends TileEntitySpecialRenderer
|
||||
{
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||
{
|
||||
if (tileEntity instanceof TileEntityFilterable)
|
||||
{
|
||||
TileEntityFilterable filterable = (TileEntityFilterable) tileEntity;
|
||||
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
|
||||
double dist = p.getDistance(filterable.xCoord, filterable.yCoord, filterable.zCoord);
|
||||
if (dist < 5)
|
||||
{
|
||||
ItemStack filter = filterable.getFilter();
|
||||
if (filter != null)
|
||||
{
|
||||
ArrayList<ItemStack> filters = ItemFilter.getFilters(filter);
|
||||
for (int i = 0; i < filters.size(); i++)
|
||||
{
|
||||
RenderHelper.renderFloatingText(filters.get(i).getTooltip(p, Minecraft.getMinecraft().gameSettings.advancedItemTooltips).get(0).toString(), (float) x + 0.5f, ((float) y + (i * 0.25f)) - 1f, (float) z + 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,50 +1,50 @@
|
|||
package assemblyline.client.render;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderHelper
|
||||
{
|
||||
public static void renderFloatingText(String text, float x, float y, float z)
|
||||
{
|
||||
RenderManager renderManager = RenderManager.instance;
|
||||
FontRenderer fontRenderer = renderManager.getFontRenderer();
|
||||
float scale = 0.027f;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.0F, (float) y + 2.3F, (float) z);
|
||||
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glScalef(-scale, -scale, scale);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
int yOffset = 0;
|
||||
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
tessellator.startDrawingQuads();
|
||||
int stringMiddle = fontRenderer.getStringWidth(text) / 2;
|
||||
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.5F);
|
||||
tessellator.addVertex((double) (-stringMiddle - 1), (double) (-1 + yOffset), 0.0D);
|
||||
tessellator.addVertex((double) (-stringMiddle - 1), (double) (8 + yOffset), 0.0D);
|
||||
tessellator.addVertex((double) (stringMiddle + 1), (double) (8 + yOffset), 0.0D);
|
||||
tessellator.addVertex((double) (stringMiddle + 1), (double) (-1 + yOffset), 0.0D);
|
||||
tessellator.draw();
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, 553648127);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glDepthMask(true);
|
||||
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, -1);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
package assemblyline.client.render;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderHelper
|
||||
{
|
||||
public static void renderFloatingText(String text, float x, float y, float z)
|
||||
{
|
||||
RenderManager renderManager = RenderManager.instance;
|
||||
FontRenderer fontRenderer = renderManager.getFontRenderer();
|
||||
float scale = 0.027f;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.0F, (float) y + 2.3F, (float) z);
|
||||
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glScalef(-scale, -scale, scale);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
int yOffset = 0;
|
||||
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
tessellator.startDrawingQuads();
|
||||
int stringMiddle = fontRenderer.getStringWidth(text) / 2;
|
||||
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.5F);
|
||||
tessellator.addVertex((double) (-stringMiddle - 1), (double) (-1 + yOffset), 0.0D);
|
||||
tessellator.addVertex((double) (-stringMiddle - 1), (double) (8 + yOffset), 0.0D);
|
||||
tessellator.addVertex((double) (stringMiddle + 1), (double) (8 + yOffset), 0.0D);
|
||||
tessellator.addVertex((double) (stringMiddle + 1), (double) (-1 + yOffset), 0.0D);
|
||||
tessellator.draw();
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, 553648127);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glDepthMask(true);
|
||||
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, -1);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,222 +1,222 @@
|
|||
package assemblyline.common.machine;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.prefab.implement.IRotatable;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
import universalelectricity.prefab.network.PacketManager.PacketType;
|
||||
import assemblyline.api.IFilterable;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
|
||||
public abstract class TileEntityFilterable extends TileEntityAssemblyNetwork implements IRotatable, IFilterable, IPacketReceiver, IInventory
|
||||
{
|
||||
private ItemStack filterItem;
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
{
|
||||
if (slot == 0)
|
||||
return filterItem;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount)
|
||||
{
|
||||
if (filterItem != null)
|
||||
{
|
||||
ItemStack stack;
|
||||
|
||||
if (filterItem.stackSize <= amount)
|
||||
{
|
||||
stack = filterItem;
|
||||
filterItem = null;
|
||||
return stack;
|
||||
}
|
||||
else
|
||||
{
|
||||
stack = filterItem.splitStack(amount);
|
||||
|
||||
if (filterItem.stackSize == 0)
|
||||
{
|
||||
filterItem = null;
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot)
|
||||
{
|
||||
if (filterItem != null)
|
||||
{
|
||||
ItemStack stack = filterItem;
|
||||
filterItem = null;
|
||||
return stack;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||
{
|
||||
filterItem = stack;
|
||||
|
||||
if (stack != null && stack.stackSize > this.getInventoryStackLimit())
|
||||
{
|
||||
stack.stackSize = this.getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilter(ItemStack filter)
|
||||
{
|
||||
this.setInventorySlotContents(0, filter);
|
||||
PacketManager.sendPacketToClients(getDescriptionPacket());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getFilter()
|
||||
{
|
||||
return this.getStackInSlot(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getDirection()
|
||||
{
|
||||
return ForgeDirection.getOrientation(this.getBlockMetadata());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection(ForgeDirection facingDirection)
|
||||
{
|
||||
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, facingDirection.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract String getInvName();
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.channel = AssemblyLine.CHANNEL;
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
try
|
||||
{
|
||||
dos.writeInt(PacketType.TILEENTITY.ordinal());
|
||||
dos.writeInt(xCoord);
|
||||
dos.writeInt(yCoord);
|
||||
dos.writeInt(zCoord);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
PacketManager.writeNBTTagCompound(tag, dos);
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
return packet;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
|
||||
{
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(packet.data);
|
||||
DataInputStream dis = new DataInputStream(bis);
|
||||
int id, x, y, z;
|
||||
try
|
||||
{
|
||||
id = dis.readInt();
|
||||
x = dis.readInt();
|
||||
y = dis.readInt();
|
||||
z = dis.readInt();
|
||||
NBTTagCompound tag = Packet.readNBTTagCompound(dis);
|
||||
readFromNBT(tag);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
NBTTagCompound filter = new NBTTagCompound();
|
||||
if (getFilter() != null)
|
||||
getFilter().writeToNBT(filter);
|
||||
nbt.setTag("filter", filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
NBTTagCompound filter = nbt.getCompoundTag("filter");
|
||||
setInventorySlotContents(0, ItemStack.loadItemStackFromNBT(filter));
|
||||
}
|
||||
|
||||
}
|
||||
package assemblyline.common.machine;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.prefab.implement.IRotatable;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
import universalelectricity.prefab.network.PacketManager.PacketType;
|
||||
import assemblyline.api.IFilterable;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
|
||||
public abstract class TileEntityFilterable extends TileEntityAssemblyNetwork implements IRotatable, IFilterable, IPacketReceiver, IInventory
|
||||
{
|
||||
private ItemStack filterItem;
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
{
|
||||
if (slot == 0)
|
||||
return filterItem;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount)
|
||||
{
|
||||
if (filterItem != null)
|
||||
{
|
||||
ItemStack stack;
|
||||
|
||||
if (filterItem.stackSize <= amount)
|
||||
{
|
||||
stack = filterItem;
|
||||
filterItem = null;
|
||||
return stack;
|
||||
}
|
||||
else
|
||||
{
|
||||
stack = filterItem.splitStack(amount);
|
||||
|
||||
if (filterItem.stackSize == 0)
|
||||
{
|
||||
filterItem = null;
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot)
|
||||
{
|
||||
if (filterItem != null)
|
||||
{
|
||||
ItemStack stack = filterItem;
|
||||
filterItem = null;
|
||||
return stack;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||
{
|
||||
filterItem = stack;
|
||||
|
||||
if (stack != null && stack.stackSize > this.getInventoryStackLimit())
|
||||
{
|
||||
stack.stackSize = this.getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilter(ItemStack filter)
|
||||
{
|
||||
this.setInventorySlotContents(0, filter);
|
||||
PacketManager.sendPacketToClients(getDescriptionPacket());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getFilter()
|
||||
{
|
||||
return this.getStackInSlot(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getDirection()
|
||||
{
|
||||
return ForgeDirection.getOrientation(this.getBlockMetadata());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection(ForgeDirection facingDirection)
|
||||
{
|
||||
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, facingDirection.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract String getInvName();
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.channel = AssemblyLine.CHANNEL;
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
try
|
||||
{
|
||||
dos.writeInt(PacketType.TILEENTITY.ordinal());
|
||||
dos.writeInt(xCoord);
|
||||
dos.writeInt(yCoord);
|
||||
dos.writeInt(zCoord);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
PacketManager.writeNBTTagCompound(tag, dos);
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
return packet;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
|
||||
{
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(packet.data);
|
||||
DataInputStream dis = new DataInputStream(bis);
|
||||
int id, x, y, z;
|
||||
try
|
||||
{
|
||||
id = dis.readInt();
|
||||
x = dis.readInt();
|
||||
y = dis.readInt();
|
||||
z = dis.readInt();
|
||||
NBTTagCompound tag = Packet.readNBTTagCompound(dis);
|
||||
readFromNBT(tag);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
NBTTagCompound filter = new NBTTagCompound();
|
||||
if (getFilter() != null)
|
||||
getFilter().writeToNBT(filter);
|
||||
nbt.setTag("filter", filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
NBTTagCompound filter = nbt.getCompoundTag("filter");
|
||||
setInventorySlotContents(0, ItemStack.loadItemStackFromNBT(filter));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue