From 0f62e21e9bc8ef1ecb9f6fc314392c87444c82c2 Mon Sep 17 00:00:00 2001 From: dicedpixels Date: Mon, 28 Oct 2024 21:19:04 +0530 Subject: [PATCH] revert tick delta related changes --- develop/rendering/basic-concepts.md | 2 +- develop/rendering/hud.md | 10 +++++----- .../example/docs/rendering/HudRenderingEntrypoint.java | 4 ++-- .../docs/rendering/RenderingConceptsEntrypoint.java | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/develop/rendering/basic-concepts.md b/develop/rendering/basic-concepts.md index e8103d988..cc1921c8a 100644 --- a/develop/rendering/basic-concepts.md +++ b/develop/rendering/basic-concepts.md @@ -135,7 +135,7 @@ The `MatrixStack` class has the following methods: You can also multiply the top matrix on the stack using quaternions, which we will cover in the next section. -Taking from our example above, we can make our diamond scale up and down by using the `MatrixStack` and the `tickDelta` - which is the "progress" between the last game tick and the next game tick. +Taking from our example above, we can make our diamond scale up and down by using the `MatrixStack` and the `tickDelta` - which is the time that has passed since the last frame. ::: warning You must first push the matrix stack and then pop it after you're done with it. If you don't, you'll end up with a broken matrix stack, which will cause rendering issues. diff --git a/develop/rendering/hud.md b/develop/rendering/hud.md index 7dbc880be..ec1dc4e35 100644 --- a/develop/rendering/hud.md +++ b/develop/rendering/hud.md @@ -7,23 +7,23 @@ authors: # Rendering in the Hud {#rendering-in-the-hud} -We already briefly touched on rendering things to the hud in the [Basic Rendering Concepts](./basic-concepts) page and [Using The Drawing Context](./draw-context), so on this page we'll stick to the `HudRenderCallback` event and the `tickCounter` parameter. +We already briefly touched on rendering things to the hud in the [Basic Rendering Concepts](./basic-concepts) page and [Using The Drawing Context](./draw-context), so on this page we'll stick to the `HudRenderCallback` event and the `deltaTick` parameter. ## HudRenderCallback {#hudrendercallback} The `HudRenderCallback` event - provided by Fabric API - is called every frame, and is used to render things to the HUD. -To register to this event, you can simply call `HudRenderCallback.EVENT.register` and pass in a lambda that takes a `DrawContext` and a `RenderTickCounter` (tickCounter) as parameters. +To register to this event, you can simply call `HudRenderCallback.EVENT.register` and pass in a lambda that takes a `DrawContext` and a `float` (deltaTick) as parameters. The draw context can be used to access the various rendering utilities provided by the game, and access the raw matrix stack. You should check out the [Draw Context](./draw-context) page to learn more about the draw context. -### Tick Delta {#deltatick} +### DeltaTick {#deltatick} -Frames are rendered faster than the game ticks. Tick delta is a `float` from `0.0` to `1.0` that represents the "progress" between the last game tick and the next game tick. This can be used to make animations and other time-based effects. +The `deltaTick` refers to the time since the last frame, in seconds. This can be used to make animations and other time-based effects. -For example, let's say you want to lerp a color over time. You can use the `tickCounter` to get the tick delta, and store it over time to lerp the color: +For example, let's say you want to lerp a color over time. You can use the `deltaTickManager` to get the deltaTick, and store it over time to lerp the color: @[code lang=java transcludeWith=:::1](@/reference/latest/src/client/java/com/example/docs/rendering/HudRenderingEntrypoint.java) diff --git a/reference/latest/src/client/java/com/example/docs/rendering/HudRenderingEntrypoint.java b/reference/latest/src/client/java/com/example/docs/rendering/HudRenderingEntrypoint.java index 16450b9b1..d226f49fe 100644 --- a/reference/latest/src/client/java/com/example/docs/rendering/HudRenderingEntrypoint.java +++ b/reference/latest/src/client/java/com/example/docs/rendering/HudRenderingEntrypoint.java @@ -11,12 +11,12 @@ public class HudRenderingEntrypoint implements ClientModInitializer { @Override public void onInitializeClient() { // :::1 - HudRenderCallback.EVENT.register((context, tickCounter) -> { + HudRenderCallback.EVENT.register((context, tickDeltaManager) -> { int color = 0xFFFF0000; // Red int targetColor = 0xFF00FF00; // Green // Total tick delta is stored in a field, so we can use it later. - totalTickDelta += tickCounter.getTickDelta(true); + totalTickDelta += tickDeltaManager.getTickDelta(true); // "lerp" simply means "linear interpolation", which is a fancy way of saying "blend". float lerpedAmount = MathHelper.abs(MathHelper.sin(totalTickDelta / 50F)); diff --git a/reference/latest/src/client/java/com/example/docs/rendering/RenderingConceptsEntrypoint.java b/reference/latest/src/client/java/com/example/docs/rendering/RenderingConceptsEntrypoint.java index 048be00de..311ea2434 100644 --- a/reference/latest/src/client/java/com/example/docs/rendering/RenderingConceptsEntrypoint.java +++ b/reference/latest/src/client/java/com/example/docs/rendering/RenderingConceptsEntrypoint.java @@ -23,7 +23,7 @@ public class RenderingConceptsEntrypoint implements ClientModInitializer { public void onInitializeClient() { // "A Practical Example: Rendering a Triangle Strip" // :::1 - HudRenderCallback.EVENT.register((drawContext, tickCounter) -> { + HudRenderCallback.EVENT.register((drawContext, tickDeltaManager) -> { // :::1 if (true) { return; @@ -33,7 +33,7 @@ public void onInitializeClient() { MatrixStack matrices = drawContext.getMatrices(); // Store the total tick delta in a field, so we can use it later. - totalTickDelta += tickCounter.getTickDelta(true); + totalTickDelta += tickDeltaManager.getTickDelta(true); // Push a new matrix onto the stack. matrices.push();