Got rid of TileEntityBase

This commit is contained in:
Calclavia 2012-11-03 11:55:11 +08:00
parent 990c58fef7
commit cefb0245bd
5 changed files with 349 additions and 281 deletions

View file

@ -1,173 +0,0 @@
package assemblyline;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
import universalelectricity.prefab.TileEntityAdvanced;
import universalelectricity.prefab.network.IPacketReceiver;
public abstract class TileEntityBase extends TileEntityAdvanced implements IPacketReceiver, IInventory
{
/**
* The items this container contains.
*/
protected ItemStack[] containingItems = new ItemStack[this.getSizeInventory()];
/**
* The amount of players using this tile
* entity.
*/
protected int playerUsing = 0;
/**
* Is this tile entity locked?
*/
protected boolean locked = false;
/**
* The owner of this tile entity.
*/
protected String owner = "";
/**
* Inventory functions.
*/
@Override
public ItemStack getStackInSlot(int par1)
{
return this.containingItems[par1];
}
@Override
public ItemStack decrStackSize(int par1, int par2)
{
if (this.containingItems[par1] != null)
{
ItemStack var3;
if (this.containingItems[par1].stackSize <= par2)
{
var3 = this.containingItems[par1];
this.containingItems[par1] = null;
return var3;
}
else
{
var3 = this.containingItems[par1].splitStack(par2);
if (this.containingItems[par1].stackSize == 0)
{
this.containingItems[par1] = null;
}
return var3;
}
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int par1)
{
if (this.containingItems[par1] != null)
{
ItemStack var2 = this.containingItems[par1];
this.containingItems[par1] = null;
return var2;
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{
this.containingItems[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@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()
{
this.playerUsing++;
}
@Override
public void closeChest()
{
this.playerUsing--;
}
/**
* NBT Data
*/
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
this.locked = nbt.getBoolean("locked");
this.owner = nbt.getString("Owner");
NBTTagList var2 = nbt.getTagList("Items");
this.containingItems = new ItemStack[this.getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
{
NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 >= 0 && var5 < this.containingItems.length)
{
this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
}
/**
* Writes a tile entity to NBT.
*/
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setBoolean("locked", this.locked);
nbt.setString("Owner", this.owner);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.containingItems.length; ++var3)
{
if (this.containingItems[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte) var3);
this.containingItems[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
nbt.setTag("Items", var2);
}
}

View file

@ -3,6 +3,7 @@ package assemblyline.ai;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.FMLLog;
import universalelectricity.prefab.TileEntityAdvanced; import universalelectricity.prefab.TileEntityAdvanced;

View file

@ -6,31 +6,37 @@ import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.Entity; import net.minecraft.src.Entity;
import net.minecraft.src.EntityItem; import net.minecraft.src.EntityItem;
import net.minecraft.src.EntityPlayer; import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IInventory;
import net.minecraft.src.INetworkManager; import net.minecraft.src.INetworkManager;
import net.minecraft.src.ItemStack; import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound; import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
import net.minecraft.src.Packet; import net.minecraft.src.Packet;
import net.minecraft.src.Packet250CustomPayload; import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.Vector3; import universalelectricity.core.Vector3;
import universalelectricity.implement.IElectricityReceiver; import universalelectricity.prefab.TileEntityElectricityReceiver;
import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager; import universalelectricity.prefab.network.PacketManager;
import assemblyline.AssemblyLine; import assemblyline.AssemblyLine;
import assemblyline.TileEntityBase;
import assemblyline.belts.TileEntityConveyorBelt; import assemblyline.belts.TileEntityConveyorBelt;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.PacketDispatcher;
public class TileEntitySorter extends TileEntityBase implements IElectricityReceiver, IPacketReceiver public class TileEntitySorter extends TileEntityElectricityReceiver implements IPacketReceiver, IInventory
{ {
/**
* The items this container contains.
*/
protected ItemStack[] containingItems = new ItemStack[this.getSizeInventory()];
/** /**
* Used to id the packet types * Used to id the packet types
*/ */
private enum tPacketID private enum PacketTypes
{ {
ANIMATION, GUI, SETTINGON ANIMATION, GUI, SETTINGON
} }
@ -38,7 +44,8 @@ public class TileEntitySorter extends TileEntityBase implements IElectricityRece
/** /**
* Joules required per tick. * Joules required per tick.
*/ */
public static final int WATTS_REQUIRED = 10; public static final int JOULES_REQUIRED = 10;
/** /**
* Stored energy * Stored energy
*/ */
@ -50,20 +57,25 @@ public class TileEntitySorter extends TileEntityBase implements IElectricityRece
/** /**
* on/off value for the GUI buttons * on/off value for the GUI buttons
*/ */
public boolean[] onOff = new boolean[] public boolean[] guiButtons = new boolean[]
{ true, true, true, true, true }; { true, true, true, true, true };
/** /**
* the belt found in the search area * the belt found in the search area
*/ */
public TileEntityConveyorBelt beltSide = null; public TileEntityConveyorBelt beltSide = null;
private int playerUsing = 0;
@Override @Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
// has to update a bit faster than a
// conveyer belt /**
if (this.ticks % 5 == 0) * Has to update a bit faster than a
* conveyer belt
*/
if (this.ticks % 5 == 0 && !this.isDisabled())
{ {
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
@ -92,7 +104,7 @@ public class TileEntitySorter extends TileEntityBase implements IElectricityRece
boolean flag = false; boolean flag = false;
if (itemsBehind.size() > 0 && this.wattsReceived > this.WATTS_REQUIRED) if (itemsBehind.size() > 0 && this.wattsReceived > this.JOULES_REQUIRED)
{ {
// for every item found check // for every item found check
// if can be thrown then throw // if can be thrown then throw
@ -111,7 +123,7 @@ public class TileEntitySorter extends TileEntityBase implements IElectricityRece
// the area // the area
if (!worldObj.isRemote && flag) if (!worldObj.isRemote && flag)
{ {
Packet packet = PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.data(tPacketID.ANIMATION)); Packet packet = PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.data(PacketTypes.ANIMATION));
PacketManager.sendPacketToClients(packet, worldObj, Vector3.get(this), 30); PacketManager.sendPacketToClients(packet, worldObj, Vector3.get(this), 30);
} }
@ -122,7 +134,7 @@ public class TileEntitySorter extends TileEntityBase implements IElectricityRece
} }
if (!worldObj.isRemote && this.playerUsing > 0) if (!worldObj.isRemote && this.playerUsing > 0)
{ {
Packet packet = PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.data(tPacketID.GUI)); Packet packet = PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.data(PacketTypes.GUI));
PacketManager.sendPacketToClients(packet, worldObj, Vector3.get(this), 10); PacketManager.sendPacketToClients(packet, worldObj, Vector3.get(this), 10);
} }
} }
@ -148,7 +160,7 @@ public class TileEntitySorter extends TileEntityBase implements IElectricityRece
entity.motionX = (double) side.offsetX * 0.1; entity.motionX = (double) side.offsetX * 0.1;
entity.motionY += 0.10000000298023224D; entity.motionY += 0.10000000298023224D;
entity.motionZ = (double) side.offsetZ * 0.1; entity.motionZ = (double) side.offsetZ * 0.1;
this.wattsReceived -= this.WATTS_REQUIRED; this.wattsReceived -= this.JOULES_REQUIRED;
} }
public boolean canItemBeThrow(Entity entity) public boolean canItemBeThrow(Entity entity)
@ -159,13 +171,13 @@ public class TileEntitySorter extends TileEntityBase implements IElectricityRece
EntityItem itemE = (EntityItem) entity; EntityItem itemE = (EntityItem) entity;
ItemStack item = itemE.item; ItemStack item = itemE.item;
if (this.onOff[4]) if (this.guiButtons[4])
{ {
// reject matching items // reject matching items
for (int i = 0; i < this.containingItems.length; i++) for (int i = 0; i < this.containingItems.length; i++)
{ {
if (containingItems[i] != null && onOff[i]) if (containingItems[i] != null && guiButtons[i])
{ {
if (containingItems[i].itemID == item.itemID && containingItems[i].getItemDamage() == item.getItemDamage()) { return true; } if (containingItems[i].itemID == item.itemID && containingItems[i].getItemDamage() == item.getItemDamage()) { return true; }
} }
@ -173,12 +185,12 @@ public class TileEntitySorter extends TileEntityBase implements IElectricityRece
return false; return false;
} }
else if (!this.onOff[4]) else if (!this.guiButtons[4])
{ {
// reject all but matching items // reject all but matching items
for (int i = 0; i < this.containingItems.length; i++) for (int i = 0; i < this.containingItems.length; i++)
{ {
if (containingItems[i] != null && onOff[i]) if (containingItems[i] != null && guiButtons[i])
{ {
if (containingItems[i].itemID == item.itemID && containingItems[i].getItemDamage() == item.getItemDamage()) { return false; } if (containingItems[i].itemID == item.itemID && containingItems[i].getItemDamage() == item.getItemDamage()) { return false; }
} }
@ -222,56 +234,33 @@ public class TileEntitySorter extends TileEntityBase implements IElectricityRece
*/ */
public void changeOnOff(int i) public void changeOnOff(int i)
{ {
if (i >= this.onOff.length) { return; } if (i >= this.guiButtons.length) { return; }
if (this.onOff[i]) if (this.guiButtons[i])
{ {
this.onOff[i] = false; this.guiButtons[i] = false;
} }
else else
{ {
this.onOff[i] = true; this.guiButtons[i] = true;
} }
if (worldObj.isRemote) if (worldObj.isRemote)
{ {
Packet packet = PacketManager.getPacket("asmLine", this, tPacketID.SETTINGON.ordinal(), i); Packet packet = PacketManager.getPacket("asmLine", this, PacketTypes.SETTINGON.ordinal(), i);
PacketDispatcher.sendPacketToServer(packet); PacketDispatcher.sendPacketToServer(packet);
} }
} }
/** public Object[] data(PacketTypes id)
* Data methods
*/
@Override
public void readFromNBT(NBTTagCompound nbt)
{ {
super.readFromNBT(nbt); if (id == PacketTypes.ANIMATION) { return new Object[]
for (int i = 0; i < this.onOff.length; i++)
{
this.onOff[i] = nbt.getBoolean("onOff" + i);
}
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
for (int i = 0; i < this.onOff.length; i++)
{
nbt.setBoolean("onOff" + i, this.onOff[i]);
}
}
public Object[] data(tPacketID id)
{
if (id == tPacketID.ANIMATION) { return new Object[]
{ id.ordinal(), this.firePiston }; } { id.ordinal(), this.firePiston }; }
if (id == tPacketID.GUI) if (id == PacketTypes.GUI)
{ {
Object[] da = new Object[this.onOff.length]; Object[] da = new Object[this.guiButtons.length];
da[0] = id.ordinal(); da[0] = id.ordinal();
for (int i = 0; i < this.onOff.length; i++) for (int i = 0; i < this.guiButtons.length; i++)
{ {
da[i + 1] = onOff[i]; da[i + 1] = guiButtons[i];
} }
return da; return da;
} }
@ -285,20 +274,20 @@ public class TileEntitySorter extends TileEntityBase implements IElectricityRece
try try
{ {
int id = dataStream.readInt(); int id = dataStream.readInt();
tPacketID pID = tPacketID.values()[id]; PacketTypes pID = PacketTypes.values()[id];
System.out.print("\n id:" + id + " "); System.out.print("\n id:" + id + " ");
if (pID == tPacketID.ANIMATION) if (pID == PacketTypes.ANIMATION)
{ {
this.firePiston = dataStream.readBoolean(); this.firePiston = dataStream.readBoolean();
} }
else if (pID == tPacketID.GUI) else if (pID == PacketTypes.GUI)
{ {
for (int i = 0; i < this.onOff.length; i++) for (int i = 0; i < this.guiButtons.length; i++)
{ {
this.onOff[i] = dataStream.readBoolean(); this.guiButtons[i] = dataStream.readBoolean();
} }
} }
else if (pID == tPacketID.SETTINGON) else if (pID == PacketTypes.SETTINGON)
{ {
int num = dataStream.readInt(); int num = dataStream.readInt();
this.changeOnOff(num); this.changeOnOff(num);
@ -317,13 +306,7 @@ public class TileEntitySorter extends TileEntityBase implements IElectricityRece
@Override @Override
public String getInvName() public String getInvName()
{ {
return "Rejector"; return "Sorter";
}
@Override
public int getInventoryStackLimit()
{
return 1;
} }
@Override @Override
@ -332,21 +315,6 @@ public class TileEntitySorter extends TileEntityBase implements IElectricityRece
return 4; return 4;
} }
/**
* disabling methods
*/
@Override
public void onDisable(int duration)
{
}
@Override
public boolean isDisabled()
{
return false;
}
@Override @Override
public boolean canConnect(ForgeDirection side) public boolean canConnect(ForgeDirection side)
{ {
@ -365,7 +333,7 @@ public class TileEntitySorter extends TileEntityBase implements IElectricityRece
@Override @Override
public double wattRequest() public double wattRequest()
{ {
return WATTS_REQUIRED; return JOULES_REQUIRED;
} }
@Override @Override
@ -375,4 +343,148 @@ public class TileEntitySorter extends TileEntityBase implements IElectricityRece
} }
/**
* Inventory functions.
*/
@Override
public ItemStack getStackInSlot(int par1)
{
return this.containingItems[par1];
}
@Override
public ItemStack decrStackSize(int par1, int par2)
{
if (this.containingItems[par1] != null)
{
ItemStack var3;
if (this.containingItems[par1].stackSize <= par2)
{
var3 = this.containingItems[par1];
this.containingItems[par1] = null;
return var3;
}
else
{
var3 = this.containingItems[par1].splitStack(par2);
if (this.containingItems[par1].stackSize == 0)
{
this.containingItems[par1] = null;
}
return var3;
}
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int par1)
{
if (this.containingItems[par1] != null)
{
ItemStack var2 = this.containingItems[par1];
this.containingItems[par1] = null;
return var2;
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{
this.containingItems[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.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()
{
this.playerUsing++;
}
@Override
public void closeChest()
{
this.playerUsing--;
}
/**
* NBT Data
*/
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
for (int i = 0; i < this.guiButtons.length; i++)
{
this.guiButtons[i] = nbt.getBoolean("guiButton" + i);
}
NBTTagList var2 = nbt.getTagList("Items");
this.containingItems = new ItemStack[this.getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
{
NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 >= 0 && var5 < this.containingItems.length)
{
this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
}
/**
* Writes a tile entity to NBT.
*/
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
for (int i = 0; i < this.guiButtons.length; i++)
{
nbt.setBoolean("guiButton" + i, this.guiButtons[i]);
}
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.containingItems.length; ++var3)
{
if (this.containingItems[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte) var3);
this.containingItems[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
nbt.setTag("Items", var2);
}
@Override
public int getInventoryStackLimit()
{
return 1;
}
} }

View file

@ -1,18 +1,26 @@
package assemblyline.machines.crafter; package assemblyline.machines.crafter;
import com.google.common.io.ByteArrayDataInput;
import assemblyline.TileEntityBase;
import universalelectricity.implement.IElectricityReceiver;
import universalelectricity.prefab.TileEntityElectricityReceiver;
import net.minecraft.src.EntityPlayer; import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IInventory;
import net.minecraft.src.INetworkManager; import net.minecraft.src.INetworkManager;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
import net.minecraft.src.Packet250CustomPayload; import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import universalelectricity.prefab.TileEntityElectricityReceiver;
import universalelectricity.prefab.network.IPacketReceiver;
public class TileEntityCraftingArm extends TileEntityBase implements IElectricityReceiver import com.google.common.io.ByteArrayDataInput;
public class TileEntityCraftingArm extends TileEntityElectricityReceiver implements IInventory, IPacketReceiver
{ {
/**
* The items this container contains.
*/
protected ItemStack[] containingItems = new ItemStack[this.getSizeInventory()];
public enum armTasks public enum armTasks
{ {
NONE, COLLECT, MINE, PLACE, SORT, CRAFT NONE, COLLECT, MINE, PLACE, SORT, CRAFT
@ -38,9 +46,12 @@ public class TileEntityCraftingArm extends TileEntityBase implements IElectricit
*/ */
public armTasks task = armTasks.NONE; public armTasks task = armTasks.NONE;
private int playerUsing = 0;
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
if (this.ticks % 5 == 0 && !this.isDisabled() && this.hasTask && EntityArm != null) if (this.ticks % 5 == 0 && !this.isDisabled() && this.hasTask && EntityArm != null)
{ {
this.jouleReceived -= this.wattUsed; this.jouleReceived -= this.wattUsed;
@ -80,20 +91,6 @@ public class TileEntityCraftingArm extends TileEntityBase implements IElectricit
return false; return false;
} }
@Override
public void onDisable(int duration)
{
// TODO Auto-generated method stub
}
@Override
public boolean isDisabled()
{
// TODO Auto-generated method stub
return false;
}
@Override @Override
public boolean canConnect(ForgeDirection side) public boolean canConnect(ForgeDirection side)
{ {
@ -104,7 +101,6 @@ public class TileEntityCraftingArm extends TileEntityBase implements IElectricit
@Override @Override
public double getVoltage() public double getVoltage()
{ {
// TODO Auto-generated method stub
return 120; return 120;
} }
@ -124,15 +120,147 @@ public class TileEntityCraftingArm extends TileEntityBase implements IElectricit
@Override @Override
public int getSizeInventory() public int getSizeInventory()
{ {
// TODO Auto-generated method stub
return 1; return 1;
} }
@Override @Override
public String getInvName() public String getInvName()
{ {
// TODO Auto-generated method stub
return "RoboticArm"; return "RoboticArm";
} }
/**
* Inventory functions.
*/
@Override
public ItemStack getStackInSlot(int par1)
{
return this.containingItems[par1];
}
@Override
public ItemStack decrStackSize(int par1, int par2)
{
if (this.containingItems[par1] != null)
{
ItemStack var3;
if (this.containingItems[par1].stackSize <= par2)
{
var3 = this.containingItems[par1];
this.containingItems[par1] = null;
return var3;
}
else
{
var3 = this.containingItems[par1].splitStack(par2);
if (this.containingItems[par1].stackSize == 0)
{
this.containingItems[par1] = null;
}
return var3;
}
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int par1)
{
if (this.containingItems[par1] != null)
{
ItemStack var2 = this.containingItems[par1];
this.containingItems[par1] = null;
return var2;
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{
this.containingItems[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@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()
{
this.playerUsing ++;
}
@Override
public void closeChest()
{
this.playerUsing--;
}
/**
* NBT Data
*/
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
NBTTagList var2 = nbt.getTagList("Items");
this.containingItems = new ItemStack[this.getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
{
NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 >= 0 && var5 < this.containingItems.length)
{
this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
}
/**
* Writes a tile entity to NBT.
*/
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.containingItems.length; ++var3)
{
if (this.containingItems[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte) var3);
this.containingItems[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
nbt.setTag("Items", var2);
}
} }

View file

@ -31,7 +31,7 @@ public class GuiSorter extends GuiContainer {
int wid = (this.width - this.xSize) / 2; int wid = (this.width - this.xSize) / 2;
int hig = (this.height - this.ySize) / 2; int hig = (this.height - this.ySize) / 2;
this.controlList.add(new GuiButton(0, wid + 112, hig + 32, 44,19, "Toggle")); this.controlList.add(new GuiButton(0, wid + 112, hig + 32, 44,19, "Toggle"));
for(int i = 1; i < this.tileEntity.onOff.length; i++) for(int i = 1; i < this.tileEntity.guiButtons.length; i++)
{ {
this.controlList.add(new GuiButtonImage(i, wid + 17 + i*18, hig + 17, 0)); this.controlList.add(new GuiButtonImage(i, wid + 17 + i*18, hig + 17, 0));
} }
@ -72,7 +72,7 @@ public class GuiSorter extends GuiContainer {
*/ */
@Override @Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) { protected void drawGuiContainerForegroundLayer(int par1, int par2) {
this.fontRenderer.drawString("Ejector Settings", 55, 6, 4210752); this.fontRenderer.drawString(this.tileEntity.getInvName(), 55, 6, 4210752);
this.fontRenderer.drawString( this.fontRenderer.drawString(
"Voltage: " + (int) this.tileEntity.getVoltage(), 95, 60, "Voltage: " + (int) this.tileEntity.getVoltage(), 95, 60,
4210752); 4210752);
@ -98,12 +98,12 @@ public class GuiSorter extends GuiContainer {
this.xSize, this.ySize); this.xSize, this.ySize);
//GUI button changes //GUI button changes
for(int i = 1; i < this.tileEntity.onOff.length; i++) for(int i = 1; i < this.tileEntity.guiButtons.length; i++)
{ {
this.drawTexturedModalRect(containerWidth+17+i*18, containerHeight+17, 176, +(tileEntity.onOff[i] ? 12 : 0), 12, 12); this.drawTexturedModalRect(containerWidth+17+i*18, containerHeight+17, 176, +(tileEntity.guiButtons[i] ? 12 : 0), 12, 12);
} }
this.fontRenderer.drawString( this.fontRenderer.drawString(
"Reject: "+(tileEntity.onOff[0] ? "Inv" : "Other"), containerWidth + 108, "Reject: "+(tileEntity.guiButtons[0] ? "Inv" : "Other"), containerWidth + 108,
containerHeight +22, 4210752); containerHeight +22, 4210752);
} }
} }