Skip to content

Commit

Permalink
made PipeFluidHandlerSidedWrapper use IFluidHandler methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Feb 23, 2025
1 parent 19852b8 commit c9b7bcb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public FluidStack drain(FluidStack fluid, FluidAction action) {
return FluidStack.EMPTY;
}

@NotNull
@Override
public FluidStack drain(int toExtract, FluidAction action) {
if (getOutputTanks() != null){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import muramasa.antimatter.blockentity.pipe.BlockEntityFluidPipe;
import muramasa.antimatter.capability.FluidHandler;
import net.minecraft.core.Direction;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler;
import org.jetbrains.annotations.NotNull;

public class PipeFluidHandlerSidedWrapper extends FluidHandlerSidedWrapper{
Expand All @@ -18,35 +20,34 @@ public PipeFluidHandlerSidedWrapper(FluidHandler<?> fluidHandler, BlockEntityFlu
}

@Override
public long insertFluid(FluidHolder resource, boolean simulate) {
public int fill(FluidStack resource, FluidAction action) {
if (side == null) return 0;
if (coverHandler != null) {
if (coverHandler.get(side).blocksInput(FluidContainer.class, side)) {
if (coverHandler.get(side).blocksInput(IFluidHandler.class, side)) {
return 0;
}
long oldAmount = resource.getFluidAmount();
if(coverHandler.onTransfer(resource, side, true, simulate)) return oldAmount - resource.getFluidAmount();
int oldAmount = resource.getAmount();
if(coverHandler.onTransfer(resource, side, true, action.simulate())) return oldAmount - resource.getAmount();
}

if (!fluidHandler.canInput(resource, side) || !fluidHandler.canInput(side)) {
return 0;
}
int tank = fluidHandler.getInputTanks().getFirstAvailableTank(resource, false);
if (tank == -1) return 0;
long insert = fluidHandler.getInputTanks().getTank(tank).insertFluid(resource, simulate);
if (insert > 0 && !simulate){
int insert = fluidHandler.getInputTanks().getTank(tank).fill(resource, action);
if (insert > 0 && action.execute()){
pipe.setLastSide(side, tank);
}
return insert;
}

@NotNull
@Override
public FluidHolder extractFluid(FluidHolder resource, boolean simulate) {
if (side == null) return FluidHooks.emptyFluid();
if (coverHandler != null && (coverHandler.get(side).blocksOutput(FluidContainer.class, side) || coverHandler.onTransfer(resource, side, false, simulate))) {
return FluidHooks.emptyFluid();
public @NotNull FluidStack drain(FluidStack resource, FluidAction action) {
if (side == null) return FluidStack.EMPTY;
if (coverHandler != null && (coverHandler.get(side).blocksOutput(IFluidHandler.class, side) || coverHandler.onTransfer(resource, side, false, action.simulate()))) {
return FluidStack.EMPTY;
}
return super.extractFluid(resource, simulate);
return super.drain(resource, action);
}
}

0 comments on commit c9b7bcb

Please sign in to comment.