Posted February 16, 201411 yr 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!
February 16, 201411 yr 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. Creator of Jobo's ModLoader If I helped you could you please click the thank you button and applaud my karma.
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.