Posted February 18, 20232 yr 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 } } -------------------------------------------------------------------------
February 18, 20232 yr You can try using a random value to do it. You can find more about creating random numbers here. I'm not good at modding, but at least I can read a crash report (well enough). That's something, right?
February 19, 20232 yr Author Yeah i saw what you send and i think it should work, but i can't figure where to put the int randomNum on the this.spawnAtLocation(ModItems.POWEREDPOWDER.get()), i tried putting randomNum on diferrent spots but i couldn't find the correct spot
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.