public boolean func_75250_a() {
   if (field_75275_a.field_70170_p.func_72935_r()) {
     return false;
   }
   Village village =
       field_75275_a.field_70170_p.field_72982_D.func_75550_a(
           MathHelper.func_76128_c(field_75275_a.field_70165_t),
           MathHelper.func_76128_c(field_75275_a.field_70163_u),
           MathHelper.func_76128_c(field_75275_a.field_70161_v),
           16);
   if (village == null) {
     return false;
   }
   field_75274_b =
       village.func_75564_b(
           MathHelper.func_76128_c(field_75275_a.field_70165_t),
           MathHelper.func_76128_c(field_75275_a.field_70163_u),
           MathHelper.func_76128_c(field_75275_a.field_70161_v));
   if (field_75274_b == null) {
     return false;
   } else {
     return (double)
             field_75274_b.func_75469_c(
                 MathHelper.func_76128_c(field_75275_a.field_70165_t),
                 MathHelper.func_76128_c(field_75275_a.field_70163_u),
                 MathHelper.func_76128_c(field_75275_a.field_70161_v))
         < 2.25D;
   }
 }
Пример #2
0
  /** Returns whether the EntityAIBase should begin execution. */
  public boolean shouldExecute() {
    if ((!this.entityObj.worldObj.isDaytime() || this.entityObj.worldObj.isRaining())
        && !this.entityObj.worldObj.worldProvider.hasNoSky) {
      if (this.entityObj.getRNG().nextInt(50) != 0) {
        return false;
      } else if (this.insidePosX != -1
          && this.entityObj.getDistanceSq(
                  (double) this.insidePosX, this.entityObj.posY, (double) this.insidePosZ)
              < 4.0D) {
        return false;
      } else {
        Village var1 =
            this.entityObj.worldObj.villageCollectionObj.findNearestVillage(
                MathHelper.floor_double(this.entityObj.posX),
                MathHelper.floor_double(this.entityObj.posY),
                MathHelper.floor_double(this.entityObj.posZ),
                14);

        if (var1 == null) {
          return false;
        } else {
          this.doorInfo =
              var1.findNearestDoorUnrestricted(
                  MathHelper.floor_double(this.entityObj.posX),
                  MathHelper.floor_double(this.entityObj.posY),
                  MathHelper.floor_double(this.entityObj.posZ));
          return this.doorInfo != null;
        }
      }
    } else {
      return false;
    }
  }
Пример #3
0
  private VillageDoorInfo getVillageDoorAt(int par1, int par2, int par3) {
    Iterator iterator = this.newDoors.iterator();
    VillageDoorInfo villagedoorinfo;

    do {
      if (!iterator.hasNext()) {
        iterator = this.villageList.iterator();
        VillageDoorInfo villagedoorinfo1;

        do {
          if (!iterator.hasNext()) {
            return null;
          }

          Village village = (Village) iterator.next();
          villagedoorinfo1 = village.getVillageDoorAt(par1, par2, par3);
        } while (villagedoorinfo1 == null);

        return villagedoorinfo1;
      }

      villagedoorinfo = (VillageDoorInfo) iterator.next();
    } while (villagedoorinfo.posX != par1
        || villagedoorinfo.posZ != par3
        || Math.abs(villagedoorinfo.posY - par2) > 1);

    return villagedoorinfo;
  }
  public boolean a() {
    if (this.a.world.r()) {
      return false;
    } else {
      Village village =
          this.a.world.villages.getClosestVillage(
              MathHelper.floor(this.a.locX),
              MathHelper.floor(this.a.locY),
              MathHelper.floor(this.a.locZ),
              16);

      if (village == null) {
        return false;
      } else {
        this.b =
            village.b(
                MathHelper.floor(this.a.locX),
                MathHelper.floor(this.a.locY),
                MathHelper.floor(this.a.locZ));
        return this.b == null
            ? false
            : (double)
                    this.b.c(
                        MathHelper.floor(this.a.locX),
                        MathHelper.floor(this.a.locY),
                        MathHelper.floor(this.a.locZ))
                < 2.25D;
      }
    }
  }
Пример #5
0
  public void func_82566_a(World par1World) {
    this.worldObj = par1World;
    Iterator iterator = this.villageList.iterator();

    while (iterator.hasNext()) {
      Village village = (Village) iterator.next();
      village.func_82691_a(par1World);
    }
  }
Пример #6
0
  /** reads in data from the NBTTagCompound into this MapDataBase */
  public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    this.tickCounter = par1NBTTagCompound.getInteger("Tick");
    NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Villages");

    for (int i = 0; i < nbttaglist.tagCount(); ++i) {
      NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
      Village village = new Village();
      village.readVillageDataFromNBT(nbttagcompound1);
      this.villageList.add(village);
    }
  }
Пример #7
0
  private void removeAnnihilatedVillages() {
    Iterator iterator = this.villageList.iterator();

    while (iterator.hasNext()) {
      Village village = (Village) iterator.next();

      if (village.isAnnihilated()) {
        iterator.remove();
        this.markDirty();
      }
    }
  }
Пример #8
0
  /** write data to NBTTagCompound from this MapDataBase, similar to Entities and TileEntities */
  public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
    par1NBTTagCompound.setInteger("Tick", this.tickCounter);
    NBTTagList nbttaglist = new NBTTagList("Villages");
    Iterator iterator = this.villageList.iterator();

    while (iterator.hasNext()) {
      Village village = (Village) iterator.next();
      NBTTagCompound nbttagcompound1 = new NBTTagCompound("Village");
      village.writeVillageDataToNBT(nbttagcompound1);
      nbttaglist.appendTag(nbttagcompound1);
    }

    par1NBTTagCompound.setTag("Villages", nbttaglist);
  }
  public boolean a() {
    if (this.a.world.w()) {
      return false;
    } else {
      BlockPosition blockposition = new BlockPosition(this.a);
      Village village = this.a.world.ae().getClosestVillage(blockposition, 16);

      if (village == null) {
        return false;
      } else {
        this.b = village.b(blockposition);
        return this.b == null ? false : (double) this.b.b(blockposition) < 2.25D;
      }
    }
  }
Пример #10
0
  /** Runs a single tick for the village collection */
  public void tick() {
    ++this.tickCounter;
    Iterator iterator = this.villageList.iterator();

    while (iterator.hasNext()) {
      Village village = (Village) iterator.next();
      village.tick(this.tickCounter);
    }

    this.removeAnnihilatedVillages();
    this.dropOldestVillagerPosition();
    this.addNewDoorsToVillageOrCreateVillage();

    if (this.tickCounter % 400 == 0) {
      this.markDirty();
    }
  }
Пример #11
0
  /**
   * Finds the nearest village, but only the given coordinates are withing it's bounding box plus
   * the given the distance.
   */
  public Village findNearestVillage(int par1, int par2, int par3, int par4) {
    Village village = null;
    float f = Float.MAX_VALUE;
    Iterator iterator = this.villageList.iterator();

    while (iterator.hasNext()) {
      Village village1 = (Village) iterator.next();
      float f1 = village1.getCenter().getDistanceSquared(par1, par2, par3);

      if (f1 < f) {
        int i1 = par4 + village1.getVillageRadius();

        if (f1 <= (float) (i1 * i1)) {
          village = village1;
          f = f1;
        }
      }
    }

    return village;
  }
Пример #12
0
  public void run() {
    try {
      while (true) {
        Village.isAttacked();

        // piggy back off the isAttacked thread to update server time
        ServerTimePanel.setServerTime(
            "Server time: "
                + WebAutomation.driver.findElement(By.xpath("//*[@id=\"serverTime\"]")).getText());

        // make the thread sleep for 10 secs
        Thread.sleep(10000);
      }
    } catch (NoSuchElementException e) {
    } catch (InterruptedException e) {
    } catch (StaleElementReferenceException e) {
    }
  }
Пример #13
0
  private void addNewDoorsToVillageOrCreateVillage() {
    int i = 0;

    while (i < this.newDoors.size()) {
      VillageDoorInfo villagedoorinfo = (VillageDoorInfo) this.newDoors.get(i);
      boolean flag = false;
      Iterator iterator = this.villageList.iterator();

      while (true) {
        if (iterator.hasNext()) {
          Village village = (Village) iterator.next();
          int j =
              (int)
                  village
                      .getCenter()
                      .getDistanceSquared(
                          villagedoorinfo.posX, villagedoorinfo.posY, villagedoorinfo.posZ);
          int k = 32 + village.getVillageRadius();

          if (j > k * k) {
            continue;
          }

          village.addVillageDoorInfo(villagedoorinfo);
          flag = true;
        }

        if (!flag) {
          Village village1 = new Village(this.worldObj);
          village1.addVillageDoorInfo(villagedoorinfo);
          this.villageList.add(village1);
          this.markDirty();
        }

        ++i;
        break;
      }
    }

    this.newDoors.clear();
  }
Пример #14
0
 private void updateConfig(SubnodeConfiguration newServerConfig)
     throws InvalidConfigurationException {
   log.debug("Updating server config for " + getServerId());
   this.config = newServerConfig;
   this.util.setServerConfig(newServerConfig);
   this.util.setServer(this);
   this.util.setServerId(user, getServerId()); // set server id for use in report processing
   // check if reading reports from overall server
   reportMode = newServerConfig.getString("/reports", null); // simple format to just read
   reportMode =
       newServerConfig.getString(
           "/reports/@enabled", reportMode); // complex config with processing
   if (reportMode != null) {
     SubnodeConfiguration reportConfig = newServerConfig.configurationAt("/reports");
     reportMode =
         reportConfig.getString("/output/@format", reportMode); // complex config with processing
     EventLog.log(loginUrl + " reportMode=" + reportMode);
     reportReader.setReportsMode(reportMode, reportConfig);
   }
   messageMode = newServerConfig.getString("/messages", null);
   messageMode = newServerConfig.getString("/messages/@enabled", messageMode);
   // note once enabled have to turn off by setting false or will not call to disable
   if (messageMode != null) {
     SubnodeConfiguration messageConfig = newServerConfig.configurationAt("/messages");
     String messageText = messageConfig.getString("/@commands", null);
     EventLog.log(
         loginUrl + " messageMode=" + messageMode + " Command Text (" + messageText + ")");
     // use same as mode or a separate param?
     messageReader.setMessagesMode(messageMode, messageConfig);
   }
   setTribeType(newServerConfig);
   //
   // Update villages
   // When a village is disabled or removed from the configuration, it is deleted from
   // this.villages
   List<Village> deletableVillages = new ArrayList<Village>(villages.values());
   // Loop all enabled villages
   List<SubnodeConfiguration> villageConfigs =
       newServerConfig.configurationsAt("/village[@enabled='true']");
   for (SubnodeConfiguration villageConfig : villageConfigs) {
     String id = Village.getIdFromConfig(villageConfig); // Either uid or url
     Village village = this.villages.get(id);
     if (village == null) {
       // New village
       village = new Village(util, villageConfig, strategyStatus);
       this.villages.put(id, village);
     } else {
       // Village already exists
       village.updateConfig(villageConfig, util);
       deletableVillages.remove(village); // This village is still enabled	
     }
   }
   // Removing deleted or disabled villages
   for (Village village : deletableVillages) {
     this.villages.remove(village.getId());
     village.terminate();
   }
   //
   // Update server strategies
   serverStrategyList =
       updateStrategies(
           "/serverStrategy[@enabled='true']", newServerConfig, serverStrategies, null);
 }
Пример #15
0
 private TimeWhenRunnable processVillages() throws InvalidConfigurationException {
   TimeWhenRunnable firstTimeWhenRunnable = null;
   try {
     List<SubnodeConfiguration> villageConfigs =
         config.configurationsAt("/village[@enabled='true']");
     for (SubnodeConfiguration villageConfig : villageConfigs) {
       // If configuration changed, abort current loop, update config and restart
       if (isConfigurationChanged()) {
         log.debug("Exiting village loop for configuration update");
         break;
       }
       String id = Village.getIdFromConfig(villageConfig);
       Village village = villages.get(id);
       if (village == null) {
         log.warn(
             "Configuration file not aligned to village map; ignoring village "
                 + villageConfig.getString("/@desc", "")
                 + " "
                 + villageConfig.getString("/url", ""));
         continue;
       }
       try {
         // getTimeWhenRunnable may update to check for triggering resources so can change page
         TimeWhenRunnable currentTimeWhenRunnable = village.getTimeWhenRunnable();
         // log.debug("currentTimeWhenRunnnable:"+currentTimeWhenRunnable);
         if (currentTimeWhenRunnable.before(new Date())) {
           EventLog.log("Processing village \"" + village.getDesc() + "\"");
           village.execute(); // Execute strategies
           currentTimeWhenRunnable = village.getTimeWhenRunnable();
           // log.debug("currentTimeWhenRunnnable after execute:"+currentTimeWhenRunnable);
         } else {
           EventLog.log(
               "Village \"" + village.getDesc() + "\" sleeping until " + currentTimeWhenRunnable);
         }
         // use current here and only reread after execute, then use new below
         if ((firstTimeWhenRunnable == null)
             || firstTimeWhenRunnable.after(currentTimeWhenRunnable)) {
           log.trace("Earlier Village " + village.getDesc() + " " + currentTimeWhenRunnable);
           firstTimeWhenRunnable = currentTimeWhenRunnable;
         }
         // check for earliest sharp strategy in village, return NEVER if none- if is store
         // earliest sharp one
         TimeWhenRunnable newTimeWhenRunnable = village.getTimeWhenSharp();
         if (newTimeWhenRunnable.isSharp()) {
           if (sharpTimeWhenRunnable == null || sharpTimeWhenRunnable.after(newTimeWhenRunnable)) {
             // log.trace("Earlier Village "+village.getDesc()+" "+newTimeWhenRunnable);
             sharpTimeWhenRunnable = newTimeWhenRunnable;
             log.trace(
                 "Earlier sharp Village is " + village.getDesc() + " " + sharpTimeWhenRunnable);
           }
         }
       } catch (SkipVillageRequested e) {
         log.debug("Village skipped");
         continue;
       } catch (SkipRequested e) {
         // Just keep going
         log.debug("Action skipped");
       } catch (ServerFatalException e) {
         throw e; // Will catch below
       } catch (Exception e) {
         String s = "Village \"" + village.getDesc() + "\" error (retrying later): ";
         log.error(s, e);
         EventLog.log(s + e.getMessage());
         util.shortestPause(false); // Just to be safe
         firstTimeWhenRunnable = null; // Retry after userPause
       }
     }
   } catch (ConcurrentModificationException e) {
     // This shouldn't happen anymore
     // Just ignore
     log.debug(
         "Village list was modified while server running (ConcurrentModificationException): skipping and repeating");
   }
   // log.debug("returning firstTimeWhenRunnable:"+firstTimeWhenRunnable);
   return firstTimeWhenRunnable;
 }