1.12.2 [1.12.2] Problème de rendu HUD personnalisé



  • J'ai fabriqué un HUD personnalisé.
    Mais il y a un problème: si le joueur place un élément de bloc dans la barre de fente, le bloc est plus sombre que la barre de fente existante. Comment puis-je le résoudre?

    text alternatif

    @SubscribeEvent
        public void drawHotbar(RenderGameOverlayEvent event) {
            if(event.getType().equals(RenderGameOverlayEvent.ElementType.TEXT)) {
                GL11.glPushMatrix();
                GL11.glTranslatef(44, (float)(event.getResolution().getScaledHeight() - 24), 0.0f);
                Tessellator t = Tessellator.getInstance();
                BufferBuilder builder = t.getBuffer();
                mc.getTextureManager().bindTexture(new ResourceLocation(MOD_ID + ":slot2.png"));
                if (mc.player.inventory.currentItem >= 0 && mc.player.inventory.currentItem <= 9) {
                    builder.begin(GL11.GL_QUADS,DefaultVertexFormats.POSITION_TEX);
                    builder.pos(-1 + mc.player.inventory.currentItem * 20,-1,0).tex(0,0).endVertex();
                    builder.pos(-1 + mc.player.inventory.currentItem * 20,19,0).tex(0,1).endVertex();
                    builder.pos(19 + mc.player.inventory.currentItem * 20,19,0).tex(1,1).endVertex();
                    builder.pos(19 + mc.player.inventory.currentItem * 20,-1,0).tex(1,0).endVertex();
                    t.draw();
                }
                for (int i = 0; i < 9; ++i) {
                    mc.getTextureManager().bindTexture(new ResourceLocation(MOD_ID + ":slot1.png"));
                    GL11.glEnable(3042);
                    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
                    RenderHelper.disableStandardItemLighting();
                    builder.begin(GL11.GL_QUADS,DefaultVertexFormats.POSITION_TEX);
                    builder.pos(0 + i * 20,0,0).tex(0,0).endVertex();
                    builder.pos(0 + i * 20,18,0).tex(0,1).endVertex();
                    builder.pos(18 + i * 20,18,0).tex(1,1).endVertex();
                    builder.pos(18 + i * 20,0,0).tex(1,0).endVertex();
                    t.draw();
                    this.renderInventorySlot(i, i * 20 + 1, 0, 0.0f);
                }
                RenderHelper.disableStandardItemLighting();
                GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
                GL11.glPopMatrix();
            }
        }
    
        protected void renderInventorySlot(final int p_73832_1_, final int x, final int y, final float p_73832_4_){
            RenderItem itemRenderer = mc.getRenderItem();
            ItemStack itemstack = mc.player.inventory.mainInventory.get(p_73832_1_);
            if (itemstack != null) {
                final float f1 = itemstack.getAnimationsToGo() - p_73832_4_;
                if (f1 > 0.0f) {
                    GL11.glPushMatrix();
                    final float f2 = 1.0f + f1 / 5.0f;
                    GL11.glTranslatef((float)(x + 8), (float)(y + 12), 0.0f);
                    GL11.glScalef(1.0f / f2, (f2 + 1.0f) / 2.0f, 1.0f);
                    GL11.glTranslatef((float)(-(x + 8)), (float)(-(y + 12)), 0.0f);
                }
                itemRenderer.renderItemIntoGUI(itemstack,x,y);
                if (f1 > 0.0f) {
                    GL11.glPopMatrix();
                }
                if(itemstack.getCount() > 1) {
                    itemRenderer.renderItemOverlayIntoGUI(mc.fontRenderer,itemstack,x,y, String.valueOf(itemstack.getCount()));
                }
                else {
                    itemRenderer.renderItemOverlayIntoGUI(mc.fontRenderer,itemstack,x,y, "");
                }
            }
        }
    

Log in to reply