Jump to content

(1.18.2) How i can make that a entity when explodes drop a quantity of items with a porcentage?


SomeoneWhoNeedsHelp2

Recommended Posts

Hello, how the title says i have the question on how to make a mob drop a quantity of items when explodes.

What i want is that when the mob explodes, it drops 1 item 100% and 3 more with a 50%, the 4 are the same items.

But it would be enough if i can make the item drop with a posibility since i found a way to make it drop always.

I already wrote a code that makes the mob drop the item when explodes but i couldn't find a way to make it drop with a posibility (like a 50% chance).

I am using the default creeper private void explodeCreeper.

I also tried using the loot_tables but i couldn't find a way to make it drop the item when explodes but when dies.

Thank you for reading and trying helping me. (Also sorry for the typos, not my main language)

 

This is the code: 

-------------------------------------------------------------------------

private void explodeCreeper () {

if (!this.level.isClientSide) {

Explosion.BlockInteraction explosion$blockinteraction = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level, this) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE;

float f = this.isPowered() ? 2.0F : 1.0F;

this.dead = true;

this.level.explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, explosion$blockinteraction);

this.discard();

this.spawnLingeringCloud();

this.spawnAtLocation(ModItems.POWEREDPOWDER.get());             <------ What i wrote

}

}                               

-------------------------------------------------------------------------

 

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.