mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Fixed bug where saving stuff to NBT would result an overflow
This commit is contained in:
parent
b80861f398
commit
b04d194eeb
@ -154,6 +154,11 @@ public class TileEntityFusionMultiblock extends TileEntity implements ISidedInve
|
|||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
NBTTagList list = nbt.getTagList("items", 10);
|
NBTTagList list = nbt.getTagList("items", 10);
|
||||||
|
|
||||||
|
water = nbt.getShort("water") * 1000;
|
||||||
|
deut = nbt.getShort("deut") * 1000;
|
||||||
|
power = nbt.getShort("power") * 1000;
|
||||||
|
trit = nbt.getShort("trit") * 1000;
|
||||||
|
|
||||||
slots = new ItemStack[getSizeInventory()];
|
slots = new ItemStack[getSizeInventory()];
|
||||||
|
|
||||||
for(int i = 0; i < list.tagCount(); i++)
|
for(int i = 0; i < list.tagCount(); i++)
|
||||||
@ -165,20 +170,15 @@ public class TileEntityFusionMultiblock extends TileEntity implements ISidedInve
|
|||||||
slots[b0] = ItemStack.loadItemStackFromNBT(nbt1);
|
slots[b0] = ItemStack.loadItemStackFromNBT(nbt1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
water = nbt.getShort("water");
|
|
||||||
deut = nbt.getShort("deut");
|
|
||||||
power = nbt.getShort("power");
|
|
||||||
trit = nbt.getShort("trit");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
nbt.setShort("water", (short) water);
|
nbt.setShort("water", (short) (water/1000));
|
||||||
nbt.setShort("deut", (short) deut);
|
nbt.setShort("deut", (short) (deut/1000));
|
||||||
nbt.setShort("power", (short) power);
|
nbt.setShort("power", (short) (power/1000));
|
||||||
nbt.setShort("trit", (short) trit);
|
nbt.setShort("trit", (short) (trit/1000));
|
||||||
NBTTagList list = new NBTTagList();
|
NBTTagList list = new NBTTagList();
|
||||||
|
|
||||||
for(int i = 0; i < slots.length; i++)
|
for(int i = 0; i < slots.length; i++)
|
||||||
@ -1018,11 +1018,19 @@ public class TileEntityFusionMultiblock extends TileEntity implements ISidedInve
|
|||||||
{
|
{
|
||||||
this.slots[2].stackSize--;
|
this.slots[2].stackSize--;
|
||||||
this.deut += 1000000;
|
this.deut += 1000000;
|
||||||
|
if(this.slots[2].stackSize == 0)
|
||||||
|
{
|
||||||
|
this.slots[2] = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(slots[3] != null && slots[3].getItem() == ModItems.cell_tritium && this.trit + 1000000 <= tritMax)
|
if(slots[3] != null && slots[3].getItem() == ModItems.cell_tritium && this.trit + 1000000 <= tritMax)
|
||||||
{
|
{
|
||||||
this.slots[3].stackSize--;
|
this.slots[3].stackSize--;
|
||||||
this.trit += 1000000;
|
this.trit += 1000000;
|
||||||
|
if(this.slots[3].stackSize == 0)
|
||||||
|
{
|
||||||
|
this.slots[3] = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(slots[0] != null && slots[0].getItem() == ModItems.inf_water)
|
if(slots[0] != null && slots[0].getItem() == ModItems.inf_water)
|
||||||
|
|||||||
@ -147,10 +147,10 @@ public class TileEntityMachineGenerator extends TileEntity implements ISidedInve
|
|||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
NBTTagList list = nbt.getTagList("items", 10);
|
NBTTagList list = nbt.getTagList("items", 10);
|
||||||
|
|
||||||
water = nbt.getShort("water");
|
water = nbt.getShort("water") * 100;
|
||||||
cool = nbt.getShort("cool");
|
cool = nbt.getShort("cool") * 100;
|
||||||
power = nbt.getShort("power");
|
power = nbt.getShort("power") * 100;
|
||||||
heat = nbt.getShort("heat");
|
heat = nbt.getShort("heat") * 100;
|
||||||
slots = new ItemStack[getSizeInventory()];
|
slots = new ItemStack[getSizeInventory()];
|
||||||
|
|
||||||
for(int i = 0; i < list.tagCount(); i++)
|
for(int i = 0; i < list.tagCount(); i++)
|
||||||
@ -167,10 +167,10 @@ public class TileEntityMachineGenerator extends TileEntity implements ISidedInve
|
|||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
nbt.setShort("water", (short) water);
|
nbt.setShort("water", (short) (water/100));
|
||||||
nbt.setShort("cool", (short) cool);
|
nbt.setShort("cool", (short) (cool/100));
|
||||||
nbt.setShort("power", (short) power);
|
nbt.setShort("power", (short) (power/100));
|
||||||
nbt.setShort("heat", (short) heat);
|
nbt.setShort("heat", (short) (heat/100));
|
||||||
NBTTagList list = new NBTTagList();
|
NBTTagList list = new NBTTagList();
|
||||||
|
|
||||||
for(int i = 0; i < slots.length; i++)
|
for(int i = 0; i < slots.length; i++)
|
||||||
|
|||||||
@ -174,6 +174,11 @@ public class TileEntityReactorMultiblock extends TileEntity implements ISidedInv
|
|||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
NBTTagList list = nbt.getTagList("items", 10);
|
NBTTagList list = nbt.getTagList("items", 10);
|
||||||
|
|
||||||
|
water = nbt.getShort("water") * 1000;
|
||||||
|
cool = nbt.getShort("cool") * 1000;
|
||||||
|
power = nbt.getShort("power") * 100;
|
||||||
|
heat = nbt.getShort("heat") * 100;
|
||||||
|
|
||||||
slots = new ItemStack[getSizeInventory()];
|
slots = new ItemStack[getSizeInventory()];
|
||||||
|
|
||||||
for(int i = 0; i < list.tagCount(); i++)
|
for(int i = 0; i < list.tagCount(); i++)
|
||||||
@ -185,20 +190,15 @@ public class TileEntityReactorMultiblock extends TileEntity implements ISidedInv
|
|||||||
slots[b0] = ItemStack.loadItemStackFromNBT(nbt1);
|
slots[b0] = ItemStack.loadItemStackFromNBT(nbt1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
water = nbt.getShort("water");
|
|
||||||
cool = nbt.getShort("cool");
|
|
||||||
power = nbt.getShort("power");
|
|
||||||
heat = nbt.getShort("heat");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
nbt.setShort("water", (short) water);
|
nbt.setShort("water", (short) (water/1000));
|
||||||
nbt.setShort("cool", (short) cool);
|
nbt.setShort("cool", (short) (cool/1000));
|
||||||
nbt.setShort("power", (short) power);
|
nbt.setShort("power", (short) (power/100));
|
||||||
nbt.setShort("heat", (short) heat);
|
nbt.setShort("heat", (short) (heat/100));
|
||||||
NBTTagList list = new NBTTagList();
|
NBTTagList list = new NBTTagList();
|
||||||
|
|
||||||
for(int i = 0; i < slots.length; i++)
|
for(int i = 0; i < slots.length; i++)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user