Posted March 12, 20214 yr 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: Edited March 12, 20214 yr by menackni
March 12, 20214 yr 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?
March 12, 20214 yr Author 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(); } }
March 12, 20214 yr Author 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 March 12, 20214 yr by menackni
March 12, 20214 yr 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.
March 12, 20214 yr Author 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.
March 12, 20214 yr 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.
March 12, 20214 yr Author 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(); } }
March 12, 20214 yr 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.
March 12, 20214 yr Author 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.