Jump to content

Recommended Posts

Posted

GUI screens are actually 3d in minecraft. The z direction is the distance out of the screen.

Look at how the class Screen handles tool tips by both translating the z co-ord of the PoseStack and changing ItemRenderer.blitOffset which controls the same thing for the drawing items.

Note how it uses +400 in renderTooltipInternal() and +200 in ItemRender.renderGuiItemDecorations() - the latter being things like the damage bar.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
  On 11/4/2022 at 7:09 PM, warjort said:

GUI screens are actually 3d in minecraft. The z direction is the distance out of the screen.

Look at how the class Screen handles tool tips by both translating the z co-ord of the PoseStack and changing ItemRenderer.blitOffset which controls the same thing for the drawing items.

Note how it uses +400 in renderTooltipInternal() and +200 in ItemRender.renderGuiItemDecorations() - the latter being things like the damage bar.

Expand  

How exactly can I move the tooltip closer? Nothing changes when I move the PoseStack before the tooltip renders until the tooltip goes out of the camera...

pose.pushPose();

pose.translate(mouseX, mouseY, 500F);

inventory.renderTooltip(pose, lines, Optional.empty(), 0, 0);

pose.popPose();

Posted (edited)

You need to show what you are actually doing.

I already guessed (wrongly) once on this thread that you were doing custom rendering.

I shouldn't have to guess.

From that small snippet of code out of context it looks like you are calling Screen's renderTooltip() which should do it for you.

There is something else you are doing wrong.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
  On 11/4/2022 at 8:34 PM, warjort said:

You need to show what you are actually doing.

I already guessed (wrongly) once on this thread that you were doing custom rendering.

I shouldn't have to guess.

From that small snippet of code out of context it looks like you are calling Screen's renderTooltip() which should do it for you.

There is something else you are doing wrong.

Expand  
@SubscribeEvent
    public static void onPlayerInventory(@NotNull ScreenEvent.InitScreenEvent.Post event) {
        if (event.getScreen() instanceof InventoryScreen inventory && event.getScreen().getMinecraft().player != null) {
            //ACTIONS
            Button.OnPress attributes = button -> event.getScreen().getMinecraft().setScreen(new ObscureBookScreen(
                    new ObscureBookMenu(1, event.getScreen().getMinecraft().player.getInventory(), new FriendlyByteBuf(Unpooled.buffer()).writeBlockPos(new BlockPos(0,0,0)) ),
                    event.getScreen().getMinecraft().player.getInventory(),
                    new TextComponent("attributes")));
            Button.OnPress factions = button -> event.getScreen().getMinecraft().setScreen(new ObscureBookScreen(
                    new ObscureBookMenu(1, event.getScreen().getMinecraft().player.getInventory(), new FriendlyByteBuf(Unpooled.buffer()).writeBlockPos(new BlockPos(0,0,0)) ),
                    event.getScreen().getMinecraft().player.getInventory(),
                    new TextComponent("factions")));
            //TOOLTIPS
            Button.OnTooltip tooltipStats = new Button.OnTooltip() {
                public void onTooltip(Button button, PoseStack pose, int mouseX, int mouseY) {
                    List<Component> lines = new ArrayList<>();
                    for (String line : getStats().split(">"))
                        lines.add(FontHelper.component(line));
                    pose.pushPose();
                    assert Minecraft.getInstance().screen != null;
                    final float scale = Math.max(1, (float) Minecraft.getInstance().options.guiScale -
                            (ObscureAPIConfig.Client.reduceTooltips.get() ? 1F : 0)) / (float) Minecraft.getInstance().options.guiScale;
                    pose.scale(scale, scale, 1F);
                    pose.translate(mouseX, mouseY, 500F);
                    inventory.renderTooltip(pose, lines, Optional.empty(), 0, 0);
                    pose.popPose();
                }
                public void narrateTooltip(Consumer<Component> text) {
                    text.accept(new TextComponent(""));
                }
            };
            Button.OnTooltip tooltipFractions = new Button.OnTooltip() {
                public void onTooltip(@NotNull Button button, @NotNull PoseStack pose, int mouseX, int mouseY) {
                    List<Component> lines = new ArrayList<>();
                    for (String line : getFactions().split(">"))
                        lines.add(FontHelper.component(line));
                    pose.pushPose();
                    assert Minecraft.getInstance().screen != null;
                    final float scale = Math.max(1, (float) Minecraft.getInstance().options.guiScale -
                            (ObscureAPIConfig.Client.reduceTooltips.get() ? 1F : 0)) / (float) Minecraft.getInstance().options.guiScale;
                    pose.translate(mouseX, mouseY, 0F);
                    pose.scale(scale, scale, 1F);
                    inventory.renderTooltip(pose, lines, Optional.empty(), 0, 0);
                    pose.popPose();
                }
                public void narrateTooltip(Consumer<Component> text) {
                    text.accept(new TextComponent(""));
                }
            };
            final int width = 20;
            final int height = 20;
            event.addListener(new ImageButton(0, 0, width, height,0, 0, 20, BUTTONS_LOCATION, 200, 200, attributes, tooltipStats, new TextComponent("")) {
                @Override
                public void renderButton(PoseStack pose, int mouseX, int mouseY, float partialTicks) {
                    assert Minecraft.getInstance().screen != null;
                    final int posX = Math.max(16, Math.min(Minecraft.getInstance().screen.width - 16,
                            (inventory.getGuiLeft() - width / 2) + 162 + ObscureAPIConfig.Client.buttonsOffsetX.get()));
                    final int posY = Math.max(16, Math.min(Minecraft.getInstance().screen.width - 16,
                            (Minecraft.getInstance().screen.height / 2 - height / 2) - 96 + ObscureAPIConfig.Client.buttonsOffsetY.get()));
                    this.x = posX;
                    this.y = posY;
                    super.renderButton(pose, mouseX, mouseY, partialTicks);
                }
            });
            event.addListener(new ImageButton(0, 0, width, height,20, 0, 20, BUTTONS_LOCATION, 200, 200, factions, tooltipFractions, new TextComponent("")) {
                @Override
                public void renderButton(PoseStack pose, int mouseX, int mouseY, float partialTicks) {
                    assert Minecraft.getInstance().screen != null;
                    final int posX = Math.max(16, Math.min(Minecraft.getInstance().screen.width - 16,
                            (inventory.getGuiLeft() - width / 2) + 140 + ObscureAPIConfig.Client.buttonsOffsetX.get()));
                    final int posY = Math.max(16, Math.min(Minecraft.getInstance().screen.width - 16,
                            (Minecraft.getInstance().screen.height / 2 - height / 2) - 96 + ObscureAPIConfig.Client.buttonsOffsetY.get()));
                    this.x = posX;
                    this.y = posY;
                    super.renderButton(pose, mouseX, mouseY, partialTicks);
                }
            });
        }
    }

 

Posted

The only unusual thing I'll do is dynamically update the contents and position of the tooltip, as the displayed information and button position may change while viewing it.

Posted

This looks like a flaw in the way AbstractContainerScreen works.

Or at least it didn't anticipate you doing this.

 

I wrote this simple test which reproduces your problem.

@Mod.EventBusSubscriber(modid = MODID, value = Dist.CLIENT)
public class TestScreenToolTip {

    static List<Component> LIST = Collections.nCopies(10, Component.literal("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"));

    @SubscribeEvent
    public static void testInit(ScreenEvent.Init.Post event) {
        if (event.getScreen() instanceof InventoryScreen screen) {
            event.addListener(new MyButton(screen));
        }
    }

    static class MyButton extends Button {
        public MyButton(Screen screen) {
            super(screen.width / 2 - 100, 140, 200, 20, CommonComponents.GUI_CANCEL, (button) -> {
                // nothing
            }, (button, poseStack, mouseX, mouseY) -> {
                screen.renderTooltip(poseStack, LIST, Optional.empty(), mouseX, mouseY);
            });
        }
    }
}

 

If you look at AbstractContainerScreen.render() the widgets get rendered before everything else, the super.render() call.

Then when it comes to drawing the item decoration's damage bar (which is after) it does RenderSystem.disableDepthTest() so it ignores the z co-ord and just draws it.

 

Normally if you were the writing the screen yourself, you could just change the render method to draw the buttons last or at least after the slots.

But you don't control the order of things for this screen.

 

I can confirm that fixes the problem by adding an additional event listener.

    @SubscribeEvent
    public static void testRender(ScreenEvent.Render.Post event) {
        if (event.getScreen() instanceof InventoryScreen screen) {
            screen.renderables.forEach(widget -> {
                if (widget instanceof MyButton) {
                    widget.render(event.getPoseStack(), event.getMouseX(), event.getMouseY(), event.getPartialTick());
                }
            });
        }
    }

The issue with the above fix is I am drawing my button twice. Once normally and then again at the end of the screen rendering.

 

There must be a better solution to this problem? 🙂 

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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

    • Hey to everyone. I am new here. Nice to meet you<><><>>>>>>>>>>>>>
    • Hey to everyone. I am new here. Nice to meet you<><><>>>>>>>>>>>>>
    • Shopping just got a whole lot more exciting this July 2025. With the verified  Temu   coupon code (acu729640), you can enjoy up to 40% off, a flat $100 discount, and much more—even if you’re a returning customer. The  Temu   coupon code (acu729640) opens the door to a world of savings, perks, and unbeatable deals for savvy shoppers like you and me. Why Everyone Is Buzzing About  Temu   in July 2025  Temu   has become one of the most talked-about shopping platforms globally. Here’s why: Over 250,000 trending items across electronics, fashion, home goods, and more Unbeatable prices with discounts reaching up to 90% Free shipping in 67 countries Reliable and fast delivery with real-time tracking User-friendly app and desktop experience New loyalty rewards programs and exclusive offers like (acu729640) What Makes the  Temu   Coupon Code (acu729640) a Game-Changer The  Temu   promo code (acu729640) for July 2025 is your golden ticket to bigger savings. It’s not just another random promo—it’s a highly flexible code packed with benefits that both new and existing Customers can enjoy. Here’s a breakdown of the savings:  Temu   coupon code (acu729640) $100 off for new Customers – Flat $100 discount on your first order  Temu   coupon code (acu729640) $100 off for existing Customers – Loyal customers get the same amazing $100 off  Temu   coupon code (acu729640) 40% off – Additional 40% discount across popular categories  Temu   $100 coupon bundle – Stackable savings up to $100 for multiple purchases  Temu   first time user coupon – Free gift + instant discounts These aren’t just generic savings. They’re curated to elevate your shopping experience. I used the (acu729640) coupon code last week and saved over $120 while shopping for kitchen gadgets, summer apparel, and gifts.  Temu   Coupons You Shouldn’t Miss in July 2025 If you’re anything like me, stacking deals is the ultimate thrill. And with the  Temu   coupon bundle available this July 2025, that thrill comes with real rewards. Whether you're a new or returning customer,  Temu   has a discount strategy tailored just for you. Must-Have  Temu   Coupon Codes  Temu   coupon code (acu729640) – Ideal for July 2025 sitewide savings  Temu   coupon code (acu729640) $100 off – Massive savings for both new and repeat Customers  Temu   coupon code (acu729640) 40% off – Perfect for trimming costs on trending products  Temu   $100 coupon bundle – Stackable codes for extra savings  Temu   coupons for new Customers – Welcome discounts + surprise gift  Temu   coupons for existing Customers – Loyalty benefits + access to VIP-only sales  Temu   discount code (acu729640) for July 2025 – Boost your cart value while spending less  Temu   promo code (acu729640) for July 2025 – Use this code for optimized checkout deals Country-Specific Coupon Benefits  Temu   coupon code $100 off for USA – Great for electronics, home appliances, and sports gear  Temu   coupon code $100 off for Canada – Ideal for winter wear, home décor, and wellness products  Temu   coupon code $100 off for UK – Popular for fashion, tech accessories, and skincare  Temu   coupon code $100 off for Japan – Perfect for minimalist homeware and tech  Temu   coupon code 40% off for Mexico – Clothing, bags, and beauty products at 40% off  Temu   coupon code 40% off for Brazil – Big savings on shoes, kitchenware, and fitness items The Power of the  Temu   Coupon Bundle The  Temu   $100 coupon bundle is not a myth. It’s a dynamic pack of stackable coupons that can be used together or separately to suit your cart size and item types. Bundle Highlights: Coupons worth $10, $20, $30, and $40 – Use one or stack all Free express shipping codes – Save time AND money Early access to flash sales – App-only deals included Seasonal bonuses – Added during holidays and big sale days Real Benefits You Can Count On Using  Temu   coupon code (acu729640) for July 2025 is not only smart—it’s empowering. Here’s what you stand to gain: $100 off for new Customers – Start strong with a generous discount $100 off for existing Customers – Stay loyal and still save 40% extra off – Cut down your final bill without cutting corners Free gift for new Customers – A little surprise goes a long way $100 coupon bundle – Plan multiple orders and save consistently How to Redeem the  Temu   Promo Code (acu729640) Visit the  Temu   website or download the app Log in or sign up for an account Add your favorite items to the shopping cart Enter the  Temu   discount code (acu729640) at checkout Watch the prices drop before your eyes  Temu   New Offers in July 2025 If you're on the lookout for fresh deals,  Temu  's new offers in July 2025 are hard to beat. With rolling flash sales, new arrivals daily, and special discounts for app Customers, you’ll always find something irresistible. And yes, you can use the  Temu   promo code (acu729640) with many of these new deals.  Temu   is constantly updating their product catalog. Whether you’re interested in smart gadgets, fashion-forward pieces, or home essentials, you’ll find quality and affordability combined in one platform. Final Thoughts Shopping on  Temu   with the coupon code (acu729640) is a no-brainer. You unlock value instantly, stack your savings strategically, and make every purchase count. In July 2025, this code isn’t just recommended—it’s essential. I’ve saved hundreds with the  Temu   coupon code (acu729640), and I know you can too. Why pay full price when you have access to: The  Temu   coupon code (acu729640) $100 off The  Temu   coupon code (acu729640) 40% off The  Temu   $100 coupon bundle Free gifts and fast delivery Your smarter shopping journey starts now. Just remember the magic key: acu729640. Happy shopping!  
  • Topics

×
×
  • Create New...

Important Information

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