2013-07-02 03:21:57 +00:00
|
|
|
From 6871003c6b983808a871055b7d89bb4edd073c37 Mon Sep 17 00:00:00 2001
|
2013-06-02 04:49:24 +00:00
|
|
|
From: Nick Minkler <sleaker@gmail.com>
|
|
|
|
Date: Sun, 2 Jun 2013 14:54:11 +1000
|
|
|
|
Subject: [PATCH] Fix Health Scaling
|
|
|
|
|
|
|
|
Fix scaled health sending incorrect values to client. No longer attempts to scale health above maximum. Hopefully fixes 'flash' when player eats food.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
2013-07-02 03:03:56 +00:00
|
|
|
index f043040..e0bb0a5 100644
|
2013-06-02 04:49:24 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2013-07-02 03:03:56 +00:00
|
|
|
@@ -251,7 +251,10 @@ public abstract class EntityLiving extends Entity {
|
2013-06-02 04:49:24 +00:00
|
|
|
|
2013-07-02 03:03:56 +00:00
|
|
|
public float getScaledHealth() {
|
2013-06-02 04:49:24 +00:00
|
|
|
if (this.maxHealth != this.getMaxHealth() && this.getHealth() > 0) {
|
|
|
|
- return this.getHealth() * this.getMaxHealth() / this.maxHealth + 1;
|
|
|
|
+ // Spigot start
|
2013-06-13 05:56:15 +00:00
|
|
|
+ int health = (int) ((((double) this.getHealth()) / this.maxHealth) * this.getMaxHealth());
|
2013-06-02 04:49:24 +00:00
|
|
|
+ return health > 0 ? health : 1;
|
|
|
|
+ // Spigot end
|
|
|
|
} else {
|
|
|
|
return this.getHealth();
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/FoodMetaData.java b/src/main/java/net/minecraft/server/FoodMetaData.java
|
2013-07-02 03:03:56 +00:00
|
|
|
index 543a430..fcf359b 100644
|
2013-06-02 04:49:24 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/FoodMetaData.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/FoodMetaData.java
|
|
|
|
@@ -39,7 +39,8 @@ public class FoodMetaData {
|
|
|
|
this.foodLevel = event.getFoodLevel();
|
|
|
|
}
|
|
|
|
|
|
|
|
- ((EntityPlayer) entityhuman).playerConnection.sendPacket(new Packet8UpdateHealth(entityhuman.getHealth(), this.foodLevel, this.saturationLevel));
|
|
|
|
+ // Spigot - This next line fixes health scaling
|
|
|
|
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new Packet8UpdateHealth(((EntityPlayer) entityhuman).getScaledHealth(), this.foodLevel, this.saturationLevel));
|
|
|
|
// CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemFood.java b/src/main/java/net/minecraft/server/ItemFood.java
|
2013-07-02 03:03:56 +00:00
|
|
|
index 5b77fc7..56eab3f 100644
|
2013-06-02 04:49:24 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemFood.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemFood.java
|
|
|
|
@@ -36,7 +36,8 @@ public class ItemFood extends Item {
|
|
|
|
entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, this.getSaturationModifier());
|
|
|
|
}
|
|
|
|
|
|
|
|
- ((EntityPlayer) entityhuman).playerConnection.sendPacket(new Packet8UpdateHealth(entityhuman.getHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel));
|
|
|
|
+ // Spigot - this next line fixes health scaling
|
|
|
|
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new Packet8UpdateHealth(((EntityPlayer) entityhuman).getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel));
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2013-07-02 03:03:56 +00:00
|
|
|
entityhuman.getFoodData().a(this);
|
2013-06-02 04:49:24 +00:00
|
|
|
--
|
|
|
|
1.8.1.2
|
|
|
|
|