DrManganese / TOPAddons

A Minecraft mod which adds mod support to The One Probe by McJty
https://www.curseforge.com/minecraft/mc-mods/top-addons
GNU General Public License v3.0
7 stars 11 forks source link

Fix ArithmeticException in FluidGaugeElement #105

Closed DPurple closed 2 years ago

DPurple commented 3 years ago

Our player send us some weird CrashReport, I can't reproduce it.

java.lang.ArithmeticException: / by zero
    at io.github.drmanganese.topaddons.elements.forge.FluidGaugeElement.renderFluid(FluidGaugeElement.java:186) ~[topaddons:1.16.5-2.1.5-beta] {re:classloading}
    at io.github.drmanganese.topaddons.elements.forge.FluidGaugeElement.render(FluidGaugeElement.java:77) ~[topaddons:1.16.5-2.1.5-beta] {re:classloading}
    at mcjty.theoneprobe.apiimpl.elements.ElementVertical.render(ElementVertical.java:54) ~[theoneprobe:1.16-3.1.4] {re:classloading}
    at mcjty.theoneprobe.rendering.OverlayRenderer.renderElements(OverlayRenderer.java:433) ~[theoneprobe:1.16-3.1.4] {re:classloading}
    at mcjty.theoneprobe.rendering.OverlayRenderer.renderHUDBlock(OverlayRenderer.java:279) ~[theoneprobe:1.16-3.1.4] {re:classloading}
    at mcjty.theoneprobe.rendering.OverlayRenderer.renderHUD(OverlayRenderer.java:115) ~[theoneprobe:1.16-3.1.4] {re:classloading}
    at mcjty.theoneprobe.proxy.ClientProxy.renderGameOverlayEvent(ClientProxy.java:110) ~[theoneprobe:1.16-3.1.4] {re:classloading}
    at net.minecraftforge.eventbus.ASMEventHandler_2904_ClientProxy_renderGameOverlayEvent_Pre.invoke(.dynamic) ~[?:?] {}
    at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-4.0.0.jar:?] {}
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-4.0.0.jar:?] {}
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-4.0.0.jar:?] {}
    at net.minecraftforge.client.gui.ForgeIngameGui.renderHUDText(ForgeIngameGui.java:634) ~[forge:?] {re:classloading}
    at net.minecraftforge.client.gui.ForgeIngameGui.func_238445_a_(ForgeIngameGui.java:187) ~[forge:?] {re:classloading}
    at net.minecraft.client.renderer.GameRenderer.func_195458_a(GameRenderer.java:765) ~[?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,xf:OptiFine:default,xf:fml:astralsorcery:reach_set_client_renderer,pl:mixin:APP:flywheel.mixins.json:StoreProjectionMatrixMixin,pl:mixin:APP:flickerfix.mixins.json:MixinGameRenderer,pl:mixin:A}
    at net.minecraft.client.Minecraft.func_195542_b(Minecraft.java:976) ~[?:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,xf:fml:customskinloader:MinecraftTransformer,pl:mixin:APP:randompatches.mixins.json:client.MinecraftMixin,pl:mixin:APP:flywheel.mixins.json:ShaderCloseMixin,pl:mixin:APP:abnormals_core.mixins.json:client.MinecraftMixin,pl:mixin:APP:kubejs-common.mixins.json:MinecraftMixin,pl:mixin:APP:immersiveengineering.mixins.json:accessors.client.MinecraftAccess,pl:mixin:APP:assets/botania/botania.mixins.json:AccessorMinecraft,pl:mixin:APP:mixins.zycraft.json:client.MinecraftMixin,pl:mixin:APP:create.mixins.json:WindowResizeMixin,pl:mixin:A,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:607) ~[?:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,xf:fml:customskinloader:MinecraftTransformer,pl:mixin:APP:randompatches.mixins.json:client.MinecraftMixin,pl:mixin:APP:flywheel.mixins.json:ShaderCloseMixin,pl:mixin:APP:abnormals_core.mixins.json:client.MinecraftMixin,pl:mixin:APP:kubejs-common.mixins.json:MinecraftMixin,pl:mixin:APP:immersiveengineering.mixins.json:accessors.client.MinecraftAccess,pl:mixin:APP:assets/botania/botania.mixins.json:AccessorMinecraft,pl:mixin:APP:mixins.zycraft.json:client.MinecraftMixin,pl:mixin:APP:create.mixins.json:WindowResizeMixin,pl:mixin:A,pl:runtimedistcleaner:A}
    at net.minecraft.client.main.Main.main(Main.java:184) ~[All%20the%20Mods%206.jar:?] {re:classloading,pl:runtimedistcleaner:A}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?] {}
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
    at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?] {}
    at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:51) ~[forge-1.16.5-36.2.4.jar:36.2] {}
    at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.9.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.9.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.9.jar:?] {}
    at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.9.jar:?] {re:classloading}
    at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.9.jar:?] {re:classloading}

This patch may help, but just a temporary fix.

DrManganese commented 2 years ago

Hey @DPurple, apologies for not looking at this sooner.

Your fix would undoubtedly work by preventing any calculations/rendering, but empty space would still be shown in TOP. That's why the check is better performed on the server. There is already a check for capacity > 0, though: https://github.com/DrManganese/TOPAddons/blob/dc0c592713e8bcb28418dc2982b39443e7e10213/src/main/java/io/github/drmanganese/topaddons/addons/forge/tiles/FluidHandlerTileInfo.java#L51

https://github.com/DrManganese/TOPAddons/blob/dc0c592713e8bcb28418dc2982b39443e7e10213/src/main/java/io/github/drmanganese/topaddons/addons/forge/tiles/FluidHandlerTileInfo.java#L97-L99

Do you remember which tile your player was looking at when this crash happened? Maybe that info can help pinpoint the cause of the server/client mismatch.