Fixed shift clicking crash, now saves the inventory of the chest
This commit is contained in:
parent
b41adffa60
commit
0e6d635e8d
7 changed files with 130 additions and 16 deletions
|
@ -1,10 +1,10 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
|
@ -73,6 +73,37 @@ public class TileQuantumChest extends TileEntity implements IInventory {
|
|||
readFromNBT(packet.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
inventory.readFromNBT(tagCompound);
|
||||
|
||||
storedItem = null;
|
||||
|
||||
if (tagCompound.hasKey("storedStack"))
|
||||
{
|
||||
storedItem = ItemStack.
|
||||
loadItemStackFromNBT((NBTTagCompound)tagCompound.getTag("storedStack"));
|
||||
}
|
||||
|
||||
if(storedItem != null){
|
||||
storedItem.stackSize = tagCompound.getInteger("storedQuantity");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
inventory.writeToNBT(tagCompound);
|
||||
if (storedItem != null)
|
||||
{
|
||||
tagCompound.setTag("storedStack", storedItem.writeToNBT(new NBTTagCompound()));
|
||||
tagCompound.setInteger("storedQuantity", storedItem.stackSize);
|
||||
}
|
||||
else
|
||||
tagCompound.setInteger("storedQuantity", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventory.getSizeInventory();
|
||||
|
|
|
@ -19,7 +19,7 @@ import techreborn.util.Tank;
|
|||
|
||||
public class TileQuantumTank extends TileEntity implements IFluidHandler, IInventory {
|
||||
|
||||
public Tank tank = new Tank("TileQuantumTank", 2000000000, this);
|
||||
public Tank tank = new Tank("TileQuantumTank", Integer.MAX_VALUE, this);
|
||||
public Inventory inventory = new Inventory(3, "TileQuantumTank", 64);
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue