Jump to content

[1.19.4] Alternatives to ItemRenderer.renderGuiItem(), .renderAndDecorateFakeItem() and .blitOffset ?


Ammonium_

Recommended Posts

Hi all,

I think the title says it all. I was using the ItemRenderer.renderGuiItem(), .renderAndDecorateFakeItem() and .blitOffset methods/properties on my mod for 1.18.2, but whilst trying to update to 1.19.4 I realized that they were no longer available, nor could I find any suitable replacements.

If necessary, here is how I was using each method:

- .renderGuiItem() and .blitOffset were to render fake items inside a Button subclass:

//Draw item
        if(item.isItem()) {
            itemRenderer.renderGuiItem(item.getItem(), x, y);
        }

        //Highlight background and write item name if hovered or focused
        if(isHoveredOrFocused()){
            isMouseOn = true;
            fill(matrix, x, y, x+width, y+height, 0xFFFFFFDF);
        }else{
            isMouseOn = false;
        }

        //Write quantity based on buttons pressed (sneak & run)
        matrix.pushPose();
        matrix.translate(0, 0, itemRenderer.blitOffset+201);
        matrix.scale(.5f, .5f, 1);
        Font font = Minecraft.getInstance().font;
        drawString(matrix, font, getQuantity()+"", 2*(x+16)- font.width(getQuantity()+""), 2*(y)+24, 0xFFFFFF);
        if(item.isTag()){
            drawString(matrix, font, "#", 2*x+width*2-font.width("#")-1, 2*y+1, 0xFFC921);
        }else if(!item.isItem()){
            drawString(matrix, font, "F", 2*x+1, 2*y+1, 0x6666FF);
        }

- .renderAndDecorateFakeItem() was used to render a fake item inside a Screen subclass:

private void renderItem(PoseStack matrixStack, Item item, int x, int y) {
        ItemRenderer itemRenderer = this.minecraft.getItemRenderer();
        ItemStack itemStack = new ItemStack(item);
        itemRenderer.renderAndDecorateFakeItem(itemStack, x, y);
    }

Which are the alternatives for 1.19.4?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.