2012-12-17 21:21:53 +01:00
|
|
|
package com.pahimar.ee3.tileentity;
|
|
|
|
|
|
|
|
import net.minecraft.inventory.IInventory;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.nbt.NBTTagList;
|
|
|
|
|
2012-12-19 19:09:56 +01:00
|
|
|
import com.pahimar.ee3.lib.Strings;
|
|
|
|
|
2012-12-17 21:21:53 +01: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)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class TileCalcinator extends TileEE implements IInventory {
|
2012-12-19 19:09:56 +01:00
|
|
|
|
|
|
|
/**
|
2012-12-17 21:21:53 +01:00
|
|
|
* The ItemStacks that hold the items currently being used in the Calcinator
|
|
|
|
*/
|
2012-12-19 19:09:56 +01:00
|
|
|
private ItemStack[] calcinatorItemStacks = new ItemStack[3];
|
2012-12-17 21:21:53 +01:00
|
|
|
|
|
|
|
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
2012-12-19 19:09:56 +01:00
|
|
|
|
|
|
|
super.readFromNBT(nbtTagCompound);
|
|
|
|
|
|
|
|
// Read in the ItemStacks in the inventory from NBT
|
|
|
|
NBTTagList tagList = nbtTagCompound.getTagList("Items");
|
2012-12-17 21:21:53 +01:00
|
|
|
this.calcinatorItemStacks = new ItemStack[this.getSizeInventory()];
|
|
|
|
for (int i = 0; i < tagList.tagCount(); ++i) {
|
2012-12-19 19:09:56 +01:00
|
|
|
NBTTagCompound tagCompound = (NBTTagCompound) tagList.tagAt(i);
|
2012-12-17 21:21:53 +01:00
|
|
|
byte slot = tagCompound.getByte("Slot");
|
|
|
|
if (slot >= 0 && slot < this.calcinatorItemStacks.length) {
|
|
|
|
this.calcinatorItemStacks[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
|
|
|
|
}
|
|
|
|
}
|
2012-12-19 19:09:56 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void writeToNBT(NBTTagCompound nbtTagCompound) {
|
|
|
|
|
|
|
|
super.writeToNBT(nbtTagCompound);
|
|
|
|
|
|
|
|
// Write the ItemStacks in the inventory to NBT
|
|
|
|
NBTTagList tagList = new NBTTagList();
|
2012-12-17 21:21:53 +01:00
|
|
|
for (int currentIndex = 0; currentIndex < this.calcinatorItemStacks.length; ++currentIndex) {
|
|
|
|
if (this.calcinatorItemStacks[currentIndex] != null) {
|
|
|
|
NBTTagCompound tagCompound = new NBTTagCompound();
|
2012-12-19 19:09:56 +01:00
|
|
|
tagCompound.setByte("Slot", (byte) currentIndex);
|
2012-12-17 21:21:53 +01:00
|
|
|
this.calcinatorItemStacks[currentIndex].writeToNBT(tagCompound);
|
|
|
|
tagList.appendTag(tagCompound);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nbtTagCompound.setTag("Items", tagList);
|
|
|
|
|
2012-12-19 19:09:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-12-17 21:21:53 +01:00
|
|
|
* Returns the number of slots in the inventory.
|
|
|
|
*/
|
2012-12-19 19:09:56 +01:00
|
|
|
public int getSizeInventory() {
|
2012-12-17 21:21:53 +01:00
|
|
|
|
2012-12-19 19:09:56 +01:00
|
|
|
return this.calcinatorItemStacks.length;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-12-17 21:21:53 +01:00
|
|
|
* Returns the stack in slot i
|
|
|
|
*/
|
2012-12-19 19:09:56 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setInventorySlotContents(int var1, ItemStack var2) {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getInvName() {
|
|
|
|
|
|
|
|
return "container." + Strings.CALCINATOR_NAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getInventoryStackLimit() {
|
|
|
|
|
|
|
|
return 64;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void openChest() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void closeChest() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-12-17 21:21:53 +01:00
|
|
|
}
|