100 lines
3.8 KiB
Java
100 lines
3.8 KiB
Java
package net.minecraft.world.level.block;
|
|
|
|
import net.minecraft.world.level.block.state.AbstractStateHolder;
|
|
import net.minecraft.world.level.material.Fluid;
|
|
import net.minecraft.world.level.block.state.properties.Property;
|
|
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
import java.util.Random;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.LevelReader;
|
|
import net.minecraft.world.level.material.Fluids;
|
|
import net.minecraft.world.level.LevelAccessor;
|
|
import javax.annotation.Nullable;
|
|
import net.minecraft.world.level.material.FluidState;
|
|
import net.minecraft.tags.FluidTags;
|
|
import net.minecraft.world.item.BlockPlaceContext;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
|
|
public class Seagrass extends BushBlock implements BonemealableBlock, LiquidBlockContainer {
|
|
protected static final VoxelShape SHAPE;
|
|
|
|
protected Seagrass(final Properties c) {
|
|
super(c);
|
|
}
|
|
|
|
@Override
|
|
public VoxelShape getShape(final BlockState byg, final BlockGetter bjd, final BlockPos fk, final CollisionContext cvn) {
|
|
return Seagrass.SHAPE;
|
|
}
|
|
|
|
@Override
|
|
protected boolean mayPlaceOn(final BlockState byg, final BlockGetter bjd, final BlockPos fk) {
|
|
return byg.isFaceSturdy(bjd, fk, Direction.UP) && byg.getBlock() != Blocks.MAGMA_BLOCK;
|
|
}
|
|
|
|
@Nullable
|
|
@Override
|
|
public BlockState getStateForPlacement(final BlockPlaceContext bcn) {
|
|
final FluidState cog3 = bcn.getLevel().getFluidState(bcn.getClickedPos());
|
|
if (cog3.is(FluidTags.WATER) && cog3.getAmount() == 8) {
|
|
return super.getStateForPlacement(bcn);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public BlockState updateShape(final BlockState byg1, final Direction fp, final BlockState byg3, final LevelAccessor bju, final BlockPos fk5, final BlockPos fk6) {
|
|
final BlockState byg4 = super.updateShape(byg1, fp, byg3, bju, fk5, fk6);
|
|
if (!byg4.isAir()) {
|
|
bju.getLiquidTicks().scheduleTick(fk5, Fluids.WATER, Fluids.WATER.getTickDelay(bju));
|
|
}
|
|
return byg4;
|
|
}
|
|
|
|
@Override
|
|
public boolean isValidBonemealTarget(final BlockGetter bjd, final BlockPos fk, final BlockState byg, final boolean boolean4) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean isBonemealSuccess(final Level bjt, final Random random, final BlockPos fk, final BlockState byg) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public FluidState getFluidState(final BlockState byg) {
|
|
return Fluids.WATER.getSource(false);
|
|
}
|
|
|
|
@Override
|
|
public void performBonemeal(final ServerLevel xd, final Random random, final BlockPos fk, final BlockState byg) {
|
|
final BlockState byg2 = Blocks.TALL_SEAGRASS.defaultBlockState();
|
|
final BlockState byg3 = ((AbstractStateHolder<O, BlockState>)byg2).<DoubleBlockHalf, DoubleBlockHalf>setValue(TallSeagrass.HALF, DoubleBlockHalf.UPPER);
|
|
final BlockPos fk2 = fk.above();
|
|
if (xd.getBlockState(fk2).getBlock() == Blocks.WATER) {
|
|
xd.setBlock(fk, byg2, 2);
|
|
xd.setBlock(fk2, byg3, 2);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public boolean canPlaceLiquid(final BlockGetter bjd, final BlockPos fk, final BlockState byg, final Fluid cof) {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean placeLiquid(final LevelAccessor bju, final BlockPos fk, final BlockState byg, final FluidState cog) {
|
|
return false;
|
|
}
|
|
|
|
static {
|
|
SHAPE = Block.box(2.0, 0.0, 2.0, 14.0, 12.0, 14.0);
|
|
}
|
|
}
|