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

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

Introduction

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

Prototype

public int getLootingLevel() 

Source Link

Usage

From source file:de.ellpeck.actuallyadditions.mod.event.CommonEvents.java

@SubscribeEvent
public void onEntityDropEvent(LivingDropsEvent event) {
    if (event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote
            && event.getSource().getEntity() instanceof EntityPlayer) {
        //Drop Cobwebs from Spiders
        if (ConfigBoolValues.DO_SPIDER_DROPS.isEnabled() && event.getEntityLiving() instanceof EntitySpider) {
            if (event.getEntityLiving().world.rand.nextInt(20) <= event.getLootingLevel() * 2) {
                event.getEntityLiving()/*from   ww w . jav  a  2s  .co m*/
                        .entityDropItem(new ItemStack(Blocks.WEB,
                                event.getEntityLiving().world.rand.nextInt(2 + event.getLootingLevel()) + 1),
                                0);
            }
        }
    }
}

From source file:de.ellpeck.actuallyadditions.mod.event.EntityLivingEvents.java

@SubscribeEvent
public void onEntityDropEvent(LivingDropsEvent event) {
    if (event.getEntityLiving().worldObj != null && !event.getEntityLiving().worldObj.isRemote
            && event.getSource().getEntity() instanceof EntityPlayer) {
        //Drop Solidified XP
        if (event.getEntityLiving() instanceof EntityCreature) {
            if (Util.RANDOM.nextInt(10) <= event.getLootingLevel() * 2) {
                event.getEntityLiving().entityDropItem(new ItemStack(InitItems.itemSolidifiedExperience,
                        Util.RANDOM.nextInt(2 + event.getLootingLevel()) + 1), 0);
            }/*from   w w w  .j  av a  2 s.c o m*/
        }

        //Drop Cobwebs from Spiders
        if (ConfigBoolValues.DO_SPIDER_DROPS.isEnabled() && event.getEntityLiving() instanceof EntitySpider) {
            if (Util.RANDOM.nextInt(20) <= event.getLootingLevel() * 2) {
                event.getEntityLiving().entityDropItem(
                        new ItemStack(Blocks.WEB, Util.RANDOM.nextInt(2 + event.getLootingLevel()) + 1), 0);
            }
        }

        //Drop Wings from Bats
        if (ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.getEntityLiving() instanceof EntityBat) {
            if (Util.RANDOM.nextInt(15) <= event.getLootingLevel() * 2) {
                event.getEntityLiving().entityDropItem(new ItemStack(InitItems.itemMisc,
                        Util.RANDOM.nextInt(2 + event.getLootingLevel()) + 1, TheMiscItems.BAT_WING.ordinal()),
                        0);
            }
        }
    }
}

From source file:de.ellpeck.actuallyadditions.mod.items.ItemSolidifiedExperience.java

@SubscribeEvent
public void onEntityDropEvent(LivingDropsEvent event) {
    if (ConfigBoolValues.DO_XP_DROPS.isEnabled()) {
        if (event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote
                && event.getSource().getEntity() instanceof EntityPlayer) {
            //Drop Solidified XP
            if (event.getEntityLiving() instanceof EntityCreature) {
                if (event.getEntityLiving().world.rand.nextInt(10) <= event.getLootingLevel() * 2) {
                    event.getEntityLiving().entityDropItem(new ItemStack(InitItems.itemSolidifiedExperience,
                            event.getEntityLiving().world.rand.nextInt(2 + event.getLootingLevel()) + 1), 0);
                }/*  w  w w  .  j a v a 2 s  . c  o m*/
            }
        }
    }
}

From source file:de.ellpeck.actuallyadditions.mod.items.ItemWingsOfTheBats.java

@SubscribeEvent
public void onEntityDropEvent(LivingDropsEvent event) {
    if (event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote
            && event.getSource().getEntity() instanceof EntityPlayer) {
        //Drop Wings from Bats
        if (ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.getEntityLiving() instanceof EntityBat) {
            if (event.getEntityLiving().world.rand.nextInt(15) <= event.getLootingLevel() * 2) {
                event.getEntityLiving()/*from   w w w. ja v a  2  s  .  c o  m*/
                        .entityDropItem(new ItemStack(InitItems.itemMisc,
                                event.getEntityLiving().world.rand.nextInt(2 + event.getLootingLevel()) + 1,
                                TheMiscItems.BAT_WING.ordinal()), 0);
            }
        }
    }
}

From source file:mod.rankshank.arbitraria.common.loot.HandlerGrabBagDrops.java

@SubscribeEvent
public void onDeath(LivingDropsEvent event) {
    EntityLivingBase src = (EntityLivingBase) event.getEntity();
    if (!event.getSource().isCreativePlayer() && event.isRecentlyHit()
            && rand.nextInt(12 - event.getLootingLevel()) == 0) {
        double pow = src.getMaxHealth() * (src instanceof IMob ? .2 : .05);
        pow += event.getLootingLevel();//from   w  w w.ja v a 2  s  .com
        EnumBagSize size = EnumBagSize.values()[0];
    }
}

From source file:vazkii.quark.vanity.feature.WitchHat.java

License:Creative Commons License

@SubscribeEvent
public void onDrops(LivingDropsEvent event) {
    if (event.getEntityLiving() instanceof EntityWitch
            && (!verifyTruePlayer || event.getSource().getTrueSource() instanceof EntityPlayer)
            && Math.random() < dropRate + lootingBoost * event.getLootingLevel())
        event.getDrops().add(new EntityItem(event.getEntity().getEntityWorld(), event.getEntity().posX,
                event.getEntity().posY, event.getEntity().posZ, new ItemStack(witch_hat)));
}