Fabric-language | Kotlin

object ModItems val EXAMPLE_ITEM: Item = Item(Item.Settings().maxCount(64)) fun register() Registry.register(Registries.ITEM, Identifier(MOD_ID, "example_item"), EXAMPLE_ITEM)

suspend fun fetchData(): String = withContext(Dispatchers.IO) // network call

In gradle.properties :

Extension Functions fun PlayerEntity.giveItem(item: Item, count: Int = 1) inventory.offerOrDrop(ItemStack(item, count))

// Usage: player.giveItem(Items.DIAMOND, 5) data class PlayerData(val mana: Int, val lastCast: Long) // Attach via Component API (Cardinal Components) Object Declarations for Singletons Use object instead of class with static methods – perfect for registries. Sealed Classes for State Machines sealed class MachineState object Idle : MachineState() data class Running(val progress: Int) : MachineState() object Broken : MachineState() fabric-language kotlin

Note: The fabric-language-kotlin module registers the kotlin language adapter automatically. Block with simple properties object ModBlocks val EXAMPLE_BLOCK: Block = Block(FabricBlockSettings.create() .strength(4.0f) .requiresTool() .mapColor(MapColor.STONE_GRAY)) fun register() Registry.register(Registries.BLOCK, Identifier(MOD_ID, "example_block"), EXAMPLE_BLOCK)

"entrypoints": "main": [ "com.example.mymod.MyMod" ] , "languageAdapters": "kotlin": "net.fabricmc.language.kotlin.KotlinLanguageAdapter" object ModItems val EXAMPLE_ITEM: Item = Item(Item

package com.example.mymod import net.fabricmc.api.ModInitializer import org.slf4j.LoggerFactory