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

项目:MakeClayValuableAgain    文件:ClayProgressionImprovements.java   
@SubscribeEvent
public void dropClay(LivingDropsEvent event) {
    EntityLivingBase deadEntity = event.getEntityLiving();
    World world = deadEntity.getEntityWorld();
    BlockPos position = deadEntity.getPosition();
    double x = position.getX();
    double y = position.getY();
    double z = position.getZ();
    if (deadEntity instanceof EntityWitherSkeleton) {
        if (world.rand.nextInt(10) == 5) {
            event.getDrops().add(new EntityItem(world, x, y, z, new ItemStack(Items.CLAY_BALL)));
        }
    } else if (deadEntity instanceof EntityDragon || deadEntity instanceof EntityWither) {
        event.getDrops().add(new EntityItem(world, x, y, z, new ItemStack(Items.CLAY_BALL)));
    }
}
项目:harshencastle    文件:HarshenUtils.java   
public static EntityPlayer getPlayer(Event event)
{
    if(event instanceof LivingEvent && ((LivingEvent)event).getEntity() instanceof EntityPlayer)
        return (EntityPlayer)((LivingEvent)event).getEntity();
    if(event instanceof RenderGameOverlayEvent || event instanceof RenderWorldLastEvent || event instanceof ClientTickEvent)
        return HarshenCastle.proxy.getPlayer();
    if(event instanceof PlayerTickEvent)
        return ((PlayerTickEvent)event).player;
    if(event instanceof PlayerEvent)
        return ((PlayerEvent)event).player;
    if(event instanceof net.minecraftforge.event.entity.player.PlayerEvent)
        return ((net.minecraftforge.event.entity.player.PlayerEvent)event).getEntityPlayer();
    if(event instanceof PlayerPunchedEvent)
        return ((PlayerPunchedEvent)event).attacker;
    if(event instanceof LivingDropsEvent && isSourceFromPlayer(((LivingDropsEvent)event).getSource()))
        return getPlayerFromSource(((LivingDropsEvent)event).getSource());
    return null;
}
项目:Never-Enough-Currency    文件:ModEventHandler.java   
@SubscribeEvent
public static void onLivingDropsEvent(LivingDropsEvent event) {
    if (ConfigHandler.dropMoney && !(event.getEntityLiving() instanceof EntityPlayer) && event.getEntityLiving() instanceof IMob && event.getEntityLiving().getEntityWorld().isRemote == false) {
        if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityPlayer && !(event.getSource().getTrueSource() instanceof FakePlayer)) {
            CurrencyUtils.dropMoneyAmount(event.getEntityLiving().getMaxHealth() / ConfigHandler.mobDivisionValue, event.getEntityLiving().getEntityWorld(), event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ);
            return;
        }

        if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityArrow) {
            EntityArrow arrow = (EntityArrow) event.getSource().getTrueSource();
            if (arrow.shootingEntity instanceof EntityPlayer && !(arrow.shootingEntity instanceof FakePlayer)) {
                CurrencyUtils.dropMoneyAmount(event.getEntityLiving().getMaxHealth() / ConfigHandler.mobDivisionValue, event.getEntityLiving().getEntityWorld(), event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ);
                return;
            }
        }
    }
}
项目:connor41-etfuturum2    文件:ServerEventHandler.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void dropEvent(LivingDropsEvent event) {
    if (event.entityLiving.worldObj.isRemote)
        return;

    if (EtFuturum.enableSkullDrop)
        dropHead(event.entityLiving, event.source, event.lootingLevel, event.drops);

    Random rand = event.entityLiving.worldObj.rand;
    if (EtFuturum.enableMutton && event.entityLiving instanceof EntitySheep) {
        int amount = rand.nextInt(3) + 1 + rand.nextInt(1 + event.lootingLevel);
        for (int i = 0; i < amount; i++)
            if (event.entityLiving.isBurning())
                addDrop(new ItemStack(ModItems.cooked_mutton), event.entityLiving, event.drops);
            else
                addDrop(new ItemStack(ModItems.raw_mutton), event.entityLiving, event.drops);
    }
}
项目:NemesisSystem    文件:DeathHandler.java   
@SubscribeEvent
public void onDrops(LivingDropsEvent event) {
    World world = event.getEntity().getEntityWorld();

    if (world.isRemote || !(event.getEntity() instanceof EntityCreature)) {
        return;
    }

    if (event.getSource() == null || event.getSource().getTrueSource() == null){
        return;
    }

    if (!(event.getSource().getTrueSource() instanceof EntityPlayer)) {
        return;
    }

    if (event.getEntity().getTags().contains(NemesisSystem.TAG_NEMESIS)) {
        handleNemesisDrops(event.getDrops(), (EntityCreature) event.getEntity());
    }
}
项目:ExtraUtilities    文件:EventHandlerServer.java   
@SubscribeEvent
public void netherDrop(final LivingDropsEvent event) {
    if (ExtraUtils.divisionSigil != null && event.entityLiving instanceof EntityWither && event.source.getSourceOfDamage() instanceof EntityPlayer && event.entity.worldObj != null && event.entity.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot")) {
        final EntityPlayer player = (EntityPlayer)event.source.getSourceOfDamage();
        NBTTagCompound t = new NBTTagCompound();
        if (player.getEntityData().hasKey("PlayerPersisted")) {
            t = player.getEntityData().getCompoundTag("PlayerPersisted");
        }
        else {
            player.getEntityData().setTag("PlayerPersisted", (NBTBase)t);
        }
        int kills = 0;
        if (t.hasKey("witherKills")) {
            kills = t.getInteger("witherKills");
        }
        ++kills;
        t.setInteger("witherKills", kills);
        if (kills == 1 || !t.hasKey("hasSigil") || event.entity.worldObj.rand.nextInt(10) == 0) {
            final ItemStack item = new ItemStack(ExtraUtils.divisionSigil);
            final EntityItem entityitem = new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, item);
            entityitem.delayBeforeCanPickup = 10;
            event.drops.add(entityitem);
        }
    }
}
项目:LittleThings-old    文件:DustMobDrop.java   
@SubscribeEvent
public void onMobDrops(LivingDropsEvent e)
{
    World world = e.getEntity().getEntityWorld();
    Random rng = world.rand;
    if (e.getEntity() instanceof EntitySkeleton) {
        EntitySkeleton skele = (EntitySkeleton) e.getEntity();
        if (skele.getSkeletonType() == 1) {
            if (rng.nextFloat() < 0.20 + (e.getLootingLevel() + 1 * 0.05))
                e.getDrops().add(new EntityItem(world, skele.posX, skele.posY, skele.posZ, new ItemStack(ModItems.MobDust, 1, 0)));
        }
    }

    if (e.getEntity() instanceof EntityCaveSpider) {
        if (rng.nextFloat() < 0.20 + (e.getLootingLevel() + 1 * 0.05))
            e.getDrops().add(new EntityItem(world, e.getEntity().posX, e.getEntity().posY, e.getEntity().posZ, new ItemStack(ModItems.MobDust, 1, 1)));
    }
}
项目:MidgarCrusade    文件:LivingEntityEvent.java   
@SubscribeEvent
   public void onEntityDrops(LivingDropsEvent event)
{
    int alea;

    if (event.entityLiving instanceof EntityMob)
        alea = 20;
    else
        alea = 50;

    if (event.entityLiving.worldObj.rand.nextInt(alea) < 1 + event.lootingLevel * 2)
    {
        EntityItem e;

        e = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, new ItemStack(ItemRegister.getRandomArmor(), 1));
        e = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, new ItemStack(ItemRegistry1.bagdrop, 1));


        event.drops.add(e);
    }
}
项目:ShearMadness    文件:CommonForgeEventProxy.java   
@SubscribeEvent
public void onLivingDrop(LivingDropsEvent event) {

    final Entity entity = event.getEntity();
    if (entity.hasCapability(Capability.CHISELED_SHEEP, null)) {
        final IChiseledSheepCapability capability = entity.getCapability(Capability.CHISELED_SHEEP, null);
        if (capability.isChiseled())
        {
            final List<EntityItem> drops = event.getDrops();
            final ItemStack chiselItemStack = capability.getChiselItemStack();
            final Item chiselItem = chiselItemStack.getItem();

            drops.removeIf(entityItem -> ItemStackHelper.isStackForBlock(entityItem.getEntityItem(), Blocks.WOOL));

            drops.add(new EntityItem(entity.worldObj, entity.posX, entity.posY, entity.posZ, chiselItemStack.copy()));

            MinecraftForge.EVENT_BUS.post(new ShearMadnessSheepKilledEvent(
                    drops,
                    event.getSource(),
                    event.getLootingLevel(),
                    chiselItemStack,
                    entity
            ));
        }
    }
}
项目:Aether-Legacy    文件:AetherEventHandler.java   
@SubscribeEvent
public void onEntityDropLoot(LivingDropsEvent event)
{
    if (event.getSource() instanceof EntityDamageSource)
    {
        EntityLivingBase entity = event.getEntityLiving();
        EntityDamageSource source = (EntityDamageSource) event.getSource();

        if (source.getEntity() instanceof EntityPlayer)
        {
            EntityPlayer player = (EntityPlayer) source.getEntity();
            ItemStack currentItem = player.inventory.getCurrentItem();

            if (currentItem != null && currentItem.getItem() instanceof ItemSkyrootSword && !(entity instanceof EntityPlayer) && !(entity instanceof EntityWither))
            {
                for (EntityItem items : event.getDrops())
                {
                    EntityItem item = new EntityItem(entity.worldObj, entity.posX, entity.posY, entity.posZ, items.getEntityItem());
                    entity.worldObj.spawnEntityInWorld(item);
                }
            }
        }
    }
}
项目:TAIGA    文件:TraitGarishly.java   
@SubscribeEvent
public void onMobDrops(LivingDropsEvent event) {
    World w = event.getEntity().getEntityWorld();
    if (!w.isRemote && event.getSource().getTrueSource() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
        if (event.getEntity() instanceof EntityMob && TinkerUtil.hasTrait(TagUtil.getTagSafe(player.getHeldItemMainhand()), identifier)) {

            int r = random.nextInt(2);
            ItemStack i = null;
            switch (r) {
                case 0:
                    i = new ItemStack(Items.BLAZE_POWDER, random.nextInt(3));
                    break;
                case 1:
                    i = new ItemStack(Items.BLAZE_ROD, random.nextInt(3));
                    break;
                case 2:
                    i = new ItemStack(Items.COAL, random.nextInt(3));
                    break;
            }
            assert i != null;
            event.getDrops().add(0, new EntityItem(w, event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, i));
        }
    }
}
项目:3DManeuverGear    文件:EntityLivingHandler.java   
@SubscribeEvent
@SuppressWarnings("unused")
public void onWitherDeath(LivingDropsEvent event) {
    if(ItemRegistry.getInstance().itemRecord == null) {
        return;
    }
    if(!(event.getEntity() instanceof EntityWither)) {
        return;
    }
    Entity killer = event.getSource().getSourceOfDamage();
    if(event.isRecentlyHit() && killer != null && killer instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) killer;
        ItemStack left = player.getHeldItem(EnumHand.MAIN_HAND);
        ItemStack right = player.getHeldItem(EnumHand.OFF_HAND);
        if(isValidStack(left) && isValidStack(right)) {
            EntityItem drop = new EntityItem(event.getEntity().getEntityWorld(), event.getEntity().posX, event.getEntity().posY+0.5D, event.getEntity().posZ,
                    new ItemStack(ItemRegistry.getInstance().itemRecord));
            event.getDrops().add(drop);
        }
    }
}
项目:Tannery    文件:EntityDropsHandler.java   
@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event)
{
    Entity e = event.entity;
    List<EntityItem> drops = event.drops;
    // Remove all drops from cows, sheep and pigs, add carcass drop
    if (e instanceof EntityCow || e instanceof EntityPig || e instanceof EntitySheep)
    {
        EntityAnimal a = (EntityAnimal) e;
        Iterator<EntityItem> it = drops.iterator();
        while (it.hasNext())
        {
            EntityItem i = it.next();
            it.remove();
        }

        if (a.getGrowingAge() == 0)
        {
            if (a instanceof EntityCow) a.dropItem(TanneryItems.bloodyCowCarcass, 1);
            else if (a instanceof EntityPig) a.dropItem(TanneryItems.bloodyPigCarcass, 1);
            else if (a instanceof EntitySheep) a.dropItem(TanneryItems.bloodySheepCarcass, 1);
        }
    }
}
项目:ARKCraft    文件:CommonEventHandler.java   
@SubscribeEvent
public void onEntityKilled(LivingDropsEvent event)
{
    // TODO remove when actual ark creatures are in place and dropping items
    if (event.getEntityLiving().world.isRemote) return;
    Random r = new Random();
    int x = r.nextInt(3) + 1;
    ItemStack meat = new ItemStack(ARKCraftItems.meat_raw, x);
    event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY,
            event.getEntityLiving().posZ, IDecayable.setDecayStart(meat, ARKCraft.proxy.getWorldTime())));
    if (r.nextDouble() < 0.05) event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX,
            event.getEntityLiving().posY, event.getEntityLiving().posZ, IDecayable.setDecayStart(new ItemStack(
                    ARKCraftItems.primemeat_raw), ARKCraft.proxy.getWorldTime())));
    if (event.getEntityLiving() instanceof EntitySpider || event.getEntityLiving() instanceof EntitySilverfish
            || event.getEntityLiving() instanceof EntityEndermite) event.getDrops().add(new EntityItem(
                    event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY,
                    event.getEntityLiving().posZ, new ItemStack(ARKCraftItems.chitin, r.nextInt(3) + 1)));
    else event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX,
            event.getEntityLiving().posY, event.getEntityLiving().posZ, new ItemStack(ARKCraftItems.hide, r.nextInt(3) + 1)));
}
项目:Mob-Rebirth    文件:CommonEvents.java   
@SubscribeEvent
public void onEntityLivingDeath(LivingDropsEvent event) {
    if (MobRebirth.instance.getHasCustomMobSettings()) {
        if (EntityList.getKey(event.getEntityLiving()) != null)
            if (ArrayUtils.contains(ConfigValues.CUSTOMENTITIES, EntityList.getKey(event.getEntityLiving()).getResourcePath())) {
                if (ConfigValues.REBIRTHFROMNONPLAYERMAP.get(EntityList.getKey(event.getEntityLiving())))
                    transition(event);
                else if (event.getSource().getTrueSource() instanceof EntityPlayer)
                    transition(event);
                return;
            }
    }
    if (ConfigValues.REBIRTHFROMNONPLAYER)
        transition(event);
    else if (event.getSource().getTrueSource() instanceof EntityPlayer)
        transition(event);
}
项目:Mob-Rebirth    文件:CommonEvents.java   
private void makeMobRebornTransition(LivingDropsEvent event) {
    if (ConfigValues.ALLOWBOSSES) {
        if (event.getEntityLiving() instanceof EntityWither || event.getEntityLiving() instanceof EntityDragon) {
            makeMobReborn(event);
            return;
        }
    } else if (event.getEntityLiving() instanceof EntityWither || event.getEntityLiving() instanceof EntityDragon)
        return;
    if (ConfigValues.ALLOWSLIMES) {
        if (event.getEntityLiving() instanceof EntitySlime) {
            makeMobReborn(event);
            return;
        }
    } else if (event.getEntityLiving() instanceof EntitySlime)
        return;
    if (ConfigValues.VANILLAONLY) {
        if (isVanilla(event.getEntityLiving())) {
            makeMobReborn(event);
        }
    } else {
        makeMobReborn(event);
    }
}
项目:Mob-Rebirth    文件:CommonEvents.java   
private void createEntity(LivingDropsEvent event) {
    //Store
    EntityLivingBase entity;
    World worldIn = event.getEntityLiving().world;
    ResourceLocation sid = EntityList.getKey(event.getEntityLiving());
    NBTTagCompound storedData = event.getEntityLiving().getEntityData();
    event.getEntityLiving().writeEntityToNBT(storedData);
    ItemStack weapon = event.getEntityLiving().getHeldItem(EnumHand.MAIN_HAND);
    ItemStack offhand = event.getEntityLiving().getHeldItem(EnumHand.OFF_HAND);
    float health = event.getEntityLiving().getMaxHealth();
    //Read
    entity = (EntityLivingBase) EntityList.createEntityByIDFromName(sid, worldIn);
    if (entity == null)
        return;
    entity.rotationYawHead = entity.rotationYaw;
    entity.renderYawOffset = entity.rotationYaw;
    storedData.setInteger("Health", (int) health);
    entity.readFromNBT(storedData);
    entity.setHealth(health);
    if (!weapon.isEmpty())
        entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, weapon);
    if (!offhand.isEmpty())
        entity.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, offhand);
    entity.setPosition(event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ);
    worldIn.spawnEntity(entity);
}
项目:OpenLootBags    文件:MobDropHandler.java   
@SubscribeEvent
public void onEntityDrop(LivingDropsEvent event)
{
    if(event.getSource().getEntity() == null ||  event.getSource().getEntity() instanceof FakePlayer || !(event.getSource().getEntity() instanceof EntityPlayer))
        return;

    //This is bad remove at some point
    //set NBT to stack
    if(random.nextInt(10) == 1)
    {
        int type = random.nextInt(OpenLootBagsApi.INSTANCE.getBagManager().getBagTypes().size());
        ItemStack stack = new ItemStack(OpenLootBags.lootbag, 1, type);
        ResourceLocation name = OpenLootBagsApi.INSTANCE.getBagManager().getBagTypes().get(type);
        ItemNBTHelper.setString(stack, "typeName", name.getResourcePath());
        ItemNBTHelper.setString(stack, "typeDomain", name.getResourceDomain());
        ItemNBTHelper.setInt(stack, "colour", OpenLootBagsApi.INSTANCE.getBagManager().getBagColorMap().get(name));

        event.getEntityLiving().entityDropItem(stack, random.nextInt(2) + 1);
    }
}
项目:Survivalist    文件:StringEventHandling.java   
@SubscribeEvent
public void entityDrops(LivingDropsEvent ev)
{
    Entity entity = ev.getEntity();
    if (!(entity instanceof EntitySheep))
        return;

    List<EntityItem> drops = ev.getDrops();
    if (drops instanceof ImmutableList)
    {
        Survivalist.logger.warn("WARNING: Some mod is returning an ImmutableList, replacing drops will NOT be possible.");
        return;
    }

    if (rnd.nextFloat() < 0.25f)
        drops.add(new EntityItem(entity.getEntityWorld(), entity.posX, entity.posY, entity.posZ, new ItemStack(Items.STRING)));
}
项目:TFC-Tweaks    文件:EventHandlers.java   
/**
 * Handles:
 * - zombies dropping zombie flesh
 */
@SubscribeEvent
public void livingDropsEvent(LivingDropsEvent event)
{
    World world = event.entity.worldObj;
    if (!world.isRemote)
    {
        if (disableZombieFlesh || disableSpiderEye)
        {
            Iterator<EntityItem> i = event.drops.iterator();
            while (i.hasNext())
            {
                EntityItem entityItem = i.next();
                if (entityItem == null) continue;
                ItemStack stack = entityItem.getEntityItem();
                if (stack == null) continue;
                Item item = stack.getItem();
                if (item == null) continue;
                if (disableZombieFlesh && item == Items.rotten_flesh) i.remove();
                else if (disableSpiderEye && item == Items.spider_eye) i.remove();
            }
        }
    }
}
项目:Culinary-Cultivation    文件:MobDropEvent.java   
@SubscribeEvent
public void livingDropsEvent(LivingDropsEvent event) {
    Random random = new Random();
    if (event.getSource().getImmediateSource() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getSource().getImmediateSource();
        if (player.inventory.getCurrentItem().getItem() == this.killTool) {
            if (event.getEntityLiving().getClass().isAssignableFrom(this.livingClass) && this.isChild == event.getEntityLiving().isChild()) {
                if (this.vanillaDropChance == -1 ? random.nextInt(100) >= 35 : random.nextInt(100) <= this.vanillaDropChance) {
                    event.getDrops().clear();
                }
                int dropChance = MathHelper.getInt(random, this.dropMin, this.dropMax);
                for (int k = 0; k < dropChance + event.getLootingLevel(); ++k) {
                    if (event.getEntityLiving().isBurning() && this.canDropBurned) {
                        event.getEntityLiving().entityDropItem(this.dropBurning.copy(), 1F);
                    } else {
                        event.getEntityLiving().entityDropItem(this.drop.copy(), 1F);
                    }
                }
            }
        }
    }
}
项目:ThermalRecycling    文件:Recycle.java   
private boolean isProperDeath(final LivingDropsEvent event) {
    final DamageSource source = event.source;

    // If the source is not known...
    if (source == null)
        return false;

    // If the source isn't a player it's not proper. Note that this
    // could include a fake player.
    if (!(source.getEntity() instanceof EntityPlayerMP))
        return false;

    final EntityPlayerMP player = (EntityPlayerMP) source.getEntity();
    final ItemStack heldItem = player.getHeldItem();
    return heldItem != null && EnchantmentHelper.getEnchantmentLevel(this.effectId, heldItem) > 0;
}
项目:Cyclic    文件:MobDropChangesModule.java   
@SubscribeEvent
public void onLivingDropsEvent(LivingDropsEvent event) {
  Entity entity = event.getEntity();
  World world = entity.getEntityWorld();
  if (nameTagDeath) {
    if (entity.getCustomNameTag() != null && entity.getCustomNameTag() != "") {
      // item stack NBT needs the name enchanted onto it
      if (world.isRemote == false) {
        ItemStack nameTag = UtilNBT.buildEnchantedNametag(entity.getCustomNameTag());
        UtilItemStack.dropItemStackInWorld(world, entity.getPosition(), nameTag);
      }
    }
  }
  if (endermanDrop && entity instanceof EntityEnderman) {
    EntityEnderman mob = (EntityEnderman) entity;
    IBlockState bs = mob.getHeldBlockState();// mob.func_175489_ck();
    if (bs != null && bs.getBlock() != null && world.isRemote == false) {
      UtilItemStack.dropItemStackInWorld(world, mob.getPosition(), bs.getBlock());
    }
  }
}
项目:Et-Futurum    文件:ServerEventHandler.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void dropEvent(LivingDropsEvent event) {
    if (event.entityLiving.worldObj.isRemote)
        return;

    if (EtFuturum.enableSkullDrop)
        dropHead(event.entityLiving, event.source, event.lootingLevel, event.drops);

    Random rand = event.entityLiving.worldObj.rand;
    if (EtFuturum.enableMutton && event.entityLiving instanceof EntitySheep) {
        int amount = rand.nextInt(3) + 1 + rand.nextInt(1 + event.lootingLevel);
        for (int i = 0; i < amount; i++)
            if (event.entityLiving.isBurning())
                addDrop(new ItemStack(ModItems.cooked_mutton), event.entityLiving, event.drops);
            else
                addDrop(new ItemStack(ModItems.raw_mutton), event.entityLiving, event.drops);
    }
}
项目:Better-Mushroom-Islands    文件:EventHooks.java   
@SubscribeEvent
public void LivingDropEvent(LivingDropsEvent event){
    if(event.entity instanceof EntityMooshroom){
        if(event.entityLiving.isChild()){
        }
        else{
        event.drops.clear();
        event.drops.add(new EntityItem(event.entityLiving.worldObj,event.entityLiving.posX,event.entityLiving.posY,event.entityLiving.posZ,new ItemStack(BetterMushroomItems.mushroom_leather, 1)));
        if (event.entityLiving.isBurning()){
            event.drops.add(new EntityItem(event.entityLiving.worldObj,event.entityLiving.posX,event.entityLiving.posY,event.entityLiving.posZ,new ItemStack(BetterMushroomItems.cooked_shroomeat, 1)));
        }else{
            event.drops.add(new EntityItem(event.entityLiving.worldObj,event.entityLiving.posX,event.entityLiving.posY,event.entityLiving.posZ,new ItemStack(BetterMushroomItems.raw_shroomeat, 1)));
            }
        }
    }
}
项目:AdvancedPotions    文件:AdvancedPotions.java   
@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event) {
    debug("drop");
    float dropChance = 0.0f;
    if (event.entityLiving instanceof EntityMob) {
        debug("drop1");
        dropChance = 0.2f;
        if (event.entityLiving instanceof EntityWitch) {
            debug("drop2");
            dropChance = 1.0f;
        }
    }
    dropChance *= (event.lootingLevel + 1);
    if (rng.nextFloat() < dropChance) {
        debug("dropping");
        event.entityLiving.worldObj.spawnEntityInWorld(new EntityItem(
                event.entityLiving.worldObj, event.entityLiving.posX,
                event.entityLiving.posY, event.entityLiving.posZ, new ItemStack(ingredient, 1, 9)));
    }
}
项目:Aura-Cascade    文件:EnchantEventHandler.java   
@SubscribeEvent
public void onDrops(LivingDropsEvent event) {
    Entity entity = event.getSource().getSourceOfDamage();
    if (entity instanceof EntityPlayer && !entity.worldObj.isRemote) {
        ItemStack stack = ((EntityPlayer) entity).inventory.getCurrentItem();
        int looting = getEffectStrength(stack, EnumRainbowColor.VIOLET, EnumRainbowColor.YELLOW);
        if (looting > 0) {
            try {
                dropCommon.invoke(event.getEntity(), true, looting);
                int j = new Random().nextInt(200) - looting;

                if (j < 5) {
                    dropRare.invoke(event.getEntity(), j <= 0 ? 1 : 0);
                }
            } catch (IllegalAccessException | InvocationTargetException e) {
                e.printStackTrace();
            }
        }
    }
}
项目:CreepTech    文件:EntityDeathEventHooks.java   
@SubscribeEvent
public void onDeathDrops(LivingDropsEvent event){
    if(event.entityLiving instanceof EntityCreeper){
        EntityItem item = new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, new ItemStack(modItems.itemCreepLeaf, 1));
        if(((EntityCreeper)event.entity).getPowered()){
            item = new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, new ItemStack(modItems.itemChargedCreepLeaf, 1));
        }
        event.drops.add(item);
    }
    else if(event.entityLiving.getDisplayName().equals("Harry9137")){
        if(event.source.getEntity() instanceof EntityPlayer){
            EntityPlayer badperson = (EntityPlayer)event.source.getEntity();
            badperson.addChatMessage(new ChatComponentText("§4§lYou Don't Know What You've Done..."));
        }
    }
}
项目:Ex-Aliquo    文件:AliquoEvents.java   
@ForgeSubscribe
public void onLivingDrops(LivingDropsEvent event)
{
    if (event.entityLiving == null)
    {
        return;
    }

    if (event.entityLiving instanceof EntityDragon)
    {
        if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer)
        {
            EntityPlayer player = (EntityPlayer) event.source.getEntity();
            if (!player.worldObj.isRemote)
            {
                EntityItem item = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, new ItemStack(Registries.dragonEgg, 1, 0));
                player.worldObj.spawnEntityInWorld(item);
                if (!(player instanceof FakePlayer))
                {
                    item.onCollideWithPlayer(player);
                }
            }
        }
    }
}
项目:D3Core    文件:EventHandler.java   
@SubscribeEvent
public static void entityDeathEvent(LivingDropsEvent event)
{
    if (event.getEntityLiving() instanceof EntityPlayer && claysTortureMode)
    {
        event.setCanceled(true);
    }
    else if (event.getEntityLiving() instanceof EntityEnderman && EndermanGriefing.dropCarrying)
    {
        EntityEnderman entityEnderman = ((EntityEnderman) event.getEntityLiving());
        IBlockState state = entityEnderman.getHeldBlockState();
        if (state != null && state.getBlock() != Blocks.AIR)
        {
            ItemStack stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
            event.getDrops().add(new EntityItem(entityEnderman.world, entityEnderman.posX, entityEnderman.posY, entityEnderman.posZ, stack));
        }
    }
}
项目:enderutilities    文件:LivingDropsEventHandler.java   
@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event)
{
    DamageSource source = event.getSource();

    if (source != null && source.damageType != null &&
        source.damageType.equals("player") && source.getImmediateSource() instanceof EntityPlayer)
    {
        ItemStack stack = ((EntityPlayer) source.getImmediateSource()).getHeldItemMainhand();

        if (stack.isEmpty() == false && stack.getItem() == EnderUtilitiesItems.ENDER_SWORD)
        {
            ((ItemEnderSword) stack.getItem()).handleLivingDropsEvent(stack, event);
        }
    }
}
项目:Marble    文件:WitheringHandler.java   
@SubscribeEvent
public void onEntityKill(LivingDropsEvent event){
    if(event.entityLiving instanceof EntitySkeleton){
        if(((EntitySkeleton) event.entityLiving).getSkeletonType() == 1){
            if(Math.round(Marble.rand.nextFloat() * 100) < ConfigHandler.witherOneDropChance){
                MiscHelper.drop(event, Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(ConfigHandler.witheringID, 1)));
            }
        }
    }

    if(event.entityLiving instanceof EntityWither){
        if(Math.round(Marble.rand.nextInt()) < ConfigHandler.witherTwoDropChance){
            MiscHelper.drop(event, Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(ConfigHandler.witheringID, 2)));
        }
    }
}
项目:Rubedo    文件:MobEquipmentHandler.java   
@SubscribeEvent
public void onEntityDrop(LivingDropsEvent event) {
    ContentAI contentAI = Singleton.getInstance(ContentAI.class);
    if (contentAI.pigmenDropSilver
            && event.entity instanceof EntityPigZombie) {
        for (EntityItem drop : event.drops) {
            if (drop.getEntityItem().getItem() == Items.gold_ingot)
                drop.setEntityItemStack(new ItemStack(
                        ContentWorld.metalItems,
                        drop.getEntityItem().stackSize,
                        ContentWorld.metalItems
                                .getTextureIndex("silver_ingot")));
            if (drop.getEntityItem().getItem() == Items.gold_nugget)
                drop.setEntityItemStack(new ItemStack(
                        ContentWorld.metalItems,
                        drop.getEntityItem().stackSize,
                        ContentWorld.metalItems
                                .getTextureIndex("silver_nugget")));

            if (drop.getEntityItem().getItem() == Singleton.getInstance(
                    ContentTools.class).getItem(ToolSword.class)) {
                drop.getEntityItem().setItemDamage(0);
            }
        }
    }
}
项目:Electro-Magic-Tools    文件:EventHandlerEMT.java   
@SubscribeEvent
public void onEntityLivingDrops(LivingDropsEvent event) {
    if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) {
        if (event.entityLiving instanceof EntityCreeper) {
            EntityCreeper creeper = (EntityCreeper) event.entityLiving;
            if (creeper.getPowered()) {
                event.drops.add(new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, new ItemStack(IC2ItemRegistry.itemEMTItems, 1, 6)));
            }
        }
        if (event.entityLiving instanceof EntityTaintChicken) {
            event.drops.add(new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, new ItemStack(IC2ItemRegistry.itemEMTItems, 1, 14)));
        }
    }

    if (event.entityLiving instanceof EntityCreeper) {
        event.entityLiving.entityDropItem(new ItemStack(IC2ItemRegistry.itemEMTItems, 6), 1);
    }
    if (event.entityLiving instanceof EntityTaintChicken) {
        event.entityLiving.entityDropItem(new ItemStack(IC2ItemRegistry.itemEMTItems, 14), 1);
    }
}
项目:CustomThings    文件:LivingDropsHandler.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onLivingDrop(LivingDropsEvent event)
{
    if (event.entityLiving instanceof EntityCreeper)
    {
        boolean foundRecord = false;
        Iterator<EntityItem> iter = event.drops.iterator();
        while (iter.hasNext())
        {
            EntityItem e = iter.next();
            if (e.getEntityItem().getItem() instanceof ItemRecord)
            {
                foundRecord = true;
            }
        }

        if (foundRecord)
        {
            addRandomRecordToDrops(event.drops);
        }
    }
}
项目:RandomAdditions    文件:EventHandlerRandom.java   
@SubscribeEvent
public void onEntityDrops(LivingDropsEvent event)
{
    if(event.source.getSourceOfDamage() instanceof EntityPlayer || event.source.getSourceOfDamage() instanceof EntityRandomArrow)
    {
        ItemStack stack = null;
        EntityPlayer player = null;
        if(event.source.getSourceOfDamage() instanceof EntityRandomArrow)
        {
            stack = ((EntityRandomArrow)event.source.getSourceOfDamage()).bow;
            player = (EntityPlayer) ((EntityRandomArrow)event.source.getSourceOfDamage()).shootingEntity; 
        }
        else
        {
            stack = ((EntityPlayer)event.source.getSourceOfDamage()).getHeldItem();
            player = (EntityPlayer)event.source.getSourceOfDamage();
        }
        if(stack != null && stack.getItem() instanceof ItemTool)
        {
            ArrayList<EnchantmentModifier> modifiers = CraftMaterial.getModifiers(stack);
            for (int i = 0; i < modifiers.size(); i++) {
                modifiers.get(i).onEntityDeath(player, event.entityLiving, event.recentlyHit);
            }
        }
    }
}
项目:projectzulu1.7.10    文件:ChangeVanillaDrops.java   
@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
public void onEvent(LivingDropsEvent event)
{
    if (event.entity instanceof EntitySheep)
    {
        // DEBUG
        Optional<?> itemBlock = ItemList.muttonRaw;

        if (itemBlock.isPresent()) {
        ItemStack itemStackToDrop = new ItemStack((Item)itemBlock.get());

        event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, 

              event.entity.posY, event.entity.posZ, itemStackToDrop));
        }
    }
}
项目:Still-Hungry    文件:EventHooks.java   
@SubscribeEvent
public void entityDrops(LivingDropsEvent event) {
    EntityLivingBase killedEnt = event.entityLiving;
    DamageSource source = event.source;
    boolean recentlyHit = event.recentlyHit;

    if (recentlyHit) {
        if (source.getEntity() instanceof EntityPlayer) {
            if (killedEnt instanceof EntitySquid) {
                event.drops.add(new EntityItem(killedEnt.worldObj, killedEnt.posX, killedEnt.posY, killedEnt.posZ,
                        new ItemStack(ModItems.squid, 1)));
            }

            if (killedEnt instanceof EntitySheep) {
                if (killedEnt.isBurning()) {
                    event.drops.add(new EntityItem(killedEnt.worldObj, killedEnt.posX, killedEnt.posY, killedEnt.posZ,
                            new ItemStack(ModItems.lambCooked, 1)));
                }
                else {
                    event.drops.add(new EntityItem(killedEnt.worldObj, killedEnt.posX, killedEnt.posY, killedEnt.posZ,
                            new ItemStack(ModItems.lamb, 1)));
                }
            }
        }
    }
}
项目:EnderIO    文件:ItemDarkSteelSword.java   
private double getSkullDropChance(@Nonnull EntityPlayer player, LivingDropsEvent evt) {
  if (isWitherSkeleton(evt)) {
    if (isEquippedAndPowered(player, Config.darkSteelSwordPowerUsePerHit)) {
      return Config.darkSteelSwordWitherSkullChance + (Config.darkSteelSwordWitherSkullLootingModifier * evt.getLootingLevel());
    } else {
      return 0.01;
    }
  }
  float fromWeapon;
  float fromLooting;
  if (isEquippedAndPowered(player, Config.darkSteelSwordPowerUsePerHit)) {
    fromWeapon = Config.darkSteelSwordSkullChance;
    fromLooting = Config.darkSteelSwordSkullLootingModifier * evt.getLootingLevel();
  } else {
    fromWeapon = Config.vanillaSwordSkullChance;
    fromLooting = Config.vanillaSwordSkullLootingModifier * evt.getLootingLevel();
  }
  return fromWeapon + fromLooting;
}
项目:harshencastle    文件:HandlerIronHeartDrop.java   
@SubscribeEvent
public void livingDrop(LivingDropsEvent event)
{
    Vec3d vec = new Vec3d(event.getEntityLiving().getPosition());
    if(event.getEntity() instanceof EntityIronGolem)
    {
        List<ItemStack> stackList = HarshenUtils.getItemsFromLootTable(event.getEntity().world, HarshenLootTables.golemDrops);
        if(stackList.size() == 1)
            event.getDrops().add(new EntityItem(event.getEntity().world, vec.x, vec.y, vec.z, stackList.get(0)));
    }
}