TrashCaster Posted March 31, 2016 Share Posted March 31, 2016 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. Quote Link to comment Share on other sites More sharing options...
TrashCaster Posted March 31, 2016 Author Share Posted March 31, 2016 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. Quote Link to comment Share on other sites More sharing options...
CHEESEBOT314 Posted March 31, 2016 Share Posted March 31, 2016 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. Quote Link to comment Share on other sites More sharing options...
TrashCaster Posted March 31, 2016 Author Share Posted March 31, 2016 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. Quote Link to comment Share on other sites More sharing options...
TrashCaster Posted March 31, 2016 Author Share Posted March 31, 2016 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 Quote Link to comment Share on other sites More sharing options...
Choonster Posted April 1, 2016 Share Posted April 1, 2016 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. Quote 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 More sharing options...
Recommended Posts
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.