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.Holder;
|
||||||
import net.minecraft.core.HolderLookup;
|
import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.data.registries.VanillaRegistries;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.animal.Cat;
|
import net.minecraft.world.entity.animal.Cat;
|
||||||
import net.minecraft.world.entity.animal.CatVariant;
|
import net.minecraft.world.entity.animal.CatVariant;
|
||||||
import net.minecraft.world.item.DyeColor;
|
import net.minecraft.world.item.DyeColor;
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -24,19 +24,10 @@ public class CatAttributes {
|
|||||||
|
|
||||||
attributes.add(new NpcAttribute(
|
attributes.add(new NpcAttribute(
|
||||||
"variant",
|
"variant",
|
||||||
List.of(
|
getCatVariantRegistry()
|
||||||
"tabby",
|
.listElementIds()
|
||||||
"black",
|
.map(id -> id.location().getPath())
|
||||||
"red",
|
.toList(),
|
||||||
"siamese",
|
|
||||||
"british_shorthair",
|
|
||||||
"calico",
|
|
||||||
"persian",
|
|
||||||
"ragdoll",
|
|
||||||
"white",
|
|
||||||
"jellie",
|
|
||||||
"all_black"
|
|
||||||
),
|
|
||||||
List.of(EntityType.CAT),
|
List.of(EntityType.CAT),
|
||||||
CatAttributes::setVariant
|
CatAttributes::setVariant
|
||||||
));
|
));
|
||||||
@@ -61,11 +52,12 @@ public class CatAttributes {
|
|||||||
private static void setVariant(Npc npc, String value) {
|
private static void setVariant(Npc npc, String value) {
|
||||||
final Cat cat = ReflectionHelper.getEntity(npc);
|
final Cat cat = ReflectionHelper.getEntity(npc);
|
||||||
|
|
||||||
HolderLookup.RegistryLookup<CatVariant> registry = getCatVariantRegistry(cat.level());
|
Holder<CatVariant> variant = getCatVariantRegistry()
|
||||||
Holder.Reference<CatVariant> variant = registry.get(ResourceKey.create(
|
.get(ResourceKey.create(
|
||||||
Registries.CAT_VARIANT,
|
Registries.CAT_VARIANT,
|
||||||
ResourceLocation.withDefaultNamespace(value.toLowerCase())
|
ResourceLocation.withDefaultNamespace(value.toLowerCase())
|
||||||
)).orElseThrow();
|
))
|
||||||
|
.orElseThrow();
|
||||||
|
|
||||||
cat.setVariant(variant);
|
cat.setVariant(variant);
|
||||||
}
|
}
|
||||||
@@ -89,8 +81,11 @@ public class CatAttributes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HolderLookup.RegistryLookup<CatVariant> getCatVariantRegistry(Level world) {
|
private static HolderLookup.RegistryLookup<CatVariant> getCatVariantRegistry() {
|
||||||
return world.registryAccess().lookup(Registries.CAT_VARIANT).orElseThrow();
|
return VanillaRegistries
|
||||||
|
.createLookup()
|
||||||
|
.lookup(Registries.CAT_VARIANT)
|
||||||
|
.orElseThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setCollarColor(Npc npc, String value) {
|
private static void setCollarColor(Npc npc, String value) {
|
||||||
@@ -104,7 +99,7 @@ public class CatAttributes {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
DyeColor color = DyeColor.valueOf(value.toUpperCase());
|
DyeColor color = DyeColor.valueOf(value.toUpperCase());
|
||||||
if (!cat.isTame()) {
|
if (!cat.isTame()){
|
||||||
cat.setTame(true, false);
|
cat.setTame(true, false);
|
||||||
}
|
}
|
||||||
cat.setCollarColor(color);
|
cat.setCollarColor(color);
|
||||||
|
|||||||
Reference in New Issue
Block a user