mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-02 17:32:03 +01:00
#1303: Create registry for banner pattern and cat type
By: Jishuna <joshl5324@gmail.com>
This commit is contained in:
parent
aacf3bd308
commit
a5594be1c7
2 changed files with 10 additions and 4 deletions
|
@ -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<CatVariant> 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<CatVariant> registry = CraftRegistry.getMinecraftRegistry(Registries.CAT_VARIANT);
|
||||
|
||||
return registry.get(CraftNamespacedKey.toMinecraft(bukkit.getKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue