mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-15 17:05:09 +01:00
MidnightLib 1.5.2 - NeoForge & more cleanness
- Native support for NeoForge (& dropped support for regular Forge) - Cleanup of some code -> Overview button is now added via callbacks instead of a mixin - Unify client & server classes - Minor breaking change only affecting mods using the hiding functionality
This commit is contained in:
79
neoforge/build.gradle
Normal file
79
neoforge/build.gradle
Normal file
@@ -0,0 +1,79 @@
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||
}
|
||||
repositories{
|
||||
maven {url "https://maven.neoforged.net/releases"}
|
||||
}
|
||||
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
neoForge()
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = project(":common").loom.accessWidenerPath
|
||||
}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentForge.extendsFrom common
|
||||
archivesBaseName = rootProject.archives_base_name + "-neoforge"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}"
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false }
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("META-INF/mods.toml") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
exclude "fabric.mod.json"
|
||||
exclude "architectury.common.json"
|
||||
|
||||
configurations = [project.configurations.shadowCommon]
|
||||
archiveClassifier = "dev-shadow"
|
||||
}
|
||||
|
||||
remapJar {
|
||||
atAccessWideners.add('midnightlib.accesswidener')
|
||||
input.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
}
|
||||
|
||||
sourcesJar {
|
||||
def commonSources = project(":common").sourcesJar
|
||||
dependsOn commonSources
|
||||
from commonSources.archiveFile.map { zipTree(it) }
|
||||
}
|
||||
|
||||
components.java {
|
||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||
skip()
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenForge(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name + "-" + project.name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
1
neoforge/gradle.properties
Normal file
1
neoforge/gradle.properties
Normal file
@@ -0,0 +1 @@
|
||||
loom.platform=neoforge
|
||||
@@ -0,0 +1,28 @@
|
||||
package eu.midnightdust.lib.util.neoforge;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import eu.midnightdust.lib.util.PlatformFunctions;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
import net.neoforged.fml.loading.FMLPaths;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class PlatformFunctionsImpl {
|
||||
/**
|
||||
* This is our actual method to {@link PlatformFunctions#getConfigDirectory()}.
|
||||
*/
|
||||
public static Path getConfigDirectory() {
|
||||
return FMLPaths.CONFIGDIR.get();
|
||||
}
|
||||
public static boolean isClientEnv() {
|
||||
return FMLEnvironment.dist.isClient();
|
||||
}
|
||||
public static boolean isModLoaded(String modid) {
|
||||
return ModList.get().isLoaded(modid);
|
||||
}
|
||||
public static void registerCommand(LiteralArgumentBuilder<ServerCommandSource> command) {
|
||||
// Ignored here, see MidnightLibServerEvents#registerCommands
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package eu.midnightdust.neoforge;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import eu.midnightdust.core.MidnightLib;
|
||||
import eu.midnightdust.core.screen.MidnightConfigOverviewScreen;
|
||||
import eu.midnightdust.lib.config.AutoCommand;
|
||||
import eu.midnightdust.lib.config.MidnightConfig;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.IExtensionPoint;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
import net.neoforged.neoforge.client.ConfigScreenHandler;
|
||||
import net.neoforged.neoforge.client.event.ScreenEvent;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
|
||||
import static net.neoforged.fml.IExtensionPoint.DisplayTest.IGNORESERVERONLY;
|
||||
|
||||
@Mod("midnightlib")
|
||||
public class MidnightLibNeoForge {
|
||||
public MidnightLibNeoForge() {
|
||||
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> IGNORESERVERONLY, (remote, server) -> true));
|
||||
if (FMLEnvironment.dist == Dist.CLIENT) MidnightLib.onInitializeClient(); else MidnightLib.onInitializeServer();
|
||||
}
|
||||
@Mod.EventBusSubscriber(modid = "midnightlib", bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
public static class MidnightLibBusEvents {
|
||||
@SubscribeEvent
|
||||
public static void onPostInit(FMLClientSetupEvent event) {
|
||||
ModList.get().forEachModContainer((modid, modContainer) -> {
|
||||
if (MidnightConfig.configClass.containsKey(modid)) {
|
||||
modContainer.registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () ->
|
||||
new ConfigScreenHandler.ConfigScreenFactory((client, parent) -> MidnightConfig.getScreen(parent, modid)));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@Mod.EventBusSubscriber(modid = "midnightlib", value = Dist.CLIENT)
|
||||
public static class MidnightLibClientEvents {
|
||||
@SubscribeEvent
|
||||
public static void afterInitScreen(ScreenEvent.Init.Post event) {
|
||||
MidnightConfigOverviewScreen.addButtonToOptionsScreen(event.getScreen(), event.getScreen().getMinecraft());
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(modid = "midnightlib", value = Dist.DEDICATED_SERVER)
|
||||
public static class MidnightLibServerEvents {
|
||||
@SubscribeEvent
|
||||
public static void registerCommands(RegisterCommandsEvent event) {
|
||||
for (LiteralArgumentBuilder<ServerCommandSource> command : AutoCommand.commands){
|
||||
event.getDispatcher().register(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
neoforge/src/main/resources/META-INF/mods.toml
Normal file
29
neoforge/src/main/resources/META-INF/mods.toml
Normal file
@@ -0,0 +1,29 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "[1,)"
|
||||
#issueTrackerURL = ""
|
||||
license = "MIT License"
|
||||
|
||||
[[mods]]
|
||||
modId = "midnightlib"
|
||||
version = "${version}"
|
||||
displayName = "MidnightLib"
|
||||
logoFile = "midnightlib.png"
|
||||
authors = "TeamMidnightDust, Motschen"
|
||||
description = '''
|
||||
Common Library for Team MidnightDust's mods.
|
||||
'''
|
||||
#logoFile = ""
|
||||
|
||||
[[dependencies.midnightlib]]
|
||||
modId = "neoforge"
|
||||
mandatory = true
|
||||
versionRange = "[20.3,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.midnightlib]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "[1.20.3,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
BIN
neoforge/src/main/resources/midnightlib.png
Normal file
BIN
neoforge/src/main/resources/midnightlib.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
6
neoforge/src/main/resources/pack.mcmeta
Normal file
6
neoforge/src/main/resources/pack.mcmeta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "MidnightLib",
|
||||
"pack_format": 22
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user