2024-09-27 20:04:57 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: masmc05 <masmc05@gmail.com>
|
|
|
|
Date: Wed, 25 Sep 2024 16:26:04 +0300
|
|
|
|
Subject: [PATCH] Add enchantWithLevels with enchantment registry set
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
2024-10-25 12:28:34 +02:00
|
|
|
index 944dcc1126c947b4c8c3b4fdd174eb57320abbba..260fb93e71812698beb475bab7a05b9b860c6cbd 100644
|
2024-09-27 20:04:57 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
2024-10-25 12:28:34 +02:00
|
|
|
@@ -322,6 +322,22 @@ public final class CraftItemFactory implements ItemFactory {
|
2024-09-27 20:04:57 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public ItemStack enchantWithLevels(ItemStack itemStack, int levels, io.papermc.paper.registry.set.RegistryKeySet<org.bukkit.enchantments.Enchantment> keySet, java.util.Random random) {
|
|
|
|
+ return enchantWithLevels(
|
|
|
|
+ itemStack,
|
|
|
|
+ levels,
|
|
|
|
+ Optional.of(
|
|
|
|
+ io.papermc.paper.registry.set.PaperRegistrySets.convertToNms(
|
|
|
|
+ Registries.ENCHANTMENT,
|
|
|
|
+ net.minecraft.server.MinecraftServer.getServer().registryAccess().createSerializationContext(net.minecraft.nbt.NbtOps.INSTANCE).lookupProvider,
|
|
|
|
+ keySet
|
|
|
|
+ )
|
|
|
|
+ ),
|
|
|
|
+ random
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
|
|
|
private ItemStack enchantWithLevels(
|
|
|
|
ItemStack itemStack,
|