数据system
本帖最后由 数据system 于 2020-9-27 23:30 编辑
  1.     //渲染HUD
  2.     @SubscribeEvent
  3.     public void onUseItem(RenderGameOverlayEvent event) {
  4.             ResourceLocation Hud = new ResourceLocation("textures/gui/Hud18.png");
  5.             Minecraft Mc = Minecraft.getMinecraft();
  6.         if (event.getType() != RenderGameOverlayEvent.ElementType.ALL) {
  7.             return;
  8.         }
  9.         int width = (event.getResolution().getScaledWidth()-182)/2;
  10.         int height = event.getResolution().getScaledHeight();
  11.         
  12.         Mc.renderEngine.bindTexture(Hud);
  13.         Mc.ingameGUI.drawTexturedModalRect(width, height-60, 0, 0, 182, 5);
  14.     }
复制代码
直接写在事件的类当中,会出现贴图渲染错误

各位大佬们这应该如何解决?应该怎么写才能在客户端为其指定贴图?
请问各位大佬们有没有hud的教程吗?论坛里似乎没有关于hud的详细教程

2021.12 数据,可能有更多内容 本帖最后由 数据system 于 2020-9-27 23:30 编辑

代码:

  1.     //渲染HUD
  2.     @SubscribeEvent
  3.     public void onUseItem(RenderGameOverlayEvent event) {
  4.    ResourceLocation Hud = new ResourceLocation("textures/gui/Hud18.png");
  5.    Minecraft Mc = Minecraft.getMinecraft();
  6.   if (event.getType() != RenderGameOverlayEvent.ElementType.ALL) {
  7.    return;
  8.   }
  9.   int width = (event.getResolution().getScaledWidth()-182)/2;
  10.   int height = event.getResolution().getScaledHeight();
  11.  
  12.   Mc.renderEngine.bindTexture(Hud);
  13.   Mc.ingameGUI.drawTexturedModalRect(width, height-60, 0, 0, 182, 5);
  14.     }
直接写在事件的类当中,会出现贴图渲染错误



各位大佬们这应该如何解决?应该怎么写才能在客户端为其指定贴图?
请问各位大佬们有没有hud的教程吗?论坛里似乎没有关于hud的详细教程

liangyaow123
6666666666

3TUSK
  1. ResourceLocation Hud = new ResourceLocation("textures/gui/Hud18.png");
复制代码


这个 ResourceLocation 会被解读为 assets/minecraft/textures/gui/Hud18.png。请改成:

  1. ResourceLocation Hud = new ResourceLocation("my_mod", "textures/gui/Hud18.png");
复制代码


其中 my_mod 是你的 modid。

数据system
本帖最后由 数据system 于 2020-9-28 13:24 编辑

已经解决问题。

第一页 上一页 下一页 最后一页