2020-07-22 06:23:34 +01:00
|
|
|
package net.minecraft.world.level.block;
|
|
|
|
|
|
|
|
import net.minecraft.world.level.LevelAccessor;
|
|
|
|
import net.minecraft.world.level.material.Fluid;
|
|
|
|
import net.minecraft.world.level.material.Fluids;
|
|
|
|
import net.minecraft.world.level.block.state.properties.Property;
|
|
|
|
import net.minecraft.world.level.LevelReader;
|
|
|
|
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.world.level.ItemLike;
|
|
|
|
import net.minecraft.world.item.ItemStack;
|
|
|
|
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;
|
|
|
|
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
|
|
|
|
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
|
|
|
|
|
|
|
public class TallSeagrass extends ShearableDoublePlantBlock implements LiquidBlockContainer {
|
|
|
|
public static final EnumProperty<DoubleBlockHalf> HALF;
|
|
|
|
protected static final VoxelShape SHAPE;
|
|
|
|
|
|
|
|
public TallSeagrass(final Properties c) {
|
|
|
|
super(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-07-22 06:25:47 +01:00
|
|
|
public VoxelShape getShape(final BlockState byg, final BlockGetter bjd, final BlockPos fk, final CollisionContext cvn) {
|
2020-07-22 06:23:34 +01:00
|
|
|
return TallSeagrass.SHAPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-07-22 06:25:47 +01:00
|
|
|
protected boolean mayPlaceOn(final BlockState byg, final BlockGetter bjd, final BlockPos fk) {
|
|
|
|
return byg.isFaceSturdy(bjd, fk, Direction.UP) && byg.getBlock() != Blocks.MAGMA_BLOCK;
|
2020-07-22 06:23:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-07-22 06:25:47 +01:00
|
|
|
public ItemStack getCloneItemStack(final BlockGetter bjd, final BlockPos fk, final BlockState byg) {
|
2020-07-22 06:23:34 +01:00
|
|
|
return new ItemStack(Blocks.SEAGRASS);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
2020-07-22 06:25:47 +01:00
|
|
|
public BlockState getStateForPlacement(final BlockPlaceContext bcn) {
|
|
|
|
final BlockState byg3 = super.getStateForPlacement(bcn);
|
|
|
|
if (byg3 != null) {
|
|
|
|
final FluidState cog4 = bcn.getLevel().getFluidState(bcn.getClickedPos().above());
|
|
|
|
if (cog4.is(FluidTags.WATER) && cog4.getAmount() == 8) {
|
|
|
|
return byg3;
|
2020-07-22 06:23:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-07-22 06:25:47 +01:00
|
|
|
public boolean canSurvive(final BlockState byg, final LevelReader bjw, final BlockPos fk) {
|
|
|
|
if (byg.<DoubleBlockHalf>getValue(TallSeagrass.HALF) == DoubleBlockHalf.UPPER) {
|
|
|
|
final BlockState byg2 = bjw.getBlockState(fk.below());
|
|
|
|
return byg2.getBlock() == this && byg2.<DoubleBlockHalf>getValue(TallSeagrass.HALF) == DoubleBlockHalf.LOWER;
|
2020-07-22 06:23:34 +01:00
|
|
|
}
|
2020-07-22 06:25:47 +01:00
|
|
|
final FluidState cog5 = bjw.getFluidState(fk);
|
|
|
|
return super.canSurvive(byg, bjw, fk) && cog5.is(FluidTags.WATER) && cog5.getAmount() == 8;
|
2020-07-22 06:23:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-07-22 06:25:47 +01:00
|
|
|
public FluidState getFluidState(final BlockState byg) {
|
2020-07-22 06:23:34 +01:00
|
|
|
return Fluids.WATER.getSource(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-07-22 06:25:47 +01:00
|
|
|
public boolean canPlaceLiquid(final BlockGetter bjd, final BlockPos fk, final BlockState byg, final Fluid cof) {
|
2020-07-22 06:23:34 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-07-22 06:25:47 +01:00
|
|
|
public boolean placeLiquid(final LevelAccessor bju, final BlockPos fk, final BlockState byg, final FluidState cog) {
|
2020-07-22 06:23:34 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static {
|
|
|
|
HALF = ShearableDoublePlantBlock.HALF;
|
|
|
|
SHAPE = Block.box(2.0, 0.0, 2.0, 14.0, 16.0, 14.0);
|
|
|
|
}
|
|
|
|
}
|