Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ...
- import ...
- public class ChoppingBoard extends HorizontalBlock {
- private static final ITextComponent TEXT_COMPONENT = ...;
- private static DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
- public ChoppingBoard(Properties properties) {
- super(properties);
- this.setDefaultState(this.stateContainer.getBaseState().with(HORIZONTAL_FACING, Direction.NORTH));
- }
- @Override
- public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
- switch (state.get(HORIZONTAL_FACING)) {
- case WEST:
- case EAST:
- return Block.makeCuboidShape(4.0D, 0.0D, 1.0D,
- 12.0D, 1.0D, 15.0D);
- default:
- return Block.makeCuboidShape(1.0D, 0.0D, 4.0D,
- 15.0D, 1.0D, 12.0D);
- }
- }
- @Override
- public BlockState getStateForPlacement(BlockItemUseContext context) {
- return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing());
- }
- @Override
- protected void fillStateContainer(StateContainer.Builder<Block, BlockState> p_206840_1_) {
- p_206840_1_.add(FACING);
- }
- @Override
- public BlockRenderType getRenderType(BlockState state) {
- return BlockRenderType.MODEL;
- }
- @Override
- public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult result) {
- player.openContainer(state.getContainer(world, pos));
- return true;
- }
- @Override
- public INamedContainerProvider getContainer(BlockState state, World world, BlockPos pos) {
- return new SimpleNamedContainerProvider((i, playerInventory, playerEntity)
- -> new ChoppingBoardContainer(playerInventory, IWorldPosCallable.of(world, pos)), TEXT_COMPONENT);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement