-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add infinite source/sink capability to creative tanks
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/main/java/com/gregtechceu/gtceu/api/transfer/fluid/InfiniteFluidTransferProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.gregtechceu.gtceu.api.transfer.fluid; | ||
|
||
import com.lowdragmc.lowdraglib.side.fluid.FluidStack; | ||
import com.lowdragmc.lowdraglib.side.fluid.IFluidTransfer; | ||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
@MethodsReturnNonnullByDefault | ||
@ParametersAreNonnullByDefault | ||
public class InfiniteFluidTransferProxy extends FluidTransferDelegate { | ||
private final boolean infiniteSource; | ||
private final boolean infiniteSink; | ||
|
||
public InfiniteFluidTransferProxy(IFluidTransfer delegate, boolean infiniteSource, boolean infiniteSink) { | ||
super(delegate); | ||
|
||
this.infiniteSource = infiniteSource; | ||
this.infiniteSink = infiniteSink; | ||
} | ||
|
||
@Override | ||
public long fill(int tank, FluidStack resource, boolean simulate, boolean notifyChanges) { | ||
if (infiniteSink) | ||
return resource.getAmount(); | ||
|
||
return super.fill(tank, resource, simulate, notifyChanges); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public FluidStack drain(int tank, FluidStack resource, boolean simulate, boolean notifyChanges) { | ||
if (infiniteSource) | ||
return resource.copy(); | ||
|
||
return super.drain(tank, resource, simulate, notifyChanges); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters