Jump to content

How to make a block drop different items with different amount


SaltStation

Recommended Posts

Hello everyone.

 

I have been working on an ore which is supposed to have a chance of dropping additional items with varying amount.

I found a method wich seams to be depricated and does not work any more.

 

@Deprecated
public ArrayList<ItemStack> onBlockDestroyedByPlayer(World world, int x, int y, int z, int metadata, int fortune){

    ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
    drops.add(new ItemStack(Items.COAL, world.rand.nextInt(100) + 1));
    drops.add(new ItemStack(Items.APPLE, world.rand.nextInt(10) + 1));
    if (world.rand.nextFloat() < 0.5F)
        drops.add(new ItemStack(Items.DIAMOND));
    return drops;


}

Are there any similar methods or did I make some stupid mistake?

 

Thank you in advance.

Link to comment
Share on other sites

5 minutes ago, SaltStation said:

Are there any similar methods or did I make some stupid mistake?

What version are you modding for?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

2 minutes ago, SaltStation said:

1.12

Override the getDrops method in your block class and add the ItemStacks you want to be dropped to the List passed in as the parameter.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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