Posted April 17, 20205 yr Hello I created some walls out of the colorful materials concrete, wool, terracotta and glazed terracotta. They now connect to all other wall-blocks, no matter, wich typr they are. How can i make them only connect to identical wall-pieces (for sample yellow concrete only to another yellow concrete wall) and solid blocks?
April 18, 20205 yr Author I found a solution, bevore i saw your answer: I made my own wall-block, that extends the vanilla one and added theese functions: private boolean isWall(BlockState state, BlockState facingState, boolean isSolid, Direction direction) { Block block = state.getBlock(); Block facingBlock = facingState.getBlock(); boolean flag = (block.isIn(BlockTags.WALLS) && (block == facingBlock)) || (facingBlock instanceof FenceGateBlock && FenceGateBlock.isParallel(state, direction)); return !cannotAttach(block) && isSolid || flag; } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { IWorldReader iworldreader = context.getWorld(); BlockPos blockpos = context.getPos(); BlockState blockstate = iworldreader.getBlockState(blockpos); IFluidState ifluidstate = context.getWorld().getFluidState(blockpos); BlockPos blockpos1 = blockpos.north(); BlockPos blockpos2 = blockpos.east(); BlockPos blockpos3 = blockpos.south(); BlockPos blockpos4 = blockpos.west(); BlockState blockstate1 = iworldreader.getBlockState(blockpos1); BlockState blockstate2 = iworldreader.getBlockState(blockpos2); BlockState blockstate3 = iworldreader.getBlockState(blockpos3); BlockState blockstate4 = iworldreader.getBlockState(blockpos4); boolean flag1 = this.isWall(blockstate, blockstate1, blockstate1.isSolidSide(iworldreader, blockpos1, Direction.SOUTH), Direction.SOUTH); boolean flag2 = this.isWall(blockstate, blockstate2, blockstate2.isSolidSide(iworldreader, blockpos2, Direction.WEST), Direction.WEST); boolean flag3 = this.isWall(blockstate, blockstate3, blockstate3.isSolidSide(iworldreader, blockpos3, Direction.NORTH), Direction.NORTH); boolean flag4 = this.isWall(blockstate, blockstate4, blockstate4.isSolidSide(iworldreader, blockpos4, Direction.EAST), Direction.EAST); boolean flag5 = (!flag1 || flag2 || !flag3 || flag4) && (flag1 || !flag2 || flag3 || !flag4); return this.getDefaultState().with(UP, Boolean.valueOf(flag5 || !iworldreader.isAirBlock(blockpos.up()))).with(NORTH, Boolean.valueOf(flag1)).with(EAST, Boolean.valueOf(flag2)).with(SOUTH, Boolean.valueOf(flag3)).with(WEST, Boolean.valueOf(flag4)).with(WATERLOGGED, Boolean.valueOf(ifluidstate.getFluid() == Fluids.WATER)); } @Override public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos currentPos, BlockPos facingPos) { if (state.get(WATERLOGGED)) { world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } if (facing == Direction.DOWN) { return super.updatePostPlacement(state, facing, facingState, world, currentPos, facingPos); } else { Direction direction = facing.getOpposite(); boolean flag1 = facing == Direction.NORTH ? this.isWall(state, facingState, facingState.isSolidSide(world, facingPos, direction), direction) : state.get(NORTH); boolean flag2 = facing == Direction.EAST ? this.isWall(state, facingState, facingState.isSolidSide(world, facingPos, direction), direction) : state.get(EAST); boolean flag3 = facing == Direction.SOUTH ? this.isWall(state, facingState, facingState.isSolidSide(world, facingPos, direction), direction) : state.get(SOUTH); boolean flag4 = facing == Direction.WEST ? this.isWall(state, facingState, facingState.isSolidSide(world, facingPos, direction), direction) : state.get(WEST); boolean flag5 = (!flag1 || flag2 || !flag3 || flag4) && (flag1 || !flag2 || flag3 || !flag4); return state.with(UP, Boolean.valueOf(flag5 || !world.isAirBlock(currentPos.up()))).with(NORTH, Boolean.valueOf(flag1)).with(EAST, Boolean.valueOf(flag2)).with(SOUTH, Boolean.valueOf(flag3)).with(WEST, Boolean.valueOf(flag4)); } } the first one bases on a function, that still has the SRC-name in the vanilla-class. It checfs for blocks in the walls-tag and fencegates. i made it compare the type of wall, too and renamed it more clear. so i also copyed and overrided the two functions, wich call it, too, and modifyed them to use my new function. Edited April 18, 20205 yr by Drachenbauer
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.