From dab2917e2544f38915ad34fc16c29e2da65f549d Mon Sep 17 00:00:00 2001 From: Liplum Date: Sat, 23 Dec 2023 05:21:21 +0800 Subject: [PATCH] try to fix power bar issue but failed. #33 --- lib/src/multicraft/MultiCrafter.java | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/src/multicraft/MultiCrafter.java b/lib/src/multicraft/MultiCrafter.java index 5633dc7..c06bad8 100644 --- a/lib/src/multicraft/MultiCrafter.java +++ b/lib/src/multicraft/MultiCrafter.java @@ -202,7 +202,9 @@ public void setCurRecipeIndexFromRemote(int index) { curRecipeIndex = newIndex; createEffect(changeRecipeEffect); craftingTime = 0f; - if (!Vars.headless) rebuildHoveredInfo(); + if (!Vars.headless) { + rebuildHoveredInfo(); + } } } @@ -300,7 +302,8 @@ public void updateTile() { public void updateBars() { barMap.clear(); - setBars(); + // TODO: Maybe passed hovered building? + setBars(this); } @Override @@ -673,19 +676,13 @@ protected void buildIOEntry(Table table, Recipe recipe, boolean isInput) { @Override public void setBars() { super.setBars(); - - if (hasPower) - addBar("power", (MultiCrafterBuild b) -> new Bar( - b.getCurRecipe().isOutputPower() ? Core.bundle.format("bar.poweroutput", Strings.fixed(b.getPowerProduction() * 60f * b.timeScale(), 1)) : "bar.power", - Pal.powerBar, - () -> b.efficiency - )); - if (isConsumeHeat || isOutputHeat) + if (isConsumeHeat || isOutputHeat) { addBar("heat", (MultiCrafterBuild b) -> new Bar( b.getCurRecipe().isConsumeHeat() ? Core.bundle.format("bar.heatpercent", (int) (b.heat + 0.01f), (int) (b.efficiencyScale() * 100 + 0.01f)) : "bar.heat", Pal.lightOrange, b::heatFrac )); + } addBar("progress", (MultiCrafterBuild b) -> new Bar( "bar.loadprogress", Pal.accent, @@ -693,6 +690,17 @@ public void setBars() { )); } + public void setBars(MultiCrafterBuild build){ + setBars(); + if (hasPower && build.getCurRecipe().isConsumePower()) { + addBar("power", (MultiCrafterBuild b) -> new Bar( + b.getCurRecipe().isOutputPower() ? Core.bundle.format("bar.poweroutput", Strings.fixed(b.getPowerProduction() * 60f * b.timeScale(), 1)) : "bar.power", + Pal.powerBar, + () -> b.efficiency + )); + } + } + @Override public boolean rotatedOutput(int x, int y) { return false;