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

I've been searching about this but all the answers seem to be outdated. I want to change the drops of vanilla blocks. For example, I want Iron Ores to drop a custom item I made instead of the block itself. I also want to change the amount of lapis dropped.

 

I tried handling the BlockEvent.HarvestDropsEvent event, however it doesn't seem to have any method to change the drops nor drop amounts, just to change the drop chances. Any help?

6 minutes ago, Jiro7 said:

it doesn't seem to have any method to change the drops nor drop amounts

This is not true. BlockEvent.HarvestDropsEvent has a List<ItemStack> that contains all drops. You can access the list with HarvestDropsEvent#getDrops. You can then modify the list's contents as you want.

  • Author
13 minutes ago, V0idWa1k3r said:

This is not true. BlockEvent.HarvestDropsEvent has a List<ItemStack> that contains all drops. You can access the list with HarvestDropsEvent#getDrops. You can then modify the list's contents as you want.

Thanks, I managed to make it drop an item. However, there is only one value for drop chances, how can I give each drop on the list its own probability?

So for example I want it to drop between 1-3 iron nuggets and a 10% chance to drop an iron ingot. Is it possible?

8 minutes ago, Jiro7 said:

I want it to drop between 1-3 iron nuggets and a 10% chance to drop an iron ingot. Is it possible?

Have your random chance happen in the event. Add a new ItemStack to the list that is your nuggets with a count of 1 - 3 based on random number, then check against a random value and if it is within the range you want add an Iron ingot.

drops.add(new ItemStack(Items.IRON_NUGGET, 1 + rand.nextInt(2), 0));
if (rand.nextFloat() <= 0.1F)
{
	drops.add(new ItemStack(Items.IRON_INGOT, 1, 0));
}

 

  • Author
24 minutes ago, V0idWa1k3r said:

Have your random chance happen in the event. Add a new ItemStack to the list that is your nuggets with a count of 1 - 3 based on random number, then check against a random value and if it is within the range you want add an Iron ingot.


drops.add(new ItemStack(Items.IRON_NUGGET, 1 + rand.nextInt(2), 0));
if (rand.nextFloat() <= 0.1F)
{
	drops.add(new ItemStack(Items.IRON_INGOT, 1, 0));
}

 

Oh, that was simpler than I thought, thank you.

  • 7 months later...
On 10/23/2018 at 11:13 PM, V0idWa1k3r said:

Have your random chance happen in the event. Add a new ItemStack to the list that is your nuggets with a count of 1 - 3 based on random number, then check against a random value and if it is within the range you want add an Iron ingot.


drops.add(new ItemStack(Items.IRON_NUGGET, 1 + rand.nextInt(2), 0));
if (rand.nextFloat() <= 0.1F)
{
	drops.add(new ItemStack(Items.IRON_INGOT, 1, 0));
}

 

Where in mod main class should be this function?

Don't hijack old threads, make your own.

This wouldn't be in the main mod class, it would be in the event handler.

  • 6 months later...
  • Guest locked this topic
Guest
This topic is now closed to further replies.

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.