AIOT Botania

AIOT Botania

24M Downloads

Infinite loop in till event handler with manasteel and elementium hoes

jeremiahwinsley opened this issue ยท 0 comments

commented

Minecraft version

None

AIOT Botania version

1.20.1-4.0.2

Botania version

1.20.1-443-FORGE

Forge version

47.2.19

The latest.log file

https://mclo.gs/ca9TZ1E

Issue description

On receiving a BlockToolModificationEvent, the onTilt event handler calls ToolUtil.hoeUse for Botania hoes: https://github.com/MelanX/aiotbotania/blob/602dfc17878d97af9f082fb475215eaac52c5f45/src/main/java/de/melanx/aiotbotania/core/proxy/CommonProxy.java#L111

This method calls BlockState#getToolModifiedState which fires another BlockToolModificationEvent, leading to an infinite loop: https://github.com/MelanX/aiotbotania/blob/602dfc17878d97af9f082fb475215eaac52c5f45/src/main/java/de/melanx/aiotbotania/util/ToolUtil.java#L103

Steps to reproduce

  1. Fresh Forge install with AIOT Botania
  2. Attempt to till dirt with a manasteel or elementium hoe.
  3. Crashes immediately with unclear error message

Requires a mixin to EventBus#handleException to get the actual exception:

@Mixin(EventBus.class)
public class MixinEventBus {
    @Inject(
            at = @At("HEAD"),
            require = 1,
            remap = false,
            method = "handleException(Lnet/minecraftforge/eventbus/api/IEventBus;Lnet/minecraftforge/eventbus/api/Event;[Lnet/minecraftforge/eventbus/api/IEventListener;ILjava/lang/Throwable;)V"
    )
    public void handleException(IEventBus bus, Event event, IEventListener[] listeners, int index, Throwable throwable, CallbackInfo ci) {
        PacketDebug.LOGGER.error("Logging exception from EventBus", throwable);
    }
}

Other information

No response