From dabada89851d18760a39eb6c30ec39b77a5d055d Mon Sep 17 00:00:00 2001 From: Jakob K Date: Tue, 13 Jul 2021 17:55:10 +0200 Subject: [PATCH 1/6] Update minotaur --- buildSrc/build.gradle.kts | 2 +- buildSrc/src/main/kotlin/BuildConstants.kt | 3 +++ buildSrc/src/main/kotlin/mod-publish-script.gradle.kts | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 376a0910..88ebb819 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -12,5 +12,5 @@ dependencies { implementation(kotlin("gradle-plugin", "1.5.10")) implementation("net.fabricmc", "fabric-loom", "0.8-SNAPSHOT") implementation("gradle.plugin.com.matthewprenger:CurseGradle:1.4.0") - implementation("gradle.plugin.com.modrinth.minotaur:Minotaur:1.1.0") + implementation("gradle.plugin.com.modrinth.minotaur:Minotaur:1.2.1") } diff --git a/buildSrc/src/main/kotlin/BuildConstants.kt b/buildSrc/src/main/kotlin/BuildConstants.kt index e5b8aa4d..40f13cfb 100644 --- a/buildSrc/src/main/kotlin/BuildConstants.kt +++ b/buildSrc/src/main/kotlin/BuildConstants.kt @@ -1,7 +1,10 @@ +import com.modrinth.minotaur.request.VersionType + object BuildConstants { const val fabrikVersion = "1.0.1-SNAPSHOT" val isSnapshot = fabrikVersion.endsWith("-SNAPSHOT") val projectState = if (isSnapshot) "beta" else "release" + val projectStateType = if (isSnapshot) VersionType.BETA else VersionType.RELEASE const val curseforgeId = "447425" const val githubRepo = "bluefireoly/fabrikmc" diff --git a/buildSrc/src/main/kotlin/mod-publish-script.gradle.kts b/buildSrc/src/main/kotlin/mod-publish-script.gradle.kts index 740da400..dd655957 100644 --- a/buildSrc/src/main/kotlin/mod-publish-script.gradle.kts +++ b/buildSrc/src/main/kotlin/mod-publish-script.gradle.kts @@ -4,6 +4,7 @@ import BuildConstants.githubRepo import BuildConstants.isSnapshot import BuildConstants.minecraftVersion import BuildConstants.projectState +import BuildConstants.projectStateType import com.matthewprenger.cursegradle.CurseProject import com.matthewprenger.cursegradle.CurseRelation import com.matthewprenger.cursegradle.CurseUploadTask @@ -35,7 +36,7 @@ tasks { uploadFile = tasks.named("remapJar").get() addGameVersion(minecraftVersion) addLoader("fabric") - releaseType = projectState + versionType = projectStateType } create("publishAndUploadMod") { From deaf4fc8fac2f578bc169718c7cfef649c1bf31a Mon Sep 17 00:00:00 2001 From: Jakob K Date: Tue, 13 Jul 2021 17:56:06 +0200 Subject: [PATCH 2/6] Update fabric dependencies --- buildSrc/src/main/kotlin/BuildConstants.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/buildSrc/src/main/kotlin/BuildConstants.kt b/buildSrc/src/main/kotlin/BuildConstants.kt index 40f13cfb..ba8c190e 100644 --- a/buildSrc/src/main/kotlin/BuildConstants.kt +++ b/buildSrc/src/main/kotlin/BuildConstants.kt @@ -14,9 +14,9 @@ object BuildConstants { const val majorMinecraftVersion = "1.17" // check these values here: https://axay.net/fabric/gradlekts/latest - const val minecraftVersion = "1.17" - const val yarnMappingsVersion = "1.17+build.1:v2" - const val fabricLoaderVersion = "0.11.3" - const val fabricApiVersion = "0.34.9+1.17" - const val fabricLanguageKotlinVersion = "1.6.1+kotlin.1.5.10" + const val minecraftVersion = "1.17.1" + const val yarnMappingsVersion = "1.17.1+build.13:v2" + const val fabricLoaderVersion = "0.11.6" + const val fabricApiVersion = "0.37.0+1.17" + const val fabricLanguageKotlinVersion = "1.6.2+kotlin.1.5.20" } From 8f0e617e106c388dd1d3101bc1a414d2d8b805b3 Mon Sep 17 00:00:00 2001 From: Jakob K Date: Tue, 13 Jul 2021 18:20:57 +0200 Subject: [PATCH 3/6] Rename getOrCreateSubTag to getOrCreateSubNbt --- .../src/main/kotlin/net/axay/fabrik/core/item/ItemBuilder.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fabrikmc-core/src/main/kotlin/net/axay/fabrik/core/item/ItemBuilder.kt b/fabrikmc-core/src/main/kotlin/net/axay/fabrik/core/item/ItemBuilder.kt index 593e1a2a..40e225a7 100644 --- a/fabrikmc-core/src/main/kotlin/net/axay/fabrik/core/item/ItemBuilder.kt +++ b/fabrikmc-core/src/main/kotlin/net/axay/fabrik/core/item/ItemBuilder.kt @@ -23,7 +23,7 @@ inline fun itemStack( * name of the item stack. */ fun ItemStack.setLore(text: Collection) { - getOrCreateSubTag("display").put( + getOrCreateSubNbt("display").put( "Lore", text.mapTo(NbtList()) { NbtString.of(Text.Serializer.toJson(it)) } ) From 8567af386668407986568228aa22e925fb35fe70 Mon Sep 17 00:00:00 2001 From: Jakob K Date: Tue, 13 Jul 2021 19:32:58 +0200 Subject: [PATCH 4/6] Add an entry point to the fabrikmc-core mod --- .../kotlin/net/axay/fabrik/core/Fabrik.kt | 28 +++++++++---------- .../src/main/resources/fabric.mod.json | 6 ++++ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/fabrikmc-core/src/main/kotlin/net/axay/fabrik/core/Fabrik.kt b/fabrikmc-core/src/main/kotlin/net/axay/fabrik/core/Fabrik.kt index 619676c7..078720ed 100644 --- a/fabrikmc-core/src/main/kotlin/net/axay/fabrik/core/Fabrik.kt +++ b/fabrikmc-core/src/main/kotlin/net/axay/fabrik/core/Fabrik.kt @@ -5,21 +5,21 @@ import net.axay.fabrik.core.task.FabrikCoroutineManager import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents import net.minecraft.server.MinecraftServer -object Fabrik { - var currentServer: MinecraftServer? = null +/** + * Do not call this function, as it is the entry point of the Fabrik + * mod itself. + */ +fun init() { + logInfo("Initializing Fabrik due to init call") - /** - * You should call this function if you intend to - * use the Fabrik API. - */ - fun init() { - logInfo("Initializing Fabrik due to init call") + ServerLifecycleEvents.SERVER_STARTING.register { + Fabrik.currentServer = it + logInfo("Reached SERVER_STARTING state") + } - ServerLifecycleEvents.SERVER_STARTING.register { - currentServer = it - logInfo("Reached SERVER_STARTING state") - } + FabrikCoroutineManager.init() +} - FabrikCoroutineManager.init() - } +object Fabrik { + var currentServer: MinecraftServer? = null } diff --git a/fabrikmc-core/src/main/resources/fabric.mod.json b/fabrikmc-core/src/main/resources/fabric.mod.json index b1f2a2c9..c03610a8 100644 --- a/fabrikmc-core/src/main/resources/fabric.mod.json +++ b/fabrikmc-core/src/main/resources/fabric.mod.json @@ -7,6 +7,12 @@ "description": "${description}", "authors": ["${author}"], + "entrypoints": { + "main": [ + "net.axay.fabrik.core.FabrikKt::init" + ] + }, + "depends": { "fabric": "*", "fabric-language-kotlin": "*", From 337f28da45b5136d9cebe8c03a1258e8c557a3e4 Mon Sep 17 00:00:00 2001 From: Jakob K Date: Tue, 13 Jul 2021 19:33:31 +0200 Subject: [PATCH 5/6] Increase development version --- buildSrc/src/main/kotlin/BuildConstants.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/BuildConstants.kt b/buildSrc/src/main/kotlin/BuildConstants.kt index ba8c190e..d0528838 100644 --- a/buildSrc/src/main/kotlin/BuildConstants.kt +++ b/buildSrc/src/main/kotlin/BuildConstants.kt @@ -1,7 +1,7 @@ import com.modrinth.minotaur.request.VersionType object BuildConstants { - const val fabrikVersion = "1.0.1-SNAPSHOT" + const val fabrikVersion = "1.1.0" val isSnapshot = fabrikVersion.endsWith("-SNAPSHOT") val projectState = if (isSnapshot) "beta" else "release" val projectStateType = if (isSnapshot) VersionType.BETA else VersionType.RELEASE From f38df4f894829387ab5617c0817abcfff25ac9e0 Mon Sep 17 00:00:00 2001 From: Jakob K Date: Thu, 15 Jul 2021 18:15:08 +0200 Subject: [PATCH 6/6] Add sideboard class --- .../axay/fabrik/core/scoreboard/Sideboard.kt | 31 ++++++++++++++++ .../kotlin/net/axay/fabrik/test/Manager.kt | 5 ++- .../fabrik/test/commands/SideboardCommand.kt | 35 +++++++++++++++++++ 3 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 fabrikmc-core/src/main/kotlin/net/axay/fabrik/core/scoreboard/Sideboard.kt create mode 100644 fabrikmc-testmod/src/main/kotlin/net/axay/fabrik/test/commands/SideboardCommand.kt diff --git a/fabrikmc-core/src/main/kotlin/net/axay/fabrik/core/scoreboard/Sideboard.kt b/fabrikmc-core/src/main/kotlin/net/axay/fabrik/core/scoreboard/Sideboard.kt new file mode 100644 index 00000000..bdff2b52 --- /dev/null +++ b/fabrikmc-core/src/main/kotlin/net/axay/fabrik/core/scoreboard/Sideboard.kt @@ -0,0 +1,31 @@ +package net.axay.fabrik.core.scoreboard + +import net.axay.fabrik.core.Fabrik +import net.minecraft.scoreboard.Scoreboard +import net.minecraft.scoreboard.ScoreboardCriterion +import net.minecraft.scoreboard.ServerScoreboard +import net.minecraft.text.Text + +class Sideboard( + name: String, + displayName: Text, + lines: List, +) { + companion object { + val sidebarId = Scoreboard.getDisplaySlotId("sidebar") + } + + private val scoreboard = ServerScoreboard(Fabrik.currentServer) + private val objective = scoreboard.addObjective(name, ScoreboardCriterion.DUMMY, displayName, ScoreboardCriterion.RenderType.INTEGER) + + init { + lines.forEachIndexed { index, line -> + val team = scoreboard.addTeam("team_$index") + team.prefix = line + scoreboard.addPlayerToTeam("§$index", team) + scoreboard.getPlayerScore("§$index", objective).score = lines.size - index + } + + scoreboard.setObjectiveSlot(sidebarId, objective) + } +} diff --git a/fabrikmc-testmod/src/main/kotlin/net/axay/fabrik/test/Manager.kt b/fabrikmc-testmod/src/main/kotlin/net/axay/fabrik/test/Manager.kt index a05eaee3..9063c015 100644 --- a/fabrikmc-testmod/src/main/kotlin/net/axay/fabrik/test/Manager.kt +++ b/fabrikmc-testmod/src/main/kotlin/net/axay/fabrik/test/Manager.kt @@ -1,12 +1,11 @@ package net.axay.fabrik.test -import net.axay.fabrik.core.Fabrik import net.axay.fabrik.test.commands.guiCommand +import net.axay.fabrik.test.commands.sideboardCommand import net.axay.fabrik.test.commands.textTestCommand fun init() { - Fabrik.init() - guiCommand textTestCommand + sideboardCommand } diff --git a/fabrikmc-testmod/src/main/kotlin/net/axay/fabrik/test/commands/SideboardCommand.kt b/fabrikmc-testmod/src/main/kotlin/net/axay/fabrik/test/commands/SideboardCommand.kt new file mode 100644 index 00000000..1e901e1d --- /dev/null +++ b/fabrikmc-testmod/src/main/kotlin/net/axay/fabrik/test/commands/SideboardCommand.kt @@ -0,0 +1,35 @@ +package net.axay.fabrik.test.commands + +import com.mojang.brigadier.arguments.StringArgumentType +import net.axay.fabrik.commands.* +import net.axay.fabrik.core.scoreboard.Sideboard +import net.axay.fabrik.core.text.literal +import net.axay.fabrik.core.text.literalText + +val sideboardCommand = command("sideboard", true) { + argument("example", StringArgumentType.string()) { + simpleSuggests { sideboardExamples.keys } + simpleExecutes { + sideboardExamples[it.getArgument("example")]?.value + } + } +} + +private val sideboardExamples = mapOf( + "simple" to lazy { + Sideboard( + "simple", + literalText("Simple Sideboard") { + color = 0x6DFF41 + }, + listOf( + "Hey wie,".literal, + "geht's?".literal, + " ".literal, + literalText("Farben gehen auch") { + color = 0x57FFF0 + } + ) + ) + } +)