diff --git a/src/main/java/xyz/nearmisses/patience/mc_rebalance/PlushBlock.java b/src/main/java/xyz/nearmisses/patience/mc_rebalance/PlushBlock.java index 9dbb22d..99ccac9 100644 --- a/src/main/java/xyz/nearmisses/patience/mc_rebalance/PlushBlock.java +++ b/src/main/java/xyz/nearmisses/patience/mc_rebalance/PlushBlock.java @@ -18,41 +18,51 @@ import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; public class PlushBlock extends Block implements SimpleWaterloggedBlock { - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + // tfw you can copy-paste the class across modloaders :) public PlushBlock(Block.Properties properties) { super(properties.noOcclusion().sound(SoundType.WOOL)); - this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, false)); + this.registerDefaultState(this.stateDefinition.any() + .setValue(FACING, Direction.NORTH) + .setValue(WATERLOGGED, false) + ); } public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(FACING, WATERLOGGED); } + @Override // New collision box + public @NotNull VoxelShape getShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) { + return Block.box(3.0, 0.0, 3.0, 13.0, 15.0, 13.0); + } + + // Water functions @Override - public FluidState getFluidState(BlockState blockState) { + public @NotNull FluidState getFluidState(BlockState blockState) { return blockState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(blockState); } @Override - public BlockState getStateForPlacement(BlockPlaceContext context) { - BlockPos blockPos = context.getClickedPos(); - FluidState fluidState = context.getLevel().getFluidState(blockPos); - return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()).setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER); - } - @Override - public VoxelShape getShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) { - return Block.box(3.0, 0.0, 3.0, 13.0, 15.0, 13.0); - } - @Override - public BlockState updateShape(BlockState blockState, Direction direction, BlockState blockState2, LevelAccessor levelAccessor, BlockPos blockPos, BlockPos blockPos2) { - if ((Boolean)blockState.getValue(WATERLOGGED)) { + public @NotNull BlockState updateShape(BlockState blockState, Direction direction, BlockState blockState2, LevelAccessor levelAccessor, BlockPos blockPos, BlockPos blockPos2) { + if (blockState.getValue(WATERLOGGED)) { levelAccessor.scheduleTick(blockPos, Fluids.WATER, Fluids.WATER.getTickDelay(levelAccessor)); } return super.updateShape(blockState, direction, blockState2, levelAccessor, blockPos, blockPos2); } + + @Override + public BlockState getStateForPlacement(BlockPlaceContext context) { + BlockPos blockPos = context.getClickedPos(); + FluidState fluidState = context.getLevel().getFluidState(blockPos); + return this.defaultBlockState() + .setValue(FACING, context.getHorizontalDirection().getOpposite()) + .setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER); + } }