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

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.

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.