From f4f49cd10a1c2791568f4ff810a2d3a67d9ad35f Mon Sep 17 00:00:00 2001 From: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> Date: Thu, 21 Dec 2023 16:27:00 -0800 Subject: [PATCH] NeoForge builds Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> --- .../geyser/api/util/PlatformType.java | 2 +- bootstrap/mod/build.gradle.kts | 6 ++++- bootstrap/mod/neoforge/build.gradle.kts | 10 +++++++- ...trap.java => GeyserNeoforgeBootstrap.java} | 24 +++++++++---------- ...pInfo.java => GeyserNeoforgeDumpInfo.java} | 12 +++++----- ...ForgeMain.java => GeyserNeoforgeMain.java} | 2 +- ...a => GeyserNeoforgePermissionHandler.java} | 14 +++++------ .../neoforge/GeyserNeoforgePlatform.java | 2 +- .../platform/mod/GeyserModBootstrap.java | 4 +--- .../mod/command/GeyserModCommandExecutor.java | 2 +- .../mod/world/GeyserModWorldManager.java | 1 + build.gradle.kts | 2 +- 12 files changed, 46 insertions(+), 35 deletions(-) rename bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/{GeyserForgeBootstrap.java => GeyserNeoforgeBootstrap.java} (81%) rename bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/{GeyserForgeDumpInfo.java => GeyserNeoforgeDumpInfo.java} (88%) rename bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/{GeyserForgeMain.java => GeyserNeoforgeMain.java} (97%) rename bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/{GeyserForgePermissionHandler.java => GeyserNeoforgePermissionHandler.java} (92%) diff --git a/api/src/main/java/org/geysermc/geyser/api/util/PlatformType.java b/api/src/main/java/org/geysermc/geyser/api/util/PlatformType.java index fc775bddd17..d59360e0431 100644 --- a/api/src/main/java/org/geysermc/geyser/api/util/PlatformType.java +++ b/api/src/main/java/org/geysermc/geyser/api/util/PlatformType.java @@ -34,7 +34,7 @@ public record PlatformType(String platformName) { public static final PlatformType ANDROID = new PlatformType("Android"); public static final PlatformType BUNGEECORD = new PlatformType("BungeeCord"); public static final PlatformType FABRIC = new PlatformType("Fabric"); - public static final PlatformType FORGE = new PlatformType("Forge"); + public static final PlatformType NEOFORGE = new PlatformType("NeoForge"); public static final PlatformType SPIGOT = new PlatformType("Spigot"); @Deprecated diff --git a/bootstrap/mod/build.gradle.kts b/bootstrap/mod/build.gradle.kts index 0a8171f3a5d..35be258785e 100644 --- a/bootstrap/mod/build.gradle.kts +++ b/bootstrap/mod/build.gradle.kts @@ -6,4 +6,8 @@ dependencies { api(projects.core) compileOnly(libs.mixin) -} \ No newline at end of file +} + +// Fails without due to shadow in neoforge somehow depending on this task +// Should see if there's a better way to workaround this +configurations.create("transformProductionForge") \ No newline at end of file diff --git a/bootstrap/mod/neoforge/build.gradle.kts b/bootstrap/mod/neoforge/build.gradle.kts index 324ca785873..764e6f29b8e 100644 --- a/bootstrap/mod/neoforge/build.gradle.kts +++ b/bootstrap/mod/neoforge/build.gradle.kts @@ -1,5 +1,6 @@ plugins { application + eclipse } architectury { @@ -17,6 +18,13 @@ loom { } dependencies { + // See https://github.com/google/guava/issues/6618 + modules { + module("com.google.guava:listenablefuture") { + replacedBy("com.google.guava:guava", "listenablefuture is part of guava") + } + } + neoForge(libs.neoforge.minecraft) api(projects.mod) @@ -24,7 +32,7 @@ dependencies { isTransitive = false } shadow(projects.core) { - //exclude(group = "com.google.guava", module = "guava") + exclude(group = "com.google.guava", module = "guava") exclude(group = "com.google.code.gson", module = "gson") exclude(group = "org.slf4j") exclude(group = "io.netty.incubator") diff --git a/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserForgeBootstrap.java b/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgeBootstrap.java similarity index 81% rename from bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserForgeBootstrap.java rename to bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgeBootstrap.java index 146dbfc4b8a..35eef6ae2ed 100644 --- a/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserForgeBootstrap.java +++ b/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgeBootstrap.java @@ -23,18 +23,18 @@ * @link https://github.com/GeyserMC/Geyser */ -package org.geysermc.geyser.platform.forge; +package org.geysermc.geyser.platform.neoforge; import net.minecraft.Util; import net.minecraft.commands.CommandSourceStack; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.player.PlayerEvent; -import net.minecraftforge.event.server.ServerStartedEvent; -import net.minecraftforge.event.server.ServerStoppedEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.loading.FMLLoader; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.event.entity.player.PlayerEvent; +import net.neoforged.neoforge.event.server.ServerStartedEvent; +import net.neoforged.neoforge.event.server.ServerStoppedEvent; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.loading.FMLLoader; import org.checkerframework.checker.nullness.qual.NonNull; import org.geysermc.geyser.platform.mod.GeyserModBootstrap; import org.geysermc.geyser.platform.mod.GeyserModUpdateListener; @@ -52,7 +52,7 @@ public GeyserNeoforgeBootstrap() { if (FMLLoader.getDist() == Dist.DEDICATED_SERVER) { // Set as an event so we can get the proper IP and port if needed - MinecraftForge.EVENT_BUS.addListener(this::onServerStarted); + NeoForge.EVENT_BUS.addListener(this::onServerStarted); } } @@ -60,10 +60,10 @@ public GeyserNeoforgeBootstrap() { public void onInitialStartup() { // Server has yet to start // Register onDisable so players are properly kicked - MinecraftForge.EVENT_BUS.addListener(this::onServerStopped); - MinecraftForge.EVENT_BUS.addListener(this::onPlayerJoin); + NeoForge.EVENT_BUS.addListener(this::onServerStopped); + NeoForge.EVENT_BUS.addListener(this::onPlayerJoin); - MinecraftForge.EVENT_BUS.addListener(this.permissionHandler::onPermissionGather); + NeoForge.EVENT_BUS.addListener(this.permissionHandler::onPermissionGather); } private void onServerStarted(ServerStartedEvent event) { diff --git a/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserForgeDumpInfo.java b/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgeDumpInfo.java similarity index 88% rename from bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserForgeDumpInfo.java rename to bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgeDumpInfo.java index 08d47e1a44a..94a19c9dafd 100644 --- a/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserForgeDumpInfo.java +++ b/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgeDumpInfo.java @@ -28,10 +28,10 @@ import lombok.AllArgsConstructor; import lombok.Getter; import net.minecraft.server.MinecraftServer; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.loading.FMLLoader; -import net.minecraftforge.forgespi.language.IModInfo; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.fml.ModList; +import net.neoforged.fml.loading.FMLLoader; +import net.neoforged.neoforgespi.language.IModInfo; import org.geysermc.geyser.dump.BootstrapDumpInfo; import org.geysermc.geyser.text.AsteriskSerializer; @@ -50,8 +50,8 @@ public class GeyserNeoforgeDumpInfo extends BootstrapDumpInfo { private final int serverPort; private final List mods; - public GeyseNeoforgeDumpInfo(MinecraftServer server) { - this.platformVersion = FMLLoader.versionInfo().mcAndForgeVersion(); + public GeyserNeoforgeDumpInfo(MinecraftServer server) { + this.platformVersion = FMLLoader.versionInfo().mcAndNeoFormVersion(); this.dist = FMLLoader.getDist(); this.serverIP = server.getLocalIp() == null ? "unknown" : server.getLocalIp(); this.serverPort = server.getPort(); diff --git a/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserForgeMain.java b/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgeMain.java similarity index 97% rename from bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserForgeMain.java rename to bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgeMain.java index 3e6910b549c..61917992aef 100644 --- a/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserForgeMain.java +++ b/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgeMain.java @@ -23,7 +23,7 @@ * @link https://github.com/GeyserMC/Geyser */ -package org.geysermc.geyser.platform.forge; +package org.geysermc.geyser.platform.neoforge; import org.geysermc.geyser.GeyserMain; diff --git a/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserForgePermissionHandler.java b/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgePermissionHandler.java similarity index 92% rename from bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserForgePermissionHandler.java rename to bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgePermissionHandler.java index 9fbbb5344c0..4fb83055b05 100644 --- a/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserForgePermissionHandler.java +++ b/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgePermissionHandler.java @@ -23,17 +23,17 @@ * @link https://github.com/GeyserMC/Geyser */ -package org.geysermc.geyser.platform.forge; +package org.geysermc.geyser.platform.neoforge; import net.minecraft.commands.CommandSourceStack; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.server.permission.PermissionAPI; -import net.minecraftforge.server.permission.events.PermissionGatherEvent; -import net.minecraftforge.server.permission.nodes.PermissionDynamicContextKey; -import net.minecraftforge.server.permission.nodes.PermissionNode; -import net.minecraftforge.server.permission.nodes.PermissionType; -import net.minecraftforge.server.permission.nodes.PermissionTypes; +import net.neoforged.neoforge.server.permission.PermissionAPI; +import net.neoforged.neoforge.server.permission.events.PermissionGatherEvent; +import net.neoforged.neoforge.server.permission.nodes.PermissionDynamicContextKey; +import net.neoforged.neoforge.server.permission.nodes.PermissionNode; +import net.neoforged.neoforge.server.permission.nodes.PermissionType; +import net.neoforged.neoforge.server.permission.nodes.PermissionTypes; import org.geysermc.geyser.Constants; import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.api.command.Command; diff --git a/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgePlatform.java b/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgePlatform.java index 817bdae502f..5e88d0007b4 100644 --- a/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgePlatform.java +++ b/bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoforgePlatform.java @@ -26,7 +26,7 @@ package org.geysermc.geyser.platform.neoforge; import net.minecraft.server.MinecraftServer; -import net.minecraftforge.fml.loading.FMLPaths; +import net.neoforged.fml.loading.FMLPaths; import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.api.util.PlatformType; import org.geysermc.geyser.dump.BootstrapDumpInfo; diff --git a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModBootstrap.java b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModBootstrap.java index a260c5c0bd3..ea43ba6db22 100644 --- a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModBootstrap.java +++ b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModBootstrap.java @@ -52,8 +52,6 @@ import org.geysermc.geyser.platform.mod.world.GeyserModWorldManager; import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.util.FileUtils; -import org.checkerframework.checker.nullness.qual.NonNull; -import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.IOException; @@ -245,7 +243,7 @@ public String getMinecraftServerVersion() { return this.server.getServerVersion(); } - @NotNull + @NonNull @Override public String getServerBindAddress() { String ip = this.server.getLocalIp(); diff --git a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/command/GeyserModCommandExecutor.java b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/command/GeyserModCommandExecutor.java index bf707c1c893..60b72e2aa35 100644 --- a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/command/GeyserModCommandExecutor.java +++ b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/command/GeyserModCommandExecutor.java @@ -57,7 +57,7 @@ public int run(CommandContext context) { public int runWithArgs(CommandContext context, String args) { CommandSourceStack source = context.getSource(); - FabricCommandSender sender = new FabricCommandSender(source); + ModCommandSender sender = new ModCommandSender(source); GeyserSession session = getGeyserSession(sender); if (!testPermission(source)) { sender.sendMessage(ChatColor.RED + GeyserLocale.getPlayerLocaleString("geyser.bootstrap.command.permission_fail", sender.locale())); diff --git a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/world/GeyserModWorldManager.java b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/world/GeyserModWorldManager.java index f2fb18b540e..04c5386320e 100644 --- a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/world/GeyserModWorldManager.java +++ b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/world/GeyserModWorldManager.java @@ -57,6 +57,7 @@ import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.LevelChunkSection; import org.checkerframework.checker.nullness.qual.NonNull; import org.cloudburstmc.math.vector.Vector3i; import org.cloudburstmc.nbt.NbtMap; diff --git a/build.gradle.kts b/build.gradle.kts index 882b65adba7..fba65e2fedd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ plugins { // Ensure AP works in eclipse (no effect on other IDEs) `eclipse` id("geyser.build-logic") - id("io.freefair.lombok") version "6.3.0" apply false + id("io.freefair.lombok") version "8.4" apply false } allprojects {