mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 07:48:53 +01:00
Convert new health to a float during set
Convert the new health value to a float before doing any validation logic
This commit is contained in:
parent
8eb7f073d6
commit
e44b71a6b4
1 changed files with 22 additions and 0 deletions
|
@ -0,0 +1,22 @@
|
||||||
|
From 04533a98c1be92ba73a9ce4cde2ee8759500cbde Mon Sep 17 00:00:00 2001
|
||||||
|
From: kashike <kashike@vq.lc>
|
||||||
|
Date: Thu, 1 Sep 2016 09:51:31 +0000
|
||||||
|
Subject: [PATCH] Convert new health to a float during set Convert the new
|
||||||
|
health value to a float before doing any validation logic
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||||
|
index b807a3f..9e19e7c 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||||
|
@@ -91,6 +91,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHealth(double health) {
|
||||||
|
+ health = (float) health; // Paper - convert health to a float during set to avoid the below error
|
||||||
|
if ((health < 0) || (health > getMaxHealth())) {
|
||||||
|
// Paper - Be more informative
|
||||||
|
throw new IllegalArgumentException("Health must be between 0 and " + getMaxHealth() + ", but was " + health
|
||||||
|
--
|
||||||
|
2.5.0
|
||||||
|
|
Loading…
Reference in a new issue