public void handleUpdateHealth(S06PacketUpdateHealth packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); this.gameController.thePlayer.setPlayerSPHealth(packetIn.getHealth()); this.gameController.thePlayer.getFoodStats().setFoodLevel(packetIn.getFoodLevel()); this.gameController.thePlayer.getFoodStats().setFoodSaturationLevel(packetIn.getSaturationLevel()); }
private void func_150036_b(World p_150036_1_, int p_150036_2_, int p_150036_3_, int p_150036_4_, EntityPlayer p_150036_5_) { if (p_150036_5_.canEat(false)) { // CraftBukkit start int oldFoodLevel = p_150036_5_.getFoodStats().foodLevel; org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(p_150036_5_, 2 + oldFoodLevel); if (!event.isCancelled()) { p_150036_5_.getFoodStats().addStats(event.getFoodLevel() - oldFoodLevel, 0.1F); } ((EntityPlayerMP) p_150036_5_).playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(((EntityPlayerMP) p_150036_5_).getBukkitEntity().getScaledHealth(), p_150036_5_.getFoodStats().foodLevel, p_150036_5_.getFoodStats().foodSaturationLevel)); // CraftBukkit end int l = p_150036_1_.getBlockMetadata(p_150036_2_, p_150036_3_, p_150036_4_) + 1; if (l >= 6) { p_150036_1_.setBlockToAir(p_150036_2_, p_150036_3_, p_150036_4_); } else { p_150036_1_.setBlockMetadataWithNotify(p_150036_2_, p_150036_3_, p_150036_4_, l, 2); } } }
public void func_151686_a(ItemFood p_151686_1_, ItemStack p_151686_2_) { // CraftBukkit start int oldFoodLevel = foodLevel; org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityplayer, p_151686_1_.func_150905_g(p_151686_2_) + oldFoodLevel); if (!event.isCancelled()) { this.addStats(event.getFoodLevel() - oldFoodLevel, p_151686_1_.func_150906_h(p_151686_2_)); } ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(((EntityPlayerMP) entityplayer).getBukkitEntity().getScaledHealth(), entityplayer.getFoodStats().foodLevel, entityplayer.getFoodStats().foodSaturationLevel)); // CraftBukkit end }
@Override public void handleServerSide(EntityPlayerMP player) { Entity e = player.worldObj.getEntityByID(entityID); if (e != null) { try { GameType preGameType = player.theItemInWorldManager.getGameType(); e.readFromNBT(tag); NBTEdit.log(Level.FINE, player.getCommandSenderName() + " edited a tag -- Entity ID #" + entityID); NBTEdit.logTag(tag); if (e == player) { //Update player info player.sendContainerToPlayer(player.inventoryContainer); GameType type = player.theItemInWorldManager.getGameType(); if (preGameType != type) player.setGameType(type); player.playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel())); player.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel)); player.sendPlayerAbilities(); } sendMessageToPlayer(player, "Your changes have been saved"); } catch(Throwable t) { sendMessageToPlayer(player, SECTION_SIGN + "cSave Failed - Invalid NBT format for Entity"); NBTEdit.log(Level.WARNING, player.getCommandSenderName() + " edited a tag and caused an exception"); NBTEdit.logTag(tag); NBTEdit.throwing("EntityNBTPacket", "handleServerSide", t); } } }
public void onUpdateEntity() { try { super.onUpdate(); for (int i = 0; i < this.inventory.getSizeInventory(); ++i) { ItemStack itemstack = this.inventory.getStackInSlot(i); if (itemstack != null && itemstack.getItem().isMap()) { Packet packet = ((ItemMapBase)itemstack.getItem()).createMapDataPacket(itemstack, this.worldObj, this); if (packet != null) { this.playerNetServerHandler.sendPacket(packet); } } } if (this.getHealth() != this.lastHealth || this.lastFoodLevel != this.foodStats.getFoodLevel() || this.foodStats.getSaturationLevel() == 0.0F != this.wasHungry) { this.playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(this.getHealth(), this.foodStats.getFoodLevel(), this.foodStats.getSaturationLevel())); this.lastHealth = this.getHealth(); this.lastFoodLevel = this.foodStats.getFoodLevel(); this.wasHungry = this.foodStats.getSaturationLevel() == 0.0F; } if (this.getHealth() + this.getAbsorptionAmount() != this.combinedHealth) { this.combinedHealth = this.getHealth() + this.getAbsorptionAmount(); for (ScoreObjective scoreobjective : this.getWorldScoreboard().getObjectivesFromCriteria(IScoreObjectiveCriteria.health)) { this.getWorldScoreboard().getValueFromObjective(this.getName(), scoreobjective).func_96651_a(Arrays.<EntityPlayer>asList(new EntityPlayer[] {this})); } } if (this.experienceTotal != this.lastExperience) { this.lastExperience = this.experienceTotal; this.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(this.experience, this.experienceTotal, this.experienceLevel)); } if (this.ticksExisted % 20 * 5 == 0 && !this.getStatFile().hasAchievementUnlocked(AchievementList.exploreAllBiomes)) { this.updateBiomesExplored(); } } catch (Throwable throwable) { CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Ticking player"); CrashReportCategory crashreportcategory = crashreport.makeCategory("Player being ticked"); this.addEntityCrashInfo(crashreportcategory); throw new ReportedException(crashreport); } }
@Override public Packet updateHealth(float health, int foodLevel, float saturation) { return new NeptunePacket(new S06PacketUpdateHealth(health, foodLevel, saturation)); }
public void onUpdateEntity() { try { super.onUpdate(); for (int var1 = 0; var1 < this.inventory.getSizeInventory(); ++var1) { ItemStack var6 = this.inventory.getStackInSlot(var1); if (var6 != null && var6.getItem().isMap()) { Packet var8 = ((ItemMapBase)var6.getItem()).func_150911_c(var6, this.worldObj, this); if (var8 != null) { this.playerNetServerHandler.sendPacket(var8); } } } if (this.getHealth() != this.lastHealth || this.lastFoodLevel != this.foodStats.getFoodLevel() || this.foodStats.getSaturationLevel() == 0.0F != this.wasHungry) { this.playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(this.getHealth(), this.foodStats.getFoodLevel(), this.foodStats.getSaturationLevel())); this.lastHealth = this.getHealth(); this.lastFoodLevel = this.foodStats.getFoodLevel(); this.wasHungry = this.foodStats.getSaturationLevel() == 0.0F; } if (this.getHealth() + this.getAbsorptionAmount() != this.field_130068_bO) { this.field_130068_bO = this.getHealth() + this.getAbsorptionAmount(); Collection var5 = this.getWorldScoreboard().func_96520_a(IScoreObjectiveCriteria.health); Iterator var7 = var5.iterator(); while (var7.hasNext()) { ScoreObjective var9 = (ScoreObjective)var7.next(); this.getWorldScoreboard().func_96529_a(this.getCommandSenderName(), var9).func_96651_a(Arrays.asList(new EntityPlayer[] {this})); } } if (this.experienceTotal != this.lastExperience) { this.lastExperience = this.experienceTotal; this.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(this.experience, this.experienceTotal, this.experienceLevel)); } if (this.ticksExisted % 20 * 5 == 0 && !this.func_147099_x().hasAchievementUnlocked(AchievementList.field_150961_L)) { this.func_147098_j(); } } catch (Throwable var4) { CrashReport var2 = CrashReport.makeCrashReport(var4, "Ticking player"); CrashReportCategory var3 = var2.makeCategory("Player being ticked"); this.addEntityCrashInfo(var3); throw new ReportedException(var2); } }
public void handleUpdateHealth(S06PacketUpdateHealth p_147249_1_) { this.gameController.thePlayer.setPlayerSPHealth(p_147249_1_.func_149332_c()); this.gameController.thePlayer.getFoodStats().setFoodLevel(p_147249_1_.func_149330_d()); this.gameController.thePlayer.getFoodStats().setFoodSaturationLevel(p_147249_1_.func_149331_e()); }
@Override public Packet updateHealth(float health, int foodLevel, float saturation) { return (Packet) new S06PacketUpdateHealth(health, foodLevel, saturation); }
public void onUpdateEntity() { try { super.onUpdate(); for (int i = 0; i < this.inventory.getSizeInventory(); ++i) { ItemStack itemstack = this.inventory.getStackInSlot(i); if (itemstack != null && itemstack.getItem().isMap()) { Packet packet = ((ItemMapBase)itemstack.getItem()).func_150911_c(itemstack, this.worldObj, this); if (packet != null) { this.playerNetServerHandler.sendPacket(packet); } } } // CraftBukkit - Optionally scale health if (this.getHealth() != this.lastHealth || this.lastFoodLevel != this.foodStats.getFoodLevel() || this.foodStats.getSaturationLevel() == 0.0F != this.wasHungry) { this.playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodStats.getFoodLevel(), this.foodStats.getSaturationLevel())); this.lastHealth = this.getHealth(); this.lastFoodLevel = this.foodStats.getFoodLevel(); this.wasHungry = this.foodStats.getSaturationLevel() == 0.0F; } if (this.getHealth() + this.getAbsorptionAmount() != this.field_130068_bO) { this.field_130068_bO = this.getHealth() + this.getAbsorptionAmount(); // CraftBukkit - Update ALL the scores! this.worldObj.getServer().getScoreboardManager().updateAllScoresForList(IScoreObjectiveCriteria.health, this.getCommandSenderName(), com.google.common.collect.ImmutableList.of(this)); } // CraftBukkit start - Force max health updates if (this.maxHealthCache != this.getMaxHealth()) { this.getBukkitEntity().updateScaledHealth(); } // CraftBukkit end if (this.experienceTotal != this.lastExperience) { this.lastExperience = this.experienceTotal; this.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(this.experience, this.experienceTotal, this.experienceLevel)); } if (this.ticksExisted % 20 * 5 == 0 && !this.func_147099_x().hasAchievementUnlocked(AchievementList.field_150961_L)) { this.func_147098_j(); } // CraftBukkit start if (this.oldLevel == -1) { this.oldLevel = this.experienceLevel; } if (this.oldLevel != this.experienceLevel) { CraftEventFactory.callPlayerLevelChangeEvent(this.worldObj.getServer().getPlayer((EntityPlayerMP) this), this.oldLevel, this.experienceLevel); this.oldLevel = this.experienceLevel; } // CraftBukkit end } catch (Throwable throwable) { CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Ticking player"); CrashReportCategory crashreportcategory = crashreport.makeCategory("Player being ticked"); this.addEntityCrashInfo(crashreportcategory); throw new ReportedException(crashreport); } }
public void onUpdate(EntityPlayer p_75118_1_) { EnumDifficulty enumdifficulty = p_75118_1_.worldObj.difficultySetting; this.prevFoodLevel = this.foodLevel; if (this.foodExhaustionLevel > 4.0F) { this.foodExhaustionLevel -= 4.0F; if (this.foodSaturationLevel > 0.0F) { this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F); } else if (enumdifficulty != EnumDifficulty.PEACEFUL) { // CraftBukkit start org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(p_75118_1_, Math.max(this.foodLevel - 1, 0)); if (!event.isCancelled()) { this.foodLevel = event.getFoodLevel(); } ((EntityPlayerMP) p_75118_1_).playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(((EntityPlayerMP) p_75118_1_).getBukkitEntity().getScaledHealth(), this.foodLevel, this.foodSaturationLevel)); // CraftBukkit end } } if (p_75118_1_.worldObj.getGameRules().getGameRuleBooleanValue("naturalRegeneration") && this.foodLevel >= 18 && p_75118_1_.shouldHeal()) { ++this.foodTimer; if (this.foodTimer >= 80) { // CraftBukkit - added RegainReason p_75118_1_.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); this.addExhaustion(3.0F); this.foodTimer = 0; } } else if (this.foodLevel <= 0) { ++this.foodTimer; if (this.foodTimer >= 80) { if (p_75118_1_.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || p_75118_1_.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL) { p_75118_1_.attackEntityFrom(DamageSource.starve, 1.0F); } this.foodTimer = 0; } } else { this.foodTimer = 0; } }
public void onUpdateEntity() { try { super.onUpdate(); for (int i = 0; i < this.inventory.getSizeInventory(); ++i) { ItemStack itemstack = this.inventory.getStackInSlot(i); if (itemstack != null && itemstack.getItem().isMap()) { Packet packet = ((ItemMapBase)itemstack.getItem()).func_150911_c(itemstack, this.worldObj, this); if (packet != null) { this.playerNetServerHandler.sendPacket(packet); } } } if (this.getHealth() != this.lastHealth || this.lastFoodLevel != this.foodStats.getFoodLevel() || this.foodStats.getSaturationLevel() == 0.0F != this.wasHungry) { this.playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(this.getHealth(), this.foodStats.getFoodLevel(), this.foodStats.getSaturationLevel())); this.lastHealth = this.getHealth(); this.lastFoodLevel = this.foodStats.getFoodLevel(); this.wasHungry = this.foodStats.getSaturationLevel() == 0.0F; } if (this.getHealth() + this.getAbsorptionAmount() != this.field_130068_bO) { this.field_130068_bO = this.getHealth() + this.getAbsorptionAmount(); Collection collection = this.getWorldScoreboard().func_96520_a(IScoreObjectiveCriteria.health); Iterator iterator = collection.iterator(); while (iterator.hasNext()) { ScoreObjective scoreobjective = (ScoreObjective)iterator.next(); this.getWorldScoreboard().func_96529_a(this.getCommandSenderName(), scoreobjective).func_96651_a(Arrays.asList(new EntityPlayer[] {this})); } } if (this.experienceTotal != this.lastExperience) { this.lastExperience = this.experienceTotal; this.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(this.experience, this.experienceTotal, this.experienceLevel)); } if (this.ticksExisted % 20 * 5 == 0 && !this.func_147099_x().hasAchievementUnlocked(AchievementList.field_150961_L)) { this.func_147098_j(); } } catch (Throwable throwable) { CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Ticking player"); CrashReportCategory crashreportcategory = crashreport.makeCategory("Player being ticked"); this.addEntityCrashInfo(crashreportcategory); throw new ReportedException(crashreport); } }
void handleUpdateHealth(S06PacketUpdateHealth packetIn);
void handleUpdateHealth(S06PacketUpdateHealth var1);
void handleUpdateHealth(S06PacketUpdateHealth p_147249_1_);