Skip to content

Commit de3bb6e

Browse files
committed
TickEvent KDocs
1 parent 0644c69 commit de3bb6e

File tree

2 files changed

+65
-25
lines changed

2 files changed

+65
-25
lines changed

common/src/main/java/com/lambda/mixin/MinecraftClientMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ void onTickPost(CallbackInfo ci) {
3737

3838
@Inject(method = "render", at = @At("HEAD"))
3939
void onLoopTickPre(CallbackInfo ci) {
40-
EventFlow.post(new TickEvent.GameLoop.Pre());
40+
EventFlow.post(new TickEvent.Render.Pre());
4141
}
4242

4343
@Inject(method = "render", at = @At("RETURN"))
4444
void onLoopTickPost(CallbackInfo ci) {
45-
EventFlow.post(new TickEvent.GameLoop.Post());
45+
EventFlow.post(new TickEvent.Render.Post());
4646
}
4747

4848
@Inject(at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;)V", shift = At.Shift.AFTER, remap = false), method = "stop")

common/src/main/kotlin/com/lambda/event/events/TickEvent.kt

Lines changed: 63 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,98 @@
11
package com.lambda.event.events
22

33
import com.lambda.event.Event
4-
import com.lambda.event.EventFlow
5-
import com.lambda.event.events.TickEvent.Post
6-
import com.lambda.event.events.TickEvent.Pre
74

8-
/**
9-
* An abstract class representing a [TickEvent] in the [EventFlow].
10-
*
11-
* A [TickEvent] is a type of [Event] that is triggered at each tick of the game loop.
12-
* It has two subclasses: [Pre] and [Post], which are triggered before and after the tick, respectively.
13-
*
14-
* The [TickEvent] class is designed to be extended by any class that needs to react to ticks.
15-
*
16-
* @see Pre
17-
* @see Post
18-
*/
195
abstract class TickEvent : Event {
206
/**
21-
* A class representing a [TickEvent] that is triggered before each tick of the tick loop.
7+
* Triggered before each iteration of the game loop.
8+
*
9+
* Phases:
10+
*
11+
* 1. **Pre-Tick**: Increments uptime, steps world tick manager, decrement item use cooldown.
12+
* 2. **GUI Update**: Processes delayed messages, updates HUD.
13+
* 3. **Game Mode Update**: Updates targeted entity, ticks tutorial, and interaction managers.
14+
* 4. **Texture Update**: Ticks texture manager.
15+
* 5. **Screen Handling**: Manages screen logic, ticks current screen.
16+
* 6. **Debug HUD Update**: Resets debug HUD chunk.
17+
* 7. **Input Handling**: Handles input events, decrements attack cooldown.
18+
* 8. **World Update**: Ticks game and world renderers, world entities.
19+
* 9. **Music and Sound Update**: Ticks music tracker and sound manager.
20+
* 10. **Tutorial and Social Interactions**: Handles tutorial and social interactions, ticks world.
21+
* 11. **Pending Connection**: Ticks integrated server connection.
22+
* 12. **Keyboard Handling**: Polls for debug crash key presses.
23+
*
24+
* @see net.minecraft.client.MinecraftClient.tick
2225
*/
2326
class Pre : TickEvent()
2427

2528
/**
26-
* A class representing a [TickEvent] that is triggered after each tick of the tick loop.
29+
* Triggered after each iteration of the game loop.
30+
* Targeted at 20 ticks per second.
31+
*
32+
* Phases:
33+
*
34+
* 1. **Pre-Tick**: Increments uptime, steps world tick manager, decrement item use cooldown.
35+
* 2. **GUI Update**: Processes delayed messages, updates HUD.
36+
* 3. **Game Mode Update**: Updates targeted entity, ticks tutorial, and interaction managers.
37+
* 4. **Texture Update**: Ticks texture manager.
38+
* 5. **Screen Handling**: Manages screen logic, ticks current screen.
39+
* 6. **Debug HUD Update**: Resets debug HUD chunk.
40+
* 7. **Input Handling**: Handles input events, decrements attack cooldown.
41+
* 8. **World Update**: Ticks game and world renderers, world entities (such as [TickEvent.Player]).
42+
* 9. **Music and Sound Update**: Ticks music tracker and sound manager.
43+
* 10. **Tutorial and Social Interactions**: Handles tutorial and social interactions, ticks world.
44+
* 11. **Pending Connection**: Ticks integrated server connection.
45+
* 12. **Keyboard Handling**: Polls for debug crash key presses.
46+
*
47+
* @see net.minecraft.client.MinecraftClient.tick
2748
*/
2849
class Post : TickEvent()
2950

3051
/**
31-
* A class representing a [TickEvent] that is triggered on each tick of the game loop.
52+
* Triggered before ([Pre]) and after ([Post]) each render tick.
53+
*
54+
* Phases:
55+
*
56+
* 1. **Pre-Render**: Prepares the window for rendering, checks for window close, handles resource reloads.
57+
* 2. **Task Execution**: Executes pending render tasks.
58+
* 3. **Client Tick**: Ticks the client ([TickEvent.Pre] and [TickEvent.Post]) until tick target was met.
59+
* 4. **Render**: Performs the actual rendering of the game.
60+
* 5. **Post-Render**: Finalizes the rendering process, updates the window.
61+
*
62+
* @see net.minecraft.client.MinecraftClient.render
3263
*/
33-
abstract class GameLoop : TickEvent() {
64+
abstract class Render : TickEvent() {
3465
/**
35-
* A class representing a [TickEvent.Player] that is triggered before each tick of the game loop.
66+
* Triggered before each render tick ([TickEvent.Render]) of the game loop.
3667
*/
3768
class Pre : TickEvent()
3869

3970
/**
40-
* A class representing a [TickEvent.Player] that is triggered after each tick of the game loop.
71+
* Triggered after each render tick ([TickEvent.Render]) of the game loop.
4172
*/
4273
class Post : TickEvent()
4374
}
4475

4576
/**
46-
* A class representing a [TickEvent] that is triggered when the player gets ticked.
77+
* Triggered before ([Pre]) and after ([Post]) each player tick that is run during the game loop [TickEvent.Pre].
78+
*
79+
* Phases:
80+
*
81+
* 1. **Pre-Tick**: Prepares player state before the tick.
82+
* 2. **Movement**: Handles player movement and input.
83+
* 3. **Action**: Processes player actions like swinging hand.
84+
* 4. **Post-Tick**: Finalizes player state after the tick.
85+
*
86+
* @see net.minecraft.client.network.ClientPlayerEntity.tick
4787
*/
4888
abstract class Player : TickEvent() {
4989
/**
50-
* A class representing a [TickEvent.Player] that is triggered before each player tick.
90+
* Triggered before each player tick ([TickEvent.Player]).
5191
*/
5292
class Pre : Player()
5393

5494
/**
55-
* A class representing a [TickEvent.Player] that is triggered after each player tick.
95+
* Triggered after each player tick ([TickEvent.Player]).
5696
*/
5797
class Post : Player()
5898
}

0 commit comments

Comments
 (0)