Skip to content

Commit

Permalink
add helper method for array access
Browse files Browse the repository at this point in the history
  • Loading branch information
ghzdude committed Jan 17, 2025
1 parent b7de2a6 commit 6e486e5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ protected void createFuelTooltip(@NotNull RichTooltip tooltip, @NotNull FixedInt
tooltip.addLine(IKey.lang("gregtech.multiblock.large_combustion_engine.fuel_none"));
} else {
tooltip.addLine(
IKey.lang("gregtech.multiblock.large_combustion_engine.fuel_amount", amounts.getValue()[0],
amounts.getValue()[1], fluid.getLocalizedName(new FluidStack(fluid, 1))));
IKey.lang("gregtech.multiblock.large_combustion_engine.fuel_amount", amounts.getValue(0),
amounts.getValue(1), fluid.getLocalizedName(new FluidStack(fluid, 1))));
}
} else {
tooltip.addLine(IKey.lang("gregtech.multiblock.invalid_structure"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,8 @@ public void read(@NotNull PacketBuffer buffer) throws IOException {
public int[] getValue() {
return this.cache;
}

public int getValue(int index) {
return this.cache[index];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ public int getProgressBarCount() {
panelSyncManager.syncValue("fuel_name", fuelNameValue);

yield new ProgressWidget()
.progress(() -> fuelValue.getValue()[1] == 0 ? 0 :
1.0 * fuelValue.getValue()[0] / fuelValue.getValue()[1])
.progress(() -> fuelValue.getValue(1) == 0 ? 0 :
1.0 * fuelValue.getValue(0) / fuelValue.getValue(1))
.texture(GTGuiTextures.PROGRESS_BAR_LCE_FUEL, MultiblockUIFactory.Bars.THIRD_WIDTH)
.tooltip(t -> t.setAutoUpdate(true))
.tooltipBuilder(t -> createFuelTooltip(t, fuelValue, fuelNameValue));
Expand All @@ -315,17 +315,17 @@ yield new ProgressWidget()
panelSyncManager.syncValue("lubricant_amount", lubricantValue);

yield new ProgressWidget()
.progress(() -> lubricantValue.getValue()[1] == 0 ? 0 :
1.0 * lubricantValue.getValue()[0] / lubricantValue.getValue()[1])
.progress(() -> lubricantValue.getValue(1) == 0 ? 0 :
1.0 * lubricantValue.getValue(0) / lubricantValue.getValue(1))
.texture(GTGuiTextures.PROGRESS_BAR_LCE_LUBRICANT, MultiblockUIFactory.Bars.THIRD_WIDTH)
.tooltip(tooltip -> tooltip.setAutoUpdate(true))
.tooltipBuilder(t -> {
if (isStructureFormed()) {
if (lubricantValue.getValue()[0] == 0) {
if (lubricantValue.getValue(0) == 0) {
t.addLine(IKey.lang("gregtech.multiblock.large_combustion_engine.no_lubricant"));
} else {
t.addLine(IKey.lang("gregtech.multiblock.large_combustion_engine.lubricant_amount",
lubricantValue.getValue()[0], lubricantValue.getValue()[1]));
lubricantValue.getValue(0), lubricantValue.getValue(0)));
}
} else {
t.addLine(IKey.lang("gregtech.multiblock.invalid_structure"));
Expand All @@ -339,22 +339,22 @@ yield new ProgressWidget()
panelSyncManager.syncValue("boost_allowed", boostValue);

yield new ProgressWidget()
.progress(() -> oxygenValue.getValue()[1] == 0 ? 0 :
1.0 * oxygenValue.getValue()[0] / oxygenValue.getValue()[1])
.progress(() -> oxygenValue.getValue(1) == 0 ? 0 :
1.0 * oxygenValue.getValue(0) / oxygenValue.getValue(1))
.texture(GTGuiTextures.PROGRESS_BAR_LCE_OXYGEN, MultiblockUIFactory.Bars.THIRD_WIDTH)
.tooltipBuilder(t -> {
t.setAutoUpdate(true);
if (isStructureFormed()) {
if (boostValue.getBoolValue()) {
if (oxygenValue.getValue()[0] == 0) {
if (oxygenValue.getValue(0) == 0) {
t.addLine(IKey.lang("gregtech.multiblock.large_combustion_engine.oxygen_none"));
} else if (isExtreme) {
t.addLine(IKey.lang(
"gregtech.multiblock.large_combustion_engine.liquid_oxygen_amount",
oxygenValue.getValue()[0], oxygenValue.getValue()[1]));
oxygenValue.getValue(0), oxygenValue.getValue(0)));
} else {
t.addLine(IKey.lang("gregtech.multiblock.large_combustion_engine.oxygen_amount",
oxygenValue.getValue()[0], oxygenValue.getValue()[1]));
oxygenValue.getValue(0), oxygenValue.getValue(1)));
}
} else if (isExtreme) {
t.addLine(IKey.lang(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ public int getProgressBarCount() {
panelSyncManager.syncValue("fuel_name", fuelNameValue);

yield new ProgressWidget()
.progress(() -> fuelValue.getValue()[1] == 0 ? 0 :
1.0 * fuelValue.getValue()[0] / fuelValue.getValue()[1])
.progress(() -> fuelValue.getValue(1) == 0 ? 0 :
1.0 * fuelValue.getValue(0) / fuelValue.getValue(1))
.texture(GTGuiTextures.PROGRESS_BAR_LCE_FUEL, MultiblockUIFactory.Bars.THIRD_WIDTH)
.tooltip(t -> t.setAutoUpdate(true))
.tooltipBuilder(t -> createFuelTooltip(t, fuelValue, fuelNameValue));
Expand Down

0 comments on commit 6e486e5

Please sign in to comment.