Skip to content

Commit

Permalink
Fixed 1.20.6+ getEnchants
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Jun 20, 2024
1 parent 9ad489b commit 6faaac2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ class FastItemStackFactory : FastItemStackFactoryProxy {
map[bukkit] = level
}

if (checkStored) {
val stored = handle.get(DataComponents.ENCHANTMENTS) ?: return map

for ((enchantment, level) in stored.entrySet()) {
val bukkit = CraftEnchantment.minecraftToBukkit(enchantment.value())

map[bukkit] = max(map.getOrDefault(bukkit, 0), level)
}
}

return map
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ class FastItemStackFactory : FastItemStackFactoryProxy {
map[bukkit] = level
}

if (checkStored) {
val stored = handle.get(DataComponents.ENCHANTMENTS) ?: return map

for ((enchantment, level) in stored.entrySet()) {
val bukkit = CraftEnchantment.minecraftToBukkit(enchantment.value())

map[bukkit] = max(map.getOrDefault(bukkit, 0), level)
}
}

return map
}

Expand Down

0 comments on commit 6faaac2

Please sign in to comment.