From d6bc25ef3acf8650a37dd30eeb4dea35ec5ad91e Mon Sep 17 00:00:00 2001 From: Flowsqy <47575244+Flowsqy@users.noreply.github.com> Date: Thu, 25 Apr 2024 22:41:58 +0200 Subject: [PATCH] Fix EntityType error in SpawnEggMeta --- .../epiceric/shopchest/nms/SpawnEggMeta.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/plugin/src/main/java/de/epiceric/shopchest/nms/SpawnEggMeta.java b/plugin/src/main/java/de/epiceric/shopchest/nms/SpawnEggMeta.java index 45de850..017e813 100644 --- a/plugin/src/main/java/de/epiceric/shopchest/nms/SpawnEggMeta.java +++ b/plugin/src/main/java/de/epiceric/shopchest/nms/SpawnEggMeta.java @@ -9,7 +9,21 @@ import org.inventivetalent.reflection.resolver.minecraft.OBCClassResolver; import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.utils.Utils; -public class SpawnEggMeta { +public class SpawnEggMeta { + + private final static EntityType MOOSHROOM; + + static { + // The constant name changed in 1.20.5 + // Doing this ensure compatibility with older version when using reflection nms module + EntityType MOOSHROOM_ENTITY_TYPE; + try { + MOOSHROOM_ENTITY_TYPE = EntityType.valueOf("MUSHROOM_COW"); + } catch (IllegalArgumentException e) { + MOOSHROOM_ENTITY_TYPE = EntityType.MOOSHROOM; + } + MOOSHROOM = MOOSHROOM_ENTITY_TYPE; + } private static String getNBTEntityID(ShopChest plugin, ItemStack stack) { try { @@ -77,7 +91,7 @@ public class SpawnEggMeta { case "LavaSlime": return EntityType.MAGMA_CUBE; case "MushroomCow": - return EntityType.MUSHROOM_COW; + return MOOSHROOM; case "EntityHorse": return EntityType.HORSE; case "PolarBear":