Package net.minecraft.profiler

Examples of net.minecraft.profiler.Profiler


      threadManager.waitForCompletion();
    }

    HashSet<ChunkCoordIntPair> activeChunkSet = chunkTickSet;
    if (tickCount % 7 == 0) {
      Profiler profiler = this.theProfiler;
      profiler.startSection("buildList");

      activeChunkSet.clear();
      activeChunkSet.addAll(getPersistentChunks().keySet());
      List<EntityPlayer> playerEntities = this.playerEntities;
      for (EntityPlayer entityPlayer : playerEntities) {
        int x = (int) (entityPlayer.posX / 16.0D);
        int z = (int) (entityPlayer.posZ / 16.0D);
        byte var5 = 6;

        for (int var6 = -var5; var6 <= var5; ++var6) {
          for (int var7 = -var5; var7 <= var5; ++var7) {
            activeChunkSet.add(new ChunkCoordIntPair(var6 + x, var7 + z));
          }
        }
      }

      profiler.endSection();

      if (this.ambientTickCountdown > 0) {
        --this.ambientTickCountdown;
      }

      profiler.startSection("playerCheckLight");

      Random rand = this.rand;
      if (!playerEntities.isEmpty()) {
        EntityPlayer entityPlayer = playerEntities.get(rand.nextInt(playerEntities.size()));
        if (entityPlayer != null) {
          int x = ((int) entityPlayer.posX) + rand.nextInt(11) - 5;
          int y = ((int) entityPlayer.posY) + rand.nextInt(11) - 5;
          int z = ((int) entityPlayer.posZ) + rand.nextInt(11) - 5;
          this.updateAllLightTypes(x, y, z);
        }
      }

      profiler.endSection();
    }

    chunkCoordIterator = activeChunkSet.iterator();

    if (concurrentTicks) {
View Full Code Here


    }
  }

  @Override
  public void updateEntities() {
    final Profiler theProfiler = this.theProfiler;
    theProfiler.startSection("updateEntities");
    int var1;
    Entity weatherEffect;
    CrashReport var4;
    CrashReportCategory var5;

    theProfiler.startSection("global");
    final List<Entity> weatherEffects = this.weatherEffects;
    synchronized (weatherEffects) {
      Iterator<Entity> iterator = weatherEffects.iterator();
      while (iterator.hasNext()) {
        weatherEffect = iterator.next();

        if (weatherEffect == null) {
          iterator.remove();
          continue;
        }

        try {
          ++weatherEffect.ticksExisted;
          weatherEffect.onUpdate();
        } catch (Throwable t) {
          Log.severe("Failed to tick weather " + Log.toString(weatherEffect), t);
        }

        if (weatherEffect.isDead) {
          iterator.remove();
        }
      }
    }

    theProfiler.endStartSection("remove");
    int var3;
    int var13;
    final List loadedEntityList = this.loadedEntityList;
    boolean tickTT = loadedEntityList instanceof EntityList;
    if (tickTT) {
      ((EntityList) loadedEntityList).manager.batchRemoveEntities(unloadedEntitySet);
      ((EntityList) loadedEntityList).manager.doTick();
    } else {
      loadedEntityList.removeAll(unloadedEntitySet);

      for (Entity entity : unloadedEntitySet) {
        var3 = entity.chunkCoordX;
        var13 = entity.chunkCoordZ;

        if (entity.addedToChunk) {
          Chunk chunk = getChunkIfExists(var3, var13);
          if (chunk != null) {
            chunk.removeEntity(entity);
          }
        }

        onEntityRemoved(entity);
      }
      unloadedEntitySet.clear();
      theProfiler.endStartSection("entities");
      for (var1 = 0; var1 < loadedEntityList.size(); ++var1) {
        weatherEffect = (Entity) loadedEntityList.get(var1);

        if (weatherEffect.ridingEntity != null) {
          if (!weatherEffect.ridingEntity.isDead && weatherEffect.ridingEntity.riddenByEntity == weatherEffect) {
            continue;
          }

          weatherEffect.ridingEntity.riddenByEntity = null;
          weatherEffect.ridingEntity = null;
        }

        theProfiler.startSection("tick");

        if (!weatherEffect.isDead) {
          try {
            updateEntity(weatherEffect);
          } catch (Throwable var7) {
            var4 = CrashReport.makeCrashReport(var7, "Ticking entity");
            var5 = var4.makeCategory("Entity being ticked");
            weatherEffect.addEntityCrashInfo(var5);

            throw new ReportedException(var4);
          }
        }

        theProfiler.endSection();
        theProfiler.startSection("remove");

        if (weatherEffect.isDead) {
          var3 = weatherEffect.chunkCoordX;
          var13 = weatherEffect.chunkCoordZ;

          if (weatherEffect.addedToChunk) {
            Chunk chunk = getChunkIfExists(var3, var13);
            if (chunk != null) {
              chunk.removeEntity(weatherEffect);
            }
          }

          loadedEntityList.remove(var1--);
          onEntityRemoved(weatherEffect);
        }

        theProfiler.endSection();
      }
      theProfiler.endStartSection("tileEntities");
      scanningTileEntities = true;

      Iterator var14 = loadedTileEntityList.iterator();

      while (var14.hasNext()) {
        TileEntity var9 = (TileEntity) var14.next();

        if (!var9.isInvalid() && var9.hasWorldObj() && blockExists(var9.xCoord, var9.yCoord, var9.zCoord)) {
          try {
            var9.updateEntity();
          } catch (Throwable var8) {
            var4 = CrashReport.makeCrashReport(var8, "Ticking tile entity");
            var5 = var4.makeCategory("Tile entity being ticked");
            var9.func_85027_a(var5);

            throw new ReportedException(var4);
          }
        }

        if (var9.isInvalid()) {
          var14.remove();

          Chunk var11 = getChunkIfExists(var9.xCoord >> 4, var9.zCoord >> 4);

          if (var11 != null) {
            var11.cleanChunkBlockTileEntity(var9.xCoord & 15, var9.yCoord, var9.zCoord & 15);
          }
        }
      }
    }

    theProfiler.endStartSection("removingTileEntities");

    final List loadedTileEntityList = this.loadedTileEntityList;
    if (loadedTileEntityList instanceof LoadedTileEntityList) {
      ((LoadedTileEntityList) loadedTileEntityList).manager.batchRemoveTileEntities(tileEntityRemovalSet);
    } else {
      if (!warnedWrongList && loadedTileEntityList.getClass() != ArrayList.class) {
        Log.severe("TickThreading's replacement loaded tile entity list has been replaced by one from another mod!\n" +
            "Class: " + loadedTileEntityList.getClass() + ", toString(): " + loadedTileEntityList);
        warnedWrongList = true;
      }
      for (TileEntity tile : tileEntityRemovalSet) {
        tile.onChunkUnload();
      }
      loadedTileEntityList.removeAll(tileEntityRemovalSet);
      tileEntityRemovalSet.clear();
    }

    scanningTileEntities = false;

    theProfiler.endStartSection("pendingTileEntities");

    if (!addedTileEntityList.isEmpty()) {
      for (TileEntity te : (Iterable<TileEntity>) addedTileEntityList) {
        if (te.isInvalid()) {
          Chunk var15 = getChunkIfExists(te.xCoord >> 4, te.zCoord >> 4);

          if (var15 != null) {
            var15.cleanChunkBlockTileEntity(te.xCoord & 15, te.yCoord, te.zCoord & 15);
          }
        } else {
          if (!loadedTileEntityList.contains(te)) {
            loadedTileEntityList.add(te);
          }
        }
      }

      addedTileEntityList.clear();
    }

    theProfiler.endSection();
    theProfiler.endSection();
  }
View Full Code Here

    tickTime = tickTime * 0.98f + ((this.tickTimeArray[ticks % 100] = System.nanoTime() - startTime) * 0.02f);
  }

  @Override
  public void updateTimeLightAndEntities() {
    final Profiler profiler = theProfiler;
    profiler.startSection("levels");

    runQueuedTasks();

    Integer[] dimensionIdsToTick = this.dimensionIdsToTick = DimensionManager.getIDs();

    if (threadManager == null) {
      threadManager = new ThreadManager(8, "World Tick");
      currentWorld = new AtomicInteger(0);
      tickRunnable = new TickRunnable(this);
    }

    currentWorld.set(0);

    boolean concurrentTicking = tickCounter >= 100 && !profiler.profilingEnabled;

    if (concurrentTicking) {
      int count = threadManager.size();
      if (count < dimensionIdsToTick.length) {
        count = dimensionIdsToTick.length;
      }
      for (int i = 0; i < count; i++) {
        threadManager.run(tickRunnable);
      }
    } else {
      // Gregtech leaks the first world which is ticked. If we tick overworld first, no leak. Only applies to first tick on server start.
      Integer[] dimensionIdsToTickOrdered = new Integer[dimensionIdsToTick.length];
      int i = 0;
      for (int d : dimensionIdsToTick) {
        if (d == 0) {
          dimensionIdsToTickOrdered[i++] = 0;
          break;
        }
      }
      for (int d : dimensionIdsToTick) {
        if (d != 0) {
          dimensionIdsToTickOrdered[i++] = d;
        }
      }
      this.dimensionIdsToTick = dimensionIdsToTickOrdered;
      if (tickCounter == 1) {
        Log.checkWorlds();
      }
      doWorldTick();
    }

    profiler.endStartSection("players");
    this.serverConfigManager.sendPlayerInfoToAllPlayers();

    profiler.endStartSection("tickables");
    for (IUpdatePlayerListBox tickable : (Iterable<IUpdatePlayerListBox>) this.tickables) {
      tickable.update();
    }

    if (concurrentTicking) {
      threadManager.waitForCompletion();
    }

    profiler.endStartSection("connection");
    this.getNetworkThread().networkTick();

    profiler.endStartSection("dim_unloading");
    DimensionManager.unloadWorlds(worldTickTimes);

    profiler.endSection();
  }
View Full Code Here

  }

  @Override
  @Declare
  public void doWorldTick() {
    final Profiler profiler = this.theProfiler;
    int i;
    while ((i = currentWorld.getAndIncrement()) < dimensionIdsToTick.length) {
      int id = dimensionIdsToTick[i];
      long var2 = System.nanoTime();

      WorldServer world = DimensionManager.getWorld(id);
      String name = world.getName();
      if (!world.loadEventFired) {
        Log.severe("Not sent WorldEvent.Load for loaded world " + name + ", sending it now.");
        MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));
      }
      if (world.getDimension() != id) {
        Log.severe("World " + world.getName() + " exists in DimensionManager with an apparently incorrect dimension ID of " + id);
        continue;
      }
      try {
        profiler.startSection(world.getWorldInfo().getWorldName());
        profiler.startSection("pools");
        world.getWorldVec3Pool().clear();
        profiler.endSection();

        int tickCount = world.tickCount;
        if (tickCount % 30 == 0) {
          profiler.startSection("timeSync");
          long totalTime = world.getTotalWorldTime();
          boolean doDaylightCycle = world.getGameRules().getGameRuleBooleanValue("doDaylightCycle");
          for (EntityPlayerMP entityPlayerMP : (Iterable<EntityPlayerMP>) world.playerEntities) {
            entityPlayerMP.playerNetServerHandler.sendPacketToPlayer(new Packet4UpdateTime(totalTime, entityPlayerMP.getPlayerTime(), doDaylightCycle));
          }
          profiler.endSection();
        }

        profiler.startSection("forgeTick");
        FMLCommonHandler.instance().onPreWorldTick(world);

        profiler.endStartSection("worldTick");
        world.tick();
        profiler.endStartSection("entityTick");
        world.updateEntities();
        profiler.endStartSection("postForgeTick");
        FMLCommonHandler.instance().onPostWorldTick(world);
        profiler.endSection();
        profiler.startSection("tracker");
        world.getEntityTracker().updateTrackedEntities();
        profiler.endSection();
        if (tickCount % 14 == 0) {
          exceptionCount.put(id, 0);
        }
        if (TickThreading.checkSaveInterval(tickCount)) {
          theProfiler.startSection("save");
          try {
            currentlySaving.getAndIncrement();
            long st = 0;
            boolean enabled = Timings.enabled;
            if (enabled) {
              st = System.nanoTime();
            }
            if (world.saveTickCount++ % 20 == 0) {
              world.saveAllChunks(false, null);
            } else {
              if (world.theChunkProviderServer.canSave()) {
                world.theChunkProviderServer.saveChunks(false, null);
              }
            }
            if (enabled) {
              Timings.record("World/save", System.nanoTime() - st);
            }
          } catch (MinecraftException e) {
            throw UnsafeUtil.throwIgnoreChecked(e);
          } finally {
            currentlySaving.getAndDecrement();
          }
          theProfiler.endSection();
        }
        profiler.endSection();

        long[] tickTimes = worldTickLengths.get(name);
        if (tickTimes == null) {
          tickTimes = new long[100];
          worldTickLengths.put(name, tickTimes);
View Full Code Here

TOP

Related Classes of net.minecraft.profiler.Profiler

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.