@Inject(method = "handleCombatEvent", at= @At(value = "INVOKE_ASSIGN", target = "net/minecraft/network/PacketThreadUtil.checkThreadAndEnqueue(Lnet/minecraft/network/Packet;Lnet/minecraft/network/INetHandler;Lnet/minecraft/util/IThreadListener;)V")) private void handleCombatEvent(SPacketCombatEvent event, CallbackInfo ci) { if (mc.world == null) return; if (event.eventType == SPacketCombatEvent.Event.ENTITY_DIED) { Entity died = mc.world.getEntityByID(event.playerId); Entity killer = mc.world.getEntityByID(event.entityId); // The entity that died should always be a player, this is just a safety measure. // The killer isn't checked because in some cases it can be null. if (died instanceof EntityPlayer) ClientAPI.EVENT_BUS.post(new PlayerDeathEvent((EntityPlayer) died, (EntityLivingBase) killer)); } }
@Override public void onDeath(DamageSource cause) { if (cause == DamageSource.OUT_OF_WORLD) { connection.sendPacket(new SPacketCombatEvent(getCombatTracker(), SPacketCombatEvent.Event.ENTITY_DIED, false)); EntityLivingBase entitylivingbase = getAttackingEntity(); if (entitylivingbase != null) { entitylivingbase.onItemPickup(this, scoreValue); } extinguish(); setFlag(0, false); getCombatTracker().reset(); } }
public void handleCombatEvent(SPacketCombatEvent packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); if (packetIn.eventType == SPacketCombatEvent.Event.ENTITY_DIED) { Entity entity = this.clientWorldController.getEntityByID(packetIn.playerId); if (entity == this.gameController.player) { this.gameController.displayGuiScreen(new GuiGameOver(packetIn.deathMessage)); } } }
public void handleCombatEvent(SPacketCombatEvent packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); if (packetIn.eventType == SPacketCombatEvent.Event.ENTITY_DIED) { Entity entity = this.clientWorldController.getEntityByID(packetIn.playerId); if (entity == this.gameController.thePlayer) { this.gameController.displayGuiScreen(new GuiGameOver(packetIn.deathMessage)); } } }
@HarshenEvent public void onEntityDeath(LivingDeathEvent event) { event.setCanceled(true); World world = event.getEntityLiving().world; if(!world.isRemote) { boolean flag = world.getGameRules().getBoolean("showDeathMessages"); EntityPlayerMP player = (EntityPlayerMP) event.getEntity(); player.connection.sendPacket(new SPacketCombatEvent(player.getCombatTracker(), SPacketCombatEvent.Event.ENTITY_DIED, flag)); if (flag) { Team team = player.getTeam(); if (team != null && team.getDeathMessageVisibility() != Team.EnumVisible.ALWAYS) if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OTHER_TEAMS) player.mcServer.getPlayerList().sendMessageToAllTeamMembers(player, player.getCombatTracker().getDeathMessage()); else if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OWN_TEAM) player.mcServer.getPlayerList().sendMessageToTeamOrAllPlayers(player, player.getCombatTracker().getDeathMessage()); else player.mcServer.getPlayerList().sendMessage(player.getCombatTracker().getDeathMessage()); } for (ScoreObjective scoreobjective : world.getScoreboard().getObjectivesFromCriteria(IScoreCriteria.DEATH_COUNT)) player.getWorldScoreboard().getOrCreateScore(player.getName(), scoreobjective).incrementScore(); EntityLivingBase entitylivingbase = player.getAttackingEntity(); if (entitylivingbase != null) { EntityList.EntityEggInfo entitylist$entityegginfo = EntityList.ENTITY_EGGS.get(EntityList.getKey(entitylivingbase)); if (entitylist$entityegginfo != null) player.addStat(entitylist$entityegginfo.entityKilledByStat); } player.addStat(StatList.DEATHS); player.takeStat(StatList.TIME_SINCE_DEATH); player.extinguish(); HarshenUtils.setFlag(player, 0, false); player.getCombatTracker().reset(); INVENTORY_MAP.put(event.getEntity().getUniqueID(), ((EntityPlayer)event.getEntity()).inventory.writeToNBT(new NBTTagList())); HarshenUtils.damageOccuringItemNoPacket(player, HarshenItems.SOUL_BINDING_PENDANT, 1); if(HarshenUtils.getFirstOccuringItem(player, HarshenItems.SOUL_BINDING_PENDANT).getItemDamage() == HarshenUtils.getFirstOccuringItem(player, HarshenItems.SOUL_BINDING_PENDANT).getMaxDamage()) HarshenUtils.damageOccuringItemNoPacket(player, HarshenItems.SOUL_BINDING_PENDANT, 1); } new HandlerHarshenInventory().onPlayerDeath(event); }
/** * Sends an ENTER_COMBAT packet to the client */ public void sendEnterCombat() { super.sendEnterCombat(); this.connection.sendPacket(new SPacketCombatEvent(this.getCombatTracker(), SPacketCombatEvent.Event.ENTER_COMBAT)); }
/** * Sends an END_COMBAT packet to the client */ public void sendEndCombat() { super.sendEndCombat(); this.connection.sendPacket(new SPacketCombatEvent(this.getCombatTracker(), SPacketCombatEvent.Event.END_COMBAT)); }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { //-ZMod-Death--------------------------------------------------------- ZHandle.handle("onPlayerDeath", this); //-------------------------------------------------------------------- boolean flag = this.world.getGameRules().getBoolean("showDeathMessages"); this.connection.sendPacket(new SPacketCombatEvent(this.getCombatTracker(), SPacketCombatEvent.Event.ENTITY_DIED, flag)); if (flag) { Team team = this.getTeam(); if (team != null && team.getDeathMessageVisibility() != Team.EnumVisible.ALWAYS) { if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OTHER_TEAMS) { this.mcServer.getPlayerList().sendMessageToAllTeamMembers(this, this.getCombatTracker().getDeathMessage()); } else if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OWN_TEAM) { this.mcServer.getPlayerList().sendMessageToTeamOrAllPlayers(this, this.getCombatTracker().getDeathMessage()); } } else { this.mcServer.getPlayerList().sendChatMsg(this.getCombatTracker().getDeathMessage()); } } if (!this.world.getGameRules().getBoolean("keepInventory") && !this.isSpectator()) { this.func_190776_cN(); this.inventory.dropAllItems(); } for (ScoreObjective scoreobjective : this.world.getScoreboard().getObjectivesFromCriteria(IScoreCriteria.DEATH_COUNT)) { Score score = this.getWorldScoreboard().getOrCreateScore(this.getName(), scoreobjective); score.incrementScore(); } EntityLivingBase entitylivingbase = this.getAttackingEntity(); if (entitylivingbase != null) { EntityList.EntityEggInfo entitylist$entityegginfo = (EntityList.EntityEggInfo)EntityList.ENTITY_EGGS.get(EntityList.func_191301_a(entitylivingbase)); if (entitylist$entityegginfo != null) { this.addStat(entitylist$entityegginfo.entityKilledByStat); } entitylivingbase.addToPlayerScore(this, this.scoreValue); } this.addStat(StatList.DEATHS); this.takeStat(StatList.TIME_SINCE_DEATH); this.extinguish(); this.setFlag(0, false); this.getCombatTracker().reset(); }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { boolean flag = this.world.getGameRules().getBoolean("showDeathMessages"); this.connection.sendPacket(new SPacketCombatEvent(this.getCombatTracker(), SPacketCombatEvent.Event.ENTITY_DIED, flag)); if (flag) { Team team = this.getTeam(); if (team != null && team.getDeathMessageVisibility() != Team.EnumVisible.ALWAYS) { if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OTHER_TEAMS) { this.mcServer.getPlayerList().sendMessageToAllTeamMembers(this, this.getCombatTracker().getDeathMessage()); } else if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OWN_TEAM) { this.mcServer.getPlayerList().sendMessageToTeamOrAllPlayers(this, this.getCombatTracker().getDeathMessage()); } } else { this.mcServer.getPlayerList().sendChatMsg(this.getCombatTracker().getDeathMessage()); } } if (!this.world.getGameRules().getBoolean("keepInventory") && !this.isSpectator()) { this.func_190776_cN(); this.inventory.dropAllItems(); } for (ScoreObjective scoreobjective : this.world.getScoreboard().getObjectivesFromCriteria(IScoreCriteria.DEATH_COUNT)) { Score score = this.getWorldScoreboard().getOrCreateScore(this.getName(), scoreobjective); score.incrementScore(); } EntityLivingBase entitylivingbase = this.getAttackingEntity(); if (entitylivingbase != null) { EntityList.EntityEggInfo entitylist$entityegginfo = (EntityList.EntityEggInfo)EntityList.ENTITY_EGGS.get(EntityList.func_191301_a(entitylivingbase)); if (entitylist$entityegginfo != null) { this.addStat(entitylist$entityegginfo.entityKilledByStat); } entitylivingbase.addToPlayerScore(this, this.scoreValue); } this.addStat(StatList.DEATHS); this.takeStat(StatList.TIME_SINCE_DEATH); this.extinguish(); this.setFlag(0, false); this.getCombatTracker().reset(); }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, cause)) return; boolean flag = this.worldObj.getGameRules().getBoolean("showDeathMessages"); this.connection.sendPacket(new SPacketCombatEvent(this.getCombatTracker(), SPacketCombatEvent.Event.ENTITY_DIED, flag)); if (flag) { Team team = this.getTeam(); if (team != null && team.getDeathMessageVisibility() != Team.EnumVisible.ALWAYS) { if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OTHER_TEAMS) { this.mcServer.getPlayerList().sendMessageToAllTeamMembers(this, this.getCombatTracker().getDeathMessage()); } else if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OWN_TEAM) { this.mcServer.getPlayerList().sendMessageToTeamOrAllPlayers(this, this.getCombatTracker().getDeathMessage()); } } else { this.mcServer.getPlayerList().sendChatMsg(this.getCombatTracker().getDeathMessage()); } } if (!this.worldObj.getGameRules().getBoolean("keepInventory") && !this.isSpectator()) { captureDrops = true; capturedDrops.clear(); this.inventory.dropAllItems(); captureDrops = false; net.minecraftforge.event.entity.player.PlayerDropsEvent event = new net.minecraftforge.event.entity.player.PlayerDropsEvent(this, cause, capturedDrops, recentlyHit > 0); if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) { for (net.minecraft.entity.item.EntityItem item : capturedDrops) { this.worldObj.spawnEntityInWorld(item); } } } for (ScoreObjective scoreobjective : this.worldObj.getScoreboard().getObjectivesFromCriteria(IScoreCriteria.DEATH_COUNT)) { Score score = this.getWorldScoreboard().getOrCreateScore(this.getName(), scoreobjective); score.incrementScore(); } EntityLivingBase entitylivingbase = this.getAttackingEntity(); if (entitylivingbase != null) { EntityList.EntityEggInfo entitylist$entityegginfo = (EntityList.EntityEggInfo)EntityList.ENTITY_EGGS.get(EntityList.getEntityString(entitylivingbase)); if (entitylist$entityegginfo != null) { this.addStat(entitylist$entityegginfo.entityKilledByStat); } entitylivingbase.addToPlayerScore(this, this.scoreValue); } this.addStat(StatList.DEATHS); this.takeStat(StatList.TIME_SINCE_DEATH); this.getCombatTracker().reset(); }
void handleCombatEvent(SPacketCombatEvent packetIn);