blob: bf8e5032be4224966351592659597ef61b39b949 (
plain)
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
|
import com.ambientaddons.commands.AmbientCommand
import com.ambientaddons.config.Config
import com.ambientaddons.config.PersistentData
import com.ambientaddons.features.dungeon.AutoBuyChest
import com.ambientaddons.utils.LocationUtils
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiScreen
import net.minecraftforge.client.ClientCommandHandler
import net.minecraftforge.common.MinecraftForge
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 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
}
@Mod.EventHandler
fun onInit(event: FMLInitializationEvent) {
ClientCommandHandler.instance.registerCommand(AmbientCommand())
listOf(
this,
LocationUtils,
AutoBuyChest
).forEach(MinecraftForge.EVENT_BUS::register)
}
@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
if (event.phase != TickEvent.Phase.START || currentGui == null) return
mc.displayGuiScreen(currentGui)
currentGui = null
}
companion object {
val mc: Minecraft = Minecraft.getMinecraft()
var currentGui: GuiScreen? = null
lateinit var configDirectory: File
lateinit var config: Config
lateinit var persistentData: PersistentData
lateinit var metadata: ModMetadata
}
}
|