Fixed Battery NBT loading
This commit is contained in:
parent
b44ea67b46
commit
f5068bda2b
3 changed files with 52 additions and 53 deletions
|
@ -260,12 +260,6 @@ public class BatteryUpdateProtocol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Bingo");
|
|
||||||
System.out.println("Height: " + structureFound.height);
|
|
||||||
System.out.println("Length: " + structureFound.length);
|
|
||||||
System.out.println("Width: " + structureFound.width);
|
|
||||||
System.out.println("Volume: " + structureFound.locations.size());
|
|
||||||
|
|
||||||
for(Vector3 obj : structureFound.locations)
|
for(Vector3 obj : structureFound.locations)
|
||||||
{
|
{
|
||||||
TileEntityBattery tileEntity = (TileEntityBattery)obj.getTileEntity(pointer.worldObj);
|
TileEntityBattery tileEntity = (TileEntityBattery)obj.getTileEntity(pointer.worldObj);
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
||||||
@Override
|
@Override
|
||||||
public float getMaxEnergyStored()
|
public float getMaxEnergyStored()
|
||||||
{
|
{
|
||||||
return 100;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -46,18 +46,6 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
||||||
PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray());
|
PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ListUtil.getTop(structure.inventory) != null)
|
|
||||||
{
|
|
||||||
System.out.println("-----");
|
|
||||||
|
|
||||||
for(ItemStack stack : structure.inventory)
|
|
||||||
{
|
|
||||||
System.out.println(((IBattery)stack.getItem()).getEnergyStored(stack));
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("----");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ticks == 5 && !structure.isMultiblock)
|
if(ticks == 5 && !structure.isMultiblock)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
|
@ -106,25 +94,31 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
||||||
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||||
{
|
{
|
||||||
NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount);
|
NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount);
|
||||||
System.out.println("Yup!");
|
int slotID = tagCompound.getInteger("Slot");
|
||||||
structure.inventory.add(ItemStack.loadItemStackFromNBT(tagCompound));
|
structure.inventory.add(slotID, ItemStack.loadItemStackFromNBT(tagCompound));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Visible inventory
|
//Visible inventory
|
||||||
if(nbtTags.hasKey("VisibleItems"))
|
if(nbtTags.hasKey("VisibleItems"))
|
||||||
{
|
{
|
||||||
NBTTagList tagList1 = nbtTags.getTagList("VisibleItems");
|
NBTTagList tagList = nbtTags.getTagList("VisibleItems");
|
||||||
structure.visibleInventory = new ItemStack[3];
|
structure.visibleInventory = new ItemStack[3];
|
||||||
|
|
||||||
for(int tagCount = 0; tagCount < tagList1.tagCount(); tagCount++)
|
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||||
{
|
{
|
||||||
NBTTagCompound tagCompound = (NBTTagCompound)tagList1.tagAt(tagCount);
|
NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount);
|
||||||
byte slotID = tagCompound.getByte("Slot");
|
byte slotID = tagCompound.getByte("Slot");
|
||||||
|
|
||||||
if(slotID >= 0 && slotID < structure.visibleInventory.length)
|
if(slotID >= 0 && slotID < structure.visibleInventory.length)
|
||||||
{
|
{
|
||||||
setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound));
|
if(slotID == 0)
|
||||||
|
{
|
||||||
|
setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setInventorySlotContents(slotID+1, ItemStack.loadItemStackFromNBT(tagCompound));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,36 +132,47 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
||||||
if(!structure.wroteInventory)
|
if(!structure.wroteInventory)
|
||||||
{
|
{
|
||||||
//Inventory
|
//Inventory
|
||||||
NBTTagList tagList = new NBTTagList();
|
if(structure.inventory != null)
|
||||||
|
{
|
||||||
for(ItemStack itemStack : structure.inventory)
|
NBTTagList tagList = new NBTTagList();
|
||||||
{
|
|
||||||
if(itemStack != null)
|
for(int slotCount = 0; slotCount < structure.inventory.size(); slotCount++)
|
||||||
{
|
{
|
||||||
System.out.println("YESTYSET");
|
if(structure.inventory.get(slotCount) != null)
|
||||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
{
|
||||||
itemStack.writeToNBT(tagCompound);
|
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||||
tagList.appendTag(tagCompound);
|
tagCompound.setInteger("Slot", slotCount);
|
||||||
}
|
structure.inventory.get(slotCount).writeToNBT(tagCompound);
|
||||||
}
|
tagList.appendTag(tagCompound);
|
||||||
|
}
|
||||||
nbtTags.setTag("Items", tagList);
|
}
|
||||||
|
|
||||||
|
nbtTags.setTag("Items", tagList);
|
||||||
|
}
|
||||||
|
|
||||||
//Visible inventory
|
//Visible inventory
|
||||||
NBTTagList tagList1 = new NBTTagList();
|
if(structure.visibleInventory != null)
|
||||||
|
{
|
||||||
for(int slotCount = 0; slotCount < structure.visibleInventory.length; slotCount++)
|
NBTTagList tagList = new NBTTagList();
|
||||||
{
|
|
||||||
if(getStackInSlot(slotCount) != null)
|
for(int slotCount = 0; slotCount < structure.visibleInventory.length; slotCount++)
|
||||||
{
|
{
|
||||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
if(slotCount > 0)
|
||||||
tagCompound.setByte("Slot", (byte)slotCount);
|
{
|
||||||
getStackInSlot(slotCount).writeToNBT(tagCompound);
|
slotCount++;
|
||||||
tagList1.appendTag(tagCompound);
|
}
|
||||||
}
|
|
||||||
}
|
if(getStackInSlot(slotCount) != null)
|
||||||
|
{
|
||||||
nbtTags.setTag("VisibleItems", tagList1);
|
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||||
|
tagCompound.setByte("Slot", (byte)slotCount);
|
||||||
|
getStackInSlot(slotCount).writeToNBT(tagCompound);
|
||||||
|
tagList.appendTag(tagCompound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nbtTags.setTag("VisibleItems", tagList);
|
||||||
|
}
|
||||||
|
|
||||||
structure.wroteInventory = true;
|
structure.wroteInventory = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue