From 139bc09acad4099ab392588271a60b9bc8dace32 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Wed, 12 Nov 2025 20:45:09 +0100 Subject: [PATCH] Fixed hitbox --- .../dev/kleo/redstonerewired/CableBlock.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/dev/kleo/redstonerewired/CableBlock.java b/src/main/java/dev/kleo/redstonerewired/CableBlock.java index 91f88d0..cb30768 100644 --- a/src/main/java/dev/kleo/redstonerewired/CableBlock.java +++ b/src/main/java/dev/kleo/redstonerewired/CableBlock.java @@ -3,6 +3,8 @@ package dev.kleo.redstonerewired; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.ShapeContext; +import net.minecraft.entity.LivingEntity; +import net.minecraft.item.ItemStack; import net.minecraft.block.AbstractBlock; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; @@ -48,6 +50,20 @@ public class CableBlock extends Block { .with(WEST, west), 2); } + @Override + public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) { + super.onPlaced(world, pos, state, placer, itemStack); + boolean north = world.getBlockState(pos.north()).getBlock() instanceof CableBlock; + boolean south = world.getBlockState(pos.south()).getBlock() instanceof CableBlock; + boolean east = world.getBlockState(pos.east()).getBlock() instanceof CableBlock; + boolean west = world.getBlockState(pos.west()).getBlock() instanceof CableBlock; + + world.setBlockState(pos, state.with(NORTH, north) + .with(SOUTH, south) + .with(EAST, east) + .with(WEST, west), 2); + } + @Override protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { VoxelShape shape = Block.createCuboidShape(6, 6, 6, 10, 10, 10); @@ -57,13 +73,13 @@ public class CableBlock extends Block { boolean east = state.get(EAST); boolean west = state.get(WEST); - if (north) + if (north || (south && !east && !west)) shape = VoxelShapes.union(shape, Block.createCuboidShape(6, 6, 0, 10, 10, 6)); - if (south) + if (south || (north && !east && !west)) shape = VoxelShapes.union(shape, Block.createCuboidShape(6, 6, 10, 10, 10, 16)); - if (east) + if (east || (!north && !south && west)) shape = VoxelShapes.union(shape, Block.createCuboidShape(10, 6, 6, 16, 10, 10)); - if (west) + if (west || (!north && !south && east)) shape = VoxelShapes.union(shape, Block.createCuboidShape(0, 6, 6, 6, 10, 10)); return shape;