Skip to content
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

NeoForge Platform Support #3781

Merged
merged 49 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
7d8b623
Initial work on Forge platform
Redned235 May 20, 2023
6f20d72
Rework modded platforms to use a common module
Redned235 May 22, 2023
3c7730e
Merge branch 'master' into feature/forge-platform
Redned235 Jun 10, 2023
e2e9c92
Add support for integrated worlds on modded platforms
Redned235 Jun 10, 2023
c94df50
Merge branch 'master' into feature/forge-platform
Redned235 Jun 17, 2023
4f1ca3d
Fix classload errors and move mixins to shared module
Redned235 Jun 17, 2023
e4a62bd
Fix Fabric mixins and check min height in mod world manager
Redned235 Jun 17, 2023
65dd8c1
Add Forge command support
Redned235 Jun 17, 2023
9020b5e
Add back modrinth publishing
Redned235 Jun 17, 2023
56ad80c
Don't apply application plugin to shared mod sources
Redned235 Jun 17, 2023
bc38c2f
Fix docs
Redned235 Jun 17, 2023
1d26194
Delete unused class
Redned235 Jun 17, 2023
2dabe46
Clean up repositories
Redned235 Jun 17, 2023
1e025b6
Merge remote-tracking branch 'upstream/master' into feature/forge-pla…
onebeastchris Oct 24, 2023
6f01dff
- Update to 1.20.2
onebeastchris Oct 24, 2023
e584c18
- Fix ClassNotFound errors on Forge due to weird Classloader
onebeastchris Oct 31, 2023
31deca9
Merge pull request #4261 from onebeastchris/feature/forge-platform
onebeastchris Nov 1, 2023
da5a7bc
Merge remote-tracking branch 'upstream/master' into feature/forge-pla…
onebeastchris Nov 18, 2023
91bf88d
merge upstream
onebeastchris Nov 18, 2023
dc292b5
oh no
onebeastchris Nov 18, 2023
8594ee1
Bump lombok, architectury-loom
onebeastchris Nov 19, 2023
071ee2a
Merge remote-tracking branch 'upstream/master' into feature/forge-pla…
onebeastchris Dec 21, 2023
0b6f558
init: neoforge 1.20.4 support
onebeastchris Dec 21, 2023
f4f49cd
NeoForge builds
Kas-tle Dec 22, 2023
fbbfa96
Archive neoforge artifacts
Kas-tle Dec 22, 2023
3726b27
Merge pull request #13 from Kas-tle/feature/neoforge
onebeastchris Dec 22, 2023
8ee9c45
transformForge -> transformNeoForge
onebeastchris Dec 26, 2023
178a886
Merge remote-tracking branch 'upstream/master' into feature/forge-pla…
onebeastchris Jan 10, 2024
afacada
Neoforge boots!
onebeastchris Jan 10, 2024
b9ab9fe
more fixes
onebeastchris Jan 12, 2024
a5883bc
Merge remote-tracking branch 'upstream/feature/forge-platform' into f…
onebeastchris Jan 16, 2024
1d3914f
yeet platform executor
onebeastchris Jan 17, 2024
6ab0e7e
yet another temp branch to figure out the runServer task
onebeastchris Jan 18, 2024
f640f97
yeet transitive dependency, that cant be right
onebeastchris Jan 21, 2024
7d4a69f
Attempt at getting the runServer task to work, part two
onebeastchris Jan 21, 2024
96c4731
Revert the changes for the runServer task, try and shut down the inje…
onebeastchris Jan 21, 2024
e94ef30
Remove spigot weird bug workaround, shut down properly
onebeastchris Jan 21, 2024
bb76158
Update forge feature branch to 1.20.4, target NeoForge
onebeastchris Jan 21, 2024
d6fb7a1
Merge branch 'master' into feature/forge-platform
onebeastchris Feb 7, 2024
1bd5d49
Merge remote-tracking branch 'upstream/master' into feature/forge-pla…
onebeastchris Feb 14, 2024
db7346a
Update to latest restart changes
onebeastchris Feb 14, 2024
af7e8d3
Merge remote-tracking branch 'upstream/feature/forge-platform' into f…
onebeastchris Feb 14, 2024
fd52a44
Consistent NeoForge spelling, move some dependencies to the version toml
onebeastchris Feb 19, 2024
0a755e4
Add lombok to version catalogue
onebeastchris Feb 19, 2024
7754077
Merge remote-tracking branch 'upstream/master' into feature/forge-pla…
onebeastchris Feb 19, 2024
1c4bf5c
Add plugins to version catalogue
onebeastchris Feb 20, 2024
af97df0
revert move to buildSrc
onebeastchris Feb 20, 2024
2a484f4
Create `assets/geyser/icon.png` to reference icon from a single file …
onebeastchris Feb 21, 2024
ebbba9a
add fabric permissions api to libs.versions.toml
onebeastchris Feb 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ jobs:
if: success()
with:
name: Geyser Fabric
path: bootstrap/fabric/build/libs/Geyser-Fabric.jar
path: bootstrap/mod/fabric/build/libs/Geyser-Fabric.jar
if-no-files-found: error
- name: Archive artifacts (Geyser NeoForge)
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
if: success()
with:
name: Geyser NeoForge
path: bootstrap/mod/neoforge/build/libs/Geyser-NeoForge.jar
if-no-files-found: error
- name: Archive artifacts (Geyser Standalone)
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
Expand Down Expand Up @@ -111,15 +118,24 @@ jobs:
echo "{\"project\": \"$project\", \"version\": \"$version\", \"id\": $GITHUB_RUN_NUMBER, \"commit\": \"$GITHUB_SHA\"}" > metadata.json
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" metadata.json $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$project/$GITHUB_RUN_NUMBER/

- name: Publish to Modrinth
- name: Publish to Modrinth (Fabric)
uses: gradle/gradle-build-action@3bfe3a46584a206fb8361cdedd0647b0c4204232
if: ${{ success() && github.repository == 'GeyserMC/Geyser' && github.ref_name == 'master' }}
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
with:
arguments: fabric:modrinth
gradle-home-cache-cleanup: true


- name: Publish to Modrinth (NeoForge)
uses: gradle/gradle-build-action@3bfe3a46584a206fb8361cdedd0647b0c4204232
if: ${{ success() && github.repository == 'GeyserMC/Geyser' && github.ref_name == 'master' }}
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
with:
arguments: neoforge:modrinth
gradle-home-cache-cleanup: true

- name: Notify Discord
if: ${{ (success() || failure()) && github.repository == 'GeyserMC/Geyser' }}
# See https://github.com/Tim203/actions-git-discord-webhook/commits
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ jobs:
if: success()
with:
name: Geyser Fabric
path: geyser/bootstrap/fabric/build/libs/Geyser-Fabric.jar
path: geyser/bootstrap/mod/fabric/build/libs/Geyser-Fabric.jar
if-no-files-found: error
- name: Archive artifacts (Geyser NeoForge)
uses: actions/upload-artifact@v3
if: success()
with:
name: Geyser NeoForge
path: geyser/bootstrap/mod/neoforge/build/libs/Geyser-NeoForge.jar
if-no-files-found: error
- name: Archive artifacts (Geyser Standalone)
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ public abstract class PathPackCodec extends PackCodec {
*/
@NonNull
public abstract Path path();
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +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 NEOFORGE = new PlatformType("NeoForge");
public static final PlatformType SPIGOT = new PlatformType("Spigot");

@Deprecated
Expand Down
15 changes: 0 additions & 15 deletions bootstrap/fabric/src/main/resources/geyser-fabric.mixins.json

This file was deleted.

15 changes: 15 additions & 0 deletions bootstrap/mod/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
architectury {
common("neoforge", "fabric")
}

loom {
mixin.defaultRefmapName.set("geyser-refmap.json")
}

dependencies {
api(projects.core)
compileOnly(libs.mixin)

// Only here to suppress "unknown enum constant EnvType.CLIENT" warnings. DO NOT USE!
compileOnly(libs.fabric.loader)
}
49 changes: 49 additions & 0 deletions bootstrap/mod/fabric/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
plugins {
application
}

architectury {
platformSetupLoomIde()
fabric()
}

dependencies {
modImplementation(libs.fabric.loader)
modApi(libs.fabric.api)

api(project(":mod", configuration = "namedElements"))
shadow(project(path = ":mod", configuration = "transformProductionFabric")) {
isTransitive = false
}
shadow(projects.core) {
exclude(group = "com.google.guava", module = "guava")
exclude(group = "com.google.code.gson", module = "gson")
exclude(group = "org.slf4j")
exclude(group = "com.nukkitx.fastutil")
exclude(group = "io.netty.incubator")
}

// This should be in the libs TOML, but something about modImplementation AND include just doesn't work
include(modImplementation("me.lucko", "fabric-permissions-api", "0.2-SNAPSHOT"))
}

application {
mainClass.set("org.geysermc.geyser.platform.fabric.GeyserFabricMain")
}

tasks {
remapJar {
archiveBaseName.set("Geyser-Fabric")
}

remapModrinthJar {
archiveBaseName.set("geyser-fabric")
}
}

modrinth {
loaders.add("fabric")
dependencies {
required.project("fabric-api")
}
}
1 change: 1 addition & 0 deletions bootstrap/mod/fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loom.platform=fabric
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2019-2023 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.fabric;

import me.lucko.fabric.api.permissions.v0.Permissions;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.world.entity.player.Player;
import org.geysermc.geyser.platform.mod.GeyserModBootstrap;
import org.geysermc.geyser.platform.mod.GeyserModUpdateListener;
import org.checkerframework.checker.nullness.qual.NonNull;

public class GeyserFabricBootstrap extends GeyserModBootstrap implements ModInitializer {

public GeyserFabricBootstrap() {
super(new GeyserFabricPlatform());
}

@Override
public void onInitialize() {
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER) {
// Set as an event, so we can get the proper IP and port if needed
ServerLifecycleEvents.SERVER_STARTED.register((server) -> {
this.setServer(server);
onGeyserEnable();
});
}

// These are only registered once
ServerLifecycleEvents.SERVER_STOPPING.register((server) -> onGeyserShutdown());
ServerPlayConnectionEvents.JOIN.register((handler, $, $$) -> GeyserModUpdateListener.onPlayReady(handler.getPlayer()));

this.onGeyserInitialize();
}

@Override
public boolean hasPermission(@NonNull Player source, @NonNull String permissionNode) {
return Permissions.check(source, permissionNode);
}

@Override
public boolean hasPermission(@NonNull CommandSourceStack source, @NonNull String permissionNode, int permissionLevel) {
return Permissions.check(source, permissionNode, permissionLevel);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright (c) 2019-2023 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.fabric;

import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.minecraft.server.MinecraftServer;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
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.Path;
import java.util.Optional;

public class GeyserFabricPlatform implements GeyserModPlatform {
private final ModContainer mod;

public GeyserFabricPlatform() {
this.mod = FabricLoader.getInstance().getModContainer("geyser-fabric").orElseThrow();
}

@Override
public @NonNull PlatformType platformType() {
return PlatformType.FABRIC;
}

@Override
public @NonNull String configPath() {
return "Geyser-Fabric";
}

@Override
public @NonNull Path dataFolder(@NonNull String modId) {
return FabricLoader.getInstance().getConfigDir().resolve(modId);
}

@Override
public @NonNull BootstrapDumpInfo dumpInfo(@NonNull MinecraftServer server) {
return new GeyserFabricDumpInfo(server);
}

@Override
public boolean testFloodgatePluginPresent(@NonNull GeyserModBootstrap bootstrap) {
Optional<ModContainer> floodgate = FabricLoader.getInstance().getModContainer("floodgate");
if (floodgate.isPresent()) {
Path floodgateDataFolder = FabricLoader.getInstance().getConfigDir().resolve("floodgate");
bootstrap.getGeyserConfig().loadFloodgate(bootstrap, floodgateDataFolder);
return true;
}

return false;
}

@Override
public @Nullable InputStream resolveResource(@NonNull String resource) {
// We need to handle this differently, because Fabric shares the classloader across multiple mods
Path path = this.mod.findPath(resource).orElse(null);
if (path == null) {
return null;
}

try {
return path.getFileSystem()
.provider()
.newInputStream(path);
} catch (IOException e) {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
],
"contact": {
"website": "${url}",
"repo": "https://github.com/GeyserMC/Geyser-Fabric"
"repo": "https://github.com/GeyserMC/Geyser"
},
"license": "MIT",
"icon": "assets/geyser-fabric/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"org.geysermc.geyser.platform.fabric.GeyserFabricMod"
"org.geysermc.geyser.platform.fabric.GeyserFabricBootstrap"
]
},
"mixins": [
"geyser-fabric.mixins.json"
"geyser.mixins.json"
],
"depends": {
"fabricloader": ">=0.15.2",
Expand Down
Loading
Loading