Removed unused inventory classes

This commit is contained in:
Henry Mao 2012-12-29 12:48:43 +08:00
parent f6b4ce8f98
commit 585a2b9599
13 changed files with 75 additions and 328 deletions

View file

@ -15,6 +15,7 @@ import cpw.mods.fml.relauncher.SideOnly;
*
*/
@SideOnly(Side.CLIENT)
@Deprecated
public class GuiButtonImage extends GuiButton
{
private int type = 0;

View file

@ -1,106 +0,0 @@
package assemblyline.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.ContainerRejector;
import assemblyline.common.machine.TileEntityRejector;
public class GuiRejector extends GuiContainer
{
private TileEntityRejector tileEntity;
private int containerWidth;
private int containerHeight;
public GuiRejector(InventoryPlayer par1InventoryPlayer, TileEntityRejector tileEntity)
{
super(new ContainerRejector(par1InventoryPlayer, tileEntity));
this.tileEntity = tileEntity;
}
public void initGui()
{
super.initGui();
Keyboard.enableRepeatEvents(true);
this.controlList.clear();
int wid = (this.width - this.xSize) / 2;
int hig = (this.height - this.ySize) / 2;
this.controlList.add(new GuiButton(0, wid + 112, hig + 32, 44, 19, "Toggle"));
for (int i = 1; i < this.tileEntity.guiButtons.length; i++)
{
this.controlList.add(new GuiButtonImage(i, wid + 17 + i * 18, hig + 17, 0));
}
}
public void updateScreen()
{
super.updateScreen();
}
/**
* Fired when a control is clicked. This is the equivalent of
* ActionListener.actionPerformed(ActionEvent e).
*/
protected void actionPerformed(GuiButton button)
{
if (button.id < 5)
{
this.tileEntity.changeOnOff(button.id);
}
super.actionPerformed(button);
}
protected void keyTyped(char par1, int par2)
{
super.keyTyped(par1, par2);
}
protected void mouseClicked(int par1, int par2, int par3)
{
super.mouseClicked(par1, par2, par3);
}
public void onGuiClosed()
{
super.onGuiClosed();
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
this.fontRenderer.drawString(this.tileEntity.getInvName(), 55, 6, 4210752);
this.fontRenderer.drawString("Voltage: " + (int) this.tileEntity.getVoltage(), 95, 60, 4210752);
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int var4 = this.mc.renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "gui_ejector.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4);
containerWidth = (this.width - this.xSize) / 2;
containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
// GUI button changes
for (int i = 1; i < this.tileEntity.guiButtons.length; i++)
{
this.drawTexturedModalRect(containerWidth + 17 + i * 18, containerHeight + 17, 176, +(tileEntity.guiButtons[i] ? 12 : 0), 12, 12);
}
this.fontRenderer.drawString((tileEntity.guiButtons[0] ? "Inv" : "Other"), containerWidth + 108, containerHeight + 22, 4210752);
}
}

View file

@ -10,8 +10,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import universalelectricity.core.vector.Vector3;
import assemblyline.common.machine.TileEntityFilterable;
import assemblyline.common.machine.filter.ItemFilter;
import assemblyline.common.machine.filter.TileEntityFilterable;
/**
* @author Briman0094

View file

@ -7,7 +7,7 @@ import net.minecraft.world.World;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.UETab;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.common.machine.detector.BlockFilterable;
import assemblyline.common.machine.filter.BlockFilterable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -1,83 +0,0 @@
package assemblyline.common.machine;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ContainerRejector extends Container
{
private TileEntityRejector tileEntity;
public ContainerRejector(InventoryPlayer par1InventoryPlayer, TileEntityRejector tileEntity)
{
this.tileEntity = tileEntity;
for (int i = 0; i < 4; i++)
{
this.addSlotToContainer(new Slot(tileEntity, 0 + i, 33 + i * 18, 34));
}
int var3;
for (var3 = 0; var3 < 3; ++var3)
{
for (int var4 = 0; var4 < 9; ++var4)
{
this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
}
}
for (var3 = 0; var3 < 9; ++var3)
{
this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142));
}
}
@Override
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
{
return this.tileEntity.isUseableByPlayer(par1EntityPlayer);
}
/**
* Called to transfer a stack from one inventory to the other eg. when shift clicking.
*/
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1)
{
ItemStack itemStack3 = null;
Slot itemStack = (Slot) this.inventorySlots.get(par1);
if (itemStack != null && itemStack.getHasStack())
{
ItemStack itemStack2 = itemStack.getStack();
itemStack3 = itemStack2.copy();
if (par1 != 0)
{
if (itemStack2.itemID == Item.coal.shiftedIndex)
{
if (!this.mergeItemStack(itemStack2, 0, 1, false)) { return null; }
}
else if (par1 >= 30 && par1 < 37 && !this.mergeItemStack(itemStack2, 3, 30, false)) { return null; }
}
else if (!this.mergeItemStack(itemStack2, 3, 37, false)) { return null; }
if (itemStack2.stackSize == 0)
{
itemStack.putStack((ItemStack) null);
}
else
{
itemStack.onSlotChanged();
}
if (itemStack2.stackSize == itemStack3.stackSize) { return null; }
itemStack.onPickupFromSlot(par1EntityPlayer, itemStack2);
}
return itemStack3;
}
}

View file

@ -1,5 +1,6 @@
package assemblyline.common.machine;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.item.EntityItem;
@ -8,7 +9,6 @@ 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.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
@ -20,7 +20,7 @@ import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.implement.IRedstoneReceptor;
import universalelectricity.prefab.network.PacketManager;
import assemblyline.api.IManipulator;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.filter.TileEntityFilterable;
import com.google.common.io.ByteArrayDataInput;
@ -182,9 +182,12 @@ public class TileEntityManipulator extends TileEntityFilterable implements IReds
}
@Override
public Packet getDescriptionPacket()
public ArrayList getPacketData()
{
return PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.isOutput, this.wattsReceived);
ArrayList list = super.getPacketData();
list.add(this.isOutput);
list.add(this.wattsReceived);
return list;
}
@Override
@ -194,6 +197,8 @@ public class TileEntityManipulator extends TileEntityFilterable implements IReds
{
try
{
super.handlePacketData(network, packetType, packet, player, dataStream);
dataStream.readShort();
this.isOutput = dataStream.readBoolean();
this.wattsReceived = dataStream.readDouble();
}

View file

@ -15,6 +15,7 @@ import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.network.PacketManager;
import assemblyline.common.machine.filter.ItemFilter;
import assemblyline.common.machine.filter.TileEntityFilterable;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.relauncher.Side;
@ -26,15 +27,6 @@ import cpw.mods.fml.relauncher.Side;
*/
public class TileEntityRejector extends TileEntityFilterable
{
/**
* Used to id the packet types
*/
private enum PacketTypes
{
ANIMATION, INVENTORY, SETTINGON
}
/**
* should the piston fire, or be extended
*/
@ -54,7 +46,7 @@ public class TileEntityRejector extends TileEntityFilterable
*/
if (this.ticks % 5 == 0 && !this.isDisabled())
{
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
int metadata = this.getBlockMetadata();
this.firePiston = false;
// area to search for items
@ -110,12 +102,6 @@ public class TileEntityRejector extends TileEntityFilterable
}
}
/*
* @Override public Packet getDescriptionPacket() { return
* PacketManager.getPacket(AssemblyLine.CHANNEL, this,
* this.getPacketData(PacketTypes.INVENTORY)); }
*/
/**
* Used to move after it has been rejected
*
@ -160,58 +146,7 @@ public class TileEntityRejector extends TileEntityFilterable
}
/**
* Used to change any one of the boolean value of on/off array After changing the value if it
* was changed client side it will send a packet server side with the changes
*
* @param i
*/
public void changeOnOff(int i)
{
if (i >= this.guiButtons.length) { return; }
if (this.guiButtons[i])
{
this.guiButtons[i] = false;
}
else
{
this.guiButtons[i] = true;
}
Packet packet = PacketManager.getPacket("asmLine", this, new Object[] { PacketTypes.SETTINGON.ordinal(), i });
if (worldObj.isRemote)
{
PacketDispatcher.sendPacketToServer(packet);
}
else
{
PacketManager.sendPacketToClients(packet, worldObj, new Vector3(this), 10);
}
}
/*
* public Object[] getPacketData(PacketTypes id) { if (id == PacketTypes.ANIMATION) { return new
* Object[] { id.ordinal(), this.firePiston }; } if (id == PacketTypes.INVENTORY) { Object[] da
* = new Object[this.guiButtons.length + 1]; da[0] = id.ordinal();
*
* for (int i = 0; i < this.guiButtons.length; i++) { da[i + 1] = guiButtons[i]; } return da; }
* return new Object[] { id.ordinal() }; }
*/
/*
* @Override public void handlePacketData(INetworkManager network, int packetType,
* Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream) { try {
* int id = dataStream.readInt(); PacketTypes pID = PacketTypes.values()[id]; DataInputStream
* inputStream = new DataInputStream((InputStream) dataStream);
*
* if (pID == PacketTypes.ANIMATION) { this.firePiston = dataStream.readBoolean(); } else if
* (pID == PacketTypes.INVENTORY) { for (int i = 0; i < this.guiButtons.length; i++) {
* this.guiButtons[i] = dataStream.readBoolean(); } } else if (pID == PacketTypes.SETTINGON) {
* int num = dataStream.readInt(); this.changeOnOff(num); }
*
* } catch (Exception e) { e.printStackTrace(); } }
*/
/**
* inventory methods
* Inventory Methods
*/
@Override
public String getInvName()

View file

@ -8,6 +8,7 @@ import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.UETab;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.filter.BlockFilterable;
/**
* @author Briman0094

View file

@ -10,8 +10,8 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.prefab.network.PacketManager;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.TileEntityFilterable;
import assemblyline.common.machine.filter.ItemFilter;
import assemblyline.common.machine.filter.TileEntityFilterable;
public class TileEntityDetector extends TileEntityFilterable
{

View file

@ -1,4 +1,4 @@
package assemblyline.common.machine.detector;
package assemblyline.common.machine.filter;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
@ -12,7 +12,6 @@ import net.minecraft.world.World;
import universalelectricity.prefab.BlockMachine;
import universalelectricity.prefab.implement.IRedstoneReceptor;
import assemblyline.api.IFilterable;
import assemblyline.common.machine.filter.ItemFilter;
/**
* Extend this block class if a filter is allowed to be placed inside of this block.

View file

@ -1,10 +1,10 @@
package assemblyline.common.machine;
package assemblyline.common.machine.filter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
@ -17,9 +17,9 @@ 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;
import assemblyline.common.machine.TileEntityAssemblyNetwork;
import com.google.common.io.ByteArrayDataInput;
@ -151,35 +151,28 @@ public abstract class TileEntityFilterable extends TileEntityAssemblyNetwork imp
return 1;
}
/**
* Don't override this! Override getPackData() instead!
*/
@Override
public Packet getDescriptionPacket()
{
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.channel = AssemblyLine.CHANNEL;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
try
return PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.getPacketData().toArray());
}
public ArrayList getPacketData()
{
dos.writeInt(PacketType.TILEENTITY.ordinal());
dos.writeInt(this.xCoord);
dos.writeInt(this.yCoord);
dos.writeInt(this.zCoord);
ArrayList array = new ArrayList();
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;
array.add(tag);
return array;
}
@Override
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
{
if (worldObj.isRemote)
{
ByteArrayInputStream bis = new ByteArrayInputStream(packet.data);
DataInputStream dis = new DataInputStream(bis);
@ -198,6 +191,7 @@ public abstract class TileEntityFilterable extends TileEntityAssemblyNetwork imp
e.printStackTrace();
}
}
}
@Override
public void writeToNBT(NBTTagCompound nbt)

View file

@ -6,7 +6,7 @@ import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.UETab;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.common.machine.TileEntityRejector;
import assemblyline.common.machine.detector.BlockFilterable;
import assemblyline.common.machine.filter.BlockFilterable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -58,7 +58,7 @@ public class PacketManager implements IPacketHandler, IPacketReceiver
else
{
byte[] var2 = CompressedStreamTools.compress(tag);
stream.writeShort((short)var2.length);
stream.writeShort((short) var2.length);
stream.write(var2);
}
}
@ -168,10 +168,7 @@ public class PacketManager implements IPacketHandler, IPacketReceiver
{
try
{
if (FMLCommonHandler.instance().getMinecraftServerInstance() != null)
{
FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendPacketToAllPlayers(packet);
}
PacketDispatcher.sendPacketToAllPlayers(packet);
}
catch (Exception e)
{
@ -218,6 +215,10 @@ public class PacketManager implements IPacketHandler, IPacketReceiver
{
data.writeLong((Long) dataValue);
}
else if (dataValue instanceof NBTTagCompound)
{
writeNBTTagCompound((NBTTagCompound) dataValue, data);
}
}
return data;