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.

Featured Replies

Posted

hello,The other wood_window is correct, but there is a problem with this one, what happened

 

The left is correct. right is error. The middle of it should be white,Why is it like this

QQ%E6%88%AA%E5%9B%BE20211210185804.png

 

%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_202

 

public abstract class AbstractWoodWindow extends FourWayBlock {

    public AbstractWoodWindow(Properties properties) {
        super(1.0F, 1.0F, 16.0F, 16.0F, 16.0F, properties);
        this.registerDefaultState(this.stateDefinition.any().setValue(NORTH, Boolean.FALSE).setValue(EAST,
                Boolean.FALSE).setValue(SOUTH, Boolean.FALSE).setValue(WEST,
                Boolean.FALSE).setValue(WATERLOGGED, Boolean.FALSE));
    }

    @Override
    public BlockState getStateForPlacement(BlockItemUseContext context) {
        IBlockReader iblockreader = context.getLevel();
        BlockPos blockpos = context.getClickedPos();
        FluidState fluidstate = context.getLevel().getFluidState(context.getClickedPos());
        BlockPos blockpos1 = blockpos.north();
        BlockPos blockpos2 = blockpos.south();
        BlockPos blockpos3 = blockpos.west();
        BlockPos blockpos4 = blockpos.east();
        BlockState blockstate = iblockreader.getBlockState(blockpos1);
        BlockState blockstate1 = iblockreader.getBlockState(blockpos2);
        BlockState blockstate2 = iblockreader.getBlockState(blockpos3);
        BlockState blockstate3 = iblockreader.getBlockState(blockpos4);
        return this.defaultBlockState().setValue(NORTH, this.attachTo(blockstate,
                blockstate.isFaceSturdy(iblockreader, blockpos1, Direction.SOUTH))).setValue(SOUTH,
                this.attachTo(blockstate1, blockstate1.isFaceSturdy(iblockreader, blockpos2,
                        Direction.NORTH))).setValue(WEST, this.attachTo(blockstate2,
                blockstate2.isFaceSturdy(iblockreader, blockpos3, Direction.EAST))).setValue(EAST,
                this.attachTo(blockstate3, blockstate3.isFaceSturdy(iblockreader, blockpos4,
                        Direction.WEST))).setValue(WATERLOGGED, fluidstate.getType() == Fluids.WATER);
    }

    @Override
    public BlockState updateShape(BlockState state1, Direction direction, BlockState state,
                                  IWorld world, BlockPos pos, BlockPos pos1) {
        if (state1.getValue(WATERLOGGED)) {
            world.getLiquidTicks().scheduleTick(pos, Fluids.WATER,
                    Fluids.WATER.getTickDelay(world));
        }

        return direction.getAxis().isHorizontal() ? state1.setValue(PROPERTY_BY_DIRECTION.get(direction),
                this.attachTo(state, state.isFaceSturdy(world, pos1,
                        direction.getOpposite()))) : super.updateShape(state1, direction, state,
                world, pos, pos1);
    }

    @Override
    public VoxelShape getVisualShape(BlockState state, IBlockReader reader, BlockPos pos,
                                     ISelectionContext context) {
        return VoxelShapes.empty();
    }

    @Override
    public boolean skipRendering(BlockState state, BlockState p_200122_2_, Direction direction) {
        if (p_200122_2_.is(this)) {
            if (!direction.getAxis().isHorizontal()) {
                return true;
            }
            if (state.getValue(PROPERTY_BY_DIRECTION.get(direction)) && p_200122_2_.getValue(PROPERTY_BY_DIRECTION.get(direction.getOpposite()))) {
                return true;
            }
        }

        return super.skipRendering(state, p_200122_2_, direction);
    }

    public boolean attachTo(BlockState state, boolean flag) {
        Block block = state.getBlock();
        return !isExceptionForConnection(block) && flag || block instanceof AbstractWoodWindow || block.is(BlockTags.WALLS);
    }

    @Override
    protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> p_206840_1_) {
        p_206840_1_.add(NORTH, EAST, WEST, SOUTH, WATERLOGGED);
    }
}


public class WoodWindow extends AbstractWoodWindow {

    public WoodWindow() {
        super(PropertiesMisc.defaultWindow());
    }

    @Override
    public BlockState getStateForPlacement(BlockItemUseContext context) {
        IBlockReader iblockreader = context.getLevel();
        BlockPos blockpos = context.getClickedPos();
        FluidState fluidstate = context.getLevel().getFluidState(context.getClickedPos());
        BlockPos blockpos1 = blockpos.north();
        BlockPos blockpos2 = blockpos.south();
        BlockPos blockpos3 = blockpos.west();
        BlockPos blockpos4 = blockpos.east();
        BlockState blockstate = iblockreader.getBlockState(blockpos1);
        BlockState blockstate1 = iblockreader.getBlockState(blockpos2);
        BlockState blockstate2 = iblockreader.getBlockState(blockpos3);
        BlockState blockstate3 = iblockreader.getBlockState(blockpos4);
        return this.defaultBlockState().setValue(NORTH, this.attachTo(blockstate,
                blockstate.isFaceSturdy(iblockreader, blockpos1, Direction.SOUTH))).setValue(SOUTH,
                this.attachTo(blockstate1, blockstate1.isFaceSturdy(iblockreader, blockpos2,
                        Direction.NORTH))).setValue(WEST, this.attachTo(blockstate2,
                blockstate2.isFaceSturdy(iblockreader, blockpos3, Direction.EAST))).setValue(EAST,
                this.attachTo(blockstate3, blockstate3.isFaceSturdy(iblockreader, blockpos4,
                        Direction.WEST))).setValue(WATERLOGGED, fluidstate.getType() == Fluids.WATER);
    }

    @Override
    public boolean attachTo(BlockState state, boolean flag) {
        Block block = state.getBlock();
        return !isExceptionForConnection(block) && flag || block instanceof WoodWindow || block.is(BlockTags.WALLS);
    }

 

 

Please help me, thanks !!!!!!!!!!!!!!!

Edited by Spring

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

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.