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
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.

Posted
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?

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

 

Posted
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...
Posted
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?

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

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • The game crashed whilst unexpected error Error: net.minecraftforge.fml.ModLoadingException: Advanced Mining Dimension (mining_dimension) encountered an error during the done event phase
    • Here is the end of the log. it was way too big to put in pastebin, but I started from when I was online and everything was fine. Error should be in here: https://pastebin.com/Sdhdq593
    • Update: I stand corrected as I was able to dig up a relevant log from my earlier testing which highlights the overall issue but does not explain how to solve it. See, Diagnostic Logs for pack.mcmeta not found: https://pastebin.com/LXS8Rtna
    • Which mod was this? What are all the mods that were in use? It will help if enough information to replicate the problem is available.
    • I have been attempting to create a supplementary resource pack with Patchouli in order to add back the guidebook for Better End but unfortunately in every prototype I have made pack.mcmeta and my resource pack are not recognized. I have tested both zipped and unzipped and either way curseforge does not recognize my resource pack as existing. For testing I stripped my pack down to just the pack.mcmeta file and two empty folders labelled data and assets and I know the data folder is not the problem as firstly my first attempts just had an assets folder following Patchouli instructions and data came later in my flailing attempts to make anything in my pack work. The mcmeta file is not recognized whether or not I use this:  { "pack": { "pack_format": 15, "description": "A replacement for the BetterEnd Guide Book." } "language": { "en_US": { "name": "English", "region": "United States" } } } ,or this:  { "pack": { "pack_format": 15, "description": "A replacement for the BetterEnd Guide Book." } } I have made sure to only use lowercase and the pack folder is named better-end-guide. Is this some magic nonsense from me doing this manually instead of using an IDE or similar tool? Could it be because my files are by default in UTF-8 even though ANSI gives the same results? Is there a specific community secret tool I am supposed to use for zipping or specific settings? I am pulling my hair in distress. Unfortunately as there are no errors involved I lack logs to offer, if that disqualifies this thread please do not be harsh and instead if you can then please direct me to a forum with different rules and sufficiently respectful but knowledgeable as to be of assistance. Most of my experience with the programming community has been poor and so naturally I find myself wary.
  • Topics

×
×
  • Create New...

Important Information

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