Allows custom blocks to define if they should use the fluid overlay instead of the flowing texture when in a fluid (#6493)

This commit is contained in:
Richard Freimer authored and GitHub committed 2020-02-06 23:53:37 +01:00
1 parent 982ed69776
commit f93289e01c
3 files changed
+35 -6

No files matched your search

@@ -35,6 +35,7 @@ import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.IBeaconBeamColorProvider;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.SoundType;
import net.minecraft.block.StainedGlassBlock;
import net.minecraft.block.material.Material;
import net.minecraft.block.BlockState;
import net.minecraft.client.particle.ParticleManager;
@@ -1054,4 +1055,18 @@ public interface IForgeBlock
{
return getBlock().isIn(BlockTags.FENCES) || getBlock().isIn(BlockTags.WALLS) || getBlock() instanceof FenceGateBlock;
}
/**
* Called to determine whether this block should use the fluid overlay texture or flowing texture when it is placed under the fluid.
*
* @param state The current state
* @param world The world
* @param pos Block position in world
* @param fluidState The state of the fluid
* @return Whether the fluid overlay texture should be used
*/
default boolean shouldDisplayFluidOverlay(BlockState state, ILightReader world, BlockPos pos, IFluidState fluidState)
{
return state.getBlock() == Blocks.GLASS || state.getBlock() instanceof StainedGlassBlock;
}
}
@@ -898,4 +898,17 @@ public interface IForgeBlockState
{
return getBlockState().getBlock().collisionExtendsVertically(getBlockState(), world, pos, collidingEntity);
}
/**
* Called to determine whether this block should use the fluid overlay texture or flowing texture when it is placed under the fluid.
*
* @param world The world
* @param pos Block position in world
* @param fluidState The state of the fluid
* @return Whether the fluid overlay texture should be used
*/
default boolean shouldDisplayFluidOverlay(ILightReader world, BlockPos pos, IFluidState fluidState)
{
return getBlockState().getBlock().shouldDisplayFluidOverlay(getBlockState(), world, pos, fluidState);
}
}