Package nallar.collections

Examples of nallar.collections.LongList


    profiler.startSection("spawnableChunks");
    int attemptedSpawnedMobs = 0;
    LongSet closeChunks = new LongSet();
    Collection<EntityPlayer> entityPlayers = worldServer.playerEntities;
    LongList spawnableChunks = new LongList(entityPlayers.size() * maxChunksPerPlayer);
    for (EntityPlayer entityPlayer : entityPlayers) {
      int pX = entityPlayer.chunkCoordX;
      int pZ = entityPlayer.chunkCoordZ;
      int x = pX - closeRange;
      int maxX = pX + closeRange;
      int startZ = pZ - closeRange;
      int maxZ = pZ + closeRange;
      for (; x <= maxX; x++) {
        for (int z = startZ; z <= maxZ; z++) {
          closeChunks.add(hash(x, z));
        }
      }
    }
    for (EntityPlayer entityPlayer : entityPlayers) {
      int pX = entityPlayer.chunkCoordX;
      int pZ = entityPlayer.chunkCoordZ;
      int x = pX - farRange;
      int maxX = pX + farRange;
      int startZ = pZ - farRange;
      int maxZ = pZ + farRange;
      for (; x <= maxX; x++) {
        for (int z = startZ; z <= maxZ; z++) {
          long hash = hash(x, z);
          if (!closeChunks.contains(hash)) {
            spawnableChunks.add(hash);
          }
        }
      }
    }
    profiler.endStartSection("spawnMobs");

    int size = spawnableChunks.size;
    if (size < 1) {
      return 0;
    }

    SpawnLoop:
    for (Map.Entry<EnumCreatureType, Integer> entry : requiredSpawns.entrySet()) {
      EnumCreatureType creatureType = entry.getKey();
      long hash = spawnableChunks.get(worldServer.rand.nextInt(size));
      int x = (int) (hash >> 32);
      int z = (int) hash;
      int sX = x * 16 + worldServer.rand.nextInt(16);
      int sZ = z * 16 + worldServer.rand.nextInt(16);
      boolean surface = creatureType.getPeacefulCreature() || (dayTime ? surfaceChance++ % 5 == 0 : surfaceChance++ % 5 != 0);
View Full Code Here

TOP

Related Classes of nallar.collections.LongList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.