48 lines
2.2 KiB
Java
48 lines
2.2 KiB
Java
package net.minecraft.world.level.block;
|
|
|
|
import net.minecraft.world.level.block.state.AbstractStateHolder;
|
|
import net.minecraft.world.level.material.Fluids;
|
|
import net.minecraft.world.level.LevelReader;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.world.level.block.state.properties.Property;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import java.util.Random;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.world.level.LevelAccessor;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
|
|
public class CoralWallFanBlock extends BaseCoralWallFanBlock {
|
|
private final Block deadBlock;
|
|
|
|
protected CoralWallFanBlock(final Block bpe, final Properties c) {
|
|
super(c);
|
|
this.deadBlock = bpe;
|
|
}
|
|
|
|
@Override
|
|
public void onPlace(final BlockState byg1, final Level bjt, final BlockPos fk, final BlockState byg4, final boolean boolean5) {
|
|
this.tryScheduleDieTick(byg1, bjt, fk);
|
|
}
|
|
|
|
@Override
|
|
public void tick(final BlockState byg, final ServerLevel xd, final BlockPos fk, final Random random) {
|
|
if (!BaseCoralPlantTypeBlock.scanForWater(byg, xd, fk)) {
|
|
xd.setBlock(fk, (((AbstractStateHolder<O, BlockState>)this.deadBlock.defaultBlockState()).setValue((Property<Comparable>)CoralWallFanBlock.WATERLOGGED, false)).<Comparable, Comparable>setValue((Property<Comparable>)CoralWallFanBlock.FACING, (Comparable)byg.<V>getValue((Property<V>)CoralWallFanBlock.FACING)), 2);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public BlockState updateShape(final BlockState byg1, final Direction fp, final BlockState byg3, final LevelAccessor bju, final BlockPos fk5, final BlockPos fk6) {
|
|
if (fp.getOpposite() == byg1.<Direction>getValue((Property<Direction>)CoralWallFanBlock.FACING) && !byg1.canSurvive(bju, fk5)) {
|
|
return Blocks.AIR.defaultBlockState();
|
|
}
|
|
if (byg1.<Boolean>getValue((Property<Boolean>)CoralWallFanBlock.WATERLOGGED)) {
|
|
bju.getLiquidTicks().scheduleTick(fk5, Fluids.WATER, Fluids.WATER.getTickDelay(bju));
|
|
}
|
|
this.tryScheduleDieTick(byg1, bju, fk5);
|
|
return super.updateShape(byg1, fp, byg3, bju, fk5, fk6);
|
|
}
|
|
}
|