Compare commits

...
4 changed files with 28 additions and 10 deletions

No files matched your search

+1 -1
View File
@@ -14,7 +14,7 @@ plugins {
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
dependencies {
mache("io.papermc:mache:26.3+build.1")
mache("io.papermc:mache:26.3+build.2")
paperclip("io.papermc:paperclip:3.0.4")
}
@@ -522,10 +522,10 @@ index 0de6f540c5192dd152d2e0a55d6b26eee0f5107f..afb2c249078f85579f37a772c41c8138
delta = this.maybeBackOffFromEdge(delta, moverType);
Vec3 movement = this.collide(delta);
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index 62ccee5c76303b679d591714e64ee93c1502f378..0ef6c4cefb457c87f4565701817d2f9034dfa0d8 100644
index db627b1d589e2c9d457b2f1b6429ea11849a1d3a..442bdb6b0bea65f4d2527eea43d2205cbaa4107a 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -3380,6 +3380,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
@@ -3391,6 +3391,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
protected void playAttackSound() {
}
@@ -1222,7 +1222,12 @@
this.player
.swingAndResetAttackStrength(hand, swingAnimation, success.swingSource() != InteractionResult.SwingSource.PREDICTED);
}
@@ -1462,20 +_,24 @@
@@ -1458,24 +_,28 @@
} else if (direction == Direction.DOWN && pos.getY() <= minY) {
this.player.sendBuildLimitMessage(false, minY);
}
- } else if (interactionResult instanceof InteractionResult.Success success && success.shouldSwing()) {
+ } else if (interactionResult instanceof InteractionResult.Success success && success.shouldSwing() && !this.player.gameMode.interactResult) { // Paper - Call interact event
this.player
.swingAndResetAttackStrength(hand, swingAnimation, success.swingSource() != InteractionResult.SwingSource.PREDICTED);
}
@@ -208,12 +208,13 @@
this.effectsDirty = true;
}
- this.setHealth(input.getFloatOr("Health", this.getMaxHealth()));
+ // CraftBukkit start
+ input.read("Bukkit.MaxHealth", com.mojang.serialization.Codec.DOUBLE).ifPresent(maxHealth -> {
+ this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(maxHealth);
+ });
+ // CraftBukkit end
this.setHealth(input.getFloatOr("Health", this.getMaxHealth()));
+ this.setHealth(input.getFloatOr("Health", this.getMaxHealth()), false); // Paper - Fix MC-17876
this.hurtTime = input.getShortOr("HurtTime", (short)0);
this.deathTime = input.getShortOr("DeathTime", (short)0);
this.setSharedFlag(Entity.FLAG_FALL_FLYING, input.getBooleanOr("FallFlying", false));
@@ -423,7 +424,7 @@
if (effectInstance != null) {
this.onEffectsRemoved(List.of(effectInstance));
return true;
@@ -1152,17 +_,62 @@
@@ -1152,18 +_,74 @@
}
public void heal(final float heal) {
@@ -463,9 +464,8 @@
return this.entityData.get(DATA_HEALTH_ID);
}
- public void setHealth(final float health) {
+ // Paper start - Check for NaN
+ public void setHealth(float health) {
+ public void setHealth(float health, final boolean clamp) { // Paper - Fix MC-17876 - add clamp parameter
+ if (Float.isNaN(health)) { health = getMaxHealth(); if (this.valid) {
+ System.err.println("[NAN-HEALTH] " + getScoreboardName() + " had NaN health set");
+ } } // Paper end - Check for NaN
@@ -475,7 +475,7 @@
+ // Squeeze
+ if (health < 0.0F) {
+ player.setRealHealth(0.0);
+ } else if (health > player.getMaxHealth()) {
+ } else if (clamp && health > player.getMaxHealth()) { // Paper - Fix MC-17876
+ player.setRealHealth(player.getMaxHealth());
+ } else {
+ player.setRealHealth(health);
@@ -485,9 +485,22 @@
+ return;
+ }
+ // CraftBukkit end
this.entityData.set(DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth()));
+ // Paper start - Fix MC-17876
+ if (clamp) {
+ health = Math.clamp(health, 0.0F, this.getMaxHealth());
+ } else {
+ health = Math.max(health, 0.0F);
+ }
+
+ this.entityData.set(DATA_HEALTH_ID, health);
+ }
public void setHealth(final float health) {
- this.entityData.set(DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth()));
+ this.setHealth(health, true);
+ // Paper end - Fix MC-17876
}
public boolean isDeadOrDying() {
@@ -1180,7 +_,7 @@
return false;
}