- 5,018
- 47
- 783
Народ, извините за дублирование моей же темы, но я все-таки не могу понять, почему предметы не сохраняются в инвентаре механизма(в другом моде, это как то само собой получилось ) Вот код.
Как видите, есть и переменная, и я ее вроде бы сохраняю! Но нет- перезаход в игру- и в инвентаре как будто ничего не бывало.
[Ответ на опережение] данный TileEntity зареган.
Имеются идеи?
Код:
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
NBTTagList nbttaglist = nbt.getTagList("Items", 10);
this.furnaceItemStacks = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
byte b0 = nbttagcompound1.getByte("Slot");
if (b0 >= 0 && b0 < this.furnaceItemStacks.length)
{
this.furnaceItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
this.furnaceBurnTime = nbt.getShort("BurnTime");
this.furnaceCookTime = nbt.getShort("CookTime");
this.currentItemBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);
if (nbt.hasKey("CustomName", 8))
{
this.field_145958_o = nbt.getString("CustomName");
}
}
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setShort("BurnTime", (short)this.furnaceBurnTime);
nbt.setShort("CookTime", (short)this.furnaceCookTime);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.furnaceItemStacks.length; ++i)
{
if (this.furnaceItemStacks[i] != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte)i);
this.furnaceItemStacks[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
nbt.setTag("Items", nbttaglist);
if (this.hasCustomInventoryName())
{
nbt.setString("CustomName", this.field_145958_o);
}
}
Как видите, есть и переменная, и я ее вроде бы сохраняю! Но нет- перезаход в игру- и в инвентаре как будто ничего не бывало.
[Ответ на опережение] данный TileEntity зареган.
Имеются идеи?