From 37501761145a7392e3ca814d99eb64ab0e8038e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nelson=20Gra=C3=A7a?= Date: Sun, 22 Mar 2026 18:10:07 +0000 Subject: [PATCH 1/6] Update to Gradle 9.4.0 Switch to Kotlin DSL Start adding Stonecutter --- build.gradle.kts | 98 ++++++++++++++++++++++++ gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 0 settings.gradle | 10 --- settings.gradle.kts | 27 +++++++ stonecutter.gradle.kts | 4 + versions/1.20.1/gradle.properties | 13 ++++ versions/1.21.1/gradle.properties | 13 ++++ versions/1.21.4/gradle.properties | 13 ++++ 10 files changed, 170 insertions(+), 12 deletions(-) create mode 100644 build.gradle.kts mode change 100644 => 100755 gradlew delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts create mode 100644 stonecutter.gradle.kts create mode 100644 versions/1.20.1/gradle.properties create mode 100644 versions/1.21.1/gradle.properties create mode 100644 versions/1.21.4/gradle.properties diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..94eb24f1 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,98 @@ +import com.modrinth.minotaur.dependencies.ModDependency +plugins { + id("fabric-loom") version "1.9-SNAPSHOT" + id("maven-publish") + id("com.modrinth.minotaur") version "2.+" + id("dev.kikugie.stonecutter") +} +version = "${property("mod_version")}+${property("minecraft_version")}" +group = property("maven_group") as String +base { + archivesName.set(property("archives_base_name") as String) +} +repositories { + mavenLocal() + maven { + name = "ParchmentMC" + url = uri("https://maven.parchmentmc.org") + } + maven { url = uri("https://maven.nucleoid.xyz") } + maven { + name = "TerraformersMC" + url = uri("https://maven.terraformersmc.com/") + } + maven { + name = "Ladysnake Libs" + url = uri("https://maven.ladysnake.org/releases") + } +} +val accessWidener = rootProject.file("src/main/resources/solstice.accesswidener") +loom { + accessWidenerPath = accessWidener +} +dependencies { + minecraft("com.mojang:minecraft:${property("minecraft_version")}") + mappings(loom.layered { + officialMojangMappings() + parchment("org.parchmentmc.data:parchment-${property("minecraft_version")}:${property("parchment_mappings")}@zip") + }) + modImplementation("net.fabricmc:fabric-loader:${property("loader_version")}") + modImplementation("net.fabricmc.fabric-api:fabric-api:${property("fabric_version")}") + include(implementation("org.spongepowered:configurate-core:${property("configurate_version")}")!!) + include(implementation("org.spongepowered:configurate-hocon:${property("configurate_version")}")!!) + include(implementation("org.spongepowered:configurate-gson:${property("configurate_version")}")!!) + include("com.typesafe:config:1.4.3") + include("io.leangen.geantyref:geantyref:1.3.16") + include(modImplementation("me.lucko:fabric-permissions-api:${property("permissions_api_version")}")!!) + include(modImplementation("eu.pb4:placeholder-api:${property("placeholderapi_version")}")!!) + include(modImplementation("eu.pb4:sgui:${property("sgui_version")}")!!) + modImplementation(include("eu.pb4:common-economy-api:${property("commoneconomy_version")}")!!) + modCompileOnly("dev.emi:trinkets:${property("trinkets_version")}") + modCompileOnly("net.luckperms:api:5.4") + modRuntimeOnly("net.luckperms:api:5.4") +} +tasks.processResources { + inputs.property("version", project.version) + filesMatching("fabric.mod.json") { + expand(mapOf("version" to project.version)) + } +} +tasks.withType().configureEach { + options.release = 17 +} +java { + withSourcesJar() + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} +tasks.jar { + from(rootProject.file("LICENSE")) { + rename { "${it}_${base.archivesName.get()}" } + } +} +modrinth { + token = System.getenv("MODRINTH_TOKEN") + projectId = "uIvrDZas" + uploadFile = tasks["remapJar"] + gameVersions = listOf(property("minecraft_version") as String) + loaders = listOf("fabric") + dependencies = listOf(ModDependency("P7dR8mSH", "required")) +} +publishing { + publications { + create("mavenJava") { + artifactId = property("archives_base_name") as String + from(components["java"]) + } + } + repositories { + maven { + name = "AlexDevsRepo" + url = uri("https://maven.alexdevs.me/releases") + credentials { + username = System.getenv("MAVEN_USERNAME") + password = System.getenv("MAVEN_PASSWORD") + } + } + } +} diff --git a/gradle.properties b/gradle.properties index 786a57fc..2d7167fa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G +org.gradle.jvmargs=-Xmx3G org.gradle.parallel=true # Fabric Properties diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ca025c83..dbc3ce4a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 75c4d726..00000000 --- a/settings.gradle +++ /dev/null @@ -1,10 +0,0 @@ -pluginManagement { - repositories { - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' - } - mavenCentral() - gradlePluginPortal() - } -} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..74c2d5d7 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,27 @@ +pluginManagement { + repositories { + maven { + name = "Fabric" + url = uri("https://maven.fabricmc.net/") + } + maven { + name = "Stonecutter" + url = uri("https://maven.kikugie.dev/snapshots") + content { includeGroup("dev.kikugie") } + } + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id("dev.kikugie.stonecutter") version "0.9" +} + +stonecutter { + create(rootProject) { + versions("1.20.1", "1.21.1", "1.21.4") + vcsVersion = "1.20.1" + } +} + diff --git a/stonecutter.gradle.kts b/stonecutter.gradle.kts new file mode 100644 index 00000000..608a157e --- /dev/null +++ b/stonecutter.gradle.kts @@ -0,0 +1,4 @@ +plugins { + id("dev.kikugie.stonecutter") +} +stonecutter active "1.20.1" \ No newline at end of file diff --git a/versions/1.20.1/gradle.properties b/versions/1.20.1/gradle.properties new file mode 100644 index 00000000..bca93552 --- /dev/null +++ b/versions/1.20.1/gradle.properties @@ -0,0 +1,13 @@ +org.gradle.jvmargs=-Xmx3G + +minecraft_version=1.20.1 +loader_version=0.16.14 +parchment_mappings=2023.09.03 + +fabric_version=0.92.6+1.20.1 +permissions_api_version=0.2-SNAPSHOT +placeholderapi_version=2.1.4+1.20.1 +sgui_version=1.2.2+1.20 +commoneconomy_version=1.1.1 +trinkets_version=3.7.2 + diff --git a/versions/1.21.1/gradle.properties b/versions/1.21.1/gradle.properties new file mode 100644 index 00000000..136a67c0 --- /dev/null +++ b/versions/1.21.1/gradle.properties @@ -0,0 +1,13 @@ +org.gradle.jvmargs=-Xmx3G + +minecraft_version=1.21.1 +loader_version=0.16.14 +parchment_mappings=2024.11.17 + +fabric_version=0.116.4+1.21.1 +permissions_api_version=0.3.3 +placeholderapi_version=2.4.2+1.21 +sgui_version=1.6.1+1.21.1 +commoneconomy_version=1.1.1 +trinkets_version=3.10.0 + diff --git a/versions/1.21.4/gradle.properties b/versions/1.21.4/gradle.properties new file mode 100644 index 00000000..39afbf42 --- /dev/null +++ b/versions/1.21.4/gradle.properties @@ -0,0 +1,13 @@ +org.gradle.jvmargs=-Xmx3G + +minecraft_version=1.21.4 +loader_version=0.17.2 +parchment_mappings=2025.03.23 + +fabric_version=0.119.4+1.21.4 +permissions_api_version=0.3.3 +placeholderapi_version=2.5.2+1.21.3 +sgui_version=1.8.2+1.21.4 +commoneconomy_version=1.2.0 +trinkets_version=3.10.0 + From 119533a7b1ee9bde4201bd355a4cdf11d2fed700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nelson=20Gra=C3=A7a?= Date: Mon, 23 Mar 2026 01:23:28 +0000 Subject: [PATCH 2/6] Integrate 1.21.1 --- build.gradle.kts | 17 +++-- gradle.properties | 2 + .../java/me/alexdevs/solstice/Solstice.java | 6 +- .../alexdevs/solstice/api/ServerLocation.java | 6 +- .../api/text/tag/PhaseGradientTag.java | 12 +++- .../solstice/api/utils/PlayerUtils.java | 10 ++- .../core/coreModule/commands/PingCommand.java | 14 +++- .../mixin/events/CommandEventsMixin.java | 4 ++ .../mixin/modules/core/RealPingMixin.java | 29 ++++++-- .../OverrideNewPlayerSpawnPointMixin.java | 26 ++++--- .../spawn/OverrideSpawnPointLevelMixin.java | 51 ++++++++++++++ .../spawn/OverrideSpawnPointMixin.java | 69 +++++++++++-------- .../styling/CustomAdvancementMixin.java | 39 +++++++++-- .../CustomConnectionMessagesMixin.java | 16 ++++- .../modules/styling/CustomNameplateMixin.java | 15 ++-- .../styling/PlayerDisconnectMixin.java | 6 +- .../solstice/modules/afk/AfkModule.java | 6 +- .../ignore/commands/IgnoreCommand.java | 6 +- .../commands/InventorySeeCommand.java | 16 ++++- .../item/commands/ItemLoreCommand.java | 46 ++++++++++--- .../item/commands/ItemNameCommand.java | 16 ++++- .../modules/item/commands/RepairCommand.java | 10 ++- .../alexdevs/solstice/modules/kit/Utils.java | 29 ++++++-- .../modules/kit/commands/KitsCommand.java | 31 +++++++-- .../commands/EffectsCommand.java | 6 +- .../commands/KittyCannonCommand.java | 6 +- .../miscellaneous/commands/SpeedCommand.java | 20 +++++- .../placeholders/PlaceholdersModule.java | 18 ++++- .../modules/rtp/commands/RTPCommand.java | 13 +++- .../solstice/modules/rtp/core/Locator.java | 6 +- .../solstice/modules/rtp/data/RTPConfig.java | 6 +- .../solstice/modules/skull/SkullModule.java | 47 ++++++++++--- .../modules/smite/commands/SmiteCommand.java | 3 + .../solstice/modules/spawn/SpawnModule.java | 6 +- .../modules/styling/CustomPlayerTeam.java | 61 +++++++++++----- .../modules/styling/CustomSentMessage.java | 6 +- .../modules/styling/StylingModule.java | 62 +++++++++++++++-- .../modules/styling/data/StylingConfig.java | 18 +++-- .../formatters/AdvancementFormatter.java | 35 ++++++++-- src/main/resources/fabric.mod.json | 4 +- src/main/resources/solstice.mixins.json | 9 ++- versions/1.20.1/gradle.properties | 2 + versions/1.21.1/gradle.properties | 3 + versions/1.21.4/gradle.properties | 3 + 44 files changed, 656 insertions(+), 160 deletions(-) create mode 100644 src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointLevelMixin.java diff --git a/build.gradle.kts b/build.gradle.kts index 94eb24f1..688a16c1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,18 +52,27 @@ dependencies { modRuntimeOnly("net.luckperms:api:5.4") } tasks.processResources { + val mcConstraint = project.property("minecraft_constraint") as String + val javaVer = project.property("java_version") as String inputs.property("version", project.version) + inputs.property("minecraft_constraint", mcConstraint) + inputs.property("java_version", javaVer) filesMatching("fabric.mod.json") { - expand(mapOf("version" to project.version)) + expand(mapOf( + "version" to project.version, + "minecraft_constraint" to mcConstraint, + "java_version" to javaVer + )) } } +val javaVersion = (property("java_version") as String).toInt() tasks.withType().configureEach { - options.release = 17 + options.release = javaVersion } java { withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.toVersion(javaVersion) + targetCompatibility = JavaVersion.toVersion(javaVersion) } tasks.jar { from(rootProject.file("LICENSE")) { diff --git a/gradle.properties b/gradle.properties index 2d7167fa..9e0a1864 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,6 +6,8 @@ org.gradle.parallel=true # check these on https://fabricmc.net/develop minecraft_version=1.21.1 loader_version=0.16.14 +java_version=17 +minecraft_constraint=~1.20.1 parchment_mappings=2024.11.17 diff --git a/src/main/java/me/alexdevs/solstice/Solstice.java b/src/main/java/me/alexdevs/solstice/Solstice.java index cac3cfa8..b0255347 100644 --- a/src/main/java/me/alexdevs/solstice/Solstice.java +++ b/src/main/java/me/alexdevs/solstice/Solstice.java @@ -28,7 +28,11 @@ public class Solstice implements ModInitializer { public static final String MOD_ID = "solstice"; public static final Logger LOGGER = LoggerFactory.getLogger(Solstice.class); - public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(MOD_ID, ""); + //? if >= 1.21.1 { + /*public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(MOD_ID, "");*/ + //? } else { + public static final ResourceLocation ID = new ResourceLocation(MOD_ID, ""); + //? } public static final IConfigDataManager configManager = new ConfigDataManager(Paths.configDirectory.resolve("config.conf")); public static final LocaleManager localeManager = new LocaleManager(Paths.configDirectory.resolve("locale.json")); diff --git a/src/main/java/me/alexdevs/solstice/api/ServerLocation.java b/src/main/java/me/alexdevs/solstice/api/ServerLocation.java index a207aab3..7b8e749d 100644 --- a/src/main/java/me/alexdevs/solstice/api/ServerLocation.java +++ b/src/main/java/me/alexdevs/solstice/api/ServerLocation.java @@ -92,7 +92,11 @@ public void teleport(ServerPlayer player) { } public ResourceKey getWorldKey() { - return ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(this.getWorld())); + //? if >= 1.21.1 { + /*return ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(this.getWorld()));*/ + //? } else { + return ResourceKey.create(Registries.DIMENSION, ResourceLocation.tryParse(this.getWorld())); + //? } } public ServerLevel getWorld(MinecraftServer server) { diff --git a/src/main/java/me/alexdevs/solstice/api/text/tag/PhaseGradientTag.java b/src/main/java/me/alexdevs/solstice/api/text/tag/PhaseGradientTag.java index 813b317c..6019cdb4 100644 --- a/src/main/java/me/alexdevs/solstice/api/text/tag/PhaseGradientTag.java +++ b/src/main/java/me/alexdevs/solstice/api/text/tag/PhaseGradientTag.java @@ -47,10 +47,18 @@ public static TextParserV1.TextTag createTag() { } var parsedColor = TextColor.parseColor(arg); - if (parsedColor.isError()) { + //? if >= 1.21.1 { + /*if (parsedColor.isError()) {*/ + //? } else { + if (parsedColor == null) { + //? } textColors.add(TextColor.fromRgb(0)); } else { - textColors.add(parsedColor.getOrThrow()); + //? if >= 1.21.1 { + /*textColors.add(parsedColor.getOrThrow());*/ + //? } else { + textColors.add(parsedColor); + //? } } } diff --git a/src/main/java/me/alexdevs/solstice/api/utils/PlayerUtils.java b/src/main/java/me/alexdevs/solstice/api/utils/PlayerUtils.java index 408f3446..a0e8c806 100644 --- a/src/main/java/me/alexdevs/solstice/api/utils/PlayerUtils.java +++ b/src/main/java/me/alexdevs/solstice/api/utils/PlayerUtils.java @@ -2,7 +2,9 @@ import com.mojang.authlib.GameProfile; import me.alexdevs.solstice.Solstice; -import net.minecraft.server.level.ClientInformation; +//? if >= 1.21.1 { +/*import net.minecraft.server.level.ClientInformation;*/ +//? } import net.minecraft.server.level.ServerPlayer; import java.util.UUID; @@ -17,7 +19,11 @@ public static ServerPlayer loadOfflinePlayer(GameProfile profile) { } var playerManager = Solstice.server.getPlayerList(); - var player = playerManager.getPlayerForLogin(profile, ClientInformation.createDefault()); + //? if >= 1.21.1 { + /*var player = playerManager.getPlayerForLogin(profile, ClientInformation.createDefault());*/ + //? } else { + var player = playerManager.getPlayerForLogin(profile); + //? } playerManager.load(player); return player; } diff --git a/src/main/java/me/alexdevs/solstice/core/coreModule/commands/PingCommand.java b/src/main/java/me/alexdevs/solstice/core/coreModule/commands/PingCommand.java index 8eec6e4b..af238309 100644 --- a/src/main/java/me/alexdevs/solstice/core/coreModule/commands/PingCommand.java +++ b/src/main/java/me/alexdevs/solstice/core/coreModule/commands/PingCommand.java @@ -26,7 +26,11 @@ public LiteralArgumentBuilder command(String name) { .requires(require("ping.base", true)) .executes(context -> { var player = context.getSource().getPlayerOrException(); - var ping = player.connection.latency(); + //? if >= 1.21.1 { + /*var ping = player.connection.latency();*/ + //? } else { + var ping = player.latency; + //? } var map = Map.of( "ping", Component.nullToEmpty(String.valueOf(ping)) ); @@ -37,8 +41,12 @@ public LiteralArgumentBuilder command(String name) { .requires(require("ping.others", 1)) .executes(context -> { var player = EntityArgument.getPlayer(context, "player"); - var ping = player.connection.latency(); - var map = Map.of( + //? if >= 1.21.1 { + /*var ping = player.connection.latency();*/ + //? } else { + var ping = player.latency; + //? } + var map = Map.of( "ping", Component.nullToEmpty(String.valueOf(ping)), "player", player.getName() ); diff --git a/src/main/java/me/alexdevs/solstice/mixin/events/CommandEventsMixin.java b/src/main/java/me/alexdevs/solstice/mixin/events/CommandEventsMixin.java index cdc8a018..4935f664 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/events/CommandEventsMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/events/CommandEventsMixin.java @@ -18,6 +18,10 @@ public abstract class CommandEventsMixin { public void solstice$interceptCommands(StringReader reader, S sourceGeneric, CallbackInfoReturnable> cir) { if (sourceGeneric instanceof CommandSourceStack source) { var command = reader.getString(); + //? if < 1.21.1 { + if(command.startsWith("/")) + return; + //? } if (!CommandEvents.ALLOW_COMMAND.invoker().allowCommand(source, command)) { cir.cancel(); } diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/core/RealPingMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/core/RealPingMixin.java index d42ca265..94e057f5 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/core/RealPingMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/core/RealPingMixin.java @@ -1,20 +1,35 @@ package me.alexdevs.solstice.mixin.modules.core; - import com.llamalad7.mixinextras.sugar.Local; -import net.minecraft.server.network.ServerCommonPacketListenerImpl; +//? if >= 1.21.1 { +/*import net.minecraft.server.network.ServerCommonPacketListenerImpl;*/ +//? } else { +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerGamePacketListenerImpl; +//? } import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; +//? if >= 1.21.1 { +/*import org.spongepowered.asm.mixin.Shadow;*/ +//? } import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(ServerCommonPacketListenerImpl.class) +//? if >= 1.21.1 { +/*@Mixin(ServerCommonPacketListenerImpl.class)*/ +//? } else { +@Mixin(ServerGamePacketListenerImpl.class) +//? } public abstract class RealPingMixin { - @Shadow + //? if >= 1.21.1 { + /*@Shadow private int latency; - @Redirect(method = "handleKeepAlive", at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerCommonPacketListenerImpl;latency:I", opcode = Opcodes.PUTFIELD)) public void solstice$realPing(ServerCommonPacketListenerImpl instance, int value, @Local int i) { latency = i; + }*/ + //? } else { + @Redirect(method = "handleKeepAlive", at = @At(value = "FIELD", target = "Lnet/minecraft/server/level/ServerPlayer;latency:I", opcode = Opcodes.PUTFIELD)) + public void solstice$realPing(ServerPlayer player, int value, @Local int i) { + player.latency = i; } + //? } } diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideNewPlayerSpawnPointMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideNewPlayerSpawnPointMixin.java index 5da4ee30..cc9dce9c 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideNewPlayerSpawnPointMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideNewPlayerSpawnPointMixin.java @@ -1,8 +1,11 @@ package me.alexdevs.solstice.mixin.modules.spawn; - -import com.llamalad7.mixinextras.sugar.Local; +//? if >= 1.21.1 { +/*import com.llamalad7.mixinextras.sugar.Local;*/ +//? } import me.alexdevs.solstice.modules.ModuleProvider; -import net.minecraft.nbt.CompoundTag; +//? if >= 1.21.1 { +/*import net.minecraft.nbt.CompoundTag;*/ +//? } import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; @@ -11,12 +14,11 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.Optional; - +//? if >= 1.21.1 { +/*import java.util.Optional;*/ +//? } @Mixin(PlayerList.class) public abstract class OverrideNewPlayerSpawnPointMixin { - // Lnet/minecraft/server/MinecraftServer;getLevel(Lnet/minecraft/resources/ResourceKey;)Lnet/minecraft/server/level/ServerLevel; @Redirect( method = "placeNewPlayer", at = @At( @@ -24,8 +26,14 @@ public abstract class OverrideNewPlayerSpawnPointMixin { target = "Lnet/minecraft/server/MinecraftServer;getLevel(Lnet/minecraft/resources/ResourceKey;)Lnet/minecraft/server/level/ServerLevel;" ) ) - public ServerLevel solstice$overrideWorld(MinecraftServer server, ResourceKey dimension, @Local Optional optional) { - if (optional.isEmpty()) { + //? if >= 1.21.1 { + /*public ServerLevel solstice$overrideWorld(MinecraftServer server, ResourceKey dimension, @Local Optional optional) { + if (optional.isEmpty()) {*/ + //? } else { + public ServerLevel solstice$overrideWorld(MinecraftServer server, ResourceKey dimension) { + var level = server.getLevel(dimension); + if (level == null) { + //? } var spawn = ModuleProvider.SPAWN; var firstSpawn = spawn.getFirstSpawn(); if (firstSpawn != null) { diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointLevelMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointLevelMixin.java new file mode 100644 index 00000000..094e0d3d --- /dev/null +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointLevelMixin.java @@ -0,0 +1,51 @@ +//? if < 1.21.1 { +/*package me.alexdevs.solstice.mixin.modules.spawn; + +import me.alexdevs.solstice.modules.ModuleProvider; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.Level; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(ServerPlayer.class) +public abstract class OverrideSpawnPointLevelMixin { + + @Shadow + private BlockPos respawnPosition; + + @Inject(method = "getRespawnPosition", at = @At("RETURN"), cancellable = true) + public void solstice$overrideSpawnPos(CallbackInfoReturnable cir) { + var spawnModule = ModuleProvider.SPAWN; + var config = spawnModule.getConfig(); + + var pos = spawnModule.getGlobalSpawnPosition().getBlockPos(); + if(config.globalSpawn.onRespawnSoft && this.respawnPosition == null) { + cir.setReturnValue(pos); + } + + if (config.globalSpawn.onRespawn) { + cir.setReturnValue(pos); + } + } + + @Inject(method = "getRespawnDimension", at = @At("RETURN"), cancellable = true) + public void solstice$overrideSpawnDimension(CallbackInfoReturnable> cir) { + var spawnModule = ModuleProvider.SPAWN; + var config = spawnModule.getConfig(); + var levelKey = spawnModule.getGlobalSpawnPosition().getWorldKey(); + if(config.globalSpawn.onRespawnSoft && this.respawnPosition == null) { + cir.setReturnValue(levelKey); + } + + if (config.globalSpawn.onRespawn) { + cir.setReturnValue(levelKey); + } + } +} +*/ +//? } \ No newline at end of file diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java index 2baa295d..9b3b405d 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java @@ -1,57 +1,68 @@ package me.alexdevs.solstice.mixin.modules.spawn; - import me.alexdevs.solstice.modules.ModuleProvider; import net.minecraft.core.BlockPos; -import net.minecraft.server.MinecraftServer; +//? if >= 1.21.1 { +/*import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.portal.DimensionTransition; import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Shadow;*/ +//? } else { +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.phys.Vec3; +//? } import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(ServerPlayer.class) +//? if < 1.21.1 { +import java.util.Optional; +//? } +//? if >= 1.21.1 { +/*@Mixin(ServerPlayer.class)*/ +//? } else { +@Mixin(Player.class) +//? } public abstract class OverrideSpawnPointMixin { - @Shadow - @Final - public MinecraftServer server; - - @Shadow - private BlockPos respawnPosition; - + //? if >= 1.21.1 { + /*@Shadow @Final public MinecraftServer server; + @Shadow private BlockPos respawnPosition; @Inject(method = "findRespawnPositionAndUseSpawnBlock", at = @At("RETURN"), cancellable = true) public void solstice$overrideRespawnTarget(boolean keepInventory, DimensionTransition.PostDimensionTransition postDimensionTransition, CallbackInfoReturnable cir) { var spawnModule = ModuleProvider.SPAWN; var config = spawnModule.getConfig(); - var spawn = spawnModule.getGlobalSpawnPosition(); var world = spawn.getWorld(this.server); - var pos = new Vec3( - spawn.getX(), - spawn.getY(), - spawn.getZ() - ); - + var pos = new Vec3(spawn.getX(), spawn.getY(), spawn.getZ()); var transition = new DimensionTransition( - world, - pos, - Vec3.ZERO, - spawn.getYaw(), - spawn.getPitch(), - false, - DimensionTransition.DO_NOTHING + world, pos, Vec3.ZERO, + spawn.getYaw(), spawn.getPitch(), + false, DimensionTransition.DO_NOTHING ); - if (config.globalSpawn.onRespawn) { cir.setReturnValue(transition); return; } - - if(config.globalSpawn.onRespawnSoft && respawnPosition == null) { + if (config.globalSpawn.onRespawnSoft && respawnPosition == null) { cir.setReturnValue(transition); } + }*/ + //? } else { + @Inject(method = "findRespawnPositionAndUseSpawnBlock", at = @At("RETURN"), cancellable = true) + private static void solstice$overrideSpawnPos(ServerLevel level, BlockPos pos, float angle, boolean forced, boolean alive, CallbackInfoReturnable> cir) { + var spawnModule = ModuleProvider.SPAWN; + var config = spawnModule.getConfig(); + var spawn = spawnModule.getGlobalSpawnPosition(); + if (config.globalSpawn.onRespawnSoft && pos == null) { + pos = spawn.getBlockPos(); + cir.setReturnValue(Optional.of(pos.getCenter())); + } + if (config.globalSpawn.onRespawn) { + pos = spawn.getBlockPos(); + cir.setReturnValue(Optional.of(pos.getCenter())); + } } + //? } } diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomAdvancementMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomAdvancementMixin.java index ac7eba7b..32b2d763 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomAdvancementMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomAdvancementMixin.java @@ -1,20 +1,47 @@ package me.alexdevs.solstice.mixin.modules.styling; - import me.alexdevs.solstice.modules.styling.formatters.AdvancementFormatter; -import net.minecraft.advancements.AdvancementHolder; +//? if >= 1.21.1 { +/*import net.minecraft.advancements.AdvancementHolder; import net.minecraft.advancements.AdvancementType; import net.minecraft.network.chat.MutableComponent; +import net.minecraft.server.level.ServerPlayer;*/ +//? } else { +import net.minecraft.advancements.Advancement; +import net.minecraft.network.chat.Component; +import net.minecraft.server.PlayerAdvancements; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.players.PlayerList; +//? } import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +//? if < 1.21.1 { +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +//? } import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(AdvancementType.class) +//? if >= 1.21.1 { +/*@Mixin(AdvancementType.class)*/ +//? } else { +@Mixin(PlayerAdvancements.class) +//? } public abstract class CustomAdvancementMixin { - - @Inject(method = "createAnnouncement", at = @At("HEAD"), cancellable = true) + //? if >= 1.21.1 { + /*@Inject(method = "createAnnouncement", at = @At("HEAD"), cancellable = true) public void solstice$getCustomAnnouncement(AdvancementHolder advancement, ServerPlayer player, CallbackInfoReturnable cir) { cir.setReturnValue(AdvancementFormatter.getText(player, advancement, (AdvancementType) (Object) this).copy()); + }*/ + //? } else { + @Shadow private ServerPlayer player; + @Final @Shadow private PlayerList playerList; + @Inject(method = "award", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V"), locals = LocalCapture.CAPTURE_FAILSOFT) + public void broadcastAdvancementMessage(Advancement advancement, String criterionKey, CallbackInfoReturnable cir) { + this.playerList.broadcastSystemMessage(AdvancementFormatter.getText(this.player, advancement), false); } + @Redirect(method = "award", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V")) + public void broadcastSystemMessageRedirect(PlayerList instance, Component message, boolean bypassHiddenChat) { + } + //? } } diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomConnectionMessagesMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomConnectionMessagesMixin.java index 30009e99..56265fe5 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomConnectionMessagesMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomConnectionMessagesMixin.java @@ -6,7 +6,9 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.contents.TranslatableContents; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.server.network.CommonListenerCookie; +//? if >= 1.21.1 { +/*import net.minecraft.server.network.CommonListenerCookie;*/ +//? } import net.minecraft.server.players.PlayerList; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -21,12 +23,20 @@ public abstract class CustomConnectionMessagesMixin { private ServerPlayer solstice$player = null; @Inject(method = "placeNewPlayer", at = @At("HEAD")) - private void solstice$onJoin(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) { + //? if >= 1.21.1 { + /*private void solstice$onJoin(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) {*/ + //? } else { + private void solstice$onJoin(Connection connection, ServerPlayer player, CallbackInfo ci) { + //? } solstice$player = player; } @Inject(method = "placeNewPlayer", at = @At("RETURN")) - private void solstice$onJoinReturn(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) { + //? if >= 1.21.1 { + /*private void solstice$onJoinReturn(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) {*/ + //? } else { + private void solstice$onJoinReturn(Connection connection, ServerPlayer player, CallbackInfo ci) { + //? } solstice$player = null; } diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java index 727c3605..d6ab0aec 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java @@ -1,7 +1,10 @@ package me.alexdevs.solstice.mixin.modules.styling; -import me.alexdevs.solstice.modules.styling.CustomPlayerTeam; -import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket; +import me.alexdevs.solstice.modules.ModuleProvider; +//? if >= 1.21.1 { +/*import me.alexdevs.solstice.modules.styling.CustomPlayerTeam; +import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;*/ +//? } import net.minecraft.server.ServerScoreboard; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.players.PlayerList; @@ -23,10 +26,14 @@ public abstract class CustomNameplateMixin { @Inject(method = "updateEntireScoreboard", at = @At("HEAD")) private void solstice$overrideNameplate(ServerScoreboard scoreboard, ServerPlayer player, CallbackInfo ci) { - for (var otherPlayer : players) { + //? if >= 1.21.1 { + /*for (var otherPlayer : players) { var team = new CustomPlayerTeam(scoreboard, otherPlayer); player.connection.send(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true)); - } + }*/ + //? } else { + ModuleProvider.STYLING.sendTeamSetup(player, players, scoreboard, true); + //? } } } diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/PlayerDisconnectMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/PlayerDisconnectMixin.java index 23ff88b5..b81802f9 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/PlayerDisconnectMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/PlayerDisconnectMixin.java @@ -16,7 +16,11 @@ public abstract class PlayerDisconnectMixin { @Shadow public ServerPlayer player; - @Redirect(method = "removePlayerFromWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V")) + //? if >= 1.21.1 { + /*@Redirect(method = "removePlayerFromWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V"))*/ + //? } else { + @Redirect(method = "onDisconnect", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V")) + //? } private void solstice$sendLeaveMessage(PlayerList playerList, Component message, boolean bypassHiddenChat) { var formattedMessage = ConnectionActivityFormatter.onLeave(this.player); ModuleProvider.STYLING.broadcastActivity(playerList, formattedMessage, bypassHiddenChat); diff --git a/src/main/java/me/alexdevs/solstice/modules/afk/AfkModule.java b/src/main/java/me/alexdevs/solstice/modules/afk/AfkModule.java index 08f2dacf..c02dc83b 100644 --- a/src/main/java/me/alexdevs/solstice/modules/afk/AfkModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/afk/AfkModule.java @@ -66,7 +66,11 @@ public void init() { this.commands.add(new AfkCommand(this)); this.commands.add(new ActiveTimeCommand(this)); - Placeholders.register(ResourceLocation.fromNamespaceAndPath(Solstice.MOD_ID, "afk"), (context, arg) -> { + //? if >= 1.21.1 { + /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(Solstice.MOD_ID, "afk"), (context, arg) -> {*/ + //? } else { + Placeholders.register(new ResourceLocation(Solstice.MOD_ID, "afk"), (context, arg) -> { + //? } if (!context.hasPlayer()) return PlaceholderResult.invalid("No player!"); diff --git a/src/main/java/me/alexdevs/solstice/modules/ignore/commands/IgnoreCommand.java b/src/main/java/me/alexdevs/solstice/modules/ignore/commands/IgnoreCommand.java index 1eb003c1..7fdc6291 100644 --- a/src/main/java/me/alexdevs/solstice/modules/ignore/commands/IgnoreCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/ignore/commands/IgnoreCommand.java @@ -41,7 +41,11 @@ public LiteralArgumentBuilder command(String name) { var targetName = StringArgumentType.getString(context, "target"); - context.getSource().getServer().getProfileCache().getAsync(targetName).thenAcceptAsync(profileOpt -> { + //? if >= 1.21.1 { + /*context.getSource().getServer().getProfileCache().getAsync(targetName).thenAcceptAsync(profileOpt -> {*/ + //? } else { + context.getSource().getServer().getProfileCache().getAsync(targetName, profileOpt -> { + //? } var playerContext = PlaceholderContext.of(player); if (profileOpt.isEmpty()) { diff --git a/src/main/java/me/alexdevs/solstice/modules/inventorySee/commands/InventorySeeCommand.java b/src/main/java/me/alexdevs/solstice/modules/inventorySee/commands/InventorySeeCommand.java index 9c8010b2..abb1a46f 100644 --- a/src/main/java/me/alexdevs/solstice/modules/inventorySee/commands/InventorySeeCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/inventorySee/commands/InventorySeeCommand.java @@ -12,7 +12,9 @@ import me.alexdevs.solstice.modules.inventorySee.InventorySeeModule; import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.commands.CommandSourceStack; -import net.minecraft.core.component.DataComponents; +//? if >= 1.21.1 { +/*import net.minecraft.core.component.DataComponents;*/ +//? } import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.inventory.ChestMenu; @@ -106,7 +108,11 @@ public void onClose() { } var barrier = new ItemStack(Items.BLACK_STAINED_GLASS_PANE); - barrier.set(DataComponents.CUSTOM_NAME, Component.literal("")); + //? if >= 1.21.1 { + /*barrier.set(DataComponents.CUSTOM_NAME, Component.literal(""));*/ + //? } else { + barrier.setHoverName(Component.literal("")); + //? } for (var i = targetInventory.getContainerSize(); i < container.getSize(); i++) { container.setSlot(i, barrier); } @@ -196,7 +202,11 @@ public void onClose() { } var barrier = new ItemStack(Items.BLACK_STAINED_GLASS_PANE); - barrier.set(DataComponents.CUSTOM_NAME, Component.literal("")); + //? if >= 1.21.1 { + /*barrier.set(DataComponents.CUSTOM_NAME, Component.literal(""));*/ + //? } else { + barrier.setHoverName(Component.literal("")); + //? } for (var i = size; i < container.getSize(); i++) { container.setSlot(i, barrier); } diff --git a/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemLoreCommand.java b/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemLoreCommand.java index f7a9a998..285c3f0f 100644 --- a/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemLoreCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemLoreCommand.java @@ -8,11 +8,22 @@ import me.alexdevs.solstice.modules.item.ItemModule; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; -import net.minecraft.core.component.DataComponents; +//? if >= 1.21.1 { +/*import net.minecraft.core.component.DataComponents;*/ +//? } +//? if < 1.21.1 { +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.StringTag; +//? } import net.minecraft.network.chat.Component; -import net.minecraft.world.item.component.ItemLore; +//? if >= 1.21.1 { +/*import net.minecraft.world.item.component.ItemLore;*/ +//? } -import java.util.ArrayList; +//? if >= 1.21.1 { +/*import java.util.ArrayList;*/ +//? } import java.util.List; public class ItemLoreCommand extends ModCommand { @@ -38,7 +49,17 @@ public LiteralArgumentBuilder command(String name) { return 0; } - item.remove(DataComponents.LORE); + //? if >= 1.21.1 { + /*item.remove(DataComponents.LORE);*/ + //? } else { + CompoundTag nbtCompound = item.getTagElement("display"); + if (nbtCompound != null) { + nbtCompound.remove("Lore"); + if (nbtCompound.isEmpty()) { + item.removeTagKey("display"); + } + } + //? } context.getSource().sendSuccess(() -> module.locale().get("loreCleared"), false); @@ -56,12 +77,21 @@ public LiteralArgumentBuilder command(String name) { } var playerContext = PlaceholderContext.of(player); - var list = new ArrayList(); - for(var line : itemLore.split("\\\\n")) { + //? if >= 1.21.1 { + /*var list = new ArrayList(); + for (var line : itemLore.split("\\\\n")) { list.add(Format.parse(line, playerContext)); } - - item.set(DataComponents.LORE, new ItemLore(list)); + item.set(DataComponents.LORE, new ItemLore(list));*/ + //? } else { + var list = new ListTag(); + for (var line : itemLore.split("\\\\n")) { + var text = Format.parse(line, playerContext); + list.add(StringTag.valueOf(Component.Serializer.toJson(text))); + } + var displayNbt = item.getOrCreateTagElement("display"); + displayNbt.put("Lore", list); + //? } context.getSource().sendSuccess(() -> module.locale().get("loreSet"), false); diff --git a/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemNameCommand.java b/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemNameCommand.java index 1ffaed3f..5441730f 100644 --- a/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemNameCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemNameCommand.java @@ -8,7 +8,9 @@ import me.alexdevs.solstice.modules.item.ItemModule; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; -import net.minecraft.core.component.DataComponents; +//? if >= 1.21.1 { +/*import net.minecraft.core.component.DataComponents;*/ +//? } import java.util.List; @@ -35,7 +37,11 @@ public LiteralArgumentBuilder command(String name) { return 0; } - item.remove(DataComponents.CUSTOM_NAME); + //? if >= 1.21.1 { + /*item.remove(DataComponents.CUSTOM_NAME);*/ + //? } else { + item.resetHoverName(); + //? } context.getSource().sendSuccess(() -> module.locale().get("nameCleared"), false); @@ -53,7 +59,11 @@ public LiteralArgumentBuilder command(String name) { } var playerContext = PlaceholderContext.of(player); - item.set(DataComponents.CUSTOM_NAME, Format.parse(itemName, playerContext)); + //? if >= 1.21.1 { + /*item.set(DataComponents.CUSTOM_NAME, Format.parse(itemName, playerContext));*/ + //? } else { + item.setHoverName(Format.parse(itemName, playerContext)); + //? } context.getSource().sendSuccess(() -> module.locale().get("nameSet"), false); diff --git a/src/main/java/me/alexdevs/solstice/modules/item/commands/RepairCommand.java b/src/main/java/me/alexdevs/solstice/modules/item/commands/RepairCommand.java index 477d663a..50073d9f 100644 --- a/src/main/java/me/alexdevs/solstice/modules/item/commands/RepairCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/item/commands/RepairCommand.java @@ -4,7 +4,9 @@ import me.alexdevs.solstice.api.module.ModCommand; import me.alexdevs.solstice.modules.item.ItemModule; import net.minecraft.commands.CommandSourceStack; -import net.minecraft.core.component.DataComponents; +//? if >= 1.21.1 { +/*import net.minecraft.core.component.DataComponents;*/ +//? } import java.util.List; @@ -42,7 +44,11 @@ public LiteralArgumentBuilder command(String name) { if(item.isDamaged()) { // Removes the NBT tag altogether instead of just setting it to 0 - item.remove(DataComponents.DAMAGE); + //? if >= 1.21.1 { + /*item.remove(DataComponents.DAMAGE);*/ + //? } else { + item.removeTagKey("Damage"); + //? } context.getSource().sendSuccess(() -> module.locale().get("repaired"), false); return 1; } else { diff --git a/src/main/java/me/alexdevs/solstice/modules/kit/Utils.java b/src/main/java/me/alexdevs/solstice/modules/kit/Utils.java index a582275c..dde31b66 100644 --- a/src/main/java/me/alexdevs/solstice/modules/kit/Utils.java +++ b/src/main/java/me/alexdevs/solstice/modules/kit/Utils.java @@ -2,7 +2,12 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import eu.pb4.sgui.api.gui.SimpleGui; -import me.alexdevs.solstice.Solstice; +//? if < 1.21.1 { +import net.minecraft.nbt.CompoundTag; +//? } +//? if >= 1.21.1 { +/*import me.alexdevs.solstice.Solstice;*/ +//? } import net.minecraft.nbt.TagParser; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; @@ -12,15 +17,25 @@ public class Utils { public static String serializeItemStack(ItemStack itemStack) { - var registry = Solstice.server.registryAccess(); - var nbt = itemStack.save(registry); + //? if >= 1.21.1 { + /*var registry = Solstice.server.registryAccess(); + var nbt = itemStack.save(registry);*/ + //? } else { + var nbt = new CompoundTag(); + itemStack.save(nbt); + //? } return nbt.getAsString(); } public static ItemStack deserializeItemStack(String string) throws CommandSyntaxException { - var registry = Solstice.server.registryAccess(); + //? if >= 1.21.1 { + /*var registry = Solstice.server.registryAccess(); var nbt = TagParser.parseTag(string); - return ItemStack.parseOptional(registry, nbt); + return ItemStack.parseOptional(registry, nbt);*/ + //? } else { + var nbt = TagParser.parseTag(string); + return ItemStack.of(nbt); + //? } } public static KitInventory createInventory(List items) { @@ -35,7 +50,7 @@ public static List getItemStacks(KitInventory inventory) { var items = new ArrayList(); for (var i = 0; i < inventory.getContainerSize(); i++) { var stack = inventory.getItem(i); - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { items.add(stack); } } @@ -43,7 +58,7 @@ public static List getItemStacks(KitInventory inventory) { } public static void redirect(SimpleGui container, KitInventory inventory) { - for(var i = 0; i < container.getSize(); i++) { + for (var i = 0; i < container.getSize(); i++) { container.setSlotRedirect(i, new Slot(inventory, i, 0, 0)); } } diff --git a/src/main/java/me/alexdevs/solstice/modules/kit/commands/KitsCommand.java b/src/main/java/me/alexdevs/solstice/modules/kit/commands/KitsCommand.java index 6ec655f2..0e7d6ab3 100644 --- a/src/main/java/me/alexdevs/solstice/modules/kit/commands/KitsCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/kit/commands/KitsCommand.java @@ -9,16 +9,23 @@ import me.alexdevs.solstice.modules.kit.KitModule; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; -import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; import net.minecraft.world.inventory.ChestMenu; import net.minecraft.world.inventory.MenuType; -import net.minecraft.world.item.component.ItemLore; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +//? if >= 1.21.1 { +/*import net.minecraft.core.component.DataComponents; +import net.minecraft.world.item.component.ItemLore;*/ +//? } +//? if < 1.21.1 { +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.StringTag; +//? } + public class KitsCommand extends ModCommand { public KitsCommand(KitModule module) { super(module); @@ -92,16 +99,26 @@ private void refreshGui(CommandContext context, SimpleGui gu if (canClaim) { kitNameComponent = Component.nullToEmpty(kitName); kitLoreComponent = module.locale().get("claimKit", placeholders); - icon.set(DataComponents.ENCHANTMENT_GLINT_OVERRIDE, true); + //? if >= 1.21.1 { + /*icon.set(DataComponents.ENCHANTMENT_GLINT_OVERRIDE, true);*/ + //? } else { + icon.getOrCreateTag().put("Enchantments", new ListTag()); + //? } } else { - kitNameComponent = module.locale().get("kitsUnavailableName", placeholders); kitLoreComponent = module.locale().get("kitsUnavailableLore", placeholders); } - icon.set(DataComponents.CUSTOM_NAME, kitNameComponent); - icon.set(DataComponents.LORE, new ItemLore(List.of(kitLoreComponent))); - + //? if >= 1.21.1 { + /*icon.set(DataComponents.CUSTOM_NAME, kitNameComponent); + icon.set(DataComponents.LORE, new ItemLore(List.of(kitLoreComponent)));*/ + //? } else { + icon.setHoverName(kitNameComponent); + var displayNbt = icon.getOrCreateTagElement("display"); + var list = new ListTag(); + list.add(StringTag.valueOf(Component.Serializer.toJson(kitLoreComponent))); + displayNbt.put("Lore", list); + //? } gui.setSlot(i, new GuiElement(icon, (syncId, clickType, slotActionType) -> { try { dispatcher.execute("kit claim " + kitName, context.getSource()); diff --git a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/EffectsCommand.java b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/EffectsCommand.java index 06b907ac..b9ad08c5 100644 --- a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/EffectsCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/EffectsCommand.java @@ -59,7 +59,11 @@ private int execute(CommandContext context, ServerPlayer tar } var map = Map.of( - "effect", Component.translatable(effect.value().getDescriptionId()), + //? if >= 1.21.1 { + /*"effect", Component.translatable(effect.value().getDescriptionId()),*/ + //? } else { + "effect", Component.translatable(effect.getDescriptionId()), + //? } "amplifier", Component.nullToEmpty(String.valueOf(instance.getAmplifier())), "duration", Component.nullToEmpty(duration) ); diff --git a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/KittyCannonCommand.java b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/KittyCannonCommand.java index 28587bc7..ab90d94c 100644 --- a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/KittyCannonCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/KittyCannonCommand.java @@ -35,7 +35,11 @@ public LiteralArgumentBuilder command(String name) { final var world = player.serverLevel(); - BALL.create(world, entity -> { + //? if >= 1.21.1 { + /*BALL.create(world, entity -> {*/ + //? } else { + BALL.create(world, null, entity -> { + //? } entity.setDeltaMovement(player.getLookAngle().scale(3.5)); entity.setPos(player.getEyePosition().add(player.getLookAngle())); world.addFreshEntity(entity); diff --git a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/SpeedCommand.java b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/SpeedCommand.java index c2cc0bc5..5305c24e 100644 --- a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/SpeedCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/SpeedCommand.java @@ -72,13 +72,27 @@ private int setWalkingSpeed(CommandContext context, float sp var map = Map.of( "speed", Component.nullToEmpty(String.valueOf(speedMultiplier)) ); + if (speedMultiplier == 1) { - instance.removeModifier(id); + //? if >= 1.21.1 { + /*instance.removeModifier(id);*/ + //? } else { + var res = instance.getModifiers().stream().filter(x -> x.getName().equals(id.toString())).findFirst(); + res.ifPresent(instance::removeModifier); + //? } context.getSource().sendSuccess(() -> module.locale().get("walkSpeedReset", map), true); } else { - var modifier = new AttributeModifier(id, speedMultiplier, AttributeModifier.Operation.ADD_MULTIPLIED_BASE); - instance.addOrUpdateTransientModifier(modifier); + //? if >= 1.21.1 { + /*var modifier = new AttributeModifier(id, speedMultiplier, AttributeModifier.Operation.ADD_MULTIPLIED_BASE); + instance.addOrUpdateTransientModifier(modifier);*/ + //? } else { + var res = instance.getModifiers().stream().filter(x -> x.getName().equals(id.toString())).findFirst(); + res.ifPresent(instance::removeModifier); + + var modifier = new AttributeModifier(id.toString(), speedMultiplier, AttributeModifier.Operation.MULTIPLY_TOTAL); + instance.addTransientModifier(modifier); + //? } context.getSource().sendSuccess(() -> module.locale().get("walkSpeedSet", map), true); } diff --git a/src/main/java/me/alexdevs/solstice/modules/placeholders/PlaceholdersModule.java b/src/main/java/me/alexdevs/solstice/modules/placeholders/PlaceholdersModule.java index 9c8e9129..842e3dab 100644 --- a/src/main/java/me/alexdevs/solstice/modules/placeholders/PlaceholdersModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/placeholders/PlaceholdersModule.java @@ -15,7 +15,11 @@ public PlaceholdersModule(ResourceLocation id) { @Override public void init() { - Placeholders.register(ResourceLocation.fromNamespaceAndPath(ENTITY, "name"), (context, str) -> { + //? if >= 1.21.1 { + /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(ENTITY, "name"), (context, str) -> {*/ + //? } else { + Placeholders.register(new ResourceLocation(ENTITY, "name"), (context, str) -> { + //? } if (!context.hasEntity()) { return PlaceholderResult.invalid("No entity!"); } @@ -23,7 +27,11 @@ public void init() { return PlaceholderResult.value(entity.getName()); }); - Placeholders.register(ResourceLocation.fromNamespaceAndPath(ENTITY, "displayname"), (context, str) -> { + //? if >= 1.21.1 { + /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(ENTITY, "displayname"), (context, str) -> {*/ + //? } else { + Placeholders.register(new ResourceLocation(ENTITY, "displayname"), (context, str) -> { + //? } if (!context.hasEntity()) { return PlaceholderResult.invalid("No entity!"); } @@ -31,7 +39,11 @@ public void init() { return PlaceholderResult.value(entity.getDisplayName()); }); - Placeholders.register(ResourceLocation.fromNamespaceAndPath(ENTITY, "uuid"), (context, str) -> { + //? if >= 1.21.1 { + /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(ENTITY, "uuid"), (context, str) -> {*/ + //? } else { + Placeholders.register(new ResourceLocation(ENTITY, "uuid"), (context, str) -> { + //? } if (!context.hasEntity()) { return PlaceholderResult.invalid("No entity!"); } diff --git a/src/main/java/me/alexdevs/solstice/modules/rtp/commands/RTPCommand.java b/src/main/java/me/alexdevs/solstice/modules/rtp/commands/RTPCommand.java index a8c1cdfc..c04e6461 100644 --- a/src/main/java/me/alexdevs/solstice/modules/rtp/commands/RTPCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/rtp/commands/RTPCommand.java @@ -5,7 +5,9 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import me.alexdevs.solstice.Solstice; import me.alexdevs.solstice.api.module.ModCommand; -import me.alexdevs.solstice.api.utils.RegistryUtils; +//? if >= 1.21.1 { +/*import me.alexdevs.solstice.api.utils.RegistryUtils;*/ +//? } import me.alexdevs.solstice.modules.rtp.RTPModule; import me.alexdevs.solstice.modules.rtp.core.Locator; import me.lucko.fabric.api.permissions.v0.Permissions; @@ -44,8 +46,13 @@ public LiteralArgumentBuilder command(String name) { .requires(require("biome.base", 2)) .suggests((context, builder) -> { if (Permissions.check(context.getSource(), getPermissionNode("exempt.biome"), 2)) { - var biomeRegistry = this.commandRegistry.lookup(Registries.BIOME); - var biomes = RegistryUtils.getBiomes(biomeRegistry.get(), false); + //? if >= 1.21.1 { + /*var biomeRegistry = this.commandRegistry.lookup(Registries.BIOME); + var biomes = RegistryUtils.getBiomes(biomeRegistry.get(), false);*/ + //? } else { + var biomeRegistry = this.commandRegistry.holderLookup(Registries.BIOME); + var biomes = biomeRegistry.listElements().map(r -> r.unwrapKey().get().location().toString()).toList(); + //? } return SharedSuggestionProvider.suggest(biomes, builder); } diff --git a/src/main/java/me/alexdevs/solstice/modules/rtp/core/Locator.java b/src/main/java/me/alexdevs/solstice/modules/rtp/core/Locator.java index 87d1845d..79a77371 100644 --- a/src/main/java/me/alexdevs/solstice/modules/rtp/core/Locator.java +++ b/src/main/java/me/alexdevs/solstice/modules/rtp/core/Locator.java @@ -175,7 +175,11 @@ private Optional getChunk(ChunkPos pos) { if (holder == null) { return Optional.empty(); } else { - var chunk = holder.getFullChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).orElse(null); + //? if >= 1.21.1 { + /*var chunk = holder.getFullChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).orElse(null);*/ + //? } else { + var chunk = holder.getFullChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).left().orElse(null); + //? } if (chunk == null) { return Optional.empty(); } diff --git a/src/main/java/me/alexdevs/solstice/modules/rtp/data/RTPConfig.java b/src/main/java/me/alexdevs/solstice/modules/rtp/data/RTPConfig.java index 55d79853..f450676b 100644 --- a/src/main/java/me/alexdevs/solstice/modules/rtp/data/RTPConfig.java +++ b/src/main/java/me/alexdevs/solstice/modules/rtp/data/RTPConfig.java @@ -67,6 +67,10 @@ public class RTPConfig { ); public List> parseBiomes() { - return prohibitedBiomes.stream().map(biomeId -> ResourceKey.create(Registries.BIOME, ResourceLocation.parse(biomeId))).toList(); + //? if >= 1.21.1 { + /*return prohibitedBiomes.stream().map(biomeId -> ResourceKey.create(Registries.BIOME, ResourceLocation.parse(biomeId))).toList();*/ + //? } else { + return prohibitedBiomes.stream().map(biomeId -> ResourceKey.create(Registries.BIOME, ResourceLocation.tryParse(biomeId))).toList(); + //? } } } diff --git a/src/main/java/me/alexdevs/solstice/modules/skull/SkullModule.java b/src/main/java/me/alexdevs/solstice/modules/skull/SkullModule.java index 206cb713..226742df 100644 --- a/src/main/java/me/alexdevs/solstice/modules/skull/SkullModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/skull/SkullModule.java @@ -1,19 +1,34 @@ package me.alexdevs.solstice.modules.skull; import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.PropertyMap; +//? if >= 1.21.1 { +/*import com.mojang.authlib.properties.PropertyMap;*/ +//? } import me.alexdevs.solstice.api.module.ModuleBase; import me.alexdevs.solstice.modules.skull.commands.SkullCommand; -import net.minecraft.core.component.DataComponents; +//? if >= 1.21.1 { +/*import net.minecraft.core.component.DataComponents;*/ +//? } +//? if < 1.21.1 { +import net.minecraft.nbt.StringTag; +//? } import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.component.ResolvableProfile; +//? if < 1.21.1 { +import net.minecraft.world.item.PlayerHeadItem; +//? } +//? if >= 1.21.1 { +/*import net.minecraft.world.item.component.ResolvableProfile;*/ +//? } -import java.util.Optional; +//? if >= 1.21.1 { +/*import java.util.Optional;*/ +//? } import java.util.UUID; + public class SkullModule extends ModuleBase.Toggleable { - + public SkullModule(ResourceLocation id) { super(id); @@ -27,19 +42,31 @@ public void init() { public ItemStack createSkull(String name) { var skull = Items.PLAYER_HEAD.getDefaultInstance(); name = name.substring(0, Math.min(name.length(), 16)); - skull.set(DataComponents.PROFILE, new ResolvableProfile(Optional.of(name), Optional.empty(), new PropertyMap())); + //? if >= 1.21.1 { + /*skull.set(DataComponents.PROFILE, new ResolvableProfile(Optional.of(name), Optional.empty(), new PropertyMap()));*/ + //? } else { + skull.addTagElement(PlayerHeadItem.TAG_SKULL_OWNER, StringTag.valueOf(name)); + //? } return skull; } public ItemStack createSkull(UUID uuid) { - var skull = Items.PLAYER_HEAD.getDefaultInstance(); + //? if >= 1.21.1 { + /*var skull = Items.PLAYER_HEAD.getDefaultInstance(); skull.set(DataComponents.PROFILE, new ResolvableProfile(Optional.empty(), Optional.of(uuid), new PropertyMap())); - return skull; + return skull;*/ + //? } else { + return createSkull(uuid.toString()); // :shrug: + //? } } public ItemStack createSkull(GameProfile profile) { - var skull = Items.PLAYER_HEAD.getDefaultInstance(); + //? if >= 1.21.1 { + /*var skull = Items.PLAYER_HEAD.getDefaultInstance(); skull.set(DataComponents.PROFILE, new ResolvableProfile(profile)); - return skull; + return skull;*/ + //? } else { + return createSkull(profile.getName()); + //? } } } diff --git a/src/main/java/me/alexdevs/solstice/modules/smite/commands/SmiteCommand.java b/src/main/java/me/alexdevs/solstice/modules/smite/commands/SmiteCommand.java index 8579427f..68b0e8f3 100644 --- a/src/main/java/me/alexdevs/solstice/modules/smite/commands/SmiteCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/smite/commands/SmiteCommand.java @@ -83,6 +83,9 @@ private int execute(CommandContext context, int times) throw private void summon(ServerLevel world, BlockPos pos) { entityType.create( world, + //? if < 1.21.1 { + null, + //? } world::addFreshEntity, pos, MobSpawnType.COMMAND, diff --git a/src/main/java/me/alexdevs/solstice/modules/spawn/SpawnModule.java b/src/main/java/me/alexdevs/solstice/modules/spawn/SpawnModule.java index ae469af0..7032a422 100644 --- a/src/main/java/me/alexdevs/solstice/modules/spawn/SpawnModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/spawn/SpawnModule.java @@ -88,7 +88,11 @@ public ServerLocation getSpawn() { public ServerLevel getGlobalSpawnWorld() { var targetWorld = getConfig().globalSpawn.targetSpawnWorld; - var key = ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(targetWorld)); + //? if >= 1.21.1 { + /*var key = ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(targetWorld));*/ + //? } else { + var key = ResourceKey.create(Registries.DIMENSION, ResourceLocation.tryParse(targetWorld)); + //? } return Solstice.server.getLevel(key); } diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java b/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java index ee84bb29..fa8c00eb 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java @@ -1,5 +1,5 @@ -package me.alexdevs.solstice.modules.styling; - +//? if >= 1.21.1 { +/*package me.alexdevs.solstice.modules.styling; import me.alexdevs.solstice.modules.ModuleProvider; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; @@ -7,55 +7,84 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.scores.PlayerTeam; import net.minecraft.world.scores.Scoreboard; - import java.util.Collection; import java.util.List; import java.util.Map; import java.util.stream.Collectors; - public class CustomPlayerTeam extends PlayerTeam { private final static Map COLOR_MAP = TextColor.NAMED_COLORS.entrySet().stream().collect(Collectors.toUnmodifiableMap(Map.Entry::getValue, entry -> textColorToFormatting(entry.getKey()))); - private static ChatFormatting textColorToFormatting(String name) { var value = ChatFormatting.getByName(name); if (value == null) return ChatFormatting.WHITE; return value; } - private static ChatFormatting getFormatting(TextColor color) { return COLOR_MAP.getOrDefault(color, ChatFormatting.WHITE); } - private final ServerPlayer player; - public CustomPlayerTeam(Scoreboard scoreboard, ServerPlayer player) { - super(scoreboard, "sol_" + player.getGameProfile().getName()); + super(scoreboard, player.getGameProfile().getName()); this.player = player; - super.getPlayers().add(player.getGameProfile().getName()); } - - @Override public ChatFormatting getColor() { - if(ModuleProvider.STYLING.shouldColorNameplate()) { + if (ModuleProvider.STYLING.shouldColorNameplate()) { return getFormatting(player.getDisplayName().getStyle().getColor()); } return super.getColor(); } - @Override public Component getPlayerPrefix() { return ModuleProvider.STYLING.getNameplatePrefix(player); } - @Override public Component getPlayerSuffix() { return ModuleProvider.STYLING.getNameplateSuffix(player); } - + @Override + public Collection getPlayers() { + return List.of(player.getGameProfile().getName()); + } +}*/ +//? } else { +package me.alexdevs.solstice.modules.styling; +import me.alexdevs.solstice.modules.ModuleProvider; +import net.minecraft.ChatFormatting; +import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.scores.PlayerTeam; +import net.minecraft.world.scores.Scoreboard; +import java.util.Collection; +import java.util.List; +@MethodsReturnNonnullByDefault +public class CustomPlayerTeam extends PlayerTeam { + private final ServerPlayer player; + public CustomPlayerTeam(Scoreboard scoreboard, ServerPlayer player) { + super(scoreboard, player.getGameProfile().getName()); + this.player = player; + super.getPlayers().add(player.getGameProfile().getName()); + } + @Override + public Component getDisplayName() { + return player.getDisplayName(); + } + @Override + public ChatFormatting getColor() { + return ModuleProvider.STYLING.getNameplateColor(player); + } + @Override + public Component getPlayerPrefix() { + return ModuleProvider.STYLING.getNameplatePrefix(player); + } + @Override + public Component getPlayerSuffix() { + return ModuleProvider.STYLING.getNameplateSuffix(player); + } @Override public Collection getPlayers() { return List.of(player.getGameProfile().getName()); } } +//? } diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/CustomSentMessage.java b/src/main/java/me/alexdevs/solstice/modules/styling/CustomSentMessage.java index 4e4c174f..b1bb1bea 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/CustomSentMessage.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/CustomSentMessage.java @@ -65,7 +65,11 @@ public void sendToPlayer(ServerPlayer receiver, boolean filterMaskEnabled, ChatT return; } - switch (params.chatType().value().chat().translationKey()) { + //? if >= 1.21.1 { + /*switch (params.chatType().value().chat().translationKey()) {*/ + //? } else { + switch (params.chatType().chat().translationKey()) { + //? } case "chat.type.text": receiver.sendSystemMessage(this.formattedChatMessage); break; diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/StylingModule.java b/src/main/java/me/alexdevs/solstice/modules/styling/StylingModule.java index de37a9e4..4e6b6e76 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/StylingModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/StylingModule.java @@ -8,17 +8,32 @@ import me.alexdevs.solstice.integrations.LuckPermsIntegration; import me.alexdevs.solstice.modules.styling.data.StylingConfig; import me.lucko.fabric.api.permissions.v0.Permissions; +//? if < 1.21.1 { +import net.minecraft.ChatFormatting; +//? } import net.minecraft.network.chat.Component; +//? if < 1.21.1 { +import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket; +//? } import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.players.PlayerList; +//? if < 1.21.1 { +import net.minecraft.world.scores.Scoreboard; +import java.util.List; +import java.util.concurrent.TimeUnit; +//? } public class StylingModule extends ModuleBase.Toggleable { public static final String ADVANCED_CHAT_FORMATTING_PERMISSION = "solstice.chat.advanced"; public static final String LEGACY_CHAT_FORMATTING_PERMISSION = "solstice.chat.legacy"; public static final String SILENT_ACTIVITY_PERMISSION = "solstice.chat.activity.silent"; - private static final StylingConfig.NameplateFormat DEFAULT_NAMEPLATE = new StylingConfig.NameplateFormat("", ""); + //? if >= 1.21.1 { + /*private static final StylingConfig.NameplateFormat DEFAULT_NAMEPLATE = new StylingConfig.NameplateFormat("", "");*/ + //? } else { + private static final StylingConfig.NameplateFormat DEFAULT_NAMEPLATE = new StylingConfig.NameplateFormat("", "", "WHITE"); + //? } public StylingModule(ResourceLocation id) { super(id); @@ -48,13 +63,18 @@ public void init() { } }); - SolsticeEvents.RELOAD.register(instance -> { + //? if >= 1.21.1 { + /*SolsticeEvents.RELOAD.register(instance -> { var playerList = Solstice.server.getPlayerList(); var scoreboard = Solstice.server.getScoreboard(); for (var player : playerList.getPlayers()) { playerList.updateEntireScoreboard(scoreboard, player); } - }); + });*/ + //? } else { + SolsticeEvents.RELOAD.register(instance -> reloadNameplates(false)); + Solstice.scheduler.scheduleAtFixedRateSync(() -> reloadNameplates(false), 0, 1, TimeUnit.SECONDS); + //? } } public StylingConfig getConfig() { @@ -89,9 +109,23 @@ public void broadcastActivity(PlayerList playerList, Component component, boolea } } - public boolean shouldColorNameplate() { + //? if >= 1.21.1 { + /*public boolean shouldColorNameplate() { return getConfig().doColorNameplate; + }*/ + //? } else { + public ChatFormatting getNameplateColor(ServerPlayer player) { + var config = getConfig(); + var primaryGroup = LuckPermsIntegration.getPrimaryGroup(player); + var color = "WHITE"; + if (config.nameplateFormats.containsKey(primaryGroup)) { + color = config.nameplateFormats.get(primaryGroup).color(); + } else { + color = config.nameplateFormats.getOrDefault("default", DEFAULT_NAMEPLATE).color(); + } + return ChatFormatting.getByName(color); } + //? } public Component getNameplatePrefix(ServerPlayer player) { var config = getConfig(); @@ -118,4 +152,24 @@ public Component getNameplateSuffix(ServerPlayer player) { return Format.parse(format, PlaceholderContext.of(player)); } + + //? if < 1.21.1 { + private void reloadNameplates(boolean add) { + var playerList = Solstice.server.getPlayerList(); + var scoreboard = Solstice.server.getScoreboard(); + for (var player : playerList.getPlayers()) { + sendTeamSetup(player, playerList.getPlayers(), scoreboard, add); + } + } + + public void sendTeamSetup(ServerPlayer player, List players, Scoreboard scoreboard, boolean add) { + for (var otherPlayer : players) { + if(otherPlayer == player) { + continue; + } + var team = new CustomPlayerTeam(scoreboard, otherPlayer); + player.connection.send(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, add)); + } + } + //? } } diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/data/StylingConfig.java b/src/main/java/me/alexdevs/solstice/modules/styling/data/StylingConfig.java index 6a8f8167..651044d9 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/data/StylingConfig.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/data/StylingConfig.java @@ -40,11 +40,17 @@ public class StylingConfig { @Comment("Nameplate formatting per group. group = format.\nPlaceholders here are not refreshed often.") public Map nameplateFormats = Map.of( - "default", new NameplateFormat("", "") + //? if >= 1.21.1 { + /*"default", new NameplateFormat("", "")*/ + //? } else { + "default", new NameplateFormat("", "", "green") + //? } ); - @Comment("Whether to color the username part in the nameplate of players.") - public boolean doColorNameplate = true; + //? if >= 1.21.1 { + /*@Comment("Whether to color the username part in the nameplate of players.") + public boolean doColorNameplate = true;*/ + //? } @Comment("Emote format (/me)") public String emoteFormat = "\uD83D\uDC64 %player:displayname% ${message}"; @@ -65,5 +71,9 @@ public class StylingConfig { public String welcome = "Welcome %player:displayname% to the server!"; @ConfigSerializable - public record NameplateFormat(String prefix, String suffix) { } + //? if >= 1.21.1 { + /*public record NameplateFormat(String prefix, String suffix) { }*/ + //? } else { + public record NameplateFormat(String prefix, String suffix, String color) { } + //? } } diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java b/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java index 76e4666a..12ce7855 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java @@ -1,34 +1,61 @@ package me.alexdevs.solstice.modules.styling.formatters; import eu.pb4.placeholders.api.PlaceholderContext; -import me.alexdevs.solstice.Solstice; +//? if >= 1.21.1 { +/*import me.alexdevs.solstice.Solstice;*/ +//? } import me.alexdevs.solstice.api.text.Format; import me.alexdevs.solstice.modules.ModuleProvider; -import me.alexdevs.solstice.modules.styling.StylingModule; +//? if >= 1.21.1 { +/*import me.alexdevs.solstice.modules.styling.StylingModule; import net.minecraft.advancements.AdvancementHolder; -import net.minecraft.advancements.AdvancementType; +import net.minecraft.advancements.AdvancementType;*/ +//? } else { +import net.minecraft.advancements.Advancement; +//? } import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import java.util.Map; public class AdvancementFormatter { - public static Component getText(ServerPlayer player, AdvancementHolder entry, AdvancementType frame) { + //? if >= 1.21.1 { + /*public static Component getText(ServerPlayer player, AdvancementHolder entry, AdvancementType frame) { var title = entry.value().display().get().getTitle(); var description = entry.value().display().get().getDescription(); + var frameId = frame.getSerializedName();*/ + //? } else { + public static Component getText(ServerPlayer player, Advancement advancement) { + var frame = advancement.getDisplay().getFrame(); + var frameId = frame.getName(); + var title = advancement.getDisplay().getTitle(); + var description = advancement.getDisplay().getDescription(); + //? } var config = ModuleProvider.STYLING.getConfig(); + //? if >= 1.21.1 { + /*String advancementFormat = switch (frame) { + case GOAL -> config.advancementGoal; + case CHALLENGE -> config.advancementChallenge; + case TASK -> config.advancementTask; + };*/ + //? } else { String advancementFormat = switch (frame) { case GOAL -> config.advancementGoal; case CHALLENGE -> config.advancementChallenge; case TASK -> config.advancementTask; }; + //? } var playerContext = PlaceholderContext.of(player); Map placeholders = Map.of( + //? if >= 1.21.1 { + /*"frame", frame.getDisplayName(),*/ + //? } else { "frame", frame.getDisplayName(), + //? } "title", title, "description", description ); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index eb6dcbec..8d0190f9 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -34,8 +34,8 @@ ], "depends": { "fabricloader": ">=0.16.0", - "minecraft": "~1.21.1", - "java": ">=21", + "minecraft": "${minecraft_constraint}", + "java": ">=${java_version}", "fabric-api": "*" }, "recommends": { diff --git a/src/main/resources/solstice.mixins.json b/src/main/resources/solstice.mixins.json index c6b04fe4..63a717b1 100644 --- a/src/main/resources/solstice.mixins.json +++ b/src/main/resources/solstice.mixins.json @@ -2,7 +2,11 @@ "required": true, "minVersion": "0.8", "package": "me.alexdevs.solstice.mixin", - "compatibilityLevel": "JAVA_21", + /*? if >= 1.21.1 {*/ + /*"compatibilityLevel": "JAVA_21",*/ + /*? } else {*/ + "compatibilityLevel": "JAVA_17", + /*? }*/ "plugin": "me.alexdevs.solstice.mixin.SolsticeMixinConfigPlugin", "client": [], "server": [], @@ -22,6 +26,9 @@ "modules.miscellaneous.BypassSleepingInBedCheckMixin", "modules.sign.FormatSignMixin", "modules.spawn.OverrideNewPlayerSpawnPointMixin", + /*? if < 1.21.1 {*/ + /*"modules.spawn.OverrideSpawnPointLevelMixin",*/ + /*? }*/ "modules.spawn.OverrideSpawnPointMixin", "modules.styling.CustomAdvancementMixin", "modules.styling.CustomChatMessageMixin", diff --git a/versions/1.20.1/gradle.properties b/versions/1.20.1/gradle.properties index bca93552..cc3ffa15 100644 --- a/versions/1.20.1/gradle.properties +++ b/versions/1.20.1/gradle.properties @@ -2,6 +2,8 @@ org.gradle.jvmargs=-Xmx3G minecraft_version=1.20.1 loader_version=0.16.14 +java_version=17 +minecraft_constraint=~1.20.1 parchment_mappings=2023.09.03 fabric_version=0.92.6+1.20.1 diff --git a/versions/1.21.1/gradle.properties b/versions/1.21.1/gradle.properties index 136a67c0..b50d0dc8 100644 --- a/versions/1.21.1/gradle.properties +++ b/versions/1.21.1/gradle.properties @@ -2,9 +2,12 @@ org.gradle.jvmargs=-Xmx3G minecraft_version=1.21.1 loader_version=0.16.14 +java_version=21 +minecraft_constraint=~1.21.1 parchment_mappings=2024.11.17 fabric_version=0.116.4+1.21.1 +configurate_version=4.1.2 permissions_api_version=0.3.3 placeholderapi_version=2.4.2+1.21 sgui_version=1.6.1+1.21.1 diff --git a/versions/1.21.4/gradle.properties b/versions/1.21.4/gradle.properties index 39afbf42..353bb674 100644 --- a/versions/1.21.4/gradle.properties +++ b/versions/1.21.4/gradle.properties @@ -2,9 +2,12 @@ org.gradle.jvmargs=-Xmx3G minecraft_version=1.21.4 loader_version=0.17.2 +java_version=21 +minecraft_constraint=~1.21.4 parchment_mappings=2025.03.23 fabric_version=0.119.4+1.21.4 +configurate_version=4.1.2 permissions_api_version=0.3.3 placeholderapi_version=2.5.2+1.21.3 sgui_version=1.8.2+1.21.4 From ed66a209a0ab9841d3bd4a167e3b0fb686b1685d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nelson=20Gra=C3=A7a?= Date: Mon, 23 Mar 2026 23:45:37 +0000 Subject: [PATCH 3/6] Integrate 1.21.4 --- .../java/me/alexdevs/solstice/Solstice.java | 4 +- .../alexdevs/solstice/api/ServerLocation.java | 11 +++++- .../api/text/tag/PhaseGradientTag.java | 8 ++-- .../solstice/api/utils/PlayerUtils.java | 8 ++-- .../core/coreModule/commands/PingCommand.java | 8 ++-- .../mixin/modules/back/PreTeleportMixin.java | 14 ++++--- .../mixin/modules/core/RealPingMixin.java | 16 ++++---- .../OverrideNewPlayerSpawnPointMixin.java | 16 ++++---- .../spawn/OverrideSpawnPointLevelMixin.java | 4 +- .../spawn/OverrideSpawnPointMixin.java | 38 +++++++++++++++++-- .../styling/CustomAdvancementMixin.java | 12 +++--- .../CustomConnectionMessagesMixin.java | 12 +++--- .../modules/styling/CustomNameplateMixin.java | 8 ++-- .../styling/PlayerDisconnectMixin.java | 4 +- .../solstice/modules/afk/AfkModule.java | 10 ++++- .../ignore/commands/IgnoreCommand.java | 4 +- .../commands/InventorySeeCommand.java | 12 +++--- .../item/commands/ItemLoreCommand.java | 20 +++++----- .../item/commands/ItemNameCommand.java | 12 +++--- .../modules/item/commands/RepairCommand.java | 8 ++-- .../solstice/modules/jail/JailModule.java | 30 +++++++++++++++ .../alexdevs/solstice/modules/kit/Utils.java | 12 +++--- .../modules/kit/commands/KitsCommand.java | 12 +++--- .../commands/EffectsCommand.java | 4 +- .../commands/KittyCannonCommand.java | 12 +++++- .../miscellaneous/commands/SpeedCommand.java | 8 ++-- .../placeholders/PlaceholdersModule.java | 12 +++--- .../modules/powertool/PowerToolModule.java | 33 ++++++++++++++++ .../modules/rtp/commands/RTPCommand.java | 8 ++-- .../solstice/modules/rtp/core/Locator.java | 16 +++++++- .../solstice/modules/rtp/data/RTPConfig.java | 4 +- .../solstice/modules/skull/SkullModule.java | 28 +++++++------- .../modules/smite/commands/SmiteCommand.java | 8 ++++ .../solstice/modules/spawn/SpawnModule.java | 4 +- .../modules/styling/CustomPlayerTeam.java | 6 +-- .../modules/styling/CustomSentMessage.java | 4 +- .../modules/styling/StylingModule.java | 12 +++--- .../modules/styling/data/StylingConfig.java | 12 +++--- .../formatters/AdvancementFormatter.java | 20 +++++----- .../modules/sudo/commands/DoAsCommand.java | 4 ++ .../modules/sudo/commands/SudoCommand.java | 4 ++ .../suicide/commands/SuicideCommand.java | 4 ++ .../commands/TeleportHereCommand.java | 4 ++ 43 files changed, 322 insertions(+), 168 deletions(-) diff --git a/src/main/java/me/alexdevs/solstice/Solstice.java b/src/main/java/me/alexdevs/solstice/Solstice.java index b0255347..0b911a34 100644 --- a/src/main/java/me/alexdevs/solstice/Solstice.java +++ b/src/main/java/me/alexdevs/solstice/Solstice.java @@ -29,8 +29,8 @@ public class Solstice implements ModInitializer { public static final String MOD_ID = "solstice"; public static final Logger LOGGER = LoggerFactory.getLogger(Solstice.class); //? if >= 1.21.1 { - /*public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(MOD_ID, "");*/ - //? } else { + /*public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(MOD_ID, ""); + *///? } else { public static final ResourceLocation ID = new ResourceLocation(MOD_ID, ""); //? } diff --git a/src/main/java/me/alexdevs/solstice/api/ServerLocation.java b/src/main/java/me/alexdevs/solstice/api/ServerLocation.java index 7b8e749d..8bb9cc04 100644 --- a/src/main/java/me/alexdevs/solstice/api/ServerLocation.java +++ b/src/main/java/me/alexdevs/solstice/api/ServerLocation.java @@ -16,6 +16,9 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.phys.Vec3; +//? if >= 1.21.4 { +/*import java.util.Set; +*///? } import java.util.Objects; @@ -80,7 +83,11 @@ public void teleport(ServerPlayer player, boolean setBackPosition) { player.setDeltaMovement(player.getDeltaMovement().multiply(1f, 0f, 1f)); player.setOnGround(true); + //? if >= 1.21.4 { + /*player.teleportTo(serverWorld, this.getX(), this.getY(), this.getZ(), Set.of(), this.getYaw(), this.getPitch(), false); + *///? } else { player.teleportTo(serverWorld, this.getX(), this.getY(), this.getZ(), this.getYaw(), this.getPitch()); + //? } // There is a bug (presumably in Fabric's api) that causes experience level to be set to 0 when teleporting between dimensions/worlds. // Therefore, this will update the experience client side as a temporary solution. @@ -93,8 +100,8 @@ public void teleport(ServerPlayer player) { public ResourceKey getWorldKey() { //? if >= 1.21.1 { - /*return ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(this.getWorld()));*/ - //? } else { + /*return ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(this.getWorld())); + *///? } else { return ResourceKey.create(Registries.DIMENSION, ResourceLocation.tryParse(this.getWorld())); //? } } diff --git a/src/main/java/me/alexdevs/solstice/api/text/tag/PhaseGradientTag.java b/src/main/java/me/alexdevs/solstice/api/text/tag/PhaseGradientTag.java index 6019cdb4..2bfd2074 100644 --- a/src/main/java/me/alexdevs/solstice/api/text/tag/PhaseGradientTag.java +++ b/src/main/java/me/alexdevs/solstice/api/text/tag/PhaseGradientTag.java @@ -48,15 +48,15 @@ public static TextParserV1.TextTag createTag() { var parsedColor = TextColor.parseColor(arg); //? if >= 1.21.1 { - /*if (parsedColor.isError()) {*/ - //? } else { + /*if (parsedColor.isError()) { + *///? } else { if (parsedColor == null) { //? } textColors.add(TextColor.fromRgb(0)); } else { //? if >= 1.21.1 { - /*textColors.add(parsedColor.getOrThrow());*/ - //? } else { + /*textColors.add(parsedColor.getOrThrow()); + *///? } else { textColors.add(parsedColor); //? } } diff --git a/src/main/java/me/alexdevs/solstice/api/utils/PlayerUtils.java b/src/main/java/me/alexdevs/solstice/api/utils/PlayerUtils.java index a0e8c806..d34d65d5 100644 --- a/src/main/java/me/alexdevs/solstice/api/utils/PlayerUtils.java +++ b/src/main/java/me/alexdevs/solstice/api/utils/PlayerUtils.java @@ -3,8 +3,8 @@ import com.mojang.authlib.GameProfile; import me.alexdevs.solstice.Solstice; //? if >= 1.21.1 { -/*import net.minecraft.server.level.ClientInformation;*/ -//? } +/*import net.minecraft.server.level.ClientInformation; +*///? } import net.minecraft.server.level.ServerPlayer; import java.util.UUID; @@ -20,8 +20,8 @@ public static ServerPlayer loadOfflinePlayer(GameProfile profile) { var playerManager = Solstice.server.getPlayerList(); //? if >= 1.21.1 { - /*var player = playerManager.getPlayerForLogin(profile, ClientInformation.createDefault());*/ - //? } else { + /*var player = playerManager.getPlayerForLogin(profile, ClientInformation.createDefault()); + *///? } else { var player = playerManager.getPlayerForLogin(profile); //? } playerManager.load(player); diff --git a/src/main/java/me/alexdevs/solstice/core/coreModule/commands/PingCommand.java b/src/main/java/me/alexdevs/solstice/core/coreModule/commands/PingCommand.java index af238309..f0c664f0 100644 --- a/src/main/java/me/alexdevs/solstice/core/coreModule/commands/PingCommand.java +++ b/src/main/java/me/alexdevs/solstice/core/coreModule/commands/PingCommand.java @@ -27,8 +27,8 @@ public LiteralArgumentBuilder command(String name) { .executes(context -> { var player = context.getSource().getPlayerOrException(); //? if >= 1.21.1 { - /*var ping = player.connection.latency();*/ - //? } else { + /*var ping = player.connection.latency(); + *///? } else { var ping = player.latency; //? } var map = Map.of( @@ -42,8 +42,8 @@ public LiteralArgumentBuilder command(String name) { .executes(context -> { var player = EntityArgument.getPlayer(context, "player"); //? if >= 1.21.1 { - /*var ping = player.connection.latency();*/ - //? } else { + /*var ping = player.connection.latency(); + *///? } else { var ping = player.latency; //? } var map = Map.of( diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/back/PreTeleportMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/back/PreTeleportMixin.java index 7be24456..5507b1fe 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/back/PreTeleportMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/back/PreTeleportMixin.java @@ -1,23 +1,27 @@ package me.alexdevs.solstice.mixin.modules.back; - -import me.alexdevs.solstice.Solstice; import me.alexdevs.solstice.api.ServerLocation; import me.alexdevs.solstice.modules.ModuleProvider; -import me.alexdevs.solstice.modules.back.BackModule; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; +//? if >= 1.21.4 { +/*import net.minecraft.world.entity.Relative; +*///? } else { import net.minecraft.world.entity.RelativeMovement; +//? } import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - import java.util.Set; - @Mixin(ServerPlayer.class) public abstract class PreTeleportMixin { + //? if >= 1.21.4 { + /*@Inject(method = "teleportTo(Lnet/minecraft/server/level/ServerLevel;DDDLjava/util/Set;FFZ)Z", at = @At("HEAD")) + public void solstice$getPreTeleportLocation(ServerLevel world, double destX, double destY, double destZ, Set flags, float yaw, float pitch, boolean setCamera, CallbackInfoReturnable cir) { + *///? } else { @Inject(method = "teleportTo(Lnet/minecraft/server/level/ServerLevel;DDDLjava/util/Set;FF)Z", at = @At("HEAD")) public void solstice$getPreTeleportLocation(ServerLevel world, double destX, double destY, double destZ, Set flags, float yaw, float pitch, CallbackInfoReturnable cir) { + //? } var player = (ServerPlayer) (Object) this; ModuleProvider.BACK.setPlayerLastLocation(player.getUUID(), new ServerLocation(player)); } diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/core/RealPingMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/core/RealPingMixin.java index 94e057f5..f24e2a8c 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/core/RealPingMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/core/RealPingMixin.java @@ -1,21 +1,21 @@ package me.alexdevs.solstice.mixin.modules.core; import com.llamalad7.mixinextras.sugar.Local; //? if >= 1.21.1 { -/*import net.minecraft.server.network.ServerCommonPacketListenerImpl;*/ -//? } else { +/*import net.minecraft.server.network.ServerCommonPacketListenerImpl; +*///? } else { import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.ServerGamePacketListenerImpl; //? } import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; //? if >= 1.21.1 { -/*import org.spongepowered.asm.mixin.Shadow;*/ -//? } +/*import org.spongepowered.asm.mixin.Shadow; +*///? } import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; //? if >= 1.21.1 { -/*@Mixin(ServerCommonPacketListenerImpl.class)*/ -//? } else { +/*@Mixin(ServerCommonPacketListenerImpl.class) +*///? } else { @Mixin(ServerGamePacketListenerImpl.class) //? } public abstract class RealPingMixin { @@ -25,8 +25,8 @@ public abstract class RealPingMixin { @Redirect(method = "handleKeepAlive", at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerCommonPacketListenerImpl;latency:I", opcode = Opcodes.PUTFIELD)) public void solstice$realPing(ServerCommonPacketListenerImpl instance, int value, @Local int i) { latency = i; - }*/ - //? } else { + } + *///? } else { @Redirect(method = "handleKeepAlive", at = @At(value = "FIELD", target = "Lnet/minecraft/server/level/ServerPlayer;latency:I", opcode = Opcodes.PUTFIELD)) public void solstice$realPing(ServerPlayer player, int value, @Local int i) { player.latency = i; diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideNewPlayerSpawnPointMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideNewPlayerSpawnPointMixin.java index cc9dce9c..ee888d86 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideNewPlayerSpawnPointMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideNewPlayerSpawnPointMixin.java @@ -1,11 +1,11 @@ package me.alexdevs.solstice.mixin.modules.spawn; //? if >= 1.21.1 { -/*import com.llamalad7.mixinextras.sugar.Local;*/ -//? } +/*import com.llamalad7.mixinextras.sugar.Local; +*///? } import me.alexdevs.solstice.modules.ModuleProvider; //? if >= 1.21.1 { -/*import net.minecraft.nbt.CompoundTag;*/ -//? } +/*import net.minecraft.nbt.CompoundTag; +*///? } import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; @@ -15,8 +15,8 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; //? if >= 1.21.1 { -/*import java.util.Optional;*/ -//? } +/*import java.util.Optional; +*///? } @Mixin(PlayerList.class) public abstract class OverrideNewPlayerSpawnPointMixin { @Redirect( @@ -28,8 +28,8 @@ public abstract class OverrideNewPlayerSpawnPointMixin { ) //? if >= 1.21.1 { /*public ServerLevel solstice$overrideWorld(MinecraftServer server, ResourceKey dimension, @Local Optional optional) { - if (optional.isEmpty()) {*/ - //? } else { + if (optional.isEmpty()) { + *///? } else { public ServerLevel solstice$overrideWorld(MinecraftServer server, ResourceKey dimension) { var level = server.getLevel(dimension); if (level == null) { diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointLevelMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointLevelMixin.java index 094e0d3d..8cf32a22 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointLevelMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointLevelMixin.java @@ -1,5 +1,5 @@ //? if < 1.21.1 { -/*package me.alexdevs.solstice.mixin.modules.spawn; +package me.alexdevs.solstice.mixin.modules.spawn; import me.alexdevs.solstice.modules.ModuleProvider; import net.minecraft.core.BlockPos; @@ -47,5 +47,5 @@ public abstract class OverrideSpawnPointLevelMixin { } } } -*/ + //? } \ No newline at end of file diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java index 9b3b405d..49c8768a 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java @@ -1,7 +1,14 @@ package me.alexdevs.solstice.mixin.modules.spawn; import me.alexdevs.solstice.modules.ModuleProvider; import net.minecraft.core.BlockPos; -//? if >= 1.21.1 { +//? if >= 1.21.4 { +/*import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.portal.TeleportTransition; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Shadow; +*///? } else if >= 1.21.1 { /*import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.portal.DimensionTransition; @@ -21,12 +28,35 @@ import java.util.Optional; //? } //? if >= 1.21.1 { -/*@Mixin(ServerPlayer.class)*/ -//? } else { +/*@Mixin(ServerPlayer.class) +*///? } else { @Mixin(Player.class) //? } public abstract class OverrideSpawnPointMixin { - //? if >= 1.21.1 { + //? if >= 1.21.4 { + /*@Shadow @Final public MinecraftServer server; + @Shadow private BlockPos respawnPosition; + @Inject(method = "findRespawnPositionAndUseSpawnBlock", at = @At("RETURN"), cancellable = true) + public void solstice$overrideRespawnTarget(boolean useCharge, TeleportTransition.PostTeleportTransition postTeleportTransition, CallbackInfoReturnable cir) { + var spawnModule = ModuleProvider.SPAWN; + var config = spawnModule.getConfig(); + var spawn = spawnModule.getGlobalSpawnPosition(); + var world = spawn.getWorld(this.server); + var pos = new Vec3(spawn.getX(), spawn.getY(), spawn.getZ()); + var transition = new TeleportTransition( + world, pos, Vec3.ZERO, + spawn.getYaw(), spawn.getPitch(), + TeleportTransition.DO_NOTHING + ); + if (config.globalSpawn.onRespawn) { + cir.setReturnValue(transition); + return; + } + if (config.globalSpawn.onRespawnSoft && respawnPosition == null) { + cir.setReturnValue(transition); + } + } + *///? } else if >= 1.21.1 { /*@Shadow @Final public MinecraftServer server; @Shadow private BlockPos respawnPosition; @Inject(method = "findRespawnPositionAndUseSpawnBlock", at = @At("RETURN"), cancellable = true) diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomAdvancementMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomAdvancementMixin.java index 32b2d763..d2593813 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomAdvancementMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomAdvancementMixin.java @@ -4,8 +4,8 @@ /*import net.minecraft.advancements.AdvancementHolder; import net.minecraft.advancements.AdvancementType; import net.minecraft.network.chat.MutableComponent; -import net.minecraft.server.level.ServerPlayer;*/ -//? } else { +import net.minecraft.server.level.ServerPlayer; +*///? } else { import net.minecraft.advancements.Advancement; import net.minecraft.network.chat.Component; import net.minecraft.server.PlayerAdvancements; @@ -23,8 +23,8 @@ //? } import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; //? if >= 1.21.1 { -/*@Mixin(AdvancementType.class)*/ -//? } else { +/*@Mixin(AdvancementType.class) +*///? } else { @Mixin(PlayerAdvancements.class) //? } public abstract class CustomAdvancementMixin { @@ -32,8 +32,8 @@ public abstract class CustomAdvancementMixin { /*@Inject(method = "createAnnouncement", at = @At("HEAD"), cancellable = true) public void solstice$getCustomAnnouncement(AdvancementHolder advancement, ServerPlayer player, CallbackInfoReturnable cir) { cir.setReturnValue(AdvancementFormatter.getText(player, advancement, (AdvancementType) (Object) this).copy()); - }*/ - //? } else { + } + *///? } else { @Shadow private ServerPlayer player; @Final @Shadow private PlayerList playerList; @Inject(method = "award", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V"), locals = LocalCapture.CAPTURE_FAILSOFT) diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomConnectionMessagesMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomConnectionMessagesMixin.java index 56265fe5..9414532b 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomConnectionMessagesMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomConnectionMessagesMixin.java @@ -7,8 +7,8 @@ import net.minecraft.network.chat.contents.TranslatableContents; import net.minecraft.server.level.ServerPlayer; //? if >= 1.21.1 { -/*import net.minecraft.server.network.CommonListenerCookie;*/ -//? } +/*import net.minecraft.server.network.CommonListenerCookie; +*///? } import net.minecraft.server.players.PlayerList; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -24,8 +24,8 @@ public abstract class CustomConnectionMessagesMixin { @Inject(method = "placeNewPlayer", at = @At("HEAD")) //? if >= 1.21.1 { - /*private void solstice$onJoin(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) {*/ - //? } else { + /*private void solstice$onJoin(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) { + *///? } else { private void solstice$onJoin(Connection connection, ServerPlayer player, CallbackInfo ci) { //? } solstice$player = player; @@ -33,8 +33,8 @@ public abstract class CustomConnectionMessagesMixin { @Inject(method = "placeNewPlayer", at = @At("RETURN")) //? if >= 1.21.1 { - /*private void solstice$onJoinReturn(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) {*/ - //? } else { + /*private void solstice$onJoinReturn(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) { + *///? } else { private void solstice$onJoinReturn(Connection connection, ServerPlayer player, CallbackInfo ci) { //? } solstice$player = null; diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java index d6ab0aec..3d3066db 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java @@ -3,8 +3,8 @@ import me.alexdevs.solstice.modules.ModuleProvider; //? if >= 1.21.1 { /*import me.alexdevs.solstice.modules.styling.CustomPlayerTeam; -import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;*/ -//? } +import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket; +*///? } import net.minecraft.server.ServerScoreboard; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.players.PlayerList; @@ -30,8 +30,8 @@ public abstract class CustomNameplateMixin { /*for (var otherPlayer : players) { var team = new CustomPlayerTeam(scoreboard, otherPlayer); player.connection.send(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true)); - }*/ - //? } else { + } + *///? } else { ModuleProvider.STYLING.sendTeamSetup(player, players, scoreboard, true); //? } } diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/PlayerDisconnectMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/PlayerDisconnectMixin.java index b81802f9..78aaa1c9 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/PlayerDisconnectMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/PlayerDisconnectMixin.java @@ -17,8 +17,8 @@ public abstract class PlayerDisconnectMixin { public ServerPlayer player; //? if >= 1.21.1 { - /*@Redirect(method = "removePlayerFromWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V"))*/ - //? } else { + /*@Redirect(method = "removePlayerFromWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V")) + *///? } else { @Redirect(method = "onDisconnect", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V")) //? } private void solstice$sendLeaveMessage(PlayerList playerList, Component message, boolean bypassHiddenChat) { diff --git a/src/main/java/me/alexdevs/solstice/modules/afk/AfkModule.java b/src/main/java/me/alexdevs/solstice/modules/afk/AfkModule.java index c02dc83b..d58311b3 100644 --- a/src/main/java/me/alexdevs/solstice/modules/afk/AfkModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/afk/AfkModule.java @@ -21,7 +21,9 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionResult; +//? if < 1.21.4 { import net.minecraft.world.InteractionResultHolder; +//? } import net.minecraft.world.entity.Entity; import net.minecraft.world.phys.Vec3; @@ -67,8 +69,8 @@ public void init() { this.commands.add(new ActiveTimeCommand(this)); //? if >= 1.21.1 { - /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(Solstice.MOD_ID, "afk"), (context, arg) -> {*/ - //? } else { + /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(Solstice.MOD_ID, "afk"), (context, arg) -> { + *///? } else { Placeholders.register(new ResourceLocation(Solstice.MOD_ID, "afk"), (context, arg) -> { //? } if (!context.hasPlayer()) @@ -347,7 +349,11 @@ private void registerTriggers() { if (getConfig().triggers.onItemUse) { clearAfk((ServerPlayer) player, AfkTriggerReason.ITEM_USE); } + //? if >= 1.21.4 { + /*return InteractionResult.PASS; + *///? } else { return InteractionResultHolder.pass(player.getItemInHand(hand)); + //? } }); ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) -> { diff --git a/src/main/java/me/alexdevs/solstice/modules/ignore/commands/IgnoreCommand.java b/src/main/java/me/alexdevs/solstice/modules/ignore/commands/IgnoreCommand.java index 7fdc6291..277298ff 100644 --- a/src/main/java/me/alexdevs/solstice/modules/ignore/commands/IgnoreCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/ignore/commands/IgnoreCommand.java @@ -42,8 +42,8 @@ public LiteralArgumentBuilder command(String name) { var targetName = StringArgumentType.getString(context, "target"); //? if >= 1.21.1 { - /*context.getSource().getServer().getProfileCache().getAsync(targetName).thenAcceptAsync(profileOpt -> {*/ - //? } else { + /*context.getSource().getServer().getProfileCache().getAsync(targetName).thenAcceptAsync(profileOpt -> { + *///? } else { context.getSource().getServer().getProfileCache().getAsync(targetName, profileOpt -> { //? } var playerContext = PlaceholderContext.of(player); diff --git a/src/main/java/me/alexdevs/solstice/modules/inventorySee/commands/InventorySeeCommand.java b/src/main/java/me/alexdevs/solstice/modules/inventorySee/commands/InventorySeeCommand.java index abb1a46f..e06eb202 100644 --- a/src/main/java/me/alexdevs/solstice/modules/inventorySee/commands/InventorySeeCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/inventorySee/commands/InventorySeeCommand.java @@ -13,8 +13,8 @@ import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.commands.CommandSourceStack; //? if >= 1.21.1 { -/*import net.minecraft.core.component.DataComponents;*/ -//? } +/*import net.minecraft.core.component.DataComponents; +*///? } import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.inventory.ChestMenu; @@ -109,8 +109,8 @@ public void onClose() { var barrier = new ItemStack(Items.BLACK_STAINED_GLASS_PANE); //? if >= 1.21.1 { - /*barrier.set(DataComponents.CUSTOM_NAME, Component.literal(""));*/ - //? } else { + /*barrier.set(DataComponents.CUSTOM_NAME, Component.literal("")); + *///? } else { barrier.setHoverName(Component.literal("")); //? } for (var i = targetInventory.getContainerSize(); i < container.getSize(); i++) { @@ -203,8 +203,8 @@ public void onClose() { var barrier = new ItemStack(Items.BLACK_STAINED_GLASS_PANE); //? if >= 1.21.1 { - /*barrier.set(DataComponents.CUSTOM_NAME, Component.literal(""));*/ - //? } else { + /*barrier.set(DataComponents.CUSTOM_NAME, Component.literal("")); + *///? } else { barrier.setHoverName(Component.literal("")); //? } for (var i = size; i < container.getSize(); i++) { diff --git a/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemLoreCommand.java b/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemLoreCommand.java index 285c3f0f..3dc94e04 100644 --- a/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemLoreCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemLoreCommand.java @@ -9,8 +9,8 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; //? if >= 1.21.1 { -/*import net.minecraft.core.component.DataComponents;*/ -//? } +/*import net.minecraft.core.component.DataComponents; +*///? } //? if < 1.21.1 { import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -18,12 +18,12 @@ //? } import net.minecraft.network.chat.Component; //? if >= 1.21.1 { -/*import net.minecraft.world.item.component.ItemLore;*/ -//? } +/*import net.minecraft.world.item.component.ItemLore; +*///? } //? if >= 1.21.1 { -/*import java.util.ArrayList;*/ -//? } +/*import java.util.ArrayList; +*///? } import java.util.List; public class ItemLoreCommand extends ModCommand { @@ -50,8 +50,8 @@ public LiteralArgumentBuilder command(String name) { } //? if >= 1.21.1 { - /*item.remove(DataComponents.LORE);*/ - //? } else { + /*item.remove(DataComponents.LORE); + *///? } else { CompoundTag nbtCompound = item.getTagElement("display"); if (nbtCompound != null) { nbtCompound.remove("Lore"); @@ -82,8 +82,8 @@ public LiteralArgumentBuilder command(String name) { for (var line : itemLore.split("\\\\n")) { list.add(Format.parse(line, playerContext)); } - item.set(DataComponents.LORE, new ItemLore(list));*/ - //? } else { + item.set(DataComponents.LORE, new ItemLore(list)); + *///? } else { var list = new ListTag(); for (var line : itemLore.split("\\\\n")) { var text = Format.parse(line, playerContext); diff --git a/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemNameCommand.java b/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemNameCommand.java index 5441730f..41ba43a7 100644 --- a/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemNameCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemNameCommand.java @@ -9,8 +9,8 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; //? if >= 1.21.1 { -/*import net.minecraft.core.component.DataComponents;*/ -//? } +/*import net.minecraft.core.component.DataComponents; +*///? } import java.util.List; @@ -38,8 +38,8 @@ public LiteralArgumentBuilder command(String name) { } //? if >= 1.21.1 { - /*item.remove(DataComponents.CUSTOM_NAME);*/ - //? } else { + /*item.remove(DataComponents.CUSTOM_NAME); + *///? } else { item.resetHoverName(); //? } @@ -60,8 +60,8 @@ public LiteralArgumentBuilder command(String name) { var playerContext = PlaceholderContext.of(player); //? if >= 1.21.1 { - /*item.set(DataComponents.CUSTOM_NAME, Format.parse(itemName, playerContext));*/ - //? } else { + /*item.set(DataComponents.CUSTOM_NAME, Format.parse(itemName, playerContext)); + *///? } else { item.setHoverName(Format.parse(itemName, playerContext)); //? } diff --git a/src/main/java/me/alexdevs/solstice/modules/item/commands/RepairCommand.java b/src/main/java/me/alexdevs/solstice/modules/item/commands/RepairCommand.java index 50073d9f..6f509dc1 100644 --- a/src/main/java/me/alexdevs/solstice/modules/item/commands/RepairCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/item/commands/RepairCommand.java @@ -5,8 +5,8 @@ import me.alexdevs.solstice.modules.item.ItemModule; import net.minecraft.commands.CommandSourceStack; //? if >= 1.21.1 { -/*import net.minecraft.core.component.DataComponents;*/ -//? } +/*import net.minecraft.core.component.DataComponents; +*///? } import java.util.List; @@ -45,8 +45,8 @@ public LiteralArgumentBuilder command(String name) { if(item.isDamaged()) { // Removes the NBT tag altogether instead of just setting it to 0 //? if >= 1.21.1 { - /*item.remove(DataComponents.DAMAGE);*/ - //? } else { + /*item.remove(DataComponents.DAMAGE); + *///? } else { item.removeTagKey("Damage"); //? } context.getSource().sendSuccess(() -> module.locale().get("repaired"), false); diff --git a/src/main/java/me/alexdevs/solstice/modules/jail/JailModule.java b/src/main/java/me/alexdevs/solstice/modules/jail/JailModule.java index a08de601..d3f70e02 100644 --- a/src/main/java/me/alexdevs/solstice/modules/jail/JailModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/jail/JailModule.java @@ -24,7 +24,9 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionResult; +//? if < 1.21.4 { import net.minecraft.world.InteractionResultHolder; +//? } import java.util.Map; import java.util.UUID; @@ -89,7 +91,11 @@ public void init() { AttackBlockCallback.EVENT.register((player, world, hand, blockPos, direction) -> { if (isPlayerJailed(player.getUUID())) { + //? if >= 1.21.4 { + /*if (player instanceof ServerPlayer sp) sp.sendSystemMessage(locale().get("cannotBreakBlocks")); + *///? } else { player.sendSystemMessage(locale().get("cannotBreakBlocks")); + //? } return InteractionResult.FAIL; } return InteractionResult.PASS; @@ -97,7 +103,11 @@ public void init() { AttackEntityCallback.EVENT.register((player, world, hand, entity, entityHitResult) -> { if (isPlayerJailed(player.getUUID())) { + //? if >= 1.21.4 { + /*if (player instanceof ServerPlayer sp) sp.sendSystemMessage(locale().get("cannotAttackEntities")); + *///? } else { player.sendSystemMessage(locale().get("cannotAttackEntities")); + //? } return InteractionResult.FAIL; } return InteractionResult.PASS; @@ -105,7 +115,11 @@ public void init() { PlayerBlockBreakEvents.BEFORE.register((world, player, blockPos, blockState, blockEntity) -> { if (isPlayerJailed(player.getUUID())) { + //? if >= 1.21.4 { + /*if (player instanceof ServerPlayer sp) sp.sendSystemMessage(locale().get("cannotBreakBlocks")); + *///? } else { player.sendSystemMessage(locale().get("cannotBreakBlocks")); + //? } return false; } @@ -114,7 +128,11 @@ public void init() { UseBlockCallback.EVENT.register((player, world, hand, blockHitResult) -> { if (isPlayerJailed(player.getUUID())) { + //? if >= 1.21.4 { + /*if (player instanceof ServerPlayer sp) sp.sendSystemMessage(locale().get("cannotUseBlocks")); + *///? } else { player.sendSystemMessage(locale().get("cannotUseBlocks")); + //? } return InteractionResult.FAIL; } return InteractionResult.PASS; @@ -122,19 +140,31 @@ public void init() { UseEntityCallback.EVENT.register((player, world, hand, entity, entityHitResult) -> { if (isPlayerJailed(player.getUUID())) { + //? if >= 1.21.4 { + /*if (player instanceof ServerPlayer sp) sp.sendSystemMessage(locale().get("cannotUseEntities")); + *///? } else { player.sendSystemMessage(locale().get("cannotUseEntities")); + //? } return InteractionResult.FAIL; } return InteractionResult.PASS; }); UseItemCallback.EVENT.register((player, world, hand) -> { + //? if >= 1.21.4 { + /*if (isPlayerJailed(player.getUUID()) && player instanceof ServerPlayer) { + ((ServerPlayer) player).sendSystemMessage(locale().get("cannotUseItems")); + return InteractionResult.FAIL; + } + return InteractionResult.PASS; + *///? } else { var stack = player.getItemInHand(hand); if (isPlayerJailed(player.getUUID())) { player.sendSystemMessage(locale().get("cannotUseItems")); return InteractionResultHolder.fail(stack); } return InteractionResultHolder.pass(stack); + //? } }); ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((signedMessage, player, parameters) -> { diff --git a/src/main/java/me/alexdevs/solstice/modules/kit/Utils.java b/src/main/java/me/alexdevs/solstice/modules/kit/Utils.java index dde31b66..9be27c15 100644 --- a/src/main/java/me/alexdevs/solstice/modules/kit/Utils.java +++ b/src/main/java/me/alexdevs/solstice/modules/kit/Utils.java @@ -6,8 +6,8 @@ import net.minecraft.nbt.CompoundTag; //? } //? if >= 1.21.1 { -/*import me.alexdevs.solstice.Solstice;*/ -//? } +/*import me.alexdevs.solstice.Solstice; +*///? } import net.minecraft.nbt.TagParser; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; @@ -19,8 +19,8 @@ public class Utils { public static String serializeItemStack(ItemStack itemStack) { //? if >= 1.21.1 { /*var registry = Solstice.server.registryAccess(); - var nbt = itemStack.save(registry);*/ - //? } else { + var nbt = itemStack.save(registry); + *///? } else { var nbt = new CompoundTag(); itemStack.save(nbt); //? } @@ -31,8 +31,8 @@ public static ItemStack deserializeItemStack(String string) throws CommandSyntax //? if >= 1.21.1 { /*var registry = Solstice.server.registryAccess(); var nbt = TagParser.parseTag(string); - return ItemStack.parseOptional(registry, nbt);*/ - //? } else { + return ItemStack.parseOptional(registry, nbt); + *///? } else { var nbt = TagParser.parseTag(string); return ItemStack.of(nbt); //? } diff --git a/src/main/java/me/alexdevs/solstice/modules/kit/commands/KitsCommand.java b/src/main/java/me/alexdevs/solstice/modules/kit/commands/KitsCommand.java index 0e7d6ab3..be34e950 100644 --- a/src/main/java/me/alexdevs/solstice/modules/kit/commands/KitsCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/kit/commands/KitsCommand.java @@ -19,8 +19,8 @@ //? if >= 1.21.1 { /*import net.minecraft.core.component.DataComponents; -import net.minecraft.world.item.component.ItemLore;*/ -//? } +import net.minecraft.world.item.component.ItemLore; +*///? } //? if < 1.21.1 { import net.minecraft.nbt.ListTag; import net.minecraft.nbt.StringTag; @@ -100,8 +100,8 @@ private void refreshGui(CommandContext context, SimpleGui gu kitNameComponent = Component.nullToEmpty(kitName); kitLoreComponent = module.locale().get("claimKit", placeholders); //? if >= 1.21.1 { - /*icon.set(DataComponents.ENCHANTMENT_GLINT_OVERRIDE, true);*/ - //? } else { + /*icon.set(DataComponents.ENCHANTMENT_GLINT_OVERRIDE, true); + *///? } else { icon.getOrCreateTag().put("Enchantments", new ListTag()); //? } } else { @@ -111,8 +111,8 @@ private void refreshGui(CommandContext context, SimpleGui gu //? if >= 1.21.1 { /*icon.set(DataComponents.CUSTOM_NAME, kitNameComponent); - icon.set(DataComponents.LORE, new ItemLore(List.of(kitLoreComponent)));*/ - //? } else { + icon.set(DataComponents.LORE, new ItemLore(List.of(kitLoreComponent))); + *///? } else { icon.setHoverName(kitNameComponent); var displayNbt = icon.getOrCreateTagElement("display"); var list = new ListTag(); diff --git a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/EffectsCommand.java b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/EffectsCommand.java index b9ad08c5..12645ce9 100644 --- a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/EffectsCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/EffectsCommand.java @@ -60,8 +60,8 @@ private int execute(CommandContext context, ServerPlayer tar var map = Map.of( //? if >= 1.21.1 { - /*"effect", Component.translatable(effect.value().getDescriptionId()),*/ - //? } else { + /*"effect", Component.translatable(effect.value().getDescriptionId()), + *///? } else { "effect", Component.translatable(effect.getDescriptionId()), //? } "amplifier", Component.nullToEmpty(String.valueOf(instance.getAmplifier())), diff --git a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/KittyCannonCommand.java b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/KittyCannonCommand.java index ab90d94c..b749bdba 100644 --- a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/KittyCannonCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/KittyCannonCommand.java @@ -9,7 +9,11 @@ import net.minecraft.commands.Commands; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; +//? if >= 1.21.4 { +/*import net.minecraft.world.entity.EntitySpawnReason; +*///? } else { import net.minecraft.world.entity.MobSpawnType; +//? } import java.util.List; import java.util.concurrent.TimeUnit; @@ -36,8 +40,8 @@ public LiteralArgumentBuilder command(String name) { final var world = player.serverLevel(); //? if >= 1.21.1 { - /*BALL.create(world, entity -> {*/ - //? } else { + /*BALL.create(world, entity -> { + *///? } else { BALL.create(world, null, entity -> { //? } entity.setDeltaMovement(player.getLookAngle().scale(3.5)); @@ -49,7 +53,11 @@ public LiteralArgumentBuilder command(String name) { DummyExplosion.spawn(world, pos, 0); entity.remove(Entity.RemovalReason.DISCARDED); }, 1, TimeUnit.SECONDS); + //? if >= 1.21.4 { + /*}, player.blockPosition().above(), EntitySpawnReason.COMMAND, true, false); + *///? } else { }, player.blockPosition().above(), MobSpawnType.COMMAND, true, false); + //? } return 1; diff --git a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/SpeedCommand.java b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/SpeedCommand.java index 5305c24e..1fe0cd39 100644 --- a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/SpeedCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/SpeedCommand.java @@ -75,8 +75,8 @@ private int setWalkingSpeed(CommandContext context, float sp if (speedMultiplier == 1) { //? if >= 1.21.1 { - /*instance.removeModifier(id);*/ - //? } else { + /*instance.removeModifier(id); + *///? } else { var res = instance.getModifiers().stream().filter(x -> x.getName().equals(id.toString())).findFirst(); res.ifPresent(instance::removeModifier); //? } @@ -85,8 +85,8 @@ private int setWalkingSpeed(CommandContext context, float sp } else { //? if >= 1.21.1 { /*var modifier = new AttributeModifier(id, speedMultiplier, AttributeModifier.Operation.ADD_MULTIPLIED_BASE); - instance.addOrUpdateTransientModifier(modifier);*/ - //? } else { + instance.addOrUpdateTransientModifier(modifier); + *///? } else { var res = instance.getModifiers().stream().filter(x -> x.getName().equals(id.toString())).findFirst(); res.ifPresent(instance::removeModifier); diff --git a/src/main/java/me/alexdevs/solstice/modules/placeholders/PlaceholdersModule.java b/src/main/java/me/alexdevs/solstice/modules/placeholders/PlaceholdersModule.java index 842e3dab..85e7f025 100644 --- a/src/main/java/me/alexdevs/solstice/modules/placeholders/PlaceholdersModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/placeholders/PlaceholdersModule.java @@ -16,8 +16,8 @@ public PlaceholdersModule(ResourceLocation id) { @Override public void init() { //? if >= 1.21.1 { - /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(ENTITY, "name"), (context, str) -> {*/ - //? } else { + /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(ENTITY, "name"), (context, str) -> { + *///? } else { Placeholders.register(new ResourceLocation(ENTITY, "name"), (context, str) -> { //? } if (!context.hasEntity()) { @@ -28,8 +28,8 @@ public void init() { }); //? if >= 1.21.1 { - /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(ENTITY, "displayname"), (context, str) -> {*/ - //? } else { + /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(ENTITY, "displayname"), (context, str) -> { + *///? } else { Placeholders.register(new ResourceLocation(ENTITY, "displayname"), (context, str) -> { //? } if (!context.hasEntity()) { @@ -40,8 +40,8 @@ public void init() { }); //? if >= 1.21.1 { - /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(ENTITY, "uuid"), (context, str) -> {*/ - //? } else { + /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(ENTITY, "uuid"), (context, str) -> { + *///? } else { Placeholders.register(new ResourceLocation(ENTITY, "uuid"), (context, str) -> { //? } if (!context.hasEntity()) { diff --git a/src/main/java/me/alexdevs/solstice/modules/powertool/PowerToolModule.java b/src/main/java/me/alexdevs/solstice/modules/powertool/PowerToolModule.java index 661a0d69..527c8b2c 100644 --- a/src/main/java/me/alexdevs/solstice/modules/powertool/PowerToolModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/powertool/PowerToolModule.java @@ -12,10 +12,15 @@ import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.fabricmc.fabric.api.event.player.*; import net.minecraft.commands.CommandSourceStack; +//? if >= 1.21.4 { +/*import net.minecraft.server.level.ServerLevel; +*///? } import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionResult; +//? if < 1.21.4 { import net.minecraft.world.InteractionResultHolder; +//? } import net.minecraft.world.item.ItemStack; import java.util.UUID; @@ -46,14 +51,26 @@ public void init() { if (data.powerTools.containsKey(itemId)) { var powertool = data.powerTools.get(itemId); if (powertool.containsKey(Action.USE)) { + //? if >= 1.21.4 { + /*var source = player.createCommandSourceStackForNameResolution(((ServerLevel) player.level())); + *///? } else { var source = player.createCommandSourceStack(); + //? } execute(source, powertool.get(Action.USE), PlaceholderContext.of(player)); + //? if >= 1.21.4 { + /*return InteractionResult.CONSUME; + *///? } else { return InteractionResultHolder.consume(stack); + //? } } } } + //? if >= 1.21.4 { + /*return InteractionResult.PASS; + *///? } else { return InteractionResultHolder.pass(stack); + //? } }); // ATTACK_BLOCK @@ -65,7 +82,11 @@ public void init() { if (data.powerTools.containsKey(itemId)) { var powertool = data.powerTools.get(itemId); if (powertool.containsKey(Action.ATTACK_BLOCK)) { + //? if >= 1.21.4 { + /*var source = player.createCommandSourceStackForNameResolution(((ServerLevel) player.level())); + *///? } else { var source = player.createCommandSourceStack(); + //? } execute(source, powertool.get(Action.ATTACK_BLOCK), PlaceholderContext.of(player)); return InteractionResult.CONSUME; @@ -84,7 +105,11 @@ public void init() { if (data.powerTools.containsKey(itemId)) { var powertool = data.powerTools.get(itemId); if (powertool.containsKey(Action.ATTACK_ENTITY)) { + //? if >= 1.21.4 { + /*var source = player.createCommandSourceStackForNameResolution(((ServerLevel) player.level())); + *///? } else { var source = player.createCommandSourceStack(); + //? } execute(source, powertool.get(Action.ATTACK_ENTITY), PlaceholderContext.of(entity)); return InteractionResult.CONSUME; @@ -103,7 +128,11 @@ public void init() { if (data.powerTools.containsKey(itemId)) { var powertool = data.powerTools.get(itemId); if (powertool.containsKey(Action.INTERACT_BLOCK)) { + //? if >= 1.21.4 { + /*var source = player.createCommandSourceStackForNameResolution(((ServerLevel) player.level())); + *///? } else { var source = player.createCommandSourceStack(); + //? } execute(source, powertool.get(Action.INTERACT_BLOCK), PlaceholderContext.of(player)); return InteractionResult.CONSUME; @@ -122,7 +151,11 @@ public void init() { if (data.powerTools.containsKey(itemId)) { var powertool = data.powerTools.get(itemId); if (powertool.containsKey(Action.INTERACT_ENTITY)) { + //? if >= 1.21.4 { + /*var source = player.createCommandSourceStackForNameResolution(((ServerLevel) player.level())); + *///? } else { var source = player.createCommandSourceStack(); + //? } execute(source, powertool.get(Action.INTERACT_ENTITY), PlaceholderContext.of(entity)); return InteractionResult.CONSUME; diff --git a/src/main/java/me/alexdevs/solstice/modules/rtp/commands/RTPCommand.java b/src/main/java/me/alexdevs/solstice/modules/rtp/commands/RTPCommand.java index c04e6461..5dc4c15a 100644 --- a/src/main/java/me/alexdevs/solstice/modules/rtp/commands/RTPCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/rtp/commands/RTPCommand.java @@ -6,8 +6,8 @@ import me.alexdevs.solstice.Solstice; import me.alexdevs.solstice.api.module.ModCommand; //? if >= 1.21.1 { -/*import me.alexdevs.solstice.api.utils.RegistryUtils;*/ -//? } +/*import me.alexdevs.solstice.api.utils.RegistryUtils; +*///? } import me.alexdevs.solstice.modules.rtp.RTPModule; import me.alexdevs.solstice.modules.rtp.core.Locator; import me.lucko.fabric.api.permissions.v0.Permissions; @@ -48,8 +48,8 @@ public LiteralArgumentBuilder command(String name) { if (Permissions.check(context.getSource(), getPermissionNode("exempt.biome"), 2)) { //? if >= 1.21.1 { /*var biomeRegistry = this.commandRegistry.lookup(Registries.BIOME); - var biomes = RegistryUtils.getBiomes(biomeRegistry.get(), false);*/ - //? } else { + var biomes = RegistryUtils.getBiomes(biomeRegistry.get(), false); + *///? } else { var biomeRegistry = this.commandRegistry.holderLookup(Registries.BIOME); var biomes = biomeRegistry.listElements().map(r -> r.unwrapKey().get().location().toString()).toList(); //? } diff --git a/src/main/java/me/alexdevs/solstice/modules/rtp/core/Locator.java b/src/main/java/me/alexdevs/solstice/modules/rtp/core/Locator.java index 79a77371..c04fcc1b 100644 --- a/src/main/java/me/alexdevs/solstice/modules/rtp/core/Locator.java +++ b/src/main/java/me/alexdevs/solstice/modules/rtp/core/Locator.java @@ -122,7 +122,11 @@ private BlockPos getTopBlock(BlockPos pos) { } private BlockPos getEmptySpace(BlockPos pos) { + //? if >= 1.21.4 { + /*var bottom = chunk.getMinY(); + *///? } else { var bottom = chunk.getMinBuildHeight(); + //? } var top = world.getLogicalHeight(); var blockPos = new BlockPos.MutableBlockPos(pos.getX(), top, pos.getZ()); @@ -151,10 +155,18 @@ private void findValidPlacement() { var dx = i % 16; var dz = i / 16; + //? if >= 1.21.4 { + /*pos = chunk.getPos().getBlockAt(dx, chunk.getMinY(), dz); + *///? } else { pos = chunk.getPos().getBlockAt(dx, chunk.getMinBuildHeight(), dz); + //? } } + //? if >= 1.21.4 { + /*if (pos.getY() <= chunk.getMinY()) { + *///? } else { if (pos.getY() <= chunk.getMinBuildHeight()) { + //? } callback.accept(new Result(Result.Type.UNSAFE, Optional.empty())); return; } @@ -176,8 +188,8 @@ private Optional getChunk(ChunkPos pos) { return Optional.empty(); } else { //? if >= 1.21.1 { - /*var chunk = holder.getFullChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).orElse(null);*/ - //? } else { + /*var chunk = holder.getFullChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).orElse(null); + *///? } else { var chunk = holder.getFullChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).left().orElse(null); //? } if (chunk == null) { diff --git a/src/main/java/me/alexdevs/solstice/modules/rtp/data/RTPConfig.java b/src/main/java/me/alexdevs/solstice/modules/rtp/data/RTPConfig.java index f450676b..9c458697 100644 --- a/src/main/java/me/alexdevs/solstice/modules/rtp/data/RTPConfig.java +++ b/src/main/java/me/alexdevs/solstice/modules/rtp/data/RTPConfig.java @@ -68,8 +68,8 @@ public class RTPConfig { public List> parseBiomes() { //? if >= 1.21.1 { - /*return prohibitedBiomes.stream().map(biomeId -> ResourceKey.create(Registries.BIOME, ResourceLocation.parse(biomeId))).toList();*/ - //? } else { + /*return prohibitedBiomes.stream().map(biomeId -> ResourceKey.create(Registries.BIOME, ResourceLocation.parse(biomeId))).toList(); + *///? } else { return prohibitedBiomes.stream().map(biomeId -> ResourceKey.create(Registries.BIOME, ResourceLocation.tryParse(biomeId))).toList(); //? } } diff --git a/src/main/java/me/alexdevs/solstice/modules/skull/SkullModule.java b/src/main/java/me/alexdevs/solstice/modules/skull/SkullModule.java index 226742df..be7cfbba 100644 --- a/src/main/java/me/alexdevs/solstice/modules/skull/SkullModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/skull/SkullModule.java @@ -2,13 +2,13 @@ import com.mojang.authlib.GameProfile; //? if >= 1.21.1 { -/*import com.mojang.authlib.properties.PropertyMap;*/ -//? } +/*import com.mojang.authlib.properties.PropertyMap; +*///? } import me.alexdevs.solstice.api.module.ModuleBase; import me.alexdevs.solstice.modules.skull.commands.SkullCommand; //? if >= 1.21.1 { -/*import net.minecraft.core.component.DataComponents;*/ -//? } +/*import net.minecraft.core.component.DataComponents; +*///? } //? if < 1.21.1 { import net.minecraft.nbt.StringTag; //? } @@ -19,12 +19,12 @@ import net.minecraft.world.item.PlayerHeadItem; //? } //? if >= 1.21.1 { -/*import net.minecraft.world.item.component.ResolvableProfile;*/ -//? } +/*import net.minecraft.world.item.component.ResolvableProfile; +*///? } //? if >= 1.21.1 { -/*import java.util.Optional;*/ -//? } +/*import java.util.Optional; +*///? } import java.util.UUID; public class SkullModule extends ModuleBase.Toggleable { @@ -43,8 +43,8 @@ public ItemStack createSkull(String name) { var skull = Items.PLAYER_HEAD.getDefaultInstance(); name = name.substring(0, Math.min(name.length(), 16)); //? if >= 1.21.1 { - /*skull.set(DataComponents.PROFILE, new ResolvableProfile(Optional.of(name), Optional.empty(), new PropertyMap()));*/ - //? } else { + /*skull.set(DataComponents.PROFILE, new ResolvableProfile(Optional.of(name), Optional.empty(), new PropertyMap())); + *///? } else { skull.addTagElement(PlayerHeadItem.TAG_SKULL_OWNER, StringTag.valueOf(name)); //? } return skull; @@ -54,8 +54,8 @@ public ItemStack createSkull(UUID uuid) { //? if >= 1.21.1 { /*var skull = Items.PLAYER_HEAD.getDefaultInstance(); skull.set(DataComponents.PROFILE, new ResolvableProfile(Optional.empty(), Optional.of(uuid), new PropertyMap())); - return skull;*/ - //? } else { + return skull; + *///? } else { return createSkull(uuid.toString()); // :shrug: //? } } @@ -64,8 +64,8 @@ public ItemStack createSkull(GameProfile profile) { //? if >= 1.21.1 { /*var skull = Items.PLAYER_HEAD.getDefaultInstance(); skull.set(DataComponents.PROFILE, new ResolvableProfile(profile)); - return skull;*/ - //? } else { + return skull; + *///? } else { return createSkull(profile.getName()); //? } } diff --git a/src/main/java/me/alexdevs/solstice/modules/smite/commands/SmiteCommand.java b/src/main/java/me/alexdevs/solstice/modules/smite/commands/SmiteCommand.java index 68b0e8f3..f277afb0 100644 --- a/src/main/java/me/alexdevs/solstice/modules/smite/commands/SmiteCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/smite/commands/SmiteCommand.java @@ -12,7 +12,11 @@ import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.EntityType; +//? if >= 1.21.4 { +/*import net.minecraft.world.entity.EntitySpawnReason; +*///? } else { import net.minecraft.world.entity.MobSpawnType; +//? } import net.minecraft.world.phys.HitResult; import java.util.List; @@ -88,7 +92,11 @@ private void summon(ServerLevel world, BlockPos pos) { //? } world::addFreshEntity, pos, + //? if >= 1.21.4 { + /*EntitySpawnReason.COMMAND, + *///? } else { MobSpawnType.COMMAND, + //? } false, false); } diff --git a/src/main/java/me/alexdevs/solstice/modules/spawn/SpawnModule.java b/src/main/java/me/alexdevs/solstice/modules/spawn/SpawnModule.java index 7032a422..145f30d9 100644 --- a/src/main/java/me/alexdevs/solstice/modules/spawn/SpawnModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/spawn/SpawnModule.java @@ -89,8 +89,8 @@ public ServerLevel getGlobalSpawnWorld() { var targetWorld = getConfig().globalSpawn.targetSpawnWorld; //? if >= 1.21.1 { - /*var key = ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(targetWorld));*/ - //? } else { + /*var key = ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(targetWorld)); + *///? } else { var key = ResourceKey.create(Registries.DIMENSION, ResourceLocation.tryParse(targetWorld)); //? } return Solstice.server.getLevel(key); diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java b/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java index fa8c00eb..47aa26c2 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java @@ -23,7 +23,7 @@ private static ChatFormatting getFormatting(TextColor color) { } private final ServerPlayer player; public CustomPlayerTeam(Scoreboard scoreboard, ServerPlayer player) { - super(scoreboard, player.getGameProfile().getName()); + super(scoreboard, "sol_" + player.getGameProfile().getName()); this.player = player; super.getPlayers().add(player.getGameProfile().getName()); } @@ -46,8 +46,8 @@ public Component getPlayerSuffix() { public Collection getPlayers() { return List.of(player.getGameProfile().getName()); } -}*/ -//? } else { +} +*///? } else { package me.alexdevs.solstice.modules.styling; import me.alexdevs.solstice.modules.ModuleProvider; import net.minecraft.ChatFormatting; diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/CustomSentMessage.java b/src/main/java/me/alexdevs/solstice/modules/styling/CustomSentMessage.java index b1bb1bea..897207e1 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/CustomSentMessage.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/CustomSentMessage.java @@ -66,8 +66,8 @@ public void sendToPlayer(ServerPlayer receiver, boolean filterMaskEnabled, ChatT } //? if >= 1.21.1 { - /*switch (params.chatType().value().chat().translationKey()) {*/ - //? } else { + /*switch (params.chatType().value().chat().translationKey()) { + *///? } else { switch (params.chatType().chat().translationKey()) { //? } case "chat.type.text": diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/StylingModule.java b/src/main/java/me/alexdevs/solstice/modules/styling/StylingModule.java index 4e6b6e76..73e874cb 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/StylingModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/StylingModule.java @@ -30,8 +30,8 @@ public class StylingModule extends ModuleBase.Toggleable { public static final String SILENT_ACTIVITY_PERMISSION = "solstice.chat.activity.silent"; //? if >= 1.21.1 { - /*private static final StylingConfig.NameplateFormat DEFAULT_NAMEPLATE = new StylingConfig.NameplateFormat("", "");*/ - //? } else { + /*private static final StylingConfig.NameplateFormat DEFAULT_NAMEPLATE = new StylingConfig.NameplateFormat("", ""); + *///? } else { private static final StylingConfig.NameplateFormat DEFAULT_NAMEPLATE = new StylingConfig.NameplateFormat("", "", "WHITE"); //? } @@ -70,8 +70,8 @@ public void init() { for (var player : playerList.getPlayers()) { playerList.updateEntireScoreboard(scoreboard, player); } - });*/ - //? } else { + }); + *///? } else { SolsticeEvents.RELOAD.register(instance -> reloadNameplates(false)); Solstice.scheduler.scheduleAtFixedRateSync(() -> reloadNameplates(false), 0, 1, TimeUnit.SECONDS); //? } @@ -112,8 +112,8 @@ public void broadcastActivity(PlayerList playerList, Component component, boolea //? if >= 1.21.1 { /*public boolean shouldColorNameplate() { return getConfig().doColorNameplate; - }*/ - //? } else { + } + *///? } else { public ChatFormatting getNameplateColor(ServerPlayer player) { var config = getConfig(); var primaryGroup = LuckPermsIntegration.getPrimaryGroup(player); diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/data/StylingConfig.java b/src/main/java/me/alexdevs/solstice/modules/styling/data/StylingConfig.java index 651044d9..a17fc75c 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/data/StylingConfig.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/data/StylingConfig.java @@ -41,16 +41,16 @@ public class StylingConfig { @Comment("Nameplate formatting per group. group = format.\nPlaceholders here are not refreshed often.") public Map nameplateFormats = Map.of( //? if >= 1.21.1 { - /*"default", new NameplateFormat("", "")*/ - //? } else { + /*"default", new NameplateFormat("", "") + *///? } else { "default", new NameplateFormat("", "", "green") //? } ); //? if >= 1.21.1 { /*@Comment("Whether to color the username part in the nameplate of players.") - public boolean doColorNameplate = true;*/ - //? } + public boolean doColorNameplate = true; + *///? } @Comment("Emote format (/me)") public String emoteFormat = "\uD83D\uDC64 %player:displayname% ${message}"; @@ -72,8 +72,8 @@ public class StylingConfig { @ConfigSerializable //? if >= 1.21.1 { - /*public record NameplateFormat(String prefix, String suffix) { }*/ - //? } else { + /*public record NameplateFormat(String prefix, String suffix) { } + *///? } else { public record NameplateFormat(String prefix, String suffix, String color) { } //? } } diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java b/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java index 12ce7855..bd91455e 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java @@ -2,15 +2,15 @@ import eu.pb4.placeholders.api.PlaceholderContext; //? if >= 1.21.1 { -/*import me.alexdevs.solstice.Solstice;*/ -//? } +/*import me.alexdevs.solstice.Solstice; +*///? } import me.alexdevs.solstice.api.text.Format; import me.alexdevs.solstice.modules.ModuleProvider; //? if >= 1.21.1 { /*import me.alexdevs.solstice.modules.styling.StylingModule; import net.minecraft.advancements.AdvancementHolder; -import net.minecraft.advancements.AdvancementType;*/ -//? } else { +import net.minecraft.advancements.AdvancementType; +*///? } else { import net.minecraft.advancements.Advancement; //? } import net.minecraft.network.chat.Component; @@ -23,8 +23,8 @@ public class AdvancementFormatter { /*public static Component getText(ServerPlayer player, AdvancementHolder entry, AdvancementType frame) { var title = entry.value().display().get().getTitle(); var description = entry.value().display().get().getDescription(); - var frameId = frame.getSerializedName();*/ - //? } else { + var frameId = frame.getSerializedName(); + *///? } else { public static Component getText(ServerPlayer player, Advancement advancement) { var frame = advancement.getDisplay().getFrame(); var frameId = frame.getName(); @@ -39,8 +39,8 @@ public static Component getText(ServerPlayer player, Advancement advancement) { case GOAL -> config.advancementGoal; case CHALLENGE -> config.advancementChallenge; case TASK -> config.advancementTask; - };*/ - //? } else { + }; + *///? } else { String advancementFormat = switch (frame) { case GOAL -> config.advancementGoal; case CHALLENGE -> config.advancementChallenge; @@ -52,8 +52,8 @@ public static Component getText(ServerPlayer player, Advancement advancement) { Map placeholders = Map.of( //? if >= 1.21.1 { - /*"frame", frame.getDisplayName(),*/ - //? } else { + /*"frame", frame.getDisplayName(), + *///? } else { "frame", frame.getDisplayName(), //? } "title", title, diff --git a/src/main/java/me/alexdevs/solstice/modules/sudo/commands/DoAsCommand.java b/src/main/java/me/alexdevs/solstice/modules/sudo/commands/DoAsCommand.java index 726e46cb..1b1785ef 100644 --- a/src/main/java/me/alexdevs/solstice/modules/sudo/commands/DoAsCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/sudo/commands/DoAsCommand.java @@ -75,7 +75,11 @@ public LiteralArgumentBuilder command(String name) { CommandSource commandOutput; if (context.getSource().isPlayer()) { + //? if >= 1.21.4 { + /*commandOutput = context.getSource().getPlayer().commandSource(); + *///? } else { commandOutput = context.getSource().getPlayer(); + //? } } else { commandOutput = context.getSource().getServer(); } diff --git a/src/main/java/me/alexdevs/solstice/modules/sudo/commands/SudoCommand.java b/src/main/java/me/alexdevs/solstice/modules/sudo/commands/SudoCommand.java index da8f1c48..7dfe2760 100644 --- a/src/main/java/me/alexdevs/solstice/modules/sudo/commands/SudoCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/sudo/commands/SudoCommand.java @@ -52,7 +52,11 @@ public LiteralArgumentBuilder command(String name) { CommandSource commandOutput; if (context.getSource().isPlayer()) { + //? if >= 1.21.4 { + /*commandOutput = context.getSource().getPlayer().commandSource(); + *///? } else { commandOutput = context.getSource().getPlayer(); + //? } } else { commandOutput = context.getSource().getServer(); } diff --git a/src/main/java/me/alexdevs/solstice/modules/suicide/commands/SuicideCommand.java b/src/main/java/me/alexdevs/solstice/modules/suicide/commands/SuicideCommand.java index acc15bdf..c11a3393 100644 --- a/src/main/java/me/alexdevs/solstice/modules/suicide/commands/SuicideCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/suicide/commands/SuicideCommand.java @@ -26,7 +26,11 @@ public LiteralArgumentBuilder command(String name) { .executes(context -> { var player = context.getSource().getPlayerOrException(); + //? if >= 1.21.4 { + /*player.kill(player.serverLevel()); + *///? } else { player.kill(); + //? } return 1; }); diff --git a/src/main/java/me/alexdevs/solstice/modules/teleportHere/commands/TeleportHereCommand.java b/src/main/java/me/alexdevs/solstice/modules/teleportHere/commands/TeleportHereCommand.java index 29cd2acf..9ca260f4 100644 --- a/src/main/java/me/alexdevs/solstice/modules/teleportHere/commands/TeleportHereCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/teleportHere/commands/TeleportHereCommand.java @@ -39,7 +39,11 @@ public LiteralArgumentBuilder command(String name) { var targets = EntityArgument.getEntities(context, "targets"); targets.forEach(target -> { + //? if >= 1.21.4 { + /*target.teleportTo(world, vec3d.x, vec3d.y, vec3d.z, Set.of(), yaw, pitch, false); + *///? } else { target.teleportTo(world, vec3d.x, vec3d.y, vec3d.z, Set.of(), yaw, pitch); + //? } target.setDeltaMovement(target.getDeltaMovement().multiply(1.0, 0.0, 1.0)); target.setOnGround(true); From 5e91535ed90923596d507cc3d085b876dce7f8cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nelson=20Gra=C3=A7a?= Date: Tue, 24 Mar 2026 22:39:19 +0000 Subject: [PATCH 4/6] Some fixes --- .../modules/spawn/OverrideSpawnPointMixin.java | 8 ++++---- .../modules/styling/CustomNameplateMixin.java | 2 ++ .../modules/styling/CustomPlayerTeam.java | 2 +- .../styling/formatters/AdvancementFormatter.java | 15 +-------------- stonecutter.gradle.kts | 2 +- 5 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java index 49c8768a..270fb8bb 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java @@ -14,8 +14,8 @@ import net.minecraft.world.level.portal.DimensionTransition; import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Shadow;*/ -//? } else { +import org.spongepowered.asm.mixin.Shadow; +*///? } else { import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.player.Player; import net.minecraft.world.phys.Vec3; @@ -78,8 +78,8 @@ public abstract class OverrideSpawnPointMixin { if (config.globalSpawn.onRespawnSoft && respawnPosition == null) { cir.setReturnValue(transition); } - }*/ - //? } else { + } + *///? } else { @Inject(method = "findRespawnPositionAndUseSpawnBlock", at = @At("RETURN"), cancellable = true) private static void solstice$overrideSpawnPos(ServerLevel level, BlockPos pos, float angle, boolean forced, boolean alive, CallbackInfoReturnable> cir) { var spawnModule = ModuleProvider.SPAWN; diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java index 3d3066db..d0f86d6b 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java @@ -1,6 +1,8 @@ package me.alexdevs.solstice.mixin.modules.styling; +//? if < 1.21.1 { import me.alexdevs.solstice.modules.ModuleProvider; +//? } //? if >= 1.21.1 { /*import me.alexdevs.solstice.modules.styling.CustomPlayerTeam; import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket; diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java b/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java index 47aa26c2..26202ed2 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java @@ -62,7 +62,7 @@ public Collection getPlayers() { public class CustomPlayerTeam extends PlayerTeam { private final ServerPlayer player; public CustomPlayerTeam(Scoreboard scoreboard, ServerPlayer player) { - super(scoreboard, player.getGameProfile().getName()); + super(scoreboard, "sol_" + player.getGameProfile().getName()); this.player = player; super.getPlayers().add(player.getGameProfile().getName()); } diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java b/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java index bd91455e..fa7b3b64 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java @@ -1,14 +1,10 @@ package me.alexdevs.solstice.modules.styling.formatters; import eu.pb4.placeholders.api.PlaceholderContext; -//? if >= 1.21.1 { -/*import me.alexdevs.solstice.Solstice; -*///? } import me.alexdevs.solstice.api.text.Format; import me.alexdevs.solstice.modules.ModuleProvider; //? if >= 1.21.1 { -/*import me.alexdevs.solstice.modules.styling.StylingModule; -import net.minecraft.advancements.AdvancementHolder; +/*import net.minecraft.advancements.AdvancementHolder; import net.minecraft.advancements.AdvancementType; *///? } else { import net.minecraft.advancements.Advancement; @@ -23,7 +19,6 @@ public class AdvancementFormatter { /*public static Component getText(ServerPlayer player, AdvancementHolder entry, AdvancementType frame) { var title = entry.value().display().get().getTitle(); var description = entry.value().display().get().getDescription(); - var frameId = frame.getSerializedName(); *///? } else { public static Component getText(ServerPlayer player, Advancement advancement) { var frame = advancement.getDisplay().getFrame(); @@ -34,19 +29,11 @@ public static Component getText(ServerPlayer player, Advancement advancement) { var config = ModuleProvider.STYLING.getConfig(); - //? if >= 1.21.1 { - /*String advancementFormat = switch (frame) { - case GOAL -> config.advancementGoal; - case CHALLENGE -> config.advancementChallenge; - case TASK -> config.advancementTask; - }; - *///? } else { String advancementFormat = switch (frame) { case GOAL -> config.advancementGoal; case CHALLENGE -> config.advancementChallenge; case TASK -> config.advancementTask; }; - //? } var playerContext = PlaceholderContext.of(player); diff --git a/stonecutter.gradle.kts b/stonecutter.gradle.kts index 608a157e..1c94c009 100644 --- a/stonecutter.gradle.kts +++ b/stonecutter.gradle.kts @@ -1,4 +1,4 @@ plugins { id("dev.kikugie.stonecutter") } -stonecutter active "1.20.1" \ No newline at end of file +stonecutter active "1.20.1" From 7304a7530025426fb0d36cecea780d88460be20e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nelson=20Gra=C3=A7a?= Date: Wed, 25 Mar 2026 18:52:16 +0000 Subject: [PATCH 5/6] cleanup for better readability --- settings.gradle.kts | 2 +- .../java/me/alexdevs/solstice/Solstice.java | 7 +- .../alexdevs/solstice/api/ServerLocation.java | 21 ++--- .../api/text/tag/PhaseGradientTag.java | 18 ++-- .../solstice/api/utils/EntityUtils.java | 31 +++++++ .../solstice/api/utils/ItemUtils.java | 89 +++++++++++++++++++ .../solstice/api/utils/PlayerUtils.java | 15 ++-- .../solstice/api/utils/ResourceUtils.java | 21 +++++ .../core/coreModule/commands/PingCommand.java | 22 ++--- .../mixin/events/CommandEventsMixin.java | 19 +--- .../mixin/modules/back/PreTeleportMixin.java | 12 +-- .../mixin/modules/core/RealPingMixin.java | 34 +++---- .../OverrideNewPlayerSpawnPointMixin.java | 26 +++--- .../spawn/OverrideSpawnPointLevelMixin.java | 4 +- .../spawn/OverrideSpawnPointMixin.java | 49 +++++----- .../styling/CustomAdvancementMixin.java | 44 ++++----- .../CustomConnectionMessagesMixin.java | 22 +++-- .../modules/styling/CustomNameplateMixin.java | 16 ++-- .../styling/PlayerDisconnectMixin.java | 9 +- .../solstice/modules/afk/AfkModule.java | 22 +++-- .../ignore/commands/IgnoreCommand.java | 10 +-- .../commands/InventorySeeCommand.java | 24 ++--- .../item/commands/ItemLoreCommand.java | 48 ++-------- .../item/commands/ItemNameCommand.java | 23 +---- .../modules/item/commands/RepairCommand.java | 10 +-- .../solstice/modules/jail/JailModule.java | 45 ++++------ .../alexdevs/solstice/modules/kit/Utils.java | 27 +++--- .../modules/kit/commands/KitsCommand.java | 29 +----- .../commands/EffectsCommand.java | 9 +- .../commands/KittyCannonCommand.java | 18 +--- .../miscellaneous/commands/SpeedCommand.java | 18 ++-- .../placeholders/PlaceholdersModule.java | 19 +--- .../modules/powertool/PowerToolModule.java | 52 +++++------ .../modules/rtp/commands/RTPCommand.java | 12 +-- .../solstice/modules/rtp/core/Locator.java | 34 +++---- .../solstice/modules/rtp/data/RTPConfig.java | 10 +-- .../solstice/modules/skull/SkullModule.java | 44 ++------- .../modules/smite/commands/SmiteCommand.java | 21 +---- .../solstice/modules/spawn/SpawnModule.java | 7 +- .../modules/styling/CustomPlayerTeam.java | 77 +++++++--------- .../modules/styling/CustomSentMessage.java | 9 +- .../modules/styling/StylingModule.java | 41 ++++----- .../modules/styling/data/StylingConfig.java | 23 +++-- .../formatters/AdvancementFormatter.java | 27 +++--- .../modules/sudo/commands/DoAsCommand.java | 21 ++--- .../modules/sudo/commands/SudoCommand.java | 11 +-- .../suicide/commands/SuicideCommand.java | 7 +- stonecutter.gradle.kts | 2 +- 48 files changed, 525 insertions(+), 636 deletions(-) create mode 100644 src/main/java/me/alexdevs/solstice/api/utils/EntityUtils.java create mode 100644 src/main/java/me/alexdevs/solstice/api/utils/ItemUtils.java create mode 100644 src/main/java/me/alexdevs/solstice/api/utils/ResourceUtils.java diff --git a/settings.gradle.kts b/settings.gradle.kts index 74c2d5d7..6e8b8034 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,7 +21,7 @@ plugins { stonecutter { create(rootProject) { versions("1.20.1", "1.21.1", "1.21.4") - vcsVersion = "1.20.1" + vcsVersion = "1.21.1" } } diff --git a/src/main/java/me/alexdevs/solstice/Solstice.java b/src/main/java/me/alexdevs/solstice/Solstice.java index 0b911a34..ee187eeb 100644 --- a/src/main/java/me/alexdevs/solstice/Solstice.java +++ b/src/main/java/me/alexdevs/solstice/Solstice.java @@ -10,6 +10,7 @@ import me.alexdevs.solstice.integrations.ConnectorIntegration; import me.alexdevs.solstice.integrations.LuckPermsIntegration; import me.alexdevs.solstice.locale.LocaleManager; +import me.alexdevs.solstice.api.utils.ResourceUtils; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; @@ -28,11 +29,7 @@ public class Solstice implements ModInitializer { public static final String MOD_ID = "solstice"; public static final Logger LOGGER = LoggerFactory.getLogger(Solstice.class); - //? if >= 1.21.1 { - /*public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(MOD_ID, ""); - *///? } else { - public static final ResourceLocation ID = new ResourceLocation(MOD_ID, ""); - //? } + public static final ResourceLocation ID = ResourceUtils.location(MOD_ID, ""); public static final IConfigDataManager configManager = new ConfigDataManager(Paths.configDirectory.resolve("config.conf")); public static final LocaleManager localeManager = new LocaleManager(Paths.configDirectory.resolve("locale.json")); diff --git a/src/main/java/me/alexdevs/solstice/api/ServerLocation.java b/src/main/java/me/alexdevs/solstice/api/ServerLocation.java index 8bb9cc04..563ed1e8 100644 --- a/src/main/java/me/alexdevs/solstice/api/ServerLocation.java +++ b/src/main/java/me/alexdevs/solstice/api/ServerLocation.java @@ -2,11 +2,11 @@ import com.google.common.collect.ImmutableList; import me.alexdevs.solstice.modules.ModuleProvider; +import me.alexdevs.solstice.api.utils.ResourceUtils; import net.minecraft.core.BlockPos; import net.minecraft.core.Vec3i; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -16,9 +16,9 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.phys.Vec3; -//? if >= 1.21.4 { -/*import java.util.Set; -*///? } + +//? >= 1.21.4 +//import java.util.Set; import java.util.Objects; @@ -83,11 +83,10 @@ public void teleport(ServerPlayer player, boolean setBackPosition) { player.setDeltaMovement(player.getDeltaMovement().multiply(1f, 0f, 1f)); player.setOnGround(true); - //? if >= 1.21.4 { - /*player.teleportTo(serverWorld, this.getX(), this.getY(), this.getZ(), Set.of(), this.getYaw(), this.getPitch(), false); - *///? } else { + //? >= 1.21.4 + //player.teleportTo(serverWorld, this.getX(), this.getY(), this.getZ(), Set.of(), this.getYaw(), this.getPitch(), false); + //? < 1.21.4 player.teleportTo(serverWorld, this.getX(), this.getY(), this.getZ(), this.getYaw(), this.getPitch()); - //? } // There is a bug (presumably in Fabric's api) that causes experience level to be set to 0 when teleporting between dimensions/worlds. // Therefore, this will update the experience client side as a temporary solution. @@ -99,11 +98,7 @@ public void teleport(ServerPlayer player) { } public ResourceKey getWorldKey() { - //? if >= 1.21.1 { - /*return ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(this.getWorld())); - *///? } else { - return ResourceKey.create(Registries.DIMENSION, ResourceLocation.tryParse(this.getWorld())); - //? } + return ResourceKey.create(Registries.DIMENSION, ResourceUtils.parse(this.getWorld())); } public ServerLevel getWorld(MinecraftServer server) { diff --git a/src/main/java/me/alexdevs/solstice/api/text/tag/PhaseGradientTag.java b/src/main/java/me/alexdevs/solstice/api/text/tag/PhaseGradientTag.java index 2bfd2074..fad460f8 100644 --- a/src/main/java/me/alexdevs/solstice/api/text/tag/PhaseGradientTag.java +++ b/src/main/java/me/alexdevs/solstice/api/text/tag/PhaseGradientTag.java @@ -47,18 +47,16 @@ public static TextParserV1.TextTag createTag() { } var parsedColor = TextColor.parseColor(arg); - //? if >= 1.21.1 { - /*if (parsedColor.isError()) { - *///? } else { - if (parsedColor == null) { - //? } + //? >= 1.21.1 + if (parsedColor.isError()) { + //? < 1.21.1 + //if (parsedColor == null) { textColors.add(TextColor.fromRgb(0)); } else { - //? if >= 1.21.1 { - /*textColors.add(parsedColor.getOrThrow()); - *///? } else { - textColors.add(parsedColor); - //? } + //? >= 1.21.1 + textColors.add(parsedColor.getOrThrow()); + //? < 1.21.1 + //textColors.add(parsedColor); } } diff --git a/src/main/java/me/alexdevs/solstice/api/utils/EntityUtils.java b/src/main/java/me/alexdevs/solstice/api/utils/EntityUtils.java new file mode 100644 index 00000000..dce5751c --- /dev/null +++ b/src/main/java/me/alexdevs/solstice/api/utils/EntityUtils.java @@ -0,0 +1,31 @@ +package me.alexdevs.solstice.api.utils; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import org.jetbrains.annotations.Nullable; +import java.util.function.Consumer; + +//? >= 1.21.4 +//import net.minecraft.world.entity.EntitySpawnReason; +//? < 1.21.4 +import net.minecraft.world.entity.MobSpawnType; + + +public class EntityUtils { + public static @Nullable T createWithCommand( + EntityType type, ServerLevel world, @Nullable Consumer consumer, + BlockPos pos, boolean particleEffects, boolean limitedLifespan) { + + final var spawnReason = + //? >= 1.21.4 + //EntitySpawnReason.COMMAND; + //? <1.21.4 + MobSpawnType.COMMAND; + + return type.create(world, + //? < 1.21.1 + //null, + consumer, pos, spawnReason, particleEffects, limitedLifespan); + } +} diff --git a/src/main/java/me/alexdevs/solstice/api/utils/ItemUtils.java b/src/main/java/me/alexdevs/solstice/api/utils/ItemUtils.java new file mode 100644 index 00000000..6734cc3a --- /dev/null +++ b/src/main/java/me/alexdevs/solstice/api/utils/ItemUtils.java @@ -0,0 +1,89 @@ +package me.alexdevs.solstice.api.utils; +import com.mojang.authlib.GameProfile; +//? if >= 1.21.1 { +import com.mojang.authlib.properties.PropertyMap; +import net.minecraft.core.component.DataComponents; +import net.minecraft.world.item.component.ItemLore; +import net.minecraft.world.item.component.ResolvableProfile; +import java.util.Optional; +//? } else { +/*import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.StringTag; +import net.minecraft.world.item.PlayerHeadItem; +*///? } +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ItemStack; +import java.util.List; +import java.util.UUID; +public class ItemUtils { + public static void setCustomName(ItemStack stack, Component name) { + //? >= 1.21.1 + stack.set(DataComponents.CUSTOM_NAME, name); + //? < 1.21.1 + //stack.setHoverName(name); + } + public static void removeCustomName(ItemStack stack) { + //? >= 1.21.1 + stack.remove(DataComponents.CUSTOM_NAME); + //? < 1.21.1 + //stack.resetHoverName(); + } + public static void setLore(ItemStack stack, List lines) { + //? if >= 1.21.1 { + stack.set(DataComponents.LORE, new ItemLore(lines)); + //? } else { + /*var list = new ListTag(); + for (var line : lines) { + list.add(StringTag.valueOf(Component.Serializer.toJson(line))); + } + var displayNbt = stack.getOrCreateTagElement("display"); + displayNbt.put("Lore", list); + *///? } + } + public static void removeLore(ItemStack stack) { + //? if >= 1.21.1 { + stack.remove(DataComponents.LORE); + //? } else { + /*var nbtCompound = stack.getTagElement("display"); + if (nbtCompound != null) { + nbtCompound.remove("Lore"); + if (nbtCompound.isEmpty()) { + stack.removeTagKey("display"); + } + } + *///? } + } + public static void removeDamage(ItemStack stack) { + //? >= 1.21.1 + stack.remove(DataComponents.DAMAGE); + //? < 1.21.1 + //stack.removeTagKey("Damage"); + } + public static void setGlint(ItemStack stack, boolean value) { + //? if >= 1.21.1 { + stack.set(DataComponents.ENCHANTMENT_GLINT_OVERRIDE, value); + //? } else { + /*if (value) { + stack.getOrCreateTag().put("Enchantments", new ListTag()); + } + *///? } + } + public static void setProfileByName(ItemStack stack, String name) { + //? >= 1.21.1 + stack.set(DataComponents.PROFILE,new ResolvableProfile(Optional.of(name), Optional.empty(), new PropertyMap())); + //? < 1.21.1 + //stack.addTagElement(PlayerHeadItem.TAG_SKULL_OWNER, StringTag.valueOf(name)); + } + public static void setProfileByUUID(ItemStack stack, UUID uuid) { + //? >= 1.21.1 + stack.set(DataComponents.PROFILE,new ResolvableProfile(Optional.empty(), Optional.of(uuid), new PropertyMap())); + //? < 1.21.1 + //stack.addTagElement(PlayerHeadItem.TAG_SKULL_OWNER, StringTag.valueOf(uuid.toString())); + } + public static void setProfile(ItemStack stack, GameProfile profile) { + //? >= 1.21.1 + stack.set(DataComponents.PROFILE, new ResolvableProfile(profile)); + //? < 1.21.1 + //stack.addTagElement(PlayerHeadItem.TAG_SKULL_OWNER, StringTag.valueOf(profile.getName())); + } +} diff --git a/src/main/java/me/alexdevs/solstice/api/utils/PlayerUtils.java b/src/main/java/me/alexdevs/solstice/api/utils/PlayerUtils.java index d34d65d5..cf6ee5c5 100644 --- a/src/main/java/me/alexdevs/solstice/api/utils/PlayerUtils.java +++ b/src/main/java/me/alexdevs/solstice/api/utils/PlayerUtils.java @@ -3,8 +3,8 @@ import com.mojang.authlib.GameProfile; import me.alexdevs.solstice.Solstice; //? if >= 1.21.1 { -/*import net.minecraft.server.level.ClientInformation; -*///? } +import net.minecraft.server.level.ClientInformation; +//? } import net.minecraft.server.level.ServerPlayer; import java.util.UUID; @@ -19,11 +19,12 @@ public static ServerPlayer loadOfflinePlayer(GameProfile profile) { } var playerManager = Solstice.server.getPlayerList(); - //? if >= 1.21.1 { - /*var player = playerManager.getPlayerForLogin(profile, ClientInformation.createDefault()); - *///? } else { - var player = playerManager.getPlayerForLogin(profile); - //? } + var player = + //? >= 1.21.1 + playerManager.getPlayerForLogin(profile, ClientInformation.createDefault()); + //? < 1.21.1 + //playerManager.getPlayerForLogin(profile); + playerManager.load(player); return player; } diff --git a/src/main/java/me/alexdevs/solstice/api/utils/ResourceUtils.java b/src/main/java/me/alexdevs/solstice/api/utils/ResourceUtils.java new file mode 100644 index 00000000..d89c5457 --- /dev/null +++ b/src/main/java/me/alexdevs/solstice/api/utils/ResourceUtils.java @@ -0,0 +1,21 @@ +package me.alexdevs.solstice.api.utils; + +import net.minecraft.resources.ResourceLocation; + +public class ResourceUtils { + + public static ResourceLocation location(String namespace, String path) { + //? if >= 1.21.1 + return ResourceLocation.fromNamespaceAndPath(namespace, path); + //? if < 1.21.1 + //return new ResourceLocation(namespace, path); + } + + public static ResourceLocation parse(String value) { + //? if >= 1.21.1 + return ResourceLocation.parse(value); + //? if < 1.21.1 + //return ResourceLocation.tryParse(value); + } +} + diff --git a/src/main/java/me/alexdevs/solstice/core/coreModule/commands/PingCommand.java b/src/main/java/me/alexdevs/solstice/core/coreModule/commands/PingCommand.java index f0c664f0..39cc3d99 100644 --- a/src/main/java/me/alexdevs/solstice/core/coreModule/commands/PingCommand.java +++ b/src/main/java/me/alexdevs/solstice/core/coreModule/commands/PingCommand.java @@ -7,6 +7,7 @@ import net.minecraft.commands.Commands; import net.minecraft.commands.arguments.EntityArgument; import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerPlayer; import java.util.List; import java.util.Map; @@ -20,17 +21,20 @@ public List getNames() { return List.of("ping"); } + private static int getLatency(ServerPlayer player) { + //? >= 1.21.1 + return player.connection.latency(); + //? < 1.21.1 + //return player.latency; + } + @Override public LiteralArgumentBuilder command(String name) { return Commands.literal(name) .requires(require("ping.base", true)) .executes(context -> { var player = context.getSource().getPlayerOrException(); - //? if >= 1.21.1 { - /*var ping = player.connection.latency(); - *///? } else { - var ping = player.latency; - //? } + var ping = getLatency(player); var map = Map.of( "ping", Component.nullToEmpty(String.valueOf(ping)) ); @@ -41,12 +45,8 @@ public LiteralArgumentBuilder command(String name) { .requires(require("ping.others", 1)) .executes(context -> { var player = EntityArgument.getPlayer(context, "player"); - //? if >= 1.21.1 { - /*var ping = player.connection.latency(); - *///? } else { - var ping = player.latency; - //? } - var map = Map.of( + var ping = getLatency(player); + var map = Map.of( "ping", Component.nullToEmpty(String.valueOf(ping)), "player", player.getName() ); diff --git a/src/main/java/me/alexdevs/solstice/mixin/events/CommandEventsMixin.java b/src/main/java/me/alexdevs/solstice/mixin/events/CommandEventsMixin.java index 4935f664..97a4cc7b 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/events/CommandEventsMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/events/CommandEventsMixin.java @@ -12,16 +12,15 @@ @Mixin(value = CommandDispatcher.class, remap = false) public abstract class CommandEventsMixin { - // Lcom/mojang/brigadier/CommandDispatcher;parse(Lcom/mojang/brigadier/StringReader;Ljava/lang/Object;)Lcom/mojang/brigadier/ParseResults; @Inject(method = "parse(Lcom/mojang/brigadier/StringReader;Ljava/lang/Object;)Lcom/mojang/brigadier/ParseResults;", at = @At("HEAD"), cancellable = true) public void solstice$interceptCommands(StringReader reader, S sourceGeneric, CallbackInfoReturnable> cir) { if (sourceGeneric instanceof CommandSourceStack source) { var command = reader.getString(); //? if < 1.21.1 { - if(command.startsWith("/")) + /*if(command.startsWith("/")) return; - //? } + *///? } if (!CommandEvents.ALLOW_COMMAND.invoker().allowCommand(source, command)) { cir.cancel(); } @@ -29,18 +28,4 @@ public abstract class CommandEventsMixin { CommandEvents.COMMAND.invoker().onCommand(source, command); } } - - // This isn't working anymore...? - /*@Inject(method = "execute(Lcom/mojang/brigadier/ParseResults;)I", at = @At("HEAD"), remap = false) - public void execute(ParseResults parse, CallbackInfoReturnable cir) throws CommandSyntaxException { - var context = parse.getContext(); - if (context.getSource() instanceof CommandSourceStack source) { - var command = parse.getReader().getString(); - if (!CommandEvents.ALLOW_COMMAND.invoker().allowCommand(source, command)) { - cir.cancel(); - } - - CommandEvents.COMMAND.invoker().onCommand(source, command); - } - }*/ } diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/back/PreTeleportMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/back/PreTeleportMixin.java index 5507b1fe..7d938a5c 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/back/PreTeleportMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/back/PreTeleportMixin.java @@ -3,16 +3,18 @@ import me.alexdevs.solstice.modules.ModuleProvider; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; -//? if >= 1.21.4 { -/*import net.minecraft.world.entity.Relative; -*///? } else { -import net.minecraft.world.entity.RelativeMovement; -//? } import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + import java.util.Set; + +//? >= 1.21.4 +//import net.minecraft.world.entity.Relative; +//? < 1.21.4 +import net.minecraft.world.entity.RelativeMovement; + @Mixin(ServerPlayer.class) public abstract class PreTeleportMixin { //? if >= 1.21.4 { diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/core/RealPingMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/core/RealPingMixin.java index f24e2a8c..d2c7bad9 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/core/RealPingMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/core/RealPingMixin.java @@ -1,35 +1,35 @@ package me.alexdevs.solstice.mixin.modules.core; import com.llamalad7.mixinextras.sugar.Local; -//? if >= 1.21.1 { -/*import net.minecraft.server.network.ServerCommonPacketListenerImpl; -*///? } else { -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.server.network.ServerGamePacketListenerImpl; -//? } import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; -//? if >= 1.21.1 { -/*import org.spongepowered.asm.mixin.Shadow; -*///? } import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; + //? if >= 1.21.1 { -/*@Mixin(ServerCommonPacketListenerImpl.class) -*///? } else { -@Mixin(ServerGamePacketListenerImpl.class) -//? } +import net.minecraft.server.network.ServerCommonPacketListenerImpl; +import org.spongepowered.asm.mixin.Shadow; +//? } else { +/*import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerGamePacketListenerImpl; +*///? } + +//? >= 1.21.1 +@Mixin(ServerCommonPacketListenerImpl.class) +//? < 1.21.1 +//@Mixin(ServerGamePacketListenerImpl.class) + public abstract class RealPingMixin { //? if >= 1.21.1 { - /*@Shadow + @Shadow private int latency; @Redirect(method = "handleKeepAlive", at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerCommonPacketListenerImpl;latency:I", opcode = Opcodes.PUTFIELD)) public void solstice$realPing(ServerCommonPacketListenerImpl instance, int value, @Local int i) { latency = i; } - *///? } else { - @Redirect(method = "handleKeepAlive", at = @At(value = "FIELD", target = "Lnet/minecraft/server/level/ServerPlayer;latency:I", opcode = Opcodes.PUTFIELD)) + //? } else { + /*@Redirect(method = "handleKeepAlive", at = @At(value = "FIELD", target = "Lnet/minecraft/server/level/ServerPlayer;latency:I", opcode = Opcodes.PUTFIELD)) public void solstice$realPing(ServerPlayer player, int value, @Local int i) { player.latency = i; } - //? } + *///? } } diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideNewPlayerSpawnPointMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideNewPlayerSpawnPointMixin.java index ee888d86..163d3ba3 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideNewPlayerSpawnPointMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideNewPlayerSpawnPointMixin.java @@ -1,11 +1,6 @@ package me.alexdevs.solstice.mixin.modules.spawn; -//? if >= 1.21.1 { -/*import com.llamalad7.mixinextras.sugar.Local; -*///? } + import me.alexdevs.solstice.modules.ModuleProvider; -//? if >= 1.21.1 { -/*import net.minecraft.nbt.CompoundTag; -*///? } import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; @@ -14,9 +9,13 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; + //? if >= 1.21.1 { -/*import java.util.Optional; -*///? } +import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.nbt.CompoundTag; +import java.util.Optional; +//? } + @Mixin(PlayerList.class) public abstract class OverrideNewPlayerSpawnPointMixin { @Redirect( @@ -27,13 +26,12 @@ public abstract class OverrideNewPlayerSpawnPointMixin { ) ) //? if >= 1.21.1 { - /*public ServerLevel solstice$overrideWorld(MinecraftServer server, ResourceKey dimension, @Local Optional optional) { + public ServerLevel solstice$overrideWorld(MinecraftServer server, ResourceKey dimension, @Local Optional optional) { if (optional.isEmpty()) { - *///? } else { - public ServerLevel solstice$overrideWorld(MinecraftServer server, ResourceKey dimension) { - var level = server.getLevel(dimension); - if (level == null) { - //? } + //? } else { + /*public ServerLevel solstice$overrideWorld(MinecraftServer server, ResourceKey dimension) { + if (server.getLevel(dimension) == null) { + *///? } var spawn = ModuleProvider.SPAWN; var firstSpawn = spawn.getFirstSpawn(); if (firstSpawn != null) { diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointLevelMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointLevelMixin.java index 8cf32a22..076cb7bb 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointLevelMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointLevelMixin.java @@ -1,5 +1,5 @@ //? if < 1.21.1 { -package me.alexdevs.solstice.mixin.modules.spawn; +/*package me.alexdevs.solstice.mixin.modules.spawn; import me.alexdevs.solstice.modules.ModuleProvider; import net.minecraft.core.BlockPos; @@ -48,4 +48,4 @@ public abstract class OverrideSpawnPointLevelMixin { } } -//? } \ No newline at end of file +*///? } \ No newline at end of file diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java index 270fb8bb..f94c7b7f 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/spawn/OverrideSpawnPointMixin.java @@ -1,37 +1,34 @@ package me.alexdevs.solstice.mixin.modules.spawn; import me.alexdevs.solstice.modules.ModuleProvider; import net.minecraft.core.BlockPos; -//? if >= 1.21.4 { -/*import net.minecraft.server.MinecraftServer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +//? if >= 1.21.1 { +import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Shadow; +//? } + +//? if >= 1.21.4 { +/*import net.minecraft.world.level.portal.TeleportTransition; *///? } else if >= 1.21.1 { -/*import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.portal.DimensionTransition; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Shadow; -*///? } else { -import net.minecraft.server.level.ServerLevel; +//? } else { +/*import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.player.Player; import net.minecraft.world.phys.Vec3; -//? } -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -//? if < 1.21.1 { import java.util.Optional; -//? } -//? if >= 1.21.1 { -/*@Mixin(ServerPlayer.class) -*///? } else { -@Mixin(Player.class) -//? } +*///? } + +//? >= 1.21.1 +@Mixin(ServerPlayer.class) +//? < 1.21.1 +//@Mixin(Player.class) public abstract class OverrideSpawnPointMixin { //? if >= 1.21.4 { /*@Shadow @Final public MinecraftServer server; @@ -57,7 +54,7 @@ public abstract class OverrideSpawnPointMixin { } } *///? } else if >= 1.21.1 { - /*@Shadow @Final public MinecraftServer server; + @Shadow @Final public MinecraftServer server; @Shadow private BlockPos respawnPosition; @Inject(method = "findRespawnPositionAndUseSpawnBlock", at = @At("RETURN"), cancellable = true) public void solstice$overrideRespawnTarget(boolean keepInventory, DimensionTransition.PostDimensionTransition postDimensionTransition, CallbackInfoReturnable cir) { @@ -79,8 +76,8 @@ public abstract class OverrideSpawnPointMixin { cir.setReturnValue(transition); } } - *///? } else { - @Inject(method = "findRespawnPositionAndUseSpawnBlock", at = @At("RETURN"), cancellable = true) + //? } else { + /*@Inject(method = "findRespawnPositionAndUseSpawnBlock", at = @At("RETURN"), cancellable = true) private static void solstice$overrideSpawnPos(ServerLevel level, BlockPos pos, float angle, boolean forced, boolean alive, CallbackInfoReturnable> cir) { var spawnModule = ModuleProvider.SPAWN; var config = spawnModule.getConfig(); @@ -94,5 +91,5 @@ public abstract class OverrideSpawnPointMixin { cir.setReturnValue(Optional.of(pos.getCenter())); } } - //? } + *///? } } diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomAdvancementMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomAdvancementMixin.java index d2593813..f6165236 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomAdvancementMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomAdvancementMixin.java @@ -1,41 +1,45 @@ package me.alexdevs.solstice.mixin.modules.styling; import me.alexdevs.solstice.modules.styling.formatters.AdvancementFormatter; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; + //? if >= 1.21.1 { -/*import net.minecraft.advancements.AdvancementHolder; +import net.minecraft.advancements.AdvancementHolder; import net.minecraft.advancements.AdvancementType; import net.minecraft.network.chat.MutableComponent; import net.minecraft.server.level.ServerPlayer; -*///? } else { -import net.minecraft.advancements.Advancement; +//? } else { +/*import net.minecraft.advancements.Advancement; import net.minecraft.network.chat.Component; import net.minecraft.server.PlayerAdvancements; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.players.PlayerList; -//? } -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -//? if < 1.21.1 { import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -//? } -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -//? if >= 1.21.1 { -/*@Mixin(AdvancementType.class) -*///? } else { -@Mixin(PlayerAdvancements.class) -//? } +*///? } + + +//? >= 1.21.1 +@Mixin(AdvancementType.class) +//? < 1.21.1 +//@Mixin(PlayerAdvancements.class) public abstract class CustomAdvancementMixin { //? if >= 1.21.1 { - /*@Inject(method = "createAnnouncement", at = @At("HEAD"), cancellable = true) + @Inject(method = "createAnnouncement", at = @At("HEAD"), cancellable = true) public void solstice$getCustomAnnouncement(AdvancementHolder advancement, ServerPlayer player, CallbackInfoReturnable cir) { cir.setReturnValue(AdvancementFormatter.getText(player, advancement, (AdvancementType) (Object) this).copy()); } - *///? } else { - @Shadow private ServerPlayer player; - @Final @Shadow private PlayerList playerList; + //? } else { + /*@Shadow + private ServerPlayer player; + @Final + @Shadow + private PlayerList playerList; + @Inject(method = "award", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V"), locals = LocalCapture.CAPTURE_FAILSOFT) public void broadcastAdvancementMessage(Advancement advancement, String criterionKey, CallbackInfoReturnable cir) { this.playerList.broadcastSystemMessage(AdvancementFormatter.getText(this.player, advancement), false); @@ -43,5 +47,5 @@ public void broadcastAdvancementMessage(Advancement advancement, String criterio @Redirect(method = "award", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V")) public void broadcastSystemMessageRedirect(PlayerList instance, Component message, boolean bypassHiddenChat) { } - //? } + *///? } } diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomConnectionMessagesMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomConnectionMessagesMixin.java index 9414532b..f3513cfb 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomConnectionMessagesMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomConnectionMessagesMixin.java @@ -7,8 +7,8 @@ import net.minecraft.network.chat.contents.TranslatableContents; import net.minecraft.server.level.ServerPlayer; //? if >= 1.21.1 { -/*import net.minecraft.server.network.CommonListenerCookie; -*///? } +import net.minecraft.server.network.CommonListenerCookie; +//? } import net.minecraft.server.players.PlayerList; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -23,20 +23,18 @@ public abstract class CustomConnectionMessagesMixin { private ServerPlayer solstice$player = null; @Inject(method = "placeNewPlayer", at = @At("HEAD")) - //? if >= 1.21.1 { - /*private void solstice$onJoin(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) { - *///? } else { - private void solstice$onJoin(Connection connection, ServerPlayer player, CallbackInfo ci) { - //? } + //? if >= 1.21.1 + private void solstice$onJoin(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) { + //? if < 1.21.1 + //private void solstice$onJoin(Connection connection, ServerPlayer player, CallbackInfo ci) { solstice$player = player; } @Inject(method = "placeNewPlayer", at = @At("RETURN")) - //? if >= 1.21.1 { - /*private void solstice$onJoinReturn(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) { - *///? } else { - private void solstice$onJoinReturn(Connection connection, ServerPlayer player, CallbackInfo ci) { - //? } + //? >= 1.21.1 + private void solstice$onJoinReturn(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) { + //? < 1.21.1 + //private void solstice$onJoinReturn(Connection connection, ServerPlayer player, CallbackInfo ci) { solstice$player = null; } diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java index d0f86d6b..9b348881 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/CustomNameplateMixin.java @@ -1,12 +1,12 @@ package me.alexdevs.solstice.mixin.modules.styling; -//? if < 1.21.1 { -import me.alexdevs.solstice.modules.ModuleProvider; -//? } //? if >= 1.21.1 { -/*import me.alexdevs.solstice.modules.styling.CustomPlayerTeam; +import me.alexdevs.solstice.modules.styling.CustomPlayerTeam; import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket; +//? } else { +/*import me.alexdevs.solstice.modules.ModuleProvider; *///? } + import net.minecraft.server.ServerScoreboard; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.players.PlayerList; @@ -29,13 +29,13 @@ public abstract class CustomNameplateMixin { @Inject(method = "updateEntireScoreboard", at = @At("HEAD")) private void solstice$overrideNameplate(ServerScoreboard scoreboard, ServerPlayer player, CallbackInfo ci) { //? if >= 1.21.1 { - /*for (var otherPlayer : players) { + for (var otherPlayer : players) { var team = new CustomPlayerTeam(scoreboard, otherPlayer); player.connection.send(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true)); } - *///? } else { - ModuleProvider.STYLING.sendTeamSetup(player, players, scoreboard, true); - //? } + //? } else { + /*ModuleProvider.STYLING.sendTeamSetup(player, players, scoreboard, true); + *///? } } } diff --git a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/PlayerDisconnectMixin.java b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/PlayerDisconnectMixin.java index 78aaa1c9..b2e8e3ba 100644 --- a/src/main/java/me/alexdevs/solstice/mixin/modules/styling/PlayerDisconnectMixin.java +++ b/src/main/java/me/alexdevs/solstice/mixin/modules/styling/PlayerDisconnectMixin.java @@ -16,11 +16,10 @@ public abstract class PlayerDisconnectMixin { @Shadow public ServerPlayer player; - //? if >= 1.21.1 { - /*@Redirect(method = "removePlayerFromWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V")) - *///? } else { - @Redirect(method = "onDisconnect", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V")) - //? } + //? >= 1.21.1 + @Redirect(method = "removePlayerFromWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V")) + //? < 1.21.1 + //@Redirect(method = "onDisconnect", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V")) private void solstice$sendLeaveMessage(PlayerList playerList, Component message, boolean bypassHiddenChat) { var formattedMessage = ConnectionActivityFormatter.onLeave(this.player); ModuleProvider.STYLING.broadcastActivity(playerList, formattedMessage, bypassHiddenChat); diff --git a/src/main/java/me/alexdevs/solstice/modules/afk/AfkModule.java b/src/main/java/me/alexdevs/solstice/modules/afk/AfkModule.java index d58311b3..68be12b0 100644 --- a/src/main/java/me/alexdevs/solstice/modules/afk/AfkModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/afk/AfkModule.java @@ -13,6 +13,7 @@ import me.alexdevs.solstice.modules.afk.commands.ActiveTimeCommand; import me.alexdevs.solstice.modules.afk.commands.AfkCommand; import me.alexdevs.solstice.modules.afk.data.*; +import me.alexdevs.solstice.api.utils.ResourceUtils; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.fabricmc.fabric.api.event.player.*; import net.fabricmc.fabric.api.message.v1.ServerMessageEvents; @@ -21,9 +22,6 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionResult; -//? if < 1.21.4 { -import net.minecraft.world.InteractionResultHolder; -//? } import net.minecraft.world.entity.Entity; import net.minecraft.world.phys.Vec3; @@ -31,6 +29,11 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; +//? if < 1.21.4 { +import net.minecraft.world.InteractionResultHolder; +//? } + + public class AfkModule extends ModuleBase.Toggleable { public static final double sprintSpeed = 0.280617; public static final double walkSpeed = 0.215859; @@ -68,11 +71,7 @@ public void init() { this.commands.add(new AfkCommand(this)); this.commands.add(new ActiveTimeCommand(this)); - //? if >= 1.21.1 { - /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(Solstice.MOD_ID, "afk"), (context, arg) -> { - *///? } else { - Placeholders.register(new ResourceLocation(Solstice.MOD_ID, "afk"), (context, arg) -> { - //? } + Placeholders.register(ResourceUtils.location(Solstice.MOD_ID, "afk"), (context, arg) -> { if (!context.hasPlayer()) return PlaceholderResult.invalid("No player!"); @@ -349,11 +348,10 @@ private void registerTriggers() { if (getConfig().triggers.onItemUse) { clearAfk((ServerPlayer) player, AfkTriggerReason.ITEM_USE); } - //? if >= 1.21.4 { - /*return InteractionResult.PASS; - *///? } else { + //? >= 1.21.4 + //return InteractionResult.PASS; + //? < 1.21.4 return InteractionResultHolder.pass(player.getItemInHand(hand)); - //? } }); ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) -> { diff --git a/src/main/java/me/alexdevs/solstice/modules/ignore/commands/IgnoreCommand.java b/src/main/java/me/alexdevs/solstice/modules/ignore/commands/IgnoreCommand.java index 277298ff..27e869d1 100644 --- a/src/main/java/me/alexdevs/solstice/modules/ignore/commands/IgnoreCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/ignore/commands/IgnoreCommand.java @@ -41,11 +41,11 @@ public LiteralArgumentBuilder command(String name) { var targetName = StringArgumentType.getString(context, "target"); - //? if >= 1.21.1 { - /*context.getSource().getServer().getProfileCache().getAsync(targetName).thenAcceptAsync(profileOpt -> { - *///? } else { - context.getSource().getServer().getProfileCache().getAsync(targetName, profileOpt -> { - //? } + //? >= 1.21.1 + context.getSource().getServer().getProfileCache().getAsync(targetName).thenAcceptAsync(profileOpt -> { + //? < 1.21.1 + //context.getSource().getServer().getProfileCache().getAsync(targetName, profileOpt -> { + var playerContext = PlaceholderContext.of(player); if (profileOpt.isEmpty()) { diff --git a/src/main/java/me/alexdevs/solstice/modules/inventorySee/commands/InventorySeeCommand.java b/src/main/java/me/alexdevs/solstice/modules/inventorySee/commands/InventorySeeCommand.java index e06eb202..f1e7bca5 100644 --- a/src/main/java/me/alexdevs/solstice/modules/inventorySee/commands/InventorySeeCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/inventorySee/commands/InventorySeeCommand.java @@ -6,15 +6,13 @@ import eu.pb4.sgui.api.gui.SimpleGui; import me.alexdevs.solstice.api.command.LocalGameProfile; import me.alexdevs.solstice.api.module.ModCommand; +import me.alexdevs.solstice.api.utils.ItemUtils; import me.alexdevs.solstice.api.utils.PlayerUtils; import me.alexdevs.solstice.integrations.TrinketsIntegration; import me.alexdevs.solstice.modules.inventorySee.ImmutableSlot; import me.alexdevs.solstice.modules.inventorySee.InventorySeeModule; import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.commands.CommandSourceStack; -//? if >= 1.21.1 { -/*import net.minecraft.core.component.DataComponents; -*///? } import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.inventory.ChestMenu; @@ -52,6 +50,12 @@ public List getNames() { invSizes.put(54, MenuType.GENERIC_9x6); } + private static ItemStack createBarrierItem() { + var barrier = new ItemStack(Items.BLACK_STAINED_GLASS_PANE); + ItemUtils.setCustomName(barrier, Component.literal("")); + return barrier; + } + @Override public LiteralArgumentBuilder command(String name) { return literal(name) @@ -107,12 +111,7 @@ public void onClose() { container.setSlotRedirect(i, slot); } - var barrier = new ItemStack(Items.BLACK_STAINED_GLASS_PANE); - //? if >= 1.21.1 { - /*barrier.set(DataComponents.CUSTOM_NAME, Component.literal("")); - *///? } else { - barrier.setHoverName(Component.literal("")); - //? } + var barrier = createBarrierItem(); for (var i = targetInventory.getContainerSize(); i < container.getSize(); i++) { container.setSlot(i, barrier); } @@ -201,12 +200,7 @@ public void onClose() { container.setSlotRedirect(i, slot); } - var barrier = new ItemStack(Items.BLACK_STAINED_GLASS_PANE); - //? if >= 1.21.1 { - /*barrier.set(DataComponents.CUSTOM_NAME, Component.literal("")); - *///? } else { - barrier.setHoverName(Component.literal("")); - //? } + var barrier = createBarrierItem(); for (var i = size; i < container.getSize(); i++) { container.setSlot(i, barrier); } diff --git a/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemLoreCommand.java b/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemLoreCommand.java index 3dc94e04..100813ea 100644 --- a/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemLoreCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemLoreCommand.java @@ -5,25 +5,12 @@ import eu.pb4.placeholders.api.PlaceholderContext; import me.alexdevs.solstice.api.module.ModCommand; import me.alexdevs.solstice.api.text.Format; +import me.alexdevs.solstice.api.utils.ItemUtils; import me.alexdevs.solstice.modules.item.ItemModule; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; -//? if >= 1.21.1 { -/*import net.minecraft.core.component.DataComponents; -*///? } -//? if < 1.21.1 { -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.StringTag; -//? } import net.minecraft.network.chat.Component; -//? if >= 1.21.1 { -/*import net.minecraft.world.item.component.ItemLore; -*///? } - -//? if >= 1.21.1 { -/*import java.util.ArrayList; -*///? } +import java.util.ArrayList; import java.util.List; public class ItemLoreCommand extends ModCommand { @@ -48,19 +35,7 @@ public LiteralArgumentBuilder command(String name) { context.getSource().sendSuccess(() -> module.locale().get("noItem"), false); return 0; } - - //? if >= 1.21.1 { - /*item.remove(DataComponents.LORE); - *///? } else { - CompoundTag nbtCompound = item.getTagElement("display"); - if (nbtCompound != null) { - nbtCompound.remove("Lore"); - if (nbtCompound.isEmpty()) { - item.removeTagKey("display"); - } - } - //? } - + ItemUtils.removeLore(item); context.getSource().sendSuccess(() -> module.locale().get("loreCleared"), false); return 1; @@ -77,22 +52,11 @@ public LiteralArgumentBuilder command(String name) { } var playerContext = PlaceholderContext.of(player); - //? if >= 1.21.1 { - /*var list = new ArrayList(); + var lines = new ArrayList(); for (var line : itemLore.split("\\\\n")) { - list.add(Format.parse(line, playerContext)); + lines.add(Format.parse(line, playerContext)); } - item.set(DataComponents.LORE, new ItemLore(list)); - *///? } else { - var list = new ListTag(); - for (var line : itemLore.split("\\\\n")) { - var text = Format.parse(line, playerContext); - list.add(StringTag.valueOf(Component.Serializer.toJson(text))); - } - var displayNbt = item.getOrCreateTagElement("display"); - displayNbt.put("Lore", list); - //? } - + ItemUtils.setLore(item, lines); context.getSource().sendSuccess(() -> module.locale().get("loreSet"), false); return 1; diff --git a/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemNameCommand.java b/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemNameCommand.java index 41ba43a7..54278e1f 100644 --- a/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemNameCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/item/commands/ItemNameCommand.java @@ -1,29 +1,23 @@ package me.alexdevs.solstice.modules.item.commands; - import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import eu.pb4.placeholders.api.PlaceholderContext; import me.alexdevs.solstice.api.module.ModCommand; import me.alexdevs.solstice.api.text.Format; +import me.alexdevs.solstice.api.utils.ItemUtils; import me.alexdevs.solstice.modules.item.ItemModule; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; -//? if >= 1.21.1 { -/*import net.minecraft.core.component.DataComponents; -*///? } - import java.util.List; public class ItemNameCommand extends ModCommand { public ItemNameCommand(ItemModule module) { super(module); } - @Override public List getNames() { return List.of("itemname"); } - @Override public LiteralArgumentBuilder command(String name) { return Commands.literal(name) @@ -36,13 +30,7 @@ public LiteralArgumentBuilder command(String name) { context.getSource().sendSuccess(() -> module.locale().get("noItem"), false); return 0; } - - //? if >= 1.21.1 { - /*item.remove(DataComponents.CUSTOM_NAME); - *///? } else { - item.resetHoverName(); - //? } - + ItemUtils.removeCustomName(item); context.getSource().sendSuccess(() -> module.locale().get("nameCleared"), false); return 1; @@ -59,12 +47,7 @@ public LiteralArgumentBuilder command(String name) { } var playerContext = PlaceholderContext.of(player); - //? if >= 1.21.1 { - /*item.set(DataComponents.CUSTOM_NAME, Format.parse(itemName, playerContext)); - *///? } else { - item.setHoverName(Format.parse(itemName, playerContext)); - //? } - + ItemUtils.setCustomName(item, Format.parse(itemName, playerContext)); context.getSource().sendSuccess(() -> module.locale().get("nameSet"), false); return 1; diff --git a/src/main/java/me/alexdevs/solstice/modules/item/commands/RepairCommand.java b/src/main/java/me/alexdevs/solstice/modules/item/commands/RepairCommand.java index 6f509dc1..cad7487c 100644 --- a/src/main/java/me/alexdevs/solstice/modules/item/commands/RepairCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/item/commands/RepairCommand.java @@ -2,11 +2,9 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import me.alexdevs.solstice.api.module.ModCommand; +import me.alexdevs.solstice.api.utils.ItemUtils; import me.alexdevs.solstice.modules.item.ItemModule; import net.minecraft.commands.CommandSourceStack; -//? if >= 1.21.1 { -/*import net.minecraft.core.component.DataComponents; -*///? } import java.util.List; @@ -44,11 +42,7 @@ public LiteralArgumentBuilder command(String name) { if(item.isDamaged()) { // Removes the NBT tag altogether instead of just setting it to 0 - //? if >= 1.21.1 { - /*item.remove(DataComponents.DAMAGE); - *///? } else { - item.removeTagKey("Damage"); - //? } + ItemUtils.removeDamage(item); context.getSource().sendSuccess(() -> module.locale().get("repaired"), false); return 1; } else { diff --git a/src/main/java/me/alexdevs/solstice/modules/jail/JailModule.java b/src/main/java/me/alexdevs/solstice/modules/jail/JailModule.java index d3f70e02..8ac0b549 100644 --- a/src/main/java/me/alexdevs/solstice/modules/jail/JailModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/jail/JailModule.java @@ -14,7 +14,6 @@ import me.alexdevs.solstice.modules.jail.data.JailLocale; import me.alexdevs.solstice.modules.jail.data.JailPlayerData; import me.alexdevs.solstice.modules.jail.data.JailServerData; -import me.alexdevs.solstice.modules.spawn.SpawnModule; import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.fabric.api.event.player.*; @@ -24,14 +23,15 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionResult; -//? if < 1.21.4 { -import net.minecraft.world.InteractionResultHolder; -//? } +import net.minecraft.world.entity.player.Player; import java.util.Map; import java.util.UUID; import java.util.concurrent.TimeUnit; +//? < 1.21.4 +import net.minecraft.world.InteractionResultHolder; + public class JailModule extends ModuleBase.Toggleable { @@ -91,11 +91,7 @@ public void init() { AttackBlockCallback.EVENT.register((player, world, hand, blockPos, direction) -> { if (isPlayerJailed(player.getUUID())) { - //? if >= 1.21.4 { - /*if (player instanceof ServerPlayer sp) sp.sendSystemMessage(locale().get("cannotBreakBlocks")); - *///? } else { - player.sendSystemMessage(locale().get("cannotBreakBlocks")); - //? } + tryNotifyPlayer(player, locale().get("cannotBreakBlocks")); return InteractionResult.FAIL; } return InteractionResult.PASS; @@ -103,11 +99,7 @@ public void init() { AttackEntityCallback.EVENT.register((player, world, hand, entity, entityHitResult) -> { if (isPlayerJailed(player.getUUID())) { - //? if >= 1.21.4 { - /*if (player instanceof ServerPlayer sp) sp.sendSystemMessage(locale().get("cannotAttackEntities")); - *///? } else { - player.sendSystemMessage(locale().get("cannotAttackEntities")); - //? } + tryNotifyPlayer(player, locale().get("cannotAttackEntities")); return InteractionResult.FAIL; } return InteractionResult.PASS; @@ -115,11 +107,7 @@ public void init() { PlayerBlockBreakEvents.BEFORE.register((world, player, blockPos, blockState, blockEntity) -> { if (isPlayerJailed(player.getUUID())) { - //? if >= 1.21.4 { - /*if (player instanceof ServerPlayer sp) sp.sendSystemMessage(locale().get("cannotBreakBlocks")); - *///? } else { - player.sendSystemMessage(locale().get("cannotBreakBlocks")); - //? } + tryNotifyPlayer(player, locale().get("cannotBreakBlocks")); return false; } @@ -128,11 +116,7 @@ public void init() { UseBlockCallback.EVENT.register((player, world, hand, blockHitResult) -> { if (isPlayerJailed(player.getUUID())) { - //? if >= 1.21.4 { - /*if (player instanceof ServerPlayer sp) sp.sendSystemMessage(locale().get("cannotUseBlocks")); - *///? } else { - player.sendSystemMessage(locale().get("cannotUseBlocks")); - //? } + tryNotifyPlayer(player, locale().get("cannotUseBlocks")); return InteractionResult.FAIL; } return InteractionResult.PASS; @@ -140,11 +124,7 @@ public void init() { UseEntityCallback.EVENT.register((player, world, hand, entity, entityHitResult) -> { if (isPlayerJailed(player.getUUID())) { - //? if >= 1.21.4 { - /*if (player instanceof ServerPlayer sp) sp.sendSystemMessage(locale().get("cannotUseEntities")); - *///? } else { - player.sendSystemMessage(locale().get("cannotUseEntities")); - //? } + tryNotifyPlayer(player, locale().get("cannotUseEntities")); return InteractionResult.FAIL; } return InteractionResult.PASS; @@ -211,6 +191,13 @@ public boolean isPlayerJailed(UUID uuid) { return getPlayer(uuid).jailed; } + private void tryNotifyPlayer(Player player, Component message) { + //? >= 1.21.4 + //if (player instanceof ServerPlayer sp) sp.sendSystemMessage(message); + //? < 1.21.4 + player.sendSystemMessage(message); + } + public void sendToJail(ServerPlayer player) { Solstice.nextTick(() -> { var data = getPlayer(player.getUUID()); diff --git a/src/main/java/me/alexdevs/solstice/modules/kit/Utils.java b/src/main/java/me/alexdevs/solstice/modules/kit/Utils.java index 9be27c15..95e8da06 100644 --- a/src/main/java/me/alexdevs/solstice/modules/kit/Utils.java +++ b/src/main/java/me/alexdevs/solstice/modules/kit/Utils.java @@ -3,11 +3,11 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import eu.pb4.sgui.api.gui.SimpleGui; //? if < 1.21.1 { -import net.minecraft.nbt.CompoundTag; -//? } -//? if >= 1.21.1 { -/*import me.alexdevs.solstice.Solstice; +/*import net.minecraft.nbt.CompoundTag; *///? } +//? if >= 1.21.1 { +import me.alexdevs.solstice.Solstice; +//? } import net.minecraft.nbt.TagParser; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; @@ -18,24 +18,23 @@ public class Utils { public static String serializeItemStack(ItemStack itemStack) { //? if >= 1.21.1 { - /*var registry = Solstice.server.registryAccess(); + var registry = Solstice.server.registryAccess(); var nbt = itemStack.save(registry); - *///? } else { - var nbt = new CompoundTag(); + //? } else { + /*var nbt = new CompoundTag(); itemStack.save(nbt); - //? } + *///? } return nbt.getAsString(); } public static ItemStack deserializeItemStack(String string) throws CommandSyntaxException { //? if >= 1.21.1 { - /*var registry = Solstice.server.registryAccess(); - var nbt = TagParser.parseTag(string); - return ItemStack.parseOptional(registry, nbt); - *///? } else { - var nbt = TagParser.parseTag(string); + var registry = Solstice.server.registryAccess(); + return ItemStack.parseOptional(registry, TagParser.parseTag(string)); + //? } else { + /*var nbt = TagParser.parseTag(string); return ItemStack.of(nbt); - //? } + *///? } } public static KitInventory createInventory(List items) { diff --git a/src/main/java/me/alexdevs/solstice/modules/kit/commands/KitsCommand.java b/src/main/java/me/alexdevs/solstice/modules/kit/commands/KitsCommand.java index be34e950..6ef44549 100644 --- a/src/main/java/me/alexdevs/solstice/modules/kit/commands/KitsCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/kit/commands/KitsCommand.java @@ -6,6 +6,7 @@ import eu.pb4.sgui.api.elements.GuiElement; import eu.pb4.sgui.api.gui.SimpleGui; import me.alexdevs.solstice.api.module.ModCommand; +import me.alexdevs.solstice.api.utils.ItemUtils; import me.alexdevs.solstice.modules.kit.KitModule; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; @@ -17,15 +18,6 @@ import java.util.List; import java.util.Map; -//? if >= 1.21.1 { -/*import net.minecraft.core.component.DataComponents; -import net.minecraft.world.item.component.ItemLore; -*///? } -//? if < 1.21.1 { -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.StringTag; -//? } - public class KitsCommand extends ModCommand { public KitsCommand(KitModule module) { super(module); @@ -99,26 +91,13 @@ private void refreshGui(CommandContext context, SimpleGui gu if (canClaim) { kitNameComponent = Component.nullToEmpty(kitName); kitLoreComponent = module.locale().get("claimKit", placeholders); - //? if >= 1.21.1 { - /*icon.set(DataComponents.ENCHANTMENT_GLINT_OVERRIDE, true); - *///? } else { - icon.getOrCreateTag().put("Enchantments", new ListTag()); - //? } + ItemUtils.setGlint(icon, true); } else { kitNameComponent = module.locale().get("kitsUnavailableName", placeholders); kitLoreComponent = module.locale().get("kitsUnavailableLore", placeholders); } - - //? if >= 1.21.1 { - /*icon.set(DataComponents.CUSTOM_NAME, kitNameComponent); - icon.set(DataComponents.LORE, new ItemLore(List.of(kitLoreComponent))); - *///? } else { - icon.setHoverName(kitNameComponent); - var displayNbt = icon.getOrCreateTagElement("display"); - var list = new ListTag(); - list.add(StringTag.valueOf(Component.Serializer.toJson(kitLoreComponent))); - displayNbt.put("Lore", list); - //? } + ItemUtils.setCustomName(icon, kitNameComponent); + ItemUtils.setLore(icon, List.of(kitLoreComponent)); gui.setSlot(i, new GuiElement(icon, (syncId, clickType, slotActionType) -> { try { dispatcher.execute("kit claim " + kitName, context.getSource()); diff --git a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/EffectsCommand.java b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/EffectsCommand.java index 12645ce9..390ffb81 100644 --- a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/EffectsCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/EffectsCommand.java @@ -59,11 +59,10 @@ private int execute(CommandContext context, ServerPlayer tar } var map = Map.of( - //? if >= 1.21.1 { - /*"effect", Component.translatable(effect.value().getDescriptionId()), - *///? } else { - "effect", Component.translatable(effect.getDescriptionId()), - //? } + //? >= 1.21.1 + "effect", Component.translatable(effect.value().getDescriptionId()), + //? < 1.21.1 + //"effect", Component.translatable(effect.getDescriptionId()), "amplifier", Component.nullToEmpty(String.valueOf(instance.getAmplifier())), "duration", Component.nullToEmpty(duration) ); diff --git a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/KittyCannonCommand.java b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/KittyCannonCommand.java index b749bdba..0c7449d4 100644 --- a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/KittyCannonCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/KittyCannonCommand.java @@ -3,17 +3,13 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import me.alexdevs.solstice.Solstice; import me.alexdevs.solstice.api.module.ModCommand; +import me.alexdevs.solstice.api.utils.EntityUtils; import me.alexdevs.solstice.modules.miscellaneous.DummyExplosion; import me.alexdevs.solstice.modules.miscellaneous.MiscellaneousModule; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; -//? if >= 1.21.4 { -/*import net.minecraft.world.entity.EntitySpawnReason; -*///? } else { -import net.minecraft.world.entity.MobSpawnType; -//? } import java.util.List; import java.util.concurrent.TimeUnit; @@ -39,11 +35,7 @@ public LiteralArgumentBuilder command(String name) { final var world = player.serverLevel(); - //? if >= 1.21.1 { - /*BALL.create(world, entity -> { - *///? } else { - BALL.create(world, null, entity -> { - //? } + EntityUtils.createWithCommand(BALL, world, entity -> { entity.setDeltaMovement(player.getLookAngle().scale(3.5)); entity.setPos(player.getEyePosition().add(player.getLookAngle())); world.addFreshEntity(entity); @@ -53,11 +45,7 @@ public LiteralArgumentBuilder command(String name) { DummyExplosion.spawn(world, pos, 0); entity.remove(Entity.RemovalReason.DISCARDED); }, 1, TimeUnit.SECONDS); - //? if >= 1.21.4 { - /*}, player.blockPosition().above(), EntitySpawnReason.COMMAND, true, false); - *///? } else { - }, player.blockPosition().above(), MobSpawnType.COMMAND, true, false); - //? } + }, player.blockPosition().above(), true, false); return 1; diff --git a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/SpeedCommand.java b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/SpeedCommand.java index 1fe0cd39..fb2915ac 100644 --- a/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/SpeedCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/miscellaneous/commands/SpeedCommand.java @@ -74,25 +74,23 @@ private int setWalkingSpeed(CommandContext context, float sp ); if (speedMultiplier == 1) { - //? if >= 1.21.1 { - /*instance.removeModifier(id); - *///? } else { - var res = instance.getModifiers().stream().filter(x -> x.getName().equals(id.toString())).findFirst(); - res.ifPresent(instance::removeModifier); - //? } + //? >= 1.21.1 + instance.removeModifier(id); + //? < 1.21.1 + //instance.getModifiers().stream().filter(x -> x.getName().equals(id.toString())).findFirst().ifPresent(instance::removeModifier); context.getSource().sendSuccess(() -> module.locale().get("walkSpeedReset", map), true); } else { //? if >= 1.21.1 { - /*var modifier = new AttributeModifier(id, speedMultiplier, AttributeModifier.Operation.ADD_MULTIPLIED_BASE); + var modifier = new AttributeModifier(id, speedMultiplier, AttributeModifier.Operation.ADD_MULTIPLIED_BASE); instance.addOrUpdateTransientModifier(modifier); - *///? } else { - var res = instance.getModifiers().stream().filter(x -> x.getName().equals(id.toString())).findFirst(); + //? } else { + /*var res = instance.getModifiers().stream().filter(x -> x.getName().equals(id.toString())).findFirst(); res.ifPresent(instance::removeModifier); var modifier = new AttributeModifier(id.toString(), speedMultiplier, AttributeModifier.Operation.MULTIPLY_TOTAL); instance.addTransientModifier(modifier); - //? } + *///? } context.getSource().sendSuccess(() -> module.locale().get("walkSpeedSet", map), true); } diff --git a/src/main/java/me/alexdevs/solstice/modules/placeholders/PlaceholdersModule.java b/src/main/java/me/alexdevs/solstice/modules/placeholders/PlaceholdersModule.java index 85e7f025..e10dfe59 100644 --- a/src/main/java/me/alexdevs/solstice/modules/placeholders/PlaceholdersModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/placeholders/PlaceholdersModule.java @@ -3,6 +3,7 @@ import eu.pb4.placeholders.api.PlaceholderResult; import eu.pb4.placeholders.api.Placeholders; import me.alexdevs.solstice.api.module.ModuleBase; +import me.alexdevs.solstice.api.utils.ResourceUtils; import net.minecraft.resources.ResourceLocation; public class PlaceholdersModule extends ModuleBase.Toggleable { @@ -15,11 +16,7 @@ public PlaceholdersModule(ResourceLocation id) { @Override public void init() { - //? if >= 1.21.1 { - /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(ENTITY, "name"), (context, str) -> { - *///? } else { - Placeholders.register(new ResourceLocation(ENTITY, "name"), (context, str) -> { - //? } + Placeholders.register(ResourceUtils.location(ENTITY, "name"), (context, str) -> { if (!context.hasEntity()) { return PlaceholderResult.invalid("No entity!"); } @@ -27,11 +24,7 @@ public void init() { return PlaceholderResult.value(entity.getName()); }); - //? if >= 1.21.1 { - /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(ENTITY, "displayname"), (context, str) -> { - *///? } else { - Placeholders.register(new ResourceLocation(ENTITY, "displayname"), (context, str) -> { - //? } + Placeholders.register(ResourceUtils.location(ENTITY, "displayname"), (context, str) -> { if (!context.hasEntity()) { return PlaceholderResult.invalid("No entity!"); } @@ -39,11 +32,7 @@ public void init() { return PlaceholderResult.value(entity.getDisplayName()); }); - //? if >= 1.21.1 { - /*Placeholders.register(ResourceLocation.fromNamespaceAndPath(ENTITY, "uuid"), (context, str) -> { - *///? } else { - Placeholders.register(new ResourceLocation(ENTITY, "uuid"), (context, str) -> { - //? } + Placeholders.register(ResourceUtils.location(ENTITY, "uuid"), (context, str) -> { if (!context.hasEntity()) { return PlaceholderResult.invalid("No entity!"); } diff --git a/src/main/java/me/alexdevs/solstice/modules/powertool/PowerToolModule.java b/src/main/java/me/alexdevs/solstice/modules/powertool/PowerToolModule.java index 527c8b2c..2bfdf906 100644 --- a/src/main/java/me/alexdevs/solstice/modules/powertool/PowerToolModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/powertool/PowerToolModule.java @@ -12,18 +12,21 @@ import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.fabricmc.fabric.api.event.player.*; import net.minecraft.commands.CommandSourceStack; -//? if >= 1.21.4 { -/*import net.minecraft.server.level.ServerLevel; -*///? } import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionResult; -//? if < 1.21.4 { -import net.minecraft.world.InteractionResultHolder; -//? } +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import java.util.UUID; + +//? >= 1.21.4 +//import net.minecraft.server.level.ServerLevel; + +//? < 1.21.4 +import net.minecraft.world.InteractionResultHolder; + + public class PowerToolModule extends ModuleBase.Toggleable { @@ -51,11 +54,7 @@ public void init() { if (data.powerTools.containsKey(itemId)) { var powertool = data.powerTools.get(itemId); if (powertool.containsKey(Action.USE)) { - //? if >= 1.21.4 { - /*var source = player.createCommandSourceStackForNameResolution(((ServerLevel) player.level())); - *///? } else { - var source = player.createCommandSourceStack(); - //? } + var source = getSource(player); execute(source, powertool.get(Action.USE), PlaceholderContext.of(player)); //? if >= 1.21.4 { @@ -82,11 +81,7 @@ public void init() { if (data.powerTools.containsKey(itemId)) { var powertool = data.powerTools.get(itemId); if (powertool.containsKey(Action.ATTACK_BLOCK)) { - //? if >= 1.21.4 { - /*var source = player.createCommandSourceStackForNameResolution(((ServerLevel) player.level())); - *///? } else { - var source = player.createCommandSourceStack(); - //? } + var source = getSource(player); execute(source, powertool.get(Action.ATTACK_BLOCK), PlaceholderContext.of(player)); return InteractionResult.CONSUME; @@ -105,11 +100,7 @@ public void init() { if (data.powerTools.containsKey(itemId)) { var powertool = data.powerTools.get(itemId); if (powertool.containsKey(Action.ATTACK_ENTITY)) { - //? if >= 1.21.4 { - /*var source = player.createCommandSourceStackForNameResolution(((ServerLevel) player.level())); - *///? } else { - var source = player.createCommandSourceStack(); - //? } + var source = getSource(player); execute(source, powertool.get(Action.ATTACK_ENTITY), PlaceholderContext.of(entity)); return InteractionResult.CONSUME; @@ -128,11 +119,7 @@ public void init() { if (data.powerTools.containsKey(itemId)) { var powertool = data.powerTools.get(itemId); if (powertool.containsKey(Action.INTERACT_BLOCK)) { - //? if >= 1.21.4 { - /*var source = player.createCommandSourceStackForNameResolution(((ServerLevel) player.level())); - *///? } else { - var source = player.createCommandSourceStack(); - //? } + var source = getSource(player); execute(source, powertool.get(Action.INTERACT_BLOCK), PlaceholderContext.of(player)); return InteractionResult.CONSUME; @@ -151,11 +138,7 @@ public void init() { if (data.powerTools.containsKey(itemId)) { var powertool = data.powerTools.get(itemId); if (powertool.containsKey(Action.INTERACT_ENTITY)) { - //? if >= 1.21.4 { - /*var source = player.createCommandSourceStackForNameResolution(((ServerLevel) player.level())); - *///? } else { - var source = player.createCommandSourceStack(); - //? } + var source = getSource(player); execute(source, powertool.get(Action.INTERACT_ENTITY), PlaceholderContext.of(entity)); return InteractionResult.CONSUME; @@ -166,6 +149,13 @@ public void init() { }); } + private CommandSourceStack getSource(Player player) { + //? >= 1.21.4 + //return player.createCommandSourceStackForNameResolution(((ServerLevel) player.level())); + //? < 1.21.4 + return player.createCommandSourceStack(); + } + public void execute(CommandSourceStack source, String command, PlaceholderContext context) { try { dispatcher.execute(resolveCommand(command, context), source); diff --git a/src/main/java/me/alexdevs/solstice/modules/rtp/commands/RTPCommand.java b/src/main/java/me/alexdevs/solstice/modules/rtp/commands/RTPCommand.java index 5dc4c15a..750d5e36 100644 --- a/src/main/java/me/alexdevs/solstice/modules/rtp/commands/RTPCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/rtp/commands/RTPCommand.java @@ -6,8 +6,8 @@ import me.alexdevs.solstice.Solstice; import me.alexdevs.solstice.api.module.ModCommand; //? if >= 1.21.1 { -/*import me.alexdevs.solstice.api.utils.RegistryUtils; -*///? } +import me.alexdevs.solstice.api.utils.RegistryUtils; +//? } import me.alexdevs.solstice.modules.rtp.RTPModule; import me.alexdevs.solstice.modules.rtp.core.Locator; import me.lucko.fabric.api.permissions.v0.Permissions; @@ -47,12 +47,12 @@ public LiteralArgumentBuilder command(String name) { .suggests((context, builder) -> { if (Permissions.check(context.getSource(), getPermissionNode("exempt.biome"), 2)) { //? if >= 1.21.1 { - /*var biomeRegistry = this.commandRegistry.lookup(Registries.BIOME); + var biomeRegistry = this.commandRegistry.lookup(Registries.BIOME); var biomes = RegistryUtils.getBiomes(biomeRegistry.get(), false); - *///? } else { - var biomeRegistry = this.commandRegistry.holderLookup(Registries.BIOME); + //? } else { + /*var biomeRegistry = this.commandRegistry.holderLookup(Registries.BIOME); var biomes = biomeRegistry.listElements().map(r -> r.unwrapKey().get().location().toString()).toList(); - //? } + *///? } return SharedSuggestionProvider.suggest(biomes, builder); } diff --git a/src/main/java/me/alexdevs/solstice/modules/rtp/core/Locator.java b/src/main/java/me/alexdevs/solstice/modules/rtp/core/Locator.java index c04fcc1b..b6dee08d 100644 --- a/src/main/java/me/alexdevs/solstice/modules/rtp/core/Locator.java +++ b/src/main/java/me/alexdevs/solstice/modules/rtp/core/Locator.java @@ -121,12 +121,15 @@ private BlockPos getTopBlock(BlockPos pos) { return world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, pos); } + private static int getChunkMinY(ChunkAccess chunk) { + //? >= 1.21.4 + //return chunk.getMinY(); + //? < 1.21.4 + return chunk.getMinBuildHeight(); + } + private BlockPos getEmptySpace(BlockPos pos) { - //? if >= 1.21.4 { - /*var bottom = chunk.getMinY(); - *///? } else { - var bottom = chunk.getMinBuildHeight(); - //? } + var bottom = getChunkMinY(chunk); var top = world.getLogicalHeight(); var blockPos = new BlockPos.MutableBlockPos(pos.getX(), top, pos.getZ()); @@ -155,18 +158,10 @@ private void findValidPlacement() { var dx = i % 16; var dz = i / 16; - //? if >= 1.21.4 { - /*pos = chunk.getPos().getBlockAt(dx, chunk.getMinY(), dz); - *///? } else { - pos = chunk.getPos().getBlockAt(dx, chunk.getMinBuildHeight(), dz); - //? } + pos = chunk.getPos().getBlockAt(dx, getChunkMinY(chunk), dz); } - //? if >= 1.21.4 { - /*if (pos.getY() <= chunk.getMinY()) { - *///? } else { - if (pos.getY() <= chunk.getMinBuildHeight()) { - //? } + if (pos.getY() <= getChunkMinY(chunk)) { callback.accept(new Result(Result.Type.UNSAFE, Optional.empty())); return; } @@ -187,11 +182,10 @@ private Optional getChunk(ChunkPos pos) { if (holder == null) { return Optional.empty(); } else { - //? if >= 1.21.1 { - /*var chunk = holder.getFullChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).orElse(null); - *///? } else { - var chunk = holder.getFullChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).left().orElse(null); - //? } + //? >= 1.21.1 + var chunk = holder.getFullChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).orElse(null); + //? < 1.21.1 + //var chunk = holder.getFullChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).left().orElse(null); if (chunk == null) { return Optional.empty(); } diff --git a/src/main/java/me/alexdevs/solstice/modules/rtp/data/RTPConfig.java b/src/main/java/me/alexdevs/solstice/modules/rtp/data/RTPConfig.java index 9c458697..847054d7 100644 --- a/src/main/java/me/alexdevs/solstice/modules/rtp/data/RTPConfig.java +++ b/src/main/java/me/alexdevs/solstice/modules/rtp/data/RTPConfig.java @@ -1,8 +1,8 @@ package me.alexdevs.solstice.modules.rtp.data; +import me.alexdevs.solstice.api.utils.ResourceUtils; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.biome.Biome; import org.spongepowered.configurate.objectmapping.ConfigSerializable; import org.spongepowered.configurate.objectmapping.meta.Comment; @@ -67,10 +67,8 @@ public class RTPConfig { ); public List> parseBiomes() { - //? if >= 1.21.1 { - /*return prohibitedBiomes.stream().map(biomeId -> ResourceKey.create(Registries.BIOME, ResourceLocation.parse(biomeId))).toList(); - *///? } else { - return prohibitedBiomes.stream().map(biomeId -> ResourceKey.create(Registries.BIOME, ResourceLocation.tryParse(biomeId))).toList(); - //? } + return prohibitedBiomes.stream() + .map(biomeId -> ResourceKey.create(Registries.BIOME, ResourceUtils.parse(biomeId))) + .toList(); } } diff --git a/src/main/java/me/alexdevs/solstice/modules/skull/SkullModule.java b/src/main/java/me/alexdevs/solstice/modules/skull/SkullModule.java index be7cfbba..8746c8c9 100644 --- a/src/main/java/me/alexdevs/solstice/modules/skull/SkullModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/skull/SkullModule.java @@ -1,30 +1,12 @@ package me.alexdevs.solstice.modules.skull; import com.mojang.authlib.GameProfile; -//? if >= 1.21.1 { -/*import com.mojang.authlib.properties.PropertyMap; -*///? } import me.alexdevs.solstice.api.module.ModuleBase; +import me.alexdevs.solstice.api.utils.ItemUtils; import me.alexdevs.solstice.modules.skull.commands.SkullCommand; -//? if >= 1.21.1 { -/*import net.minecraft.core.component.DataComponents; -*///? } -//? if < 1.21.1 { -import net.minecraft.nbt.StringTag; -//? } import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -//? if < 1.21.1 { -import net.minecraft.world.item.PlayerHeadItem; -//? } -//? if >= 1.21.1 { -/*import net.minecraft.world.item.component.ResolvableProfile; -*///? } - -//? if >= 1.21.1 { -/*import java.util.Optional; -*///? } import java.util.UUID; public class SkullModule extends ModuleBase.Toggleable { @@ -38,35 +20,21 @@ public SkullModule(ResourceLocation id) { public void init() { commands.add(new SkullCommand(this)); } - public ItemStack createSkull(String name) { var skull = Items.PLAYER_HEAD.getDefaultInstance(); name = name.substring(0, Math.min(name.length(), 16)); - //? if >= 1.21.1 { - /*skull.set(DataComponents.PROFILE, new ResolvableProfile(Optional.of(name), Optional.empty(), new PropertyMap())); - *///? } else { - skull.addTagElement(PlayerHeadItem.TAG_SKULL_OWNER, StringTag.valueOf(name)); - //? } + ItemUtils.setProfileByName(skull, name); return skull; } - public ItemStack createSkull(UUID uuid) { - //? if >= 1.21.1 { - /*var skull = Items.PLAYER_HEAD.getDefaultInstance(); - skull.set(DataComponents.PROFILE, new ResolvableProfile(Optional.empty(), Optional.of(uuid), new PropertyMap())); + var skull = Items.PLAYER_HEAD.getDefaultInstance(); + ItemUtils.setProfileByUUID(skull, uuid); return skull; - *///? } else { - return createSkull(uuid.toString()); // :shrug: - //? } } public ItemStack createSkull(GameProfile profile) { - //? if >= 1.21.1 { - /*var skull = Items.PLAYER_HEAD.getDefaultInstance(); - skull.set(DataComponents.PROFILE, new ResolvableProfile(profile)); + var skull = Items.PLAYER_HEAD.getDefaultInstance(); + ItemUtils.setProfile(skull, profile); return skull; - *///? } else { - return createSkull(profile.getName()); - //? } } } diff --git a/src/main/java/me/alexdevs/solstice/modules/smite/commands/SmiteCommand.java b/src/main/java/me/alexdevs/solstice/modules/smite/commands/SmiteCommand.java index f277afb0..785c3f54 100644 --- a/src/main/java/me/alexdevs/solstice/modules/smite/commands/SmiteCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/smite/commands/SmiteCommand.java @@ -6,17 +6,13 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import me.alexdevs.solstice.api.Raycast; import me.alexdevs.solstice.api.module.ModCommand; +import me.alexdevs.solstice.api.utils.EntityUtils; import me.alexdevs.solstice.modules.smite.SmiteModule; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.EntityArgument; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.EntityType; -//? if >= 1.21.4 { -/*import net.minecraft.world.entity.EntitySpawnReason; -*///? } else { -import net.minecraft.world.entity.MobSpawnType; -//? } import net.minecraft.world.phys.HitResult; import java.util.List; @@ -85,19 +81,6 @@ private int execute(CommandContext context, int times) throw } private void summon(ServerLevel world, BlockPos pos) { - entityType.create( - world, - //? if < 1.21.1 { - null, - //? } - world::addFreshEntity, - pos, - //? if >= 1.21.4 { - /*EntitySpawnReason.COMMAND, - *///? } else { - MobSpawnType.COMMAND, - //? } - false, - false); + EntityUtils.createWithCommand(entityType, world, world::addFreshEntity, pos, false, false); } } diff --git a/src/main/java/me/alexdevs/solstice/modules/spawn/SpawnModule.java b/src/main/java/me/alexdevs/solstice/modules/spawn/SpawnModule.java index 145f30d9..e5197192 100644 --- a/src/main/java/me/alexdevs/solstice/modules/spawn/SpawnModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/spawn/SpawnModule.java @@ -11,6 +11,7 @@ import me.alexdevs.solstice.modules.spawn.data.SpawnConfig; import me.alexdevs.solstice.modules.spawn.data.SpawnLocale; import me.alexdevs.solstice.modules.spawn.data.SpawnServerData; +import me.alexdevs.solstice.api.utils.ResourceUtils; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.minecraft.core.BlockPos; import net.minecraft.core.registries.Registries; @@ -88,11 +89,7 @@ public ServerLocation getSpawn() { public ServerLevel getGlobalSpawnWorld() { var targetWorld = getConfig().globalSpawn.targetSpawnWorld; - //? if >= 1.21.1 { - /*var key = ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(targetWorld)); - *///? } else { - var key = ResourceKey.create(Registries.DIMENSION, ResourceLocation.tryParse(targetWorld)); - //? } + var key = ResourceKey.create(Registries.DIMENSION, ResourceUtils.parse(targetWorld)); return Solstice.server.getLevel(key); } diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java b/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java index 26202ed2..2c08fe3f 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/CustomPlayerTeam.java @@ -1,32 +1,46 @@ -//? if >= 1.21.1 { -/*package me.alexdevs.solstice.modules.styling; +package me.alexdevs.solstice.modules.styling; import me.alexdevs.solstice.modules.ModuleProvider; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextColor; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.scores.PlayerTeam; import net.minecraft.world.scores.Scoreboard; import java.util.Collection; import java.util.List; + + +//? if >= 1.21.1 { +import net.minecraft.network.chat.TextColor; import java.util.Map; import java.util.stream.Collectors; +//? } else { +/*import net.minecraft.MethodsReturnNonnullByDefault; +@MethodsReturnNonnullByDefault +*///? } + public class CustomPlayerTeam extends PlayerTeam { + + private final ServerPlayer player; + + public CustomPlayerTeam(Scoreboard scoreboard, ServerPlayer player) { + super(scoreboard, "sol_" + player.getGameProfile().getName()); + this.player = player; + super.getPlayers().add(player.getGameProfile().getName()); + } +//? if >= 1.21.1 { + private final static Map COLOR_MAP = TextColor.NAMED_COLORS.entrySet().stream().collect(Collectors.toUnmodifiableMap(Map.Entry::getValue, entry -> textColorToFormatting(entry.getKey()))); + private static ChatFormatting textColorToFormatting(String name) { var value = ChatFormatting.getByName(name); if (value == null) return ChatFormatting.WHITE; return value; } + private static ChatFormatting getFormatting(TextColor color) { return COLOR_MAP.getOrDefault(color, ChatFormatting.WHITE); } - private final ServerPlayer player; - public CustomPlayerTeam(Scoreboard scoreboard, ServerPlayer player) { - super(scoreboard, "sol_" + player.getGameProfile().getName()); - this.player = player; - super.getPlayers().add(player.getGameProfile().getName()); - } + @Override public ChatFormatting getColor() { if (ModuleProvider.STYLING.shouldColorNameplate()) { @@ -34,57 +48,32 @@ public ChatFormatting getColor() { } return super.getColor(); } - @Override - public Component getPlayerPrefix() { - return ModuleProvider.STYLING.getNameplatePrefix(player); - } - @Override - public Component getPlayerSuffix() { - return ModuleProvider.STYLING.getNameplateSuffix(player); - } - @Override - public Collection getPlayers() { - return List.of(player.getGameProfile().getName()); - } -} -*///? } else { -package me.alexdevs.solstice.modules.styling; -import me.alexdevs.solstice.modules.ModuleProvider; -import net.minecraft.ChatFormatting; -import net.minecraft.MethodsReturnNonnullByDefault; -import net.minecraft.network.chat.Component; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.scores.PlayerTeam; -import net.minecraft.world.scores.Scoreboard; -import java.util.Collection; -import java.util.List; -@MethodsReturnNonnullByDefault -public class CustomPlayerTeam extends PlayerTeam { - private final ServerPlayer player; - public CustomPlayerTeam(Scoreboard scoreboard, ServerPlayer player) { - super(scoreboard, "sol_" + player.getGameProfile().getName()); - this.player = player; - super.getPlayers().add(player.getGameProfile().getName()); - } - @Override + +//? } else { + /*@Override public Component getDisplayName() { return player.getDisplayName(); } + @Override public ChatFormatting getColor() { return ModuleProvider.STYLING.getNameplateColor(player); } + +*///? } + @Override public Component getPlayerPrefix() { return ModuleProvider.STYLING.getNameplatePrefix(player); } + @Override public Component getPlayerSuffix() { return ModuleProvider.STYLING.getNameplateSuffix(player); } + @Override public Collection getPlayers() { return List.of(player.getGameProfile().getName()); } -} -//? } +} \ No newline at end of file diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/CustomSentMessage.java b/src/main/java/me/alexdevs/solstice/modules/styling/CustomSentMessage.java index 897207e1..5d31daa9 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/CustomSentMessage.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/CustomSentMessage.java @@ -65,11 +65,10 @@ public void sendToPlayer(ServerPlayer receiver, boolean filterMaskEnabled, ChatT return; } - //? if >= 1.21.1 { - /*switch (params.chatType().value().chat().translationKey()) { - *///? } else { - switch (params.chatType().chat().translationKey()) { - //? } + //? >= 1.21.1 + switch (params.chatType().value().chat().translationKey()) { + //? < 1.21.1 + //switch (params.chatType().chat().translationKey()) { case "chat.type.text": receiver.sendSystemMessage(this.formattedChatMessage); break; diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/StylingModule.java b/src/main/java/me/alexdevs/solstice/modules/styling/StylingModule.java index 73e874cb..a1e7ca8b 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/StylingModule.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/StylingModule.java @@ -8,32 +8,29 @@ import me.alexdevs.solstice.integrations.LuckPermsIntegration; import me.alexdevs.solstice.modules.styling.data.StylingConfig; import me.lucko.fabric.api.permissions.v0.Permissions; -//? if < 1.21.1 { -import net.minecraft.ChatFormatting; -//? } + import net.minecraft.network.chat.Component; -//? if < 1.21.1 { -import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket; -//? } import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.players.PlayerList; + //? if < 1.21.1 { +/*import net.minecraft.ChatFormatting; +import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket; import net.minecraft.world.scores.Scoreboard; import java.util.List; import java.util.concurrent.TimeUnit; -//? } +*///? } public class StylingModule extends ModuleBase.Toggleable { public static final String ADVANCED_CHAT_FORMATTING_PERMISSION = "solstice.chat.advanced"; public static final String LEGACY_CHAT_FORMATTING_PERMISSION = "solstice.chat.legacy"; public static final String SILENT_ACTIVITY_PERMISSION = "solstice.chat.activity.silent"; - //? if >= 1.21.1 { - /*private static final StylingConfig.NameplateFormat DEFAULT_NAMEPLATE = new StylingConfig.NameplateFormat("", ""); - *///? } else { - private static final StylingConfig.NameplateFormat DEFAULT_NAMEPLATE = new StylingConfig.NameplateFormat("", "", "WHITE"); - //? } + //? >= 1.21.1 + private static final StylingConfig.NameplateFormat DEFAULT_NAMEPLATE = new StylingConfig.NameplateFormat("", ""); + //? < 1.21.1 + //private static final StylingConfig.NameplateFormat DEFAULT_NAMEPLATE = new StylingConfig.NameplateFormat("", "", "WHITE"); public StylingModule(ResourceLocation id) { super(id); @@ -64,17 +61,17 @@ public void init() { }); //? if >= 1.21.1 { - /*SolsticeEvents.RELOAD.register(instance -> { + SolsticeEvents.RELOAD.register(instance -> { var playerList = Solstice.server.getPlayerList(); var scoreboard = Solstice.server.getScoreboard(); for (var player : playerList.getPlayers()) { playerList.updateEntireScoreboard(scoreboard, player); } }); - *///? } else { - SolsticeEvents.RELOAD.register(instance -> reloadNameplates(false)); + //? } else { + /*SolsticeEvents.RELOAD.register(instance -> reloadNameplates(false)); Solstice.scheduler.scheduleAtFixedRateSync(() -> reloadNameplates(false), 0, 1, TimeUnit.SECONDS); - //? } + *///? } } public StylingConfig getConfig() { @@ -110,11 +107,11 @@ public void broadcastActivity(PlayerList playerList, Component component, boolea } //? if >= 1.21.1 { - /*public boolean shouldColorNameplate() { + public boolean shouldColorNameplate() { return getConfig().doColorNameplate; } - *///? } else { - public ChatFormatting getNameplateColor(ServerPlayer player) { + //? } else { + /*public ChatFormatting getNameplateColor(ServerPlayer player) { var config = getConfig(); var primaryGroup = LuckPermsIntegration.getPrimaryGroup(player); var color = "WHITE"; @@ -125,7 +122,7 @@ public ChatFormatting getNameplateColor(ServerPlayer player) { } return ChatFormatting.getByName(color); } - //? } + *///? } public Component getNameplatePrefix(ServerPlayer player) { var config = getConfig(); @@ -154,7 +151,7 @@ public Component getNameplateSuffix(ServerPlayer player) { } //? if < 1.21.1 { - private void reloadNameplates(boolean add) { + /*private void reloadNameplates(boolean add) { var playerList = Solstice.server.getPlayerList(); var scoreboard = Solstice.server.getScoreboard(); for (var player : playerList.getPlayers()) { @@ -171,5 +168,5 @@ public void sendTeamSetup(ServerPlayer player, List players, Score player.connection.send(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, add)); } } - //? } + *///? } } diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/data/StylingConfig.java b/src/main/java/me/alexdevs/solstice/modules/styling/data/StylingConfig.java index a17fc75c..d7268617 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/data/StylingConfig.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/data/StylingConfig.java @@ -40,17 +40,16 @@ public class StylingConfig { @Comment("Nameplate formatting per group. group = format.\nPlaceholders here are not refreshed often.") public Map nameplateFormats = Map.of( - //? if >= 1.21.1 { - /*"default", new NameplateFormat("", "") - *///? } else { - "default", new NameplateFormat("", "", "green") - //? } + //? >= 1.21.1 + "default", new NameplateFormat("", "") + //? < 1.21.1 + //"default", new NameplateFormat("", "", "green") ); //? if >= 1.21.1 { - /*@Comment("Whether to color the username part in the nameplate of players.") + @Comment("Whether to color the username part in the nameplate of players.") public boolean doColorNameplate = true; - *///? } + //? } @Comment("Emote format (/me)") public String emoteFormat = "\uD83D\uDC64 %player:displayname% ${message}"; @@ -71,9 +70,9 @@ public class StylingConfig { public String welcome = "Welcome %player:displayname% to the server!"; @ConfigSerializable - //? if >= 1.21.1 { - /*public record NameplateFormat(String prefix, String suffix) { } - *///? } else { - public record NameplateFormat(String prefix, String suffix, String color) { } - //? } + //? >= 1.21.1 + public record NameplateFormat(String prefix, String suffix) { } + //? < 1.21.1 + //public record NameplateFormat(String prefix, String suffix, String color) { } + } diff --git a/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java b/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java index fa7b3b64..44a1a4b8 100644 --- a/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java +++ b/src/main/java/me/alexdevs/solstice/modules/styling/formatters/AdvancementFormatter.java @@ -3,29 +3,30 @@ import eu.pb4.placeholders.api.PlaceholderContext; import me.alexdevs.solstice.api.text.Format; import me.alexdevs.solstice.modules.ModuleProvider; -//? if >= 1.21.1 { -/*import net.minecraft.advancements.AdvancementHolder; -import net.minecraft.advancements.AdvancementType; -*///? } else { -import net.minecraft.advancements.Advancement; -//? } import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import java.util.Map; +//? if >= 1.21.1 { +import net.minecraft.advancements.AdvancementHolder; +import net.minecraft.advancements.AdvancementType; +//? } else { +/*import net.minecraft.advancements.Advancement; +*///? } + + public class AdvancementFormatter { //? if >= 1.21.1 { - /*public static Component getText(ServerPlayer player, AdvancementHolder entry, AdvancementType frame) { + public static Component getText(ServerPlayer player, AdvancementHolder entry, AdvancementType frame) { var title = entry.value().display().get().getTitle(); var description = entry.value().display().get().getDescription(); - *///? } else { - public static Component getText(ServerPlayer player, Advancement advancement) { + //? } else { + /*public static Component getText(ServerPlayer player, Advancement advancement) { var frame = advancement.getDisplay().getFrame(); - var frameId = frame.getName(); var title = advancement.getDisplay().getTitle(); var description = advancement.getDisplay().getDescription(); - //? } + *///? } var config = ModuleProvider.STYLING.getConfig(); @@ -38,11 +39,7 @@ public static Component getText(ServerPlayer player, Advancement advancement) { var playerContext = PlaceholderContext.of(player); Map placeholders = Map.of( - //? if >= 1.21.1 { - /*"frame", frame.getDisplayName(), - *///? } else { "frame", frame.getDisplayName(), - //? } "title", title, "description", description ); diff --git a/src/main/java/me/alexdevs/solstice/modules/sudo/commands/DoAsCommand.java b/src/main/java/me/alexdevs/solstice/modules/sudo/commands/DoAsCommand.java index 1b1785ef..f8afd7b4 100644 --- a/src/main/java/me/alexdevs/solstice/modules/sudo/commands/DoAsCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/sudo/commands/DoAsCommand.java @@ -30,6 +30,16 @@ public static void execute(CommandDispatcher dispatcher, Str } } + public static CommandSource getCommandOutput(CommandSourceStack source) { + if (source.isPlayer()) { + return source.getPlayer() + //? >= 1.21.4 + //.commandSource() + ; + } + return source.getServer(); + } + public static CommandSourceStack buildPlayerSource(CommandSource commandOutput, MinecraftServer server, ServerPlayer player) { var opList = server.getPlayerList().getOps(); var operator = opList.get(player.getGameProfile()); @@ -73,16 +83,7 @@ public LiteralArgumentBuilder command(String name) { context.getSource().sendSuccess(() -> Component.literal(String.format("Executing '%s' as %s", command, stringProfiles)), true); - CommandSource commandOutput; - if (context.getSource().isPlayer()) { - //? if >= 1.21.4 { - /*commandOutput = context.getSource().getPlayer().commandSource(); - *///? } else { - commandOutput = context.getSource().getPlayer(); - //? } - } else { - commandOutput = context.getSource().getServer(); - } + var commandOutput = getCommandOutput(context.getSource()); var server = context.getSource().getServer(); for (var player : players) { diff --git a/src/main/java/me/alexdevs/solstice/modules/sudo/commands/SudoCommand.java b/src/main/java/me/alexdevs/solstice/modules/sudo/commands/SudoCommand.java index 7dfe2760..b1c73b05 100644 --- a/src/main/java/me/alexdevs/solstice/modules/sudo/commands/SudoCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/sudo/commands/SudoCommand.java @@ -50,16 +50,7 @@ public LiteralArgumentBuilder command(String name) { context.getSource().sendSuccess(() -> Component.literal(String.format("Executing '%s' as Server", command)), true); - CommandSource commandOutput; - if (context.getSource().isPlayer()) { - //? if >= 1.21.4 { - /*commandOutput = context.getSource().getPlayer().commandSource(); - *///? } else { - commandOutput = context.getSource().getPlayer(); - //? } - } else { - commandOutput = context.getSource().getServer(); - } + var commandOutput = DoAsCommand.getCommandOutput(context.getSource()); var server = context.getSource().getServer(); var source = buildServerSource(commandOutput, server); diff --git a/src/main/java/me/alexdevs/solstice/modules/suicide/commands/SuicideCommand.java b/src/main/java/me/alexdevs/solstice/modules/suicide/commands/SuicideCommand.java index c11a3393..9916902d 100644 --- a/src/main/java/me/alexdevs/solstice/modules/suicide/commands/SuicideCommand.java +++ b/src/main/java/me/alexdevs/solstice/modules/suicide/commands/SuicideCommand.java @@ -26,11 +26,10 @@ public LiteralArgumentBuilder command(String name) { .executes(context -> { var player = context.getSource().getPlayerOrException(); - //? if >= 1.21.4 { - /*player.kill(player.serverLevel()); - *///? } else { + //? >= 1.21.4 + //player.kill(player.serverLevel()); + //? < 1.21.4 player.kill(); - //? } return 1; }); diff --git a/stonecutter.gradle.kts b/stonecutter.gradle.kts index 1c94c009..80056fe4 100644 --- a/stonecutter.gradle.kts +++ b/stonecutter.gradle.kts @@ -1,4 +1,4 @@ plugins { id("dev.kikugie.stonecutter") } -stonecutter active "1.20.1" +stonecutter active "1.21.1" From 9a05a85045af337d5bca1d3caa81ec3552c937d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nelson=20Gra=C3=A7a?= Date: Wed, 25 Mar 2026 21:16:53 +0000 Subject: [PATCH 6/6] delete build.gradle, rebase leftovers --- build.gradle | 135 --------------------------------------------------- 1 file changed, 135 deletions(-) delete mode 100644 build.gradle diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 6c6d811b..00000000 --- a/build.gradle +++ /dev/null @@ -1,135 +0,0 @@ -import com.modrinth.minotaur.dependencies.ModDependency -plugins { - id 'fabric-loom' version '1.11-SNAPSHOT' - id 'maven-publish' - id "com.modrinth.minotaur" version "2.+" -} - -version = "${project.mod_version}+${project.minecraft_version}" -group = project.maven_group - -base { - archivesName = project.archives_base_name -} - -repositories { - mavenLocal() - - maven { - name = 'ParchmentMC' - url = 'https://maven.parchmentmc.org' - } - - maven { url 'https://maven.nucleoid.xyz' } - - maven { - name = "TerraformersMC" - url = "https://maven.terraformersmc.com/" - } - maven { - name = "Ladysnake Libs" - url = 'https://maven.ladysnake.org/releases' - } -} - -loom { - accessWidenerPath = file("src/main/resources/solstice.accesswidener") -} - -dependencies { - // To change the versions see the gradle.properties file - minecraft "com.mojang:minecraft:${project.minecraft_version}" - - mappings loom.layered() { - officialMojangMappings() - parchment("org.parchmentmc.data:parchment-${project.minecraft_version}:${project.parchment_mappings}@zip") - } - - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - - include implementation("org.spongepowered:configurate-core:${project.configurate_version}") - include implementation("org.spongepowered:configurate-hocon:${project.configurate_version}") - include implementation("org.spongepowered:configurate-gson:${project.configurate_version}") - include "com.typesafe:config:1.4.3" - include "io.leangen.geantyref:geantyref:1.3.16" - - include modImplementation("me.lucko:fabric-permissions-api:${project.permissions_api_version}") - - include modImplementation("eu.pb4:placeholder-api:${project.placeholderapi_version}") - include modImplementation("eu.pb4:sgui:${project.sgui_version}") - modImplementation include("eu.pb4:common-economy-api:${project.commoneconomy_version}") - - modCompileOnly "dev.emi:trinkets:${project.trinkets_version}" - - modCompileOnly "net.luckperms:api:5.4" - modRuntimeOnly "net.luckperms:api:5.4" -} - -processResources { - inputs.property "version", project.version - - filesMatching("fabric.mod.json") { - expand "version": project.version - } -} - -tasks.withType(JavaCompile).configureEach { - it.options.release = 21 -} - -java { - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() - - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 -} - -jar { - from("LICENSE") { - rename { "${it}_${project.base.archivesName.get()}"} - } -} - -modrinth { - token = System.getenv("MODRINTH_TOKEN") - projectId = 'uIvrDZas' - uploadFile = remapJar - gameVersions = [project.minecraft_version] - loaders = ['fabric'] - dependencies = [ - new ModDependency('P7dR8mSH', 'required') // Fabric API - ] -} - -// configure the maven publication -publishing { - publications { - create("mavenJava", MavenPublication) { - artifactId = project.archives_base_name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - // Notice: This block does NOT have the same function as the block in the top level. - // The repositories here will be used for publishing your artifact, not for - // retrieving dependencies. - - - maven { - name = "AlexDevsRepo" - url = "https://maven.alexdevs.me/releases" - credentials { - username = System.getenv("MAVEN_USERNAME") - password = System.getenv("MAVEN_PASSWORD") - } - } - } -} \ No newline at end of file