Jump to content

[1.8.9] Backpack inventory is duping [Solved]


Recommended Posts

Alright, so I added some backpacks to my mod. The backpacks are entities with items stored in NBT, which hold the inventory. When you throw the back pack from your inventory, it creates a backpack entity instead. Right clicking opens the backpack, punching gives you back the item, etc, etc.


My problem is that after throwing an item into it, and moving the item, it dupes instead. Everything else is working as I need it (or so I believe).


This has been solved. Sorry.

Link to comment
Share on other sites

At a first glance in your inventory class in the decrStackSize method, I can see that you are performing the splitStack operation on the new stack you just created. So, to fix this you need to replace stack.splitStack with inventory[slot].splitStack.


No, no, that's not the problem. That's how it is supposed to function. They share the same pointer. The problem has to be somewhere in the saving/loading of the inventory. I just can't put my thumb on where.

Link to comment
Share on other sites

Ok, I have solved this.


I actually had the inventory loading from item every update, which caused the duping. I had originally done this to ensure it was getting loaded (cause when I dropped it on the ground, the inventory was always empty), and forgot to remove it when that didn't resolve it.


It now applies the inventory to the entity from the itemstack tag when I drop it, and that fixed all of it.


Thanks again for the time anyone took to read/reply to this.


Mods, you can close this :)

Link to comment
Share on other sites

It's not directly related to your problem, but you may want to consider moving your inventory to the


capability. This will allow the inventory to be stored in memory and only read from/written to NBT when needed instead of having to read/write every time you want to do something.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.