1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-23 09:57:39 +00:00
Files
CC-Tweaked/src/main/java/dan200/computercraft/shared/util/WaterloggableHelpers.java
SquidDev 46595e73df Initial update to Minecraft 1.16.1
A lot is broken, but at least we can get in game:
 - GUIs render a whole bunch of additional "inventory" text, which we
   really don't want.
 - Computers load from the wrong location.
 - There's some issues with using Forge's tags from outside of JSON
   recipes. We need to work out why.
2020-07-11 20:36:10 +01:00

62 lines
2.1 KiB
Java

/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.shared.util;
import net.minecraft.block.BlockState;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
/**
* Represents a block which can be filled with water
*
* I'm fairly sure this exists on 1.14, but it's a useful convenience wrapper to have on 1.13.
*/
public final class WaterloggableHelpers
{
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
private WaterloggableHelpers()
{
}
/**
* Call from {@link net.minecraft.block.Block#getFluidState(BlockState)}.
*
* @param state The current state
* @return This waterlogged block's current fluid
*/
public static FluidState getWaterloggedFluidState( BlockState state )
{
return state.get( WATERLOGGED ) ? Fluids.WATER.getStillFluidState( false ) : Fluids.EMPTY.getDefaultState();
}
/**
* Call from {@link net.minecraft.block.Block#updatePostPlacement(BlockState, Direction, BlockState, IWorld, BlockPos, BlockPos)}.
*
* @param state The current state
* @param world The position of this block
* @param pos The world this block exists in
*/
public static void updateWaterloggedPostPlacement( BlockState state, IWorld world, BlockPos pos )
{
if( state.get( WATERLOGGED ) )
{
world.getPendingFluidTicks().scheduleTick( pos, Fluids.WATER, Fluids.WATER.getTickRate( world ) );
}
}
public static boolean getWaterloggedStateForPlacement( BlockItemUseContext context )
{
return context.getWorld().getFluidState( context.getPos() ).getFluid() == Fluids.WATER;
}
}