2012-08-29 22:02:30 +02:00
|
|
|
package ee3.common.tile;
|
|
|
|
|
2012-09-28 22:05:29 +02:00
|
|
|
import ee3.common.block.ModBlocks;
|
2012-11-06 21:49:43 +01:00
|
|
|
import ee3.common.lib.Strings;
|
2012-09-28 22:05:29 +02:00
|
|
|
import net.minecraft.src.IInventory;
|
|
|
|
import net.minecraft.src.ItemStack;
|
2012-08-29 22:02:30 +02:00
|
|
|
import net.minecraft.src.NBTTagCompound;
|
2012-10-04 13:59:46 +02:00
|
|
|
import net.minecraft.src.NBTTagList;
|
2012-08-29 22:02:30 +02:00
|
|
|
|
2012-10-27 23:41:02 +02:00
|
|
|
/**
|
|
|
|
* TileCalcinator
|
|
|
|
*
|
|
|
|
* Calcinator tile entity, and all the logic associated with it
|
|
|
|
*
|
|
|
|
* @author pahimar
|
|
|
|
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
|
|
|
*
|
|
|
|
*/
|
2012-09-28 22:05:29 +02:00
|
|
|
public class TileCalcinator extends TileEE implements IInventory {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The ItemStacks that hold the items currently being used in the Calcinator
|
|
|
|
*/
|
|
|
|
private ItemStack[] calcinatorItemStacks = new ItemStack[3];
|
2012-08-29 22:02:30 +02:00
|
|
|
|
2012-09-28 22:05:29 +02:00
|
|
|
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
|
|
|
super.readFromNBT(nbtTagCompound);
|
2012-10-04 13:59:46 +02:00
|
|
|
|
|
|
|
// Read in the ItemStacks in the inventory from NBT
|
|
|
|
NBTTagList tagList = nbtTagCompound.getTagList("Items");
|
|
|
|
this.calcinatorItemStacks = new ItemStack[this.getSizeInventory()];
|
|
|
|
for (int i = 0; i < tagList.tagCount(); ++i) {
|
|
|
|
NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(i);
|
|
|
|
byte slot = tagCompound.getByte("Slot");
|
|
|
|
if (slot >= 0 && slot < this.calcinatorItemStacks.length) {
|
|
|
|
this.calcinatorItemStacks[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-29 22:02:30 +02:00
|
|
|
}
|
|
|
|
|
2012-09-28 22:05:29 +02:00
|
|
|
public void writeToNBT(NBTTagCompound nbtTagCompound) {
|
|
|
|
super.writeToNBT(nbtTagCompound);
|
2012-10-04 13:59:46 +02:00
|
|
|
|
|
|
|
// Write the ItemStacks in the inventory to NBT
|
|
|
|
NBTTagList tagList = new NBTTagList();
|
|
|
|
for (int currentIndex = 0; currentIndex < this.calcinatorItemStacks.length; ++currentIndex) {
|
|
|
|
if (this.calcinatorItemStacks[currentIndex] != null) {
|
|
|
|
NBTTagCompound tagCompound = new NBTTagCompound();
|
|
|
|
tagCompound.setByte("Slot", (byte)currentIndex);
|
|
|
|
this.calcinatorItemStacks[currentIndex].writeToNBT(tagCompound);
|
|
|
|
tagList.appendTag(tagCompound);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nbtTagCompound.setTag("Items", tagList);
|
|
|
|
|
2012-09-28 22:05:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number of slots in the inventory.
|
|
|
|
*/
|
|
|
|
public int getSizeInventory() {
|
|
|
|
return this.calcinatorItemStacks.length;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the stack in slot i
|
|
|
|
*/
|
|
|
|
public ItemStack getStackInSlot(int i) {
|
|
|
|
return this.calcinatorItemStacks[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack decrStackSize(int i, int j) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack getStackInSlotOnClosing(int i) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-08-29 22:02:30 +02:00
|
|
|
@Override
|
2012-09-28 22:05:29 +02:00
|
|
|
public void setInventorySlotContents(int var1, ItemStack var2) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getInvName() {
|
2012-11-06 21:49:43 +01:00
|
|
|
return "container." + Strings.CALCINATOR_NAME;
|
2012-08-29 22:02:30 +02:00
|
|
|
}
|
2012-09-28 22:05:29 +02:00
|
|
|
|
|
|
|
public int getInventoryStackLimit() {
|
|
|
|
return 64;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void openChest() { }
|
|
|
|
public void closeChest() { }
|
2012-08-29 22:02:30 +02:00
|
|
|
|
|
|
|
}
|