-
-
Notifications
You must be signed in to change notification settings - Fork 822
Support legacy versions of Fabric and NeoForge #5728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 6 commits
0c9e524
c27fc80
0cc0c6b
8a06bf0
fc358a9
76c1a8b
efb8388
5aba664
e9c21e2
97eb5d7
29fa0a5
3336526
3fadccb
8a72109
9de1070
26ad23a
4e715b3
2a39a59
0692506
18c34ef
c9eb3eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.Setter; | ||
| import net.minecraft.SharedConstants; | ||
| import net.minecraft.server.MinecraftServer; | ||
| import org.checkerframework.checker.nullness.qual.NonNull; | ||
| import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
|
@@ -54,7 +55,6 @@ | |
|
|
||
| @RequiredArgsConstructor | ||
| public abstract class GeyserModBootstrap implements GeyserBootstrap { | ||
|
|
||
| @Getter | ||
| private static GeyserModBootstrap instance; | ||
|
|
||
|
|
@@ -85,6 +85,15 @@ public void onGeyserInitialize() { | |
| } | ||
| this.geyserLogger.setDebug(geyserConfig.isDebugMode()); | ||
| GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger); | ||
|
|
||
| if (!ModConstants.isModernVersion() && !this.platform.testViaPresent(this)) { | ||
| this.geyserLogger.error("-------------------------------------------------------------------------"); | ||
| this.geyserLogger.error("The current server version is not supported unless ViaVersion is present!"); | ||
| this.geyserLogger.error("Geyser will not start unless you add ViaVersion!"); | ||
| this.geyserLogger.error("-------------------------------------------------------------------------"); | ||
| return; | ||
| } | ||
|
Comment on lines
+93
to
+99
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could also throw a runtime exception :p
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should try depend in the adapters, but if that causes Neo issues, I think the current solution works good enough |
||
|
|
||
| this.geyser = GeyserImpl.load(this.platform.platformType(), this); | ||
| } | ||
|
|
||
|
|
@@ -104,7 +113,7 @@ public void onGeyserEnable() { | |
|
|
||
| GeyserImpl.start(); | ||
|
|
||
| if (geyserConfig.isLegacyPingPassthrough()) { | ||
| if (geyserConfig.isLegacyPingPassthrough() || !ModConstants.isModernVersion()) { | ||
| this.geyserPingPassthrough = GeyserLegacyPingPassthrough.init(geyser); | ||
| } else { | ||
| this.geyserPingPassthrough = new ModPingPassthrough(server, geyserLogger); | ||
|
|
@@ -115,12 +124,12 @@ public void onGeyserEnable() { | |
| return; | ||
| } | ||
|
|
||
| this.geyserWorldManager = new GeyserModWorldManager(server); | ||
| this.geyserWorldManager = ModConstants.isModernVersion() ? new GeyserModWorldManager(server) : null; | ||
|
|
||
| // We want to do this late in the server startup process to allow other mods | ||
| // To do their job injecting, then connect into *that* | ||
| this.geyserInjector = new GeyserModInjector(server, this.platform); | ||
| if (isServer()) { | ||
| this.geyserInjector = ModConstants.isModernVersion() ? new GeyserModInjector(server, this.platform) : null; | ||
| if (isServer() && this.geyserInjector != null) { | ||
| this.geyserInjector.initializeLocalChannel(this); | ||
| } | ||
| } | ||
|
|
@@ -166,7 +175,7 @@ public IGeyserPingPassthrough getGeyserPingPassthrough() { | |
|
|
||
| @Override | ||
| public WorldManager getWorldManager() { | ||
| return geyserWorldManager; | ||
| return geyserWorldManager == null ? DEFAULT_CHUNK_MANAGER : geyserWorldManager; | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -181,7 +190,7 @@ public BootstrapDumpInfo getDumpInfo() { | |
|
|
||
| @Override | ||
| public String getMinecraftServerVersion() { | ||
| return this.server.getServerVersion(); | ||
| return ModConstants.CURRENT_VERSION; | ||
| } | ||
|
|
||
| @SuppressWarnings("ConstantConditions") // Certain IDEA installations think that ip cannot be null | ||
|
|
@@ -194,12 +203,12 @@ public String getServerBindAddress() { | |
|
|
||
| @Override | ||
| public SocketAddress getSocketAddress() { | ||
| return this.geyserInjector.getServerSocketAddress(); | ||
| return this.geyserInjector == null ? null : this.geyserInjector.getServerSocketAddress(); | ||
| } | ||
|
|
||
| @Override | ||
| public int getServerPort() { | ||
| if (isServer()) { | ||
| if (isServer() && ModConstants.isModernVersion()) { | ||
| return ((GeyserServerPortGetter) server).geyser$getServerPort(); | ||
| } else { | ||
| // Set in the IntegratedServerMixin | ||
|
|
@@ -214,6 +223,11 @@ public boolean testFloodgatePluginPresent() { | |
| return this.platform.testFloodgatePluginPresent(this); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isStandaloneCommandManager() { | ||
| return !ModConstants.isModernVersion(); | ||
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public InputStream getResourceOrNull(String resource) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /* | ||
| * Copyright (c) 2025 GeyserMC. http://geysermc.org | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in | ||
| * all copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| * THE SOFTWARE. | ||
| * | ||
| * @author GeyserMC | ||
| * @link https://github.com/GeyserMC/Geyser | ||
| */ | ||
|
|
||
| package org.geysermc.geyser.platform.mod; | ||
|
|
||
| import net.minecraft.DetectedVersion; | ||
| import net.minecraft.WorldVersion; | ||
| import org.objectweb.asm.tree.ClassNode; | ||
| import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; | ||
| import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
|
|
||
| import java.lang.reflect.InvocationTargetException; | ||
| import java.lang.reflect.Method; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
| public class GeyserModMixinPlugin implements IMixinConfigPlugin { | ||
| @Override | ||
| public void onLoad(String s) { | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public String getRefMapperConfig() { | ||
| return ""; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { | ||
| WorldVersion worldVersion = DetectedVersion.tryDetectVersion(); | ||
|
|
||
| List<String> potentialMethods = List.of("name", "getName", "comp_4024", "method_48019"); | ||
|
|
||
| Method nameMethod = null; | ||
|
|
||
| for (String methodName : potentialMethods) { | ||
| try { | ||
| nameMethod = worldVersion.getClass().getMethod(methodName); | ||
| break; | ||
| } catch (NoSuchMethodException ignored) {} | ||
| } | ||
|
|
||
| if (nameMethod == null) throw new IllegalStateException("Unable to determine suitable method for getting Minecraft version."); | ||
|
|
||
| try { | ||
| return !mixinClassName.startsWith("org.geysermc.geyser.platform.mod.mixin") || nameMethod.invoke(worldVersion).equals(ModConstants.MODERN_VERSION); | ||
| } catch (IllegalAccessException | InvocationTargetException e) { | ||
| throw new RuntimeException(e); // This hopefully, will never happen | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void acceptTargets(Set<String> set, Set<String> set1) { | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public List<String> getMixins() { | ||
| return List.of(); | ||
| } | ||
|
|
||
| @Override | ||
| public void preApply(String s, ClassNode classNode, String s1, IMixinInfo iMixinInfo) { | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public void postApply(String s, ClassNode classNode, String s1, IMixinInfo iMixinInfo) { | ||
|
|
||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.