Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How can i make walls only connect to other walls of the same type and solid blocks?


Drachenbauer
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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 by Drachenbauer
Link to comment
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • i re-made the player model with RenderPlayerEvent so i can modify the model, but the event is making a "double" of steve like a mirror, i dont know which steve is the real and which one is the fake but i need to remove or make invisible the one below i tried to use .Pre to make invisible the model this is how it looks without the bipedPART.showModel = false: https://imgur.com/a/fMuXsBR i tried to make the steve that is rotated down invisible but im doing the opposite(made invisible the one that is looking up or the correct one) and thats not what i want @SubscribeEvent public static void renderPre(RenderPlayerEvent.Pre event) { event.getRenderer().getEntityModel().bipedHead.showModel = false; event.getRenderer().getEntityModel().bipedBody.showModel = false; event.getRenderer().getEntityModel().bipedRightArm.showModel = false; event.getRenderer().getEntityModel().bipedLeftArm.showModel = false; event.getRenderer().getEntityModel().bipedRightLeg.showModel = false; event.getRenderer().getEntityModel().bipedLeftLeg.showModel = false; } @SubscribeEvent public static void renderPost(RenderPlayerEvent.Post event) { event.getRenderer().getEntityModel().bipedHead.showModel = true; event.getRenderer().getEntityModel().bipedBody.showModel = true; event.getRenderer().getEntityModel().bipedRightArm.showModel = true; event.getRenderer().getEntityModel().bipedLeftArm.showModel = true; event.getRenderer().getEntityModel().bipedRightLeg.showModel = true; event.getRenderer().getEntityModel().bipedLeftLeg.showModel = true; if(ModKeys.ability1Key.isKeyDown()) { PlayerEntity player = event.getPlayer(); GlStateManager.enableBlend(); PlayerModel<AbstractClientPlayerEntity> model = event.getRenderer().getEntityModel(); ModelRenderer head = model.bipedHead; ModelRenderer rightarm = model.bipedRightArm; ModelRenderer leftarm = model.bipedLeftArm; ModelRenderer body = model.bipedBody; ModelRenderer rightleg = model.bipedRightLeg; ModelRenderer leftleg = model.bipedLeftLeg; head.render(event.getMatrixStack(), event.getBuffers().getBuffer(RenderType.getEntitySolid(((AbstractClientPlayerEntity)player).getLocationSkin())), Minecraft.getInstance().getRenderManager().getPackedLight(player, 1f), OverlayTexture.NO_OVERLAY); rightarm.render(event.getMatrixStack(), event.getBuffers().getBuffer(RenderType.getEntitySolid(((AbstractClientPlayerEntity)player).getLocationSkin())), Minecraft.getInstance().getRenderManager().getPackedLight(player, 1f), OverlayTexture.NO_OVERLAY); leftarm.render(event.getMatrixStack(), event.getBuffers().getBuffer(RenderType.getEntitySolid(((AbstractClientPlayerEntity)player).getLocationSkin())), Minecraft.getInstance().getRenderManager().getPackedLight(player, 1f), OverlayTexture.NO_OVERLAY); body.render(event.getMatrixStack(), event.getBuffers().getBuffer(RenderType.getEntitySolid(((AbstractClientPlayerEntity)player).getLocationSkin())), Minecraft.getInstance().getRenderManager().getPackedLight(player, 1f), OverlayTexture.NO_OVERLAY); rightleg.render(event.getMatrixStack(), event.getBuffers().getBuffer(RenderType.getEntitySolid(((AbstractClientPlayerEntity)player).getLocationSkin())), Minecraft.getInstance().getRenderManager().getPackedLight(player, 1f), OverlayTexture.NO_OVERLAY); leftleg.render(event.getMatrixStack(), event.getBuffers().getBuffer(RenderType.getEntitySolid(((AbstractClientPlayerEntity)player).getLocationSkin())), Minecraft.getInstance().getRenderManager().getPackedLight(player, 1f), OverlayTexture.NO_OVERLAY); } }      
    • I figured it out! i had an extra "2" in the port. A personal paste error! Darn.
    • The voicechat-server.toml file is invalid. Correct it or delete it to regenerate the default.
    • 1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • debug.log must be explicitly enabled when using curse launcher, maybe that is the issue.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.