59 lines
No EOL
2.2 KiB
Java
59 lines
No EOL
2.2 KiB
Java
package su.a71.new_soviet.blocks;
|
|
|
|
import net.minecraft.block.*;
|
|
import net.minecraft.block.entity.BlockEntity;
|
|
import net.minecraft.block.piston.PistonBehavior;
|
|
import net.minecraft.item.ItemPlacementContext;
|
|
import net.minecraft.sound.BlockSoundGroup;
|
|
import net.minecraft.state.StateManager;
|
|
import net.minecraft.state.property.Properties;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.util.math.Direction;
|
|
import net.minecraft.util.shape.VoxelShape;
|
|
import net.minecraft.util.shape.VoxelShapes;
|
|
import net.minecraft.world.BlockView;
|
|
|
|
import su.a71.new_soviet.entity.TVBlockEntity;
|
|
import su.a71.new_soviet.util.Shapes;
|
|
|
|
import java.util.List;
|
|
|
|
public class TVBlock extends HorizontalFacingBlock implements BlockEntityProvider {
|
|
protected static final Shapes.HorizontalShape SHAPE;
|
|
|
|
public TVBlock(AbstractBlock.Settings settings) {
|
|
super(settings.sounds(BlockSoundGroup.METAL).pistonBehavior(PistonBehavior.BLOCK).strength(1f, 2f));
|
|
setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH));
|
|
}
|
|
|
|
@Override
|
|
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
|
builder.add(Properties.HORIZONTAL_FACING);
|
|
}
|
|
|
|
@Override
|
|
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext ctx) {
|
|
Direction dir = state.get(FACING);
|
|
return switch (dir) {
|
|
case NORTH -> SHAPE.north();
|
|
case SOUTH -> SHAPE.south();
|
|
case EAST -> SHAPE.east();
|
|
case WEST -> SHAPE.west();
|
|
default -> VoxelShapes.fullCube();
|
|
};
|
|
}
|
|
|
|
@Override
|
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
|
return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite());
|
|
}
|
|
|
|
@Override
|
|
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
|
|
return new TVBlockEntity(pos, state);
|
|
}
|
|
|
|
static {
|
|
SHAPE = new Shapes.HorizontalShape(List.of(List.of(0.0, 1.0, 3.0, 16.0, 13.0, 13.0), List.of(2.0, 0.0, 4.0, 14.0, 1.0, 12.0), List.of(6.0, 13.0, 7.0, 10.0, 14.0, 9.0)));
|
|
}
|
|
} |