Orion_shadow
这个是GUi类的代码
  1. public class GuiContainerDemo extends GuiContainer {
  2.         private static final String TEXTURE_PATH = Begin.MOD_ID + ":" + "textures/gui/container/gui_demo.png";
  3.         private static final ResourceLocation TEXTURE = new ResourceLocation(TEXTURE_PATH);
  4.         public GuiContainerDemo(Container inventorySlotsIn) {
  5.                super(inventorySlotsIn);
  6.                this.xSize = 176;
  7.                 this.ySize = 133;
  8.         }

  9.         /**
  10.           * Draws the background layer of this container (behind the items).
  11.           *
  12.           * @param partialTicks
  13.           * @param mouseX
  14.           * @param mouseY
  15.           */
  16.          @Override
  17.          protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
  18.                 GlStateManager.color(1.0F, 1.0F, 1.0F);
  19.                 this.mc.getTextureManager().bindTexture(TEXTURE);
  20.                 int offsetX = (this.width-this.xSize)/2;
  21.                 int offsetY = (this.height-this.ySize)/2;
  22.                 this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
  23.         }
  24. }
复制代码
我希望右键手里的一个物品然后出现这个gui界面
这个是调用方法
  1. public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
  2.                     BlockPos blockPos = playerIn.getPosition();
  3.                     playerIn.openGui(Begin.INSTANCE, GuiElementLoader.GUI_DEMO, worldIn, blockPos.getX(), blockPos.getY(), blockPos.getZ());
  4.             return super.onItemRightClick(worldIn, playerIn, handIn);
  5.     }
复制代码
是按这个教程学习的大佬教程地址
贤者遇到的问题是,我右键后,GUI界面会一闪而过,闪一下,没了,QAQ ,
是不是教师1.8.9和我这个1.12.2在这块有变化呀,
期待大佬帮忙解决



3TUSK
注册 IGuiHandler 了吗?
物品右键时没有检查 !world.isRemote。

你会用调试器的单步执行吗?

于淞泽
好复杂看不懂

Orion_shadow
3TUSK 发表于 2020-6-3 08:15
注册 IGuiHandler 了吗?
物品右键时没有检查 !world.isRemote。

你会用调试器的单步执行吗? ...

感谢大佬,那块对了,是这个方法返回值我设置错了,刚开始设置成false了
  1. public boolean canInteractWith(EntityPlayer playerIn) {
  2.         return true;
  3.     }
复制代码


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