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.

[Solved] [1.8] Potions get Replaced with Regeneration Potion in Chest Generator

Featured Replies

Posted

My chest generator is working fine except for this problem where potions with metadata 8194+ all show up as regeneration potions (8193) in my chests. I don't know if this is a metadata issue with Forge or a silly mistake I'm making, but I can't seem to figure it out. I haven't tested other potions so I don't know if others will do the same thing.

 

Here are the lines of code for the potions:

 

chestContents_High.addItem(new WeightedRandomChestContent(new ItemStack(Item.getItemById(373), 8193, 1), 1, 1, 20)); // Regeneration Potion (0:45)

chestContents_High.addItem(new WeightedRandomChestContent(new ItemStack(Item.getItemById(373), 8194, 1), 1, 1, 20)); // Swiftness Potion (3:00)

chestContents_High.addItem(new WeightedRandomChestContent(new ItemStack(Item.getItemById(373), 8195, 1), 1, 1, 20)); // Fire Resistance Potion (3:00)

chestContents_High.addItem(new WeightedRandomChestContent(new ItemStack(Item.getItemById(373), 8196, 1), 1, 1, 20)); // Poison Potion (0:45)

chestContents_High.addItem(new WeightedRandomChestContent(new ItemStack(Item.getItemById(373), 8197, 1), 1, 1, 20)); // Healing Potion

chestContents_High.addItem(new WeightedRandomChestContent(new ItemStack(Item.getItemById(373), 8198, 1), 1, 1, 20)); // Night Vision Potion (3:00)

chestContents_High.addItem(new WeightedRandomChestContent(new ItemStack(Item.getItemById(373), 8200, 1), 1, 1, 20)); // Weakness Potion (1:30)

chestContents_High.addItem(new WeightedRandomChestContent(new ItemStack(Item.getItemById(373), 8201, 1), 1, 1, 15)); // Strength Potion (3:00)

chestContents_High.addItem(new WeightedRandomChestContent(new ItemStack(Item.getItemById(373), 8202, 1), 1, 1, 20)); // Slowness Potion (1:30)

 

You should NOT be using Item.getItemById, especially in this case since you clearly know exactly what item you want: Items.potionitem.

 

That aside, how do you know your potions are getting replaced? Did you put a breakpoint in / log all items generated, or did you just generate a few chests and look at their contents in game?

  • Author

That aside, how do you know your potions are getting replaced? Did you put a breakpoint in / log all items generated, or did you just generate a few chests and look at their contents in game?

 

I actually replaced all the blocks in a huge custom structure with chests and I can definitely tell, since there are many other non-potion items, that all potions are being replaced with regeneration potions. Also, does using Item.getItemById cause this problem?

No, it doesn't cause that, but you should reference the item you want directly, rather than relying on ids which can vary from game to game. Item 373 could be something completely different when I load up Minecraft vs. when you do.

 

Anyway, your problem is that you have mixed up the item damage and the item stack size arguments in ItemStack - switch the potion id to the 3rd argument.

  • Author

Anyway, your problem is that you have mixed up the item damage and the item stack size arguments in ItemStack - switch the potion id to the 3rd argument.

 

Thank you! I had lots of other items in my generator and there was a big gap between items using metadata so I didn't notice confusing the arguments.

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.