summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle76
-rw-r--r--src/main/java/com/example/examplemod/ExampleMod.java16
2 files changed, 44 insertions, 48 deletions
diff --git a/build.gradle b/build.gradle
index 17e2f9b..2cd5253 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,6 @@
buildscript {
repositories {
+ // These repositories are only for Gradle plugins, put any other repositories in the repository block further below
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
@@ -16,11 +17,12 @@ version = '1.0'
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'modid'
-java.toolchain.languageVersion = JavaLanguageVersion.of(8) // Mojang ships Java 8 to end users, so your mod should target Java 8.
+// Mojang ships Java 16 to end users in 1.17+ instead of Java 8 in 1.16 or lower, so your mod should target Java 16.
+java.toolchain.languageVersion = JavaLanguageVersion.of(16)
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
- // The mappings can be changed at any time, and must be in the following format.
+ // The mappings can be changed at any time and must be in the following format.
// Channel: Version:
// snapshot YYYYMMDD Snapshot are built nightly.
// stable # Stables are built at the discretion of the MCP team.
@@ -29,12 +31,11 @@ minecraft {
// You must be aware of the Mojang license when using the 'official' mappings.
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
//
- // Use non-default mappings at your own risk. they may not always work.
+ // Use non-default mappings at your own risk. They may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: '@MAPPING_CHANNEL@', version: '@MAPPING_VERSION@'
- // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
-
- // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
+
+ // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
@@ -43,7 +44,7 @@ minecraft {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
- // The markers can be changed as needed.
+ // The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
@@ -65,7 +66,7 @@ minecraft {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
- // The markers can be changed as needed.
+ // The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
@@ -87,7 +88,7 @@ minecraft {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
- // The markers can be changed as needed.
+ // The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
@@ -113,52 +114,55 @@ minecraft {
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
+repositories {
+ // Put repositories for dependencies here
+ // ForgeGradle automatically adds the Forge maven and Maven Central for you
+
+ // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
+ // flatDir {
+ // dir 'libs'
+ // }
+}
+
dependencies {
- // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
- // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
+ // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
+ // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft '@FORGE_GROUP@:@FORGE_NAME@:@FORGE_VERSION@'
- // You may put jars on which you depend on in ./libs or you may define them like so..
- // compile "some.group:artifact:version:classifier"
- // compile "some.group:artifact:version"
+ // Real mod deobf dependency examples - these get remapped to your current mappings
+ // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
+ // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
+ // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
- // Real examples
- // compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
- // compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
-
- // The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
- // provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
-
- // These dependencies get remapped to your current MCP mappings
- // deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
+ // Examples using mod jars from ./libs
+ // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
-
}
-// Example for how to get properties into the manifest for reading by the runtime..
+// Example for how to get properties into the manifest for reading at runtime.
jar {
manifest {
attributes([
- "Specification-Title": "examplemod",
- "Specification-Vendor": "examplemodsareus",
- "Specification-Version": "1", // We are version 1 of ourselves
- "Implementation-Title": project.name,
- "Implementation-Version": "${version}",
- "Implementation-Vendor" :"examplemodsareus",
- "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
+ "Specification-Title" : "examplemod",
+ "Specification-Vendor" : "examplemodsareus",
+ "Specification-Version" : "1", // We are version 1 of ourselves
+ "Implementation-Title" : project.name,
+ "Implementation-Version" : project.jar.archiveVersion,
+ "Implementation-Vendor" : "examplemodsareus",
+ "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
-// Example configuration to allow publishing using the maven-publish task
+// Example configuration to allow publishing using the maven-publish plugin
// This is the preferred method to reobfuscate your jar file
-jar.finalizedBy('reobfJar')
+jar.finalizedBy('reobfJar')
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
-//publish.dependsOn('reobfJar')
+// publish.dependsOn('reobfJar')
publishing {
publications {
@@ -168,7 +172,7 @@ publishing {
}
repositories {
maven {
- url "file:///${project.projectDir}/mcmodsrepo"
+ url "file://${project.projectDir}/mcmodsrepo"
}
}
}
diff --git a/src/main/java/com/example/examplemod/ExampleMod.java b/src/main/java/com/example/examplemod/ExampleMod.java
index b96f36a..b744326 100644
--- a/src/main/java/com/example/examplemod/ExampleMod.java
+++ b/src/main/java/com/example/examplemod/ExampleMod.java
@@ -1,17 +1,16 @@
package com.example.examplemod;
-import net.minecraft.block.Block;
-import net.minecraft.block.Blocks;
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.common.Mod;
-import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
-import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
+import net.minecraftforge.fmlserverevents.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -32,8 +31,6 @@ public class ExampleMod
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
// Register the processIMC method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
- // Register the doClientStuff method for modloading
- FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
@@ -46,11 +43,6 @@ public class ExampleMod
LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
}
- private void doClientStuff(final FMLClientSetupEvent event) {
- // do something that can only be done on the client
- LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().options);
- }
-
private void enqueueIMC(final InterModEnqueueEvent event)
{
// some example code to dispatch IMC to another mod
@@ -61,7 +53,7 @@ public class ExampleMod
{
// some example code to receive and process InterModComms from other mods
LOGGER.info("Got IMC {}", event.getIMCStream().
- map(m->m.getMessageSupplier().get()).
+ map(m->m.messageSupplier().get()).
collect(Collectors.toList()));
}
// You can use SubscribeEvent and let the Event Bus discover methods to call