Hi, I've been trying for days fiddling around with my handler class to try and create random custom mob drops. I want EntityWolf to have a 50% chance of dropping RawWolf. I have created the custom drop constructor and added "Random rand = new Random();" to it. At the moment, every time I kill a wolf it either drops 0, 1 or 2 RawWolf (because the nextInt is set to 3). How can I make it so it has a 50% chance of dropping 1 RawWolf and a 50% chance of dropping nothing.
Here is my code for my handler class:
public class IYPDropHandler {
@SubscribeEvent
public void addEntityDrop (LivingDropsEvent event){
if(event.entity instanceof EntityWolf){
Random rand = new Random();
ItemStack itemstack = new ItemStack(IYPItems.RawWolf, rand.nextInt(3));
event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, itemstack));
}
}
}
Also, is it possible to make it so the entity drops a different item (CookedWolf) when it is on fire and dies in the handler class?
Hi, I've been trying for days fiddling around with my handler class to try and create random custom mob drops. I want EntityWolf to have a 50% chance of dropping RawWolf. I have created the custom drop constructor and added "Random rand = new Random();" to it. At the moment, every time I kill a wolf it either drops 0, 1 or 2 RawWolf (because the nextInt is set to 3). How can I make it so it has a 50% chance of dropping 1 RawWolf and a 50% chance of dropping nothing.
Here is my code for my handler class:
Also, is it possible to make it so the entity drops a different item (CookedWolf) when it is on fire and dies in the handler class?
Thank you, help much appreciated.
Try the Mod Development section.
"We live on a placid island of ignorance in the midst of black seas of infinity, and it was not meant that we should voyage far."