Skip to content

Commit

Permalink
added methods for sorting fluid input and output hatches in multiblocks
Browse files Browse the repository at this point in the history
also made it possible to publicly get tile instance from a FluidHandler
instance
  • Loading branch information
Trinsdar committed May 14, 2024
1 parent d5d62e0 commit 3f1209b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,6 +24,7 @@
import java.util.*;

public abstract class FluidHandler<T extends BlockEntityBase & IMachineHandler> implements IMachineHandler, IFluidNode {
@Getter
protected final T tile;
protected final EnumMap<FluidDirection, FluidTanks> tanks = new EnumMap<>(FluidDirection.class);
protected int capacity, pressure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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";
}
Expand All @@ -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();
Expand All @@ -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
Expand Down

0 comments on commit 3f1209b

Please sign in to comment.