### Quick Start: Create World Generation Elements Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/data-driven/Worldgen.md A comprehensive example demonstrating the creation of a DataPack with a dimension type, noise settings, a biome, a dimension, and a world preset. ```kotlin val dp = DataPack("my_pack") // 1) Dimension type val dimType = dp.dimensionType("example_type") { minY = -64 height = 384 hasSkylight = true } // 2) Noise settings val terrain = dp.noiseSettings("example_noise") { noiseOptions(-64, 384, 1, 2) } // 3) Biome with features val plains = dp.biome("example_plains") { temperature = 0.8f downfall = 0.4f hasPrecipitation = true attributes { skyColor(0x78A7FF) fogColor(0xC0D8FF) waterFogColor(0x050533) } effects { waterColor = color(0x3F76E4) } } // 4) Dimension val dim = dp.dimension("example_dimension", type = dimType) { // noiseGenerator(settings = terrain, biomeSource = ...) } // 5) World preset dp.worldPreset("example_preset") { dimension(DimensionTypes.OVERWORLD) { type = dimType } } ``` -------------------------------- ### Kore Project Structure Example Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/guides/From_Datapacks_to_Kore.md Illustrates how to define constants, functions, and register lifecycle events within a Kore project. This example shows the typical setup for a game's core features. ```kotlin data object Objectives { const val LIVES = "lives" const val ROUND = "round" } fun Function.combatInit() = function("feature/combat/init") { tellraw(allPlayers(), textComponent("[combat] initialized")) } fun Function.combatTick() = function("feature/combat/tick") { // Keep tick work small and dispatch if it grows. } fun Function.progressionTick() = function("feature/progression/tick") { // Keep progression routing isolated from combat. } fun DataPack.registerLifecycle() { load("system/bootstrap") { scoreboard.objectives.add(Objectives.LIVES, "dummy") scoreboard.objectives.add(Objectives.ROUND, "dummy") function(combatInit()) } tick("runtime/main") { function(combatTick()) function(progressionTick()) } } fun main() { dataPack("arena_core") { registerLifecycle() }.generate() } ``` -------------------------------- ### Vanilla Kore Datapack Setup Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/oop/OOP_Utilities.md Demonstrates the setup of scoreboard objectives, teams, player joining, game state transitions, cooldown ticks, and mob spawning using the vanilla Kore command DSL. ```kotlin dataPack("arena") { val namespace = "arena" // --- Scoreboard objectives --- function("setup") { scoreboard.objectives.add("kills", "dummy", textComponent("Kills")) scoreboard.objectives.add("game_state", "dummy") scoreboard.objectives.add("cooldown_dash", "dummy") teams { team("red") { color = FormattingColor.RED collisionRule = CollisionRule.PUSH_OTHER_TEAMS } team("blue") { color = FormattingColor.BLUE collisionRule = CollisionRule.PUSH_OTHER_TEAMS } } } // --- Player setup (manual selectors) --- function("join_red") { val player = allPlayers { limit = 1 sort = Sort.NEAREST } teams.join("red", player) gamemode(Gamemode.SURVIVAL, player) effect.give(player, Effects.SPEED, 999999, 1) scoreboard.players.set(player, "kills", 0) scoreboard.players.set(player, "cooldown_dash", 0) } function("join_blue") { val player = allPlayers { limit = 1 sort = Sort.NEAREST } teams.join("blue", player) gamemode(Gamemode.SURVIVAL, player) effect.give(player, Effects.SPEED, 999999, 1) scoreboard.players.set(player, "kills", 0) scoreboard.players.set(player, "cooldown_dash", 0) } // --- State transitions (manual scoreboard) --- function("start_game") { scoreboard.players.set(literal("#game_state"), "game_state", 1) execute { asTarget(allPlayers()) run { title(self()) { title(textComponent("Game Started!") { color = Color.GREEN bold = true }) } } } } // --- Cooldown tick (manual decrement) --- function("tick_cooldowns") { execute { ifCondition { score(allPlayers(), "cooldown_dash", 1..Int.MAX_VALUE) } run { scoreboard.players.remove(allPlayers(), "cooldown_dash", 1) } } } // --- Spawning a mob (manual summon) --- function("spawn_guardian") { summon(EntityTypes.IRON_GOLEM, vec3(0, 64, 0)) } } ``` -------------------------------- ### Complete Test Suite Example Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/advanced/Test_Features.md A comprehensive example demonstrating the creation of a test suite with reusable environments, function-based tests, and various test instance configurations. ```kotlin fun DataPack.createTestSuite() { val setupFn = function("test_setup") { say("Setting up test") } val cleanupFn = function("test_cleanup") { say("Cleaning up test") } // Create reusable environments val controlled = testEnvironmentsBuilder.gameRules("controlled") { this[Gamerules.DO_DAYLIGHT_CYCLE] = false this[Gamerules.DO_MOB_SPAWNING] = false this[Gamerules.RANDOM_TICK_SPEED] = 0 } val dayTime = testEnvironmentsBuilder.timeOfDay("day", 6000) val controlledDay = testEnvironmentsBuilder.allOf("controlled_day", controlled, dayTime) // Function environment (setup/teardown) testEnvironments { function("test_functions") { setup(setupFn) teardown(cleanupFn) } } testInstances { testInstance("redstone_basic") { blockBased() environment(controlledDay) maxTicks = 100 required = true structure(Structures.AncientCity.Structures.BARRACKS) } testInstance("complex_logic_test") { functionBased() environment(controlled) function("com.example.MyMod::myTest") maxAttempts = 2 maxTicks = 200 required = true structure(Structures.AncientCity.Structures.BARRACKS) } testInstance("directional_blocks") { blockBased() clockwise90() environment(controlled) maxTicks = 120 required = true structure(Structures.AncientCity.Structures.BARRACKS) } } } ``` -------------------------------- ### Complete Test Suite Example Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/advanced/Test_Features.md A comprehensive example demonstrating the creation of a test suite with multiple test instances, environments, and configurations. ```APIDOC ## Complete Example ### Description An example of creating a reusable test suite with custom environments and multiple test instances. ### Code ```kotlin fun DataPack.createTestSuite() { val setupFn = function("test_setup") { say("Setting up test") } val cleanupFn = function("test_cleanup") { say("Cleaning up test") } // Create reusable environments val controlled = testEnvironmentsBuilder.gameRules("controlled") { this[Gamerules.DO_DAYLIGHT_CYCLE] = false this[Gamerules.DO_MOB_SPAWNING] = false this[Gamerules.RANDOM_TICK_SPEED] = 0 } val dayTime = testEnvironmentsBuilder.timeOfDay("day", 6000) val controlledDay = testEnvironmentsBuilder.allOf("controlled_day", controlled, dayTime) // Function environment (setup/teardown) testEnvironments { function("test_functions") { setup(setupFn) teardown(cleanupFn) } } testInstances { testInstance("redstone_basic") { blockBased() environment(controlledDay) maxTicks = 100 required = true structure(Structures.AncientCity.Structures.BARRACKS) } testInstance("complex_logic_test") { functionBased() environment(controlled) function("com.example.MyMod::myTest") maxAttempts = 2 maxTicks = 200 required = true structure(Structures.AncientCity.Structures.BARRACKS) } testInstance("directional_blocks") { blockBased() clockwise90() environment(controlled) maxTicks = 120 required = true structure(Structures.AncientCity.Structures.BARRACKS) } } } ``` ``` -------------------------------- ### Bootstrap Datapack with Setup and Tick Functions Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/guides/Cookbook.md Use this pattern for a clear separation between initialization logic (setup) and recurring gameplay logic (tick). It ensures one-time registration and continuous execution of game loops. ```kotlin fun DataPack.registerCoreSystems() { load("setup") { scoreboard.objectives.add("round", "dummy") scoreboard.objectives.add("lives", "dummy") } tick("game_loop") { execute { asTarget(allPlayers()) run { say("tick") } } } } fun main() = dataPack("arena") { registerCoreSystems() }.generateZip() ``` -------------------------------- ### Complete Example: Custom Data Pack Advancements Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/data-driven/Advancements.md A comprehensive example demonstrating the creation of a custom data pack with multiple advancements, including a root advancement, a child advancement with multiple criteria and rewards, and a challenge advancement. ```kotlin dataPack("adventure_pack") { // Create a custom tab val customRoot = advancement("custom/root") { display(Items.COMPASS, "Custom Adventures", "Begin your custom journey") { frame = AdvancementFrameType.TASK background = Textures.Gui.Advancements.Backgrounds.ADVENTURE } criteria { tick("start") } } // Child advancement with multiple criteria advancement("custom/explorer") { parent = customRoot display(Items.MAP, "Explorer", "Visit multiple biomes") { frame = AdvancementFrameType.GOAL showToast = true announceToChat = true } criteria { location("visit_forest") { location { biome = Biomes.FOREST } } location("visit_desert") { location { biome = Biomes.DESERT } } location("visit_ocean") { location { biome = Biomes.OCEAN } } } // Any two biomes complete the advancement requirements( listOf("visit_forest", "visit_desert"), listOf("visit_forest", "visit_ocean"), listOf("visit_desert", "visit_ocean") ) rewards { experience = 50 } } // Challenge advancement advancement("custom/master") { parent = customRoot display(Items.NETHERITE_SWORD, "Master Adventurer", "Complete the ultimate challenge") { icon(Items.NETHERITE_SWORD) { enchantments { enchantment(Enchantments.SHARPNESS, 5) } } frame = AdvancementFrameType.CHALLENGE hidden = true } criteria { playerKilledEntity("kill_dragon") { entity { type(EntityTypes.ENDER_DRAGON) } } playerKilledEntity("kill_wither") { entity { type(EntityTypes.WITHER) } } } rewards { experience = 1000 function("master_reward") { title(self(), textComponent("MASTER ADVENTURER", Color.GOLD), textComponent("")) } } } } ``` -------------------------------- ### Complete Example: Custom World Clock Integration Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/data-driven/World_Clocks.md This comprehensive example demonstrates registering a custom clock, building a timeline driven by it, configuring a dimension type to use it, defining a predicate based on the clock, and creating commands to manipulate the clock. ```kotlin dataPack("my_mod") { // 1. Register a custom clock val season = worldClock("season") // 2. Build a timeline driven by that clock timeline("seasons", clock = season) { periodTicks = 96000 timeMarker("spring", ticks = 0, showInCommands = true) timeMarker("summer", ticks = 24000, showInCommands = true) timeMarker("autumn", ticks = 48000, showInCommands = true) timeMarker("winter", ticks = 72000, showInCommands = true) track(EnvironmentAttributes.Visual.FOG_END_DISTANCE) { ease = InOutSine keyframe(0) { value(200.0f) } keyframe(24000) { value(300.0f) } keyframe(48000) { value(200.0f) } keyframe(72000) { value(80.0f) } } } // 3. Wire the clock to a custom dimension val dimType = dimensionType("my_dimension_type") { defaultClock = season natural = true hasSkylight = true logicalHeight = 256 infiniburn = Tags.Block.INFINIBURN_OVERWORLD minY = -64 height = 384 monsterSpawnBlockLightLimit = 0 monsterSpawnLightLevel = constant(0) } // 4. Predicate: is it currently summer? predicate("is_summer") { timeCheck(min = 24000f, max = 48000f, clock = season) } // 5. Command: skip to winter function("skip_to_winter") { time.of(season).set(timeMarker("winter", "my_mod")) } // 6. Command: advance the season clock function("tick_season") { time.of(season).add(1) time.of(season).query(TimeType.DAYTIME) } } ``` -------------------------------- ### Example: Spawning a Wave of Entities Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/oop/Spawners.md An example of using a spawner to create a wave of 5 entities at the configured position, followed by a single entity at a specific offset. ```kotlin function("spawn_wave") { with(zombieSpawner) { spawnMultiple(5) spawnAt(vec3(12, 64, 12)) } } ``` -------------------------------- ### Implement scoreboard match setup Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/oop/Scoreboards.md Configures an objective and initializes a player's score for that objective. ```kotlin function("match_setup") { val kills = scoreboard("kills") kills.create() kills.setDisplaySlot(DisplaySlots.sidebar) val playerKills = player.getScoreEntity("kills") playerKills.set(0) } ``` -------------------------------- ### Complete Custom Village Example in Kotlin Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/data-driven/worldgen/Structures.md A comprehensive example demonstrating the creation of a custom village structure, including processor lists, template pools, and structure set configuration. ```kotlin fun DataPack.createCustomVillage() { // 1) Processor list for aging blocks val villageProcessors = processorList("village_processors") { processors = listOf( // Add aging, gravity, etc. ) } // 2) Template pool for houses val housesPool = templatePool("village/houses") { fallback = TemplatePools.Empty elements { singlePoolElement( location = "my_pack:village/house_small", projection = Projection.RIGID, processors = villageProcessors, weight = 3 ) singlePoolElement( location = "my_pack:village/house_large", projection = Projection.RIGID, processors = villageProcessors, weight = 1 ) } } // 3) Start pool (village center) the startPool = templatePool("village/start") { fallback = TemplatePools.Empty elements { singlePoolElement( location = "my_pack:village/center", projection = Projection.RIGID, processors = villageProcessors, weight = 1 ) } } // 4) Configured structure (via structures builder) structures { // Define jigsaw structure referencing startPool } // 5) Structure set for placement structureSet("custom_villages") { // structure(customVillage, weight = 1) randomSpreadPlacement(spacing = 34, separation = 8) { salt = 10387312 } } } ``` -------------------------------- ### Datapack Compatibility Check Example Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/guides/Creating_A_Datapack.md Demonstrates merging datapacks and highlights Kore's automatic checks for pack format range and supported formats, with example output. ```kotlin val myDatapack1 = dataPack("my_datapack 1") { // datapack code here pack { minFormat(40) maxFormat(40) } } val myDatapack2 = dataPack("my_datapack 2") { // datapack code here pack { minFormat(50) maxFormat(50) } } myDatapack1.generate { mergeWithDatapacks(myDatapack2) } ``` -------------------------------- ### Full Debug Function Execution Log Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/commands/Functions.md This example demonstrates the log messages generated by a 'debug' block when it includes calls to 'startDebug()' and other commands, showing start, end, and per-command logs. ```mcfunction tellraw @a [{"text":"Running function ","color":"gray","italic":true},{"text":"my_datapack:my_function","color":"white","bold":true,"click_event":{"action":"run_command","command":"function my_datapack:my_function"},"hoverEvent":{"action":"show_text","value":{"text":"Click to execute function","color":"gray","italic":true}},"italic":true}] say hello ! tellraw @a {"text":"/say hello !","click_event":{"action":"suggest_command","command":"say hello !"},"hoverEvent":{"action":"show_text","value":{"text":"Click to copy command","color":"gray","italic":true}}} tellraw @a [{"text":"Finished running function ","color":"gray","italic":true},{"text":"my_datapack:my_function","color":"white","bold":true,"click_event":{"action":"run_command","command":"function my_datapack:my_function"},"hoverEvent":{"action":"show_text","value":{"text":"Click to execute function","color":"gray","italic":true}},"italic":true}] ``` -------------------------------- ### Complete Custom Terrain Example Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/data-driven/worldgen/Noise.md A comprehensive example demonstrating the creation of custom terrain within a DataPack. This includes defining custom noise, noise settings, dimension types, and integrating them into a dimension. ```kotlin fun DataPack.createCustomTerrain() { // 1) Custom noise definition val hillsNoise = noise("hills_noise") { firstOctave = -5 amplitudes = listOf(1.0, 0.5, 0.25) } // 2) Noise settings for terrain val terrain = noiseSettings("custom_terrain") { noiseOptions(minY = -64, height = 384, sizeHorizontal = 1, sizeVertical = 2) defaultBlock(Blocks.STONE) {} defaultFluid(Blocks.WATER) { this["level"] = "0" } } // 3) Use in dimension val dimType = dimensionType("custom_type") { minY = -64 height = 384 hasSkylight = true } dimension("custom_world", type = dimType) { noiseGenerator( settings = terrain, biomeSource = /* your biome source */ ) } } ``` -------------------------------- ### Full Loot Table Example Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/data-driven/Loot_Tables.md A comprehensive example demonstrating the creation of a custom boss drop loot table, including global functions, guaranteed drops, rare equipment, and bonus loot from existing tables. ```kotlin dataPack("treasure_hunt") { // Custom boss drop table lootTable("boss_drops") { type = LootTableType.ENTITY // Global enchantment on all drops functions { enchantRandomly() } // Guaranteed drops pool { rolls = constant(1f) entries { item(Items.NETHER_STAR) } } // Rare equipment drops pool { rolls = constant(1f) bonusRolls = constant(0.5f) conditions { killedByPlayer() } entries { item(Items.NETHERITE_SWORD) { weight = 1 functions { enchantWithLevels(levels = constant(30f)) setName("Boss Slayer") } } item(Items.DIAMOND_SWORD) { weight = 5 functions { enchantWithLevels(levels = uniform(15f, 25f)) } } empty { weight = 10 } } } // Bonus loot from existing table pool { rolls = uniform(1f, 3f) entries { lootTable(LootTables.Chests.END_CITY_TREASURE) } } } } ``` -------------------------------- ### Full Shaped Crafting Recipe Example Source: https://github.com/ayfri/kore/wiki/Recipes A comprehensive example demonstrating the creation of a shaped crafting recipe for upgrading a diamond sword to a netherite sword, including pattern, keys, and a customized result. ```kotlin fun DataPack.createRecipes() { recipes { craftingShaped("diamond_sword_upgrade") { pattern( " E ", " D ", " S " ) keys { "E" to Items.EMERALD "D" to Items.DIAMOND_SWORD "S" to Items.NETHERITE_INGOT } result = Items.NETHERITE_SWORD { enchantments { enchantment(Enchantments.SHARPNESS, 5) } } } } } ``` -------------------------------- ### Complete Skylands World Preset Example Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/data-driven/worldgen/World_Presets.md This comprehensive example defines a custom dimension type, noise settings, biome, and finally integrates them into a world preset named 'skylands'. ```kotlin fun DataPack.createSkylandsPreset() { // 1) Custom dimension type val skyType = dimensionType("skylands_type") { minY = 0 height = 256 hasSkylight = true hasCeiling = false natural = true ambientLight = 0.1f attributes { canStartRaid(true) bedRule( BedRule( canSleep = BedSleepRule.ALWAYS, canSetSpawn = BedSleepRule.ALWAYS, explodes = false, ) ) } } // 2) Noise settings val skyNoise = noiseSettings("skylands_noise") { noiseOptions(minY = 0, height = 256, sizeHorizontal = 2, sizeVertical = 1) defaultBlock(Blocks.STONE) {} defaultFluid(Blocks.WATER) { this["level"] = "0" } } // 3) Biome val skyBiome = biome("skylands_biome") { temperature = 0.5f downfall = 0.5f hasPrecipitation = true attributes { skyColor(0x87CEEB) fogColor(0xC0D8FF) waterFogColor(0x050533) } effects { waterColor = color(0x3F76E4) } } // 4) World preset worldPreset("skylands") { dimension(DimensionTypes.OVERWORLD) { type = skyType noiseGenerator( settings = skyNoise, biomeSource = fixed(skyBiome) ) } } } ``` -------------------------------- ### Create a Custom Sky Dimension Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/data-driven/worldgen/Dimensions.md A complete example demonstrating the creation of a custom dimension with specific environmental attributes, noise settings, a custom biome, and a fixed biome source. This setup is for a unique 'sky' dimension. ```kotlin fun DataPack.createSkyDimension() { // 1) Dimension type with high ambient light val skyType = dimensionType("sky_type") { ambientLight = 0.5f hasCeiling = false hasSkylight = true height = 256 logicalHeight = 256 minY = 0 natural = true attributes { canStartRaid(false) respawnAnchorWorks(false) piglinsZombify(true) waterEvaporates(false) fastLava(false) increasedFireBurnout(false) bedRule( BedRule( canSleep = BedSleepRule.ALWAYS, canSetSpawn = BedSleepRule.ALWAYS, explodes = false, ) ) } } // 2) Simple noise settings val skyTerrain = noiseSettings("sky_terrain") { noiseOptions(minY = 0, height = 256, sizeHorizontal = 1, sizeVertical = 2) defaultBlock(Blocks.STONE) {} defaultFluid(Blocks.WATER) { this["level"] = "0" } } // 3) Create a biome val skyBiome = biome("sky_biome") { temperature = 0.5f downfall = 0.0f hasPrecipitation = false attributes { skyColor(0xFFFFFF) fogColor(0xFFFFFF) waterFogColor(0x050533) } effects { waterColor = color(0x3F76E4) } } // 4) Create the dimension dimension("sky", type = skyType) { noiseGenerator( biomeSource = fixed(skyBiome), settings = skyTerrain, ) } } ``` -------------------------------- ### Schedule Command Examples Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/commands/Commands.md Demonstrates scheduling a function to run after a delay, replacing existing schedules, and clearing schedules. ```kotlin function("schedule_examples") { val myFunction = function("delayed_action") { say("This runs later!") } schedule.function(myFunction, 100.ticks) schedule.function(myFunction, 5.seconds, ScheduleMode.REPLACE) schedule.clear(myFunction) } ``` -------------------------------- ### Full Inventory Manager Example with Player and Chest Policies Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/helpers/Inventory_Manager.md Combines player inventory policies with messaging and a chest that constantly re-seeds its first slot. This example mirrors test coverage used in Kore's own suite. ```kotlin fun Function.inventoryManagerTests() { val counter = "take_counter" val playerInv = inventoryManager(nearestPlayer()) playerInv.slotEvent(HOTBAR[0], Items.NETHER_STAR) { onTake { title(self(), TitleLocation.ACTIONBAR, text("Don’t take me", Color.RED)) scoreboard.players.add(self(), counter, 1) } duringTake { setItemInSlot() } onTick { clearAllItemsNotInSlot(); killAllItemsNotInSlot() } setItemInSlot() } playerInv.generateSlotsListeners() datapack.load { scoreboard.objectives.add(counter) scoreboard.players.set(playerInv.container as ScoreHolderArgument, counter, 0) } inventoryManager(vec3(0, -59, 0)) { setBlock(Blocks.CHEST) slotEvent(CONTAINER[0], Items.DIAMOND_SWORD) { onTake { tellraw(allPlayers(), text("You took the diamond sword from the chest", Color.RED)) } duringTake { setItemInSlot() } onTick { clearAllItemsNotInSlot(); killAllItemsNotInSlot() } setItemInSlot() } generateSlotsListeners() } } ``` -------------------------------- ### Configure Height Providers in Kotlin Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/data-driven/worldgen/Features.md Examples of different height distribution strategies for ore and feature placement. ```kotlin // Uniform distribution between min and max heightRange(uniformHeightProvider(minY = 0, maxY = 64)) // Triangular distribution (peaks at center) heightRange(trapezoidHeightProvider(minY = 0, maxY = 64, plateau = 20)) // Constant height heightRange(constantHeightProvider(y = 32)) // Relative to world bounds heightRange(veryBiasedToBottomHeightProvider(minY = 0, maxY = 64)) ``` -------------------------------- ### Create a complex advancement Source: https://github.com/ayfri/kore/wiki/Advancements A comprehensive example combining display, parent, criteria, requirements, rewards, and telemetry settings. ```kotlin advancement("complex_advancement") { display(Items.DIAMOND_SWORD, "Master Craftsman", "Craft a special item") { frame = AdvancementFrameType.CHALLENGE announceToChat = true } parent = Advancements.Story.ROOT criteria { crafterRecipeCrafted("craft_special", Recipes.SPECIAL_RECIPE) { ingredient(Items.DIAMOND) { components { damage(0) } } } } requirements("craft_special") rewards { experience = 100 function = function("reward") { say("Congratulations on becoming a Master Craftsman!") } loots(LootTables.Chests.IGLOO_CHEST) } sendsTelemetryEvent = false } ``` -------------------------------- ### Started Riding Trigger Example Source: https://github.com/ayfri/kore/wiki/Advancements-Triggers Triggers when a player starts riding an entity, with conditions on the vehicle type. This trigger has no additional properties. ```kotlin startedRiding("ride_horse") { conditions { vehicle { type(EntityTypes.HORSE) } } } ``` -------------------------------- ### Complete Example: Custom Tool Upgrade System Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/concepts/Components.md Demonstrates a tool upgrade system using item predicates to detect enchanted, damaged tools and replace them with upgraded versions. Includes functions for checking player inventory and clearing specific items. ```kotlin dataPack("tool_upgrades") { // Predicate to find diamond swords that need upgrading predicate("upgradeable_sword") { matchTool { items(Items.DIAMOND_SWORD) predicates { // Must have Sharpness enchantment enchantments { enchantment(Enchantments.SHARPNESS, level = rangeOrInt(1..4)) } // Must be damaged (durability used) damage { damage = rangeOrInt(1..1000) } } } } // Function to check player's held item and upgrade it function("check_upgrade") { // Check if holding an upgradeable sword execute { ifCondition { items( self(), ItemSlot.WEAPON_MAINHAND, Items.DIAMOND_SWORD.predicate { subPredicates { enchantments { enchantment(Enchantments.SHARPNESS, level = rangeOrInt(3..4)) } } } ) } run { // Replace with netherite sword keeping enchantments items.modify(self(), ItemSlot.WEAPON_MAINHAND, itemModifier("upgrade_to_netherite")) tellraw(self(), textComponent("Your sword has been upgraded!", Color.GOLD)) } } } // Clear specific items from inventory using predicates function("clear_broken_tools") { // Clear any tool with 1 durability left clear(allPlayers(), itemPredicate { subPredicates { damage { durability = rangeOrInt(1) } } }) } // Give reward only if player has specific item combination function("check_collection") { execute { // Check for a goat horn (any variant) ifCondition { items( self(), ItemSlot.INVENTORY, itemPredicate { isPresent(ItemComponentTypes.INSTRUMENT) } ) } // Check for enchanted book with Mending ifCondition { items( self(), ItemSlot.INVENTORY, Items.ENCHANTED_BOOK.predicate { subPredicates { storedEnchantments { enchantment(Enchantments.MENDING) } } } ) } run { give(self(), Items.NETHER_STAR) } } } } ``` -------------------------------- ### Particle Command Examples Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/commands/Commands.md Shows how to spawn simple particles, particles with position and spread, and particles with force mode for increased visibility. Also demonstrates targeting specific entities. ```kotlin function("particle_examples") { // Simple particle particle(Particles.ASH) // Particle at position with delta and count particle(Particles.ASH, vec3(), vec3(), 1.0, 2) // Particle with force mode (visible from far away) particle(Particles.ASH, vec3(), vec3(), 1.0, 2, ParticleMode.FORCE) // Particle visible only to specific players particle(Particles.ASH, vec3(), vec3(), 1.0, 2, ParticleMode.NORMAL, allEntities()) } ``` ```mcfunction particle minecraft:ash particle minecraft:ash ~ ~ ~ ~ ~ ~ 1 2 particle minecraft:ash ~ ~ ~ ~ ~ ~ 1 2 force particle minecraft:ash ~ ~ ~ ~ ~ ~ 1 2 normal @e ``` -------------------------------- ### fallAfterExplosion Trigger Example Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/data-driven/advancements/Triggers.md Triggers after falling from an explosion. Specifies the start position and horizontal distance of the fall. ```kotlin fallAfterExplosion("tnt_launch") { startPosition { position { y = rangeOrInt(100..200) } } distance { horizontal(10f) } } ``` -------------------------------- ### Comprehensive Recipe Definitions Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/data-driven/Recipes.md Examples of various recipe types including shaped, shapeless, smelting, and smithing configurations. ```kotlin dataPack("custom_recipes") { recipes { // Shaped crafting with components craftingShaped("legendary_sword") { pattern( " N ", " N ", " B " ) keys { "N" to Items.NETHERITE_INGOT "B" to Items.BLAZE_ROD } result(Items.NETHERITE_SWORD) { customName(textComponent("Blade of Flames", Color.GOLD)) enchantments { enchantment(Enchantments.FIRE_ASPECT, 2) enchantment(Enchantments.SHARPNESS, 5) } unbreakable() } category = CraftingCategory.EQUIPMENT } // Shapeless recipe craftingShapeless("quick_tnt") { ingredient(Items.GUNPOWDER) ingredient(Items.GUNPOWDER) ingredient(Items.GUNPOWDER) ingredient(Items.GUNPOWDER) ingredient(Tags.Item.SAND) result(Items.TNT) } // Transmute recipe craftingTransmute("repaint_bed") { input(Tags.Item.BEDS) material(Items.WHITE_DYE) result(Items.WHITE_BED) } // Smelting with experience smelting("ancient_debris") { ingredient(Items.ANCIENT_DEBRIS) result(Items.NETHERITE_SCRAP) experience = 2.0 cookingTime = 200 category = SmeltingCategory.MISC } // Smithing upgrade smithingTransform("netherite_boots") { template(Items.NETHERITE_UPGRADE_SMITHING_TEMPLATE) base(Items.DIAMOND_BOOTS) addition(Items.NETHERITE_INGOT) result(Items.NETHERITE_BOOTS) } // Smithing trim smithingTrim("ward_trim") { template(Items.WARD_ARMOR_TRIM_SMITHING_TEMPLATE) base(Tags.Item.TRIMMABLE_ARMOR) addition(Tags.Item.TRIM_MATERIALS) pattern = TrimPatterns.WARD } // Stonecutting variants stoneCutting("cut_copper_slab") { ingredient(Items.COPPER_BLOCK) result(Items.CUT_COPPER_SLAB) count = 8 } } // Reference recipe in function val beaconRecipe = recipesBuilder.craftingShaped("easy_beacon") { pattern( "GGG", "GSG", "OOO" ) keys { "G" to Items.GLASS "S" to Items.NETHER_STAR "O" to Items.OBSIDIAN } result(Items.BEACON) } load { recipeGive(allPlayers(), beaconRecipe) } } ``` -------------------------------- ### Ride Entity in Lava Trigger Example Source: https://github.com/ayfri/kore/wiki/Advancements-Triggers Triggers when riding an entity in lava, capturing travel distance and starting position. ```kotlin rideEntityInLava("lava_ride") { distance { horizontal(10f) } startPosition { position { y = rangeOrInt(100..200) } } } ``` -------------------------------- ### Generate Minimal Datapack Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/Home.md Creates a simple datapack named 'example' with a single function that displays 'Hello World!' to all players. The datapack is then packaged as a zip file. ```kotlin fun main() { dataPack("example") { function("display_text") { tellraw(allPlayers(), textComponent("Hello World!")) } }.generateZip() } ``` -------------------------------- ### Nether Travel Trigger Example Source: https://github.com/ayfri/kore/wiki/Advancements-Triggers Triggers when a player enters or exits the Nether. Captures travel distance and starting position. ```kotlin netherTravel("enter_nether") { distance { horizontal(100f) } startPosition { position { x = rangeOrInt(0..100) z = rangeOrInt(0..100) } } } ``` -------------------------------- ### Dynamic Entry Example Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/data-driven/Loot_Tables.md A dynamic entry for block-specific drops, such as decorated pot sherds or shulker contents. ```kotlin entries { dynamic(LootEntryDynamicName.SHERDS) { // Drops contents of decorated pot sherds } } ``` -------------------------------- ### Filter Block Files in Datapack Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/guides/Creating_A_Datapack.md Implement filters to exclude specific block files from the datapack. This example filters out block files starting with 'stone'. ```kotlin dataPack("my_datapack") { filter { blocks("stone*") } } ``` -------------------------------- ### OOP Kore Datapack Setup Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/oop/OOP_Utilities.md Illustrates setting up players, teams, scoreboard objectives, cooldowns, game states, and spawners using Kore's OOP abstractions. ```kotlin dataPack("arena") { // --- Players as objects --- val redPlayer = player("RedPlayer") val bluePlayer = player("BluePlayer") // --- Teams --- val redTeam = team("red") { color = FormattingColor.RED collisionRule = CollisionRule.PUSH_OTHER_TEAMS } val blueTeam = team("blue") { color = FormattingColor.BLUE collisionRule = CollisionRule.PUSH_OTHER_TEAMS } // --- Scoreboard --- val kills = scoreboard("kills") // --- Cooldown --- val dashCooldown = registerCooldown("dash", 3.seconds) // --- Game states --- val states = registerGameStates { state("lobby") state("running") state("finished") } // --- Spawner --- val guardian = registerSpawner("guardian", EntityTypes.IRON_GOLEM) { position = vec3(0, 64, 0) } // --- Player setup --- function("join_red") { redPlayer.joinTeam("red") redPlayer.setGamemode(Gamemode.SURVIVAL) redPlayer.giveEffect(Effects.SPEED, duration = 999999, amplifier = 1) kills.set(redPlayer, 0) } function("join_blue") { bluePlayer.joinTeam("blue") bluePlayer.setGamemode(Gamemode.SURVIVAL) bluePlayer.giveEffect(Effects.SPEED, duration = 999999, amplifier = 1) kills.set(bluePlayer, 0) } // --- State transition --- function("start_game") { states.transitionTo("running") redPlayer.title(textComponent("Game Started!") { color = Color.GREEN bold = true }) bluePlayer.title(textComponent("Game Started!") { color = Color.GREEN bold = true }) } // --- Spawning --- function("spawn_guardian") { guardian.spawn() } } ``` -------------------------------- ### Initialize Dialogs with Builder Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/data-driven/Dialogs.md Use the dialogBuilder to start defining a confirmation dialog. This is a common way to initiate dialog creation. ```kotlin val myDialog = dialogBuilder.confirmation("welcome", "Welcome!") { // Define dialog properties here } ``` -------------------------------- ### Attribute Command Examples Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/commands/Commands.md Reads and modifies entity attributes. Supports getting base values, setting base values, and adding/removing attribute modifiers. ```kotlin function("attribute_examples") { attribute(self(), Attributes.GENERIC_MAX_HEALTH) { get() base.get() base.set(40.0) } attribute(self(), Attributes.GENERIC_MOVEMENT_SPEED) { modifiers.add("speed_boost", 0.1, AttributeModifierOperation.ADD_VALUE) modifiers.remove("speed_boost") } } ``` -------------------------------- ### Difficulty Command Examples Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/commands/Commands.md Gets or sets the world's difficulty level. Difficulty affects mob damage, hunger depletion, and hostile mob spawning. ```kotlin function("difficulty_examples") { difficulty() // Query current difficulty difficulty(Difficulty.HARD) } ``` -------------------------------- ### Clone Command Examples Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/commands/Commands.md Demonstrates various ways to use the clone command, including basic cloning, cross-dimension cloning, masked cloning, filtering by block type, and strict mode. ```kotlin clone { begin = vec3(0, 64, 0) end = vec3(10, 74, 10) destination = vec3(100, 64, 100) } ``` ```kotlin clone { begin = vec3(0, 64, 0) end = vec3(10, 74, 10) destination = vec3(0, 64, 0) from = Dimensions.THE_NETHER o = Dimensions.OVERWORLD } ``` ```kotlin clone { begin = vec3(0, 64, 0) end = vec3(10, 74, 10) destination = vec3(100, 64, 100) masked(CloneMode.MOVE) // Only non-air blocks, move instead of copy } ``` ```kotlin clone { begin = vec3(0, 64, 0) end = vec3(10, 74, 10) destination = vec3(100, 64, 100) filter(Tags.Block.BASE_STONE_OVERWORLD, CloneMode.FORCE) } ``` ```kotlin clone { begin = vec3(0, 64, 0) end = vec3(10, 74, 10) destination = vec3(5, 64, 5) strict = true } ``` -------------------------------- ### Item Entry Example Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/data-driven/Loot_Tables.md Defines a singleton entry that drops a specific item with configurable weight, quality, conditions, and functions. ```kotlin entries { item(Items.DIAMOND) { weight = 1 quality = 2 conditions { randomChance(0.5f) } functions { setCount(uniform(1f, 3f)) } } } ``` -------------------------------- ### Configure Raid Start Condition Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/data-driven/worldgen/Environment_Attributes.md Determines if a Raid can be initiated by a player with Raid Omen. Set to false to disallow raid starts. ```kotlin attributes { canStartRaid(false) } ``` -------------------------------- ### Practical Raycast Setup - Kotlin Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/helpers/Raycasts.md Sets up a raycast for scanning with specific parameters for step size and callbacks. The scanner is then used to perform a single scan within a function. ```kotlin val scanner = raycast { name = "scanner" maxDistance = 24 step = 0.25 onStep = { particle(Particles.END_ROD, vec3()) } onHitBlock = { say("Target acquired") } onMaxDistance = { say("No target found") } } function("scan_once") { with(scanner) { cast() } } ``` -------------------------------- ### Start a Cooldown Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/oop/Cooldowns.md Starts or restarts a cooldown for a player by setting their score to the configured duration. This is typically called after an action that consumes the cooldown. ```kotlin function("dash_hit") { cd.start(player) } ``` -------------------------------- ### Create a Basic Datapack with Functions Source: https://github.com/ayfri/kore/blob/master/website/src/jsMain/resources/markdown/doc/Getting_Started.md This snippet shows how to create a simple datapack with a 'hello' and 'setup' function. It generates a zip file ready to be placed in the Minecraft datapacks folder. ```kotlin fun main() { val datapack = dataPack("starter_kore") { pack { description = textComponent("Starter datapack generated with Kore") } function("hello") { tellraw(allPlayers(), textComponent("Hello from Kore")) } function("setup") { tellraw(allPlayers(), textComponent("Setup complete")) } } datapack.generateZip() } ```