Skip to content

Commit

Permalink
port to neo and 1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunekaer committed Jan 7, 2024
1 parent 2531487 commit 9061ac3
Show file tree
Hide file tree
Showing 31 changed files with 440 additions and 160 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ out
# gradle
build
.gradle
logs

# other
eclipse
run
.vscode

# Files from Forge MDK
forge*changelog.txt
logs/
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Changelog

Updated build script
Update to 1.20.4 and neo
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

211 changes: 93 additions & 118 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,133 +1,108 @@
plugins {
id "dev.architectury.loom" version "0.12.0-SNAPSHOT"
id 'maven-publish'
id "me.modmuss50.mod-publish-plugin" version "0.3.0"
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
id "me.modmuss50.mod-publish-plugin" version "0.4.5"
}

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17

def ENV = System.getenv()
version = "${mod_version}-build.${ENV.GITHUB_RUN_NUMBER ?: 9999}"
archivesBaseName = project.archives_base_name
group = project.maven_group

loom {
silentMojangMappingsLicense()

forge {
mixinConfigs = [
'structureexpansion.mixins.json'
]

dataGen {
mod project.mod_id
}

launches {
data {
arg "--existing", file("src/main/resources").absolutePath
}
}
}
architectury {
minecraft = rootProject.minecraft_version
}

repositories {
subprojects {
apply plugin: "dev.architectury.loom"
apply plugin: "maven-publish"

loom {
silentMojangMappingsLicense()
}

dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings loom.officialMojangMappings()
}

publishing {
repositories {
if (providers.environmentVariable("NANITE_TOKEN").isPresent()) {
maven {
url "https://maven.nanite.dev/releases"
credentials {
username = "nanite"
password = providers.environmentVariable("NANITE_TOKEN").get()
}
}
}
}
}
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings()
allprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"

forge "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}"
}
archivesBaseName = rootProject.archives_base_name
version = rootProject.mod_version
group = rootProject.maven_group

processResources {
inputs.property "version", project.version
repositories {
}

filesMatching("META-INF/mods.toml") {
expand "version": project.version
}
}

compileJava {
options.encoding = "UTF-8"
options.release = 17
}

java {
withSourcesJar()
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
}

manifest {
attributes([
"Specification-Title" : project.mod_id,
"Specification-Vendor" : project.mod_author,
"Specification-Version" : "1",
"Implementation-Title" : project.name,
"Implementation-Version" : version,
"Implementation-Vendor" : project.mod_author,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 17
}

publishing {
publications {
mavenForge(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}

repositories {
if (providers.environmentVariable("NANITE_TOKEN").orNull) {
maven {
url "${maven_url}/releases"
credentials {
username = "nanite"
password = providers.environmentVariable("NANITE_TOKEN").get()
}
}
}
}
java {
withSourcesJar()
}
}

publishMods {
dryRun = providers.environmentVariable("CURSE_TOKEN").getOrNull() == null
changelog = file("./CHANGELOG.md").text
version = "${mod_version}"
type = STABLE

def forgeOptions = publishOptions {
file = project.provider { project.tasks.remapJar }.flatMap { it.archiveFile }
displayName = "${project.name} Forge ${mod_version}+mc${minecraft_version}"
modLoaders.add("forge")
}

def curseForgeOptions = curseforgeOptions {
accessToken = providers.environmentVariable("CURSE_TOKEN")
projectId = "${curseforge_id}"
minecraftVersions.add("${minecraft_version}")
}

def modrinthOptions = modrinthOptions {
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
projectId = "${modrinth_id}"
minecraftVersions.add("${minecraft_version}")
}

curseforge("curseforgeForge") {
from(curseForgeOptions, forgeOptions)
}

if (providers.environmentVariable("MODRINTH_TOKEN").getOrNull() != null) {
modrinth("modrinthForge") {
from(modrinthOptions, forgeOptions)
}
}
dryRun = providers.environmentVariable("CURSE_TOKEN").getOrNull() == null
changelog = file("./CHANGELOG.md").text
version = "${mod_version}"
type = STABLE

def forgeOptions = publishOptions {
file = project.provider { project(":forge").tasks.remapJar }.flatMap { it.archiveFile }
displayName = "[FORGE][${minecraft_version}] ${project.name} ${mod_version}"
modLoaders.add("forge")
}

def neoForge = publishOptions {
file = project.provider { project(":neoforge").tasks.remapJar }.flatMap { it.archiveFile }
displayName = "[NEOFORGE][${minecraft_version}] ${project.name} ${mod_version}"
modLoaders.add("neoforge")
}

def curseForgeOptions = curseforgeOptions {
accessToken = providers.environmentVariable("CURSE_TOKEN")
projectId = "${curseforge_id}"
minecraftVersions.add("${minecraft_version}")
}

def modrinthOptions = modrinthOptions {
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
projectId = "${modrinth_id}"
minecraftVersions.add("${minecraft_version}")
}

curseforge("curseforgeForge") {
from(curseForgeOptions, forgeOptions)
}

curseforge("curseforgeNeoForge") {
from(curseForgeOptions, neoForge)
}

if (providers.environmentVariable("MODRINTH_TOKEN").getOrNull() != null) {
modrinth("modrinthForge") {
from(modrinthOptions, forgeOptions)
}

modrinth("modrinthNeoforge") {
from(modrinthOptions, neoForge)
}
}
}
26 changes: 26 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
architectury {
common(rootProject.enabled_platforms.split(","))
}

loom {
accessWidenerPath = file("src/main/resources/structureexpansion.accesswidener")
}

// sourceSets.main.resources.srcDirs += file("src/generated/resources")

dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
// Remove the next line if you don't want to depend on the API
modApi "dev.architectury:architectury:${rootProject.architectury_version}"
}

publishing {
publications {
mavenCommon(MavenPublication) {
artifactId = "${rootProject.archivesBaseName}-${project.name}"
from components.java
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.sunekaer.mods.structureexpansion;

import com.mojang.brigadier.CommandDispatcher;
import com.sunekaer.mods.structureexpansion.commands.CommandClean;
import dev.architectury.event.events.common.CommandRegistrationEvent;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;

public class StructureExpansion {
public static final int NEW_LIMIT = 200;
public static final int NEW_LIMIT_POS = NEW_LIMIT - 1;
public static final int NEW_LIMIT_NEG = -NEW_LIMIT_POS;


public static void init() {
CommandRegistrationEvent.EVENT.register(StructureExpansion::registerCommands);
}

public static void registerCommands(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext context, Commands.CommandSelection selection) {
dispatcher.register(Commands.literal("structure").then(CommandClean.register()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

@Mixin(StructureBlockRenderer.class)
public abstract class StructureBlockRendererMixin {
/**
* @author Sunekaer
* @reason Extend the view distance of Structure Block.
*/
@Overwrite
public int getViewDistance() {
return StructureExpansion.NEW_LIMIT;
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/architectury.common.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"accessWidener": "structureexpansion.accesswidener"
}
2 changes: 2 additions & 0 deletions common/src/main/resources/structureexpansion.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
accessWidener v2 named
accessible field net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate palettes Ljava/util/List;
Loading

0 comments on commit 9061ac3

Please sign in to comment.