2016-06-22 23:49:47 -04:00
|
|
|
/*
|
|
|
|
|
* Minecraft Forge
|
|
|
|
|
* Copyright (c) 2016.
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation version 2.1
|
|
|
|
|
* of the License.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*/
|
|
|
|
|
|
2013-05-23 01:01:19 -04:00
|
|
|
package net.minecraftforge.fluids;
|
|
|
|
|
|
2016-03-01 04:58:03 -08:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2013-05-23 01:01:19 -04:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
2016-12-05 20:17:47 -08:00
|
|
|
import javax.annotation.Nonnull;
|
2017-01-11 15:17:56 -08:00
|
|
|
import javax.annotation.Nullable;
|
2016-12-05 20:17:47 -08:00
|
|
|
|
2013-05-23 01:01:19 -04:00
|
|
|
/**
|
|
|
|
|
* Implement this interface on Block classes which represent world-placeable Fluids.
|
2014-11-25 19:56:35 -08:00
|
|
|
*
|
2013-05-23 01:01:19 -04:00
|
|
|
* NOTE: Using/extending the reference implementations {@link BlockFluidBase} is encouraged.
|
2014-11-25 19:56:35 -08:00
|
|
|
*
|
2013-05-23 01:01:19 -04:00
|
|
|
*/
|
2013-07-16 21:40:49 -07:00
|
|
|
public interface IFluidBlock
|
|
|
|
|
{
|
2013-05-23 01:01:19 -04:00
|
|
|
/**
|
|
|
|
|
* Returns the Fluid associated with this Block.
|
|
|
|
|
*/
|
|
|
|
|
Fluid getFluid();
|
|
|
|
|
|
2016-12-05 20:17:47 -08:00
|
|
|
/**
|
|
|
|
|
* Attempts to place the block at a given position. The placed block's level will correspond
|
|
|
|
|
* to the provided fluid amount.
|
|
|
|
|
* This method should be called by fluid containers such as buckets, but it is recommended
|
|
|
|
|
* to use {@link FluidUtil}.
|
|
|
|
|
*
|
|
|
|
|
* @param world the world to place the block in
|
|
|
|
|
* @param pos the position to place the block at
|
|
|
|
|
* @param fluidStack the fluid stack to get the required data from
|
|
|
|
|
* @param doPlace if false, the placement will only be simulated
|
|
|
|
|
* @return the amount of fluid extracted from the provided stack to achieve some fluid level
|
|
|
|
|
*/
|
|
|
|
|
int place(World world, BlockPos pos, @Nonnull FluidStack fluidStack, boolean doPlace);
|
|
|
|
|
|
2013-05-23 01:01:19 -04:00
|
|
|
/**
|
|
|
|
|
* Attempt to drain the block. This method should be called by devices such as pumps.
|
2014-11-25 19:56:35 -08:00
|
|
|
*
|
2013-05-23 01:01:19 -04:00
|
|
|
* NOTE: The block is intended to handle its own state changes.
|
2014-11-25 19:56:35 -08:00
|
|
|
*
|
2013-05-23 01:01:19 -04:00
|
|
|
* @param doDrain
|
|
|
|
|
* If false, the drain will only be simulated.
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2017-01-11 15:17:56 -08:00
|
|
|
@Nullable
|
2014-11-25 19:56:35 -08:00
|
|
|
FluidStack drain(World world, BlockPos pos, boolean doDrain);
|
2013-05-23 01:01:19 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check to see if a block can be drained. This method should be called by devices such as
|
|
|
|
|
* pumps.
|
2014-11-25 19:56:35 -08:00
|
|
|
*
|
2013-05-23 01:01:19 -04:00
|
|
|
* @return
|
|
|
|
|
*/
|
2014-11-25 19:56:35 -08:00
|
|
|
boolean canDrain(World world, BlockPos pos);
|
2013-08-18 23:16:36 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the amount of a single block is filled. Value between 0 and 1.
|
|
|
|
|
* 1 meaning the entire 1x1x1 cube is full, 0 meaning completely empty.
|
2014-11-25 19:56:35 -08:00
|
|
|
*
|
|
|
|
|
* If the return value is negative. It will be treated as filling the block
|
2013-08-18 23:16:36 -07:00
|
|
|
* from the top down instead of bottom up.
|
2014-11-25 19:56:35 -08:00
|
|
|
*
|
2013-08-18 23:16:36 -07:00
|
|
|
* @return
|
|
|
|
|
*/
|
2014-11-25 19:56:35 -08:00
|
|
|
float getFilledPercentage(World world, BlockPos pos);
|
2016-03-06 16:54:47 -08:00
|
|
|
}
|