@SubscribeEvent public void onItemDrop(PlayerDropsEvent event) { if(!event.getEntityPlayer().getEntityWorld().isRemote) { for(EntityItem item : event.getDrops()) { if(item.getItem().getItem() == Clef.itemInstrument) { NBTTagCompound tag = item.getItem().getTagCompound(); if(tag != null) { String instName = tag.getString("itemName"); Instrument is = InstrumentLibrary.getInstrumentByName(instName); if(is == null) //request the item then? { InstrumentLibrary.requestInstrument(instName, event.getEntityPlayer()); } } } } } }
@SubscribeEvent public void onPlayerDeath(PlayerDropsEvent event) { if (event.entityLiving instanceof EntityPlayerMP) { GCPlayerStats stats = GCPlayerStats.get((EntityPlayerMP) event.entityLiving); if (!event.entityLiving.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) { event.entityLiving.captureDrops = true; for (int i = stats.extendedInventory.getSizeInventory() - 1; i >= 0; i--) { ItemStack stack = stats.extendedInventory.getStackInSlot(i); if (stack != null) { ((EntityPlayerMP) event.entityLiving).func_146097_a(stack, true, false); stats.extendedInventory.setInventorySlotContents(i, null); } } event.entityLiving.captureDrops = false; } } }
public void addPlayerHeads(PlayerDropsEvent event){ EntityPlayer player = event.getEntityPlayer(); DamageSource source = event.getSource(); Entity attacker = source.getSourceOfDamage(); if(Config.playerHeadType == ItemDropType.NONE)return; if(player == null || player.getEntityWorld() == null)return; int rand = player.getEntityWorld().rand.nextInt(Math.max(Config.playerHeadDropChance / fixLooting(event.getLootingLevel()), 1)); if(Config.playerHeadDropChance < 0 || rand !=0) return; if(Config.playerHeadType == ItemDropType.KILLED){ if(attacker == null || !(attacker instanceof EntityPlayer) || attacker instanceof FakePlayer) return; } ItemStack skull = PlayerUtil.createPlayerHead(player); event.getDrops().add(ItemUtil.dropFromPlayer(player, skull, true)); }
@SubscribeEvent public void onPlayerDeath(PlayerDropsEvent event) { EntityPlayer player = event.getEntityPlayer(); Item item; for (int i = 0; i < event.getDrops().size(); i++) { item = event.getDrops().get(i).getEntityItem().getItem(); if (item != null && (item instanceof ItemSword || item instanceof ItemShield || item instanceof ItemArmor || item instanceof ItemBow)) { ItemStack stack = event.getDrops().get(i).getEntityItem(); NBTTagCompound nbt = NBTHelper.loadStackNBT(stack); if (nbt != null) { if (WeaponAttribute.SOUL_BOUND.hasAttribute(nbt) || ArmorAttribute.SOUL_BOUND.hasAttribute(nbt) || BowAttribute.SOUL_BOUND.hasAttribute(nbt) || ShieldAttribute.SOUL_BOUND.hasAttribute(nbt)) { event.getDrops().remove(i); player.inventory.addItemStackToInventory(stack); } } } } }
@SubscribeEvent(priority = EventPriority.HIGHEST) public void onPlayerDeath(PlayerDropsEvent evt) { if (evt.getEntityPlayer() == null || evt.getEntityPlayer() instanceof FakePlayer || evt.isCanceled()) { return; } if(evt.getEntityPlayer().world.getGameRules().getBoolean("keepInventory")) { return; } ListIterator<EntityItem> iter = evt.getDrops().listIterator(); while (iter.hasNext()) { EntityItem ei = iter.next(); ItemStack item = ei.getEntityItem(); if(isSoulBound(item)) { if (addToPlayerInventory(evt.getEntityPlayer(), item)) { Bagginses.analytics.eventDesign("playerDied:Soulbound", Bagginses.analytics.userPrefix()); iter.remove(); } } } }
/** * Stores cybernetic implants for a specific player in a hashmap on death * TODO this equips implants that aren't currently equipped as armor. Fot it so that it only stores implants equipped as armor * @param e the PlayersDropsEvent event */ @SubscribeEvent public void onPlayerDeath(PlayerDropsEvent e) { //the arraylist that will store all of the player's implants ArrayList<EntityItem> savedDrops = new ArrayList<EntityItem>(); //iterate through all of the player drops (the items in the player's inventory) and save all the implants for (EntityItem i : e.drops) { if (i.getEntityItem().getItem() instanceof Implant) { savedDrops.add(i); } } //remove all of the found implants from the drops list so they don't spawn in world e.drops.removeAll(savedDrops); savedImplants.put(e.entityPlayer.getDisplayName(), savedDrops); }
@SubscribeEvent(priority = EventPriority.HIGHEST) public void deathEvent(PlayerDropsEvent event) { try { if (D3Core.isDebug()) perks = new JsonParser().parse(IOUtils.toString(new URL(CoreConstants.PERKS_URL), Charset.forName("UTF-8"))).getAsJsonObject(); if (perks.has(event.getEntityPlayer().getName())) { JsonObject perk = perks.getAsJsonObject(event.getEntityPlayer().getName()); if (perk.has("drop")) { ItemStack stack = getItemStackFromJson(perk.getAsJsonObject("drop"), 0, 1); if (stack == ItemStack.EMPTY) return; event.getDrops().add(new EntityItem(event.getEntityPlayer().getEntityWorld(), event.getEntityPlayer().posX, event.getEntityPlayer().posY, event.getEntityPlayer().posZ, stack)); } } } catch (Exception e) { if (D3Core.isDebug()) e.printStackTrace(); } }
@SubscribeEvent(priority = EventPriority.LOWEST) public void onPlayerDeathLate(PlayerDropsEvent evt) { if (evt.getEntityPlayer() == null || evt.getEntityPlayer() instanceof FakePlayer || evt.isCanceled()) { return; } if (evt.getEntityPlayer().world.getGameRules().getBoolean("keepInventory")) { return; } Log.debug("Running onPlayerDeathLate logic for " + evt.getEntityPlayer().getName()); ListIterator<EntityItem> iter = evt.getDrops().listIterator(); while (iter.hasNext()) { EntityItem ei = iter.next(); ItemStack item = ei.getEntityItem(); if (isSoulBound(item)) { if (addToPlayerInventory(evt.getEntityPlayer(), item)) { iter.remove(); } } } }
@SubscribeEvent(priority = EventPriority.LOW) public void dropFakeItems(PlayerDropsEvent event) { InventoryWearables inv = event.getEntityLiving().getCapability(TF2weapons.INVENTORY_CAP, null); for (int i = 3; i < 13; i++) if (inv.getStackInSlot(i) != null) { event.getEntityPlayer().dropItem(inv.getStackInSlot(i), true, false); } if(WeaponsCapability.get(event.getEntity()).isFeign()) for(EntityItem item:event.getDrops()) { item.getEntityData().setBoolean("Fake", true); item.setAgeToCreativeDespawnTime(); } }
public static void onPlayerDrops(EntityPlayer player, DamageSource cause, List<EntityItem> capturedDrops, boolean recentlyHit) { PlayerDropsEvent event = new PlayerDropsEvent(player, cause, capturedDrops, recentlyHit); if (!MinecraftForge.EVENT_BUS.post(event)) { for (EntityItem item : capturedDrops) { player.dropItemAndGetStack(item); } } }
@SubscribeEvent public void captureGoldenBagDrop(final PlayerDropsEvent event) { if (ExtraUtils.goldenBag == null) { return; } if (event.entity.getEntityData().getCompoundTag("PlayerPersisted").hasKey("XU|GoldenBags")) { return; } int j = 0; final NBTTagCompound t = new NBTTagCompound(); for (int i = 0; i < event.drops.size(); ++i) { final ItemStack item = event.drops.get(i).getEntityItem(); if (item != null && item.getItem() == ExtraUtils.goldenBag && ItemGoldenBag.isMagic(item)) { final NBTTagCompound tags = new NBTTagCompound(); item.writeToNBT(tags); t.setTag("item_" + j, (NBTBase)tags); ++j; event.drops.remove(i); --i; } } t.setInteger("no_items", j); NBTTagCompound e; if (event.entityPlayer.getEntityData().hasKey("PlayerPersisted")) { e = event.entityPlayer.getEntityData().getCompoundTag("PlayerPersisted"); } else { e = new NBTTagCompound(); event.entityPlayer.getEntityData().setTag("PlayerPersisted", (NBTBase)e); } e.setTag("XU|GoldenBags", (NBTBase)t); }
@SubscribeEvent public void onPlayerDeath(PlayerDropsEvent e) { EntityPlayer player = e.getEntityPlayer(); int x = (int) player.posX; int y = (int) player.posY; int z = (int) player.posZ; int dim = player.dimension; player.addChatComponentMessage(new TextComponentTranslation("message.littlethings.deathCoords", x, y, z)); player.addChatComponentMessage(ITextComponent.Serializer.jsonToComponent(I18n.translateToLocal("message.littlethings.deathLinks") .replaceAll("%w%", String.valueOf(dim)) .replaceAll("%x%", String.valueOf(x)) .replaceAll("%y%", String.valueOf(y)) .replaceAll("%z%", String.valueOf(z)))); }
public void onDeath(DamageSource p_70645_1_) { if (ForgeHooks.onLivingDeath(this, p_70645_1_)) { return; } super.onDeath(p_70645_1_); setSize(0.2F, 0.2F); setPosition(this.posX, this.posY, this.posZ); this.motionY = 0.1000000014901161D; this.captureDrops = true; this.capturedDrops.clear(); if (getCommandSenderName().equals("Notch")) { func_146097_a(new ItemStack(Items.apple, 1), true, false); } if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) { this.inventory.dropAllItems(); } this.captureDrops = false; if (!this.worldObj.isRemote) { PlayerDropsEvent event = new PlayerDropsEvent(this, p_70645_1_, this.capturedDrops, this.recentlyHit > 0); if (!MinecraftForge.EVENT_BUS.post(event)) { for (EntityItem item : this.capturedDrops) { joinEntityItemWithWorld(item); } } } if (p_70645_1_ != null) { this.motionX = (-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * 3.141593F / 180.0F) * 0.1F); this.motionZ = (-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * 3.141593F / 180.0F) * 0.1F); } else { this.motionX = (this.motionZ = 0.0D); } this.yOffset = 0.1F; addStat(StatList.deathsStat, 1); }
@SubscribeEvent public void itemDrop(PlayerDropsEvent event) { List<EntityItem> items = event.getDrops(); for (EntityItem item : items) { if (item.getEntityItem().getItem() == ModItems.itemDeathList) { item.setDead(); } } }
@SubscribeEvent(priority = EventPriority.LOWEST) public void onPlayerDrops(PlayerDropsEvent event) { EntityPlayer player = event.getEntityPlayer(); if (!player.world.getGameRules().getBoolean("keepInventory")) { IInventory inventory = player.getCapability(AlchemyCapabilityLoader.bauble, null); if (inventory != null) for (int i = 0, len = inventory.getSizeInventory(); i < len; i++) { ItemStack item = inventory.removeStackFromSlot(i); if (!item.isEmpty()) event.getDrops().add(InventoryHelper.getEntityItem(player, item)); } } }
/** Adds yoke and backpack to player death drops. */ @SubscribeEvent public void playerDrops(PlayerDropsEvent event) { EntityPlayer player = event.getEntityPlayer(); ICapPlayer capPlayer = player.getCapability(GeoCaps.CAP_PLAYER, null); World world = player.world; double x = player.posX; double y = player.posY; double z = player.posZ; List<EntityItem> drops = event.getDrops(); drops.add(new EntityItem(world, x, y, z, capPlayer.removeBackpack())); drops.add(new EntityItem(world, x, y, z, capPlayer.removeYoke())); }
@SubscribeEvent public void playerDeath(PlayerDropsEvent event) { if (keepOnDeath == false) { World world = event.getEntityPlayer().getEntityWorld(); if (!world.isRemote && world.getGameRules().getBoolean("keepInventory") == false) { //so config says dont keep it on death. AND the gamerule says dont keep as well UtilPlayerInventoryFilestorage.getPlayerInventory(event.getEntityPlayer()).dropItems(event.getDrops(), event.getEntityPlayer().getPosition()); } } }
/** Make the player drop a skull. */ @SubscribeEvent public void onPlayerDeath(PlayerDropsEvent e) { e.getEntityPlayer().dropItem( Misc.getSkullFromOwner(e.getEntityPlayer().getGameProfile()), true, false); }
@SubscribeEvent public void onPlayerDeath( PlayerDropsEvent event ) { NBTTagList persisted = new NBTTagList(); List< EntityItem > items = event.drops; for ( int i = 0; i < items.size(); ++i ) { EntityItem entity = items.get( i ); ItemStack stack = entity.getEntityItem(); if ( stack == null || !( stack.getItem() instanceof EquipmentItem ) ) { continue; } EquipmentItem itemBase = ( EquipmentItem ) stack.getItem(); int level = itemBase.equipment.getModifierLevel( stack, "persistance" ); if ( ( level & PersistanceModifier.INVENTORY ) != 0 ) { NBTTagCompound item = new NBTTagCompound(); stack.writeToNBT( item ); persisted.appendTag( item ); items.remove( i ); --i; continue; } } if ( persisted.tagCount() > 0 ) { NBTTagCompound tag = event.entityPlayer.getEntityData(); NBTTagCompound persistant = tag.getCompoundTag( EntityPlayer.PERSISTED_NBT_TAG ); persistant.setTag( PERSIST_TAG, persisted ); tag.setTag( EntityPlayer.PERSISTED_NBT_TAG, persistant ); } }
/** * For deaths */ @ForgeSubscribe(priority = EventPriority.HIGHEST) public void deathEvent(PlayerDropsEvent event) { World world = event.entityPlayer.getEntityWorld(); if (world.isRemote) return; event.setCanceled(GraveHandler.onDeath(event.entityPlayer.worldObj, event.entityPlayer, event.drops)); }
@SubscribeEvent public void playerDrops (PlayerDropsEvent evt) { // After playerDeath event. Modifying saved data. NPlayerStats stats = playerStats.get(evt.entityPlayer.getPersistentID()); stats.armor.dropItems(evt.drops); playerStats.put(evt.entityPlayer.getPersistentID(), stats); }
@SubscribeEvent public void onPlayerDeath(PlayerDropsEvent event) { if (event.entity instanceof EntityPlayer && !event.entity.worldObj.isRemote && !event.entity.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory") && CommonProxy.dropOnDeath) { PlayerHandler.getArmor(event.entityPlayer).dropItemsAt(event.drops, event.entityPlayer); } }
private PlayerDropsEvent createPlayerDropEvent(EntityPlayer player, DamageSource damageSource, ArrayList<EntityItem> drops) { int recentlyHit; try { recentlyHit = ObfuscationHelper.getCatchableFieldFromReflection("field_70718_bc", EntityLivingBase.class, player, Integer.class); } catch (NoSuchFieldException e) { recentlyHit = ObfuscationHelper.getFieldFromReflection("recentlyHit", EntityLivingBase.class, player, Integer.class); } return new PlayerDropsEvent(player, damageSource, player.capturedDrops, recentlyHit > 0); }
@SubscribeEvent public void playerDeath(PlayerDropsEvent event) { if (event.entity instanceof EntityPlayer && !event.entity.worldObj.isRemote && !event.entity.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) { PlayerHandler.getPlayerBaubles(event.entityPlayer).dropItems(event.drops); } }
@SubscribeEvent public void PlayerDropsEvent(PlayerDropsEvent event) { if (event.getSource().getSourceOfDamage()!=null) { if (event.getSource().getSourceOfDamage() instanceof EntityPlayer) { //drop essence if (RecallItems.dropEssence) { EntityPlayer deadPlayer = event.getEntityPlayer(); ItemPlayerEssence essence = RecallItems.itemPlayerEssence; ItemStack essenceStack = new ItemStack(essence); essence.setPlayer(essenceStack, deadPlayer); event.getEntity().entityDropItem(essenceStack, 0.5F); } } } }
@SubscribeEvent public void onDrop(PlayerDropsEvent e) { final boolean gr = e.entityPlayer.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory"); if (!e.entityPlayer.worldObj.isRemote && e.entityPlayer.dimension == IaSFlags.dim_nyx_id && !gr) { e.setCanceled(true); NyxDeathSystem.plai_inv = NyxDeathSystem.determineRespawnInventory(NyxDeathSystem.plai_inv, true); e.entityPlayer.inventory.copyInventory(NyxDeathSystem.plai_inv); NyxDeathSystem.death_inv.put(e.entityPlayer.getEntityId(), e.entityPlayer.inventory); } }
@SubscribeEvent public void onPlayerDrops(PlayerDropsEvent event) { if(playersToSave.contains(event.entityPlayer)) { for(EntityItem drop : event.drops) { if(drop.getEntityItem().getItem() == MBItems.reviveHeart) { drop.setDead(); } if(drop.getEntityItem().getItem() == MBItems.dodgeGem) { NBTHelper.writeIntToStack(drop.getEntityItem(), "ShortDespawn", 1); } } playersToSave.remove(event.entityPlayer); } }
@ForgeSubscribe public void onPlayerDrops(PlayerDropsEvent event) { if (event.entity.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) { // If "keepInventory" is turned on, the items will return to you anyway. return; } // Remember all the Dota 2 items the player had in inventory. // In case he logs out while dead, put them back into his inventory for storage. Iterator<EntityItem> iter = event.drops.iterator(); List<ItemStack> list = retainedItems.get(event.entityPlayer); if (list == null) { list = new ArrayList<ItemStack>(); retainedItems.put(event.entityPlayer, list); } while (iter.hasNext()) { EntityItem entityItem = iter.next(); ItemStack stack = entityItem.getEntityItem(); if (stack.getItem() instanceof Dota2Item) { Dota2Item dota2Item = (Dota2Item) stack.getItem(); if (!dota2Item.getDropsOnDeath()) { iter.remove(); list.add(stack.copy()); event.entityPlayer.inventory.addItemStackToInventory(stack); } } } }
@SubscribeEvent public void playerDeath(PlayerDropsEvent event) { if (event.getEntity() instanceof EntityPlayer && !event.getEntity().getEntityWorld().isRemote) { boolean keepInv = event.getEntity().getEntityWorld().getGameRules().getBoolean("keepInventory"); addPlayerHeads(event); if(!keepInv){ ExtendedPlayer exPlayer = ExtendedPlayerProvider.getExtendedPlayer(event.getEntityPlayer()); if(exPlayer !=null){ ExtendedPlayerInventory inv = exPlayer.getInventory(); ItemStack backpack = inv.getStackInSlot(ExtendedPlayerInventory.BACKPACK_SLOT_ID); boolean keepBackpack = false; if(ItemStackTools.isValid(backpack)){ InventoryBackpackUpgrades upgrades = BackpackUtil.getUpgradeInventory(event.getEntityPlayer(), backpack); if(upgrades !=null && upgrades.hasUpgrade(BackpackUpgrade.DEATH)){ if(Config.backpackDeathUpgradeConsume){ int index = upgrades.getUpgradeIndex(BackpackUpgrade.DEATH); if(index > -1){ upgrades.decrStackSize(index, 1); upgrades.markDirty(); upgrades.guiSave(event.getEntityPlayer()); inv.setChanged(ExtendedPlayerInventory.BACKPACK_SLOT_ID, true); keepBackpack = true; } } else keepBackpack = true; } } for (int i = 0; i < inv.getSlots(); ++i) { if (ItemStackTools.isValid(inv.getStackInSlot(i))) { if(i == ExtendedPlayerInventory.BACKPACK_SLOT_ID){ if(keepBackpack){ continue; } } event.getDrops().add(ItemUtil.dropFromPlayer(event.getEntityPlayer(), inv.getStackInSlot(i).copy(), true)); inv.setStackInSlot(i, ItemStackTools.getEmptyStack()); } } } } } }
public PlayerDeathEvent(PlayerDropsEvent playerDropsEvent){ this.playerDropsEvent = playerDropsEvent; setCancelled(playerDropsEvent.isCanceled()); }
@SubscribeEvent public void playerDropEvent(PlayerDropsEvent e){ PlayerDeathEvent playerDeathEvent = new PlayerDeathEvent(e); eventManager.fireEvent(playerDeathEvent); e.setCanceled(playerDeathEvent.getCancelled()); }
public void onDeath(DamageSource p_70645_1_) { if (ForgeHooks.onLivingDeath(this, p_70645_1_)) return; super.onDeath(p_70645_1_); this.setSize(0.2F, 0.2F); this.setPosition(this.posX, this.posY, this.posZ); this.motionY = 0.10000000149011612D; captureDrops = true; capturedDrops.clear(); if (this.getCommandSenderName().equals("Notch")) { this.func_146097_a(new ItemStack(Items.apple, 1), true, false); } if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) { this.inventory.dropAllItems(); } captureDrops = false; if (!worldObj.isRemote) { PlayerDropsEvent event = new PlayerDropsEvent(this, p_70645_1_, capturedDrops, recentlyHit > 0); if (!MinecraftForge.EVENT_BUS.post(event)) { for (EntityItem item : capturedDrops) { joinEntityItemWithWorld(item); } } } if (p_70645_1_ != null) { this.motionX = (double)(-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F); this.motionZ = (double)(-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F); } else { this.motionX = this.motionZ = 0.0D; } this.yOffset = 0.1F; this.addStat(StatList.deathsStat, 1); }
public void onDeath(DamageSource p_70645_1_) { if (ForgeHooks.onLivingDeath(this, p_70645_1_)) return; this.mcServer.getConfigurationManager().sendChatMsg(this.func_110142_aN().func_151521_b()); if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) { captureDrops = true; capturedDrops.clear(); this.inventory.dropAllItems(); captureDrops = false; PlayerDropsEvent event = new PlayerDropsEvent(this, p_70645_1_, capturedDrops, recentlyHit > 0); if (!MinecraftForge.EVENT_BUS.post(event)) { for (EntityItem item : capturedDrops) { joinEntityItemWithWorld(item); } } } Collection collection = this.worldObj.getScoreboard().func_96520_a(IScoreObjectiveCriteria.deathCount); Iterator iterator = collection.iterator(); while (iterator.hasNext()) { ScoreObjective scoreobjective = (ScoreObjective)iterator.next(); Score score = this.getWorldScoreboard().func_96529_a(this.getCommandSenderName(), scoreobjective); score.func_96648_a(); } EntityLivingBase entitylivingbase = this.func_94060_bK(); if (entitylivingbase != null) { int i = EntityList.getEntityID(entitylivingbase); EntityList.EntityEggInfo entityegginfo = (EntityList.EntityEggInfo)EntityList.entityEggs.get(Integer.valueOf(i)); if (entityegginfo != null) { this.addStat(entityegginfo.field_151513_e, 1); } entitylivingbase.addToPlayerScore(this, this.scoreValue); } this.addStat(StatList.deathsStat, 1); this.func_110142_aN().func_94549_h(); }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource par1DamageSource) { if (ForgeHooks.onLivingDeath(this, par1DamageSource)) return; this.mcServer.getConfigurationManager().sendChatMsg(this.func_110142_aN().func_94546_b()); if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) { captureDrops = true; capturedDrops.clear(); this.inventory.dropAllItems(); captureDrops = false; PlayerDropsEvent event = new PlayerDropsEvent(this, par1DamageSource, capturedDrops, recentlyHit > 0); if (!MinecraftForge.EVENT_BUS.post(event)) { for (EntityItem item : capturedDrops) { joinEntityItemWithWorld(item); } } } Collection collection = this.worldObj.getScoreboard().func_96520_a(ScoreObjectiveCriteria.deathCount); Iterator iterator = collection.iterator(); while (iterator.hasNext()) { ScoreObjective scoreobjective = (ScoreObjective)iterator.next(); Score score = this.getWorldScoreboard().func_96529_a(this.getEntityName(), scoreobjective); score.func_96648_a(); } EntityLivingBase entitylivingbase = this.func_94060_bK(); if (entitylivingbase != null) { entitylivingbase.addToPlayerScore(this, this.scoreValue); } this.addStat(StatList.deathsStat, 1); }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource par1DamageSource) { if (ForgeHooks.onLivingDeath(this, par1DamageSource)) return; super.onDeath(par1DamageSource); this.setSize(0.2F, 0.2F); this.setPosition(this.posX, this.posY, this.posZ); this.motionY = 0.10000000149011612D; captureDrops = true; capturedDrops.clear(); if (this.username.equals("Notch")) { this.dropPlayerItemWithRandomChoice(new ItemStack(Item.appleRed, 1), true); } if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) { this.inventory.dropAllItems(); } captureDrops = false; if (!worldObj.isRemote) { PlayerDropsEvent event = new PlayerDropsEvent(this, par1DamageSource, capturedDrops, recentlyHit > 0); if (!MinecraftForge.EVENT_BUS.post(event)) { for (EntityItem item : capturedDrops) { joinEntityItemWithWorld(item); } } } if (par1DamageSource != null) { this.motionX = (double)(-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F); this.motionZ = (double)(-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F); } else { this.motionX = this.motionZ = 0.0D; } this.yOffset = 0.1F; this.addStat(StatList.deathsStat, 1); }