I just can't seem to figure this one out. I copied the code for saving my slots from a TileEntity nbt read write section I've created in the past. The TE works fine, but this IInventory doesn't seem to want to save. There must be a spot I'm missing a markDirty() [which contains the writeToNBT inside it]... Any ideas?
Rollback Post to RevisionRollBack
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
@Override
public void markDirty()
{
writeToNBT(Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem().getTagCompound());
for (int i = 0; i < getSizeInventory(); ++i)
{
if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0)
{
itemslots[i] = null;
}
}
}
because first you have to save your content and then you can set all slots to null.
P.S. the line Minecraft.getMinecraft().thePlayer will crash your minecraft when exexuted on client side. I suggest you to pass the EntityPlayer instance that opened the backpack in your constructor, save it in a variable and then reuse it
Soo Minecraft class is client only. (that means that the MC class loader will skip it). And nbt requires both sides for it to be functional. So instead of Minecraft.getMinecraft().thePlayer you need to save the player in the class and use it in the mark dirty method. Try launching the mod on the server and you'll get an error. SO you cant use Minecraft.getMinecraft().thePlayer it the code is ever going to run on server. aka it's not rendering classes or guis
Also you are setting all the slots to null when saving and that does not make much sense
Edit: Wops I didn't see the comment above! I didn't refresh the site before posting. Sorry for duplicate reply!
Sorry for not responding, I left for college and was getting in the swing of things again before you two answered this and haven't gotten around to checking until now.
Yup, your solution did in fact work, and it required the player that opened the instance to be passed instead of Minecraft.getMinecraft().thePlayer as well.
Thank you!
Rollback Post to RevisionRollBack
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
I know it's the NBT. It for some reason doesn't save correctly...
BTW @coolAlias I partially used your backpack git that you provided in another thread question a long time ago...
http://pastebin.com/2UEMQDfm
I just can't seem to figure this one out. I copied the code for saving my slots from a TileEntity nbt read write section I've created in the past. The TE works fine, but this IInventory doesn't seem to want to save. There must be a spot I'm missing a markDirty() [which contains the writeToNBT inside it]... Any ideas?
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
I think your code should be like this:
because first you have to save your content and then you can set all slots to null.
P.S. the line Minecraft.getMinecraft().thePlayer will crash your minecraft when exexuted on client side. I suggest you to pass the EntityPlayer instance that opened the backpack in your constructor, save it in a variable and then reuse it
sorry for my bad english I'm Italian
I see.
Soo Minecraft class is client only. (that means that the MC class loader will skip it). And nbt requires both sides for it to be functional. So instead of Minecraft.getMinecraft().thePlayer you need to save the player in the class and use it in the mark dirty method. Try launching the mod on the server and you'll get an error. SO you cant use Minecraft.getMinecraft().thePlayer it the code is ever going to run on server. aka it's not rendering classes or guis
Also you are setting all the slots to null when saving and that does not make much sense
Edit: Wops I didn't see the comment above! I didn't refresh the site before posting. Sorry for duplicate reply!
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
Sorry for not responding, I left for college and was getting in the swing of things again before you two answered this and haven't gotten around to checking until now.
Yup, your solution did in fact work, and it required the player that opened the instance to be passed instead of Minecraft.getMinecraft().thePlayer as well.
Thank you!
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
np
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
np
I know is the same message that wrote Lapis but I don't know what to say other than that
sorry for my bad english I'm Italian
hahahhaha xD
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.