private BakedQuad getQuad(EnumFacing side, ConnectionData data) { Connections cons = data.getConnections(); int rotation = 0; boolean connected = false; float[] uvs = UVS_TOP_LEFT; if (side.getAxis().isHorizontal() && cons.connectedOr(UP, DOWN)) { if (cons.connectedOr(UP, DOWN)) { connected = true; if (cons.connectedAnd(UP, DOWN)) { uvs = UVS_BOTTOM_LEFT; } else { if (cons.connected(UP)) { uvs = UVS_BOTTOM_RIGHT; } else { uvs = UVS_TOP_RIGHT; } } } } else { if (side != EAST && side != WEST && cons.connectedOr(EAST, WEST) && !cons.connectedOr(UP, DOWN)) { connected = true; rotation = 90; if (cons.connectedAnd(EAST, WEST)) { if (blockConnectionZ(EAST, data) && blockConnectionZ(WEST, data)) { connected = false; } else if (blockConnectionZ(EAST, data)) { uvs = UVS_TOP_RIGHT; } else if (blockConnectionZ(WEST, data)) { uvs = UVS_BOTTOM_RIGHT; } else { uvs = UVS_BOTTOM_LEFT; } } else { if (cons.connected(WEST) && !blockConnectionZ(WEST, data)) { uvs = UVS_TOP_RIGHT; } else if (cons.connected(EAST) && !blockConnectionZ(EAST, data)){ uvs = UVS_BOTTOM_RIGHT; } else { connected = false; } } } else if (side != NORTH && side != SOUTH && cons.connectedOr(NORTH, SOUTH) && !cons.connectedOr(UP, DOWN)) { connected = true; if (cons.connectedAnd(NORTH, SOUTH)) { if (blockConnectionY(NORTH, data) && blockConnectionY(SOUTH, data)) { connected = false; } else if (blockConnectionY(NORTH, data)) { uvs = UVS_TOP_RIGHT; } else if (blockConnectionY(SOUTH, data)) { uvs = UVS_BOTTOM_RIGHT; } else { uvs = UVS_BOTTOM_LEFT; } } else { if (cons.connected(NORTH) && !blockConnectionY(NORTH, data)) { uvs = UVS_BOTTOM_RIGHT; } else if (cons.connected(SOUTH) && !blockConnectionY(SOUTH, data)){ uvs = UVS_TOP_RIGHT; } else { connected = false; } } if (side == DOWN) { rotation += 180; } } if (connected) { if (side == NORTH) { rotation += 180; } if (side == EAST) { rotation += 90; } if (side == WEST) { rotation += 270; } } } if (!connected && side.getAxis().isHorizontal() && cons.getConnections().isEmpty()) { connected = true; } if (connected) { return makeUVFaceQuad(side, sprites[1].getSprite(), uvs, rotation); } return makeNormalFaceQuad(side, sprites[0].getSprite()); } private boolean blockConnectionY(EnumFacing dir, ConnectionData data) { return blockConnection(dir, Axis.Y, data) || blockConnection(dir, dir.rotateAround(Axis.Y).getAxis(), data); } private boolean blockConnectionZ(EnumFacing dir, ConnectionData data) { return blockConnection(dir, Axis.Z, data); } private boolean blockConnection(EnumFacing dir, Axis axis, ConnectionData data) { EnumFacing rot = dir.rotateAround(axis); return data.getConnections(dir).connectedOr(rot, rot.getOpposite()); }