From 7e008226ecaf41be62a9cf0810214ff0c4fdc61b Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 1 Oct 2019 10:04:58 +0200 Subject: [PATCH] Fix 1.14+ walk animation (#1469) * Do not send NaN health metadata to 1.14+ clients * Added config option 'fix-1_14-health-nan' --- .../myles/ViaVersion/bukkit/platform/BukkitViaConfig.java | 5 +++++ .../myles/ViaVersion/bungee/platform/BungeeViaConfig.java | 5 +++++ .../main/java/us/myles/ViaVersion/api/ViaVersionConfig.java | 2 ++ .../protocols/protocol1_14to1_13_2/MetadataRewriter.java | 6 ++++++ common/src/main/resources/assets/viaversion/config.yml | 2 ++ .../myles/ViaVersion/sponge/platform/SpongeViaConfig.java | 5 +++++ .../ViaVersion/velocity/platform/VelocityViaConfig.java | 5 +++++ 7 files changed, 30 insertions(+) diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaConfig.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaConfig.java index b11198b0f..d07c7b7d3 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaConfig.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaConfig.java @@ -274,4 +274,9 @@ public class BukkitViaConfig extends Config implements ViaVersionConfig { public boolean isNonFullBlockLightFix() { return getBoolean("fix-non-full-blocklight", true); } + + @Override + public boolean is1_14HealthNaNFix() { + return getBoolean("fix-1_14-health-nan", true); + } } diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeViaConfig.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeViaConfig.java index 0ff0d5f1c..29fd23541 100644 --- a/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeViaConfig.java +++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeViaConfig.java @@ -327,4 +327,9 @@ public class BungeeViaConfig extends Config implements ViaVersionConfig { public boolean isNonFullBlockLightFix() { return getBoolean("fix-non-full-blocklight", true); } + + @Override + public boolean is1_14HealthNaNFix() { + return getBoolean("fix-1_14-health-nan", true); + } } diff --git a/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java b/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java index b0c36be4b..f3f96d058 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java +++ b/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java @@ -344,4 +344,6 @@ public interface ViaVersionConfig { * @return True if enabled */ boolean isNonFullBlockLightFix(); + + boolean is1_14HealthNaNFix(); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/MetadataRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/MetadataRewriter.java index 52899f59b..6d9095d67 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/MetadataRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/MetadataRewriter.java @@ -39,6 +39,12 @@ public class MetadataRewriter { if (metadata.getId() > 5) { metadata.setId(metadata.getId() + 1); } + if (metadata.getId() == 8 && type.isOrHasParent(Entity1_14Types.EntityType.LIVINGENTITY)) { + final float v = ((Number) metadata.getValue()).floatValue(); + if (Float.isNaN(v) && Via.getConfig().is1_14HealthNaNFix()) { + metadata.setValue(1F); + } + } //Metadata 12 added to living_entity if (metadata.getId() > 11 && type.isOrHasParent(Entity1_14Types.EntityType.LIVINGENTITY)) { diff --git a/common/src/main/resources/assets/viaversion/config.yml b/common/src/main/resources/assets/viaversion/config.yml index 29ffa6a44..b0ab105a4 100644 --- a/common/src/main/resources/assets/viaversion/config.yml +++ b/common/src/main/resources/assets/viaversion/config.yml @@ -128,6 +128,8 @@ change-1_9-hitbox: false change-1_14-hitbox: false # Fixes 1.14+ clients on sub 1.14 servers having a light value of 0 for non full blocks. fix-non-full-blocklight: true +# Fixes walk animation not shown when health is set to Float.NaN +fix-1_14-health-nan: true # # Enable serverside block-connections for 1.13+ clients serverside-blockconnections: false diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeViaConfig.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeViaConfig.java index 3637ef493..7a4aad783 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeViaConfig.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeViaConfig.java @@ -280,4 +280,9 @@ public class SpongeViaConfig extends Config implements ViaVersionConfig { public boolean isNonFullBlockLightFix() { return getBoolean("fix-non-full-blocklight", true); } + + @Override + public boolean is1_14HealthNaNFix() { + return getBoolean("fix-1_14-health-nan", true); + } } diff --git a/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaConfig.java b/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaConfig.java index ab4d184ef..0b10c7184 100644 --- a/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaConfig.java +++ b/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityViaConfig.java @@ -333,4 +333,9 @@ public class VelocityViaConfig extends Config implements ViaVersionConfig { public boolean isNonFullBlockLightFix() { return getBoolean("fix-non-full-blocklight", true); } + + @Override + public boolean is1_14HealthNaNFix() { + return getBoolean("fix-1_14-health-nan", true); + } }