User: rednesto Date: 04 Jul 23 19:46 Revision: 24fff2b540f5aeee514e70b1f764fd81ffe86926 Summary: Always use official mappings, fix #2079 Also remove old unused Forge templates TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=8586&personal=false Index: src/main/kotlin/platform/forge/creator/asset-steps.kt =================================================================== --- src/main/kotlin/platform/forge/creator/asset-steps.kt (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/kotlin/platform/forge/creator/asset-steps.kt (revision 24fff2b540f5aeee514e70b1f764fd81ffe86926) @@ -108,7 +108,7 @@ mcVersion >= MinecraftVersions.MC1_19 -> MinecraftTemplates.FG3_1_19_MAIN_CLASS_TEMPLATE mcVersion >= MinecraftVersions.MC1_18 -> MinecraftTemplates.FG3_1_18_MAIN_CLASS_TEMPLATE mcVersion >= MinecraftVersions.MC1_17 -> MinecraftTemplates.FG3_1_17_MAIN_CLASS_TEMPLATE - else -> MinecraftTemplates.FG3_MAIN_CLASS_TEMPLATE + else -> MinecraftTemplates.FG3_1_16_MAIN_CLASS_TEMPLATE } assets.addTemplates( Index: src/main/kotlin/platform/forge/creator/gradle-steps.kt =================================================================== --- src/main/kotlin/platform/forge/creator/gradle-steps.kt (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/kotlin/platform/forge/creator/gradle-steps.kt (revision 24fff2b540f5aeee514e70b1f764fd81ffe86926) @@ -40,7 +40,6 @@ import com.demonwav.mcdev.creator.step.NewProjectWizardChainStep.Companion.nextStep import com.demonwav.mcdev.creator.step.UseMixinsStep import com.demonwav.mcdev.util.MinecraftTemplates -import com.demonwav.mcdev.util.MinecraftVersions import com.demonwav.mcdev.util.SemanticVersion import com.intellij.ide.wizard.NewProjectWizardStep import com.intellij.openapi.application.WriteAction @@ -95,9 +94,6 @@ assets.addTemplateProperties( "MOD_NAME" to modName, "MC_VERSION" to mcVersion, - "MCP_CHANNEL" to "official", - "MCP_VERSION" to mcVersion, - "MCP_MC_VERSION" to mcVersion, "MC_NEXT_VERSION" to mcNextVersion, "FORGE_VERSION" to forgeVersion, "FORGE_SPEC_VERSION" to forgeVersion.parts[0].versionString, @@ -122,13 +118,6 @@ assets.addTemplateProperties("GAME_TEST_FRAMEWORK" to "true") } - if (mcVersion <= MinecraftVersions.MC1_16_5) { - assets.addTemplateProperties( - "MCP_CHANNEL" to "snapshot", - "MCP_VERSION" to "20210309", - ) - } - assets.addTemplates( project, "build.gradle" to MinecraftTemplates.FG3_BUILD_GRADLE_TEMPLATE, Index: src/main/kotlin/util/MinecraftTemplates.kt =================================================================== --- src/main/kotlin/util/MinecraftTemplates.kt (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/kotlin/util/MinecraftTemplates.kt (revision 24fff2b540f5aeee514e70b1f764fd81ffe86926) @@ -81,7 +81,7 @@ FileTemplateGroupDescriptor("Forge", PlatformAssets.FORGE_ICON).let { forgeGroup -> group.addTemplate(forgeGroup) forgeGroup.addTemplate(FileTemplateDescriptor(FORGE_MIXINS_JSON_TEMPLATE, PlatformAssets.FORGE_ICON)) - forgeGroup.addTemplate(FileTemplateDescriptor(FG3_MAIN_CLASS_TEMPLATE)) + forgeGroup.addTemplate(FileTemplateDescriptor(FG3_1_16_MAIN_CLASS_TEMPLATE)) forgeGroup.addTemplate(FileTemplateDescriptor(FG3_1_17_MAIN_CLASS_TEMPLATE)) forgeGroup.addTemplate(FileTemplateDescriptor(FG3_1_18_MAIN_CLASS_TEMPLATE)) forgeGroup.addTemplate(FileTemplateDescriptor(FG3_1_19_MAIN_CLASS_TEMPLATE)) @@ -106,15 +106,6 @@ fabricGroup.addTemplate(FileTemplateDescriptor(FABRIC_SETTINGS_GRADLE_TEMPLATE, PlatformAssets.FABRIC_ICON)) } - FileTemplateGroupDescriptor("Multi-Module", PlatformAssets.MINECRAFT_ICON).let { multiGroup -> - group.addTemplate(multiGroup) - multiGroup.addTemplate(FileTemplateDescriptor(MULTI_MODULE_BUILD_GRADLE_TEMPLATE)) - multiGroup.addTemplate(FileTemplateDescriptor(MULTI_MODULE_GRADLE_PROPERTIES_TEMPLATE)) - multiGroup.addTemplate(FileTemplateDescriptor(MULTI_MODULE_SETTINGS_GRADLE_TEMPLATE)) - multiGroup.addTemplate(FileTemplateDescriptor(MULTI_MODULE_POM_TEMPLATE)) - multiGroup.addTemplate(FileTemplateDescriptor(MULTI_MODULE_COMMON_POM_TEMPLATE)) - } - FileTemplateGroupDescriptor("Mixin", PlatformAssets.MIXIN_ICON).let { mixinGroup -> group.addTemplate(mixinGroup) mixinGroup.addTemplate(FileTemplateDescriptor(MIXIN_OVERWRITE_FALLBACK)) @@ -199,7 +190,7 @@ const val SPONGE8_SETTINGS_GRADLE_TEMPLATE = "Sponge 8+ settings.gradle.kts" const val FORGE_MIXINS_JSON_TEMPLATE = "Forge Mixins Config.json" - const val FG3_MAIN_CLASS_TEMPLATE = "Forge (1.13+) Main Class.java" + const val FG3_1_16_MAIN_CLASS_TEMPLATE = "Forge (1.16+) Main Class.java" const val FG3_1_17_MAIN_CLASS_TEMPLATE = "Forge (1.17+) Main Class.java" const val FG3_1_18_MAIN_CLASS_TEMPLATE = "Forge (1.18+) Main Class.java" const val FG3_1_19_MAIN_CLASS_TEMPLATE = "Forge (1.19+) Main Class.java" @@ -235,12 +226,6 @@ const val ARCHITECTURY_FORGE_MODS_TOML_TEMPLATE = "architectury_forge_mods.toml" const val ARCHITECTURY_FORGE_PACK_MCMETA_TEMPLATE = "architectury_forge_pack.mcmeta" - const val MULTI_MODULE_BUILD_GRADLE_TEMPLATE = "Multi-Module Base build.gradle" - const val MULTI_MODULE_GRADLE_PROPERTIES_TEMPLATE = "Multi-Module Base gradle.properties" - const val MULTI_MODULE_SETTINGS_GRADLE_TEMPLATE = "Multi-Module Base settings.gradle" - const val MULTI_MODULE_POM_TEMPLATE = "Multi-Module Base pom.xml" - const val MULTI_MODULE_COMMON_POM_TEMPLATE = "Multi-Module Common pom.xml" - const val MIXIN_OVERWRITE_FALLBACK = "Mixin Overwrite Fallback.java" const val GRADLE_WRAPPER_PROPERTIES = "MinecraftDev gradle-wrapper.properties" Index: src/main/resources/fileTemplates/j2ee/forge/Forge (1.13+) Main Class.java.ft =================================================================== --- src/main/resources/fileTemplates/j2ee/forge/Forge (1.13+) Main Class.java.ft (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/resources/fileTemplates/j2ee/forge/Forge (1.13+) Main Class.java.ft (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) @@ -1,82 +0,0 @@ -package ${PACKAGE_NAME}; - -import net.minecraft.block.Block; -import net.minecraft.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.fml.javafmlmod.FMLJavaModLoadingContext; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.stream.Collectors; - -// The value here should match an entry in the META-INF/mods.toml file -@Mod("${ARTIFACT_ID}") -public class ${CLASS_NAME} { - - // Directly reference a log4j logger. - private static final Logger LOGGER = LogManager.getLogger(); - - public ${CLASS_NAME}() { - // Register the setup method for modloading - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); - // Register the enqueueIMC method for modloading - 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); - } - - private void setup(final FMLCommonSetupEvent event) { - // some preinit code - LOGGER.info("HELLO FROM PREINIT"); - 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().gameSettings); - } - - private void enqueueIMC(final InterModEnqueueEvent event) { - // some example code to dispatch IMC to another mod - InterModComms.sendTo("${ARTIFACT_ID}", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";}); - } - - private void processIMC(final InterModProcessEvent event) { - // some example code to receive and process InterModComms from other mods - LOGGER.info("Got IMC {}", event.getIMCStream(). - map(m->m.getMessageSupplier().get()). - collect(Collectors.toList())); - } - - // You can use SubscribeEvent and let the Event Bus discover methods to call - @SubscribeEvent - public void onServerStarting(FMLServerStartingEvent event) { - // do something when the server starts - LOGGER.info("HELLO from server starting"); - } - - // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD - // Event bus for receiving Registry Events) - @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) - public static class RegistryEvents { - @SubscribeEvent - public static void onBlocksRegistry(final RegistryEvent.Register blockRegistryEvent) { - // register a new block here - LOGGER.info("HELLO from Register Block"); - } - } -} Index: src/main/resources/fileTemplates/j2ee/forge/Forge (1.13+) Main Class.java.html =================================================================== --- src/main/resources/fileTemplates/j2ee/forge/Forge (1.13+) Main Class.java.html (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/resources/fileTemplates/j2ee/forge/Forge (1.13+) Main Class.java.html (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) @@ -1,25 +0,0 @@ - - - - -

This is a built-in file template used to create a new main class for Forge projects 1.13 and above

- - Index: src/main/resources/fileTemplates/j2ee/forge/Forge (1.13+) Submodule build.gradle.ft =================================================================== --- src/main/resources/fileTemplates/j2ee/forge/Forge (1.13+) Submodule build.gradle.ft (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/resources/fileTemplates/j2ee/forge/Forge (1.13+) Submodule build.gradle.ft (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) @@ -1,232 +0,0 @@ -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' } - #if (${MIXINS}) - maven { url = 'https://repo.spongepowered.org/repository/maven-public/' } - #end - mavenCentral() - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true - #if (${MIXINS}) - classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT' - #end - } -} - -apply plugin: 'net.minecraftforge.gradle' -#if (${MIXINS}) -apply plugin: 'org.spongepowered.mixin' -#end - -java { - archivesBaseName = '${ARTIFACT_ID}' - toolchain.languageVersion = JavaLanguageVersion.of(${JAVA_VERSION}) -} - -minecraft { - // 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. - // official MCVersion Official field/method names from Mojang mapping files - // - // 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. - // Simply re-run your setup task after changing the mappings to update your workspace. -#if(${MCP_CHANNEL} == "stable" || ${MCP_CHANNEL} == "snapshot") - mappings channel: '${MCP_CHANNEL}', version: '${MCP_VERSION}-${MCP_MC_VERSION}' -#else - mappings channel: '${MCP_CHANNEL}', version: '${MCP_VERSION}' -#end - - // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') - - // Default run configurations. - // These can be tweaked, removed, or duplicated as needed. - runs { - client { - workingDirectory project.file('run') - - // Recommended logging data for a userdev environment - // The markers can be added/removed as needed separated by commas. - // "SCAN": For mods scan. - // "REGISTRIES": For firing of registry events. - // "REGISTRYDUMP": For getting the contents of all registries. - property 'forge.logging.markers', 'REGISTRIES' - - // Recommended logging level for the console - // You can set various levels here. - // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels - property 'forge.logging.console.level', 'debug' - - #if (${GAME_TEST_FRAMEWORK}) - property 'forge.enabledGameTestNamespaces', '${ARTIFACT_ID}' - #end - - mods { - ${MOD_NAME} { - source sourceSets.main - } - } - } - - server { - workingDirectory project.file('run') - - // Recommended logging data for a userdev environment - // The markers can be added/removed as needed separated by commas. - // "SCAN": For mods scan. - // "REGISTRIES": For firing of registry events. - // "REGISTRYDUMP": For getting the contents of all registries. - property 'forge.logging.markers', 'REGISTRIES' - - // Recommended logging level for the console - // You can set various levels here. - // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels - property 'forge.logging.console.level', 'debug' - - #if (${GAME_TEST_FRAMEWORK}) - property 'forge.enabledGameTestNamespaces', '${ARTIFACT_ID}' - #end - - mods { - ${MOD_NAME} { - source sourceSets.main - } - } - } -#if (${GAME_TEST_FRAMEWORK}) - - gameTestServer { - workingDirectory project.file('run') - - // Recommended logging data for a userdev environment - // 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. - property 'forge.logging.markers', 'REGISTRIES' - - // Recommended logging level for the console - // You can set various levels here. - // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels - property 'forge.logging.console.level', 'debug' - - // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. - property 'forge.enabledGameTestNamespaces', '${ARTIFACT_ID}' - - mods { - ${MOD_NAME} { - source sourceSets.main - } - } - } -#end -#if (${HAS_DATA}) - - data { - workingDirectory project.file('run') - - // Recommended logging data for a userdev environment - // The markers can be added/removed as needed separated by commas. - // "SCAN": For mods scan. - // "REGISTRIES": For firing of registry events. - // "REGISTRYDUMP": For getting the contents of all registries. - property 'forge.logging.markers', 'REGISTRIES' - - // Recommended logging level for the console - // You can set various levels here. - // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels - 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', '${MOD_NAME}', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') - - mods { - ${MOD_NAME} { - source sourceSets.main - } - } - } -#end - } -} -#if (${MIXINS}) - -mixin { - add sourceSets.main, "${ARTIFACT_ID}.refmap.json" - - config "${ARTIFACT_ID}.mixins.json" -} -#end - -// 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 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 'net.minecraftforge:forge:${FORGE_VERSION}' - - api project(":${COMMON_PROJECT_NAME}") - - // 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 - - // 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 -#if (${MIXINS}) - - annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' -#end -} - -// Example for how to get properties into the manifest for reading at runtime. -jar { - manifest { - attributes([ - "Specification-Title": "${MOD_NAME}", - #if (${AUTHOR_LIST}) - "Specification-Vendor": "${AUTHOR_LIST}", - #else - //"Specification-Vendor": "${MOD_NAME} authors", - #end - "Specification-Version": "1", // We are version 1 of ourselves - "Implementation-Title": project.name, - "Implementation-Version": project.jar.archiveVersion, - #if (${AUTHOR_LIST}) - "Implementation-Vendor": "${AUTHOR_LIST}", - #else - //"Implementation-Vendor": "${MOD_NAME} authors", - #end - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ]) - } -} - -tasks.withType(JavaCompile).configureEach { - options.release = ${JAVA_VERSION} -} - -jar.finalizedBy('reobfJar') Index: src/main/resources/fileTemplates/j2ee/forge/Forge (1.13+) Submodule build.gradle.html =================================================================== --- src/main/resources/fileTemplates/j2ee/forge/Forge (1.13+) Submodule build.gradle.html (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/resources/fileTemplates/j2ee/forge/Forge (1.13+) Submodule build.gradle.html (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) @@ -1,25 +0,0 @@ - - - - -

This is a built-in file template used to create a new build.gradle for multi-module Forge projects 1.13 and above.

- - Index: src/main/resources/fileTemplates/j2ee/forge/Forge (1.13+) gradle.properties.ft =================================================================== --- src/main/resources/fileTemplates/j2ee/forge/Forge (1.13+) gradle.properties.ft (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/resources/fileTemplates/j2ee/forge/Forge (1.13+) gradle.properties.ft (revision 24fff2b540f5aeee514e70b1f764fd81ffe86926) @@ -29,7 +29,7 @@ # # 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=${MCP_CHANNEL} +mapping_channel=official # The mapping version to query from the mapping channel. # This must match the format required by the mapping channel. mapping_version=${MC_VERSION} Index: src/main/resources/fileTemplates/j2ee/forge/Forge (1.16+) Main Class.java.ft =================================================================== --- src/main/resources/fileTemplates/j2ee/forge/Forge (1.16+) Main Class.java.ft (revision 24fff2b540f5aeee514e70b1f764fd81ffe86926) +++ src/main/resources/fileTemplates/j2ee/forge/Forge (1.16+) Main Class.java.ft (revision 24fff2b540f5aeee514e70b1f764fd81ffe86926) @@ -0,0 +1,82 @@ +package ${PACKAGE_NAME}; + +import net.minecraft.block.Block; +import net.minecraft.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.fml.javafmlmod.FMLJavaModLoadingContext; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.stream.Collectors; + +// The value here should match an entry in the META-INF/mods.toml file +@Mod("${ARTIFACT_ID}") +public class ${CLASS_NAME} { + + // Directly reference a log4j logger. + private static final Logger LOGGER = LogManager.getLogger(); + + public ${CLASS_NAME}() { + // Register the setup method for modloading + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); + // Register the enqueueIMC method for modloading + 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); + } + + private void setup(final FMLCommonSetupEvent event) { + // some preinit code + LOGGER.info("HELLO FROM PREINIT"); + 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 + InterModComms.sendTo("${ARTIFACT_ID}", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";}); + } + + private void processIMC(final InterModProcessEvent event) { + // some example code to receive and process InterModComms from other mods + LOGGER.info("Got IMC {}", event.getIMCStream(). + map(m->m.getMessageSupplier().get()). + collect(Collectors.toList())); + } + + // You can use SubscribeEvent and let the Event Bus discover methods to call + @SubscribeEvent + public void onServerStarting(FMLServerStartingEvent event) { + // do something when the server starts + LOGGER.info("HELLO from server starting"); + } + + // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD + // Event bus for receiving Registry Events) + @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) + public static class RegistryEvents { + @SubscribeEvent + public static void onBlocksRegistry(final RegistryEvent.Register blockRegistryEvent) { + // register a new block here + LOGGER.info("HELLO from Register Block"); + } + } +} Index: src/main/resources/fileTemplates/j2ee/forge/Forge (1.16+) Main Class.java.html =================================================================== --- src/main/resources/fileTemplates/j2ee/forge/Forge (1.16+) Main Class.java.html (revision 24fff2b540f5aeee514e70b1f764fd81ffe86926) +++ src/main/resources/fileTemplates/j2ee/forge/Forge (1.16+) Main Class.java.html (revision 24fff2b540f5aeee514e70b1f764fd81ffe86926) @@ -0,0 +1,25 @@ + + + + +

This is a built-in file template used to create a new main class for Forge projects 1.16 and above

+ + Index: src/main/resources/fileTemplates/j2ee/forge/Forge Main Class.java.ft =================================================================== --- src/main/resources/fileTemplates/j2ee/forge/Forge Main Class.java.ft (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/resources/fileTemplates/j2ee/forge/Forge Main Class.java.ft (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) @@ -1,106 +0,0 @@ -package ${PACKAGE_NAME}; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.registry.GameRegistry; - -@Mod( - modid = ${CLASS_NAME}.MOD_ID, - name = ${CLASS_NAME}.MOD_NAME, - version = ${CLASS_NAME}.VERSION -) -public class ${CLASS_NAME} { - - public static final String MOD_ID = "${ARTIFACT_ID}"; - public static final String MOD_NAME = "${MOD_NAME}"; - public static final String VERSION = "${MOD_VERSION}"; - - /** This is the instance of your mod as created by Forge. It will never be null. */ - @Mod.Instance(MOD_ID) - public static ${CLASS_NAME} INSTANCE; - - /** - * This is the first initialization event. Register tile entities here. - * The registry events below will have fired prior to entry to this method. - */ - @Mod.EventHandler - public void preinit(FMLPreInitializationEvent event) { - - } - - /** - * This is the second initialization event. Register custom recipes - */ - @Mod.EventHandler - public void init(FMLInitializationEvent event) { - - } - - /** - * This is the final initialization event. Register actions from other mods here - */ - @Mod.EventHandler - public void postinit(FMLPostInitializationEvent event) { - - } - - /** - * Forge will automatically look up and bind blocks to the fields in this class - * based on their registry name. - */ - @GameRegistry.ObjectHolder(MOD_ID) - public static class Blocks { - /* - public static final MySpecialBlock mySpecialBlock = null; // placeholder for special block below - */ - } - - /** - * Forge will automatically look up and bind items to the fields in this class - * based on their registry name. - */ - @GameRegistry.ObjectHolder(MOD_ID) - public static class Items { - /* - public static final ItemBlock mySpecialBlock = null; // itemblock for the block above - public static final MySpecialItem mySpecialItem = null; // placeholder for special item below - */ - } - - /** - * This is a special class that listens to registry events, to allow creation of mod blocks and items at the proper time. - */ - @Mod.EventBusSubscriber - public static class ObjectRegistryHandler { - /** Listen for the register event for creating custom items */ - @SubscribeEvent - public static void addItems(RegistryEvent.Register event) { - /* - event.getRegistry().register(new ItemBlock(Blocks.myBlock).setRegistryName(MOD_ID, "myBlock")); - event.getRegistry().register(new MySpecialItem().setRegistryName(MOD_ID, "mySpecialItem")); - */ - } - /** Listen for the register event for creating custom blocks */ - @SubscribeEvent - public static void addBlocks(RegistryEvent.Register event) { - /* - event.getRegistry().register(new MySpecialBlock().setRegistryName(MOD_ID, "mySpecialBlock")); - */ - } - } - /* EXAMPLE ITEM AND BLOCK - you probably want these in separate files - public static class MySpecialItem extends Item { - - } - - public static class MySpecialBlock extends Block { - - } - */ -} Index: src/main/resources/fileTemplates/j2ee/forge/Forge Main Class.java.html =================================================================== --- src/main/resources/fileTemplates/j2ee/forge/Forge Main Class.java.html (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/resources/fileTemplates/j2ee/forge/Forge Main Class.java.html (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) @@ -1,25 +0,0 @@ - - - - -

This is a built-in file template used to create a new main class for Forge projects 1.12 and below

- - Index: src/main/resources/fileTemplates/j2ee/forge/Forge build.gradle.ft =================================================================== --- src/main/resources/fileTemplates/j2ee/forge/Forge build.gradle.ft (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/resources/fileTemplates/j2ee/forge/Forge build.gradle.ft (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) @@ -1,57 +0,0 @@ -buildscript { - repositories { - mavenCentral() - maven { - name = "forge" - url = "https://files.minecraftforge.net/maven" - } - } - dependencies { - classpath "net.minecraftforge.gradle:ForgeGradle:${FORGEGRADLE_VERSION}-SNAPSHOT" - } -} - -apply plugin: "net.minecraftforge.gradle.forge" - -group = '${GROUP_ID}' -version = '${MOD_VERSION}' -archivesBaseName = '${ARTIFACT_ID}' - -minecraft { - version = project.forgeVersion - runDir = "run" - - // the mappings can be changed at any time, and must be in the following format. - // snapshot_YYYYMMDD snapshot are built nightly. - // stable_# stables are built at the discretion of the MCP team. - // 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 = project.mcpVersion - // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. -} - -repositories { - mavenCentral() -} - -dependencies { -} - -processResources { - // this will ensure that this task is redone when the versions change. - inputs.property "version", project.version - inputs.property "mcversion", project.minecraft.version - - // replace stuff in mcmod.info, nothing else - from(sourceSets.main.resources.srcDirs) { - include "mcmod.info" - - // replace version and mcversion - expand "version": project.version, "mcversion": project.minecraft.version - } - - // copy everything else, thats not the mcmod.info - from(sourceSets.main.resources.srcDirs) { - exclude "mcmod.info" - } -} Index: src/main/resources/fileTemplates/j2ee/forge/Forge build.gradle.html =================================================================== --- src/main/resources/fileTemplates/j2ee/forge/Forge build.gradle.html (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/resources/fileTemplates/j2ee/forge/Forge build.gradle.html (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) @@ -1,25 +0,0 @@ - - - - -

This is a built-in file template used to create a new build.gradle for Forge projects 1.12 and below.

- - Index: src/main/resources/fileTemplates/j2ee/forge/Forge gradle.properties.ft =================================================================== --- src/main/resources/fileTemplates/j2ee/forge/Forge gradle.properties.ft (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/resources/fileTemplates/j2ee/forge/Forge gradle.properties.ft (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) @@ -1,8 +0,0 @@ -#if (${FORGE_VERSION}) -forgeVersion = ${FORGE_VERSION} -#end -#if (${MCP_VERSION}) -mcpVersion = ${MCP_VERSION} -#end -org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false Index: src/main/resources/fileTemplates/j2ee/forge/Forge gradle.properties.html =================================================================== --- src/main/resources/fileTemplates/j2ee/forge/Forge gradle.properties.html (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/resources/fileTemplates/j2ee/forge/Forge gradle.properties.html (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) @@ -1,25 +0,0 @@ - - - - -

This is a built-in file template used to create a new gradle.properties file for Forge projects 1.12 and below.

- - Index: src/main/resources/fileTemplates/j2ee/forge/Forge settings.gradle.ft =================================================================== --- src/main/resources/fileTemplates/j2ee/forge/Forge settings.gradle.ft (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/resources/fileTemplates/j2ee/forge/Forge settings.gradle.ft (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) @@ -1,1 +0,0 @@ -rootProject.name = '${ARTIFACT_ID}' Index: src/main/resources/fileTemplates/j2ee/forge/Forge settings.gradle.html =================================================================== --- src/main/resources/fileTemplates/j2ee/forge/Forge settings.gradle.html (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) +++ src/main/resources/fileTemplates/j2ee/forge/Forge settings.gradle.html (revision af4d95cbe1f4e7698d75bdc795d99012b15c9a18) @@ -1,25 +0,0 @@ - - - - -

This is a built-in file template used to create a new settings.gradle for Forge projects 1.12 and below.

- -