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
|
import com.ambientaddons.commands.AmbientCommand
import com.ambientaddons.config.Config
import com.ambientaddons.config.PersistentData
import com.ambientaddons.features.display.WitherShieldOverlay
import com.ambientaddons.features.dungeon.*
import com.ambientaddons.features.dungeon.terminals.MelodyHelper
import com.ambientaddons.features.keybinds.PerspectiveKeybind
import com.ambientaddons.features.keybinds.SendLastMessageKeybind
import com.ambientaddons.features.misc.*
import com.ambientaddons.utils.SBLocation
import com.ambientaddons.utils.dungeon.DungeonPlayers
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiScreen
import net.minecraft.client.settings.KeyBinding
import net.minecraftforge.client.ClientCommandHandler
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fml.client.registry.ClientRegistry
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.ModMetadata
import net.minecraftforge.fml.common.event.FMLInitializationEvent
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
import org.lwjgl.input.Keyboard
import java.io.File
@Mod(
modid = "ambientaddons",
name = "AmbientAddons",
version = "0.1",
useMetadata = true,
clientSideOnly = true
)
class AmbientAddons {
@Mod.EventHandler
fun preInit(event: FMLPreInitializationEvent) {
metadata = event.modMetadata
val directory = File(event.modConfigurationDirectory, "ambientaddons-forge")
directory.mkdirs()
configDirectory = directory
persistentData = PersistentData.load()
config = Config.apply { this.initialize() }
}
@Mod.EventHandler
fun onInit(event: FMLInitializationEvent) {
ClientCommandHandler.instance.registerCommand(AmbientCommand())
listOf(
this,
SBLocation,
AutoBuyChest,
CloseChest,
CancelInteractions,
DungeonReady,
ShortbowClicker,
BonzoMask,
PerspectiveKeybind,
SendLastMessageKeybind,
DungeonPlayers,
MelodyHelper,
WitherShieldOverlay,
KuudraReady,
DungeonHighlights,
Trapper,
CrimsonFishing
).forEach(MinecraftForge.EVENT_BUS::register)
keyBinds.values.forEach(ClientRegistry::registerKeyBinding)
}
@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
if (event.phase != TickEvent.Phase.START || currentGui == null) return
mc.displayGuiScreen(currentGui)
currentGui = null
}
companion object {
fun isInitialized(): Boolean {
return ::config.isInitialized
}
val mc: Minecraft = Minecraft.getMinecraft()
val keyBinds = mapOf(
"thirdPersonKey" to KeyBinding("Toggle third-person perspective", Keyboard.KEY_NONE, "AmbientAddons"),
"secondPersonKey" to KeyBinding("Toggle second-person perspective", Keyboard.KEY_NONE, "AmbientAddons"),
"spamKey" to KeyBinding("Send last message in party chat", Keyboard.KEY_NONE, "AmbientAddons"),
)
var currentGui: GuiScreen? = null
lateinit var configDirectory: File
lateinit var config: Config
lateinit var persistentData: PersistentData
lateinit var metadata: ModMetadata
}
}
|