
[bug? suggestion?] add a fallback check for `float progress` inside `RunicAltarBlockEntity.Hud`
Closed this issue · 4 comments
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
- do some random rune crafting
- /data merge block ${coord of runic altar} {mana: 114514}
- right click with bare hand
- see the memory usage curve ascend to heaven
well, this procedure is more accurate
Other information
No response
Probably better to just add a check that manaToGet is nonzero here https://github.com/VazkiiMods/Botania/blob/1.20.x/Xplat/src/main/java/vazkii/botania/common/block/block_entity/RunicAltarBlockEntity.java#L406
thx, PRed as #4841