diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamBoilerMachine.java b/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamBoilerMachine.java index 5d57cf31ac..0a33304a85 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamBoilerMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamBoilerMachine.java @@ -291,11 +291,11 @@ public ModularUI createUI(Player entityPlayer) { .setProgressTexture(GuiTextures.PROGRESS_BAR_BOILER_EMPTY.get(isHighPressure), GuiTextures.PROGRESS_BAR_BOILER_HEAT) .setFillDirection(ProgressTexture.FillDirection.DOWN_TO_UP) .setDynamicHoverTips(pct -> I18n.get("gtceu.multiblock.large_boiler.temperature", (int) (currentTemperature + 274.15), (int) (getMaxTemperature() + 274.15)))) - .widget(new TankWidget(waterTank.storages[0], 83, 26, 10, 54, false, true) + .widget(new TankWidget(waterTank.getStorages()[0], 83, 26, 10, 54, false, true) .setShowAmount(false) .setFillDirection(ProgressTexture.FillDirection.DOWN_TO_UP) .setBackground(GuiTextures.PROGRESS_BAR_BOILER_EMPTY.get(isHighPressure))) - .widget(new TankWidget(steamTank.storages[0], 70, 26, 10, 54, true, false) + .widget(new TankWidget(steamTank.getStorages()[0], 70, 26, 10, 54, true, false) .setShowAmount(false) .setFillDirection(ProgressTexture.FillDirection.DOWN_TO_UP) .setBackground(GuiTextures.PROGRESS_BAR_BOILER_EMPTY.get(isHighPressure))) diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableFluidTank.java b/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableFluidTank.java index d4a41ccc43..90f61ca922 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableFluidTank.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableFluidTank.java @@ -36,8 +36,8 @@ public class NotifiableFluidTank extends NotifiableRecipeHandlerTrait storages, IO this.handlerIO = io; this.storages = storages.toArray(FluidStorage[]::new); this.capabilityIO = capabilityIO; - for (FluidStorage storage : this.storages) { + for (FluidStorage storage : this.getStorages()) { storage.setOnContentsChanged(this::onContentsChanged); } if (io == IO.IN) { @@ -148,7 +148,7 @@ public static List handleIngredient(IO io, List filter) { - for (FluidStorage storage : storages) { + for (FluidStorage storage : getStorages()) { storage.setValidator(filter); } return this; @@ -160,7 +160,7 @@ public RecipeCapability getCapability() { } public int getTanks() { - return storages.length; + return getStorages().length; } @Override @@ -183,7 +183,7 @@ public List getContents() { public boolean isEmpty() { if (isEmpty == null) { isEmpty = true; - for (FluidStorage storage : storages) { + for (FluidStorage storage : getStorages()) { if (!storage.getFluid().isEmpty()) { isEmpty = false; break; @@ -216,22 +216,22 @@ public void importFromNearby(@NotNull Direction... facings) { @NotNull @Override public FluidStack getFluidInTank(int tank) { - return storages[tank].getFluid(); + return getStorages()[tank].getFluid(); } @Override public void setFluidInTank(int tank, @NotNull FluidStack fluidStack) { - storages[tank].setFluid(fluidStack); + getStorages()[tank].setFluid(fluidStack); } @Override public long getTankCapacity(int tank) { - return storages[tank].getCapacity(); + return getStorages()[tank].getCapacity(); } @Override public boolean isFluidValid(int tank, @NotNull FluidStack stack) { - return storages[tank].isFluidValid(stack); + return getStorages()[tank].isFluidValid(stack); } @Override @@ -240,7 +240,7 @@ public long fill(FluidStack resource, boolean simulate, boolean notifyChanges) { long filled = 0; FluidStorage existingStorage = null; if (!allowSameFluids) { - for (var storage : storages) { + for (var storage : getStorages()) { if (!storage.getFluid().isEmpty() && storage.getFluid().isFluidEqual(resource)) { existingStorage = storage; break; @@ -266,8 +266,8 @@ public long fill(FluidStack resource, boolean simulate, boolean notifyChanges) { @Override public long fill(int tank, FluidStack resource, boolean simulate, boolean notifyChanges) { - if (tank >= 0 && tank < storages.length && canCapInput()) { - return storages[tank].fill(resource, simulate, notifyChanges); + if (tank >= 0 && tank < getStorages().length && canCapInput()) { + return getStorages()[tank].fill(resource, simulate, notifyChanges); } return 0; } @@ -285,7 +285,7 @@ public long fillInternal(FluidStack resource, boolean simulate) { var copied = resource.copy(); FluidStorage existingStorage = null; if (!allowSameFluids) { - for (var storage : storages) { + for (var storage : getStorages()) { if (!storage.getFluid().isEmpty() && storage.getFluid().isFluidEqual(resource)) { existingStorage = storage; break; @@ -293,7 +293,7 @@ public long fillInternal(FluidStack resource, boolean simulate) { } } if (existingStorage == null) { - for (var storage : storages) { + for (var storage : getStorages()) { var filled = storage.fill(copied.copy(), simulate); if (filled > 0) { copied.shrink(filled); @@ -312,8 +312,8 @@ public long fillInternal(FluidStack resource, boolean simulate) { @NotNull @Override public FluidStack drain(int tank, FluidStack resource, boolean simulate, boolean notifyChanges) { - if (tank >= 0 && tank < storages.length && canCapOutput()) { - return storages[tank].drain(resource, simulate, notifyChanges); + if (tank >= 0 && tank < getStorages().length && canCapOutput()) { + return getStorages()[tank].drain(resource, simulate, notifyChanges); } return FluidStack.empty(); } @@ -330,7 +330,7 @@ public FluidStack drain(FluidStack resource, boolean simulate) { public FluidStack drainInternal(FluidStack resource, boolean simulate) { if (!resource.isEmpty()) { var copied = resource.copy(); - for (var transfer : storages) { + for (var transfer : getStorages()) { var candidate = copied.copy(); copied.shrink(transfer.drain(candidate, simulate).getAmount()); if (copied.isEmpty()) break; @@ -355,7 +355,7 @@ public FluidStack drainInternal(long maxDrain, boolean simulate) { return FluidStack.empty(); } FluidStack totalDrained = null; - for (var storage : storages) { + for (var storage : getStorages()) { if (totalDrained == null || totalDrained.isEmpty()) { totalDrained = storage.drain(maxDrain, simulate); if (totalDrained.isEmpty()) { @@ -389,14 +389,14 @@ public boolean supportsDrain(int i) { @NotNull @Override public Object createSnapshot() { - return Arrays.stream(storages).map(IFluidTransfer::createSnapshot).toArray(Object[]::new); + return Arrays.stream(getStorages()).map(IFluidTransfer::createSnapshot).toArray(Object[]::new); } @Override public void restoreFromSnapshot(Object snapshot) { - if (snapshot instanceof Object[] array && array.length == storages.length) { + if (snapshot instanceof Object[] array && array.length == getStorages().length) { for (int i = 0; i < array.length; i++) { - storages[i].restoreFromSnapshot(array[i]); + getStorages()[i].restoreFromSnapshot(array[i]); } } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/PumpMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/PumpMachine.java index 830f408012..542f98885a 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/PumpMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/PumpMachine.java @@ -255,7 +255,7 @@ public ModularUI createUI(Player entityPlayer) { .widget(new LabelWidget(11, 20, "gtceu.gui.fluid_amount")) .widget(new LabelWidget(11, 30, () -> cache.getFluidInTank(0).getAmount() + "").setTextColor(-1).setDropShadow(true)) .widget(new LabelWidget(6, 6, getBlockState().getBlock().getDescriptionId())) - .widget(new TankWidget(cache.storages[0], 90, 35, true, true) + .widget(new TankWidget(cache.getStorages()[0], 90, 35, true, true) .setBackground(GuiTextures.FLUID_SLOT)) .widget(new ToggleButtonWidget(7, 53, 18, 18, GuiTextures.BUTTON_FLUID_OUTPUT, this::isAutoOutputFluids, this::setAutoOutputFluids) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/FluidHatchPartMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/FluidHatchPartMachine.java index 617bae8677..b049b50301 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/FluidHatchPartMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/FluidHatchPartMachine.java @@ -151,7 +151,7 @@ protected Widget createSingleSlotGUI() { group.addWidget(new ImageWidget(4, 4, 81, 55, GuiTextures.DISPLAY)) .addWidget(new LabelWidget(8, 8, "gtceu.gui.fluid_amount")) .addWidget(new LabelWidget(8, 18, () -> String.valueOf(tank.getFluidInTank(0).getAmount())).setTextColor(-1).setDropShadow(true)) - .addWidget(new TankWidget(tank.storages[0], 67, 22, true, io.support(IO.IN)).setBackground(GuiTextures.FLUID_SLOT)); + .addWidget(new TankWidget(tank.getStorages()[0], 67, 22, true, io.support(IO.IN)).setBackground(GuiTextures.FLUID_SLOT)); group.setBackground(GuiTextures.BACKGROUND_INVERSE); return group; @@ -171,7 +171,7 @@ protected Widget createMultiSlotGUI() { int index = 0; for (int y = 0; y < colSize; y++) { for (int x = 0; x < rowSize; x++) { - container.addWidget(new TankWidget(tank.storages[index++], 4 + x * 18, 4 + y * 18, true, io.support(IO.IN)).setBackground(GuiTextures.FLUID_SLOT)); + container.addWidget(new TankWidget(tank.getStorages()[index++], 4 + x * 18, 4 + y * 18, true, io.support(IO.IN)).setBackground(GuiTextures.FLUID_SLOT)); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/PumpHatchPartMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/PumpHatchPartMachine.java index 90fc3c0187..3776598ccc 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/PumpHatchPartMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/PumpHatchPartMachine.java @@ -38,7 +38,7 @@ public ModularUI createUI(Player entityPlayer) { .widget(new LabelWidget(11, 20, "gtceu.gui.fluid_amount")) .widget(new LabelWidget(11, 30, () -> String.valueOf(tank.getFluidInTank(0).getAmount())).setTextColor(-1).setDropShadow(true)) .widget(new LabelWidget(6, 6, getBlockState().getBlock().getDescriptionId())) - .widget(new TankWidget(tank.storages[0], 90, 35, true, io.support(IO.IN)) + .widget(new TankWidget(tank.getStorages()[0], 90, 35, true, io.support(IO.IN)) .setBackground(GuiTextures.FLUID_SLOT)) .widget(new ToggleButtonWidget(7, 53, 18, 18, GuiTextures.BUTTON_FLUID_OUTPUT, this::isWorkingEnabled, this::setWorkingEnabled) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/SteamHatchPartMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/SteamHatchPartMachine.java index 862e053a6c..e0dd3494c3 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/SteamHatchPartMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/SteamHatchPartMachine.java @@ -47,7 +47,7 @@ public ModularUI createUI(Player entityPlayer) { .widget(new LabelWidget(11, 20, "gtceu.gui.fluid_amount")) .widget(new LabelWidget(11, 30, () -> tank.getFluidInTank(0).getAmount() + "").setTextColor(-1).setDropShadow(true)) .widget(new LabelWidget(6, 6, getBlockState().getBlock().getDescriptionId())) - .widget(new TankWidget(tank.storages[0], 90, 35, true, true) + .widget(new TankWidget(tank.getStorages()[0], 90, 35, true, true) .setBackground(GuiTextures.FLUID_SLOT)) .widget(UITemplate.bindPlayerInventory(entityPlayer.getInventory(), GuiTextures.SLOT_STEAM.get(IS_STEEL), 7, 84, true)); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/CokeOvenMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/CokeOvenMachine.java index 97ac21a3b0..f9ca9b8830 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/CokeOvenMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/CokeOvenMachine.java @@ -44,7 +44,7 @@ public ModularUI createUI(Player entityPlayer) { .widget(new ProgressWidget(recipeLogic::getProgressPercent, 76, 32, 20, 15, GuiTextures.PRIMITIVE_BLAST_FURNACE_PROGRESS_BAR)) .widget(new SlotWidget(exportItems.storage, 0, 103, 30, true, false) .setBackgroundTexture(new GuiTextureGroup(GuiTextures.PRIMITIVE_SLOT, GuiTextures.PRIMITIVE_FURNACE_OVERLAY))) - .widget(new TankWidget(exportFluids.storages[0], 134, 13, 20, 58, true, false) + .widget(new TankWidget(exportFluids.getStorages()[0], 134, 13, 20, 58, true, false) .setBackground(GuiTextures.PRIMITIVE_LARGE_FLUID_TANK) .setOverlay(GuiTextures.PRIMITIVE_LARGE_FLUID_TANK_OVERLAY) .setFillDirection(ProgressTexture.FillDirection.DOWN_TO_UP) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamLiquidBoilerMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamLiquidBoilerMachine.java index d0d83838b5..d4857f5e1a 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamLiquidBoilerMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/steam/SteamLiquidBoilerMachine.java @@ -72,7 +72,7 @@ protected long getBaseSteamOutput() { @Override public ModularUI createUI(Player entityPlayer) { return super.createUI(entityPlayer) - .widget(new TankWidget(fuelTank.storages[0], 119, 26, 10, 54, true, true) + .widget(new TankWidget(fuelTank.getStorages()[0], 119, 26, 10, 54, true, true) .setShowAmount(false) .setFillDirection(ProgressTexture.FillDirection.DOWN_TO_UP) .setBackground(GuiTextures.PROGRESS_BAR_BOILER_EMPTY.get(isHighPressure))); diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeTankMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeTankMachine.java index 1a1d816295..82d58398af 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeTankMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/CreativeTankMachine.java @@ -77,7 +77,7 @@ protected void checkAutoOutput() { @Override public WidgetGroup createUIWidget() { var group = new WidgetGroup(0, 0, 176, 131); - group.addWidget(new PhantomFluidWidget(this.cache.storages[0], 36, 6, 18, 18).setShowAmount(false).setBackground(GuiTextures.FLUID_SLOT)); + group.addWidget(new PhantomFluidWidget(this.cache.getStorages()[0], 36, 6, 18, 18).setShowAmount(false).setBackground(GuiTextures.FLUID_SLOT)); group.addWidget(new LabelWidget(7, 9, "gtceu.creative.tank.fluid")); group.addWidget(new ImageWidget(7, 45, 154, 14, GuiTextures.DISPLAY)); group.addWidget(new TextFieldWidget(9, 47, 152, 10, () -> String.valueOf(mBPerCycle), value -> { @@ -105,12 +105,12 @@ public WidgetGroup createUIWidget() { } public void updateFluidTick() { - if (ticksPerCycle == 0 || getOffsetTimer() % ticksPerCycle != 0 || cache.storages[0].getFluid().isEmpty() || getLevel().isClientSide || !isWorkingEnabled()) + if (ticksPerCycle == 0 || getOffsetTimer() % ticksPerCycle != 0 || cache.getStorages()[0].getFluid().isEmpty() || getLevel().isClientSide || !isWorkingEnabled()) return; IFluidTransfer transfer = FluidTransferHelper.getFluidTransfer(getLevel(), getPos().relative(getOutputFacingFluids()), getOutputFacingFluids().getOpposite()); if (transfer != null) { - FluidStack stack = cache.storages[0].getFluid().copy(); + FluidStack stack = cache.getStorages()[0].getFluid().copy(); stack.setAmount(mBPerCycle); long canInsertAmount = transfer.fill(stack, true); stack.setAmount(Math.min(mBPerCycle, canInsertAmount)); diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/DrumMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/DrumMachine.java index 920b60491d..f8fc3bf4e1 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/DrumMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/DrumMachine.java @@ -130,7 +130,7 @@ public void loadFromItem(CompoundTag tag) { stored = FluidStack.empty(); } // "stored" may not be same as cache (due to item's fluid cap). we should update it. - cache.storages[0].setFluid(stored.copy()); + cache.getStorages()[0].setFluid(stored.copy()); } @Override @@ -192,9 +192,9 @@ public InteractionResult onUse(BlockState state, Level world, BlockPos pos, Play var currentStack = player.getMainHandItem(); if (!currentStack.isEmpty()) { var handler = FluidTransferHelper.getFluidTransfer(player, InteractionHand.MAIN_HAND); - var fluidTank = cache.storages[0]; + var fluidTank = cache.getStorages()[0]; if (handler != null && !isRemote()) { - if (cache.storages[0].getFluidAmount() > 0) { + if (cache.getStorages()[0].getFluidAmount() > 0) { FluidStack initialFluid = fluidTank.getFluid(); FluidActionResult result = FluidTransferHelper.tryFillContainer(currentStack, fluidTank, Integer.MAX_VALUE, null, false); if (result.isSuccess()) { diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumTankMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumTankMachine.java index 35e3ef4dfb..4942f478b2 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumTankMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumTankMachine.java @@ -221,9 +221,9 @@ public InteractionResult onUse(BlockState state, Level world, BlockPos pos, Play var currentStack = player.getMainHandItem(); if (hit.getDirection() == getFrontFacing() && !currentStack.isEmpty()) { var handler = FluidTransferHelper.getFluidTransfer(player, InteractionHand.MAIN_HAND); - var fluidTank = cache.storages[0]; + var fluidTank = cache.getStorages()[0]; if (handler != null && !isRemote()) { - if (cache.storages[0].getFluidAmount() > 0) { + if (cache.getStorages()[0].getFluidAmount() > 0) { FluidStack initialFluid = fluidTank.getFluid(); FluidActionResult result = FluidTransferHelper.tryFillContainer(currentStack, fluidTank, Integer.MAX_VALUE, null, false); if (result.isSuccess()) { @@ -316,7 +316,7 @@ public Widget createUIWidget() { .addWidget(new LabelWidget(8, 18, () -> String.valueOf(cache.getFluidInTank(0).getAmount() / (FluidHelper.getBucket() / 1000)) ).setTextColor(-1).setDropShadow(true)) - .addWidget(new TankWidget(cache.storages[0], 68, 23, true, true) + .addWidget(new TankWidget(cache.getStorages()[0], 68, 23, true, true) .setBackground(GuiTextures.FLUID_SLOT)) .addWidget(new PhantomFluidWidget(lockedFluid, 68, 41, 18, 18) .setShowAmount(false) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/ae2/GTAEMachines.java b/src/main/java/com/gregtechceu/gtceu/integration/ae2/GTAEMachines.java index 5fd5279dee..1da255e297 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/ae2/GTAEMachines.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/ae2/GTAEMachines.java @@ -6,6 +6,7 @@ import com.gregtechceu.gtceu.integration.ae2.machine.*; import net.minecraft.network.chat.Component; +import static com.gregtechceu.gtceu.api.GTValues.EV; import static com.gregtechceu.gtceu.api.GTValues.UHV; import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; @@ -14,7 +15,7 @@ public class GTAEMachines { public final static MachineDefinition ITEM_IMPORT_BUS = REGISTRATE.machine("me_input_bus", MEInputBusPartMachine::new) .langValue("ME Stocking Input Bus") - .tier(UHV) + .tier(EV) .rotationState(RotationState.ALL) .abilities(PartAbility.IMPORT_ITEMS) .overlayTieredHullRenderer("me_item_bus.import") @@ -24,7 +25,7 @@ public class GTAEMachines { public final static MachineDefinition ITEM_EXPORT_BUS = REGISTRATE.machine("me_output_bus", MEOutputBusPartMachine::new) .langValue("ME Output Bus") - .tier(UHV) + .tier(EV) .rotationState(RotationState.ALL) .abilities(PartAbility.IMPORT_ITEMS) .overlayTieredHullRenderer("me_item_bus.export") @@ -37,7 +38,7 @@ public class GTAEMachines { public final static MachineDefinition FLUID_IMPORT_HATCH = REGISTRATE.machine("me_input_hatch", MEInputHatchPartMachine::new) .langValue("ME Stocking Input Hatch") - .tier(UHV) + .tier(EV) .rotationState(RotationState.ALL) .abilities(PartAbility.IMPORT_FLUIDS) .overlayTieredHullRenderer("me_fluid_hatch.import") @@ -47,7 +48,7 @@ public class GTAEMachines { public final static MachineDefinition FLUID_EXPORT_HATCH = REGISTRATE.machine("me_output_hatch", MEOutputHatchPartMachine::new) .langValue("ME Output Hatch") - .tier(UHV) + .tier(EV) .rotationState(RotationState.ALL) .abilities(PartAbility.EXPORT_FLUIDS) .overlayTieredHullRenderer("me_fluid_hatch.export") diff --git a/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/widget/AEConfigWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/widget/AEConfigWidget.java index 018802380c..23b091b85f 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/widget/AEConfigWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/widget/AEConfigWidget.java @@ -25,7 +25,7 @@ public AEConfigWidget(int x, int y, IConfigurableSlot[] config) { super(new Position(x, y), new Size(config.length / 2 * 18, 18 * 4 + 2)); this.config = config; this.init(); - this.amountSetWidget = new AmountSetSlot(80, -40, this); + this.amountSetWidget = new AmountSetSlot(31, -50, this); this.addWidget(this.amountSetWidget); this.addWidget(this.amountSetWidget.getAmountText()); this.amountSetWidget.setVisible(false); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/widget/AEItemGridWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/widget/AEItemGridWidget.java index f280d2645c..435f8c000f 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/widget/AEItemGridWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/widget/AEItemGridWidget.java @@ -65,6 +65,9 @@ protected void writeListChange() { GenericStack cachedItem = this.cached.getStack(j); if (item.what().matches(cachedItem) && cachedItem.amount() != item.amount()) { this.changeMap.put(ExportOnlyAESlot.copy(item), item.amount() - cachedItem.amount()); + if(item.amount() - cachedItem.amount() <= 0) { + this.cached.extract(j, item.what(), item.amount(), Actionable.MODULATE); + } this.cached.insert(j, item.what(), item.amount() - cachedItem.amount(), Actionable.MODULATE); matched = true; break; diff --git a/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEInputHatchPartMachine.java b/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEInputHatchPartMachine.java index c47a875497..0020932529 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEInputHatchPartMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/ae2/machine/MEInputHatchPartMachine.java @@ -6,6 +6,8 @@ import appeng.api.stacks.GenericStack; import appeng.api.storage.MEStorage; import appeng.me.helpers.IGridConnectedBlockEntity; +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; import com.gregtechceu.gtceu.api.machine.MetaMachine; @@ -25,6 +27,8 @@ import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder; import com.lowdragmc.lowdraglib.utils.Position; import com.mojang.datafixers.util.Pair; +import net.minecraft.network.chat.Component; +import net.minecraftforge.server.command.TextComponentHelper; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -60,11 +64,17 @@ public Widget createUIWidget() { "gtceu.gui.me_network.offline")); // Config slots - group.addWidget(new AEFluidConfigWidget(3, 10, this.aeFluidTanks.tanks)); + group.addWidget(new AEFluidConfigWidget(3, 0, this.aeFluidTanks.tanks)); return group; } + @Override + public void onLoad() { + super.onLoad(); + tankSubs = this.aeFluidTanks.addChangedListener(this::updateTankSubscription); + } + @Override protected void autoIO() { if (getLevel().isClientSide) return; @@ -109,6 +119,8 @@ public static class ExportOnlyAEFluidList extends NotifiableFluidTank { @Persisted private final ExportOnlyAEFluid[] tanks; + private FluidStorage[] fluidStorages; + public ExportOnlyAEFluidList(MetaMachine machine, int slots, long capacity, IO io) { super(machine, slots, capacity, io); @@ -117,6 +129,17 @@ public ExportOnlyAEFluidList(MetaMachine machine, int slots, long capacity, IO i this.tanks[i] = new ExportOnlyAEFluid(null, null); this.tanks[i].setOnContentsChanged(this::onContentsChanged); } + this.fluidStorages = null; + } + + @Override + public FluidStorage[] getStorages() { + if(this.fluidStorages == null) { + this.fluidStorages = Arrays.stream(this.tanks).map(tank -> new WrappingFluidStorage(tank.getCapacity(), tank)).toArray(FluidStorage[]::new); + return this.fluidStorages; + } else { + return this.fluidStorages; + } } @Override @@ -126,7 +149,7 @@ public long fill(int tank, FluidStack resource, boolean simulate, boolean notify @Override public List handleRecipeInner(IO io, GTRecipe recipe, List left, @Nullable String slotName, boolean simulate) { - return handleIngredient(io, left, simulate, this.handlerIO, Arrays.stream(this.tanks).map(tank -> new WrappingFluidStorage(tank.getCapacity(), tank)).toArray(FluidStorage[]::new)); + return handleIngredient(io, left, simulate, this.handlerIO, getStorages()); } public FluidStack drainInternal(long maxDrain, boolean simulate) { @@ -217,7 +240,6 @@ public static class ExportOnlyAEFluid extends ExportOnlyAESlot implements IFluid public ExportOnlyAEFluid(GenericStack config, GenericStack stock) { super(config, stock); - //this.setOnContentsChanged(holder::onChanged); } public ExportOnlyAEFluid() { @@ -231,7 +253,7 @@ public void addStack(GenericStack stack) { } else { this.stock = GenericStack.sum(this.stock, stack); } - trigger(); + onContentsChanged(); } @Override @@ -312,7 +334,7 @@ public FluidStack drain(long maxDrain, boolean simulate, boolean notifyChanges) if (this.stock.amount() == 0) { this.stock = null; } - if (notifyChanges) trigger(); + if (notifyChanges) onContentsChanged(); } return result; } @@ -331,7 +353,8 @@ public void restoreFromSnapshot(Object snapshot) { } } - private void trigger() { + @Override + public void onContentsChanged() { if (onContentsChanged != null) { onContentsChanged.run(); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/ae2/util/AmountSetSlot.java b/src/main/java/com/gregtechceu/gtceu/integration/ae2/util/AmountSetSlot.java index 7afafa30eb..ddefb2b913 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/ae2/util/AmountSetSlot.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/ae2/util/AmountSetSlot.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.integration.ae2.util; import appeng.api.stacks.GenericStack; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.api.gui.widget.LongInputWidget; import com.gregtechceu.gtceu.integration.ae2.gui.widget.AEConfigWidget; @@ -8,6 +9,7 @@ import com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget; import com.lowdragmc.lowdraglib.gui.widget.Widget; import com.lowdragmc.lowdraglib.utils.Position; +import io.netty.buffer.Unpooled; import lombok.Getter; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.FriendlyByteBuf; @@ -30,7 +32,7 @@ public class AmountSetSlot extends Widget { public AmountSetSlot(int x, int y, AEConfigWidget widget) { super(x, y, 80, 30); this.parentWidget = widget; - this.amountText = new TextFieldWidget(x + 3, y + 14, 60, 15, this::getAmountStr, this::setNewAmount) + this.amountText = new TextFieldWidget(x + 3, y + 12, 65, 13, this::getAmountStr, this::setNewAmount) .setNumbersOnly(0, Integer.MAX_VALUE) .setMaxStringLength(10); } @@ -45,6 +47,9 @@ public String getAmountStr() { return "0"; } IConfigurableSlot slot = this.parentWidget.getConfig(this.index); + if(slot.getConfig() != null && slot.getConfig().amount() > 1000) { + return "1000"; + } if (slot.getConfig() != null) { return String.valueOf(slot.getConfig().amount()); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/ae2/util/ExportOnlyAESlot.java b/src/main/java/com/gregtechceu/gtceu/integration/ae2/util/ExportOnlyAESlot.java index 347b1d66e5..e04c385d9c 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/ae2/util/ExportOnlyAESlot.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/ae2/util/ExportOnlyAESlot.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.integration.ae2.util; import appeng.api.stacks.GenericStack; +import com.gregtechceu.gtceu.GTCEu; import com.lowdragmc.lowdraglib.syncdata.IContentChangeAware; import com.lowdragmc.lowdraglib.syncdata.ITagSerializable; import lombok.Getter; @@ -21,7 +22,9 @@ public abstract class ExportOnlyAESlot implements IConfigurableSlot, ITagSeriali @Getter @Setter protected Runnable onContentsChanged = () -> {}; + @Getter @Setter protected GenericStack config; + @Getter @Setter protected GenericStack stock; public ExportOnlyAESlot(GenericStack config, GenericStack stock) { @@ -44,7 +47,7 @@ public GenericStack requestStack() { if (this.stock == null) { return copy(this.config); } - if (this.stock.amount() < this.config.amount()) { + if (this.stock.amount() <= this.config.amount()) { return copy(this.config, this.config.amount() - this.stock.amount()); } return null; @@ -96,26 +99,6 @@ public void deserializeNBT(CompoundTag tag) { } - @Override - public GenericStack getConfig() { - return this.config; - } - - @Override - public GenericStack getStock() { - return this.stock; - } - - @Override - public void setConfig(GenericStack val) { - this.config = val; - } - - @Override - public void setStock(GenericStack val) { - this.stock = val; - } - public static GenericStack copy(GenericStack stack) { return new GenericStack(stack.what(), stack.amount()); } diff --git a/src/main/java/com/gregtechceu/gtceu/utils/OverlayingFluidStorage.java b/src/main/java/com/gregtechceu/gtceu/utils/OverlayingFluidStorage.java index 5fab1256bc..2509084c62 100644 --- a/src/main/java/com/gregtechceu/gtceu/utils/OverlayingFluidStorage.java +++ b/src/main/java/com/gregtechceu/gtceu/utils/OverlayingFluidStorage.java @@ -41,7 +41,7 @@ public boolean isFluidValid(FluidStack stack) { @Override public long fill(int tank, FluidStack resource, boolean simulate, boolean notifyChanges) { if (transfer instanceof NotifiableFluidTank notifiable) { - return notifiable.storages[this.tank].fill(resource, simulate, notifyChanges); + return notifiable.getStorages()[this.tank].fill(resource, simulate, notifyChanges); } return transfer.fill(this.tank, resource, simulate, notifyChanges); } @@ -55,7 +55,7 @@ public boolean supportsFill(int tank) { @Override public FluidStack drain(int tank, FluidStack resource, boolean simulate, boolean notifyChanges) { if (transfer instanceof NotifiableFluidTank notifiable) { - return notifiable.storages[this.tank].drain(resource, simulate, notifyChanges); + return notifiable.getStorages()[this.tank].drain(resource, simulate, notifyChanges); } return transfer.drain(this.tank, resource, simulate, notifyChanges); }