2015-02-20 22:45:33 +01:00
|
|
|
package ellpeck.someprettyrandomstuff.tile;
|
|
|
|
|
|
|
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.nbt.NBTTagList;
|
|
|
|
|
|
|
|
public class TileEntityGiantChest extends TileEntityInventoryBase{
|
|
|
|
|
|
|
|
public TileEntityGiantChest(){
|
|
|
|
super(169, "tileEntityGiantChest");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeToNBT(NBTTagCompound compound){
|
|
|
|
super.writeToNBT(compound);
|
|
|
|
NBTTagList tagList = new NBTTagList();
|
|
|
|
for(int currentIndex = 0; currentIndex < slots.length; ++currentIndex){
|
|
|
|
if (slots[currentIndex] != null){
|
|
|
|
NBTTagCompound tagCompound = new NBTTagCompound();
|
|
|
|
//Too many slots to get saved as Byte
|
|
|
|
tagCompound.setShort("Slot", (short)currentIndex);
|
|
|
|
slots[currentIndex].writeToNBT(tagCompound);
|
|
|
|
tagList.appendTag(tagCompound);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
compound.setTag("Items", tagList);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void readFromNBT(NBTTagCompound compound){
|
|
|
|
super.readFromNBT(compound);
|
|
|
|
NBTTagList tagList = compound.getTagList("Items", 10);
|
|
|
|
for (int i = 0; i < tagList.tagCount(); ++i){
|
|
|
|
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
|
|
|
|
//Too many slots to get saved as Byte
|
|
|
|
short slotIndex = tagCompound.getShort("Slot");
|
|
|
|
if (slotIndex >= 0 && slotIndex < slots.length){
|
|
|
|
slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-03-07 02:23:31 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canUpdate(){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isItemValidForSlot(int i, ItemStack stack){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
|
|
|
return this.isItemValidForSlot(slot, stack);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canExtractItem(int slot, ItemStack stack, int side){
|
|
|
|
return true;
|
|
|
|
}
|
2015-02-20 22:45:33 +01:00
|
|
|
}
|