Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 07:40:10 +01:00
Ensure we load mod resources correctly on Geyser-NeoForge (#4651)
* correctly load jar resource files on neoforge * also add support for neoforge-floodgate
Dieser Commit ist enthalten in:
Ursprung
7801e357fb
Commit
86dafbc108
@ -31,7 +31,9 @@ dependencies {
|
|||||||
|
|
||||||
// Let's shade in our own api
|
// Let's shade in our own api
|
||||||
shadow(projects.api) { isTransitive = false }
|
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
|
// Include all transitive deps of core via JiJ
|
||||||
includeTransitive(projects.core)
|
includeTransitive(projects.core)
|
||||||
|
@ -27,6 +27,7 @@ package org.geysermc.geyser.platform.neoforge;
|
|||||||
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.neoforged.fml.ModContainer;
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
import net.neoforged.fml.loading.FMLLoader;
|
import net.neoforged.fml.loading.FMLLoader;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
@ -43,8 +44,8 @@ public class GeyserNeoForgeBootstrap extends GeyserModBootstrap {
|
|||||||
|
|
||||||
private final GeyserNeoForgePermissionHandler permissionHandler = new GeyserNeoForgePermissionHandler();
|
private final GeyserNeoForgePermissionHandler permissionHandler = new GeyserNeoForgePermissionHandler();
|
||||||
|
|
||||||
public GeyserNeoForgeBootstrap() {
|
public GeyserNeoForgeBootstrap(ModContainer container) {
|
||||||
super(new GeyserNeoForgePlatform());
|
super(new GeyserNeoForgePlatform(container));
|
||||||
|
|
||||||
if (isServer()) {
|
if (isServer()) {
|
||||||
// Set as an event so we can get the proper IP and port if needed
|
// Set as an event so we can get the proper IP and port if needed
|
||||||
|
@ -26,20 +26,29 @@
|
|||||||
package org.geysermc.geyser.platform.neoforge;
|
package org.geysermc.geyser.platform.neoforge;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.neoforged.fml.ModContainer;
|
||||||
|
import net.neoforged.fml.ModList;
|
||||||
import net.neoforged.fml.loading.FMLPaths;
|
import net.neoforged.fml.loading.FMLPaths;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.geysermc.geyser.GeyserBootstrap;
|
|
||||||
import org.geysermc.geyser.api.util.PlatformType;
|
import org.geysermc.geyser.api.util.PlatformType;
|
||||||
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
||||||
import org.geysermc.geyser.platform.mod.GeyserModBootstrap;
|
import org.geysermc.geyser.platform.mod.GeyserModBootstrap;
|
||||||
import org.geysermc.geyser.platform.mod.platform.GeyserModPlatform;
|
import org.geysermc.geyser.platform.mod.platform.GeyserModPlatform;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public class GeyserNeoForgePlatform implements GeyserModPlatform {
|
public class GeyserNeoForgePlatform implements GeyserModPlatform {
|
||||||
|
|
||||||
|
private final ModContainer container;
|
||||||
|
|
||||||
|
public GeyserNeoForgePlatform(ModContainer container) {
|
||||||
|
this.container = container;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull PlatformType platformType() {
|
public @NonNull PlatformType platformType() {
|
||||||
return PlatformType.NEOFORGE;
|
return PlatformType.NEOFORGE;
|
||||||
@ -62,11 +71,21 @@ public class GeyserNeoForgePlatform implements GeyserModPlatform {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean testFloodgatePluginPresent(@NonNull GeyserModBootstrap bootstrap) {
|
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
|
@Override
|
||||||
public @Nullable InputStream resolveResource(@NonNull String resource) {
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren