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

项目:Loot-Slash-Conquer    文件:EventLivingDeath.java   
@SubscribeEvent
public void onLivingDeath(LivingDeathEvent event)
{
    /*
     * Update player experience when they kill a monster. Experience gained is determined from how much health/damage the monsters has.
     */

    if (event.getSource().getTrueSource() instanceof EntityPlayer)
    {
        EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
        EntityLivingBase enemy = event.getEntityLiving();
        PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);

        if (!player.getEntityWorld().isRemote && playerInfo != null)
        {
            addExperience(player, playerInfo, enemy);
        }
    }
}
项目:harshencastle    文件:HandlerTotemOfUndying.java   
@HarshenEvent
public void PlayerDeath(LivingDeathEvent event)
{
    EntityPlayer player = (EntityPlayer) event.getEntity();
    event.setCanceled(true);
    if (player instanceof EntityPlayerMP)
    {
           EntityPlayerMP entityplayermp = (EntityPlayerMP)player;
           entityplayermp.addStat(StatList.getObjectUseStats(Items.TOTEM_OF_UNDYING));
           CriteriaTriggers.USED_TOTEM.trigger(entityplayermp, HarshenUtils.getFirstOccuringItem(player, Items.TOTEM_OF_UNDYING));
       }

    HarshenUtils.setStackInSlot(player, Items.TOTEM_OF_UNDYING, ItemStack.EMPTY);
    player.setHealth(1.0F);
    player.clearActivePotions();
    player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 900, 1));
    player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 100, 1));
    player.world.setEntityState(player, (byte)35);
}
项目:VillagerInventory    文件:VillagerInventoryMod.java   
@SubscribeEvent
public static void onEntityDeath(LivingDeathEvent event)
{
    // if villager death drops are enabled, if the newly dead entity is a villager, and that villager was killed by a player...
    if ((ModConfiguration.enableDeathDrops) && (event.getEntityLiving() instanceof EntityVillager) && (event.getSource().getTrueSource() instanceof EntityPlayerMP))
    {
        // iterate through the itemstacks in the villager's inventory
        InventoryBasic inventory = ((EntityVillager)event.getEntityLiving()).getVillagerInventory();
        for (int i = 0; i < inventory.getSizeInventory(); i++)
        {
            // remove the stack from the inventory and spawn it in the world
            ItemStack stack = inventory.getStackInSlot(i);
            if (stack != ItemStack.EMPTY)
            {
                event.getEntityLiving().entityDropItem(stack, 0.0F);
            }
        }
    }
}
项目:statclock    文件:EventStatclock.java   
public void printChat(int ID, LivingDeathEvent event, String item) {

        Entity killer = event.getSource().getEntity();
        EntityLivingBase target = event.getEntityLiving();

        // Thanks again 'SourceCoded' <3
        // Add to statclock weapon
        if (killer != null && killer instanceof EntityPlayer) {

            EntityPlayer player = (EntityPlayer) killer;
            String name = killer.getName();
            item = translate(item + ".name");
            player.sendMessage(new TextComponentString( name + "'s " + item + " " + translate("statclock.translate.chat") + " §6[" + translate("strange." + ID) + "]"));
        }

    }
项目:uniquecrops    文件:UCEventHandlerServer.java   
@SubscribeEvent
public void checkPlayerDeath(LivingDeathEvent event) {

    if (event.getEntityLiving() != null && event.getEntityLiving() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer)event.getEntityLiving();
        NBTTagCompound tag = player.getEntityData();
        if (tag.hasKey("hasSacrificed") && !tag.getBoolean("hasSacrificed"))
        {
            EntityItem ei = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, new ItemStack(UCItems.heart));
            tag.setBoolean("hasSacrificed", true);
            if (!player.worldObj.isRemote)
                player.worldObj.spawnEntityInWorld(ei);
            return;
        }
    }
}
项目:NemesisSystem    文件:DeathHandler.java   
@SubscribeEvent
public void onDeath(LivingDeathEvent event) {

    World world = event.getEntity().getEntityWorld();

    if (world.isRemote) {
        return;
    }

    Entity slayer = event.getSource().getTrueSource();

    if (event.getEntity() instanceof EntityPlayer && slayer instanceof EntityCreature) {
        handlePlayerDeath((EntityPlayer) event.getEntity(), (EntityCreature) slayer);
        return;
    }

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

    if (event.getEntity().getTags().contains(NemesisSystem.TAG_NEMESIS)) {
        handleNemesisDeath((EntityCreature) event.getEntity(), slayer);
    }
}
项目:Possessed    文件:ZombieHandler.java   
@SubscribeEvent
public void onLivingDeath(LivingDeathEvent event) {
    if (event.getSource().getSourceOfDamage() != null && event.getSource().getSourceOfDamage() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getSource().getSourceOfDamage();
        if (this.isActive(player) && event.getEntityLiving() instanceof EntityVillager) {
            EntityVillager villager = (EntityVillager) event.getEntityLiving();
            EntityZombie zombieVillager = new EntityZombie(player.worldObj);
            zombieVillager.copyLocationAndAnglesFrom(villager);
            player.worldObj.removeEntity(villager);
            zombieVillager.onInitialSpawn(player.worldObj.getDifficultyForLocation(new BlockPos(zombieVillager)), null);
            zombieVillager.setVillagerType(villager.getProfessionForge());
            zombieVillager.setChild(villager.isChild());
            zombieVillager.setNoAI(villager.isAIDisabled());
            if (villager.hasCustomName()) {
                zombieVillager.setCustomNameTag(villager.getCustomNameTag());
                zombieVillager.setAlwaysRenderNameTag(villager.getAlwaysRenderNameTag());
            }
            player.worldObj.spawnEntityInWorld(zombieVillager);
            player.worldObj.playEvent(null, 1026, zombieVillager.getPosition(), 0);
        }
    }
}
项目:BetterWithAddons    文件:JapaneseMobHandler.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void japaneseDeath(LivingDeathEvent event)
{
    EntityLivingBase living = event.getEntityLiving();
    World world = living.world;
    if(!event.isCanceled() && !world.isRemote && living.hasCapability(JAPANESE_MOB_CAP,null))
    {
        JapaneseMob japaneseMob = living.getCapability(JAPANESE_MOB_CAP,null);
        int i = japaneseMob.spirits;

        while (i > 0)
        {
            int j = EntitySpirit.getSpiritSplit(i);
            i -= j;
            world.spawnEntity(new EntitySpirit(world, living.posX, living.posY, living.posZ, j));
        }
    }
}
项目:Dailies    文件:Events.java   
@SubscribeEvent
public void onHunt(LivingDeathEvent event) {

    EntityPlayer player = null;

    EntityLivingBase e = (EntityLivingBase) event.getEntity();
    DamageSource source = event.getSource();

    if (source.getTrueSource() instanceof EntityPlayer) {
        player = (EntityPlayer) source.getTrueSource();
    }

    if (player == null) {
        return;
    }

    IDailiesCapability dailies = getCapability(player);
    if (dailies == null) {
        return;
    }

    dailies.hunt(player, e);
}
项目:MidgarCrusade    文件:ForgeEventHooksHandler.java   
@SubscribeEvent
public void reviveEffect(LivingDeathEvent lde)
  {
    if ((Main.allowPFeather) && ((lde.entityLiving instanceof EntityPlayer)))
    {
      EntityPlayer ep = (EntityPlayer)lde.entityLiving;
    if (((EntityLivingBase) ep).isPotionActive(ItemRegistry1.customPotion))
      {
        if (!ep.worldObj.isRemote)
        {
            ep.setHealth(17);
          ep.worldObj.playSoundAtEntity(ep, "fireworks.launch", 5.0F, 1.0F);
          ep.worldObj.playSoundAtEntity(ep, "assets.speedboost", 0.4F, 0.3F);
          ((EntityLivingBase) ep).removePotionEffect(ItemRegistry1.customPotion.id);
        }
        System.out.println("Potion types capacity: " + Potion.potionTypes.length);
        lde.setCanceled(true);
      }
    }
    }
项目:ToroQuest    文件:QuestKillMobs.java   
@SubscribeEvent
public void onKill(LivingDeathEvent event) {
    EntityPlayer player = null;
    EntityLivingBase victim = (EntityLivingBase) event.getEntity();
    DamageSource source = event.getSource();

    if (source.getTrueSource() instanceof EntityPlayer) {
        player = (EntityPlayer) source.getTrueSource();
    }

    if (player == null) {
        return;
    }

    Province province = PlayerCivilizationCapabilityImpl.get(player).getInCivilization();

    if (province == null || province.civilization == null) {
        return;
    }

    handleKillMobsQuest(player, province, victim);
}
项目:ToroQuest    文件:QuestEnemyEncampment.java   
@SubscribeEvent
public void checkkills(LivingDeathEvent event) {
    EntityPlayer player = null;
    EntityLivingBase victum = (EntityLivingBase) event.getEntity();
    DamageSource source = event.getSource();

    if (!victum.getTags().contains("encampment_quest")) {
        return;
    }

    if (source.getTrueSource() instanceof EntityPlayer) {
        player = (EntityPlayer) source.getTrueSource();
    } else {
        return;
    }

    Set<QuestData> quests = PlayerCivilizationCapabilityImpl.get(player).getCurrentQuests();
    for (QuestData data : quests) {
        if (ID == data.getQuestType() && victum.getTags().contains(data.getQuestId().toString())) {
            incrementKills(data);
            return;
        }
    }
}
项目:ToroQuest    文件:CivilizationHandlers.java   
@SubscribeEvent
public void checkKillsInCivilization(LivingDeathEvent event) {
    EntityPlayer player = null;
    EntityLivingBase victim = (EntityLivingBase) event.getEntity();
    DamageSource source = event.getSource();

    if (source.getTrueSource() instanceof EntityPlayer) {
        player = (EntityPlayer) source.getTrueSource();
    }

    if (player == null) {
        return;
    }

    Province province = PlayerCivilizationCapabilityImpl.get(player).getInCivilization();

    if (province == null || province.civilization == null) {
        return;
    }

    PlayerCivilizationCapabilityImpl.get(player).adjustReputation(province.civilization, getRepuationAdjustmentFor(victim, province));

}
项目:TAIGA    文件:TraitReviving.java   
@SubscribeEvent
public void onEntityKill(LivingDeathEvent e) {
    BlockPos pos = e.getEntity().getPosition();
    World w = e.getEntity().getEntityWorld();
    if (!w.isRemote && e.getSource().getTrueSource() != null) {
        if (e.getSource().getTrueSource() instanceof EntityPlayer && e.getEntity() instanceof EntityCreature) {
            if (random.nextFloat() <= chance && TinkerUtil.hasTrait(TagUtil.getTagSafe(((EntityPlayer) e.getSource().getTrueSource()).getHeldItemMainhand()), identifier)) {
                int id = e.getEntity().getEntityId();
                Entity ent = EntityList.createEntityByID(id, w);
                if (ent != null) {
                    ent.setPosition(pos.getX(), pos.getY(), pos.getZ());
                    w.spawnEntity(ent);
                    e.getSource().getTrueSource().playSound(SoundEvents.AMBIENT_CAVE, 1.0F, 1.0F);
                }
            }
        }
    }
}
项目:TAIGA    文件:TraitSoulEater.java   
@SubscribeEvent
public void onTargetKilled(LivingDeathEvent event) {
    if (event.getSource().getTrueSource() instanceof EntityPlayer && event.getEntity() instanceof EntityLiving) {
        World w = event.getSource().getTrueSource().world;
        ItemStack tool = ((EntityPlayer) event.getSource().getTrueSource()).getHeldItemMainhand();
        if (!w.isRemote && TinkerUtil.hasTrait(TagUtil.getTagSafe(tool), identifier)) {
            NBTTagCompound tag = TagUtil.getExtraTag(tool);
            Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
            float health = ((EntityLiving) event.getEntity()).getMaxHealth();
            data.killcount += 1;
            data.health = health;
            float bonus = Math.round(random.nextFloat() * health * 100) / divisor;
            data.bonus += bonus;
            data.bonus = (float) Math.round(data.bonus * 100f) / 100f;
            data.write(tag);
            TagUtil.setExtraTag(tool, tag);
        }
    }
}
项目:TAIGA    文件:TraitCongenial.java   
@SubscribeEvent
public void onEntityKill(LivingDeathEvent e) {
    if (e.getSource().getTrueSource() instanceof EntityPlayer && !e.getSource().getTrueSource().world.isRemote && e.getEntity() instanceof EntityCreature) {
        if (TinkerUtil.hasTrait(TagUtil.getTagSafe(((EntityPlayer) e.getSource().getTrueSource()).getHeldItemMainhand()), identifier)) {
            ItemStack tool = ((EntityPlayer) e.getSource().getTrueSource()).getHeldItemMainhand();
            String name = e.getEntity().getName();
            NBTTagCompound tag = TagUtil.getExtraTag(tool);
            Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
            if (!data.name.isEmpty()) {
                return;
            }
            data.name = name;
            data.write(tag);
            TagUtil.setExtraTag(tool, tag);
        }
    }
}
项目:Alchemy    文件:ItemRingAlive.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onLivingDeath(LivingDeathEvent event) {
    if (Always.isServer()) {
        EntityLivingBase living = event.getEntityLiving();
        if (!living.isEntityUndead()) {
            EntityLivingBase target = EntityAIFindEntityNearestHelper.findNearest(living,
                    EntityLivingBase.class, AABBHelper.getAABBFromEntity(living, RADIUS), this::isEquipmented);
            float power = living.getMaxHealth() / 5;
            if (target != null && power > 0) {
                ItemStack alive = getFormLiving(target);
                alive_power.set(alive, min(alive_power.get(alive) + power, MAX_POWER));
                List<Double6IntArrayPackage> d6iaps = Lists.newLinkedList();
                int update[] = FXUpdateHelper.getIntArrayByArgs(FX_KEY_FOLLOW, target.getEntityId());
                for (int i = 0; i < 4; i++)
                    d6iaps.add(new Double6IntArrayPackage(
                            living.posX + living.rand.nextGaussian(),
                            living.posY + living.rand.nextFloat() * .5,
                            living.posZ + living.rand.nextGaussian(), 0, 0, 0, update));
                AlchemyNetworkHandler.spawnParticle(FXWisp.Info.type,
                        AABBHelper.getAABBFromEntity(living, AlchemyNetworkHandler.getParticleRange()), living.world, d6iaps);
            }
        }
    }
}
项目:BlockSystems    文件:ServerEventHandler.java   
@SubscribeEvent
public void onLivingDeath(LivingDeathEvent event) {
    Entity entity = event.getEntity();
    World world = entity.world;
    if (entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        if (world instanceof WorldServer && player instanceof EntityPlayerMP) {
            Map<Integer, BlockSystem> blockSystems = BlockSystems.PROXY.getBlockSystemHandler(world).getBlockSystems();
            for (Map.Entry<Integer, BlockSystem> entry : blockSystems.entrySet()) {
                BlockSystem blockSystem = entry.getValue();
                if (blockSystem instanceof BlockSystemServer) {
                    ((BlockSystemServer) blockSystem).getChunkTracker().removePlayer((EntityPlayerMP) player);
                }
            }
        }
    }
}
项目:LootableBodies    文件:PlayerDeathEventHandler.java   
@SubscribeEvent(priority= EventPriority.LOW)
public void entityDeathEvent(LivingDeathEvent e){
    if(e.getEntity() instanceof EntityPlayer
            && e.getResult() != Event.Result.DENY
            && !e.getEntity().getEntityWorld().isRemote) {
        final EntityPlayer player = (EntityPlayer)e.getEntity();
        if(player.isSpectator()) return;
        Map<ItemStack,EntityEquipmentSlot> cache = equipmentCache.computeIfAbsent(player,(EntityPlayer p)->new HashMap<>());
        for(EntityEquipmentSlot slot : EntityLootableBody.EQUIPMENT_SLOTS){
            cache.put(player.getItemStackFromSlot(slot),slot);
        }

        if(player.getPrimaryHand() == EnumHandSide.LEFT){
            // swap main and off hand items (easier than messing with the rendering code)
            cache.put(player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND),EntityEquipmentSlot.OFFHAND);
            cache.put(player.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND),EntityEquipmentSlot.MAINHAND);
        }
    }
}
项目:DiscordCE    文件:MinecraftEventHandler.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPlayerDeathMessage(LivingDeathEvent e)
{
    if (!Config.deathMessages
            || !(e.getEntityLiving() instanceof EntityPlayer)
            || e.getEntityLiving().getUniqueID() != Minecraft.getMinecraft().thePlayer.getUniqueID())
        return;

    // Getting discord and minecraft user
    EntityPlayer player = (EntityPlayer) e.getEntityLiving();
    User me = DiscordCE.client.getUserById(DiscordCE.client.getSelfInfo().getId());

    // Getting death message
    String deathMessage = e.getSource().getDeathMessage(e.getEntityLiving()).getUnformattedText();

    // Replacing minecraft name with discord name
    deathMessage = deathMessage.replaceAll(player.getDisplayNameString(), me.getAsMention());

    // Sending death message
    DiscordCE.client.getTextChannelById(Preferences.i.usingChannel).sendMessageAsync(deathMessage, null);
}
项目:EnderPay    文件:EventHandler.java   
@SubscribeEvent
@SuppressWarnings("unused")
public void onLivingDeathEvent(LivingDeathEvent event) {
    int moneyDropValue = EnderPay.settings.getPvpMoneyDrop();
    if (moneyDropValue == 0) return;
    Entity entity = event.getEntity();
    if (!(entity instanceof EntityPlayer) || entity.world.isRemote) return;
    Entity killer = event.getSource().getTrueSource();
    if (!(killer instanceof EntityPlayerMP)) return;

    Account account = Account.get((EntityPlayer) entity);
    if (account.getBalance() <= 0) return;
    long amountTaken = (moneyDropValue > 0) ?
            (account.getBalance() * EnderPay.settings.getPvpMoneyDrop()) / 100 :
            Math.max(Math.min(account.getBalance(), -EnderPay.settings.getPvpMoneyDrop()), 0);
    account.addBalance(-amountTaken);

    long balance = account.getBalance();
    PacketDispatcher.sendTo(new MessageBalance(balance), (EntityPlayerMP) entity);

    Account killerAccount = Account.get((EntityPlayer) killer);
    killerAccount.addBalance(amountTaken);
    long balance2 = killerAccount.getBalance();
    PacketDispatcher.sendTo(new MessageBalance(balance2), (EntityPlayerMP) killer);
}
项目:Limited-Lives    文件:EventHandler.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerDeath(LivingDeathEvent event)
{
    if(!event.getEntityLiving().getEntityWorld().isRemote && event.getEntityLiving() instanceof EntityPlayer && !(event.getEntityLiving() instanceof FakePlayer))
    {
        EntityPlayerMP player = (EntityPlayerMP)event.getEntityLiving();
        if(player.interactionManager.getGameType() == GameType.CREATIVE || player.interactionManager.getGameType() == GameType.SPECTATOR)
        {
            return;
        }
        NBTTagCompound tag = EntityHelper.getPlayerPersistentData(player, "LimitedLivesSave");
        int prevDeaths = tag.getInteger("deathCount");
        int liveCount = tag.getInteger("maxLives");
        if(liveCount == 0)
        {
            liveCount = LimitedLives.maxLives;
        }
        tag.setDouble("healthOffset", event.getEntityLiving().getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).getBaseValue() - (20D - (20D * prevDeaths / (double)liveCount)));
        tag.setInteger("deathCount", prevDeaths + 1);
        tag.setInteger("maxLives", LimitedLives.maxLives);
    }
}
项目:EnderCore    文件:XPBoostHandler.java   
@SubscribeEvent
public void handleEntityKill(LivingDeathEvent event) {
  EntityLivingBase entity = event.entityLiving;
  Entity killer = event.source.getSourceOfDamage();

  if (!entity.worldObj.isRemote && killer != null) {
    if (killer instanceof EntityPlayer) {
      scheduleXP(entity, getXPBoost(entity, (EntityPlayer) killer));
    } else if (killer instanceof EntityArrow && ((EntityArrow) killer).shootingEntity instanceof EntityPlayer) {
      NBTTagCompound tag = killer.getEntityData();
      if (tag.hasKey(NBT_KEY) && tag.getInteger(NBT_KEY) >= 0) {
        int level = tag.getInteger(NBT_KEY);
        EntityArrow arrow = (EntityArrow) killer;
        scheduleXP(entity, getXPBoost(entity, (EntityPlayer) arrow.shootingEntity, level));
      }
    }
  }
}
项目:Kingdom-Keys-Re-Coded    文件:DriveFormFinal.java   
@SubscribeEvent
public static void getXP(LivingDeathEvent event) {
     if (!event.getEntity().world.isRemote && event.getEntity() instanceof EntityEnderman) { 
         if (event.getSource().getTrueSource() instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
            IDriveState DRIVE = player.getCapability(ModCapabilities.DRIVE_STATE, null); 

            if(DRIVE.getActiveDriveName().equals(Strings.Form_Final)) {
                DRIVE.setDriveExp(DRIVE.getActiveDriveName(), DRIVE.getDriveExp(DRIVE.getActiveDriveName())+1);

                int[] costs = DriveFormRegistry.get(DRIVE.getActiveDriveName()).getExpCosts();
                int actualLevel = DRIVE.getDriveLevel(DRIVE.getActiveDriveName());
                int actualExp = DRIVE.getDriveExp(DRIVE.getActiveDriveName());

                if(costs.length == 7 && actualLevel < 7) {
                    if (actualExp >= costs[actualLevel]){
                        System.out.println("LEVEL UP");
                        DRIVE.setDriveLevel(DRIVE.getActiveDriveName(),actualLevel+1); 
                        DRIVE.displayLevelUpMessage(player, DRIVE.getActiveDriveName());
                    }
                }
                PacketDispatcher.sendTo(new SyncDriveData(DRIVE), (EntityPlayerMP) player);
             }
         }
     }
}
项目:Kingdom-Keys-Re-Coded    文件:DriveFormWisdom.java   
@SubscribeEvent
public static void getXP(LivingDeathEvent event) {
     if (!event.getEntity().world.isRemote && event.getEntity() instanceof IKHMob) { 
         if (event.getSource().getTrueSource() instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
            IDriveState DRIVE = player.getCapability(ModCapabilities.DRIVE_STATE, null); 

            if(DRIVE.getActiveDriveName().equals(Strings.Form_Wisdom)) {
                DRIVE.setDriveExp(DRIVE.getActiveDriveName(), DRIVE.getDriveExp(DRIVE.getActiveDriveName())+1);

                int[] costs = DriveFormRegistry.get(DRIVE.getActiveDriveName()).getExpCosts();
                int actualLevel = DRIVE.getDriveLevel(DRIVE.getActiveDriveName());
                int actualExp = DRIVE.getDriveExp(DRIVE.getActiveDriveName());

                if(costs.length == 7 && actualLevel < 7) {
                    if (actualExp >= costs[actualLevel]){
                        System.out.println("LEVEL UP");
                        DRIVE.setDriveLevel(DRIVE.getActiveDriveName(),actualLevel+1); 
                        DRIVE.displayLevelUpMessage(player, DRIVE.getActiveDriveName());
                    }
                }
                PacketDispatcher.sendTo(new SyncDriveData(DRIVE), (EntityPlayerMP) player);
            }
         }
     }
}
项目:HardcoreWither    文件:EventHandler.java   
@SubscribeEvent
public void onEntityDieing(LivingDeathEvent event)
{
   if(!event.entity.worldObj.isRemote)
   {
      if (event.entityLiving != null && event.entityLiving.getClass() == EntityWither.class)
      {
         List nearbyPlayers = event.entity.worldObj.getEntitiesWithinAABB(EntityPlayer.class, event.entity.boundingBox.expand(64.0D, 64.0D, 64.0D));
         double powerUpSize = 0.0;
         for (int index = 0; index < nearbyPlayers.size(); ++index)
         {
            EntityPlayer player = (EntityPlayer)nearbyPlayers.get(index);
            powerUpSize += playerHandler.wasAtWitherSpawn(player);
            player.addChatMessage(new ChatComponentText(TextHelper.localize("info." + ModInformation.ID + ".chat.wither-experience")));
         }
         powerUpManager.witherDied((EntityWither) event.entityLiving);
      }
   }
}
项目:Cyclic    文件:EnchantXpBoost.java   
@SubscribeEvent
public void onEntityKill(LivingDeathEvent event) {
  if (event.getSource() == null) {
    return;
  }
  if (event.getSource().getTrueSource() instanceof EntityPlayer && event.getEntity() instanceof EntityLivingBase) {
    EntityPlayer attacker = (EntityPlayer) event.getSource().getTrueSource();
    int level = getCurrentLevelTool(attacker);
    if (level <= 0) {
      return;
    }
    EntityLivingBase target = (EntityLivingBase) event.getEntity();
    World world = attacker.getEntityWorld();
    BlockPos pos = target.getPosition();
    dropExp(world, pos, XP_PER_LVL * level);
  }
}
项目:Cyclic    文件:EnchantLifeLeech.java   
@SubscribeEvent
public void onEntityKill(LivingDeathEvent event) {
  if (event.getSource().getTrueSource() instanceof EntityPlayer && event.getEntity() instanceof EntityLivingBase) {
    EntityPlayer attacker = (EntityPlayer) event.getSource().getTrueSource();
    EntityLivingBase target = (EntityLivingBase) event.getEntity();
    int level = getCurrentLevelTool(attacker);
    if (level > 0) {
      // we -1  since potion level 1 is  II
      //so that means enchantment I giving poison I means this
      int restore = (int) Math.max(Math.ceil(target.getMaxHealth() / 5), 4);
      int min = 1;//so if restore starts at 4 the rand will be [min,restore]
      restore = attacker.getEntityWorld().rand.nextInt(restore + 1) + min;
      if (restore > 0) {
        attacker.getFoodStats().setFoodLevel(attacker.getFoodStats().getFoodLevel() + level);
        if (attacker.getHealth() < attacker.getMaxHealth()) {
          attacker.heal(restore);
          UtilParticle.spawnParticle(attacker.getEntityWorld(), EnumParticleTypes.HEART, attacker.getPosition().up(2));
        }
      }
    }
  }
}
项目:AchieveSON    文件:ConditionKillEntity.java   
@SubscribeEvent
public void entityDeathEvent(LivingDeathEvent event) {
    if (event.entityLiving != null && !event.entityLiving.worldObj.isRemote && event.source != null) {
        if (event.source.getSourceOfDamage() != null && damageFromPlayer(event.source) && !targets.isEmpty()) {
            KillTarget info = matchInfo(event.entityLiving.getClass());
            EntityPlayerMP player = getPlayerFromSource(event.source);
            if (info != null && player != null && !player.func_147099_x().hasAchievementUnlocked(info.getAchievement()) && player.func_147099_x().canUnlockAchievement(info.getAchievement())) {
                int count = 1 + NBTUtil.getInt(player, info.getAchievement().statId);
                NBTUtil.setInt(player, info.getAchievement().statId, count);
                if (count >= info.getCount()) {
                    player.addStat(info.getAchievement(), 1);
                    NBTUtil.removeTag(player, info.getAchievement().statId);
                }
            }
        }
    }
}
项目:TechNodefirmacraftMod    文件:PlayerInteractHandler.java   
@SubscribeEvent
public void onEntityLivingDeath(LivingDeathEvent event)
{

    if(event.entityLiving instanceof EntityPlayer)
    {
        // You play with the bear, you sometimes get your head ripped clean off!
        if(event.source.getEntity() instanceof EntityBear && event.entityLiving.worldObj.rand. nextDouble() * 100 <= ModOptions.dropChance)
        {
            ItemStack playerHead = new ItemStack(Items.skull, 1, 3);
            playerHead.setTagCompound(new NBTTagCompound());
            EntityPlayer player = (EntityPlayer)event.entityLiving;
            String playerName = player.getCommandSenderName();
            playerHead.getTagCompound().setString("SkullOwner", playerName);
            event.entityLiving.entityDropItem(playerHead, 0.5F);

        }
    }       
}
项目:Cooking-with-TFC    文件:PlayerHandler.java   
@SubscribeEvent
public void onEntityDeath(LivingDeathEvent event)
{
    EntityLivingBase entity = event.entityLiving;

    //Reset eaten foods after death
    if (entity instanceof EntityPlayer && Settings.diminishingReturns)
    {
        FoodRecord fr = CWTFC_Core.getPlayerFoodRecord((EntityPlayer)entity);
        for(int i = 0; i < fr.FoodsEaten.length; i++)
        {
            fr.FoodsEaten[i] = null;
        }
        fr.FoodListRef = 0;
        CWTFC_Core.setPlayerFoodRecord((EntityPlayer)entity, fr);
    }
}
项目:BluePower    文件:BPEventHandler.java   
@SubscribeEvent
public void onEntityDeath(LivingDeathEvent event) {
    if(event.source instanceof EntityDamageSource) {
        EntityDamageSource entitySource = (EntityDamageSource) event.source;

        if(entitySource.getEntity() instanceof EntityPlayer) {
            EntityPlayer killer = (EntityPlayer) entitySource.getEntity();

            if(killer.inventory.getCurrentItem() != null) { 
                if(EnchantmentHelper.getEnchantments(killer.inventory.getCurrentItem()).containsKey(BPEnchantments.vorpal.effectId)) {
                    int level = EnchantmentHelper.getEnchantmentLevel(BPEnchantments.vorpal.effectId, killer.inventory.getCurrentItem());

                    if(level == 1) {
                        if(killer.worldObj.rand.nextInt(6) == 1) {
                            this.dropHeads(event);
                        }
                    } else if(level == 2) {
                        if(killer.worldObj.rand.nextInt(3) == 1) {
                        this.dropHeads(event);
                        }
                    }
                }
            }
        }
    }
}
项目:Runecraft-2    文件:Runecraft2EventHandler.java   
@SubscribeEvent
public void onLivingDeathEvent(LivingDeathEvent event) {
    // we only want to save data for players (most likely, anyway)
    if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer) {
        // NOTE: See step 6 for a way to do this all in one line!!!
        // create a new NBT Tag Compound to store the
        // IExtendedEntityProperties data
        NBTTagCompound playerData = new NBTTagCompound();
        // write the data to the new compound
        ((ExtendedPlayer) (event.entity.getExtendedProperties(ExtendedPlayer.EXT_PROP_NAME))).saveNBTData(playerData);
        // and store it in our proxy
        if (event.entity instanceof EntityLiving) {
            username = event.entity.getCommandSenderEntity().getName();
        }
        proxy.storeEntityData(username, playerData);
        // call our handy static one-liner to save custom data to the proxy
        // save player data:
        proxy.storeEntityData(username + ExtendedPlayer.EXT_PROP_NAME, playerData);

        ExtendedPlayer.saveProxyData((EntityPlayer) event.entity);
    }
}
项目:mcpvp-mod    文件:AssistTrackerCTF.java   
public static void onDeath(LivingDeathEvent event) {
    if (!(event.entity instanceof EntityVillager)) return;
    String name = ((EntityVillager)event.entity).getCustomNameTag().replaceAll("\u00A7.", "");

    if (playersHit.containsKey(name)) {

        // Check the time. 
        // If the current time minus the time hit them is greater than or equal to our assistTime, continue.
        // Also check if the time is greater than 500 to avoid killing interfering. 
        if (System.currentTimeMillis() - playersHit.get(name) <= assistTime 
                && System.currentTimeMillis() - playersHit.get(name) > 500) {
            // If we pass those checks, show the custom alert and sound alert, and increase the assist number.
            Vars.put("player", TeamCTF.getTeam(name).color() + name);
            CustomAlert.get("assist").show();
            SoundAlert.get("assist").play();
            StatsCTF.assists++;
        }
        playersHit.remove(name);
    }
}
项目:vintagecraft    文件:VintageCraft.java   
@SubscribeEvent
public void entityDeath(LivingDeathEvent evt) {
    if (evt.entityLiving instanceof EntityZombie && evt.source.getEntity() instanceof EntityPlayer) {
        ItemStack[]inventory = evt.entityLiving.getInventory();
        int numArmorItems = 0;
        for (ItemStack stack : inventory) {
            if (stack != null && stack.getItem() instanceof ItemArmorVC) {
                ItemArmorVC armoritem = (ItemArmorVC)stack.getItem();
                if (armoritem.getArmorMaterial().name().equals("IRONVC")) numArmorItems++;
            }
        }

        if (numArmorItems == 4) {
            ((EntityPlayer)evt.source.getEntity()).triggerAchievement(AchievementsVC.killIronArmorZombie);
        }
    }
}
项目:Billund    文件:BillundProxyCommon.java   
@ForgeSubscribe
public void onEntityLivingDeath( LivingDeathEvent event )
{
    if( event.entity.worldObj.isRemote )
    {
        return;
    }

    if( event.entity instanceof EntityZombie )
    {
        EntityLivingBase living = (EntityLivingBase)event.entity;
        if( (living.isChild() && r.nextInt(20) == 0) ||
            (!living.isChild() && r.nextInt(100) == 0) )
        {
            event.entity.entityDropItem( new ItemStack( Billund.Items.orderForm, 1 ), 0.0f );
        }
    }
}
项目:MagicalRings    文件:EntityHandler.java   
@SubscribeEvent
public void onDeath(LivingDeathEvent event) {
    if (!event.entityLiving.worldObj.isRemote) {
        EntityLivingBase entity = event.entityLiving;
        if (entity instanceof EntityBat) {
            if (((EntityBat) entity).worldObj.rand.nextInt(100) < 80) {
                EntityItem batWing = new EntityItem(((EntityBat) entity).worldObj, ((EntityBat) entity).posX, ((EntityBat) entity).posY, ((EntityBat) entity).posZ, new ItemStack(ModItems.materials));
                ((EntityBat) entity).worldObj.spawnEntityInWorld(batWing);
            }
        } else if (entity instanceof EntitySquid) {
            if (((EntitySquid) entity).worldObj.rand.nextInt(100) < 60) {
                EntityItem tentacle = new EntityItem(((EntitySquid) entity).worldObj, ((EntitySquid) entity).posX, ((EntitySquid) entity).posY, ((EntitySquid) entity).posZ, new ItemStack(ModItems.materials, 1, 4));
                ((EntitySquid) entity).worldObj.spawnEntityInWorld(tentacle);
            }
        }
    }
}
项目:D3Core    文件:VoidRefunds.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void livingDeathEvent(LivingDeathEvent event)
{
    if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return;
    if (event.getSource() != DamageSource.OUT_OF_WORLD || !(event.getEntity() instanceof EntityPlayer)) return;
    if (event.getEntityLiving().lastDamage >= (Float.MAX_VALUE / 2)) return; // try to ignore /kill command
    for (int dim : voidRefundDimensions)
    {
        if (dim != event.getEntity().dimension) continue;
        event.setCanceled(true);

        //noinspection ConstantConditions
        InventoryPlayer tempCopy = new InventoryPlayer(null);
        tempCopy.copyInventory(((EntityPlayer) event.getEntity()).inventory);
        map.put(event.getEntity().getPersistentID(), tempCopy);
    }
}
项目:MoarPeripherals    文件:TileChatBox.java   
@Override
public void onDeathEvent(LivingDeathEvent event) {
    if (event.entity instanceof EntityPlayerMP) {
        DamageSource source = event.source;
        String killer = null;
        if (source instanceof EntityDamageSource) {
            Entity ent = source.getEntity();
            if (ent != null) {
                killer = ent.getCommandSenderName();
            }
        }
        if (rangeRead < 0 || entityInRange(event.entity, rangeRead)) {
            computerQueueEvent(EVENT_DEATH, event.entity.getCommandSenderName(), source.getDamageType(), killer);
        }
    }
}
项目:Quantum-Anomalies    文件:DiscoveryListener.java   
@SubscribeEvent
public void livingKilled(LivingDeathEvent event) {
    Entity killer = event.source.getEntity();
    EntityLivingBase target = event.entityLiving;
    if (isServer() && killer != null && killer instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) killer;

        if (target instanceof EntityWither) {
            DiscoveryManager.unlockItem(QADiscoveries.Item.STAR.get().getKey(), player, false);
        } else if (target instanceof EntityZombie) {
            ItemStack equip = ((EntityZombie) target).getEquipmentInSlot(0);
            if (equip != null && equip.getItem() instanceof ItemSword)
                DiscoveryManager.unlockItem(QADiscoveries.Item.SWORD.get().getKey(), player, false);
        } else if (target instanceof EntityBlaze) {
            DiscoveryManager.unlockItem(QADiscoveries.Item.TOOLS.get().getKey(), player, false);
        }
    }
}