1
0
mirror of https://github.com/PaperMC/Paper.git synced 2025-04-08 04:55:44 +02:00

SPIGOT-6026: Pull PotionEffectType and Enchantment from registry

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
CraftBukkit/Spigot 2023-12-06 03:40:00 +11:00
parent 8398e12b34
commit dd8ca5c2dc
9 changed files with 226 additions and 265 deletions
paper-server
nms-patches/net/minecraft/world
src

View File

@ -1,14 +0,0 @@
--- a/net/minecraft/world/effect/MobEffects.java
+++ b/net/minecraft/world/effect/MobEffects.java
@@ -47,6 +47,10 @@
public MobEffects() {}
private static MobEffectList register(String s, MobEffectList mobeffectlist) {
- return (MobEffectList) IRegistry.register(BuiltInRegistries.MOB_EFFECT, s, mobeffectlist);
+ // CraftBukkit start
+ mobeffectlist = (MobEffectList) IRegistry.register(BuiltInRegistries.MOB_EFFECT, s, mobeffectlist);
+ org.bukkit.potion.PotionEffectType.registerPotionEffectType(new org.bukkit.craftbukkit.potion.CraftPotionEffectType(mobeffectlist));
+ return mobeffectlist;
+ // CraftBukkit end
}
}

View File

@ -1,14 +0,0 @@
--- a/net/minecraft/world/item/enchantment/Enchantments.java
+++ b/net/minecraft/world/item/enchantment/Enchantments.java
@@ -50,6 +50,10 @@
public Enchantments() {}
private static Enchantment register(String s, Enchantment enchantment) {
- return (Enchantment) IRegistry.register(BuiltInRegistries.ENCHANTMENT, s, enchantment);
+ // CraftBukkit start
+ enchantment = (Enchantment) IRegistry.register(BuiltInRegistries.ENCHANTMENT, s, enchantment);
+ org.bukkit.enchantments.Enchantment.registerEnchantment(new org.bukkit.craftbukkit.enchantments.CraftEnchantment(enchantment));
+ return enchantment;
+ // CraftBukkit end
}
}

View File

@ -16,15 +16,19 @@ import org.bukkit.Keyed;
import org.bukkit.MusicInstrument; import org.bukkit.MusicInstrument;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.Registry; import org.bukkit.Registry;
import org.bukkit.craftbukkit.enchantments.CraftEnchantment;
import org.bukkit.craftbukkit.generator.structure.CraftStructure; import org.bukkit.craftbukkit.generator.structure.CraftStructure;
import org.bukkit.craftbukkit.generator.structure.CraftStructureType; import org.bukkit.craftbukkit.generator.structure.CraftStructureType;
import org.bukkit.craftbukkit.inventory.trim.CraftTrimMaterial; import org.bukkit.craftbukkit.inventory.trim.CraftTrimMaterial;
import org.bukkit.craftbukkit.inventory.trim.CraftTrimPattern; import org.bukkit.craftbukkit.inventory.trim.CraftTrimPattern;
import org.bukkit.craftbukkit.potion.CraftPotionEffectType;
import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.generator.structure.Structure; import org.bukkit.generator.structure.Structure;
import org.bukkit.generator.structure.StructureType; import org.bukkit.generator.structure.StructureType;
import org.bukkit.inventory.meta.trim.TrimMaterial; import org.bukkit.inventory.meta.trim.TrimMaterial;
import org.bukkit.inventory.meta.trim.TrimPattern; import org.bukkit.inventory.meta.trim.TrimPattern;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class CraftRegistry<B extends Keyed, M> implements Registry<B> { public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
@ -45,12 +49,18 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
} }
public static <B extends Keyed> Registry<?> createRegistry(Class<B> bukkitClass, IRegistryCustom registryHolder) { public static <B extends Keyed> Registry<?> createRegistry(Class<B> bukkitClass, IRegistryCustom registryHolder) {
if (bukkitClass == Enchantment.class) {
return new CraftRegistry<>(Enchantment.class, registryHolder.registryOrThrow(Registries.ENCHANTMENT), CraftEnchantment::new);
}
if (bukkitClass == GameEvent.class) { if (bukkitClass == GameEvent.class) {
return new CraftRegistry<>(GameEvent.class, registryHolder.registryOrThrow(Registries.GAME_EVENT), CraftGameEvent::new); return new CraftRegistry<>(GameEvent.class, registryHolder.registryOrThrow(Registries.GAME_EVENT), CraftGameEvent::new);
} }
if (bukkitClass == MusicInstrument.class) { if (bukkitClass == MusicInstrument.class) {
return new CraftRegistry<>(MusicInstrument.class, registryHolder.registryOrThrow(Registries.INSTRUMENT), CraftMusicInstrument::new); return new CraftRegistry<>(MusicInstrument.class, registryHolder.registryOrThrow(Registries.INSTRUMENT), CraftMusicInstrument::new);
} }
if (bukkitClass == PotionEffectType.class) {
return new CraftRegistry<>(PotionEffectType.class, registryHolder.registryOrThrow(Registries.MOB_EFFECT), CraftPotionEffectType::new);
}
if (bukkitClass == Structure.class) { if (bukkitClass == Structure.class) {
return new CraftRegistry<>(Structure.class, registryHolder.registryOrThrow(Registries.STRUCTURE), CraftStructure::new); return new CraftRegistry<>(Structure.class, registryHolder.registryOrThrow(Registries.STRUCTURE), CraftStructure::new);
} }

View File

@ -329,13 +329,7 @@ public final class CraftServer implements Server {
CraftRegistry.setMinecraftRegistry(console.registryAccess()); CraftRegistry.setMinecraftRegistry(console.registryAccess());
// Register all the Enchantments and PotionTypes now so we can stop new registration immediately after
Enchantments.SHARPNESS.getClass();
org.bukkit.enchantments.Enchantment.stopAcceptingRegistrations();
Potion.setPotionBrewer(new CraftPotionBrewer()); Potion.setPotionBrewer(new CraftPotionBrewer());
MobEffects.BLINDNESS.getClass();
PotionEffectType.stopAcceptingRegistrations();
// Ugly hack :( // Ugly hack :(
if (!Main.useConsole) { if (!Main.useConsole) {

View File

@ -1,9 +1,14 @@
package org.bukkit.craftbukkit.enchantments; package org.bukkit.craftbukkit.enchantments;
import com.google.common.base.Preconditions;
import net.minecraft.core.IRegistry; import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.item.enchantment.EnchantmentBinding; import net.minecraft.world.item.enchantment.EnchantmentBinding;
import net.minecraft.world.item.enchantment.EnchantmentVanishing; import net.minecraft.world.item.enchantment.EnchantmentVanishing;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.craftbukkit.CraftRegistry;
import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@ -12,171 +17,133 @@ import org.bukkit.enchantments.EnchantmentWrapper;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class CraftEnchantment extends Enchantment { public class CraftEnchantment extends Enchantment {
private final net.minecraft.world.item.enchantment.Enchantment target;
public CraftEnchantment(net.minecraft.world.item.enchantment.Enchantment target) { public static Enchantment minecraftToBukkit(net.minecraft.world.item.enchantment.Enchantment minecraft) {
super(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.ENCHANTMENT.getKey(target))); Preconditions.checkArgument(minecraft != null);
this.target = target;
IRegistry<net.minecraft.world.item.enchantment.Enchantment> registry = CraftRegistry.getMinecraftRegistry(Registries.ENCHANTMENT);
Enchantment bukkit = Registry.ENCHANTMENT.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().location()));
Preconditions.checkArgument(bukkit != null);
return bukkit;
}
public static net.minecraft.world.item.enchantment.Enchantment bukkitToMinecraft(Enchantment bukkit) {
Preconditions.checkArgument(bukkit != null);
return ((CraftEnchantment) bukkit).getHandle();
}
private final NamespacedKey key;
private final net.minecraft.world.item.enchantment.Enchantment handle;
private final int id;
public CraftEnchantment(NamespacedKey key, net.minecraft.world.item.enchantment.Enchantment handle) {
this.key = key;
this.handle = handle;
this.id = BuiltInRegistries.ENCHANTMENT.getId(handle);
}
public net.minecraft.world.item.enchantment.Enchantment getHandle() {
return handle;
}
@Override
public NamespacedKey getKey() {
return key;
} }
@Override @Override
public int getMaxLevel() { public int getMaxLevel() {
return target.getMaxLevel(); return handle.getMaxLevel();
} }
@Override @Override
public int getStartLevel() { public int getStartLevel() {
return target.getMinLevel(); return handle.getMinLevel();
} }
@Override @Override
public EnchantmentTarget getItemTarget() { public EnchantmentTarget getItemTarget() {
switch (target.category) { return switch (handle.category) {
case ARMOR: case ARMOR -> EnchantmentTarget.ARMOR;
return EnchantmentTarget.ARMOR; case ARMOR_FEET -> EnchantmentTarget.ARMOR_FEET;
case ARMOR_FEET: case ARMOR_HEAD -> EnchantmentTarget.ARMOR_HEAD;
return EnchantmentTarget.ARMOR_FEET; case ARMOR_LEGS -> EnchantmentTarget.ARMOR_LEGS;
case ARMOR_HEAD: case ARMOR_CHEST -> EnchantmentTarget.ARMOR_TORSO;
return EnchantmentTarget.ARMOR_HEAD; case DIGGER -> EnchantmentTarget.TOOL;
case ARMOR_LEGS: case WEAPON -> EnchantmentTarget.WEAPON;
return EnchantmentTarget.ARMOR_LEGS; case BOW -> EnchantmentTarget.BOW;
case ARMOR_CHEST: case FISHING_ROD -> EnchantmentTarget.FISHING_ROD;
return EnchantmentTarget.ARMOR_TORSO; case BREAKABLE -> EnchantmentTarget.BREAKABLE;
case DIGGER: case WEARABLE -> EnchantmentTarget.WEARABLE;
return EnchantmentTarget.TOOL; case TRIDENT -> EnchantmentTarget.TRIDENT;
case WEAPON: case CROSSBOW -> EnchantmentTarget.CROSSBOW;
return EnchantmentTarget.WEAPON; case VANISHABLE -> EnchantmentTarget.VANISHABLE;
case BOW: };
return EnchantmentTarget.BOW;
case FISHING_ROD:
return EnchantmentTarget.FISHING_ROD;
case BREAKABLE:
return EnchantmentTarget.BREAKABLE;
case WEARABLE:
return EnchantmentTarget.WEARABLE;
case TRIDENT:
return EnchantmentTarget.TRIDENT;
case CROSSBOW:
return EnchantmentTarget.CROSSBOW;
case VANISHABLE:
return EnchantmentTarget.VANISHABLE;
default:
return null;
}
} }
@Override @Override
public boolean isTreasure() { public boolean isTreasure() {
return target.isTreasureOnly(); return handle.isTreasureOnly();
} }
@Override @Override
public boolean isCursed() { public boolean isCursed() {
return target instanceof EnchantmentBinding || target instanceof EnchantmentVanishing; return handle instanceof EnchantmentBinding || handle instanceof EnchantmentVanishing;
} }
@Override @Override
public boolean canEnchantItem(ItemStack item) { public boolean canEnchantItem(ItemStack item) {
return target.canEnchant(CraftItemStack.asNMSCopy(item)); return handle.canEnchant(CraftItemStack.asNMSCopy(item));
} }
@Override @Override
public String getName() { public String getName() {
// PAIL: migration paths // PAIL: migration paths
switch (BuiltInRegistries.ENCHANTMENT.getId(target)) { return switch (id) {
case 0: case 0 -> "PROTECTION_ENVIRONMENTAL";
return "PROTECTION_ENVIRONMENTAL"; case 1 -> "PROTECTION_FIRE";
case 1: case 2 -> "PROTECTION_FALL";
return "PROTECTION_FIRE"; case 3 -> "PROTECTION_EXPLOSIONS";
case 2: case 4 -> "PROTECTION_PROJECTILE";
return "PROTECTION_FALL"; case 5 -> "OXYGEN";
case 3: case 6 -> "WATER_WORKER";
return "PROTECTION_EXPLOSIONS"; case 7 -> "THORNS";
case 4: case 8 -> "DEPTH_STRIDER";
return "PROTECTION_PROJECTILE"; case 9 -> "FROST_WALKER";
case 5: case 10 -> "BINDING_CURSE";
return "OXYGEN"; case 11 -> "SOUL_SPEED";
case 6: case 12 -> "SWIFT_SNEAK";
return "WATER_WORKER"; case 13 -> "DAMAGE_ALL";
case 7: case 14 -> "DAMAGE_UNDEAD";
return "THORNS"; case 15 -> "DAMAGE_ARTHROPODS";
case 8: case 16 -> "KNOCKBACK";
return "DEPTH_STRIDER"; case 17 -> "FIRE_ASPECT";
case 9: case 18 -> "LOOT_BONUS_MOBS";
return "FROST_WALKER"; case 19 -> "SWEEPING_EDGE";
case 10: case 20 -> "DIG_SPEED";
return "BINDING_CURSE"; case 21 -> "SILK_TOUCH";
case 11: case 22 -> "DURABILITY";
return "SOUL_SPEED"; case 23 -> "LOOT_BONUS_BLOCKS";
case 12: case 24 -> "ARROW_DAMAGE";
return "SWIFT_SNEAK"; case 25 -> "ARROW_KNOCKBACK";
case 13: case 26 -> "ARROW_FIRE";
return "DAMAGE_ALL"; case 27 -> "ARROW_INFINITE";
case 14: case 28 -> "LUCK";
return "DAMAGE_UNDEAD"; case 29 -> "LURE";
case 15: case 30 -> "LOYALTY";
return "DAMAGE_ARTHROPODS"; case 31 -> "IMPALING";
case 16: case 32 -> "RIPTIDE";
return "KNOCKBACK"; case 33 -> "CHANNELING";
case 17: case 34 -> "MULTISHOT";
return "FIRE_ASPECT"; case 35 -> "QUICK_CHARGE";
case 18: case 36 -> "PIERCING";
return "LOOT_BONUS_MOBS"; case 37 -> "MENDING";
case 19: case 38 -> "VANISHING_CURSE";
return "SWEEPING_EDGE"; default -> getKey().toString();
case 20: };
return "DIG_SPEED";
case 21:
return "SILK_TOUCH";
case 22:
return "DURABILITY";
case 23:
return "LOOT_BONUS_BLOCKS";
case 24:
return "ARROW_DAMAGE";
case 25:
return "ARROW_KNOCKBACK";
case 26:
return "ARROW_FIRE";
case 27:
return "ARROW_INFINITE";
case 28:
return "LUCK";
case 29:
return "LURE";
case 30:
return "LOYALTY";
case 31:
return "IMPALING";
case 32:
return "RIPTIDE";
case 33:
return "CHANNELING";
case 34:
return "MULTISHOT";
case 35:
return "QUICK_CHARGE";
case 36:
return "PIERCING";
case 37:
return "MENDING";
case 38:
return "VANISHING_CURSE";
default:
return "UNKNOWN_ENCHANT_" + BuiltInRegistries.ENCHANTMENT.getId(target);
}
}
public static net.minecraft.world.item.enchantment.Enchantment getRaw(Enchantment enchantment) {
if (enchantment instanceof EnchantmentWrapper) {
enchantment = ((EnchantmentWrapper) enchantment).getEnchantment();
}
if (enchantment instanceof CraftEnchantment) {
return ((CraftEnchantment) enchantment).target;
}
return null;
} }
@Override @Override
@ -188,10 +155,29 @@ public class CraftEnchantment extends Enchantment {
return false; return false;
} }
CraftEnchantment ench = (CraftEnchantment) other; CraftEnchantment ench = (CraftEnchantment) other;
return !target.isCompatibleWith(ench.target); return !handle.isCompatibleWith(ench.getHandle());
} }
public net.minecraft.world.item.enchantment.Enchantment getHandle() { @Override
return target; public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof CraftEnchantment)) {
return false;
}
return getKey().equals(((Enchantment) other).getKey());
}
@Override
public int hashCode() {
return getKey().hashCode();
}
@Override
public String toString() {
return "CraftEnchantment[" + getKey() + "]";
} }
} }

View File

@ -225,7 +225,7 @@ public final class CraftItemStack extends ItemStack {
if (handle == null) { if (handle == null) {
return 0; return 0;
} }
return EnchantmentManager.getItemEnchantmentLevel(CraftEnchantment.getRaw(ench), handle); return EnchantmentManager.getItemEnchantmentLevel(CraftEnchantment.bukkitToMinecraft(ench), handle);
} }
@Override @Override

View File

@ -2,20 +2,37 @@ package org.bukkit.craftbukkit.potion;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import net.minecraft.core.IRegistry; import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries; import net.minecraft.core.registries.Registries;
import net.minecraft.world.effect.MobEffectList; import net.minecraft.world.effect.MobEffectList;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftRegistry;
import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
public class CraftPotionEffectType extends PotionEffectType { public class CraftPotionEffectType extends PotionEffectType {
private final MobEffectList handle;
public CraftPotionEffectType(MobEffectList handle) { private final NamespacedKey key;
super(BuiltInRegistries.MOB_EFFECT.getId(handle) + 1, CraftNamespacedKey.fromMinecraft(BuiltInRegistries.MOB_EFFECT.getKey(handle))); private final MobEffectList handle;
private final int id;
public CraftPotionEffectType(NamespacedKey key, MobEffectList handle) {
this.key = key;
this.handle = handle; this.handle = handle;
this.id = CraftRegistry.getMinecraftRegistry(Registries.MOB_EFFECT).getId(handle) + 1;
}
public MobEffectList getHandle() {
return handle;
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
} }
@Override @Override
@ -23,82 +40,55 @@ public class CraftPotionEffectType extends PotionEffectType {
return 1.0D; return 1.0D;
} }
public MobEffectList getHandle() { @Override
return handle; public int getId() {
return id;
} }
@Override @Override
public String getName() { public String getName() {
switch (getId()) { return switch (getId()) {
case 1: case 1 -> "SPEED";
return "SPEED"; case 2 -> "SLOW";
case 2: case 3 -> "FAST_DIGGING";
return "SLOW"; case 4 -> "SLOW_DIGGING";
case 3: case 5 -> "INCREASE_DAMAGE";
return "FAST_DIGGING"; case 6 -> "HEAL";
case 4: case 7 -> "HARM";
return "SLOW_DIGGING"; case 8 -> "JUMP";
case 5: case 9 -> "CONFUSION";
return "INCREASE_DAMAGE"; case 10 -> "REGENERATION";
case 6: case 11 -> "DAMAGE_RESISTANCE";
return "HEAL"; case 12 -> "FIRE_RESISTANCE";
case 7: case 13 -> "WATER_BREATHING";
return "HARM"; case 14 -> "INVISIBILITY";
case 8: case 15 -> "BLINDNESS";
return "JUMP"; case 16 -> "NIGHT_VISION";
case 9: case 17 -> "HUNGER";
return "CONFUSION"; case 18 -> "WEAKNESS";
case 10: case 19 -> "POISON";
return "REGENERATION"; case 20 -> "WITHER";
case 11: case 21 -> "HEALTH_BOOST";
return "DAMAGE_RESISTANCE"; case 22 -> "ABSORPTION";
case 12: case 23 -> "SATURATION";
return "FIRE_RESISTANCE"; case 24 -> "GLOWING";
case 13: case 25 -> "LEVITATION";
return "WATER_BREATHING"; case 26 -> "LUCK";
case 14: case 27 -> "UNLUCK";
return "INVISIBILITY"; case 28 -> "SLOW_FALLING";
case 15: case 29 -> "CONDUIT_POWER";
return "BLINDNESS"; case 30 -> "DOLPHINS_GRACE";
case 16: case 31 -> "BAD_OMEN";
return "NIGHT_VISION"; case 32 -> "HERO_OF_THE_VILLAGE";
case 17: case 33 -> "DARKNESS";
return "HUNGER"; default -> getKey().toString();
case 18: };
return "WEAKNESS"; }
case 19:
return "POISON"; @NotNull
case 20: @Override
return "WITHER"; public PotionEffect createEffect(int duration, int amplifier) {
case 21: return new PotionEffect(this, isInstant() ? 1 : (int) (duration * getDurationModifier()), amplifier);
return "HEALTH_BOOST";
case 22:
return "ABSORPTION";
case 23:
return "SATURATION";
case 24:
return "GLOWING";
case 25:
return "LEVITATION";
case 26:
return "LUCK";
case 27:
return "UNLUCK";
case 28:
return "SLOW_FALLING";
case 29:
return "CONDUIT_POWER";
case 30:
return "DOLPHINS_GRACE";
case 31:
return "BAD_OMEN";
case 32:
return "HERO_OF_THE_VILLAGE";
case 33:
return "DARKNESS";
default:
return "UNKNOWN_EFFECT_TYPE_" + getId();
}
} }
@Override @Override
@ -111,11 +101,34 @@ public class CraftPotionEffectType extends PotionEffectType {
return Color.fromRGB(handle.getColor()); return Color.fromRGB(handle.getColor());
} }
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof PotionEffectType)) {
return false;
}
return getKey().equals(((PotionEffectType) other).getKey());
}
@Override
public int hashCode() {
return getKey().hashCode();
}
@Override
public String toString() {
return "CraftPotionEffectType[" + getKey() + "]";
}
public static PotionEffectType minecraftToBukkit(MobEffectList minecraft) { public static PotionEffectType minecraftToBukkit(MobEffectList minecraft) {
Preconditions.checkArgument(minecraft != null); Preconditions.checkArgument(minecraft != null);
IRegistry<MobEffectList> registry = CraftRegistry.getMinecraftRegistry(Registries.MOB_EFFECT); IRegistry<MobEffectList> registry = CraftRegistry.getMinecraftRegistry(Registries.MOB_EFFECT);
PotionEffectType bukkit = PotionEffectType.getByKey(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().location())); PotionEffectType bukkit = Registry.EFFECT.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().location()));
Preconditions.checkArgument(bukkit != null); Preconditions.checkArgument(bukkit != null);
@ -125,7 +138,6 @@ public class CraftPotionEffectType extends PotionEffectType {
public static MobEffectList bukkitToMinecraft(PotionEffectType bukkit) { public static MobEffectList bukkitToMinecraft(PotionEffectType bukkit) {
Preconditions.checkArgument(bukkit != null); Preconditions.checkArgument(bukkit != null);
return CraftRegistry.getMinecraftRegistry(Registries.MOB_EFFECT) return ((CraftPotionEffectType) bukkit).getHandle();
.getOptional(CraftNamespacedKey.toMinecraft(bukkit.getKey())).orElseThrow();
} }
} }

View File

@ -62,7 +62,6 @@ public abstract class AbstractTestingBase {
BIOMES = REGISTRY_CUSTOM.registryOrThrow(Registries.BIOME); BIOMES = REGISTRY_CUSTOM.registryOrThrow(Registries.BIOME);
DummyServer.setup(); DummyServer.setup();
DummyEnchantments.setup();
CraftRegistry.setMinecraftRegistry(REGISTRY_CUSTOM); CraftRegistry.setMinecraftRegistry(REGISTRY_CUSTOM);

View File

@ -1,12 +0,0 @@
package org.bukkit.support;
import net.minecraft.world.item.enchantment.Enchantments;
public class DummyEnchantments {
static {
Enchantments.SHARPNESS.getClass();
org.bukkit.enchantments.Enchantment.stopAcceptingRegistrations();
}
public static void setup() {}
}