Java 类net.minecraftforge.event.entity.living.LootingLevelEvent 实例源码

项目:Melodium    文件:SongHunt.java   
@SubscribeEvent
public void handleBounty(LootingLevelEvent event) {
    EntityLivingBase target = event.getEntityLiving();
    EntityLivingBase attacker = target.getAttackingEntity();
    if (attacker instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) attacker;
        Collection<PotionEffect> potions = player.getActivePotionEffects();
        for (PotionEffect potion : potions) {
            if (potion.getPotion() instanceof PotionHunt) {
                PotionHunt huntPotion = (PotionHunt) potion.getPotion();
                if (huntPotion.appliesTo(target)) {
                    event.setLootingLevel(event.getLootingLevel() + 2);

                    return;
                }
            }
        }
    }
}
项目:CrystalMod    文件:EventHandler.java   
@SubscribeEvent
public void addLooting(LootingLevelEvent event){
    DamageSource source = event.getDamageSource();
    Entity attacker = source.getSourceOfDamage();
    final int prevLooting = event.getLootingLevel();
    int looting = 0;
    if(attacker !=null){
        if(attacker instanceof EntityPlayer){
            EntityPlayer player = (EntityPlayer)attacker;
            ItemStack hand = player.getHeldItemMainhand();
            if(ItemStackTools.isValid(hand)){
                UpgradeData lapis = BatHelper.getBatUpgradeData(hand, ModBats.LAPIS);
                if(lapis !=null){
                    looting+=(int) ModBats.LAPIS.getValue(lapis);
                }
            }
        }
    }
    event.setLootingLevel(prevLooting+looting);
}
项目:Inhuman-Resources    文件:EventHandler.java   
@SubscribeEvent
public void onEntityLooted(LootingLevelEvent event)
{
    EntityLivingBase target = event.getEntityLiving();
    BlockPos pos = target.getPosition();
    int lootingBonus = 0;
    for (int x = -16; x <= 16; x++)
        for (int z = -16; z <= 16; z++)
            for (int y = -8; y <= 8; y++)
                if (target.world.getBlockState(pos.add(x, y, z)).getBlock() == Blocks.BEACON)
                {
                    Block block = target.world.getBlockState(pos.add(x, y, z).down()).getBlock();
                    if (block == Blocks.IRON_BLOCK)
                        lootingBonus = Math.max(lootingBonus, 1);
                    else if (block == Blocks.GOLD_BLOCK)
                        lootingBonus = Math.max(lootingBonus, 2);
                    else if (block == Blocks.DIAMOND_BLOCK)
                        lootingBonus = Math.max(lootingBonus, 3);
                    else if (block == Blocks.EMERALD_BLOCK)
                        lootingBonus = Math.max(lootingBonus, 4);
                }
    event.setLootingLevel(event.getLootingLevel() + lootingBonus);
}
项目:Mods    文件:TF2EventsCommon.java   
@SubscribeEvent
public void looting(LootingLevelEvent event) {
    if(event.getDamageSource() instanceof TF2DamageSource) {
        event.setLootingLevel(event.getLootingLevel() + 
                (int) TF2Attribute.getModifier("Looting",((TF2DamageSource) event.getDamageSource()).getWeapon(),0,(EntityLivingBase) event.getDamageSource().getTrueSource()));
    }
}
项目:InspiringWorld    文件:ItemSourceBomb.java   
@SubscribeEvent
public void onLootingLevel(LootingLevelEvent event) {
    if (!event.getEntity().worldObj.isRemote) {
        if (event.getDamageSource() instanceof EntityDamageSource) {
            EntityDamageSource source = (EntityDamageSource) event.getDamageSource();
            if (source.getEntity() instanceof EntitySourceBomb) {
                event.setLootingLevel(1);
            }
        }
    }
}
项目:CustomWorldGen    文件:ForgeHooks.java   
public static int getLootingLevel(EntityLivingBase target, DamageSource cause, int level)
{
    LootingLevelEvent event = new LootingLevelEvent(target, cause, level);
    MinecraftForge.EVENT_BUS.post(event);
    return event.getLootingLevel();
}