Example usage for net.minecraftforge.event.entity.living LivingDropsEvent getDrops

List of usage examples for net.minecraftforge.event.entity.living LivingDropsEvent getDrops

Introduction

In this page you can find the example usage for net.minecraftforge.event.entity.living LivingDropsEvent getDrops.

Prototype

public Collection<ItemEntity> getDrops() 

Source Link

Usage

From source file:blusunrize.immersiveengineering.common.util.compat.BotaniaHelper.java

@SubscribeEvent(priority = EventPriority.LOW)
public void onLivingDrops(LivingDropsEvent event) {
    if (!event.isCanceled() && event.getEntityLiving().getClass().getName().endsWith("EntityDoppleganger")) {
        NBTTagCompound tag = new NBTTagCompound();
        event.getEntityLiving().writeEntityToNBT(tag);
        if (tag.getBoolean("hardMode"))
            for (EntityItem item : event.getDrops())
                if (item != null && !item.getItem().isEmpty()
                        && IEContent.itemShaderBag.equals(item.getItem().getItem()))
                    ItemNBTHelper.setString(item.getItem(), "rarity", "RELIC");
    }/*from  w  ww .ja  v  a 2s .com*/
}

From source file:com.blogspot.jabelarminecraft.blocksmith.EventHandler.java

License:Open Source License

@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public void onEvent(LivingDropsEvent event) {
    for (EntityItem dropItem : event.getDrops()) {
        if (dropItem.getItem().getItem() == Items.LEATHER) {
            int stackSize = dropItem.getItem().getCount();

            if (event.getEntityLiving() instanceof EntityCow) {
                dropItem.setItem(new ItemStack(ItemRegistry.COW_HIDE, stackSize));
            }//from   w  w w. j a  va 2s  . c o  m
            if (event.getEntityLiving() instanceof EntityHorse) {
                dropItem.setItem(new ItemStack(ItemRegistry.HORSE_HIDE, stackSize));
            }
            if (event.getEntityLiving() instanceof EntityMooshroom) {
                dropItem.setItem(new ItemStack(ItemRegistry.COW_HIDE, stackSize));
            }
        }
    }

    if (event.getEntityLiving() instanceof EntityPig) {
        event.getDrops()
                .add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX,
                        event.getEntityLiving().posY, event.getEntityLiving().posZ,
                        new ItemStack(ItemRegistry.PIG_SKIN)));
    } else if (event.getEntityLiving() instanceof EntitySheep) {
        event.getDrops()
                .add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX,
                        event.getEntityLiving().posY, event.getEntityLiving().posZ,
                        new ItemStack(ItemRegistry.SHEEP_SKIN)));
    }
}

From source file:com.buuz135.industrial.proxy.event.MobDeathHandler.java

License:Open Source License

@SubscribeEvent(priority = EventPriority.LOWEST)
public void onDeath(LivingDropsEvent event) {
    if (event.getSource().equals(CommonProxy.custom)) {
        event.getDrops().clear();
    }/*www .  j  a  v a 2  s  .  com*/
}

From source file:com.dyonovan.needfulthings.enchantments.EnchantmentBeheading.java

License:Creative Commons License

@SubscribeEvent
public void onLivingDropsEvent(LivingDropsEvent event) {
    DamageSource source = event.getSource();
    if (source.getDamageType().equalsIgnoreCase("player") || source.getDamageType().equalsIgnoreCase("arrow")) {
        EntityPlayer player = null;// w  ww. ja  v  a 2  s.  c  o  m
        if (source.getDamageType().equalsIgnoreCase("arrow")) {
            if (((EntityArrow) event.getSource().getSourceOfDamage()).shootingEntity instanceof EntityPlayer)
                player = (EntityPlayer) ((EntityArrow) event.getSource().getSourceOfDamage()).shootingEntity;
        } else
            player = (EntityPlayer) event.getSource().getSourceOfDamage();
        if (player != null) {
            int level = EnchantmentHelper.getEnchantmentLevel(
                    Enchantment.getEnchantmentByLocation(Reference.MOD_ID + ":" + NAME),
                    player.getHeldItemMainhand());
            if (level > 0) {
                ItemStack skull = getSkullForEntity((EntityLivingBase) event.getEntity());
                if (skull != null) {
                    int random = (MathHelper.getRandomIntegerInRange(player.getRNG(), 0, 100) + (level * 10));
                    //System.out.println(random);
                    if (random >= 80 || skull.getItemDamage() == 3) {
                        if (!event.getDrops().contains(skull)) {
                            World world = player.getEntityWorld();
                            Entity entity = event.getEntity();
                            float rx = world.rand.nextFloat() * 0.8F;
                            float ry = world.rand.nextFloat() * 0.8F;
                            float rz = world.rand.nextFloat() * 0.8F;
                            event.getDrops().add(new EntityItem(world, entity.posX + rx, entity.posY + ry,
                                    entity.posZ + rz, skull));
                        }
                    }
                }
            }
        }
    }
}

From source file:com.github.liachmodded.uhcreloaded.forge.rule.EnforceNoGhastTear.java

License:Open Source License

@SubscribeEvent(priority = EventPriority.HIGH)
public void onGhastDropsTears(LivingDropsEvent event) {
    if (event.getEntityLiving() instanceof EntityGhast) {
        for (EntityItem item : event.getDrops()) {
            if (item.getEntityItem().getItem() == Items.GHAST_TEAR) {
                event.getEntityLiving().dropItem(Items.GOLD_INGOT, item.getEntityItem().getCount());
                item.setDead();/*from w w w .ja  v  a  2s  .c  o  m*/
            }
        }
    }
}

From source file:jayavery.geomastery.main.EntityEvents.java

License:Open Source License

/** Alters drops for vanilla entities. */
@SubscribeEvent/*from w  ww . j  a  v  a  2  s .c  o m*/
public void livingDrops(LivingDropsEvent event) {

    Entity entity = event.getEntity();
    World world = entity.world;

    if (entity.world.isRemote) {

        return;
    }

    if (entity instanceof EntityPig) {

        event.getDrops().clear();
        entity.entityDropItem(ItemSimple.newStack(GeoBlocks.CARCASS_PIG.getItem(), 1, world), 0);

    } else if (entity instanceof EntityCow) {

        event.getDrops().clear();
        entity.entityDropItem(ItemSimple.newStack(GeoBlocks.CARCASS_COWPART.getItem(), 4, world), 0);

    } else if (entity instanceof EntitySheep) {

        event.getDrops().clear();
        entity.entityDropItem(ItemSimple.newStack(GeoBlocks.CARCASS_SHEEP.getItem(), 1, world), 0);

    } else if (entity instanceof EntityChicken) {

        event.getDrops().clear();
        entity.entityDropItem(ItemSimple.newStack(GeoBlocks.CARCASS_CHICKEN.getItem(), 1, world), 0);

    } else if (entity instanceof EntityRabbit) {

        event.getDrops().clear();
        entity.entityDropItem(ItemSimple.newStack(GeoBlocks.CARCASS_RABBIT.getItem(), 1, world), 0);

    } else if (entity instanceof EntityMob) {

        event.getDrops().clear();
    }
}

From source file:md.zazpro.mod.common.items.SpellBook.java

License:Open Source License

@SubscribeEvent
public void onKill(LivingDropsEvent event) {
    if (event.getEntity() instanceof EntityPigZombie) {
        if (randInt(1, 20) == 1)
            event.getDrops()
                    .add(new EntityItem(event.getEntity().worldObj, event.getEntity().posX,
                            event.getEntity().posY, event.getEntity().posZ,
                            new ItemStack(ItemsAndUpgrades.Spell_Book)));
    }//w  w  w.j  a v a2 s  .com
}

From source file:md.zazpro.mod.common.items.Translator.java

License:Open Source License

@SubscribeEvent
public void onKill(LivingDropsEvent event) {
    if (event.getEntity() instanceof EntityPigZombie) {
        if (randInt(1, ConfigurationHandler.TranslatorChance) == 1)
            event.getDrops()
                    .add(new EntityItem(event.getEntity().worldObj, event.getEntity().posX,
                            event.getEntity().posY, event.getEntity().posZ,
                            new ItemStack(ItemsAndUpgrades.Translator)));
    }// w w  w . j  a  v a 2s . c o  m
}

From source file:necauqua.mods.cm.Handlers.java

License:Apache License

@SubscribeEvent
public void onLivingDrops(LivingDropsEvent e) {
    float size = getSize(e.getEntity());
    if (size != 1.0F) {
        for (EntityItem item : e.getDrops()) {
            EntitySizeManager.setSize(item, size, false);
        }/*from  w w  w.  j a v  a 2 s  . c o m*/
    }
}

From source file:robmart.rpgmode.common.handlers.MobEventHandler.java

License:Open Source License

@SubscribeEvent
public static void onLivingDrop(LivingDropsEvent event) {
    if (event.getEntityLiving() instanceof EntityBat && random.nextInt(10) < 3)
        event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX,
                event.getEntityLiving().posY, event.getEntityLiving().posZ, new ItemStack(RPGItems.BAT_WING)));

    if (event.getEntityLiving() instanceof EntityParrot && random.nextInt(10) < 3) {
        event.getDrops()/*  w  w w .  jav a2  s  .co  m*/
                .add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX,
                        event.getEntityLiving().posY, event.getEntityLiving().posZ,
                        new ItemStack(RPGItems.PARROT_FEATHER)));

        event.getDrops().removeIf(entityItem -> entityItem.getItem().getItem() == Items.FEATHER);
    }
}