Logged in as Ivorius.

[1.10] Add drops to mob death event

LexManos
Forge Code God
I'm curious about how this works.

I am "monitoring" when mobs dies, and I want to add drops to their list. This is what I'm doing, the "problem" is that I'm not sure, will this guarantee the drop 100% the time? Is there a way to pass a % chance of dropping the added item.

PS: Would it be ok to spawn the item on the world, so I can add a chance % there?

Code: [Select]
@SubscribeEvent
public void onLivingDropsEvent(LivingDropsEvent event) {

    Entity entity = event.getEntity();
    World world = event.getEntity().getEntityWorld();
    BlockPos pos = event.getEntity().getPosition();

    if(entity.getClass().equals(MobsReference.VANILLA_ZOMBIE)){

        EntityItem itemDropX = new EntityItem(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, ItemsReference.IRON_ORE.copy());

// world.spawnEntityInWorld(itemDropX);

        event.getDrops().add(itemDropX);

    }

}
Developer of CameraCraft.
You should get off the internet and grab a creeper plushie because you're 7 years old.
RainWarrior
Forge Rendering God Global Moderator Tree Puncher
I'm curious about how this works.

I am "monitoring" when mobs dies, and I want to add drops to their list. This is what I'm doing, the "problem" is that I'm not sure, will this guarantee the drop 100% the time? Is there a way to pass a % chance of dropping the added item.

PS: Would it be ok to spawn the item on the world, so I can add a chance % there?

Code: [Select]
@SubscribeEvent
public void onLivingDropsEvent(LivingDropsEvent event) {

    Entity entity = event.getEntity();
    World world = event.getEntity().getEntityWorld();
    BlockPos pos = event.getEntity().getPosition();

    if(entity.getClass().equals(MobsReference.VANILLA_ZOMBIE)){

        EntityItem itemDropX = new EntityItem(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, ItemsReference.IRON_ORE.copy());

// world.spawnEntityInWorld(itemDropX);

        event.getDrops().add(itemDropX);

    }

}
Developer of CameraCraft.
You should get off the internet and grab a creeper plushie because you're 7 years old.
Lomeli12
World Shaper
I'm curious about how this works.

I am "monitoring" when mobs dies, and I want to add drops to their list. This is what I'm doing, the "problem" is that I'm not sure, will this guarantee the drop 100% the time? Is there a way to pass a % chance of dropping the added item.

PS: Would it be ok to spawn the item on the world, so I can add a chance % there?

Code: [Select]
@SubscribeEvent
public void onLivingDropsEvent(LivingDropsEvent event) {

    Entity entity = event.getEntity();
    World world = event.getEntity().getEntityWorld();
    BlockPos pos = event.getEntity().getPosition();

    if(entity.getClass().equals(MobsReference.VANILLA_ZOMBIE)){

        EntityItem itemDropX = new EntityItem(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, ItemsReference.IRON_ORE.copy());

// world.spawnEntityInWorld(itemDropX);

        event.getDrops().add(itemDropX);

    }

}
Developer of CameraCraft.
You should get off the internet and grab a creeper plushie because you're 7 years old.
Lomeli12
Forge Modder Creeper Killer
I'm curious about how this works.

I am "monitoring" when mobs dies, and I want to add drops to their list. This is what I'm doing, the "problem" is that I'm not sure, will this guarantee the drop 100% the time? Is there a way to pass a % chance of dropping the added item.

PS: Would it be ok to spawn the item on the world, so I can add a chance % there?

Code: [Select]
@SubscribeEvent
public void onLivingDropsEvent(LivingDropsEvent event) {

    Entity entity = event.getEntity();
    World world = event.getEntity().getEntityWorld();
    BlockPos pos = event.getEntity().getPosition();

    if(entity.getClass().equals(MobsReference.VANILLA_ZOMBIE)){

        EntityItem itemDropX = new EntityItem(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, ItemsReference.IRON_ORE.copy());

// world.spawnEntityInWorld(itemDropX);

        event.getDrops().add(itemDropX);

    }

}
Developer of CameraCraft.
You should get off the internet and grab a creeper plushie because you're 7 years old.