private boolean isBeingPoweredByNonElevator(World world, int i, int j, int k) { for (int iter = 0; iter < 6; iter++) { int tempX = i; int tempZ = k; int tempY = j; if (iter == 0) { tempY--; } else if (iter == 1) { tempY++; } else if (iter == 2) { tempZ--; } else if (iter == 3) { tempZ++; } else if (iter == 4) { tempX--; } else if (iter == 5) { tempX++; } int ID = world.getBlockId(tempX, tempY, tempZ); DECore.say("Checking: " + tempX + ", " + tempY + ", " + tempZ + ": has block ID" + ID); if (ID > 0 && ID != DECore.Elevator.blockID && Block.blocksList[ID].isProvidingWeakPower(world, tempX, tempY, tempZ, iter)) { return true; } } return false; }
public static boolean findAndActivateElevator(World world, int i, int j, int k, int depth) { if (depth > 32) { return false; } if (depth == 0) { checkedCallers.clear(); checkedBlocks.clear(); elvs.clear(); } checkedCallers.add(new ChunkPosition(i, j, k)); // Look for adjacent elevator caller blocks - if any are found, activate // them. // Also, if any are found, do not search at this location boolean foundOtherCallerBlock = false; for (int iter = 0; iter < 6; iter++) { int tempX = i; int tempY = j; int tempZ = k; if (iter == 0) { tempY--; } else if (iter == 1) { tempY++; } else if (iter == 2) { tempZ--; } else if (iter == 3) { tempZ++; } else if (iter == 4) { tempX--; } else if (iter == 5) { tempX++; } if (world.getBlockId(tempX, tempY, tempZ) == DECore.ElevatorCaller.blockID && !checkedCallers.contains(new ChunkPosition(tempX, tempY, tempZ))) { findAndActivateElevator(world, tempX, tempY, tempZ, depth + 1); foundOtherCallerBlock = true; } } clearSets(depth); if (foundOtherCallerBlock) { return true; } // No uncalled elevator callers were found, so search for elevators here checkForElevators(world, new ChunkPosition(i, j, k), 0); DECore.say("ElevatorCaller activated at: " + i + ", " + j + ", " + k); DECore.say( (new StringBuilder()) .append("Checked ") .append(checkedBlocks.size()) .append(" blocks") .toString()); DECore.say( (new StringBuilder()).append("Found ").append(elvs.size()).append(" elevators").toString()); int dist = 500; int destY = -1; ChunkPosition newPos = null; if (!elvs.isEmpty()) { Iterator<ChunkPosition> iter = elvs.iterator(); while (iter.hasNext()) { ChunkPosition curPos = iter.next(); BlockElevator.refreshAndCombineAllAdjacentElevators(world, curPos); TileEntityElevator curTile = BlockElevator.getTileEntity(world, curPos.x, curPos.y, curPos.z); if (curTile != null) { int suggestedY = curTile.getClosestYFromYCoor(j); if (MathHelper.abs(suggestedY - curPos.y) < dist) { dist = (int) MathHelper.abs(suggestedY - curPos.y); newPos = curPos; destY = suggestedY; } } } } if (newPos != null) { DECore.elevator_demandY(world, newPos, j); clearSets(depth); return true; } return false; }