mirror of
https://github.com/trafficlunar/options-profiles.git
synced 2026-06-28 06:34:11 +00:00
port to 26.1 part 1
This commit is contained in:
parent
b64f9b6741
commit
3a17ce9f60
33 changed files with 581 additions and 344 deletions
|
|
@ -1,59 +1,61 @@
|
|||
plugins {
|
||||
id 'com.gradleup.shadow'
|
||||
id 'multiloader-loader'
|
||||
id 'net.neoforged.moddev'
|
||||
}
|
||||
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
neoForge()
|
||||
}
|
||||
|
||||
configurations {
|
||||
common {
|
||||
canBeResolved = true
|
||||
canBeConsumed = false
|
||||
neoForge {
|
||||
version = neoforge_version
|
||||
// Automatically enable neoforge AccessTransformers if the file exists
|
||||
def at = project(':common').file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
if (at.exists()) {
|
||||
accessTransformers.from(at.absolutePath)
|
||||
}
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentNeoForge.extendsFrom common
|
||||
|
||||
// Files in this configuration will be bundled into your mod using the Shadow plugin.
|
||||
// Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files.
|
||||
shadowBundle {
|
||||
canBeResolved = true
|
||||
canBeConsumed = false
|
||||
runs {
|
||||
configureEach {
|
||||
systemProperty('neoforge.enabledGameTestNamespaces', mod_id)
|
||||
ideName = "NeoForge ${it.name.capitalize()} (${project.path})" // Unify the run config names with fabric
|
||||
}
|
||||
client {
|
||||
client()
|
||||
gameDirectory = this.mkdir(this.file("runs/client"))
|
||||
}
|
||||
data {
|
||||
clientData()
|
||||
gameDirectory = this.mkdir(this.file("runs/data"))
|
||||
// DataGen can be run by - "./gradlew :neoforge:runData" in Terminal.
|
||||
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
|
||||
}
|
||||
server {
|
||||
server()
|
||||
this.file("runs/server").createParentDirectories()
|
||||
gameDirectory = this.mkdir(this.file("runs/server"))
|
||||
}
|
||||
}
|
||||
mods {
|
||||
"${mod_id}" {
|
||||
sourceSet sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = 'NeoForged'
|
||||
url = 'https://maven.neoforged.net/releases'
|
||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
|
||||
// Implement mcgradleconventions loader attribute
|
||||
def loaderAttribute = Attribute.of('io.github.mcgradleconventions.loader', String)
|
||||
['apiElements', 'runtimeElements', 'sourcesElements', 'javadocElements'].each { variant ->
|
||||
configurations.named("$variant") {
|
||||
attributes {
|
||||
attribute(loaderAttribute, 'neoforge')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
neoForge "net.neoforged:neoforge:$rootProject.neoforge_version"
|
||||
|
||||
// Architectury API
|
||||
modImplementation "dev.architectury:architectury-neoforge:$rootProject.architectury_api_version"
|
||||
|
||||
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
|
||||
shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge')
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property 'version', project.version
|
||||
|
||||
filesMatching('META-INF/neoforge.mods.toml') {
|
||||
expand version: project.version
|
||||
sourceSets.configureEach {
|
||||
[it.compileClasspathConfigurationName, it.runtimeClasspathConfigurationName, it.getTaskName(null, 'jarJar')].each { variant ->
|
||||
configurations.named("$variant") {
|
||||
attributes {
|
||||
attribute(loaderAttribute, 'neoforge')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadowBundle]
|
||||
archiveClassifier = 'dev-shadow'
|
||||
}
|
||||
|
||||
remapJar {
|
||||
input.set shadowJar.archiveFile
|
||||
}
|
||||
|
|
@ -1,11 +1,55 @@
|
|||
package net.trafficlunar.optionsprofiles.neoforge;
|
||||
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
import net.neoforged.neoforge.client.event.ClientPlayerNetworkEvent;
|
||||
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
||||
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
|
||||
import net.neoforged.neoforge.client.event.lifecycle.ClientStartedEvent;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.trafficlunar.optionsprofiles.Commands;
|
||||
import net.trafficlunar.optionsprofiles.Keybinds;
|
||||
import net.trafficlunar.optionsprofiles.OptionsProfilesMod;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
|
||||
@Mod(OptionsProfilesMod.MOD_ID)
|
||||
@Mod(value = OptionsProfilesMod.MOD_ID, dist = Dist.CLIENT)
|
||||
public class OptionsProfilesModNeoForge {
|
||||
public OptionsProfilesModNeoForge() {
|
||||
public OptionsProfilesModNeoForge(IEventBus bus) {
|
||||
OptionsProfilesMod.init();
|
||||
|
||||
if (FMLEnvironment.getDist() == Dist.CLIENT) {
|
||||
NeoForge.EVENT_BUS.addListener(OptionsProfilesModNeoForge::onClientStarted);
|
||||
NeoForge.EVENT_BUS.addListener(OptionsProfilesModNeoForge::onClientPlayerJoin);
|
||||
NeoForge.EVENT_BUS.addListener(OptionsProfilesModNeoForge::onClientPlayerQuit);
|
||||
NeoForge.EVENT_BUS.addListener(OptionsProfilesModNeoForge::registerKeybinds);
|
||||
NeoForge.EVENT_BUS.addListener(OptionsProfilesModNeoForge::registerKeybindTick);
|
||||
NeoForge.EVENT_BUS.addListener(OptionsProfilesModNeoForge::registerCommands);
|
||||
}
|
||||
}
|
||||
|
||||
private static void onClientStarted(ClientStartedEvent event) {
|
||||
OptionsProfilesMod.handleClientLoad();
|
||||
}
|
||||
|
||||
private static void onClientPlayerJoin(ClientPlayerNetworkEvent.LoggingIn event) {
|
||||
OptionsProfilesMod.handleClientPlayerEvent(event.getPlayer(), false);
|
||||
}
|
||||
|
||||
private static void onClientPlayerQuit(ClientPlayerNetworkEvent.LoggingOut event) {
|
||||
OptionsProfilesMod.handleClientPlayerEvent(event.getPlayer(), true);
|
||||
}
|
||||
|
||||
private static void registerKeybinds(RegisterKeyMappingsEvent event) {
|
||||
Keybinds.registerKeybinds(event::register);
|
||||
}
|
||||
|
||||
private static void registerKeybindTick(ClientTickEvent.Post event) {
|
||||
Keybinds.tick();
|
||||
}
|
||||
|
||||
private static void registerCommands(RegisterCommandsEvent event) {
|
||||
Commands.registerCommands(event.getDispatcher()::register);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package net.trafficlunar.optionsprofiles.neoforge.platform;
|
||||
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.trafficlunar.optionsprofiles.platform.services.IPlatformHelper;
|
||||
|
||||
public class NeoForgePlatformHelper implements IPlatformHelper {
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
return "NeoForge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modId) {
|
||||
return ModList.get().isLoaded(modId);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +1,29 @@
|
|||
modLoader = "javafml"
|
||||
loaderVersion = "[10,)"
|
||||
loaderVersion = "${neoforge_loader_version_range}"
|
||||
issueTrackerURL = "https://github.com/trafficlunar/options-profiles/issues"
|
||||
license = "GNU GPL 3.0"
|
||||
|
||||
[[mods]]
|
||||
modId = "optionsprofiles"
|
||||
version = "${version}"
|
||||
displayName = "Options Profiles"
|
||||
authors = "trafficlunar"
|
||||
description = '''
|
||||
Load and save your options from in-game.
|
||||
'''
|
||||
logoFile = "icon.png"
|
||||
modId = "${mod_id}"
|
||||
version = "${mod_version}"
|
||||
displayName = "${mod_name}"
|
||||
authors = "${mod_author}"
|
||||
description = '''${mod_description}'''
|
||||
logoFile = "${mod_id}.png"
|
||||
|
||||
[[dependencies.optionsprofiles]]
|
||||
[[dependencies.${mod_id}]]
|
||||
modId = "neoforge"
|
||||
type = "required"
|
||||
versionRange = "[21.9.0-beta,)"
|
||||
versionRange = "[${neoforge_version},)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.optionsprofiles]]
|
||||
[[dependencies.${mod_id}]]
|
||||
modId = "minecraft"
|
||||
type = "required"
|
||||
versionRange = "[1.21,)"
|
||||
versionRange = "${minecraft_version_range}"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.optionsprofiles]]
|
||||
modId = "architectury"
|
||||
type = "required"
|
||||
versionRange = "[18.0.3,)"
|
||||
ordering = "AFTER"
|
||||
side = "BOTH"
|
||||
|
||||
[[mixins]]
|
||||
config = "optionsprofiles.mixins.json"
|
||||
config = "${mod_id}.mixins.json"
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
net.trafficlunar.optionsprofiles.neoforge.platform.NeoForgePlatformHelper
|
||||
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
Loading…
Add table
Add a link
Reference in a new issue