Skip to content

Commit

Permalink
Port to Minecraft 1.20.2 and added support for NeoForge.
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkhax committed Nov 16, 2023
1 parent 625c893 commit dfd90f6
Show file tree
Hide file tree
Showing 13 changed files with 274 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ build
# other
eclipse
run
runs
*.DS_Store
14 changes: 8 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ buildscript {
}

plugins {
id 'fabric-loom' version '1.2-SNAPSHOT' apply(false)
id 'net.minecraftforge.gradle' version '[6.0,6.2)' apply(false)
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' apply(false)
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT' apply(false)
id 'net.darkhax.curseforgegradle' version '1.1.16' apply(false)
id 'com.modrinth.minotaur' version '2.8.0' apply(false)
id 'net.darkhax.curseforgegradle' version '1.1.17' apply(false)
id 'com.modrinth.minotaur' version '2.8.5' apply(false)
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
}

apply from: 'gradle/property_loader.gradle'
Expand Down Expand Up @@ -106,6 +103,11 @@ task postDiscord() {
downloadSources.add("<:fabric:916233929722314763> [Fabric](${project(':fabric').findProperty('curse_file_url')})")
}

if (project(':neoforge').hasProperty('curse_file_url')) {

downloadSources.add("<:neoforge:1173939148806176779> [NeoForge](${project(':neoforge').findProperty('curse_file_url')})")
}

// Add Curseforge DL link if available.
def downloadString = downloadSources.toString()

Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'org.spongepowered.gradle.vanilla'
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
}
apply from: '../gradle/property_helper.gradle'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.darkhax.bookshelf.api.Services;
import net.darkhax.bookshelf.api.registry.IRegistryObject;
import net.darkhax.bookshelf.api.registry.RegistryDataProvider;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.npc.VillagerProfession;
Expand Down Expand Up @@ -63,7 +64,7 @@ private Content() {

private void createPattern(String name, Rarity rarity, String... variants) {

final TagKey<BannerPattern> bannerTag = Services.TAGS.bannerPatternTag(new ResourceLocation(Constants.MOD_ID, "pattern_item/" + name));
final TagKey<BannerPattern> bannerTag = TagKey.create(Registries.BANNER_PATTERN, new ResourceLocation(Constants.MOD_ID, "pattern_item/" + name));
final IRegistryObject<BannerPatternItem> stencilItem = this.items.add(() -> new BannerPatternItem(bannerTag, new Item.Properties().stacksTo(1).rarity(rarity)), name);
addTradeEntries(name, stencilItem, rarity);

Expand All @@ -76,7 +77,7 @@ private void createPattern(String name, Rarity rarity, String... variants) {

private void createPattern(String name, Rarity rarity) {

final TagKey<BannerPattern> bannerTag = Services.TAGS.bannerPatternTag(new ResourceLocation(Constants.MOD_ID, "pattern_item/" + name));
final TagKey<BannerPattern> bannerTag = TagKey.create(Registries.BANNER_PATTERN, new ResourceLocation(Constants.MOD_ID, "pattern_item/" + name));
final IRegistryObject<BannerPatternItem> stencilItem = this.items.add(() -> new BannerPatternItem(bannerTag, new Item.Properties().stacksTo(1).rarity(rarity)), name);
this.bannerPatterns.add(() -> new BannerPattern(name), name);
addTradeEntries(name, stencilItem, rarity);
Expand Down
2 changes: 1 addition & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom'
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'net.darkhax.curseforgegradle'
id 'com.modrinth.minotaur'
id 'idea'
Expand Down
6 changes: 3 additions & 3 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
]
},
"depends": {
"fabricloader": ">=0.14.21",
"fabricloader": ">=0.14.24",
"fabric": "*",
"minecraft": "1.20.1",
"minecraft": "${minecraft_version}",
"java": ">=17",
"bookshelf": ">=20"
"bookshelf": ">=21"
},
"custom": {
"modmenu": {
Expand Down
5 changes: 2 additions & 3 deletions forge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id 'net.minecraftforge.gradle'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT'
id 'net.darkhax.curseforgegradle'
id 'com.modrinth.minotaur'
id 'org.spongepowered.mixin'
}

apply from: '../gradle/patreon.gradle'
Expand Down Expand Up @@ -190,7 +190,6 @@ task publishCurseForge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge)
apiToken = findProperty('curse_auth')

def mainFile = upload(curse_project, jar)
mainFile.addModLoader('NeoForge')
mainFile.releaseType = 'release'
mainFile.addGameVersion('Client', 'Server')
mainFile.changelogType = 'markdown'
Expand Down
14 changes: 11 additions & 3 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modLoader = "javafml"
loaderVersion = "[47,)"
loaderVersion = "[48,)"
license = "${mod_license}"
issueTrackerURL = "${mod_issues}"
logoFile = "logo.png"
Expand All @@ -10,6 +10,7 @@ modId = "${mod_id}"
version = "${file.jarVersion}"
displayName = "${mod_name}"
displayURL = "${mod_homepage}"
updateJSONURL = "https://updates.blamejared.com/get?n=${mod_id}&gv=${minecraft_version}"
credits = "This project is made possible with Patreon support from players like you. Thank you! ${mod_supporters}"
authors = "${mod_author}"
description = '''
Expand All @@ -19,13 +20,20 @@ ${mod_description}
[[dependencies.${ mod_id }]]
modId = "forge"
mandatory = true
versionRange = "[47,)"
versionRange = "[48,)"
ordering = "NONE"
side = "BOTH"

[[dependencies.${ mod_id }]]
modId = "minecraft"
mandatory = true
versionRange = "${minecraft_version}"
ordering = "NONE"
side = "BOTH"

[[dependencies.${ mod_id }]]
modId = "bookshelf"
mandatory = true
versionRange = "[20,)"
versionRange = "[21,)"
ordering = "NONE"
side = "BOTH"
16 changes: 10 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
# Project
version=14.0
version=15.0
group=net.darkhax.additionalbanners

# Common
minecraft_version=1.20.1
bookshelf_version=20.0.1
minecraft_version=1.20.2
bookshelf_version=21.0.10

# Forge
forge_version=47.1.44
forge_version=48.0.37

# NeoForge
neoforge_version=20.2.47-beta
neoforge_version_range=20.2,

# Fabric
fabric_version=0.87.0+1.20.1
fabric_loader_version=0.14.22
fabric_version=0.90.7+1.20.2
fabric_loader_version=0.14.24

# Mod options
mod_name=AdditionalBanners
Expand Down
177 changes: 177 additions & 0 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
plugins {
id 'net.neoforged.gradle.userdev' version '7.0.43'
id 'net.darkhax.curseforgegradle'
id 'com.modrinth.minotaur'
}

apply from: '../gradle/patreon.gradle'

base {
archivesName = "${mod_name}-NeoForge-${minecraft_version}"
}

runs {
configureEach {
modSource project.sourceSets.main
}
client {
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
server {
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
programArgument '--nogui'
}

gameTestServer {
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
}

dependencies {
implementation "net.neoforged:neoforge:${neoforge_version}"
implementation "net.darkhax.bookshelf:Bookshelf-NeoForge-${project.ext.minecraft_version}:${project.ext.bookshelf_version}"
compileOnly project(':common')
}

// NeoGradle compiles the game, but we don't want to add our common code to the game's code
TaskCollection.metaClass.excludingNeoTasks = { ->
delegate.matching { !it.name.startsWith("neo") }
}

tasks.withType(JavaCompile).excludingNeoTasks().configureEach {
source(project(':common').sourceSets.main.allSource)
}

tasks.withType(Javadoc).excludingNeoTasks().configureEach {
source(project(':common').sourceSets.main.allJava)
}

tasks.named("sourcesJar", Jar) {
from(project(':common').sourceSets.main.allSource)
}

tasks.withType(ProcessResources).excludingNeoTasks().configureEach {
from project(':common').sourceSets.main.resources
}

processResources {

from project(":common").sourceSets.main.resources

def buildProps = project.properties.clone()

// Replaces FML's magic file.jarVersion string with the correct version at
// build time.
buildProps.put('file', [jarVersion: project.version])

if (project.hasProperty('patreon')) {

def supporters = new ArrayList<String>()

for (entry in project.ext.patreon.pledges) {

def pledge = entry.value;

if (pledge.isValid()) {

supporters.add(pledge.getDisplayName())
}
}

buildProps.put('mod_supporters', supporters.join(', '))
}

filesMatching('*.mixins.json') {
filter(org.apache.tools.ant.filters.LineContains, negate: true, contains: ['refmap' ] )
}

filesMatching(['META-INF/mods.toml', 'pack.mcmeta', '*.mixins.json']) {

expand buildProps
}
}

// -- MAVEN PUBLISHING --
project.publishing {

publications {

mavenJava(MavenPublication) {

artifactId = base.archivesName.get()
from components.java
}
}

repositories {

maven {

// Sets maven credentials if they are provided. This is generally
// only used for external/remote uploads.
if (project.hasProperty('mavenUsername') && project.hasProperty('mavenPassword')) {

credentials {

username findProperty('mavenUsername')
password findProperty('mavenPassword')
}
}

url getDefaultString('mavenURL', 'undefined', true)
}
}
}

// CurseForge Publishing
task publishCurseForge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) {

apiToken = findProperty('curse_auth')

def mainFile = upload(curse_project, jar)
mainFile.changelogType = 'markdown'
mainFile.changelog = project.ext.mod_changelog
mainFile.addJavaVersion('Java 17')
mainFile.releaseType = 'release'
mainFile.addGameVersion('Server', 'Client')
mainFile.addRequirement('bookshelf')

// Append Patreon Supporters
def patreonInfo = project.findProperty('patreon')

if (patreonInfo) {
mainFile.changelog += "\n\nThis project is made possible by [Patreon](${patreonInfo.campaignUrlTracked}) support from players like you. Thank you!\n\n${patreonInfo.pledgeLog}"
}

doLast {

if (project.hasProperty('mod_homepage')) {

project.ext.curse_file_url = "${mod_homepage}/files/${mainFile.curseFileId}"
}
}
}

// Modrinth
modrinth {

def patreonInfo = project.findProperty('patreon')
def changelog = project.ext.mod_changelog

if (patreonInfo) {
changelog += "\n\nThis project is made possible by [Patreon](${patreonInfo.campaignUrlTracked}) support from players like you. Thank you!\n\n${patreonInfo.pledgeLog}"
}

token.set(project.findProperty('modrinth_auth'))
projectId.set(modrinth_project)
changelog = changelog
versionName.set("${mod_name}-NeoForge-${minecraft_version}-$version")
versionType.set('release')
uploadFile.set(tasks.jar)
loaders = ["neoforge"]
gameVersions = ["${minecraft_version}"]

dependencies {
required.project('bookshelf-lib')
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.darkhax.additionalbanners;

import net.neoforged.fml.common.Mod;

@Mod(Constants.MOD_ID)
public class AdditionalBannersNeoForge {

public AdditionalBannersNeoForge() {

Content.init();
}
}

0 comments on commit dfd90f6

Please sign in to comment.