Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

marcoslopez

Members
  • Joined

  • Last visited

  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; } }

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.