Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Solved] [1.20.1] How to get player data (position / facing direction / etc. )

Featured Replies

Posted

I am trying to create a (client-side) mod which would work almost like using F3 screen, but with custom pictures blit on player HUD (for example showing N/S when player is facing North/South etc.).

Currently I am able to blit any image on screen I want, but I don't know, how to access player data for use in some logic to switch between images.

I need help in what I should add in the blank space bellow so that the mod will blit on screen 1 if I'm facing South-ish (range -45 to 45 degrees) and 0 otherwise.

public class HUDOverlay {
    private static final ResourceLocation COMPASS_0 = new ResourceLocation(HUDMod.MODID, "textures/compass/0.png");
    private static final ResourceLocation COMPASS_1 = new ResourceLocation(HUDMod.MODID, "textures/compass/1.png");

    public static final IGuiOverlay COMPASS_OVERLAY = ((gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
        int facing_direction = ___?___;

        if(-45 < facing_direction && facing_direction < 45) {
            guiGraphics.blit(COMPASS_1, screenWidth/2, 5, 0,0,3,4,3,4);
        } else {
            guiGraphics.blit(COMPASS_0, screenWidth/2, 5, 0,0,3,4,3,4);
        }
    });
}

Essentially I'm asking for help in getting current client data.

Thanks for any help.

Edited by JohnyK

  • JohnyK changed the title to [1.20.1] How to get player data (position / facing direction / etc. )
2 hours ago, JohnyK said:

Essentially I'm asking for help in getting current client data.

You can access the player on the client with 'Minecraft.getInstance().player'

  • Author

Thank you, your answer helped and it is working just like I imagined.

  • JohnyK changed the title to [Solved] [1.20.1] How to get player data (position / facing direction / etc. )

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.