From 8aa8895c52317a137ede1b2bf2bbd57fbb5179d6 Mon Sep 17 00:00:00 2001 From: Justin Parsell Date: Sun, 24 Oct 2021 21:21:27 -0400 Subject: [PATCH] minor refactoring --- .../common/GlowstoneWireBlock.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/me/parsell/glowstonewire/common/GlowstoneWireBlock.java b/src/main/java/me/parsell/glowstonewire/common/GlowstoneWireBlock.java index 2ecbf6e..325dbe2 100644 --- a/src/main/java/me/parsell/glowstonewire/common/GlowstoneWireBlock.java +++ b/src/main/java/me/parsell/glowstonewire/common/GlowstoneWireBlock.java @@ -70,9 +70,9 @@ public class GlowstoneWireBlock extends Block{ private static boolean hasConnection(BlockState state) { return ((GlowWireConnection)state.get(WIRE_CONNECTION_NORTH)).isConnected() || - ((GlowWireConnection)state.get(WIRE_CONNECTION_SOUTH)).isConnected() || - ((GlowWireConnection)state.get(WIRE_CONNECTION_EAST)).isConnected() || - ((GlowWireConnection)state.get(WIRE_CONNECTION_WEST)).isConnected(); + ((GlowWireConnection)state.get(WIRE_CONNECTION_SOUTH)).isConnected() || + ((GlowWireConnection)state.get(WIRE_CONNECTION_EAST)).isConnected() || + ((GlowWireConnection)state.get(WIRE_CONNECTION_WEST)).isConnected(); } private BlockState determineState(WorldAccess world, BlockState state, BlockPos pos){ @@ -85,17 +85,18 @@ public class GlowstoneWireBlock extends Block{ } private GlowWireConnection determineConnection(WorldAccess world, BlockPos pos, Direction direction){ - if((world.getBlockState(pos.offset(direction).up()).isOf(this) && world.isAir(pos.up()))) // If offset+up is me && if up is air - if(!world.getBlockState(pos.offset(direction).up()).get(DIRECTION_TO_WIRE_CONNECTION.get(direction.getOpposite())).isBroken()) //if offset+up is not broken - if(world.getBlockState(pos.offset(direction)).hasSidedTransparency()) + BlockPos offsetPos = pos.offset(direction); + if((world.getBlockState(offsetPos.up()).isOf(this) && world.isAir(pos.up()))) // If offset+up is me && if up is air + if(!world.getBlockState(offsetPos.up()).get(DIRECTION_TO_WIRE_CONNECTION.get(direction.getOpposite())).isBroken()) //if offset+up is not broken + if(world.getBlockState(offsetPos).hasSidedTransparency()) return GlowWireConnection.SIDE; else return GlowWireConnection.UP; - if(world.getBlockState(pos.offset(direction).down()).isOf(this) && world.isAir(pos.offset(direction))) // if offset+down is me && if offset is air - if(!world.getBlockState(pos.offset(direction).down()).get(DIRECTION_TO_WIRE_CONNECTION.get(direction.getOpposite())).isBroken()) //if offset+down is not broken + if(world.getBlockState(offsetPos.down()).isOf(this) && world.isAir(offsetPos)) // if offset+down is me && if offset is air + if(!world.getBlockState(offsetPos.down()).get(DIRECTION_TO_WIRE_CONNECTION.get(direction.getOpposite())).isBroken()) //if offset+down is not broken return GlowWireConnection.SIDE; - if(world.getBlockState(pos.offset(direction)).isOf(this)) // if offset is me - if(!world.getBlockState(pos.offset(direction)).get(DIRECTION_TO_WIRE_CONNECTION.get(direction.getOpposite())).isBroken()) // if offset is not broken + if(world.getBlockState(offsetPos).isOf(this)) // if offset is me + if(!world.getBlockState(offsetPos).get(DIRECTION_TO_WIRE_CONNECTION.get(direction.getOpposite())).isBroken()) // if offset is not broken return GlowWireConnection.SIDE; return GlowWireConnection.NONE; } @@ -108,9 +109,9 @@ public class GlowstoneWireBlock extends Block{ public VoxelShape determineVoxelShape(BlockState state){ VoxelShape voxelShape = DOT_VOXELSHAPE; - Iterator dirItr1 = Direction.Type.HORIZONTAL.iterator(); - while(dirItr1.hasNext()) { - Direction direction = (Direction)dirItr1.next(); + Iterator dirItr = Direction.Type.HORIZONTAL.iterator(); + while(dirItr.hasNext()) { + Direction direction = (Direction)dirItr.next(); GlowWireConnection wireConnection = state.get(DIRECTION_TO_WIRE_CONNECTION.get(direction)); if(state.equals(this.getDefaultState().with(DIRECTION_TO_WIRE_CONNECTION.get(direction), GlowWireConnection.SIDE))) { voxelShape = VoxelShapes.union(voxelShape, (VoxelShape)DIRECTION_HITBOX.get(direction));