mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
Revert "fancynpcs: Fix cat variant attribute for 1.21.5"
This reverts commit d3a3b53b09.
This commit is contained in:
@@ -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<CatVariant> registry = getCatVariantRegistry(cat.level());
|
||||
Holder.Reference<CatVariant> variant = registry.get(ResourceKey.create(
|
||||
Registries.CAT_VARIANT,
|
||||
ResourceLocation.withDefaultNamespace(value.toLowerCase())
|
||||
)).orElseThrow();
|
||||
Holder<CatVariant> 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<CatVariant> getCatVariantRegistry(Level world) {
|
||||
return world.registryAccess().lookup(Registries.CAT_VARIANT).orElseThrow();
|
||||
private static HolderLookup.RegistryLookup<CatVariant> 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);
|
||||
|
||||
Reference in New Issue
Block a user