Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.5 - SOLVED] Render string over an ItemStack


Recommended Posts

I want to draw string over an itemStack, but string is rendering below an itemStack

Here's my code:

 

// i = index (0-9)

// j = rows

int count = listStack.get(i + (j * 9)).getCount();

Minecraft.getInstance().getItemRenderer().renderItemAndEffectIntoGUI(listStack.get(i + (j * 9)), startPointX + (i * 18), startPointY + (j * 18));

if (count > 1) { this.font.drawStringWithShadow(matrixStack, String.valueOf(count), (float) (startPointX + (i * 18) + 16) - this.font.getStringWidth(String.valueOf(count)), (float) (startPointY + (j * 18) + 10), FontColor.WHITE.getColorCodes()); }

 

 

string_render_forge.PNG

Edited by Th1Minecraft
Link to post
Share on other sites

This code is in MixinContainerScreen and I've tried for RenderGameOverlayEvent.Pre but it is just the same

 

private final ContainerScreen that = (ContainerScreen) (Object) this;

 

Method RenderExtraContainer:

private void renderExtraContainer(MatrixStack matrixStack, Slot slot) throws CommandSyntaxException { if (!slot.getStack().isEmpty()) { RenderSystem.disableDepthTest(); RenderSystem.enableBlend(); RenderSystem.enableAlphaTest(); RenderUtils.bindTexture(EXTRA_CONTAINER); AbstractGui.blit(matrixStack, this.that.getGuiLeft() + this.that.getXSize() + 10, this.that.getGuiTop(), 0.0F, 0.0F, 176, 80, 176, 80); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.blendFunc(770, 771); GL11.glTexEnvi(8960, 8704, 3042); GL11.glTexEnvi(8960, 8704, 8448); RenderSystem.enableDepthTest(); RenderSystem.disableAlphaTest(); RenderSystem.enableRescaleNormal(); this.font.drawString(matrixStack, slot.getStack().getDisplayName().getString(), this.that.getGuiLeft() + this.that.getXSize() + 18, this.that.getGuiTop() + 6, FontColor.GRAY.getColorCodes()); ArrayList<ItemStack> listStack = this.getInventoryFromShulkerBoxItem(slot.getStack()); assert this.minecraft != null; ItemRenderer itemRenderer = this.minecraft.getItemRenderer(); int startPointX = this.that.getGuiLeft() + this.that.getXSize() + 18; int startPointY = this.that.getGuiTop() + 18; if (!listStack.isEmpty()) { for (int i = 0; i < 9; i++) { for (int j = 0; j < 3; j++) { if ((i + j * 9) <= listStack.size() - 1) { int count = listStack.get(i + (j * 9)).getCount(); matrixStack.push(); itemRenderer.renderItemAndEffectIntoGUI(listStack.get(i + (j * 9)), startPointX + (i * 18), startPointY + (j * 18)); matrixStack.pop(); if (count > 1) { this.font.drawStringWithShadow(matrixStack, String.valueOf(count), (float) (startPointX + (i * 18) + 16) - this.font.getStringWidth(String.valueOf(count)), (float) (startPointY + (j * 18) + 10), FontColor.WHITE.getColorCodes()); } } } } } } }

mixincontainer_bs0.PNG

Link to post
Share on other sites
  • Th1Minecraft changed the title to [1.16.5 - SOLVED] Render string over an ItemStack

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
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.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I have made a custom armor piece and have given it a texture for when you hold it. I have also made a custom armor material but I dont know how to make it so that when you where the armor you see a custom texture.
    • Probably only the main block should hold all the data, that way you don't have things spread out.
    • It hasn't been changed in a long time and should be updated.  But no, it's not overly aggressive. People don't read it. Look at all the support threads. 90% of them are "okay i have this issue", no debug.log in sight.
    • I solved it by copying the .gradle folder from another laptop where it works to run the client!
    • I am currently drawing a compass to my ingame gui as follows: private static void renderCompass(MatrixStack matrixStack, int width, int height) { TextureDrawer.drawGuiTexture(matrixStack, width / 2 - 110, 10, 0, 37, 221, 14); int rot; boolean f0 = mc.player.yRot < 0.0f; if(f0) rot = -MathHelper.floor(mc.player.yRot % 360); else rot = MathHelper.floor(mc.player.yRot % 360); boolean f1 = rot > 0 && rot < 180; boolean f2 = rot <= 270 && rot >= 90; boolean f3 = rot <= 180 && rot >= 0; AtomicInteger targetAngle = new AtomicInteger(-1); mc.player.getCapability(ISkyrimPlayerDataProvider.SKYRIM_PLAYER_DATA_CAPABILITY).ifPresent(cap -> { if(cap.getCurrentTarget() != null && cap.getCurrentTarget().isAlive()) { Vector3d playerPos = mc.player.getLookAngle(); Vector3d targetPos = cap.getCurrentTarget().position(); Vector3d norm = playerPos.subtract(targetPos); double angleDir = (Math.atan2(norm.z, norm.x) / 2 / Math.PI * 360 + 360) % 360; double angleLook = (Math.atan2(playerPos.z, playerPos.x) / 2 / Math.PI * 360 + 360) % 360; targetAngle.set((int)(angleDir - angleLook + 360) % 360); } else targetAngle.set(-1); }); int targetEntityAngle = targetAngle.get(); if(targetEntityAngle > 0 && targetEntityAngle <= 90) TextureDrawer.drawGuiTexture(matrixStack, width / 2 - targetEntityAngle, 14, 105, 52, 6, 6); else if(targetEntityAngle > 90 && targetEntityAngle <= 180) TextureDrawer.drawGuiTexture(matrixStack, width / 2 - targetEntityAngle + 90, 14, 105, 52, 6, 6); if (rot == 0) { drawCenteredString(matrixStack, fontRenderer, "S", width / 2, 13, 16777215); drawCenteredString(matrixStack, fontRenderer, "E", (width / 2) - 90, 13, 16777215); drawCenteredString(matrixStack, fontRenderer, "W", (width / 2) + 90, 13, 16777215); } else if (!f0) { drawCenteredString(matrixStack, fontRenderer, f2 ? "N" : "", (width / 2 - rot) + 180, 13, 16777215); if (!f1) rot -= 360; drawCenteredString(matrixStack, fontRenderer, !f2 ? "S" : "", width / 2 - rot, 13, 16777215); drawCenteredString(matrixStack, fontRenderer, !f3 ? "E" : "", (width / 2 - rot) - 90, 13, 16777215); drawCenteredString(matrixStack, fontRenderer, f3 ? "W" : "", (width / 2 - rot) + 90, 13, 16777215); } else if(f0) { drawCenteredString(matrixStack, fontRenderer, f2 ? "N" : "", (width / 2 + rot) - 180, 13, 16777215); if (!f1) rot -= 360; drawCenteredString(matrixStack, fontRenderer, !f2 ? "S" : "", width / 2 + rot, 13, 16777215); drawCenteredString(matrixStack, fontRenderer, !f3 ? "W" : "", (width / 2 + rot) + 90, 13, 16777215); drawCenteredString(matrixStack, fontRenderer, f3 ? "E" : "", (width / 2 + rot) - 90, 13, 16777215); } } What I'm trying to do is only render the entity texture (the calls including targetEntityAngle) when it is in compass view.  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.