@Override public void run() { @SuppressWarnings("rawtypes") List entities = null; try { switch (TYPE) { case 0: entities = etc.getServer().getPlayerList(); break; case 1: entities = this.WORLD.getMobList(); break; case 2: entities = this.WORLD.getAnimalList(); break; case 3: entities = this.WORLD.getLivingEntityList(); break; case 4: entities = entitiesExceptPlayers(this.WORLD.getWorld()); break; case 5: entities = entitiesExceptPlayersItems(this.WORLD.getWorld()); break; } } catch (ConcurrentModificationException e) { e.printStackTrace(); return; } if (entities == null) return; boolean found = false; for (Object obj : entities) { BaseEntity entity = (BaseEntity) obj; if (entity.getWorld().getType().getId() != WORLD.getType().getId()) continue; double diffX = BLOCK.getBlockX() - entity.getX(); double diffY = BLOCK.getBlockY() - entity.getY(); double diffZ = BLOCK.getBlockZ() - entity.getZ(); if (diffX * diffX + diffY * diffY + diffZ * diffZ < DISTANCE) { boolean result = entityInRange(entity); if (result) { found = true; if (DESTROY) { entity.destroy(); } else { break; } } } } Redstone.setOutput(CraftBook.getCBWorld(WORLD), LEVER, found); }
/** * Tests to see if a block is high, possibly including redstone wires. If there was no redstone at * that location, null will be returned. * * @param pt * @param icName * @param considerWires * @return */ static boolean isHighBinary(int worldType, Vector pt, boolean considerWires) { Boolean result = Redstone.isHigh(worldType, pt, CraftBook.getBlockID(worldType, pt), considerWires); if (result != null && result) { return true; } else { return false; } }
static Boolean testAnyInput( World world, Vector pt, boolean checkWiresAbove, boolean checkOnlyHorizontal) { Boolean result = null; Boolean temp = null; int x = pt.getBlockX(); int y = pt.getBlockY(); int z = pt.getBlockZ(); if (checkWiresAbove) { temp = testAnyInput(world, new Vector(x, y + 1, z), false, true); if (temp != null) { if (temp == true) { return true; } else { result = false; } } } if (!checkOnlyHorizontal) { // Check block above int above = CraftBook.getBlockID(world, x, y + 1, z); temp = Redstone.isHigh(world, new Vector(x, y + 1, z), above, true); if (temp != null) { if (temp == true) { return true; } else { result = false; } } } if (!checkOnlyHorizontal) { // Check block below int below = CraftBook.getBlockID(world, x, y - 1, z); temp = Redstone.isHigh(world, new Vector(x, y - 1, z), below, true); if (temp != null) { if (temp == true) { return true; } else { result = false; } } } int north = CraftBook.getBlockID(world, x - 1, y, z); int south = CraftBook.getBlockID(world, x + 1, y, z); int west = CraftBook.getBlockID(world, x, y, z + 1); int east = CraftBook.getBlockID(world, x, y, z - 1); // For wires that lead up to only this block if (north == BlockType.REDSTONE_WIRE) { temp = Redstone.isWireHigh( world, new Vector(x - 1, y, z), new Vector(x - 1, y, z - 1), new Vector(x - 1, y, z + 1)); if (temp != null) { if (temp == true) { return true; } else { result = false; } } } if (south == BlockType.REDSTONE_WIRE) { temp = Redstone.isWireHigh( world, new Vector(x + 1, y, z), new Vector(x + 1, y, z - 1), new Vector(x + 1, y, z + 1)); if (temp != null) { if (temp == true) { return true; } else { result = false; } } } if (west == BlockType.REDSTONE_WIRE) { temp = Redstone.isWireHigh( world, new Vector(x, y, z + 1), new Vector(x + 1, y, z + 1), new Vector(x - 1, y, z + 1)); if (temp != null) { if (temp == true) { return true; } else { result = false; } } } if (east == BlockType.REDSTONE_WIRE) { temp = Redstone.isWireHigh( world, new Vector(x, y, z - 1), new Vector(x + 1, y, z - 1), new Vector(x - 1, y, z - 1)); if (temp != null) { if (temp == true) { return true; } else { result = false; } } } // The sides of the block temp = Redstone.isHigh(world, new Vector(x - 1, y, z), north, false); if (temp != null) { if (temp == true) { return true; } else { result = false; } } temp = Redstone.isHigh(world, new Vector(x + 1, y, z), south, false); if (temp != null) { if (temp == true) { return true; } else { result = false; } } temp = Redstone.isHigh(world, new Vector(x, y, z + 1), west, false); if (temp != null) { if (temp == true) { return true; } else { result = false; } } temp = Redstone.isHigh(world, new Vector(x, y, z - 1), east, false); if (temp != null) { if (temp == true) { return true; } else { result = false; } } return result; }