Fluid API rework (#5983)

- Moved forge fluids into FluidAttributes companion object to the vanilla Fluid. By gigaherz
- Redesigned the Fluid API to be closer to the Items API. By King Lemming
Co-authored-by: King Lemming <[email protected]>
This commit is contained in:
David Quintana committed 2019-08-29 03:18:41 +02:00
1 parent e784a7f606
commit b7e1cc5f6b
48 files changed
+1077 -2193

No files matched your search

@@ -19,15 +19,17 @@
package net.minecraftforge.fluids;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
import javax.annotation.Nullable;
/**
* A tank is the unit of interaction with Fluid inventories.
*
* A reference implementation can be found at {@link FluidTank}.
* This interface represents a Fluid Tank. IT IS NOT REQUIRED but is provided for convenience.
* You are free to handle Fluids in any way that you wish - this is simply an easy default way.
* DO NOT ASSUME that these objects are used internally in all cases.
*/
public interface IFluidTank
{
public interface IFluidTank {
/**
* @return FluidStack representing the fluid in the tank, null if the tank is empty.
*/
@@ -45,33 +47,32 @@ public interface IFluidTank
int getCapacity();
/**
* Returns a wrapper object {@link FluidTankInfo } containing the capacity of the tank and the
* FluidStack it holds.
*
* Should prevent manipulation of the IFluidTank. See {@link FluidTank}.
*
* @return State information for the IFluidTank.
* @param stack Fluidstack holding the Fluid to be queried.
* @return If the tank can hold the fluid (EVER, not at the time of query).
*/
FluidTankInfo getInfo();
boolean isFluidValid(FluidStack stack);
/**
*
* @param resource
* FluidStack attempting to fill the tank.
* @param doFill
* If false, the fill will only be simulated.
* @return Amount of fluid that was accepted by the tank.
* @param resource FluidStack attempting to fill the tank.
* @param action If SIMULATE, the fill will only be simulated.
* @return Amount of fluid that was accepted (or would be, if simulated) by the tank.
*/
int fill(FluidStack resource, boolean doFill);
int fill(FluidStack resource, FluidAction action);
/**
*
* @param maxDrain
* Maximum amount of fluid to be removed from the container.
* @param doDrain
* If false, the drain will only be simulated.
* @return Amount of fluid that was removed from the tank.
* @param maxDrain Maximum amount of fluid to be removed from the container.
* @param action If SIMULATE, the drain will only be simulated.
* @return Amount of fluid that was removed (or would be, if simulated) from the tank.
*/
@Nullable
FluidStack drain(int maxDrain, boolean doDrain);
FluidStack drain(int maxDrain, FluidAction action);
/**
* @param resource Maximum amount of fluid to be removed from the container.
* @param action If SIMULATE, the drain will only be simulated.
* @return FluidStack representing fluid that was removed (or would be, if simulated) from the tank.
*/
@Nullable
FluidStack drain(FluidStack resource, FluidAction action);
}