Skip to content

Commit

Permalink
NeoForge builds
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Castle <[email protected]>
  • Loading branch information
Kas-tle committed Dec 22, 2023
1 parent 0b6f558 commit f4f49cd
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion bootstrap/mod/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ dependencies {
api(projects.core)

compileOnly(libs.mixin)
}
}

// 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")
10 changes: 9 additions & 1 deletion bootstrap/mod/neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
application
eclipse
}

architectury {
Expand All @@ -17,14 +18,21 @@ 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)
shadow(project(path = ":mod", configuration = "transformProductionForge")) {
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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -52,18 +52,18 @@ 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);
}
}

@Override
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -50,8 +50,8 @@ public class GeyserNeoforgeDumpInfo extends BootstrapDumpInfo {
private final int serverPort;
private final List<ModInfo> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -245,7 +243,7 @@ public String getMinecraftServerVersion() {
return this.server.getServerVersion();
}

@NotNull
@NonNull
@Override
public String getServerBindAddress() {
String ip = this.server.getLocalIp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public int run(CommandContext<CommandSourceStack> context) {

public int runWithArgs(CommandContext<CommandSourceStack> 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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f4f49cd

Please sign in to comment.