Jump to content

Recommended Posts

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?

Posted
  On 10/23/2018 at 7:49 PM, Jiro7 said:

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

Expand  

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.

Posted
  On 10/23/2018 at 7:52 PM, 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.

Expand  

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?

Posted
  On 10/23/2018 at 8:08 PM, Jiro7 said:

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

Expand  

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));
}

 

Posted
  On 10/23/2018 at 8: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));
}

 

Expand  

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

  • 7 months later...
Posted
  On 10/23/2018 at 8: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));
}

 

Expand  

Where in mod main class should be this function?

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

Announcements



×
×
  • Create New...

Important Information

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