FallingTree

FallingTree

28M Downloads

Chopper Enchantment on invalid tools in Villager trading/mobs

CrazyRandomzZ opened this issue ยท 6 comments

commented

Describe the bug

As the title states. Im getting chopper on crossbows, Swords, Bows up to this point. dont think this is intended or if it is it shouldnt be. mobs drop mainly bows with chopper, and mastered weapon villager offering a diamand sword with chopper.

Minecraft version

1.19

Fabric API version

0.58.0

Mod version

3.7.3

Relevant log output

No response

commented

Those enchants will drive me crazy x)

Seems like this verification is not performed somehow: https://github.com/RakSrinaNa/FallingTree/blob/3.7.3/fabric/src/main/java/fr/raksrinana/fallingtree/fabric/enchant/ChopperEnchantment.java#L47

Will have to investigate a bit.

commented

So after inspecting a bit the code, I'm not sure I can change this. This is done at the minecraft level.

Basically the enchant has to define a category, which has a defined set of values and can't be modified:
image
In my case I use BREAKABLE which allows a lot of items.

In the enchant itself I override the canEnchant method to use my logic based on the config:
image

However, when a villager builds its trades (and I guess it's the same for spawned mobs), it doesn't use enchant.canEnchant, but instead checks enchant.category.canEnchant, which leads to the fact the enchant is considered ok on almost any item.
image


To keep track: https://discord.com/channels/507304429255393322/507982478276034570/1007688569785159731

commented

This check has other implications on Minecraft itself. Like you'll never see an axe with sharpness in the villager trades.

I don't know if this is intentional or not, so I gave it a shot and reported it to Mojang. We'll see what they say about it.
https://bugs.mojang.com/browse/MC-255174

commented

Ok, well I do have a suggestion as a work around for the time being,

I set the enchantment to hidden so it doesn't show up at all, then made a custom data pack that Adds the enchanted book to some of the chest loot tables such as spawners, ruined portals and sunken ship treasure. So that way the only way to get the enchantment is via the book. And anvil.

If mojang doesn't fix the bug perhaps you can add this function to the mod pack.

commented

So far seems that Mojang considers it as intentional behavior.

I'll investigate a bit further but I think that if you set the "hide enchant option to true", it should be considered as a treasure and already be generated in chests.
But I'll take a look at it to be sure.

commented

It has been officially marked as intentional by Mojang.