From 679d50131d2830192a036e8b721df2c6b64d2d97 Mon Sep 17 00:00:00 2001 From: sylv256 Date: Wed, 17 Jul 2024 14:31:23 -0400 Subject: [PATCH] fix: dispel disinformation denoted by the dangerously dubious documentation --- .../api/event/client/ClientEntityTickEvents.java | 9 ++++++++- .../api/event/client/ClientLevelTickEvents.java | 4 ++-- .../gluon/lifecycle/test/client/ClientTickTests.java | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/library/core/lifecycle_events/src/main/java/org/muonmc/gluon/lifecycle/api/event/client/ClientEntityTickEvents.java b/library/core/lifecycle_events/src/main/java/org/muonmc/gluon/lifecycle/api/event/client/ClientEntityTickEvents.java index a489409a3..66d6df7eb 100644 --- a/library/core/lifecycle_events/src/main/java/org/muonmc/gluon/lifecycle/api/event/client/ClientEntityTickEvents.java +++ b/library/core/lifecycle_events/src/main/java/org/muonmc/gluon/lifecycle/api/event/client/ClientEntityTickEvents.java @@ -23,10 +23,17 @@ /** * Events related to a ticking Minecraft client's entities. + * + *

+ * Note that entities are ticked before the level is ticked. If you need to increment anything time-related, see {@link ClientLevelTickEvents}. However, block + * entity rendering should be handled in these events. + * *

A note of warning

*

* Callbacks registered to any of these events should ensure as little time as possible is spent executing, since the tick * loop is a very hot code path. + * + * @see ClientLevelTickEvents */ public final class ClientEntityTickEvents { /** @@ -42,7 +49,7 @@ public final class ClientEntityTickEvents { * This event is invoked at the end of a tick. * *

Tick Count

- * Note that the tick count has increased since the beginning of the tick. That means that the current tick count is ahead by one. + * The level tick count has not increased yet, so it should be accurate when this event is invoked. */ public static final Event END = Event.create(End.class, callbacks -> (minecraft, level) -> { for (var callback : callbacks) { diff --git a/library/core/lifecycle_events/src/main/java/org/muonmc/gluon/lifecycle/api/event/client/ClientLevelTickEvents.java b/library/core/lifecycle_events/src/main/java/org/muonmc/gluon/lifecycle/api/event/client/ClientLevelTickEvents.java index ae0ac070a..ec6981d98 100644 --- a/library/core/lifecycle_events/src/main/java/org/muonmc/gluon/lifecycle/api/event/client/ClientLevelTickEvents.java +++ b/library/core/lifecycle_events/src/main/java/org/muonmc/gluon/lifecycle/api/event/client/ClientLevelTickEvents.java @@ -26,8 +26,8 @@ * *

Entity Ticking

*

- * Note that these events are only called in the method that handles time and world border ticking. For entity ticking events, see - * {@link ClientEntityTickEvents}. + * Note that these events are only called in the method that handles time and world border ticking. Moreover, the level is ticked after entities are + * ticked. For entity ticking events, see {@link ClientEntityTickEvents}. * *

A note of warning

*

diff --git a/library/core/lifecycle_events/src/testmod/java/org/muonmc/gluon/lifecycle/test/client/ClientTickTests.java b/library/core/lifecycle_events/src/testmod/java/org/muonmc/gluon/lifecycle/test/client/ClientTickTests.java index db644a933..0d873f513 100644 --- a/library/core/lifecycle_events/src/testmod/java/org/muonmc/gluon/lifecycle/test/client/ClientTickTests.java +++ b/library/core/lifecycle_events/src/testmod/java/org/muonmc/gluon/lifecycle/test/client/ClientTickTests.java @@ -40,7 +40,7 @@ public void onEntityTickBegin(Minecraft minecraft, ClientLevel level) { @Override public void onEntityTickEnd(Minecraft minecraft, ClientLevel level) { - long ticks = level.getGameTime() - 1; + long ticks = level.getGameTime(); if (ticks % 40 == 0) { LOGGER.info("Entity tick end at {}t", ticks); }