From 3f1209b9e0c322e52ed14f3c06a2b7730b408ea0 Mon Sep 17 00:00:00 2001 From: trinsdar <30245301+Trinsdar@users.noreply.github.com> Date: Tue, 14 May 2024 19:02:58 -0400 Subject: [PATCH] added methods for sorting fluid input and output hatches in multiblocks also made it possible to publicly get tile instance from a FluidHandler instance --- .../muramasa/antimatter/capability/FluidHandler.java | 2 ++ .../capability/machine/MultiMachineFluidHandler.java | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/muramasa/antimatter/capability/FluidHandler.java b/common/src/main/java/muramasa/antimatter/capability/FluidHandler.java index f478de24e..011047dc1 100644 --- a/common/src/main/java/muramasa/antimatter/capability/FluidHandler.java +++ b/common/src/main/java/muramasa/antimatter/capability/FluidHandler.java @@ -5,6 +5,7 @@ import earth.terrarium.botarium.common.fluid.base.FluidSnapshot; import earth.terrarium.botarium.common.fluid.utils.FluidHooks; import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import lombok.Getter; import muramasa.antimatter.capability.fluid.FluidTank; import muramasa.antimatter.capability.fluid.FluidTanks; import muramasa.antimatter.gui.SlotType; @@ -23,6 +24,7 @@ import java.util.*; public abstract class FluidHandler implements IMachineHandler, IFluidNode { + @Getter protected final T tile; protected final EnumMap tanks = new EnumMap<>(FluidDirection.class); protected int capacity, pressure; diff --git a/common/src/main/java/muramasa/antimatter/capability/machine/MultiMachineFluidHandler.java b/common/src/main/java/muramasa/antimatter/capability/machine/MultiMachineFluidHandler.java index 8b49fd729..dcf872fcd 100644 --- a/common/src/main/java/muramasa/antimatter/capability/machine/MultiMachineFluidHandler.java +++ b/common/src/main/java/muramasa/antimatter/capability/machine/MultiMachineFluidHandler.java @@ -64,7 +64,7 @@ public boolean canOutputsFit(FluidHolder[] outputs) { } protected void cacheInputs() { - inputs = tile.getComponentsByHandlerId(inputComponentString()).stream().map(IComponentHandler::getFluidHandler).map(Optional::get).toArray(MachineFluidHandler[]::new);//this::allocateExtraSize); + inputs = tile.getComponentsByHandlerId(inputComponentString()).stream().map(IComponentHandler::getFluidHandler).map(Optional::get).sorted(this::compareInputHatches).toArray(MachineFluidHandler[]::new);//this::allocateExtraSize); // handlers[handlers.length-1] = this.inputWrapper; INPUT_TO_HANDLER.clear(); INPUT_START.clear(); @@ -79,6 +79,10 @@ protected void cacheInputs() { INPUT_END = i; } + protected int compareInputHatches(MachineFluidHandler a, MachineFluidHandler b) { + return 0; + } + protected String inputComponentString(){ return "fluid_input"; } @@ -88,7 +92,7 @@ protected String outputComponentString(){ } protected void cacheOutputs() { - outputs = tile.getComponentsByHandlerId(outputComponentString()).stream().map(IComponentHandler::getFluidHandler).map(Optional::get).toArray(MachineFluidHandler[]::new);//this::allocateExtraSize); + outputs = tile.getComponentsByHandlerId(outputComponentString()).stream().map(IComponentHandler::getFluidHandler).map(Optional::get).sorted(this::compareOutputHatches).toArray(MachineFluidHandler[]::new);//this::allocateExtraSize); // handlers[handlers.length-1] = this.inputWrapper; OUTPUT_TO_HANDLER.clear(); OUTPUT_START.clear(); @@ -102,6 +106,10 @@ protected void cacheOutputs() { } } + protected int compareOutputHatches(MachineFluidHandler a, MachineFluidHandler b) { + return 0; + } + //TODO: Remove gettanks() != null as this is called twice. @Nullable @Override