LootJS: KubeJS Addon

LootJS: KubeJS Addon

8M Downloads

`ItemFilter.ENCHANTED` does not cover enchanted books

ANormalRaft opened this issue ยท 2 comments

commented

Version

2.9.1

Describe the bug!

When using .modifyLoot() with ItemFilter.ENCHANTED or ItemFilter.ENCHANTABLE, enchanted books were not caught by the statement, but equipments were (armors and tools). I had to resort to use ALWAYS_TRUE to check for all loot that can be enchanted, including enchanted books.

I wanted to report this in case it was a bug (the wiki doesn't mention this, so I assume it is) and if it's a feature I'd like for the types in the wiki to mention that enchanted books aren't considered

I love your mod btw <3

Crash Report

No response

Log

No response

Additional Context

Yes

Modifications

No response

Did the issue happen in singleplayer or on a server?

Singleplayer

commented

ItemFilter.ENCHANTED is if an Item is enchanted. Enchanted books are not really enchanted. They store their enchantments with a different nbt key.

ItemFilter.ENCHANTABLE is a bit weird in vanilla. Items are enchantable if they have a stacksize of 1. I maybe will remove that in the future. That could cause some confusion.

You probably want ItemFilter.hasEnchantment(enchantment, minLevel, maxLevel). Something like ItemFilter.hasEnchantment(/.*/).and("minecraft:enchanted_book") would catch all enchanted books with any enchantment.

commented

I did not realize I could add regex to .hasEnchantment. Thanks for the tip!