Java Code Examples for net.minecraftforge.event.entity.living.LivingDropsEvent#getDrops()

The following examples show how to use net.minecraftforge.event.entity.living.LivingDropsEvent#getDrops() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StringEventHandling.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@SubscribeEvent
public void entityDrops(LivingDropsEvent ev)
{
    if (!ConfigManager.SERVER.dropStringFromSheep.get())
        return;

    Entity entity = ev.getEntity();
    if (!(entity instanceof SheepEntity))
        return;

    Collection<ItemEntity> drops = ev.getDrops();
    if (drops instanceof ImmutableList)
    {
        SurvivalistMod.LOGGER.warn("WARNING: Some mod is returning an ImmutableList, replacing drops will NOT be possible.");
        return;
    }

    if (rnd.nextFloat() < 0.25f)
        drops.add(new ItemEntity(entity.getEntityWorld(), entity.getPosX(), entity.getPosY(), entity.getPosZ(), new ItemStack(Items.STRING)));
}