Jump to content

[1.6.2 Forge] Randomizer Item Help


squealy_squigs

Recommended Posts

Alright, so for the past few hours I tried many different combinations of codes, looking it up, and everything. I am trying to make an item that chooses a random item from an array list.

 

The code I have below is the one I once thought it was close, but I changed it, and I’m just not positive anymore. Am I heading in the wrong direction? How would I get to this item choosing a random item from a list of items I declare?

 

public ItemStack onItemRightClick(ItemStack var1, World var2){
var1.getItem();
return var1;



}

List item = Arrays.asList(Item.diamond, Item.bakedPotato, Item.appleRed, Item.book);



}

 

Most likely this code is wrong, I’m pretty sure of it. Any help would be great, thanks! :)

Link to comment
Share on other sites

All you need to do is create a new instance of random then make a new int of random with a cap of 32000 then check if that id is an item and if it is continue or else loop through and create a new int till it is then make an itemstack with it and then have it return that itemstack.

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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