Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Shanwer committed May 13, 2024
2 parents 6413e4b + 86dafbc commit a8d8d77
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
4 changes: 3 additions & 1 deletion bootstrap/mod/neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ dependencies {

// Let's shade in our own api
shadow(projects.api) { isTransitive = false }
shadow(projects.common) { isTransitive = false }

// cannot be shaded, since neoforge will complain if floodgate-neoforge tries to provide this
include(projects.common)

// Include all transitive deps of core via JiJ
includeTransitive(projects.core)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import net.minecraft.commands.CommandSourceStack;
import net.minecraft.world.entity.player.Player;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.loading.FMLLoader;
import net.neoforged.neoforge.common.NeoForge;
Expand All @@ -43,8 +44,8 @@ public class GeyserNeoForgeBootstrap extends GeyserModBootstrap {

private final GeyserNeoForgePermissionHandler permissionHandler = new GeyserNeoForgePermissionHandler();

public GeyserNeoForgeBootstrap() {
super(new GeyserNeoForgePlatform());
public GeyserNeoForgeBootstrap(ModContainer container) {
super(new GeyserNeoForgePlatform(container));

if (isServer()) {
// Set as an event so we can get the proper IP and port if needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,29 @@
package org.geysermc.geyser.platform.neoforge;

import net.minecraft.server.MinecraftServer;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.ModList;
import net.neoforged.fml.loading.FMLPaths;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.dump.BootstrapDumpInfo;
import org.geysermc.geyser.platform.mod.GeyserModBootstrap;
import org.geysermc.geyser.platform.mod.platform.GeyserModPlatform;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;

public class GeyserNeoForgePlatform implements GeyserModPlatform {

private final ModContainer container;

public GeyserNeoForgePlatform(ModContainer container) {
this.container = container;
}

@Override
public @NonNull PlatformType platformType() {
return PlatformType.NEOFORGE;
Expand All @@ -62,11 +71,21 @@ public class GeyserNeoForgePlatform implements GeyserModPlatform {

@Override
public boolean testFloodgatePluginPresent(@NonNull GeyserModBootstrap bootstrap) {
return false; // No Floodgate mod for NeoForge yet
if (ModList.get().isLoaded("floodgate")) {
Path floodgateDataFolder = FMLPaths.CONFIGDIR.get().resolve("floodgate");
bootstrap.getGeyserConfig().loadFloodgate(bootstrap, floodgateDataFolder);
return true;
}
return false;
}

@Override
public @Nullable InputStream resolveResource(@NonNull String resource) {
return GeyserBootstrap.class.getClassLoader().getResourceAsStream(resource);
try {
Path path = container.getModInfo().getOwningFile().getFile().findResource(resource);
return Files.newInputStream(path);
} catch (IOException e) {
return null;
}
}
}

0 comments on commit a8d8d77

Please sign in to comment.