Improve enchantWithLevels logic
Previously would stream and optionally filter out all entries in the enchantment registry. Moves it to using the empty optional if treasure is allowed, leaving the logic to EnchantmentHelper.
This commit is contained in:
parent
967ee0c7b1
commit
128085ba3e
1 changed files with 8 additions and 3 deletions
|
@ -30,9 +30,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ new org.bukkit.craftbukkit.util.RandomSourceWrapper(random),
|
||||
+ internalStack,
|
||||
+ levels,
|
||||
+ enchantments.holders()
|
||||
+ .<net.minecraft.core.Holder<Enchantment>>map(r -> r)
|
||||
+ .filter(r -> allowTreasure || !r.is(EnchantmentTags.TREASURE))
|
||||
+ registryAccess,
|
||||
+ allowTreasure
|
||||
+ ? Optional.empty()
|
||||
+ // While IN_ENCHANTING_TABLE is not logically the same as all but TREASURE, the tag is defined as
|
||||
+ // NON_TREASURE, which does contain all enchantments not in the treasure tag.
|
||||
+ // Additionally, the allowTreasure boolean is more intended to configure this method to behave like
|
||||
+ // an enchanting table.
|
||||
+ : registryAccess.registryOrThrow(Registries.ENCHANTMENT).getTag(EnchantmentTags.IN_ENCHANTING_TABLE)
|
||||
+ );
|
||||
+ return CraftItemStack.asCraftMirror(enchanted);
|
||||
+ }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue