Jump to content

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


Recommended Posts

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)

 

Posted

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?

Posted

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?

Posted

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.

Posted

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

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

Announcements



×
×
  • Create New...

Important Information

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