protected boolean setTarget(boolean doSet, int destFreq) { if (!GalacticraftCore.isPlanetsLoaded || FMLCommonHandler.instance().getMinecraftServerInstance() == null || FMLCommonHandler.instance().getMinecraftServerInstance().worldServers == null) { return false; } WorldServer[] servers = FMLCommonHandler.instance().getMinecraftServerInstance().worldServers; for (int i = 0; i < servers.length; i++) { WorldServer world = servers[i]; try { Class<?> controllerClass = Class.forName( "micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController"); for (TileEntity tile : new ArrayList<TileEntity>(world.loadedTileEntityList)) { if (tile != null) { tile = world.getTileEntity(tile.getPos()); if (tile == null) continue; try { controllerClass.cast(tile); } catch (ClassCastException e) { continue; } int controllerFrequency = controllerClass.getField("frequency").getInt(tile); if (destFreq == controllerFrequency) { boolean targetSet = false; blockLoop: for (int x = -2; x <= 2; x++) { for (int z = -2; z <= 2; z++) { BlockPos pos = new BlockPos(tile.getPos().add(x, 0, z)); Block block = world.getBlockState(pos).getBlock(); if (block instanceof BlockLandingPadFull) { if (doSet) { this.targetVec = pos; } targetSet = true; break blockLoop; } } } if (doSet) { this.targetDimension = tile.getWorld().provider.getDimensionId(); } if (!targetSet) { if (doSet) { this.targetVec = null; } return false; } else { return true; } } } } } catch (Exception e) { e.printStackTrace(); } } return false; }