Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

  • 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.

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.

  • 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.

  • 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 :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.