Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,33 @@ Mod for Minecraft that adds Worker Villagers.

https://www.curseforge.com/minecraft/mc-mods/workers

## NeoForge 1.21.1 build

Requirements:

- Java 21
- NeoForge 21.1.219
- A built Recruits 1.21.1 development checkout

By default, the build uses:

```text
../recruits-neoforge-1.21.1/build/libs/recruits-1.21.1-1.15.0-all.jar
```

Build Recruits first, then run:

```bash
./gradlew clean build
```

To use a Recruits jar in another location:

```bash
./gradlew clean build -Precruits_jar=/absolute/path/to/recruits-1.21.1-1.15.0-all.jar
```

The distributable Workers artifact is the `-all.jar` file in `build/libs`.
It contains the relocated CoreLib classes and still requires Recruits 1.21.1.

All Rights Reserved unless otherwise explicitly stated.
183 changes: 73 additions & 110 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://repo.spongepowered.org/maven' }
jcenter()
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.+', changing: true
classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7-SNAPSHOT'
}
}
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.

plugins {
id "com.matthewprenger.cursegradle" version "1.4.0"
id "com.github.johnrengelman.shadow" version "7.1.0"
id 'net.neoforged.moddev' version '2.0.107'
id 'com.gradleup.shadow' version '8.3.10'
}
apply plugin: 'net.minecraftforge.gradle'

apply plugin: 'idea'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'org.spongepowered.mixin'

idea {
module {
Expand All @@ -28,135 +12,114 @@ idea {
}
}

mixin{
add sourceSets.main, 'mixins.workers.refmap.json'
config 'mixins.workers.json'
version = mod_version
group = mod_group_id
archivesBaseName = "workers-${minecraft_version}"

disableTargetValidator = true
overwriteErrorLevel = 'error'
}

version = '2.0.3'

group = 'com.talhanation.workers'
archivesBaseName = 'workers-1.20.1'
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

tasks.withType(JavaCompile).configureEach {
options.compilerArgs.addAll(['-Xmaxerrs', '1000'])
}

sourceSets.main.resources {
srcDir 'src/generated/resources'
srcDir 'src/main/templates'
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
def workersRunDirectory = findProperty('workers_run_dir') ?: 'run'

minecraft {
mappings channel: 'official', version: '1.20.1'
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
neoForge {
version = neo_version
accessTransformers = files('src/main/resources/META-INF/accesstransformer.cfg')

runs {
client {
workingDirectory project.file('run')

property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'

property 'forge.enabledGameTestNamespaces', 'workers'

Random rnd = new Random()

args = ['--username', 'talhanation']
//args = ['--username', 'ezgination']
configureEach {
logLevel = org.slf4j.event.Level.INFO
systemProperty 'neoforge.enabledGameTestNamespaces', mod_id
}

mods {
'workers' {
source sourceSets.main
}
}
client {
client()
gameDirectory = project.file(workersRunDirectory)
programArgument '--username'
programArgument 'talhanation'
}

server {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'workers'


mods {
'workers' {
source sourceSets.main
}
}
server()
gameDirectory = project.file(workersRunDirectory)
programArgument 'nogui'
}

data {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'

// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
args '--mod', 'workers', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')

mods {
'workers' {
source sourceSets.main
}
}
data()
gameDirectory = project.file(workersRunDirectory)
programArguments.addAll '--mod', mod_id, '--all',
'--output', file('src/generated/resources/').absolutePath,
'--existing', file('src/main/resources/').absolutePath
}
}
}


sourceSets.main.resources { srcDir 'src/generated/resources' }
mods {
workers {
sourceSet sourceSets.main
}
}
}

repositories {
maven {
name = "henkelmax.public"
name = 'henkelmax.public'
url = 'https://maven.maxhenkel.de/repository/public'
}
mavenLocal()
maven {

url "https://www.cursemaven.com"
name = 'NeoForge'
url = 'https://maven.neoforged.net/releases'
}
}

dependencies {
minecraft 'net.minecraftforge:forge:1.20.1-47.4.1'
shadow fg.deobf("de.maxhenkel.corelib:corelib:1.20.1-1.1.3:api")
runtimeOnly fg.deobf("de.maxhenkel.corelib:corelib:1.20.1-1.1.3")
runtimeOnly fg.deobf("de.maxhenkel.corelib:corelib:1.20.1-1.1.3:javadoc")

annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'

implementation fg.deobf("curse.maven:recruits-523860:8253342")

implementation fg.deobf("curse.maven:dynamictrees-252818:8227003")
implementation fg.deobf("curse.maven:architectury-api-419699:5137938")
implementation fg.deobf("curse.maven:lets-do-herbal-brews-951221:6458889")
implementation fg.deobf("curse.maven:supplementaries-412082:6615104")
implementation fg.deobf("curse.maven:selene-499980:6681465")

//implementation fg.deobf("curse.maven:small-ships-450659:5324996")

implementation fg.deobf("curse.maven:farmers-delight-398521:8083474")
implementation fg.deobf("curse.maven:worldedit-225608:4586218")

def recruitsJar = file(recruits_jar)
if (!recruitsJar.exists()) {
throw new GradleException(
"Recruits 1.21.1 dependency not found at ${recruitsJar}. " +
"Build ../recruits-neoforge-1.21.1 first."
)
}

// Example for how to get properties into the manifest for reading at runtime.
jar {
dependencies {
shadow "de.maxhenkel.corelib:corelib:${corelib_version}:api"
runtimeOnly "de.maxhenkel.corelib:corelib:${corelib_version}"

implementation files(recruitsJar)
}

jar.finalizedBy('reobfJar')

artifacts {
archives shadowJar
}

shadowJar {
project.configurations.shadow.setTransitive(true)
configurations = [project.configurations.shadow]
//classifier = ""
relocate 'de.maxhenkel.corelib', "de.maxhenkel.workers.corelib"
relocate 'de.maxhenkel.corelib', 'de.maxhenkel.workers.corelib'
}

reobf {
shadowJar {}
tasks.named('processResources') {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
def replaceProperties = [
minecraft_version_range: minecraft_version_range,
neo_version_range : neo_version_range,
loader_version_range : loader_version_range,
mod_id : mod_id,
mod_name : mod_name,
mod_license : mod_license,
mod_version : mod_version,
mod_authors : mod_authors,
mod_description : mod_description,
recruits_version_range : recruits_version_range
]
inputs.properties replaceProperties
filesMatching('META-INF/neoforge.mods.toml') {
expand replaceProperties
}
}
69 changes: 15 additions & 54 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,59 +1,20 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx4G
org.gradle.daemon=false

minecraft_version=1.21.1
minecraft_version_range=[1.21.1,1.22)
neo_version=21.1.219
neo_version_range=[21.1,)
loader_version_range=[4,)

## Environment Properties

# The Minecraft version must agree with the Forge version to get a valid artifact
minecraft_version=1.20.1
# The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.20.1,1.21)
# The Forge version must agree with the Minecraft version to get a valid artifact
forge_version=47.1.0
# The Forge version range can use any version of Forge as bounds or match the loader version range
forge_version_range=[47,)
# The loader version range can only use the major version of Forge/FML as bounds
loader_version_range=[47,)
# The mapping channel to use for mappings.
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
#
# | Channel | Version | |
# |-----------|----------------------|--------------------------------------------------------------------------------|
# | official | MCVersion | Official field/method names from Mojang mapping files |
# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official |
#
# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
#
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
mapping_channel=official
# The mapping version to query from the mapping channel.
# This must match the format required by the mapping channel.
mapping_version=1.20.1


## Mod Properties

# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
# Must match the String constant located in the main mod class annotated with @Mod.
mod_id=examplemod
# The human-readable display name for the mod.
mod_name=Example Mod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_id=workers
mod_name=Villager Workers Mod
mod_license=All Rights Reserved
# The mod version. See https://semver.org/
mod_version=1.0.0
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
mod_group_id=com.example.examplemod
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
mod_authors=YourNameHere, OtherNameHere
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=Example mod description.\nNewline characters can be used and will be replaced properly.
mod_version=2.0.3
mod_group_id=com.talhanation.workers
mod_authors=talhanation
mod_description=Adds hireable Villager Workers into Minecraft.

corelib_version=1.21.1-2.1.11
recruits_version_range=[1.15.0,)
recruits_jar=../recruits-neoforge-1.21.1/build/libs/recruits-1.21.1-1.15.0-all.jar
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 6 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
maven {
name = 'MinecraftForge'
url = 'https://maven.minecraftforge.net/'
}
maven {
name = 'NeoForge'
url = 'https://maven.neoforged.net/releases'
}
}
}

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
}
}
10 changes: 5 additions & 5 deletions src/main/java/com/talhanation/workers/AttributeEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.talhanation.workers.entities.*;
import com.talhanation.workers.init.ModEntityTypes;
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.neoforged.neoforge.event.entity.EntityAttributeCreationEvent;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;

@Mod.EventBusSubscriber(modid = WorkersMain.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
@EventBusSubscriber(modid = WorkersMain.MOD_ID)
public class AttributeEvent {

@SubscribeEvent
Expand All @@ -21,4 +21,4 @@ public static void entityAttributeEvent(final EntityAttributeCreationEvent event
event.put(ModEntityTypes.COURIER.get(), AnimalFarmerEntity.setAttributes().build());
event.put(ModEntityTypes.COOK.get(), CookEntity.setAttributes().build());
}
}
}
Loading