Skip to content

Commit

Permalink
Fixed FastItemStack#getEnchants(true) giving incorrect results when t…
Browse files Browse the repository at this point in the history
…he enchantment component was removed from an item
  • Loading branch information
WillFP committed Aug 23, 2024
1 parent 763a3e9 commit 9cb596e
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import net.minecraft.util.Unit
import net.minecraft.world.item.component.CustomData
import net.minecraft.world.item.component.CustomModelData
import net.minecraft.world.item.component.ItemLore
import net.minecraft.world.item.enchantment.ItemEnchantments
import org.bukkit.Bukkit
import org.bukkit.craftbukkit.CraftRegistry
import org.bukkit.craftbukkit.CraftServer
Expand Down Expand Up @@ -53,7 +54,7 @@ class NewEcoFastItemStack(
private val pdc = (handle.get(DataComponents.CUSTOM_DATA)?.copyTag() ?: CompoundTag()).makePdc()

override fun getEnchants(checkStored: Boolean): Map<Enchantment, Int> {
val enchantments = handle.get(DataComponents.ENCHANTMENTS) ?: return emptyMap()
val enchantments = handle.get(DataComponents.ENCHANTMENTS) ?: ItemEnchantments.EMPTY

val map = mutableMapOf<Enchantment, Int>()

Expand Down

0 comments on commit 9cb596e

Please sign in to comment.