Skip to content

Commit

Permalink
Update to NeoForge 1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Mar 17, 2024
1 parent 4e82e80 commit 3af3043
Show file tree
Hide file tree
Showing 13 changed files with 141 additions and 135 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
doc/info.txt
/build
/run
/runs

# Ignore project specific files
.classpath
Expand All @@ -17,6 +18,7 @@ repo/*
*.iws
out/*
keystore.jks
.idea

# Ignore mac-specific file(s)
.DS_Store
Expand Down
129 changes: 58 additions & 71 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
plugins {
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'net.neoforged.gradle.userdev' version '7.0.97'
id 'net.darkhax.curseforgegradle' version '1.0.8'
id 'com.diffplug.spotless' version '5.14.3'
id 'com.modrinth.minotaur' version '2.+'
}

apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'idea'
apply plugin: 'maven-publish'

import net.minecraftforge.gradle.common.tasks.SignJar
import net.neoforged.gradle.common.tasks.PotentiallySignJar

// Determine build number
String build_number = "DEV" // this will be referenced as simply build_number from now on.
Expand All @@ -26,7 +25,10 @@ logger.lifecycle "BUILDING VERSION: " + build_number
// Set mod details
version = project.mod_version
group = "org.cyclops.flopper"
archivesBaseName = "Flopper"
archivesBaseName = "Flopper-${project.minecraft_version}-neoforge"
base {
archivesName = archivesBaseName
}

// Set Java details
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
Expand All @@ -47,6 +49,7 @@ sourceSets {
main
test
}
sourceSets.main.resources { srcDir 'src/generated/resources' }

repositories {
mavenCentral()
Expand All @@ -62,13 +65,13 @@ repositories {
}

dependencies {
minecraft "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}"
implementation "net.neoforged:neoforge:${project.neoforge_version}"

// Add something like 'cyclopscore_version_local=0.1.0-DEV' to your secrets.properties if you want to use a custom local CyclopsCore version.
if (secrets.cyclopscore_version_local) {
implementation "org.cyclops.cyclopscore:cyclopscore:${project.minecraft_version}-${secrets.cyclopscore_version_local}:deobf"
implementation "org.cyclops.cyclopscore:cyclopscore-${project.minecraft_version}-neoforge:${secrets.cyclopscore_version_local}:deobf"
} else {
implementation "org.cyclops.cyclopscore:cyclopscore:${project.minecraft_version}-${project.cyclopscore_version}:deobf"
implementation "org.cyclops.cyclopscore:cyclopscore-${project.minecraft_version}-neoforge:${project.cyclopscore_version}:deobf"
}

// Project lombok
Expand All @@ -78,50 +81,36 @@ dependencies {
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
}

minecraft {
mappings channel: "official", version: "${project.minecraft_version}"

accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs {
configureEach {
systemProperty 'forge.logging.markers', 'REGISTRIES'
systemProperty 'forge.logging.console.level', 'debug'
systemProperty 'forge.logging.console.level', 'debug'
modSource project.sourceSets.main
}

client {
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
}

runs {
client {
workingDirectory project.file('run')
//property 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
mods {
flopper {
source sourceSets.main
}
}
}
server {
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
programArgument '--nogui'
}

server {
workingDirectory project.file('run')
property 'forge.logging.console.level', 'debug'
mods {
flopper {
source sourceSets.main
}
}
}
gameTestServer {
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
}

data {
workingDirectory project.file('run')
property 'forge.logging.console.level', 'debug'
args '--mod', 'flopper', '--all', '--output', file('src/generated/resources/')
mods {
flopper {
source sourceSets.main
}
}
}
data {
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}

if (build_number.equals("RELEASE"))
version = "${project.minecraft_version}-${project.mod_version}"
version = "${project.mod_version}"
else
version = "${project.minecraft_version}-${project.mod_version}-${build_number}"
version = "${project.mod_version}-${build_number}"

jar {
manifest {
Expand All @@ -136,15 +125,16 @@ jar {
])
}
}
jar.finalizedBy('reobfJar')

javadoc {
source = [sourceSets.main.allJava]
// prevent java 8's strict doclint for javadocs from failing builds
options.addStringOption('Xdoclint:accessibility,html,reference,syntax', '-quiet')
}

task signJar(type: SignJar, dependsOn: jar) {
task signJar(type: PotentiallySignJar, dependsOn: jar) {
dependsOn(tasks.jar)

onlyIf {
System.getenv().SIGN_KEYSTORE
}
Expand All @@ -153,10 +143,9 @@ task signJar(type: SignJar, dependsOn: jar) {
alias = System.getenv().SIGN_ALIAS
storePass = System.getenv().SIGN_STOREPASS
keyPass = System.getenv().SIGN_KEYPASS
inputFile = jar.archivePath
outputFile = jar.archivePath
input = jar.archivePath
output = jar.archivePath
}
build.dependsOn signJar

task deobfJar(type: Jar) {
from sourceSets.main.output
Expand Down Expand Up @@ -192,32 +181,26 @@ artifacts {
archives javadocJar
}

curseforge {
if(secrets.hasProperty("curseforge_key")) {
apiKey = secrets.curseforge_key
} else if((System.getenv().TRAVIS || System.getenv().GITHUB_ACTIONS) && System.getenv().CURSEFORGE_KEY_SECRET) {
apiKey = System.getenv().CURSEFORGE_KEY_SECRET
}
task publishCurseForge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) {
dependsOn(tasks.jar)

project {
id = "290404" // my project url is http://minecraft.curseforge.com/mc-mods/290404/
releaseType = project.project.release_type
addGameVersion project.minecraft_version
mainArtifact(jar) {
relations {
requiredDependency 'cyclops-core'
}
}
if(secrets.hasProperty("curseforge_key") && secrets.hasProperty("changelog")) {
apiToken = secrets.curseforge_key
} else if(System.getenv().GITHUB_ACTIONS && System.getenv().CURSEFORGE_KEY_SECRET) {
apiToken = System.getenv().CURSEFORGE_KEY_SECRET
} else {
apiToken = "DUMMY"
}

changelog = ""
if (new File("resources/changelog/${project.version}.txt").exists()) {
changelog = new File("resources/changelog/${project.version}.txt").text
}
def projectId = "290404" // my project url is http://minecraft.curseforge.com/mc-mods/290404/

addArtifact deobfJar
addArtifact sourcesJar
addArtifact javadocJar
def mainFile = upload(projectId, jar)
mainFile.changelogType = "text"
if (new File("resources/changelog/${project.version}.txt").exists()) {
mainFile.changelog = file("resources/changelog/${project.version}.txt")
}
mainFile.addGameVersion(project.minecraft_version)
mainFile.addModLoader("NeoForge")
}

modrinth {
Expand Down Expand Up @@ -299,3 +282,7 @@ tasks.register('updateGitHooks', Copy) {
into './.git/hooks'
}
compileJava.dependsOn updateGitHooks

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
7 changes: 4 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
mod_id=flopper
mod_version=1.1.5
minecraft_version=1.20.1
forge_version=47.0.1
cyclopscore_version=1.18.4-340
minecraft_version=1.20.4
neoforge_version=20.4.160-beta
cyclopscore_version=1.19.0-408
release_type=release
fingerprint=bd0353b3e8a2810d60dd584e256e364bc3bedd44

Expand Down
8 changes: 3 additions & 5 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven {
name = 'MinecraftForge'
url = 'https://maven.minecraftforge.net/'
}
mavenLocal()
gradlePluginPortal()
maven { url = 'https://maven.neoforged.net/releases' }
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/cyclops/flopper/Flopper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fml.common.Mod;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;
import org.apache.logging.log4j.Level;
import org.cyclops.cyclopscore.config.ConfigHandler;
import org.cyclops.cyclopscore.init.ModBaseVersionable;
Expand All @@ -26,8 +27,8 @@ public class Flopper extends ModBaseVersionable<Flopper> {
*/
public static Flopper _instance;

public Flopper() {
super(Reference.MOD_ID, (instance) -> _instance = instance);
public Flopper(IEventBus modEventBus) {
super(Reference.MOD_ID, (instance) -> _instance = instance, modEventBus);
}

@Override
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/org/cyclops/flopper/RegistryEntries.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.cyclops.flopper;

import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.registries.ObjectHolder;
import net.neoforged.neoforge.registries.DeferredHolder;
import org.cyclops.flopper.blockentity.BlockEntityFlopper;

/**
Expand All @@ -12,11 +14,8 @@
*/
public class RegistryEntries {

@ObjectHolder(registryName = "item", value = "flopper:flopper")
public static final Item ITEM_FLOPPER = null;
@ObjectHolder(registryName = "block", value = "flopper:flopper")
public static final Block BLOCK_FLOPPER = null;
@ObjectHolder(registryName = "block_entity_type", value = "flopper:flopper")
public static final BlockEntityType<BlockEntityFlopper> BLOCK_ENTITY_FLOPPER = null;
public static final DeferredHolder<Item, Item> ITEM_FLOPPER = DeferredHolder.create(Registries.ITEM, new ResourceLocation("flopper:flopper"));
public static final DeferredHolder<Block, Block> BLOCK_FLOPPER = DeferredHolder.create(Registries.BLOCK, new ResourceLocation("flopper:flopper"));
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<BlockEntityFlopper>> BLOCK_ENTITY_FLOPPER = DeferredHolder.create(Registries.BLOCK_ENTITY_TYPE, new ResourceLocation("flopper:flopper"));

}
Loading

0 comments on commit 3af3043

Please sign in to comment.