net.minecraft.profiler.Profiler类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(180)

本文整理了Java中net.minecraft.profiler.Profiler类的一些代码示例,展示了Profiler类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Profiler类的具体详情如下:
包路径:net.minecraft.profiler.Profiler
类名称:Profiler

Profiler介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void onDrawScreenPre(RenderGameOverlayEvent.Pre event) {
  Minecraft mc = Minecraft.getMinecraft();
  Profiler profiler = mc.profiler;
  if(event.getType() == ElementType.HEALTH) {
    profiler.startSection("botania-hud");
    IItemHandler baublesInv = BaublesApi.getBaublesHandler(mc.player);
    ItemStack headpiece = baublesInv.getStackInSlot(4);
    if(!headpiece.isEmpty() && headpiece.getItem() == ModItems.flightTiara) {
      profiler.startSection("flugelTiara");
      ItemFlightTiara.renderHUD(event.getResolution(), mc.player, headpiece);
      profiler.endSection();
    }
    dodgeRing: {
      ItemStack ring = baublesInv.getStackInSlot(1);
      if(ring.isEmpty() || !(ring.getItem() instanceof ItemDodgeRing)) {
        ring = baublesInv.getStackInSlot(2);
        if(ring.isEmpty() || !(ring.getItem() instanceof ItemDodgeRing))
          break dodgeRing;
      }
      profiler.startSection("dodgeRing");
      ItemDodgeRing.renderHUD(event.getResolution(), mc.player, ring, event.getPartialTicks());
      profiler.endSection();
    }
    profiler.endSection();
  }
}

代码示例来源:origin: Vazkii/Botania

public static void dispatch() {
  Tessellator tessellator = Tessellator.getInstance();
  Profiler profiler = Minecraft.getMinecraft().profiler;
  GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
  GlStateManager.depthMask(false);
  GlStateManager.enableBlend();
  GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
  GlStateManager.alphaFunc(GL11.GL_GREATER, 0.003921569F);
  GlStateManager.disableLighting();
  profiler.startSection("sparkle");
  FXSparkle.dispatchQueuedRenders(tessellator);
  profiler.endStartSection("wisp");
  FXWisp.dispatchQueuedRenders(tessellator);
  profiler.endSection();
  GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
  GlStateManager.disableBlend();
  GlStateManager.depthMask(true);
  GL11.glPopAttrib();
}

代码示例来源:origin: superckl/BiomeTweaker

public DummyWorld(final WorldInfo info) {
  super(null, info, new DummyWorldProvider(), new Profiler(), true);
}

代码示例来源:origin: DimensionalDevelopment/VanillaFix

/**
   * @reason Adds subsections to the "root.tick.level.entities.blockEntities"
   * profiler, using the entity ID, or the class name if the ID is null.
   */
  @Redirect(method = "updateEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ITickable;update()V"))
  private void tileEntityUpdate(ITickable tileEntity) {
    profiler.func_194340_a(() -> { // func_194340_a = startSection(Supplier<String>)
      final ResourceLocation tileEntityID = TileEntity.getKey(((TileEntity) tileEntity).getClass());
      return tileEntityID == null ? tileEntity.getClass().getSimpleName() : tileEntityID.toString();
    });
    tileEntity.update();
    profiler.endSection();
  }
}

代码示例来源:origin: SleepyTrousers/EnderIO

public static void stop(@Nullable Profiler profiler) {
 if (--counter.get().count >= 0) {
  if (profiler != null) {
   profiler.endSection();
  }
 } else {
  new RuntimeException("Profiler underflow!").printStackTrace();
 }
}

代码示例来源:origin: SleepyTrousers/EnderIO

public static void start(@Nullable Profiler profiler, @Nonnull String section) {
 if (profiler != null) {
  profiler.startSection(section);
 }
 counter.get().count++;
}

代码示例来源:origin: SleepyTrousers/EnderIO

public static void next(@Nullable Profiler profiler, @Nonnull String section) {
 if (profiler != null) {
  profiler.endStartSection(section);
 }
}

代码示例来源:origin: DimensionalDevelopment/VanillaFix

/**
 * @reason Store profiler data on each tick such that the client can get it
 * without having to call getLastProfilerData (Profiler isn't async).
 */
@Inject(method = "tick", at = @At("HEAD"))
private void updateLastProfilerData(CallbackInfo ci) {
  if (profiler.profilingEnabled) {
    lastProfilerData = profiler.getProfilingData(profilerName);
  } else {
    lastProfilerData = null;
  }
}

代码示例来源:origin: DimensionalDevelopment/VanillaFix

/**
   * @reason Adds subsections to the "root.gameRenderer.level.entities.blockentities"
   * profiler, using the tile entity ID, or the class name if the id is null.
   */
  @Redirect(method = "renderEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher;render(Lnet/minecraft/tileentity/TileEntity;FI)V"))
  private void tileEntityRender(TileEntityRendererDispatcher renderDispatcher, TileEntity tileEntity, float partialTicks, int destroyStage) {
    world.profiler.func_194340_a(() -> { // func_194340_a = startSection(Supplier<String>)
      final ResourceLocation tileEntityId = TileEntity.getKey(((TileEntity) tileEntity).getClass());
      return tileEntityId == null ? tileEntity.getClass().getSimpleName() : tileEntityId.toString();
    });
    renderDispatcher.render(tileEntity, partialTicks, destroyStage);
    world.profiler.endSection();
  }
}

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
public void endSection() {
 if (this.profilingEnabled && !isBlacklisted(new RuntimeException())) {
  super.endSection();
 }
}

代码示例来源:origin: SleepyTrousers/EnderIO

public static void start(@Nullable Profiler profiler, @Nonnull String section, @Nullable Object param) {
 if (profiler != null) {
  profiler.startSection(makeSection(section, param));
 }
 counter.get().count++;
}

代码示例来源:origin: SleepyTrousers/EnderIO

public static void next(@Nullable Profiler profiler, @Nonnull String section, @Nullable Object param) {
 if (profiler != null) {
  profiler.endStartSection(makeSection(section, param));
 }
}

代码示例来源:origin: DimensionalDevelopment/VanillaFix

/**
 * @reason Profiler isn't safe to use async, so get the results from server's last tick if server
 * profilder is being displayed.
 * <p>
 * Note: profilerName is always "root" client-side
 */
@SuppressWarnings("InvalidMemberReference") // https://github.com/minecraft-dev/MinecraftDev/issues/387
@Redirect(method = {"displayDebugInfo", "updateDebugProfilerName"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/profiler/Profiler;getProfilingData(Ljava/lang/String;)Ljava/util/List;"))
private List<Profiler.Result> getProfilerData(Profiler profiler, String profilerName) {
  if (useIntegratedServerProfiler && integratedServer != null) {
    return new ArrayList<>(((IPatchedMinecraftServer) integratedServer).getLastProfilerData());
  } else {
    return profiler.getProfilingData(profilerName);
  }
}

代码示例来源:origin: Vazkii/Botania

private static void renderWandModeDisplay(ItemStack stack, ScaledResolution res) {
  Minecraft mc = Minecraft.getMinecraft();
  Profiler profiler = mc.profiler;
  profiler.startSection("wandMode");
  int ticks = mc.ingameGUI.remainingHighlightTicks;
  ticks -= 15;
  if(ticks > 0) {
    int alpha = Math.min(255, (int) (ticks * 256.0F / 10.0F));
    int color = 0x00CC00 + (alpha << 24);
    String disp = I18n.format(ItemTwigWand.getModeString(stack));
    int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(disp) / 2;
    int y = res.getScaledHeight() - 70;
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    mc.fontRenderer.drawStringWithShadow(disp, x, y, color);
    GlStateManager.disableBlend();
  }
  profiler.endSection();
}

代码示例来源:origin: Vazkii/Botania

profiler.startSection("botania-hud");
RayTraceResult pos = mc.objectMouseOver;
        profiler.startSection("wandItem");
        ((IWandHUD) block).renderHUD(mc, event.getResolution(), mc.world, pos.getBlockPos());
        profiler.endSection();
  profiler.startSection("nearIndex");
  renderNearIndexDisplay(event.getResolution());
  profiler.endSection();
  profiler.startSection("multiblockRightClick");
  String s = I18n.format("botaniamisc.rightClickToAnchor");
  mc.fontRenderer.drawStringWithShadow(s, event.getResolution().getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(s) / 2, event.getResolution().getScaledHeight() / 2 - 30, 0xFFFFFF);
  profiler.endSection();
  profiler.startSection("craftingHalo_main");
  ItemCraftingHalo.renderHUD(event.getResolution(), mc.player, main);
  profiler.endSection();
} else if(!offhand.isEmpty() && offhand.getItem() instanceof ItemCraftingHalo) {
  profiler.startSection("craftingHalo_off");
  ItemCraftingHalo.renderHUD(event.getResolution(), mc.player, offhand);
  profiler.endSection();
  profiler.startSection("sextant");
  ItemSextant.renderHUD(event.getResolution(), mc.player, main);
  profiler.endSection();
  profiler.startSection("monocle");

代码示例来源:origin: DimensionalDevelopment/VanillaFix

/**
 * @reason Adds subsections to the "root.tick.level.entities.regular.tick"
 * profiler, using the entity ID, or the class name if the ID is null.
 */
@Redirect(method = "updateEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;updateEntity(Lnet/minecraft/entity/Entity;)V"))
private void updateEntity(World world, Entity entity) {
  profiler.func_194340_a(() -> { // func_194340_a = startSection(Supplier<String>)
    final ResourceLocation entityID = EntityList.getKey(entity);
    return entityID == null ? entity.getClass().getSimpleName() : entityID.toString();
  });
  updateEntity(entity);
  profiler.endSection();
}

代码示例来源:origin: SleepyTrousers/EnderIO

super.endSection();

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
public void startSection(@Nonnull String name) {
 if (this.profilingEnabled) {
  super.startSection(name);
  if (stack.isEmpty() && name.equals("root")) {
   discarded.clear();
   candidates.clear();
  }
  stack.add(0, new Element(getNameOfLastSection(), new RuntimeException()));
 }
}

代码示例来源:origin: DimensionalDevelopment/VanillaFix

/** @reason Part 2 of GUI logic fix. */
@Redirect(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/TextureManager;tick()V", ordinal = 0))
private void tickTextureManagerWithCorrectProfiler(TextureManager textureManager) {
  profiler.endStartSection("textures");
  textureManager.tick();
  profiler.endStartSection("gui");
}

代码示例来源:origin: Lunatrius/Schematica

public static WorldDummy instance() {
    if (instance == null) {
      final WorldSettings worldSettings = new WorldSettings(0, GameType.CREATIVE, false, false, WorldType.FLAT);
      final WorldInfo worldInfo = new WorldInfo(worldSettings, "FakeWorld");
      instance = new WorldDummy(new SaveHandlerSchematic(), worldInfo, new WorldProviderSchematic(), new Profiler(), false);
    }

    return instance;
  }
}

相关文章