minor refactoring

This commit is contained in:
Justin Parsell 2021-10-24 21:21:27 -04:00
parent 9fc1ea35e8
commit 8aa8895c52
1 changed files with 14 additions and 13 deletions

View File

@ -85,17 +85,18 @@ public class GlowstoneWireBlock extends Block{
} }
private GlowWireConnection determineConnection(WorldAccess world, BlockPos pos, Direction direction){ 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 BlockPos offsetPos = pos.offset(direction);
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(offsetPos.up()).isOf(this) && world.isAir(pos.up()))) // If offset+up is me && if up is air
if(world.getBlockState(pos.offset(direction)).hasSidedTransparency()) 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; return GlowWireConnection.SIDE;
else else
return GlowWireConnection.UP; 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(offsetPos.down()).isOf(this) && world.isAir(offsetPos)) // 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()).get(DIRECTION_TO_WIRE_CONNECTION.get(direction.getOpposite())).isBroken()) //if offset+down is not broken
return GlowWireConnection.SIDE; return GlowWireConnection.SIDE;
if(world.getBlockState(pos.offset(direction)).isOf(this)) // if offset is me if(world.getBlockState(offsetPos).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).get(DIRECTION_TO_WIRE_CONNECTION.get(direction.getOpposite())).isBroken()) // if offset is not broken
return GlowWireConnection.SIDE; return GlowWireConnection.SIDE;
return GlowWireConnection.NONE; return GlowWireConnection.NONE;
} }
@ -108,9 +109,9 @@ public class GlowstoneWireBlock extends Block{
public VoxelShape determineVoxelShape(BlockState state){ public VoxelShape determineVoxelShape(BlockState state){
VoxelShape voxelShape = DOT_VOXELSHAPE; VoxelShape voxelShape = DOT_VOXELSHAPE;
Iterator dirItr1 = Direction.Type.HORIZONTAL.iterator(); Iterator dirItr = Direction.Type.HORIZONTAL.iterator();
while(dirItr1.hasNext()) { while(dirItr.hasNext()) {
Direction direction = (Direction)dirItr1.next(); Direction direction = (Direction)dirItr.next();
GlowWireConnection wireConnection = state.get(DIRECTION_TO_WIRE_CONNECTION.get(direction)); GlowWireConnection wireConnection = state.get(DIRECTION_TO_WIRE_CONNECTION.get(direction));
if(state.equals(this.getDefaultState().with(DIRECTION_TO_WIRE_CONNECTION.get(direction), GlowWireConnection.SIDE))) { if(state.equals(this.getDefaultState().with(DIRECTION_TO_WIRE_CONNECTION.get(direction), GlowWireConnection.SIDE))) {
voxelShape = VoxelShapes.union(voxelShape, (VoxelShape)DIRECTION_HITBOX.get(direction)); voxelShape = VoxelShapes.union(voxelShape, (VoxelShape)DIRECTION_HITBOX.get(direction));