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
  On 3/12/2021 at 3:15 PM, 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?

Expand  

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)
  On 3/12/2021 at 3:43 PM, 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();
        }
    }

 

Expand  

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
  On 3/12/2021 at 3:43 PM, 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

Expand  

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
  On 3/12/2021 at 5:10 PM, 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.

Expand  

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
  On 3/12/2021 at 6:24 PM, 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.

Expand  

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
  On 3/12/2021 at 8:14 PM, 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.

Expand  

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

    • UPDATE: this seems to be an Arch-specific issue. Switching to Ubuntu server fixed EVERYTHING.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
  • Topics

×
×
  • Create New...

Important Information

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