Jump to content

Recommended Posts

Posted (edited)

Hello.

 

I am trying to render item in gui like i do it in tileEntityRenderer but it dosent work.

I start digging and experementing, and find that this code work but every thing "excepting ender dragon head" colored red and deephtest only work on full blocks and ender dragon head.

@Override
    public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {
        this.renderBackground(ms);
        super.render(ms, mouseX, mouseY, partialTicks);
        this.renderHoveredTooltip(ms, mouseX, mouseY);
        
        Minecraft mc=Minecraft.getInstance();
        ItemRenderer ir=mc.getItemRenderer();
        ItemStack is=container.getInventory().get(0);
        EntityRendererManager er=mc.getRenderManager();
        
        if (!is.isEmpty()){
        	ms.push();
        	
            ms.translate(100, 100, 100);
            ms.rotate(Vector3f.YP.rotationDegrees(3 * (mc.world.getGameTime() % 360 +partialTicks)));
            ms.scale(100, 100, 100);
            
        	IRenderTypeBuffer irtb = mc.getRenderTypeBuffers().getCrumblingBufferSource();
        	
        	ir.renderItem(is, TransformType.GUI, 240, 0, ms, irtb);
        	ir.renderModel(ir.getItemModelWithOverrides(is, mc.world, mc.player), is, 240, 0, ms, irtb.getBuffer(RenderType.getSolid()));
        	
        	ms.pop();
        }
    }

Here some examples:

image.thumb.png.435fe186ed83d980b27471f4fc04df28.png

image.png.73cb1bcb7c33be01f42f2200a60cb371.png

Edited by menackni
Posted
17 minutes ago, ChampionAsh5357 said:

You can look within ContainerScreen to see how ItemStacks are rendered. If this is not the end goal, can you explain in more detail what you are exactly trying to do?

I try draw items like models instead of icons, i already fix deephtest but items still red, i try dig vanilla code and doing like it but it dosent work

@Override
    public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {
        this.renderBackground(ms);
        super.render(ms, mouseX, mouseY, partialTicks);
        this.renderHoveredTooltip(ms, mouseX, mouseY);
        
        Minecraft mc=Minecraft.getInstance();
        ItemRenderer ir=mc.getItemRenderer();
        ItemStack is=container.getInventory().get(0);
        
        if (!is.isEmpty()){
        	
        	ms.push();
            ms.translate(100, 100, 100);
            ms.rotate(Vector3f.YP.rotationDegrees(3 * (mc.world.getGameTime() % 360 +partialTicks)));
            ms.scale(100, -100, 100);
            
        	IRenderTypeBuffer.Impl irtb = mc.getRenderTypeBuffers().getCrumblingBufferSource();
        	ir.renderItem(is, TransformType.FIXED, 240, 0, ms, irtb);
        	
        	irtb.finish();
        	ms.pop();
        }
    }

 

Posted (edited)
8 minutes ago, menackni said:

I try draw items like models instead of icons, i already fix deephtest but items still red, i try dig vanilla code and doing like it but it dosent work


@Override
    public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {
        this.renderBackground(ms);
        super.render(ms, mouseX, mouseY, partialTicks);
        this.renderHoveredTooltip(ms, mouseX, mouseY);
        
        Minecraft mc=Minecraft.getInstance();
        ItemRenderer ir=mc.getItemRenderer();
        ItemStack is=container.getInventory().get(0);
        
        if (!is.isEmpty()){
        	
        	ms.push();
            ms.translate(100, 100, 100);
            ms.rotate(Vector3f.YP.rotationDegrees(3 * (mc.world.getGameTime() % 360 +partialTicks)));
            ms.scale(100, -100, 100);
            
        	IRenderTypeBuffer.Impl irtb = mc.getRenderTypeBuffers().getCrumblingBufferSource();
        	ir.renderItem(is, TransformType.FIXED, 240, 0, ms, irtb);
        	
        	irtb.finish();
        	ms.pop();
        }
    }

 

Also items with enchanted effect cause crash game.

Also also this code work too but dosen draw shadows, enchantments and heads.

ir.renderModel(ir.getItemModelWithOverrides(is, mc.world, mc.player), is, 240, 0, ms, irtb.getBuffer(RenderType.getCutout()));
irtb.finish();

 

Edited by menackni
Posted
1 hour ago, menackni said:

I try draw items like models instead of icons, i already fix deephtest but items still red, i try dig vanilla code and doing like it but it dosent work

The items are models and not icons. They have been rotated, translated, and scaled to that position to be drawn. You still have yet to answer what is the end goal here and why it should be done.

Posted
2 minutes ago, ChampionAsh5357 said:

The items are models and not icons. They have been rotated, translated, and scaled to that position to be drawn. You still have yet to answer what is the end goal here and why it should be done.

I realise that items not icons, but result of renderItemAndEffectIntoGUI(ItemStack, mouseX, mouseY) "look like icon" they work perfectly but cant rotate or scale items with methots that i know.

With renderItem(ItemStack, TransformType, x, y, matrixStack, IRenderTypeBuffer) i can transform items how i want, but for some reasons it color everything red except heads and crash game when i try to put enchanted items.

 

My goal is to make gui where i can rotate and transform items.

Posted
8 minutes ago, ChampionAsh5357 said:

Just remake the method then to take in a preexisting MatrixStack and then modify that as needed. The method does call renderItem after a bit of prework.

Do you mean make like that?  code bolowe render nothing

@Override
    public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {
        this.renderBackground(ms);
        super.render(ms, mouseX, mouseY, partialTicks);
        this.renderHoveredTooltip(ms, mouseX, mouseY);
        
        Minecraft mc=Minecraft.getInstance();
        ItemRenderer ir=mc.getItemRenderer();
        ItemStack is=container.getInventory().get(0).copy();
        
        if (!is.isEmpty()){
        	ms.push();
            ms.translate(10, 10, 10);
            ms.rotate(Vector3f.YP.rotationDegrees(3 * (mc.world.getGameTime() % 360 +partialTicks)));
            ms.scale(100, -100, 100);
            IRenderTypeBuffer.Impl irtb =  mc.getRenderTypeBuffers().getCrumblingBufferSource();
            ir.renderItem(is, TransformType.GUI, 240, 0, ms, irtb);
        	ms.pop();
        }
    }

 

Posted
1 hour ago, ChampionAsh5357 said:

That doesn't remake the method. Look at how renderItemAndEffectIntoGUI is defined and rewrite it to take some MatrixStack to define the rotation and/or scale to render.

I try it before but seems i did something wrong, thanks you give this method second chance.

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I can't figure out if you're looking for help trying to steal someone elses work, or cheat at the game....
    • Title: Why Is It So Hard to Rename and Restructure Mods Like Xray or AntiXray? 🤔 Post text: Hey everyone! I’ve been digging into Minecraft modding for a while and have one big question that I can’t figure out on my own. Maybe someone with more experience could help or give me some advice. Here’s the issue: When I take a “normal” Minecraft mod — for example, one that just adds some blocks or new items — I can easily change its structure, package names, or even rebrand it entirely. It’s straightforward. But as soon as I try this with cheat-type mods like XrayMod or AntiXray, everything falls apart. Even if I just rename the classes, refactor the packages, or hide its identity somehow, the mod either breaks or stops working properly. XrayMod in particular is proving to be a nightmare to modify without losing its core function. So my question is — why is this so much harder with cheat mods like Xray? Is there something fundamentally different about how they’re coded, loaded, or protected that prevents simple renaming or restructuring? And if so, how can I actually learn to understand someone else’s cheat mod enough to safely refactor it without breaking the core features? I’ve already been spending over two months trying to figure this out and haven’t gotten anywhere. It feels like there must be some trick or knowledge I’m missing. Would really appreciate any thoughts, tips, or references — maybe there are guides or techniques for understanding cheat-mod internals? Or if you’ve successfully “disguised” a cheat mod like Xray before, I’d love to hear how you did it. Thanks in advance for any help or discussion. ✌️
    • just started making cinamatic contect check it out on my channel or check out my facebook page    Humbug City Minecraft Youtube https://www.youtube.com/watch?v=v2N6OveKwno https://www.facebook.com/profile.php?id=61575866982337  
    • Where did you get the schematic? Source/Link? And do use an own modpack or a pre-configured from curseforge? If yes, which one On a later time, I can make some tests on my own - but I need the schematic and the modpack name
  • Topics

×
×
  • Create New...

Important Information

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