Package net.minecraft.world.gen

Examples of net.minecraft.world.gen.ChunkProviderServer


    int duplicateTiles = 0;
    int invalidTiles = 0;
    int unloadedEntities = 0;
    int unloadedTiles = 0;

    ChunkProviderServer chunkProviderServer = world.theChunkProviderServer;

    {
      Set<Entity> contained = new HashSet<Entity>();
      Set<Entity> toRemove = new ContainedRemoveSet<Entity>();
      List<Entity> unloaded = new ArrayList<Entity>();
      synchronized (entityLock) {
        for (Entity e : entityList) {
          if (add(e, false)) {
            missingEntities++;
            fixed++;
          } else if (!contained.add(e)) {
            toRemove.add(e);
            duplicateEntities++;
            fixed++;
          } else if (e instanceof IProjectile || e instanceof EntityCreature || e instanceof EntityMob) {
            synchronized (e) {
              Chunk chunk = world.getChunkIfExists(e.chunkCoordX, e.chunkCoordZ);
              if (chunk == null || !chunk.entityLists[e.chunkCoordY].contains(e)) {
                unloaded.add(e);
                unloadedEntities++;
              }
            }
          }
        }
        for (Entity e : unloaded) {
          remove(e);
        }
        entityList.removeAll(toRemove);
      }
    }

    {
      Set<TileEntity> contained = new HashSet<TileEntity>();
      Set<TileEntity> toRemove = new ContainedRemoveSet<TileEntity>();
      List<TileEntity> copy = new ArrayList<TileEntity>(tileEntityList.size());
      synchronized (tileEntityLock) {
        for (TileEntity te : tileEntityList) {
          copy.add(te);
          if (add(te, false)) {
            missingTiles++;
            fixed++;
          }
          if (!contained.add(te)) {
            toRemove.add(te);
            duplicateTiles++;
            fixed++;
          }
        }
        tileEntityList.removeAll(toRemove);
      }

      for (TileEntity te : copy) {
        Chunk chunk;
        boolean invalid = te.isInvalid();
        if (te.yCoord < 0 || te.yCoord > 255) {
          sb.append("TileEntity ").append(Log.toString(te)).append(" has an invalid y coordinate.\n");
          invalid = true;
        }
        if (invalid || (chunk = chunkProviderServer.getChunkIfExists(te.xCoord >> 4, te.zCoord >> 4)) == null || chunk.getChunkBlockTileEntity(te.xCoord & 15, te.yCoord, te.zCoord & 15) != te) {
          if (invalid) {
            invalidTiles++;
            sb.append("Removed ").append(Log.toString(te)).append(" as it is invalid.\n");
          } else {
            unloadedTiles++;
View Full Code Here


  }

  @Override
  @Declare
  public Object[] getChunks() {
    ChunkProviderServer chunkProviderServer = theChunkProviderServer;
    if (chunkProviderServer == null) {
      Log.warning("Bukkit getChunks call for unloaded world", new Throwable());
      return new Object[0];
    }
    List<Chunk> loadedChunks = chunkProviderServer.getLoadedChunks();
    synchronized (loadedChunks) {
      return loadedChunks.toArray();
    }
  }
View Full Code Here

  @Override
  public void run() {
    double tpsFactor = MinecraftServer.getTPS() / MinecraftServer.getTargetTPS();
    final Random rand = randoms.get();
    final Iterator<ChunkCoordIntPair> chunkCoordIterator = this.chunkCoordIterator;
    final ChunkProviderServer chunkProviderServer = this.theChunkProviderServer;
    final boolean isRaining = this.isRaining();
    final boolean isThundering = this.isThundering();
    final WorldProvider provider = this.provider;
    int updateLCG = this.updateLCG;
    // We use a random per thread - randoms are threadsafe, however it can result in some contention. See Random.nextInt - compareAndSet.
    // This reduces contention -> slightly increased performance, woo! :P
    while (true) {
      ChunkCoordIntPair chunkCoordIntPair;
      synchronized (chunkCoordIterator) {
        if (!chunkCoordIterator.hasNext()) {
          break;
        }
        try {
          chunkCoordIntPair = chunkCoordIterator.next();
        } catch (ConcurrentModificationException e) {
          break;
        }
      }

      if (tpsFactor < 1 && rand.nextFloat() > tpsFactor) {
        continue;
      }

      int cX = chunkCoordIntPair.chunkXPos;
      int cZ = chunkCoordIntPair.chunkZPos;

      Chunk chunk = chunkProviderServer.getChunkFastUnsafe(cX, cZ);
      if (chunk == null || !chunk.isTerrainPopulated || chunk.partiallyUnloaded || chunk.queuedUnload) {
        continue;
      }

      int xPos = cX * 16;
 
View Full Code Here

    super(world, manager, regionX, regionZ);
  }

  @Override
  public void doTick() {
    ChunkProviderServer chunkProvider = (ChunkProviderServer) world.getChunkProvider();
    boolean profilingEnabled = manager.profilingEnabled || this.profilingEnabled;
    EntityTickProfiler entityTickProfiler = profilingEnabled ? EntityTickProfiler.ENTITY_TICK_PROFILER : null;
    long startTime = 0;
    Iterator<Entity> entitiesIterator = entitySet.startIteration();
    try {
      while (entitiesIterator.hasNext()) {
        if (profilingEnabled) {
          startTime = System.nanoTime();
        }
        Entity entity = entitiesIterator.next();
        try {
          Entity ridingEntity = entity.ridingEntity;
          if (ridingEntity != null) {
            if (!ridingEntity.isDead && ridingEntity.riddenByEntity == entity) {
              continue;
            }

            ridingEntity.riddenByEntity = null;
            entity.ridingEntity = null;
          }

          if (!entity.isDead) {
            if (entity instanceof EntityPlayerMP) {
              Unsafe $ = UnsafeAccess.$;
              Object lock = ((EntityPlayerMP) entity).playerNetServerHandler;
              if ($.tryMonitorEnter(lock)) {
                try {
                  world.updateEntity(entity);
                } finally {
                  $.monitorExit(lock);
                }
              }
            } else {
              world.updateEntity(entity);
            }
          }

          if (entity.isDead) {
            int entityX = entity.chunkCoordX;
            int entityZ = entity.chunkCoordZ;

            synchronized (entity) {
              if (entity.addedToChunk) {
                Chunk chunk = entity.chunk;
                if (chunk == null) {
                  chunkProvider.getChunkIfExists(entityX, entityZ);
                }
                if (chunk != null) {
                  chunk.removeEntity(entity);
                }
              }
View Full Code Here

TOP

Related Classes of net.minecraft.world.gen.ChunkProviderServer

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.