diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java index c380361fe4..88b40f4688 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java @@ -7,8 +7,10 @@ import net.minecraft.world.entity.animal.CatVariant; import net.minecraft.world.entity.animal.EntityCat; import net.minecraft.world.item.EnumColor; import org.bukkit.DyeColor; +import org.bukkit.Registry; import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.entity.Cat; public class CraftCat extends CraftTameableAnimal implements Cat { @@ -56,14 +58,15 @@ public class CraftCat extends CraftTameableAnimal implements Cat { IRegistry registry = CraftRegistry.getMinecraftRegistry(Registries.CAT_VARIANT); - return Type.values()[registry.getId(minecraft)]; + return Registry.CAT_VARIANT.get(CraftNamespacedKey.fromMinecraft(registry.getKey(minecraft))); } public static CatVariant bukkitToMinecraft(Type bukkit) { Preconditions.checkArgument(bukkit != null); - return CraftRegistry.getMinecraftRegistry(Registries.CAT_VARIANT) - .byId(bukkit.ordinal()); + IRegistry registry = CraftRegistry.getMinecraftRegistry(Registries.CAT_VARIANT); + + return registry.get(CraftNamespacedKey.toMinecraft(bukkit.getKey())); } } } diff --git a/paper-server/src/test/java/org/bukkit/block/banner/PatternTypeTest.java b/paper-server/src/test/java/org/bukkit/block/banner/PatternTypeTest.java index 5134fe8d98..74103b6df8 100644 --- a/paper-server/src/test/java/org/bukkit/block/banner/PatternTypeTest.java +++ b/paper-server/src/test/java/org/bukkit/block/banner/PatternTypeTest.java @@ -3,6 +3,8 @@ package org.bukkit.block.banner; import static org.junit.jupiter.api.Assertions.*; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.level.block.entity.EnumBannerPatternType; +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.support.AbstractTestingBase; import org.junit.jupiter.api.Test; @@ -22,7 +24,8 @@ public class PatternTypeTest extends AbstractTestingBase { for (PatternType bukkit : PatternType.values()) { EnumBannerPatternType found = null; for (EnumBannerPatternType nms : BuiltInRegistries.BANNER_PATTERN) { - if (bukkit.getIdentifier().equals(nms.getHashname())) { + NamespacedKey nmsKey = CraftNamespacedKey.fromMinecraft(BuiltInRegistries.BANNER_PATTERN.getKey(nms)); + if (bukkit.getIdentifier().equals(nms.getHashname()) && bukkit.getKey().equals(nmsKey)) { found = nms; break; }