diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 46138a749..a2be2b7da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,7 @@ jobs: uses: actions/setup-java@v5 with: distribution: 'temurin' - java-version: 21 + java-version: 25 cache: 'gradle' - name: Tests run: ./gradlew spotlessCheck test --stacktrace @@ -44,7 +44,7 @@ jobs: uses: actions/setup-java@v5 with: distribution: 'temurin' - java-version: 21 + java-version: 25 cache: 'gradle' - name: Build with Gradle run: ./gradlew release --stacktrace diff --git a/buildSrc/src/main/kotlin/bluemap.java.gradle.kts b/buildSrc/src/main/kotlin/bluemap.java.gradle.kts index cdd04bfa9..1fdefc0af 100644 --- a/buildSrc/src/main/kotlin/bluemap.java.gradle.kts +++ b/buildSrc/src/main/kotlin/bluemap.java.gradle.kts @@ -5,6 +5,22 @@ plugins { id ( "com.diffplug.spotless" ) } +var libs = project.extensions.getByType(VersionCatalogsExtension::class).named("libs") + +dependencies { + compileOnly ( libs.findLibrary("jetbrains-annotations").get() ) + compileOnly ( libs.findLibrary("lombok").get() ) + + annotationProcessor ( libs.findLibrary("lombok").get() ) + + testImplementation( platform(libs.findLibrary("junit-bom").get()) ) + testImplementation( libs.findBundle("junit-jupiter").get() ) + testAnnotationProcessor ( libs.findLibrary("lombok").get() ) + + testRuntimeOnly( libs.findBundle("junit-runtime").get() ) + testRuntimeOnly ( libs.findLibrary("lombok").get() ) +} + tasks.withType(JavaCompile::class).configureEach { options.encoding = "utf-8" } @@ -15,7 +31,7 @@ tasks.withType(AbstractArchiveTask::class).configureEach { } java { - toolchain.languageVersion = JavaLanguageVersion.of(21) + toolchain.languageVersion = JavaLanguageVersion.of(25) withSourcesJar() withJavadocJar() } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 6ba74f2a7..d09d0f0a6 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -14,17 +14,6 @@ dependencies { compileOnly ( libs.bluecommands.brigadier ) compileOnly ( libs.brigadier ) - - compileOnly ( libs.jetbrains.annotations ) - compileOnly ( libs.lombok ) - - annotationProcessor ( libs.lombok ) - - // tests - testImplementation ( libs.junit.core ) - testRuntimeOnly ( libs.junit.engine ) - testRuntimeOnly ( libs.lombok ) - testAnnotationProcessor ( libs.lombok ) } node { diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 5420f73bb..8dfbd9ec9 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -12,17 +12,6 @@ dependencies { api ( libs.configurate.hocon ) api ( libs.configurate.gson ) api ( libs.lz4 ) - - compileOnly ( libs.jetbrains.annotations ) - compileOnly ( libs.lombok ) - - annotationProcessor ( libs.lombok ) - - // tests - testImplementation ( libs.junit.core ) - testRuntimeOnly ( libs.junit.engine ) - testRuntimeOnly ( libs.lombok ) - testAnnotationProcessor ( libs.lombok ) } tasks.register("zipResourceExtensions", type = Zip::class) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5afd24c81..8089509d4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ adventure = "4.23.0" bluecommands = "1.3.4" bstats = "2.2.1" configurate = "4.1.2" -junit = "5.8.2" +junit = "6.1.0-M1" spongegradle = "2.2.0" [libraries] @@ -27,20 +27,28 @@ flow-math = { module = "com.flowpowered:flow-math", version = "1.0.3" } gson = { module = "com.google.code.gson:gson", version = "2.8.9" } guava = { module = "com.google.guava:guava", version = "33.3.0-jre" } jetbrains-annotations = { module = "org.jetbrains:annotations", version = "23.0.0" } -junit-core = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" } -junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" } -lombok = { module = "org.projectlombok:lombok", version = "1.18.32" } +junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" } +junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" } +junit-vintage-engine = { module = "org.junit.vintage:junit-vintage-engine" } +junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine" } +junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api" } +junit-jupiter = { module = "org.junit.jupiter:junit-jupiter" } +lombok = { module = "org.projectlombok:lombok", version = "1.18.42" } lz4 = { module = "at.yawk.lz4:lz4-java", version = "1.8.1" } [plugins] cursegradle = { id = "com.matthewprenger.cursegradle", version = "1.4.0" } forgegradle = { id = "net.minecraftforge.gradle", version = "[6.0.24,6.2)" } hangar = { id = "io.papermc.hangar-publish-plugin", version = "0.1.2" } -loom = { id = "fabric-loom", version = "1.13-SNAPSHOT" } +loom = { id = "net.fabricmc.fabric-loom", version = "1.15-SNAPSHOT" } minotaur = { id = "com.modrinth.minotaur", version = "2.8.7" } node-gradle = { id = "com.github.node-gradle.node", version = "7.0.2" } neoforge-gradle = { id = "net.neoforged.moddev", version = "2.0.107" } shadow = { id = "com.gradleup.shadow", version = "9.1.0" } sponge-plugin = { id = "org.spongepowered.gradle.plugin", version.ref = "spongegradle" } sponge-ore = { id = "org.spongepowered.gradle.ore", version.ref = "spongegradle" } -spotless = { id = "com.diffplug.spotless", version = "6.25.0" } \ No newline at end of file +spotless = { id = "com.diffplug.spotless", version = "6.25.0" } + +[bundles] +junit-runtime = [ "junit-platform-launcher", "junit-vintage-engine", "junit-jupiter-engine" ] +junit-jupiter = [ "junit-jupiter", "junit-jupiter-api" ] \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index a4b76b953..1b33c55ba 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ca025c83a..dbc3ce4a0 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 index f5feea6d6..23d15a936 100755 --- a/gradlew +++ b/gradlew @@ -86,8 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -115,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -206,7 +205,7 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. @@ -214,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 9d21a2183..db3a6ac20 100755 --- a/gradlew.bat +++ b/gradlew.bat @@ -70,11 +70,11 @@ goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/implementations/fabric/build.gradle.kts b/implementations/fabric/build.gradle.kts index d4e014dc3..83b6dbd43 100644 --- a/implementations/fabric/build.gradle.kts +++ b/implementations/fabric/build.gradle.kts @@ -1,5 +1,4 @@ import com.matthewprenger.cursegradle.CurseRelation -import net.fabricmc.loom.task.RemapJarTask plugins { bluemap.implementation @@ -9,13 +8,13 @@ plugins { } val supportedMinecraftVersions = listOf( - "1.21.11" + "26.1-snapshot-11" ) val minecraftVersion = supportedMinecraftVersions.first() -val yarnMappings = "${minecraftVersion}+build.1" -val fabricLoaderVersion = "0.18.2" -val fabricApiVersion = "0.139.4+${minecraftVersion}" +val fabricLoaderVersion = "0.18.4" +//val fabricApiVersion = "0.143.11+${minecraftVersion}" +val fabricApiVersion = "0.143.11+26.1" val shadowInclude: Configuration by configurations.creating configurations.api.get().extendsFrom(shadowInclude) @@ -27,10 +26,9 @@ dependencies { } minecraft ("com.mojang:minecraft:${minecraftVersion}") - mappings ("net.fabricmc:yarn:${yarnMappings}") - modImplementation ("net.fabricmc:fabric-loader:${fabricLoaderVersion}") - modImplementation ("net.fabricmc.fabric-api:fabric-api:${fabricApiVersion}") - modImplementation ( libs.fabric.permissions ) + implementation ("net.fabricmc:fabric-loader:${fabricLoaderVersion}") + implementation ("net.fabricmc.fabric-api:fabric-api:${fabricApiVersion}") + implementation ( libs.fabric.permissions ) shadowInclude ( libs.bluecommands.brigadier ) { exclude ( group = "com.mojang", module = "brigadier" ) @@ -85,7 +83,8 @@ tasks.withType(ProcessResources::class).configureEach { val replacements = mapOf( "version" to project.version, "fabric_loader_version" to fabricLoaderVersion, - "minecraft_version" to minecraftVersion, + "minecraft_version" to "26.1-alpha.11", + //"minecraft_version" to minecraftVersion, "java_version" to java.toolchain.languageVersion.get() ) inputs.properties(replacements) @@ -94,16 +93,25 @@ tasks.withType(ProcessResources::class).configureEach { )) { expand(replacements) } } -val remappedShadowJar = tasks.register("remappedShadowJar", type = RemapJarTask::class) { - dependsOn (tasks.shadowJar) - archiveFileName = "${project.name}-${project.version}-shadow-remapped.jar" - inputFile = tasks.shadowJar.flatMap { it.archiveFile } - addNestedDependencies = true +val mergeShadowAndJarJar = tasks.register("mergeShadowAndJarJar") { + dependsOn( tasks.shadowJar, tasks.jar ) + from ( + zipTree( tasks.shadowJar.map { it.outputs.files.singleFile } ).matching { + exclude("fabric.mod.json") + }, + zipTree( tasks.jar.map { it.outputs.files.singleFile } ).matching { + include("META-INF/jars/**") + include("fabric.mod.json") + } + ).exclude( + "META-INF/services/net.kyori.adventure*" // not correctly relocated and not needed -> exclude + ) + archiveFileName = "${project.name}-${project.version}-merged.jar" } tasks.getByName("release") { - dependsOn(remappedShadowJar) - inputFile = remappedShadowJar.flatMap { it.archiveFile } + dependsOn(mergeShadowAndJarJar) + inputFile = mergeShadowAndJarJar.flatMap { it.archiveFile } } modrinth { diff --git a/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricCommandSource.java b/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricCommandSource.java index a97df6034..13a51cbf4 100644 --- a/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricCommandSource.java +++ b/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricCommandSource.java @@ -30,25 +30,19 @@ import de.bluecolored.bluemap.common.commands.TextFormat; import de.bluecolored.bluemap.common.serverinterface.CommandSource; import de.bluecolored.bluemap.common.serverinterface.ServerWorld; -import me.lucko.fabric.api.permissions.v0.Permissions; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; -import net.minecraft.command.DefaultPermissions; -import net.minecraft.command.permission.Permission; -import net.minecraft.command.permission.PermissionLevel; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.text.Text; -import net.minecraft.text.TextCodecs; -import net.minecraft.util.math.Vec3d; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.network.chat.ComponentSerialization; import java.util.Optional; public class FabricCommandSource implements CommandSource { private final FabricMod mod; - private final ServerCommandSource delegate; + private final CommandSourceStack delegate; - public FabricCommandSource(FabricMod mod, ServerCommandSource delegate) { + public FabricCommandSource(FabricMod mod, CommandSourceStack delegate) { this.mod = mod; this.delegate = delegate; } @@ -59,23 +53,27 @@ public void sendMessage(Component text) { text = Component.newline().append(text).appendNewline(); JsonElement textJson = GsonComponentSerializer.gson().serializeToTree(text.compact()); - Text minecraftText = TextCodecs.CODEC.parse(JsonOps.INSTANCE, textJson).getOrThrow(); - delegate.sendMessage(minecraftText); + net.minecraft.network.chat.Component minecraftText = ComponentSerialization.CODEC.parse(JsonOps.INSTANCE, textJson).getOrThrow(); + delegate.sendSystemMessage(minecraftText); } @Override public boolean hasPermission(String permission) { + /* TODO: re-enable permission-api support once fabric-permission-api is updated try { Class.forName("me.lucko.fabric.api.permissions.v0.Permissions"); return Permissions.check(delegate, permission, PermissionLevel.MODERATORS); } catch (ClassNotFoundException ex) { - return delegate.getPermissions().hasPermission(DefaultPermissions.MODERATORS); + return delegate.permissions().hasPermission(net.minecraft.server.permissions.Permissions.COMMANDS_MODERATOR); } + */ + + return delegate.permissions().hasPermission(net.minecraft.server.permissions.Permissions.COMMANDS_MODERATOR); } @Override public Optional getPosition() { - if (!delegate.isExecutedByPlayer() && delegate.getName().equals("Server")) return Optional.empty(); + if (!delegate.isPlayer() && delegate.getTextName().equals("Server")) return Optional.empty(); return Optional.ofNullable(delegate.getPosition()) .map(pos -> new Vector3d(pos.x, pos.y, pos.z)); @@ -83,9 +81,9 @@ public Optional getPosition() { @Override public Optional getWorld() { - if (!delegate.isExecutedByPlayer() && delegate.getName().equals("Server")) return Optional.empty(); + if (!delegate.isPlayer() && delegate.getTextName().equals("Server")) return Optional.empty(); - return Optional.ofNullable(delegate.getWorld()) + return Optional.ofNullable(delegate.getLevel()) .map(mod::getServerWorld); } diff --git a/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricEventForwarder.java b/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricEventForwarder.java index f2cd2e0cf..c8b154a23 100644 --- a/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricEventForwarder.java +++ b/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricEventForwarder.java @@ -27,8 +27,7 @@ import de.bluecolored.bluemap.common.serverinterface.ServerEventListener; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.network.ServerPlayerEntity; - +import net.minecraft.server.level.ServerPlayer; import java.util.ArrayList; import java.util.Collection; import java.util.UUID; @@ -61,17 +60,17 @@ public synchronized void removeAllListeners() { this.eventListeners.clear(); } - public synchronized void onPlayerJoin(MinecraftServer server, ServerPlayerEntity player) { + public synchronized void onPlayerJoin(MinecraftServer server, ServerPlayer player) { if (this.mod.getServer() != server) return; - UUID uuid = player.getUuid(); + UUID uuid = player.getUUID(); for (ServerEventListener listener : eventListeners) listener.onPlayerJoin(uuid); } - public synchronized void onPlayerLeave(MinecraftServer server, ServerPlayerEntity player) { + public synchronized void onPlayerLeave(MinecraftServer server, ServerPlayer player) { if (this.mod.getServer() != server) return; - UUID uuid = player.getUuid(); + UUID uuid = player.getUUID(); for (ServerEventListener listener : eventListeners) listener.onPlayerLeave(uuid); } diff --git a/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricMod.java b/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricMod.java index 82e04026f..a0f9ba03f 100644 --- a/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricMod.java +++ b/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricMod.java @@ -41,13 +41,13 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.minecraft.SharedConstants; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.Identifier; -import net.minecraft.world.World; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.Level; import org.apache.logging.log4j.LogManager; import java.io.IOException; @@ -62,7 +62,7 @@ public class FabricMod implements ModInitializer, Server { private final FabricEventForwarder eventForwarder; - private final LoadingCache worlds; + private final LoadingCache worlds; private int playerUpdateIndex = 0; private final Map onlinePlayerMap; @@ -92,7 +92,7 @@ public void onInitialize() { BrigadierBridge.createCommandNodes( Commands.create(pluginInstance), new BrigadierExecutionHandler(pluginInstance), - (ServerCommandSource fabricSource) -> new FabricCommandSource(this, fabricSource) + (CommandSourceStack fabricSource) -> new FabricCommandSource(this, fabricSource) ).forEach(dispatcher.getRoot()::addChild) ); @@ -139,7 +139,7 @@ public void onInitialize() { @Override public String getMinecraftVersion() { - return SharedConstants.getGameVersion().comp_4024(); + return SharedConstants.getCurrentVersion().id(); } @Override @@ -155,7 +155,7 @@ public void unregisterAllListeners() { @Override public Collection getLoadedServerWorlds() { Collection loadedWorlds = new ArrayList<>(3); - for (net.minecraft.server.world.ServerWorld serverWorld : serverInstance.getWorlds()) { + for (net.minecraft.server.level.ServerLevel serverWorld : serverInstance.getAllLevels()) { loadedWorlds.add(worlds.get(serverWorld)); } return loadedWorlds; @@ -167,22 +167,22 @@ public Optional getServerWorld(Object world) { if (world instanceof String) { Identifier identifier = Identifier.tryParse((String) world); - if (identifier != null) world = serverInstance.getWorld(RegistryKey.of(RegistryKeys.WORLD, identifier)); + if (identifier != null) world = serverInstance.getLevel(ResourceKey.create(Registries.DIMENSION, identifier)); } - if (world instanceof RegistryKey) { + if (world instanceof ResourceKey) { try { - world = serverInstance.getWorld((RegistryKey) world); + world = serverInstance.getLevel((ResourceKey) world); } catch (ClassCastException ignored) {} } - if (world instanceof net.minecraft.server.world.ServerWorld) - return Optional.of(getServerWorld((net.minecraft.server.world.ServerWorld) world)); + if (world instanceof net.minecraft.server.level.ServerLevel) + return Optional.of(getServerWorld((net.minecraft.server.level.ServerLevel) world)); return Optional.empty(); } - public ServerWorld getServerWorld(net.minecraft.server.world.ServerWorld serverWorld) { + public ServerWorld getServerWorld(net.minecraft.server.level.ServerLevel serverWorld) { return worlds.get(Objects.requireNonNull(serverWorld)); } @@ -196,7 +196,7 @@ public Optional getModsFolder() { return Optional.of(Path.of("mods")); } - public void onPlayerJoin(MinecraftServer server, ServerPlayerEntity playerInstance) { + public void onPlayerJoin(MinecraftServer server, ServerPlayer playerInstance) { if (this.serverInstance != server) return; FabricPlayer player = new FabricPlayer(playerInstance, this); @@ -204,10 +204,10 @@ public void onPlayerJoin(MinecraftServer server, ServerPlayerEntity playerInstan onlinePlayerList.add(player); } - public void onPlayerLeave(MinecraftServer server, ServerPlayerEntity player) { + public void onPlayerLeave(MinecraftServer server, ServerPlayer player) { if (this.serverInstance != server) return; - UUID playerUUID = player.getUuid(); + UUID playerUUID = player.getUUID(); onlinePlayerMap.remove(playerUUID); synchronized (onlinePlayerList) { onlinePlayerList.removeIf(p -> p.getUuid().equals(playerUUID)); diff --git a/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricPlayer.java b/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricPlayer.java index 0808939c9..d7d8b9cfd 100644 --- a/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricPlayer.java +++ b/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricPlayer.java @@ -29,26 +29,25 @@ import de.bluecolored.bluemap.common.serverinterface.Gamemode; import de.bluecolored.bluemap.common.serverinterface.Player; import de.bluecolored.bluemap.common.serverinterface.ServerWorld; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.GameMode; -import net.minecraft.world.LightType; - +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.level.GameType; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.phys.Vec3; import java.util.EnumMap; import java.util.Map; import java.util.UUID; public class FabricPlayer extends Player { - private static final Map GAMEMODE_MAP = new EnumMap<>(GameMode.class); + private static final Map GAMEMODE_MAP = new EnumMap<>(GameType.class); static { - GAMEMODE_MAP.put(GameMode.ADVENTURE, Gamemode.ADVENTURE); - GAMEMODE_MAP.put(GameMode.SURVIVAL, Gamemode.SURVIVAL); - GAMEMODE_MAP.put(GameMode.CREATIVE, Gamemode.CREATIVE); - GAMEMODE_MAP.put(GameMode.SPECTATOR, Gamemode.SPECTATOR); + GAMEMODE_MAP.put(GameType.ADVENTURE, Gamemode.ADVENTURE); + GAMEMODE_MAP.put(GameType.SURVIVAL, Gamemode.SURVIVAL); + GAMEMODE_MAP.put(GameType.CREATIVE, Gamemode.CREATIVE); + GAMEMODE_MAP.put(GameType.SPECTATOR, Gamemode.SPECTATOR); } private final UUID uuid; @@ -64,8 +63,8 @@ public class FabricPlayer extends Player { private final FabricMod mod; - public FabricPlayer(ServerPlayerEntity player, FabricMod mod) { - this.uuid = player.getUuid(); + public FabricPlayer(ServerPlayer player, FabricMod mod) { + this.uuid = player.getUUID(); this.mod = mod; update(player); @@ -128,30 +127,30 @@ public void update() { MinecraftServer server = mod.getServer(); if (server == null) return; - ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); + ServerPlayer player = server.getPlayerList().getPlayer(uuid); if (player == null) return; update(player); } - private void update(ServerPlayerEntity player) { - this.gamemode = GAMEMODE_MAP.get(player.interactionManager.getGameMode()); + private void update(ServerPlayer player) { + this.gamemode = GAMEMODE_MAP.get(player.gameMode.getGameModeForPlayer()); if (this.gamemode == null) this.gamemode = Gamemode.SURVIVAL; - StatusEffectInstance invis = player.getStatusEffect(StatusEffects.INVISIBILITY); + MobEffectInstance invis = player.getEffect(MobEffects.INVISIBILITY); this.invisible = invis != null && invis.getDuration() > 0; this.name = Text.of(player.getName().getString()); - Vec3d pos = player.getEntityPos(); - this.position = new Vector3d(pos.getX(), pos.getY(), pos.getZ()); - this.rotation = new Vector3d(player.getPitch(), player.getHeadYaw(), 0); - this.sneaking = player.isSneaking(); + Vec3 pos = player.position(); + this.position = new Vector3d(pos.x(), pos.y(), pos.z()); + this.rotation = new Vector3d(player.getXRot(), player.getYHeadRot(), 0); + this.sneaking = player.isShiftKeyDown(); - net.minecraft.server.world.ServerWorld world = player.getEntityWorld(); + net.minecraft.server.level.ServerLevel world = player.level(); - this.skyLight = world.getLightingProvider().get(LightType.SKY).getLightLevel(player.getBlockPos()); - this.blockLight = world.getLightingProvider().get(LightType.BLOCK).getLightLevel(player.getBlockPos()); + this.skyLight = world.getLightEngine().getLayerListener(LightLayer.SKY).getLightValue(player.blockPosition()); + this.blockLight = world.getLightEngine().getLayerListener(LightLayer.BLOCK).getLightValue(player.blockPosition()); this.world = mod.getServerWorld(world); } diff --git a/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricWorld.java b/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricWorld.java index 6f461a3f9..0f41eb0bf 100644 --- a/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricWorld.java +++ b/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricWorld.java @@ -26,10 +26,9 @@ import de.bluecolored.bluemap.common.serverinterface.ServerWorld; import de.bluecolored.bluemap.core.util.Key; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.Identifier; -import net.minecraft.util.WorldSavePath; - +import net.minecraft.world.level.storage.LevelResource; import java.io.IOException; import java.lang.ref.WeakReference; import java.nio.file.Path; @@ -40,23 +39,23 @@ public class FabricWorld implements ServerWorld { - private final WeakReference delegate; + private final WeakReference delegate; private final Path worldFolder; private final Key dimension; - public FabricWorld(net.minecraft.server.world.ServerWorld delegate) { + public FabricWorld(net.minecraft.server.level.ServerLevel delegate) { this.delegate = new WeakReference<>(delegate); MinecraftServer server = Objects.requireNonNull(delegate.getServer()); - this.worldFolder = server.getRunDirectory().resolve(server.getSavePath(WorldSavePath.ROOT)); + this.worldFolder = server.getServerDirectory().resolve(server.getWorldPath(LevelResource.ROOT)); - Identifier id = delegate.getRegistryKey().getValue(); + Identifier id = delegate.dimension().identifier(); this.dimension = new Key(id.getNamespace(), id.getPath()); } @Override public boolean persistWorldChanges() throws IOException { - net.minecraft.server.world.ServerWorld world = delegate.get(); + net.minecraft.server.level.ServerLevel world = delegate.get(); if (world == null) return false; var taskResult = CompletableFuture.supplyAsync(() -> { diff --git a/settings.gradle.kts b/settings.gradle.kts index cd2481e72..4e84e9651 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -24,11 +24,11 @@ include(":common") implementation("cli") implementation("fabric") -implementation("forge") -implementation("neoforge") -implementation("paper") -implementation("spigot") -implementation("sponge") +//implementation("forge") +//implementation("neoforge") +//implementation("paper") +//implementation("spigot") +//implementation("sponge") fun implementation(name: String) { val project = ":$name"