Jump to content

marcoslopez

Members
  • Posts

    2
  • Joined

  • Last visited

marcoslopez's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hello, I've been trying to make a 2x1 block and I can't do it, and I get to this point but I need to remove both blocks at the same time, can someone help me? public class CustomModeBlock extends HorizontalDirectionalBlock { //SHAPE public static final DirectionProperty FACING = HORIZONTAL_FACING; //NUEVO public static final BooleanProperty BEING_PLACED = BooleanProperty.create("being_placed" ); //public static final EnumProperty<DoubleBlockHalf> HALF = BlockStateProperties.DOUBLE_BLOCK_HALF; //LAS PROPIEDADES DEL BLOQUE public CustomModeBlock(Properties properties) { super(properties); } //FACING @Override protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { builder.add(HORIZONTAL_FACING); builder.add(CustomModeBlock.BEING_PLACED); //builder.add(FACING); //builder.add(HALF); } //NUEVO @Override public BlockState getStateForPlacement(BlockPlaceContext pContext) { Direction direction = pContext.getHorizontalDirection().getOpposite(); BlockPos blockPos = pContext.getClickedPos(); BlockPos blockPos1 = blockPos.relative(direction); Level level = pContext.getLevel(); return level.getBlockState(blockPos1).canBeReplaced(pContext) && level.getWorldBorder().isWithinBounds(blockPos1) ? this.defaultBlockState().setValue(FACING, direction) : null; } @Override public void setPlacedBy(Level pLevel, BlockPos pPos, BlockState pState, LivingEntity pEntity, ItemStack pStack) { BlockPos blockPos = pPos.relative(pState.getValue(FACING).getCounterClockWise()); pLevel.setBlock(blockPos, pState, 3); } @Override public boolean canSurvive(BlockState pState, LevelReader pReader, BlockPos pPos) { if (pState.getValue(BEING_PLACED) == true){ return true; } if (pReader.getBlockState(pPos.relative(FACING).getBlock().equals(getStateForPlacement))){ return true; } return false; } @Override public BlockState rotate(BlockState pState, Rotation pRotation) { return pState.setValue(FACING, pRotation.rotate(pState.getValue(FACING))); } @Override public BlockState mirror(BlockState pState, Mirror pMirror) { return pState.rotate(pMirror.getRotation(pState.getValue(FACING))); } //SHAPE @Override public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { switch (pState.getValue(FACING)){ case NORTH: return SHAPE_N; case SOUTH: return SHAPE_S; case EAST: return SHAPE_E; case WEST: return SHAPE_W; default: return SHAPE_N; } }
  2. Hello, what state trying to make a 2x1 block and I can't do it, and get to this point but I need to eliminate the two blocks at the same time, can someone help me? public class CustomModeBlock extends HorizontalDirectionalBlock { //SHAPE public static final DirectionProperty FACING = HORIZONTAL_FACING; //NUEVO public static final BooleanProperty BEING_PLACED = BooleanProperty.create("being_placed" ); //public static final EnumProperty<DoubleBlockHalf> HALF = BlockStateProperties.DOUBLE_BLOCK_HALF; //LAS PROPIEDADES DEL BLOQUE public CustomModeBlock(Properties properties) { super(properties); } //FACING @Override protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { builder.add(HORIZONTAL_FACING); builder.add(CustomModeBlock.BEING_PLACED); //builder.add(FACING); //builder.add(HALF); } //NUEVO @Override public BlockState getStateForPlacement(BlockPlaceContext pContext) { Direction direction = pContext.getHorizontalDirection().getOpposite(); BlockPos blockPos = pContext.getClickedPos(); BlockPos blockPos1 = blockPos.relative(direction); Level level = pContext.getLevel(); return level.getBlockState(blockPos1).canBeReplaced(pContext) && level.getWorldBorder().isWithinBounds(blockPos1) ? this.defaultBlockState().setValue(FACING, direction) : null; } @Override public void setPlacedBy(Level pLevel, BlockPos pPos, BlockState pState, LivingEntity pEntity, ItemStack pStack) { BlockPos blockPos = pPos.relative(pState.getValue(FACING).getCounterClockWise()); pLevel.setBlock(blockPos, pState, 3); } @Override public boolean canSurvive(BlockState pState, LevelReader pReader, BlockPos pPos) { if (pState.getValue(BEING_PLACED) == true){ return true; } if (pReader.getBlockState(pPos.relative(FACING).getBlock().equals(getStateForPlacement))){ return true; } return false; } @Override public BlockState rotate(BlockState pState, Rotation pRotation) { return pState.setValue(FACING, pRotation.rotate(pState.getValue(FACING))); } @Override public BlockState mirror(BlockState pState, Mirror pMirror) { return pState.rotate(pMirror.getRotation(pState.getValue(FACING))); } //SHAPE @Override public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { switch (pState.getValue(FACING)){ case NORTH: return SHAPE_N; case SOUTH: return SHAPE_S; case EAST: return SHAPE_E; case WEST: return SHAPE_W; default: return SHAPE_N; } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.