1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
package com.dulkirfabric
import com.dulkirfabric.DulkirModFabric.EVENT_BUS
import com.dulkirfabric.commands.*
import com.dulkirfabric.events.*
import com.dulkirfabric.events.chat.ChatEvents
import com.dulkirfabric.events.chat.ModifyCommandEvent
import com.dulkirfabric.events.chat.OverlayReceivedEvent
import com.dulkirfabric.features.*
import com.dulkirfabric.features.chat.AbiPhoneDND
import com.dulkirfabric.features.chat.BridgeBotFormatter
import com.dulkirfabric.features.filters.CullExplosionParticles
import com.dulkirfabric.features.filters.DamageNumbers
import com.dulkirfabric.features.filters.Lightning
import com.dulkirfabric.features.slayer.BossTimer
import com.dulkirfabric.features.slayer.Demonlord
import com.dulkirfabric.features.slayer.MiniBossHighlight
import com.dulkirfabric.features.slayer.Vampire
import com.dulkirfabric.hud.ActionBarHudReplacements
import com.dulkirfabric.hud.Garden
import com.dulkirfabric.hud.SpeedOverlay
import com.dulkirfabric.util.ActionBarUtil
import com.dulkirfabric.util.ScoreBoardUtils
import com.dulkirfabric.util.TablistUtils
import com.dulkirfabric.util.Utils
import com.dulkirfabric.util.render.HudRenderUtil
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientEntityEvents
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents
import net.fabricmc.fabric.api.client.message.v1.ClientSendMessageEvents
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents
import net.fabricmc.fabric.api.client.screen.v1.ScreenMouseEvents
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents
import net.fabricmc.loader.api.FabricLoader
/**
* Collection of different mod registration stuff ran on initializing the mod. It is separated for readability
* purposes, as the list of features is planned to be quite large.
*/
object Registrations {
private var tickCount: Int = 0
fun registerCommands() {
val cre = ClientCommandRegistrationCallback.EVENT
cre.register(ConfigCommand::register)
cre.register(JoinDungeonCommands.F1Command::register)
cre.register(JoinDungeonCommands.F2Command::register)
cre.register(JoinDungeonCommands.F3Command::register)
cre.register(JoinDungeonCommands.F4Command::register)
cre.register(JoinDungeonCommands.F5Command::register)
cre.register(JoinDungeonCommands.F6Command::register)
cre.register(JoinDungeonCommands.F7Command::register)
cre.register(JoinDungeonCommands.M1Command::register)
cre.register(JoinDungeonCommands.M2Command::register)
cre.register(JoinDungeonCommands.M3Command::register)
cre.register(JoinDungeonCommands.M4Command::register)
cre.register(JoinDungeonCommands.M5Command::register)
cre.register(JoinDungeonCommands.M6Command::register)
cre.register(JoinDungeonCommands.M7Command::register)
cre.register(DynamicKeyCommand::register)
cre.register(AnimationCommand::register)
if (FabricLoader.getInstance().isDevelopmentEnvironment)
cre.register(TestCommand::register)
}
fun registerEventListeners() {
EVENT_BUS.subscribe(DulkirModFabric)
EVENT_BUS.subscribe(KeyShortCutImpl)
EVENT_BUS.subscribe(RenderTest)
EVENT_BUS.subscribe(TooltipImpl)
EVENT_BUS.subscribe(CustomBlockOutline)
EVENT_BUS.subscribe(AbiPhoneDND)
EVENT_BUS.subscribe(InventoryScale)
EVENT_BUS.subscribe(IPhoneAlarm)
EVENT_BUS.subscribe(AliasImpl)
EVENT_BUS.subscribe(EffigyDisplay)
EVENT_BUS.subscribe(TablistUtils)
EVENT_BUS.subscribe(CullExplosionParticles)
EVENT_BUS.subscribe(CooldownDisplays)
EVENT_BUS.subscribe(ArachneFeatures)
EVENT_BUS.subscribe(BridgeBotFormatter)
EVENT_BUS.subscribe(SpeedOverlay)
EVENT_BUS.subscribe(ActionBarUtil)
EVENT_BUS.subscribe(ActionBarHudReplacements)
EVENT_BUS.subscribe(AotvHighlight)
EVENT_BUS.subscribe(MiniBossHighlight)
EVENT_BUS.subscribe(ScoreBoardUtils)
EVENT_BUS.subscribe(HudRenderUtil)
EVENT_BUS.subscribe(Demonlord)
EVENT_BUS.subscribe(Lightning)
EVENT_BUS.subscribe(Utils)
EVENT_BUS.subscribe(BossTimer)
EVENT_BUS.subscribe(DamageNumbers)
EVENT_BUS.subscribe(Garden)
EVENT_BUS.subscribe(VisitorAlert)
EVENT_BUS.subscribe(BrokenHyp)
EVENT_BUS.subscribe(Vampire)
if (FabricLoader.getInstance().isDevelopmentEnvironment)
EVENT_BUS.subscribe(RenderTest)
}
fun registerEvents() {
// Register Custom Tick event, so we can use it like 1.8.9 forge
ClientTickEvents.START_CLIENT_TICK.register { _ ->
ClientTickEvent.post()
if (tickCount % 20 == 0) LongUpdateEvent.post()
tickCount++
}
ClientReceiveMessageEvents.ALLOW_GAME.register { message, overlay ->
if (!overlay)
return@register !ChatEvents.AllowChat(message).post()
return@register true
}
ClientReceiveMessageEvents.MODIFY_GAME.register { message, overlay ->
if (overlay)
return@register OverlayReceivedEvent(message).post()
return@register ChatEvents.ModifyChat(message).post()
}
ClientSendMessageEvents.MODIFY_COMMAND.register { command ->
ModifyCommandEvent(command).also { it.post() }.command
}
WorldRenderEvents.END.register { context ->
WorldRenderLastEvent(
context,
context.matrixStack()!! // Not null assertion is safe here since this is late enough in rendering
).post()
}
ScreenEvents.BEFORE_INIT.register(
ScreenEvents.BeforeInit { client, screen, scaledWidth, scaledHeight ->
ScreenMouseEvents.beforeMouseScroll(screen)
.register(ScreenMouseEvents.BeforeMouseScroll { coolScreen, mouseX, mouseY, horizontalAmount, verticalAmount ->
MouseScrollEvent(coolScreen, mouseX, mouseY, horizontalAmount, verticalAmount).post()
})
}
)
WorldRenderEvents.BLOCK_OUTLINE.register { worldRenderContext, blockOutlineContext ->
!BlockOutlineEvent(worldRenderContext, blockOutlineContext).post()
}
ClientEntityEvents.ENTITY_LOAD.register { entity, world ->
EntityLoadEvent(entity, world).post()
}
ServerWorldEvents.LOAD.register { server, world ->
WorldLoadEvent(server, world).post()
}
HudRenderCallback.EVENT.register { context, delta ->
HudRenderEvent(context, delta).post()
}
}
}
|