Fix EntityType error in SpawnEggMeta

This commit is contained in:
Flowsqy 2024-04-25 22:41:58 +02:00
parent aa2546e4b8
commit d6bc25ef3a

View File

@ -11,6 +11,20 @@ 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) { private static String getNBTEntityID(ShopChest plugin, ItemStack stack) {
try { try {
OBCClassResolver obcClassResolver = new OBCClassResolver(); OBCClassResolver obcClassResolver = new OBCClassResolver();
@ -77,7 +91,7 @@ public class SpawnEggMeta {
case "LavaSlime": case "LavaSlime":
return EntityType.MAGMA_CUBE; return EntityType.MAGMA_CUBE;
case "MushroomCow": case "MushroomCow":
return EntityType.MUSHROOM_COW; return MOOSHROOM;
case "EntityHorse": case "EntityHorse":
return EntityType.HORSE; return EntityType.HORSE;
case "PolarBear": case "PolarBear":