From 6e486e59ec833ef4c01551a84eb605a51e9fcde7 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Fri, 17 Jan 2025 16:55:19 -0700 Subject: [PATCH] add helper method for array access --- .../multiblock/FuelMultiblockController.java | 4 ++-- .../api/mui/sync/FixedIntArraySyncValue.java | 4 ++++ .../MetaTileEntityLargeCombustionEngine.java | 22 +++++++++---------- .../generator/MetaTileEntityLargeTurbine.java | 4 ++-- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/multiblock/FuelMultiblockController.java b/src/main/java/gregtech/api/metatileentity/multiblock/FuelMultiblockController.java index 7bdcd5b0164..c64ea1949e6 100644 --- a/src/main/java/gregtech/api/metatileentity/multiblock/FuelMultiblockController.java +++ b/src/main/java/gregtech/api/metatileentity/multiblock/FuelMultiblockController.java @@ -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")); diff --git a/src/main/java/gregtech/api/mui/sync/FixedIntArraySyncValue.java b/src/main/java/gregtech/api/mui/sync/FixedIntArraySyncValue.java index 461864ac8a7..c3f29ee80b5 100644 --- a/src/main/java/gregtech/api/mui/sync/FixedIntArraySyncValue.java +++ b/src/main/java/gregtech/api/mui/sync/FixedIntArraySyncValue.java @@ -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]; + } } diff --git a/src/main/java/gregtech/common/metatileentities/multi/electric/generator/MetaTileEntityLargeCombustionEngine.java b/src/main/java/gregtech/common/metatileentities/multi/electric/generator/MetaTileEntityLargeCombustionEngine.java index 0d462391aa0..668ab77aa91 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/electric/generator/MetaTileEntityLargeCombustionEngine.java +++ b/src/main/java/gregtech/common/metatileentities/multi/electric/generator/MetaTileEntityLargeCombustionEngine.java @@ -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)); @@ -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")); @@ -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( diff --git a/src/main/java/gregtech/common/metatileentities/multi/electric/generator/MetaTileEntityLargeTurbine.java b/src/main/java/gregtech/common/metatileentities/multi/electric/generator/MetaTileEntityLargeTurbine.java index 697fa63c22e..69ebfe807af 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/electric/generator/MetaTileEntityLargeTurbine.java +++ b/src/main/java/gregtech/common/metatileentities/multi/electric/generator/MetaTileEntityLargeTurbine.java @@ -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));