[1.20.1] Anvil Bug?
Looodon opened this issue ยท 3 comments
Issue description
I tried to disable the anvil from giving the trident any enchantments and failed even after three people on the discord reviewed and said it should have worked. No one is able to stop the item from getting an enchantment from a book on the anvil. I tried it with only 1) crafttweaker, 2) jeitweaker, and 3) jei installed.
Steps to reproduce
No response
Script used
The crafttweaker.log file
Minecraft version
1.20.1
Modloader
Forge
Modloader version
47.3.7
CraftTweaker version
14.0.43
Other relevant information
No response
The latest.log file
The AnvilUpdateEvent is cancelable, despite what the docs say, so the following will work:
import crafttweaker.forge.api.event.tick.PlayerTickEvent;
events.register<crafttweaker.forge.api.event.anvil.AnvilUpdateEvent>((event) => {
if <item:minecraft:trident>.matches(event.left) {
event.cancel();
}
}
);
I am working on updating the docs, but I do not have an ETA on when it will be done.
That would be a bug with Forge then, we don't have any special handling for events, writing that same event exactly like that in a mod would result in the same thing happening.
While not a good solution, you can do this instead:
import crafttweaker.forge.api.event.tick.PlayerTickEvent;
events.register<crafttweaker.forge.api.event.anvil.AnvilUpdateEvent>((event) => {
if <item:minecraft:trident>.matches(event.left) {
event.output = event.left;
}
}
);
however that will still consume the book, but it won't get any enchantments.