Skip to content

Commit

Permalink
try to fix power bar issue but failed. #33
Browse files Browse the repository at this point in the history
  • Loading branch information
liplum committed Dec 22, 2023
1 parent 4459629 commit dab2917
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions lib/src/multicraft/MultiCrafter.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ public void setCurRecipeIndexFromRemote(int index) {
curRecipeIndex = newIndex;
createEffect(changeRecipeEffect);
craftingTime = 0f;
if (!Vars.headless) rebuildHoveredInfo();
if (!Vars.headless) {
rebuildHoveredInfo();
}
}
}

Expand Down Expand Up @@ -300,7 +302,8 @@ public void updateTile() {

public void updateBars() {
barMap.clear();
setBars();
// TODO: Maybe passed hovered building?
setBars(this);
}

@Override
Expand Down Expand Up @@ -673,26 +676,31 @@ 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,
b::progress
));
}

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;
Expand Down

0 comments on commit dab2917

Please sign in to comment.