-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Hud page #281
base: main
Are you sure you want to change the base?
Update Hud page #281
Conversation
✅ Deploy Preview for nimble-elf-d9d491 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some nit picks, the new api is a little more complex for people to understand so I think we need to explain it a bit more to compensate.
|
||
The `HudRenderCallback` event - provided by Fabric API - is called every frame, and is used to render things to the HUD. | ||
::: warning | ||
Previously, Fabric provided `HudRenderCallback` to render to the hud. Due to changes to hud rendering, this event became extremely limited and is deprecated since Fabric API 0.116. Usage is strongly discouraged. Deprecated events may be removed in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, Fabric provided `HudRenderCallback` to render to the hud. Due to changes to hud rendering, this event became extremely limited and is deprecated since Fabric API 0.116. Usage is strongly discouraged. Deprecated events may be removed in the future. | |
Previously, Fabric provided `HudRenderCallback` to render to the hud. Due to changes to hud rendering, this event became extremely limited and is deprecated since Fabric API 0.116. Usage is strongly discouraged. |
I dont think you need to mention this, we tend to only remove deprecated APIs when they break becuase of a Mojang change, I expect the old event will be around for a good while longer.
|
||
You should check out the [Draw Context](./draw-context) page to learn more about the draw context. | ||
To start, we need to register a listener to `HudLayerRegistrationCallback` which registers your layers. Each layer takes a `DrawContext` and a `RenderTickCounter` instance as parameters. See the `HudLayerRegistrationCallback` and related Javadocs for more details on how to use the API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each layer takes a
DrawContext
and aRenderTickCounter
instance as parameters.
This doesnt really tell the full picture, maybe its worth expanding a bit on this and saying that a layer is a IdentifiedLayer that takes a Layer, that is often a lamabda that takes those 2 params?
|
||
public class HudRenderingEntrypoint implements ClientModInitializer { | ||
@Override | ||
public void onInitializeClient() { | ||
// :::1 | ||
HudRenderCallback.EVENT.register((context, renderTickCounter) -> { | ||
// Attach our rendering code to before the chat hud layer. Our layer will render right before the chat. The API will take care of z spacing and automatically add 200 after every layer. | ||
HudLayerRegistrationCallback.EVENT.register(layeredDrawer -> layeredDrawer.attachLayerBefore(IdentifiedLayer.CHAT, Identifier.of(FabricDocsReference.MOD_ID, "hud-example-layer"), (context, tickCounter) -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Id maybe split this into multiple lines, and possibly move the layer code out into a method.
E.g
public static final Identifier HUD_LAYER = Identifier.of(FabricDocsReference.MOD_ID, "hud-example-layer");
HudLayerRegistrationCallback.EVENT.register(layeredDrawer -> {
layeredDrawer.attachLayerBefore(IdentifiedLayer.CHAT, HUD_LAYER, this::render);
});
No description provided.