Posted March 31, 20169 yr 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.
March 31, 20169 yr Author I don't mean to prematurely bump this, but if there's anyone who can point me in the right direction, that'd be swell.
March 31, 20169 yr 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.
March 31, 20169 yr Author 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.
March 31, 20169 yr Author 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
April 1, 20169 yr It's not directly related to your problem, but you may want to consider moving your inventory to the IItemHandler 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.
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.