Fix wolf variants

This commit is contained in:
libraryaddict 2024-07-14 02:22:37 +12:00
parent 549827f0d3
commit 7bae78f2dd
4 changed files with 18 additions and 33 deletions

View File

@ -10,7 +10,6 @@ import io.netty.buffer.PooledByteBufAllocator;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract; import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.component.DataComponentPatch; import net.minecraft.core.component.DataComponentPatch;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
@ -323,7 +322,7 @@ public class ReflectionManager implements ReflectionManagerAbstract {
public int getEntityTypeId(Object entityTypes) { public int getEntityTypeId(Object entityTypes) {
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes; net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
return BuiltInRegistries.ENTITY_TYPE.getId(entityType); return BuiltInRegistries.ENTITY_TYPE.getIdOrThrow(entityType);
} }
@Override @Override
@ -401,8 +400,6 @@ public class ReflectionManager implements ReflectionManagerAbstract {
public Cat.Type getCatTypeFromInt(int catType) { public Cat.Type getCatTypeFromInt(int catType) {
Registry<CatVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.CAT_VARIANT); Registry<CatVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.CAT_VARIANT);
Holder.Reference<CatVariant> ref = registry.getHolder(catType).get();
return CraftCat.CraftType.minecraftHolderToBukkit(registry.getHolder(catType).get()); return CraftCat.CraftType.minecraftHolderToBukkit(registry.getHolder(catType).get());
} }
@ -410,15 +407,13 @@ public class ReflectionManager implements ReflectionManagerAbstract {
public int getCatVariantAsInt(Cat.Type type) { public int getCatVariantAsInt(Cat.Type type) {
Registry<CatVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.CAT_VARIANT); Registry<CatVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.CAT_VARIANT);
return registry.getId(CraftCat.CraftType.bukkitToMinecraft(type)); return registry.getIdOrThrow(CraftCat.CraftType.bukkitToMinecraft(type));
} }
@Override @Override
public Frog.Variant getFrogVariantFromInt(int frogType) { public Frog.Variant getFrogVariantFromInt(int frogType) {
Registry<FrogVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.FROG_VARIANT); Registry<FrogVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.FROG_VARIANT);
Holder.Reference<FrogVariant> ref = registry.getHolder(frogType).get();
return CraftFrog.CraftVariant.minecraftHolderToBukkit(registry.getHolder(frogType).get()); return CraftFrog.CraftVariant.minecraftHolderToBukkit(registry.getHolder(frogType).get());
} }
@ -426,15 +421,13 @@ public class ReflectionManager implements ReflectionManagerAbstract {
public int getFrogVariantAsInt(Frog.Variant type) { public int getFrogVariantAsInt(Frog.Variant type) {
Registry<FrogVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.FROG_VARIANT); Registry<FrogVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.FROG_VARIANT);
return registry.getId(CraftFrog.CraftVariant.bukkitToMinecraft(type)); return registry.getIdOrThrow(CraftFrog.CraftVariant.bukkitToMinecraft(type));
} }
@Override @Override
public Art getPaintingFromInt(int paintingId) { public Art getPaintingFromInt(int paintingId) {
Registry<PaintingVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.PAINTING_VARIANT); Registry<PaintingVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.PAINTING_VARIANT);
Holder.Reference<PaintingVariant> ref = registry.getHolder(paintingId).get();
return CraftArt.minecraftHolderToBukkit(registry.getHolder(paintingId).get()); return CraftArt.minecraftHolderToBukkit(registry.getHolder(paintingId).get());
} }
@ -442,23 +435,21 @@ public class ReflectionManager implements ReflectionManagerAbstract {
public int getPaintingAsInt(Art type) { public int getPaintingAsInt(Art type) {
Registry<PaintingVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.PAINTING_VARIANT); Registry<PaintingVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.PAINTING_VARIANT);
return registry.getId(CraftArt.bukkitToMinecraft(type)); return registry.getIdOrThrow(CraftArt.bukkitToMinecraft(type));
} }
@Override @Override
public Wolf.Variant getWolfVariantFromInt(int wolfVariant) { public Wolf.Variant getWolfVariantFromInt(int wolfVariant) {
Registry<WolfVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.WOLF_VARIANT); Registry<WolfVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.WOLF_VARIANT);
Holder.Reference<WolfVariant> ref = registry.getHolder(wolfVariant).get(); return CraftWolf.CraftVariant.minecraftHolderToBukkit(registry.getHolder(wolfVariant - 1).get());
return CraftWolf.CraftVariant.minecraftHolderToBukkit(registry.getHolder(wolfVariant).get());
} }
@Override @Override
public int getWolfVariantAsInt(Wolf.Variant type) { public int getWolfVariantAsInt(Wolf.Variant type) {
Registry<WolfVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.WOLF_VARIANT); Registry<WolfVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.WOLF_VARIANT);
return registry.getId(CraftWolf.CraftVariant.bukkitToMinecraft(type)); return registry.getIdOrThrow(CraftWolf.CraftVariant.bukkitToMinecraft(type)) + 1;
} }
@Override @Override

View File

@ -10,7 +10,6 @@ import io.netty.buffer.PooledByteBufAllocator;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract; import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.component.DataComponentPatch; import net.minecraft.core.component.DataComponentPatch;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
@ -323,7 +322,7 @@ public class ReflectionManager implements ReflectionManagerAbstract {
public int getEntityTypeId(Object entityTypes) { public int getEntityTypeId(Object entityTypes) {
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes; net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
return BuiltInRegistries.ENTITY_TYPE.getId(entityType); return BuiltInRegistries.ENTITY_TYPE.getIdOrThrow(entityType);
} }
@Override @Override
@ -401,8 +400,6 @@ public class ReflectionManager implements ReflectionManagerAbstract {
public Cat.Type getCatTypeFromInt(int catType) { public Cat.Type getCatTypeFromInt(int catType) {
Registry<CatVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.CAT_VARIANT); Registry<CatVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.CAT_VARIANT);
Holder.Reference<CatVariant> ref = registry.getHolder(catType).get();
return CraftCat.CraftType.minecraftHolderToBukkit(registry.getHolder(catType).get()); return CraftCat.CraftType.minecraftHolderToBukkit(registry.getHolder(catType).get());
} }
@ -410,15 +407,13 @@ public class ReflectionManager implements ReflectionManagerAbstract {
public int getCatVariantAsInt(Cat.Type type) { public int getCatVariantAsInt(Cat.Type type) {
Registry<CatVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.CAT_VARIANT); Registry<CatVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.CAT_VARIANT);
return registry.getId(CraftCat.CraftType.bukkitToMinecraft(type)); return registry.getIdOrThrow(CraftCat.CraftType.bukkitToMinecraft(type));
} }
@Override @Override
public Frog.Variant getFrogVariantFromInt(int frogType) { public Frog.Variant getFrogVariantFromInt(int frogType) {
Registry<FrogVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.FROG_VARIANT); Registry<FrogVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.FROG_VARIANT);
Holder.Reference<FrogVariant> ref = registry.getHolder(frogType).get();
return CraftFrog.CraftVariant.minecraftHolderToBukkit(registry.getHolder(frogType).get()); return CraftFrog.CraftVariant.minecraftHolderToBukkit(registry.getHolder(frogType).get());
} }
@ -426,15 +421,13 @@ public class ReflectionManager implements ReflectionManagerAbstract {
public int getFrogVariantAsInt(Frog.Variant type) { public int getFrogVariantAsInt(Frog.Variant type) {
Registry<FrogVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.FROG_VARIANT); Registry<FrogVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.FROG_VARIANT);
return registry.getId(CraftFrog.CraftVariant.bukkitToMinecraft(type)); return registry.getIdOrThrow(CraftFrog.CraftVariant.bukkitToMinecraft(type));
} }
@Override @Override
public Art getPaintingFromInt(int paintingId) { public Art getPaintingFromInt(int paintingId) {
Registry<PaintingVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.PAINTING_VARIANT); Registry<PaintingVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.PAINTING_VARIANT);
Holder.Reference<PaintingVariant> ref = registry.getHolder(paintingId).get();
return CraftArt.minecraftHolderToBukkit(registry.getHolder(paintingId).get()); return CraftArt.minecraftHolderToBukkit(registry.getHolder(paintingId).get());
} }
@ -442,23 +435,21 @@ public class ReflectionManager implements ReflectionManagerAbstract {
public int getPaintingAsInt(Art type) { public int getPaintingAsInt(Art type) {
Registry<PaintingVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.PAINTING_VARIANT); Registry<PaintingVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.PAINTING_VARIANT);
return registry.getId(CraftArt.bukkitToMinecraft(type)); return registry.getIdOrThrow(CraftArt.bukkitToMinecraft(type));
} }
@Override @Override
public Wolf.Variant getWolfVariantFromInt(int wolfVariant) { public Wolf.Variant getWolfVariantFromInt(int wolfVariant) {
Registry<WolfVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.WOLF_VARIANT); Registry<WolfVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.WOLF_VARIANT);
Holder.Reference<WolfVariant> ref = registry.getHolder(wolfVariant).get(); return CraftWolf.CraftVariant.minecraftHolderToBukkit(registry.getHolder(wolfVariant - 1).get());
return CraftWolf.CraftVariant.minecraftHolderToBukkit(registry.getHolder(wolfVariant).get());
} }
@Override @Override
public int getWolfVariantAsInt(Wolf.Variant type) { public int getWolfVariantAsInt(Wolf.Variant type) {
Registry<WolfVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.WOLF_VARIANT); Registry<WolfVariant> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.WOLF_VARIANT);
return registry.getId(CraftWolf.CraftVariant.bukkitToMinecraft(type)); return registry.getIdOrThrow(CraftWolf.CraftVariant.bukkitToMinecraft(type)) + 1;
} }
@Override @Override

View File

@ -1,5 +1,6 @@
package me.libraryaddict.disguise.disguisetypes; package me.libraryaddict.disguise.disguisetypes;
import lombok.Getter;
import me.libraryaddict.disguise.utilities.reflection.NmsVersion; import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -102,6 +103,7 @@ public enum AnimalColor {
return null; return null;
} }
@Getter
private final DyeColor dyeColor; private final DyeColor dyeColor;
private final Material material; private final Material material;
@ -114,7 +116,4 @@ public enum AnimalColor {
return material; return material;
} }
public DyeColor getDyeColor() {
return dyeColor;
}
} }

View File

@ -1281,4 +1281,8 @@ public class MetaIndex<Y> {
return this == ARMORSTAND_BODY || this == ARMORSTAND_HEAD || this == ARMORSTAND_LEFT_ARM || this == ARMORSTAND_RIGHT_ARM || return this == ARMORSTAND_BODY || this == ARMORSTAND_HEAD || this == ARMORSTAND_LEFT_ARM || this == ARMORSTAND_RIGHT_ARM ||
this == ARMORSTAND_LEFT_LEG || this == ARMORSTAND_RIGHT_LEG; this == ARMORSTAND_LEFT_LEG || this == ARMORSTAND_RIGHT_LEG;
} }
public boolean isUsed() {
return getIndex() >= 0;
}
} }