Skip to content

Commit

Permalink
initial port to 1.21 (#29)
Browse files Browse the repository at this point in the history
Co-authored-by: Ridanis <[email protected]>
Co-authored-by: rlnt <[email protected]>
  • Loading branch information
3 people authored Aug 5, 2024
1 parent d3d2718 commit b941dfc
Show file tree
Hide file tree
Showing 63 changed files with 514 additions and 398 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
branches:
- "1.20.4"
- "1.21"
tags-ignore:
- "**"
paths:
Expand All @@ -15,7 +15,7 @@ on:
- "**/build.yml"
pull_request:
branches:
- "1.20.4"
- "1.21"
paths:
- "gradle/**"
- "**.java"
Expand All @@ -29,4 +29,7 @@ concurrency:

jobs:
redirect:
uses: AlmostReliable/.github/.github/workflows/build-java17.yml@main
uses: AlmostReliable/.github/.github/workflows/build.yml@main
with:
java-distribution: "microsoft"
java-version: "21"
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ on:

jobs:
redirect:
uses: AlmostReliable/.github/.github/workflows/release-java17-nf.yml@main
uses: AlmostReliable/.github/.github/workflows/release-nf.yml@main
secrets: inherit
with:
java-distribution: "microsoft"
java-version: "21"
mod_name: "MERequester"
curseforge_id: "688367"
modrinth_id: "E6BFl96N"
Expand Down
5 changes: 2 additions & 3 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

109 changes: 51 additions & 58 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@file:Suppress("UnstableApiUsage")

val license: String by project
val logLevel: String by project
val loggingLevel: String by project
val mixinDebugExport: String by project
val recipeViewer: String by project
val mcVersion: String by project
Expand All @@ -21,7 +21,7 @@ val githubUser: String by project
val githubRepo: String by project

plugins {
id("net.neoforged.gradle.userdev") version "7.0.97"
id("net.neoforged.moddev") version "2.0.+"
id("com.github.gmazzo.buildconfig") version "4.0.4"
java
}
Expand All @@ -32,35 +32,48 @@ base {
archivesName.set("$modId-neoforge")
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

val commonSystemProperties = mapOf(
"forge.logging.console.level" to logLevel,
"mixin.debug.export" to mixinDebugExport,
"guideDev.ae2guide.sources" to file("guidebook").absolutePath,
"guideDev.ae2guide.sourcesNamespace" to modId
)

runs {
configureEach {
workingDirectory = project.file("run")
systemProperties = commonSystemProperties
modSource(sourceSets.main.get())
jvmArguments("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

neoForge {
version = neoVersion

mods {
create("merequester") {
modSourceSets.add(sourceSets.main)
}
}

create("client") {
programArguments("--quickPlaySingleplayer", "New World")
runs {
configureEach {
gameDirectory = project.file("run")
systemProperties = mapOf(
"forge.logging.console.level" to loggingLevel,
"mixin.debug.export" to mixinDebugExport,
"guideDev.ae2guide.sources" to file("guidebook").absolutePath,
"guideDev.ae2guide.sourcesNamespace" to modId
)
jvmArguments.addAll("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
}
create("client") {
client()
programArguments.addAll("--quickPlaySingleplayer", "New World")
}
create("guide") {
client()
systemProperty("guideDev.ae2guide.startupPage", "$modId:$modId.md")
}
create("server") {
server()
}
}
create("guide") {
configure("client")
systemProperty("guideDev.ae2guide.startupPage", "$modId:$modId.md")

parchment {
minecraftVersion = mcVersion
mappingsVersion = parchmentVersion
}
create("server")
}

repositories {
maven("https://maven.neoforged.net/releases") // NeoForge
maven("https://modmaven.dev") // Applied Energistics 2
maven("https://maven.blamejared.com") // JEI
maven("https://maven.shedaniel.me") // REI
Expand All @@ -69,42 +82,32 @@ repositories {
}

dependencies {
// NeoForge
implementation("net.neoforged:neoforge:$neoVersion")
implementation("appeng:appliedenergistics2:$aeVersion")

// Compile
compileOnly("appeng:appliedenergistics2-neoforge:$aeVersion")

// Runtime
runtimeOnly("appeng:appliedenergistics2-neoforge:$aeVersion")
when (recipeViewer) {
"jei" -> runtimeOnly("mezz.jei:jei-$mcVersion-neoforge:$jeiVersion") { isTransitive = false }
"rei" -> {
runtimeOnly("me.shedaniel:RoughlyEnoughItems-neoforge:$reiVersion")
runtimeOnly("dev.architectury:architectury-neoforge:11.1.17") // TODO: Remove on new REI version
}

"rei" -> runtimeOnly("me.shedaniel:RoughlyEnoughItems-neoforge:$reiVersion")
"emi" -> runtimeOnly("dev.emi:emi-neoforge:$emiVersion+$mcVersion")
else -> throw GradleException("Invalid recipeViewer value: $recipeViewer")
}
}

tasks {
processResources {
val resourceTargets = listOf("META-INF/mods.toml", "pack.mcmeta")
val resourceTargets = listOf("META-INF/neoforge.mods.toml", "pack.mcmeta")

val replaceProperties = mapOf(
"license" to license,
"mcVersion" to mcVersion,
"version" to project.version as String,
"modId" to modId,
"modName" to modName,
"modAuthor" to modAuthor,
"modDescription" to modDescription,
"neoVersion" to neoVersion,
"aeVersion" to aeVersion,
"githubUser" to githubUser,
"githubRepo" to githubRepo
"license" to license,
"mcVersion" to mcVersion,
"version" to project.version as String,
"modId" to modId,
"modName" to modName,
"modAuthor" to modAuthor,
"modDescription" to modDescription,
"neoVersion" to neoVersion,
"aeVersion" to aeVersion,
"githubUser" to githubUser,
"githubRepo" to githubRepo
)

println("[Process Resources] Replacing properties in resources: ")
Expand All @@ -118,23 +121,13 @@ tasks {

withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
}

withType<Jar> {
from("guidebook") {
into("assets/$modId/ae2guide")
}
}

withType<GenerateModuleMetadata> {
enabled = false
}
}

subsystems.parchment {
minecraftVersion(mcVersion)
mappingsVersion(parchmentVersion)
}

buildConfig {
Expand Down
20 changes: 8 additions & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ license = GNU Lesser General Public License v3.0
loom.platform = neoforge

# Settings
logLevel = debug
loggingLevel = debug
mixinDebugExport = false
recipeViewer = emi

# Minecraft
mcVersion = 1.20.4
mcVersion = 1.21

# Mod
modVersion = 1.1.6
Expand All @@ -19,19 +19,15 @@ modAuthor = Almost Reliable
modDescription = Keep items and fluids in your ME-System in stock.

# Project Dependencies
neoVersion = 20.4.196
parchmentVersion = 2024.02.25
neoVersion = 21.0.143
parchmentVersion = 2024.07.28

# Mod Dependencies
aeVersion = 17.12.1-beta
jeiVersion = 17.3.0.49
reiVersion = 14.0.688
emiVersion = 1.1.2
aeVersion = 19.0.18-beta
jeiVersion = 19.5.2.66
reiVersion = 16.0.744
emiVersion = 1.1.10

# Github
githubUser = AlmostReliable
githubRepo = merequester

# Gradle
org.gradle.jvmargs = -Xmx3G
org.gradle.daemon = false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase = GRADLE_USER_HOME
distributionPath = wrapper/dists
distributionUrl = https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl = https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase = GRADLE_USER_HOME
zipStorePath = wrapper/dists
Binary file modified guidebook/assets/gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 4 additions & 5 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
pluginManagement {
repositories {
maven("https://maven.neoforged.net/releases")
gradlePluginPortal()
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}

val modName = extra.get("modName").toString().replace(" ", "-")
val mcVersion: String by extra
rootProject.name = "$modName-$mcVersion-NeoForge"

enableFeaturePreview("STABLE_CONFIGURATION_CACHE")
36 changes: 8 additions & 28 deletions src/main/java/com/almostreliable/merequester/MERequester.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package com.almostreliable.merequester;

import appeng.api.util.AEColor;
import appeng.client.render.StaticItemColor;
import appeng.init.client.InitScreens;
import com.almostreliable.merequester.client.RequesterScreen;
import com.almostreliable.merequester.client.RequesterTerminalScreen;
import com.almostreliable.merequester.data.MERequesterData;
import com.almostreliable.merequester.network.PacketHandler;
import com.almostreliable.merequester.requester.RequesterMenu;
import com.almostreliable.merequester.terminal.RequesterTerminalMenu;
import com.mojang.logging.LogUtils;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.config.ModConfig;
Expand All @@ -25,33 +22,16 @@ public final class MERequester {
public static final String REQUESTER_ID = "requester";
public static final String TERMINAL_ID = "requester_terminal";

public MERequester(IEventBus modEventBus) {
public MERequester(IEventBus modEventBus, ModContainer modContainer) {
Registration.BLOCKS.register(modEventBus);
Registration.ITEMS.register(modEventBus);
Registration.BLOCK_ENTITY_TYPES.register(modEventBus);
modEventBus.addListener(Registration::registerContents);
modEventBus.addListener(Registration::registerCapabilities);
modEventBus.addListener(Registration.Tab::initContents);
modEventBus.addListener(PacketHandler::onPacketRegistration);
if (FMLEnvironment.dist.isClient()) {
modEventBus.addListener(MERequesterClient::registerScreens);
modEventBus.addListener(MERequesterClient::registerColors);
}
MERequesterData.DR.register(modEventBus);

ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.COMMON_SPEC);
}

private static class MERequesterClient {

@SuppressWarnings("RedundantTypeArguments")
private static void registerScreens(RegisterMenuScreensEvent event) {
InitScreens.register(RequesterMenu.TYPE, RequesterScreen::new, String.format("/screens/%s.json", REQUESTER_ID));
InitScreens.<RequesterTerminalMenu, RequesterTerminalScreen<RequesterTerminalMenu>> register(
RequesterTerminalMenu.TYPE,
RequesterTerminalScreen::new,
String.format("/screens/%s.json", TERMINAL_ID)
);
}

private static void registerColors(RegisterColorHandlersEvent.Item event) {
event.register(new StaticItemColor(AEColor.TRANSPARENT), Registration.REQUESTER_TERMINAL);
}
modContainer.registerConfig(ModConfig.Type.COMMON, Config.COMMON_SPEC);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.almostreliable.merequester;

import appeng.api.util.AEColor;
import appeng.client.render.StaticItemColor;
import appeng.init.client.InitScreens;
import com.almostreliable.merequester.client.RequesterScreen;
import com.almostreliable.merequester.client.RequesterTerminalScreen;
import com.almostreliable.merequester.requester.RequesterMenu;
import com.almostreliable.merequester.terminal.RequesterTerminalMenu;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent;
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;

@Mod(value = BuildConfig.MOD_ID, dist = Dist.CLIENT)
public final class MERequesterClient {

public MERequesterClient(IEventBus modEventBus) {
modEventBus.addListener(this::registerScreens);
modEventBus.addListener(this::registerColors);
}

@SuppressWarnings("RedundantTypeArguments")
private void registerScreens(RegisterMenuScreensEvent event) {
InitScreens.register(event, RequesterMenu.TYPE, RequesterScreen::new, String.format("/screens/%s.json", MERequester.REQUESTER_ID));
InitScreens.<RequesterTerminalMenu, RequesterTerminalScreen<RequesterTerminalMenu>> register(
event,
RequesterTerminalMenu.TYPE,
RequesterTerminalScreen::new,
String.format("/screens/%s.json", MERequester.TERMINAL_ID)
);
}

private void registerColors(RegisterColorHandlersEvent.Item event) {
event.register(new StaticItemColor(AEColor.TRANSPARENT), Registration.REQUESTER_TERMINAL);
}
}
Loading

0 comments on commit b941dfc

Please sign in to comment.