From 27516ee39ea7be95b5eb4ea700a2df4aeab147d6 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Thu, 16 Feb 2023 03:20:43 +0000 Subject: [PATCH] Temp fix for EntityType.translationKey Upstream improperly used the enum name for looking up the vanilla entity type to get the translation key; temp patch this until upstream fixes this, also add some quick validation --- ...mp-fix-for-EntityType.translationKey.patch | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 patches/server/0961-Temp-fix-for-EntityType.translationKey.patch diff --git a/patches/server/0961-Temp-fix-for-EntityType.translationKey.patch b/patches/server/0961-Temp-fix-for-EntityType.translationKey.patch new file mode 100644 index 0000000000..4ca8168950 --- /dev/null +++ b/patches/server/0961-Temp-fix-for-EntityType.translationKey.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shane Freeder +Date: Thu, 16 Feb 2023 03:19:19 +0000 +Subject: [PATCH] Temp fix for EntityType.translationKey() + + +diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +index c51a7f7489a37093e4096b28bfc1031ba6a2b8c2..287e8c4c57ea1737460fdaf114e7eed627a25b2d 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +@@ -440,7 +440,12 @@ public final class CraftMagicNumbers implements UnsafeValues { + + @Override + public String getTranslationKey(EntityType entityType) { +- return net.minecraft.world.entity.EntityType.byString(entityType.name()).map(net.minecraft.world.entity.EntityType::getDescriptionId).orElseThrow(); ++ // Paper start ++ if (entityType.getName() == null || entityType == EntityType.UNKNOWN) { ++ throw new IllegalArgumentException("Cannot lookup translation key of entity type " + entityType); ++ } ++ return net.minecraft.world.entity.EntityType.byString(entityType.getName()).map(net.minecraft.world.entity.EntityType::getDescriptionId).orElseThrow(); ++ // Paper end + } + + @Override