From 6d317b1646830a544cf04157411f3c264118ba0a Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 31 May 2025 13:57:34 +0200 Subject: [PATCH] Revert "fancynpcs: Fix cat variant attribute for 1.21.5" This reverts commit d3a3b53b090578f0498dd7c311bc9f19240a43e5. --- .../v1_21_5/attributes/CatAttributes.java | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/plugins/fancynpcs/implementation_1_21_5/src/main/java/de/oliver/fancynpcs/v1_21_5/attributes/CatAttributes.java b/plugins/fancynpcs/implementation_1_21_5/src/main/java/de/oliver/fancynpcs/v1_21_5/attributes/CatAttributes.java index e8631cd2..e80ce702 100644 --- a/plugins/fancynpcs/implementation_1_21_5/src/main/java/de/oliver/fancynpcs/v1_21_5/attributes/CatAttributes.java +++ b/plugins/fancynpcs/implementation_1_21_5/src/main/java/de/oliver/fancynpcs/v1_21_5/attributes/CatAttributes.java @@ -6,12 +6,12 @@ import de.oliver.fancynpcs.v1_21_5.ReflectionHelper; import net.minecraft.core.Holder; import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.Registries; +import net.minecraft.data.registries.VanillaRegistries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.animal.Cat; import net.minecraft.world.entity.animal.CatVariant; import net.minecraft.world.item.DyeColor; -import net.minecraft.world.level.Level; import org.bukkit.entity.EntityType; import java.util.ArrayList; @@ -24,19 +24,10 @@ public class CatAttributes { attributes.add(new NpcAttribute( "variant", - List.of( - "tabby", - "black", - "red", - "siamese", - "british_shorthair", - "calico", - "persian", - "ragdoll", - "white", - "jellie", - "all_black" - ), + getCatVariantRegistry() + .listElementIds() + .map(id -> id.location().getPath()) + .toList(), List.of(EntityType.CAT), CatAttributes::setVariant )); @@ -61,11 +52,12 @@ public class CatAttributes { private static void setVariant(Npc npc, String value) { final Cat cat = ReflectionHelper.getEntity(npc); - HolderLookup.RegistryLookup registry = getCatVariantRegistry(cat.level()); - Holder.Reference variant = registry.get(ResourceKey.create( - Registries.CAT_VARIANT, - ResourceLocation.withDefaultNamespace(value.toLowerCase()) - )).orElseThrow(); + Holder variant = getCatVariantRegistry() + .get(ResourceKey.create( + Registries.CAT_VARIANT, + ResourceLocation.withDefaultNamespace(value.toLowerCase()) + )) + .orElseThrow(); cat.setVariant(variant); } @@ -89,8 +81,11 @@ public class CatAttributes { } } - private static HolderLookup.RegistryLookup getCatVariantRegistry(Level world) { - return world.registryAccess().lookup(Registries.CAT_VARIANT).orElseThrow(); + private static HolderLookup.RegistryLookup getCatVariantRegistry() { + return VanillaRegistries + .createLookup() + .lookup(Registries.CAT_VARIANT) + .orElseThrow(); } private static void setCollarColor(Npc npc, String value) { @@ -104,7 +99,7 @@ public class CatAttributes { try { DyeColor color = DyeColor.valueOf(value.toUpperCase()); - if (!cat.isTame()) { + if (!cat.isTame()){ cat.setTame(true, false); } cat.setCollarColor(color);