@SubscribeEvent public static void onDeath(LivingDeathEvent evt) { if(!evt.getEntityLiving().world.isRemote && evt.getEntityLiving() instanceof EntityPlayer && !evt.getEntityLiving().world.getGameRules().getBoolean("keepInventory") && !((EntityPlayer) evt.getEntityLiving()).isSpectator()) { IItemHandler inv = BaublesApi.getBaublesHandler((EntityPlayer) evt.getEntityLiving()); for(int i = 0; i < inv.getSlots(); i++) { ItemStack stack = inv.getStackInSlot(i); if (!stack.isEmpty() && stack.getItem().getRegistryName().getNamespace().equals(LibMisc.MOD_ID)) { ((ItemBauble) stack.getItem()).onUnequipped(stack, evt.getEntityLiving()); } } } }
@SubscribeEvent public void onEntityKill(LivingDeathEvent event) { Entity killer = event.getSource().getTrueSource(); if(killer != null && killer instanceof EntityLivingBase) { EntityLivingBase living = (EntityLivingBase) killer; if(hasEffect(living)) living.heal(event.getEntityLiving().getMaxHealth() / 20); } }
@SubscribeEvent public void onCyl18Down(LivingDeathEvent event) { if (event.getEntityLiving() instanceof EntityPlayer) { if (event.getEntityLiving().getName().equals("Cyl18")) ((EntityPlayer) event.getEntityLiving()).dropItem(new ItemStack(FCRFoods.CY), true, true); } } }
public static EntityPlayer getKiller(LivingDeathEvent event) { if (event.getEntityLiving() != null && !event.getEntityLiving().getEntityWorld().isRemote && event.getSource() != null) { if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityPlayer) { return (EntityPlayer) event.getSource().getTrueSource(); } else if (event.getEntityLiving().getCommandSenderEntity() instanceof EntityPlayer) { return (EntityPlayer) event.getEntityLiving().getCommandSenderEntity(); } } return null; }
@SubscribeEvent @SuppressWarnings("ConstantConditions") public void onEntityDeath(LivingDeathEvent event) { AnimalStats stats = EntityHelper.getStats(event.getEntityLiving()); if (stats != null && !event.getEntity().world.isRemote) { HFTrackers.<AnimalTrackerServer>getAnimalTracker(event.getEntityLiving().world).onDeath(stats); } }
@SubscribeEvent public void onPlayerDeath(LivingDeathEvent event) { if (event.getEntityLiving() instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP) event.getEntityLiving(); QuestingData.getQuestingData(player).die(player); DeathType.onDeath(player, event.getSource()); } }
private void palingDeath(LivingDeathEvent event) { if(event.getSource() == ExtendedDamageSource.paling && Configs.isEnabled(SpiritPortalConfig.class)) { SpiritPortal.tryPlacePortal(event.getEntityLiving().world, event.getEntityLiving().getPosition().add(0, 1, 0)); } }
@SubscribeEvent public static void onEntityAttacked(LivingDeathEvent event) { if (event.getSource() instanceof EntityDamageSourceIndirect) { Entity sourceEntity = event.getSource().getImmediateSource(); if (sourceEntity instanceof EntitySentientArrow) { ((EntitySentientArrow) sourceEntity).reimbursePlayer(event.getEntityLiving(), event.getEntityLiving().getMaxHealth()); } } }
private void dropHumanoidFleshEvent(LivingDeathEvent event) { if(event.getEntityLiving() instanceof EntityPlayerMP && Configs.isEnabled(WerewolfFleshConfig.class) && !event.getEntityLiving().world.isRemote && event.getEntityLiving().world.rand.nextInt(WerewolfFleshConfig.humanoidFleshDropChance) == 0) { EntityPlayerMP player = (EntityPlayerMP) event.getEntityLiving(); ItemStack itemStack = new ItemStack(WerewolfFlesh.getInstance(), 1, 1); NBTTagCompound tag = itemStack.getTagCompound(); if(tag == null) { tag = new NBTTagCompound(); itemStack.setTagCompound(tag); } NBTUtil.writeGameProfile(tag, player.getGameProfile()); double x = player.posX; double y = player.posY; double z = player.posZ; EntityItem entity = new EntityItem(player.world, x, y, z, itemStack); player.world.spawnEntity(entity); } }
private void vengeanceEvent(LivingDeathEvent event) { if (event.getEntityLiving() != null) { World world = event.getEntityLiving().world; boolean directToPlayer = shouldDirectSpiritToPlayer(event); if (!world.isRemote && world.getDifficulty() != EnumDifficulty.PEACEFUL && Configs.isEnabled(VengeanceSpiritConfig.class) && VengeanceSpirit.canSustain(event.getEntityLiving()) && (directToPlayer || VengeanceSpirit.canSpawnNew(world, event.getEntityLiving().getPosition()))) { VengeanceSpirit spirit = new VengeanceSpirit(world); spirit.setInnerEntity(event.getEntityLiving()); spirit.copyLocationAndAnglesFrom(event.getEntityLiving()); world.spawnEntity(spirit); if(directToPlayer) { EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource(); spirit.setBuildupDuration(3 * MinecraftHelpers.SECOND_IN_TICKS); spirit.setGlobalVengeance(true); spirit.setAttackTarget(player); } } } }
@SubscribeEvent public void onKillChicken(LivingDeathEvent event) { if (Debug.CHICKEN_FISHING > 0) { EntityPlayer angler = event.getSource().getEntity() instanceof EntityPlayer ? (EntityPlayer) event.getSource().getEntity() : null; if (angler != null && !angler.worldObj.isRemote && event.getEntityLiving() instanceof EntityChicken) { for (int i = 0; i < Debug.CHICKEN_FISHING; i++) { LootContext.Builder lootcontext$builder = new LootContext.Builder((WorldServer) angler.worldObj); lootcontext$builder.withLuck((float) EnchantmentHelper.getLuckOfSeaModifier(angler) + angler.getLuck()); lootcontext$builder.withPlayer(angler); //Added by Mariculture lootcontext$builder.withLootedEntity(event.getEntityLiving()); //Added by Mariculture for (ItemStack itemstack : angler.worldObj.getLootTableManager().getLootTableFromLocation(LootTableList.GAMEPLAY_FISHING).generateLootForPools(this.rand, lootcontext$builder.build())) { EntityItem entityitem = new EntityItem(angler.worldObj, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, itemstack); double d0 = angler.posX - event.getEntityLiving().posX; double d1 = angler.posY - event.getEntityLiving().posY; double d2 = angler.posZ - event.getEntityLiving().posZ; double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d1 * d1 + d2 * d2); double d4 = 0.1D; entityitem.motionX = d0 * d4; entityitem.motionY = d1 * d4 + (double) MathHelper.sqrt_double(d3) * 0.08D; entityitem.motionZ = d2 * d4; angler.worldObj.spawnEntityInWorld(entityitem); angler.worldObj.spawnEntityInWorld(new EntityXPOrb(angler.worldObj, angler.posX, angler.posY + 0.5D, angler.posZ + 0.5D, this.rand.nextInt(6) + 1)); } } } } } }
@Override public void onLivingDeath(LivingDeathEvent event) { EntityPlayer killer = QuestTaskMob.getKiller(event); if (killer != null && parent.isEnabled(killer) && parent.isAvailable(killer) && this.isVisible(killer) && !this.isCompleted(killer) && !killer.equals(event.getEntityLiving())) { if (event.getEntityLiving() instanceof EntityPlayer && isPlayerInRange((EntityPlayer) event.getEntityLiving())) { QuestDataTaskReputationKill killData = (QuestDataTaskReputationKill) getData(killer); if (killData.kills < kills) { killData.kills += 1; if (killData.kills == kills) { completeTask(killer.getUniqueID()); } parent.sendUpdatedDataToTeam(killer); } } } }
@Override public void onLivingDeath(LivingDeathEvent event) { if (event.getEntityLiving() instanceof EntityPlayerMP) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); if (parent.isEnabled(player) && parent.isAvailable(player) && this.isVisible(player) && !isCompleted(player)) { QuestDataTaskDeath deathData = (QuestDataTaskDeath) getData(player); if (deathData.deaths < deaths) { deathData.deaths += 1; if (deathData.deaths == deaths) { completeTask(player.getUniqueID()); } parent.sendUpdatedDataToTeam(player); } } } }
@SubscribeEvent public void onLivingDeath(LivingDeathEvent event) { if(event.getEntityLiving().world.isRemote || !QuestSettings.INSTANCE.getProperty(NativeProps.HARDCORE)) { return; } if(event.getEntityLiving() instanceof EntityPlayer) { UUID uuid = QuestingAPI.getQuestingUUID(((EntityPlayer)event.getEntityLiving())); IParty party = PartyManager.INSTANCE.getUserParty(uuid); if(party == null || !party.getProperties().getProperty(NativeProps.PARTY_LIVES)) { int lives = LifeDatabase.INSTANCE.getLives(uuid); LifeDatabase.INSTANCE.setLives(uuid, lives - 1); } else { int lives = LifeDatabase.INSTANCE.getLives(party); LifeDatabase.INSTANCE.setLives(party, lives - 1); } } }
@SubscribeEvent public void onDeath(LivingDeathEvent event) { EntityPlayer player = getPlayerFromSource(event.getSource()); if (player != null) { if (counter < targetAmount && isValidKill(event.getEntityLiving())) { counter++; //Increase the counter syncData(player); } } }
@SubscribeEvent public void handleLivingDeathEvent(LivingDeathEvent event) { Entity entity = event.getEntity(); Entity attacker = event.getSource().getTrueSource(); if (attacker instanceof EntityPlayer) { int encLeech = getHeldEnchantmentLevel((EntityPlayer) attacker, CoreEnchantments.leech); int encInsight = getHeldEnchantmentLevel((EntityPlayer) attacker, CoreEnchantments.insight); if (encLeech > 0) { ((EntityPlayer) attacker).heal(encLeech); } if (encInsight > 0) { entity.world.spawnEntity(new EntityXPOrb(entity.world, entity.posX, entity.posY + 0.5D, entity.posZ, encInsight + entity.world.rand.nextInt(1 + encInsight * 3))); } } if (!CoreProps.enableLivingEntityDeathMessages || entity.world.isRemote || !(entity instanceof EntityLiving) || !event.getEntityLiving().hasCustomName()) { return; } PlayerList playerList = entity.world.getMinecraftServer().getPlayerList(); ITextComponent deathMessage = event.getEntityLiving().getCombatTracker().getDeathMessage(); if (playerList == null) { CoFHCore.LOG.error("Null Player List! That's not good.", event); } if (deathMessage == null) { CoFHCore.LOG.error("Null Death Message! Please report to the mod responsible.", event.getSource().getClass()); } entity.world.getMinecraftServer().getPlayerList().sendMessage(event.getEntityLiving().getCombatTracker().getDeathMessage()); }
@SubscribeEvent(priority = EventPriority.HIGHEST) public static void onEntityDeath(LivingDeathEvent event) { if (event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); if (LivingArmour.hasFullSet(player)) { ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); if (armour != null) { StatTrackerGrimReaperSprint.incrementCounter(armour); LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.grimReaper", chestStack); if (upgrade instanceof LivingArmourUpgradeGrimReaperSprint && ((LivingArmourUpgradeGrimReaperSprint) upgrade).canSavePlayer(player)) { ((LivingArmourUpgradeGrimReaperSprint) upgrade).applyEffectOnRebirth(player); event.setCanceled(true); event.setResult(Event.Result.DENY); } armour.writeDirtyToNBT(ItemLivingArmour.getArmourTag(chestStack)); } } } }
private void bloodObtainEvent(LivingDeathEvent event) { Entity e = event.getSource().getTrueSource(); if(e != null && e instanceof EntityPlayerMP && !e.world.isRemote && event.getEntityLiving() != null && Configs.isEnabled(BloodExtractorConfig.class)) { float boost = 1.0F; EntityPlayerMP player = (EntityPlayerMP) e; EnumHand hand = player.getActiveHand(); if(Configs.isEnabled(VeinSwordConfig.class) && player.getHeldItem(hand) != null && player.getHeldItem(hand).getItem() == VeinSword.getInstance()) { boost = (float) VeinSwordConfig.extractionBoost; } float health = event.getEntityLiving().getMaxHealth(); int minimumMB = MathHelper.floor(health * (float) BloodExtractorConfig.minimumMobMultiplier * boost); int maximumMB = MathHelper.floor(health * (float) BloodExtractorConfig.maximumMobMultiplier * boost); BloodExtractor.getInstance().fillForAllBloodExtractors(player, minimumMB, maximumMB); } }
@SubscribeEvent public static void handleEntityKill(LivingDeathEvent event) { EntityLivingBase entity = event.getEntityLiving(); Entity killer = event.getSource().getTrueSource(); if (!entity.world.isRemote && killer != null) { if (killer instanceof EntityPlayer) { scheduleXP(entity, getXPBoost(entity, (EntityPlayer) killer)); } else if (killer instanceof EntityArrow) { 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)); } } } }
(int) (BloodStainedBlockConfig.bloodMBPerHP * event.getEntityLiving().getMaxHealth())); }))); } else { ParticleBloodSplash.spawnParticles(event.getEntity().world, pos.add(0, 1, 0), ((int) event.getEntityLiving().getMaxHealth()) + random.nextInt(15), 5 + random.nextInt(5));