48 lines
1.5 KiB
Java
48 lines
1.5 KiB
Java
package net.minecraft.world.level.block;
|
|
|
|
import net.minecraft.world.level.LevelReader;
|
|
import net.minecraft.world.level.LevelAccessor;
|
|
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.item.DyeColor;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
|
|
public class WoolCarpetBlock extends Block {
|
|
protected static final VoxelShape SHAPE;
|
|
private final DyeColor color;
|
|
|
|
protected WoolCarpetBlock(final DyeColor bdg, final Properties c) {
|
|
super(c);
|
|
this.color = bdg;
|
|
}
|
|
|
|
public DyeColor getColor() {
|
|
return this.color;
|
|
}
|
|
|
|
@Override
|
|
public VoxelShape getShape(final BlockState byg, final BlockGetter bjd, final BlockPos fk, final CollisionContext cvn) {
|
|
return WoolCarpetBlock.SHAPE;
|
|
}
|
|
|
|
@Override
|
|
public BlockState updateShape(final BlockState byg1, final Direction fp, final BlockState byg3, final LevelAccessor bju, final BlockPos fk5, final BlockPos fk6) {
|
|
if (!byg1.canSurvive(bju, fk5)) {
|
|
return Blocks.AIR.defaultBlockState();
|
|
}
|
|
return super.updateShape(byg1, fp, byg3, bju, fk5, fk6);
|
|
}
|
|
|
|
@Override
|
|
public boolean canSurvive(final BlockState byg, final LevelReader bjw, final BlockPos fk) {
|
|
return !bjw.isEmptyBlock(fk.below());
|
|
}
|
|
|
|
static {
|
|
SHAPE = Block.box(0.0, 0.0, 0.0, 16.0, 1.0, 16.0);
|
|
}
|
|
}
|