1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-01-18 23:23:19 +01:00

Fix vanilla parity on enchantable items with no targets ()

This commit is contained in:
Miles 2025-01-11 17:44:20 +00:00 committed by GitHub
parent 3ad3fbc19a
commit 79ffcd1536
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -97,7 +97,7 @@
+ .bukkitToMinecraftHolder(offer.getEnchantment()));
+ this.levelClue[j] = offer.getEnchantmentLevel();
+ } else {
+ this.costs[j] = 0;
+ if (enchantClue[j] != -1) this.costs[j] = 0;
+ this.enchantClue[j] = -1;
+ this.levelClue[j] = -1;
+ }
@ -107,7 +107,7 @@
this.broadcastChanges();
});
} else {
@@ -145,19 +_,51 @@
@@ -145,19 +_,53 @@
return false;
} else {
this.access.execute((level, blockPos) -> {
@ -124,7 +124,9 @@
+ enchants.put(org.bukkit.craftbukkit.enchantments.CraftEnchantment.minecraftHolderToBukkit(instance.enchantment), instance.level);
+ }
+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItemStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack);
+ org.bukkit.enchantments.Enchantment hintedEnchantment = org.bukkit.craftbukkit.enchantments.CraftEnchantment.minecraftHolderToBukkit(registry.byId(this.enchantClue[id]));
+ Holder<Enchantment> holder = registry.byId(this.enchantClue[id]);
+ if (holder == null) return;
+ org.bukkit.enchantments.Enchantment hintedEnchantment = org.bukkit.craftbukkit.enchantments.CraftEnchantment.minecraftHolderToBukkit(holder);
+ int hintedEnchantmentLevel = this.levelClue[id];
+ org.bukkit.event.enchantment.EnchantItemEvent event = new org.bukkit.event.enchantment.EnchantItemEvent((org.bukkit.entity.Player) player.getBukkitEntity(), this.getBukkitView(), this.access.getLocation().getBlock(), craftItemStack, this.costs[id], enchants, hintedEnchantment, hintedEnchantmentLevel, id);
+ level.getCraftServer().getPluginManager().callEvent(event);