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