Botania

Botania

145M Downloads

[bug? suggestion?] add a fallback check for `float progress` inside `RunicAltarBlockEntity.Hud`

Closed this issue · 4 comments

commented

Mod Loader

Forge

Minecraft Version

1.20.1

Botania version

1.20.1-448-FORGE

Modloader version

Forge 47.4.0

Modpack info

in a dev branch, sry :(

The latest.log file

https://gnomebot.dev/paste/mclogs/KCDuYB5

Issue description

not sure the real cause is block update order or some mod interaction: in the modpack the altar left some mana inside after crafted a rune; then when I bare hand right click it for repeating recipe, the progress became num / 0 = Infinity and blew up my computer's memory inside a for-loop in RenderHelper.renderProgressPie


in the log I mixined the function with additional log for debugging and reproduced the procedure last night:

@Mixin(RunicAltarBlockEntity.Hud.class)
public class HookRunicAltar {
    @WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/Optional;ifPresent(Ljava/util/function/Consumer;)V"))
    private static void hookProgress(Optional instance, Consumer<RunicAltarRecipe> action, Operation<Void> original, @Local(argsOnly = true) RunicAltarBlockEntity altar) {
        BotaniaAPI.LOGGER.error("mana: {}; maxMana: {}, progress: {}", altar.getCurrentMana(), altar.manaToGet, (float) altar.getCurrentMana() / (float) altar.manaToGet);
        original.call(instance, action);
    }
}

and it revealed that even before the mana injection, there's a period (from line 8314) that the progress was NaN, but the inner function happened not to mess up; but with initial glitchy mana inside (line 9352) it became Infinity and boom

Steps to reproduce

  1. do some random rune crafting
  2. /data merge block ${coord of runic altar} {mana: 114514}
  3. right click with bare hand
  4. see the memory usage curve ascend to heaven
    well, this procedure is more accurate

Other information

No response

commented

if I made a simple PR for it, would it be accepted? ::)

commented

thx, PRed as #4841

commented

btw I'm still curious why there's a moment the altar has recipe but lacks target mana _(:з」∠)_