ASMR/src/main/kotlin/net/shadowfacts/asmr/ASMR.kt

49 lines
1.5 KiB
Kotlin

package net.shadowfacts.asmr
import net.fabricmc.api.ModInitializer
import net.fabricmc.fabric.api.registry.CommandRegistry
import net.minecraft.block.entity.BlockEntityType
import net.minecraft.client.MinecraftClient
import net.minecraft.item.BlockItem
import net.minecraft.item.Item
import net.minecraft.server.command.CommandManager
import net.minecraft.util.Identifier
import net.minecraft.util.registry.Registry
import net.shadowfacts.asmr.manager.ManagerBlock
import net.shadowfacts.asmr.manager.ManagerBlockEntity
import net.shadowfacts.asmr.util.register
import java.util.function.Supplier
/**
* @author shadowfacts
*/
object ASMR: ModInitializer {
const val modid = "asmr"
val managerBlock = ManagerBlock()
val managerBlockItem = BlockItem(managerBlock, Item.Settings())
val managerEntityType = BlockEntityType.Builder.create(Supplier { ManagerBlockEntity() }, managerBlock).build(null)
override fun onInitialize() {
println("hello fabric")
Registry.BLOCK.register(managerBlock, Identifier(modid, "manager"))
Registry.ITEM.register(managerBlockItem, Identifier(modid, "manager"))
Registry.BLOCK_ENTITY.register(managerEntityType, Identifier(modid, "manager"))
CommandRegistry.INSTANCE.register(false) { dispatcher ->
val command = CommandManager.literal("uitest").executes {
try {
MinecraftClient.getInstance().openScreen(TestCacaoScreen())
} catch (e: Throwable) {
e.printStackTrace()
}
1
}
dispatcher.register(command)
}
}
}