Vertical hitbox
This commit is contained in:
@@ -21,6 +21,8 @@ public class CableBlock extends Block {
|
|||||||
public static final BooleanProperty SOUTH = BooleanProperty.of("south");
|
public static final BooleanProperty SOUTH = BooleanProperty.of("south");
|
||||||
public static final BooleanProperty EAST = BooleanProperty.of("east");
|
public static final BooleanProperty EAST = BooleanProperty.of("east");
|
||||||
public static final BooleanProperty WEST = BooleanProperty.of("west");
|
public static final BooleanProperty WEST = BooleanProperty.of("west");
|
||||||
|
public static final BooleanProperty UP = BooleanProperty.of("up");
|
||||||
|
public static final BooleanProperty DOWN = BooleanProperty.of("down");
|
||||||
|
|
||||||
public CableBlock(AbstractBlock.Settings settings) {
|
public CableBlock(AbstractBlock.Settings settings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
@@ -28,12 +30,14 @@ public class CableBlock extends Block {
|
|||||||
.with(NORTH, false)
|
.with(NORTH, false)
|
||||||
.with(SOUTH, false)
|
.with(SOUTH, false)
|
||||||
.with(EAST, false)
|
.with(EAST, false)
|
||||||
.with(WEST, false));
|
.with(WEST, false)
|
||||||
|
.with(UP, false)
|
||||||
|
.with(DOWN, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||||
builder.add(NORTH, SOUTH, EAST, WEST);
|
builder.add(NORTH, SOUTH, EAST, WEST, UP, DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -43,25 +47,34 @@ public class CableBlock extends Block {
|
|||||||
boolean south = world.getBlockState(pos.south()).getBlock() instanceof CableBlock;
|
boolean south = world.getBlockState(pos.south()).getBlock() instanceof CableBlock;
|
||||||
boolean east = world.getBlockState(pos.east()).getBlock() instanceof CableBlock;
|
boolean east = world.getBlockState(pos.east()).getBlock() instanceof CableBlock;
|
||||||
boolean west = world.getBlockState(pos.west()).getBlock() instanceof CableBlock;
|
boolean west = world.getBlockState(pos.west()).getBlock() instanceof CableBlock;
|
||||||
|
boolean up = world.getBlockState(pos.up()).getBlock() instanceof CableBlock;
|
||||||
|
boolean down = world.getBlockState(pos.down()).getBlock() instanceof CableBlock;
|
||||||
|
|
||||||
world.setBlockState(pos, state.with(NORTH, north)
|
world.setBlockState(pos, state
|
||||||
|
.with(NORTH, north)
|
||||||
.with(SOUTH, south)
|
.with(SOUTH, south)
|
||||||
.with(EAST, east)
|
.with(EAST, east)
|
||||||
.with(WEST, west), 2);
|
.with(WEST, west)
|
||||||
|
.with(UP, up)
|
||||||
|
.with(DOWN, down), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
|
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 north = world.getBlockState(pos.north()).getBlock() instanceof CableBlock;
|
||||||
boolean south = world.getBlockState(pos.south()).getBlock() instanceof CableBlock;
|
boolean south = world.getBlockState(pos.south()).getBlock() instanceof CableBlock;
|
||||||
boolean east = world.getBlockState(pos.east()).getBlock() instanceof CableBlock;
|
boolean east = world.getBlockState(pos.east()).getBlock() instanceof CableBlock;
|
||||||
boolean west = world.getBlockState(pos.west()).getBlock() instanceof CableBlock;
|
boolean west = world.getBlockState(pos.west()).getBlock() instanceof CableBlock;
|
||||||
|
boolean up = world.getBlockState(pos.up()).getBlock() instanceof CableBlock;
|
||||||
|
boolean down = world.getBlockState(pos.down()).getBlock() instanceof CableBlock;
|
||||||
|
|
||||||
world.setBlockState(pos, state.with(NORTH, north)
|
world.setBlockState(pos, state
|
||||||
|
.with(NORTH, north)
|
||||||
.with(SOUTH, south)
|
.with(SOUTH, south)
|
||||||
.with(EAST, east)
|
.with(EAST, east)
|
||||||
.with(WEST, west), 2);
|
.with(WEST, west)
|
||||||
|
.with(UP, up)
|
||||||
|
.with(DOWN, down), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,6 +85,8 @@ public class CableBlock extends Block {
|
|||||||
boolean south = state.get(SOUTH);
|
boolean south = state.get(SOUTH);
|
||||||
boolean east = state.get(EAST);
|
boolean east = state.get(EAST);
|
||||||
boolean west = state.get(WEST);
|
boolean west = state.get(WEST);
|
||||||
|
boolean up = state.get(UP);
|
||||||
|
boolean down = state.get(DOWN);
|
||||||
|
|
||||||
if (north || (south && !east && !west))
|
if (north || (south && !east && !west))
|
||||||
shape = VoxelShapes.union(shape, Block.createCuboidShape(6, 6, 0, 10, 10, 6));
|
shape = VoxelShapes.union(shape, Block.createCuboidShape(6, 6, 0, 10, 10, 6));
|
||||||
@@ -81,6 +96,10 @@ public class CableBlock extends Block {
|
|||||||
shape = VoxelShapes.union(shape, Block.createCuboidShape(10, 6, 6, 16, 10, 10));
|
shape = VoxelShapes.union(shape, Block.createCuboidShape(10, 6, 6, 16, 10, 10));
|
||||||
if (west || (!north && !south && east))
|
if (west || (!north && !south && east))
|
||||||
shape = VoxelShapes.union(shape, Block.createCuboidShape(0, 6, 6, 6, 10, 10));
|
shape = VoxelShapes.union(shape, Block.createCuboidShape(0, 6, 6, 6, 10, 10));
|
||||||
|
if (up)
|
||||||
|
shape = VoxelShapes.union(shape, Block.createCuboidShape(6, 6, 6, 10, 16, 10));
|
||||||
|
if (down)
|
||||||
|
shape = VoxelShapes.union(shape, Block.createCuboidShape(6, 0, 6, 10, 6, 10));
|
||||||
|
|
||||||
return shape;
|
return shape;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user