From 38ba20305ebf45f4cb7db24a426cd74b655c53ec Mon Sep 17 00:00:00 2001 From: DrMangoTea Date: Mon, 28 Aug 2023 09:52:33 +0200 Subject: [PATCH] gradle does not combust when starting the game --- build.gradle | 161 +++++++++--------- gradle.properties | 14 +- .../java/com/drmangotea/tfmg/CreateTFMG.java | 37 ++++ .../com/example/examplemod/ExampleMod.java | 90 ---------- src/main/resources/META-INF/mods.toml | 93 ++++------ src/main/resources/pack.mcmeta | 2 +- src/main/resources/tfmg.mixins.json | 15 ++ 7 files changed, 175 insertions(+), 237 deletions(-) create mode 100644 src/main/java/com/drmangotea/tfmg/CreateTFMG.java delete mode 100644 src/main/java/com/example/examplemod/ExampleMod.java create mode 100644 src/main/resources/tfmg.mixins.json diff --git a/build.gradle b/build.gradle index dc7c9085..e709b832 100644 --- a/build.gradle +++ b/build.gradle @@ -1,58 +1,52 @@ +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() + jcenter() + maven { url = 'https://repo.spongepowered.org/repository/maven-public' } + } + dependencies { + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true + classpath "org.spongepowered:mixingradle:0.7-SNAPSHOT" + } +} +// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. plugins { id 'eclipse' id 'maven-publish' - id 'net.minecraftforge.gradle' version '5.1.+' + id 'com.matthewprenger.cursegradle' version '1.4.0' } +apply plugin: 'net.minecraftforge.gradle' +apply plugin: 'org.spongepowered.mixin' +//mixin { +// add sourceSets.main, "tfmg.refmap.json" +//} -version = '1.0' -group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = 'modid' +version = '0.6.0-1.19.2' +group = 'com.drmangotea.tfmg' // http://maven.apache.org/guides/mini/guide-naming-conventions.html +archivesBaseName = 'tfmg' // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) 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. - // 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 MinecraftForge - // Additional setup is needed to use their mappings: https://github.com/ParchmentMC/Parchment/wiki/Getting-Started - // - // 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: 'official', version: '1.19.2' // 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. runs { client { 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. + arg '-mixin.config=tfmg.mixins.json' 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', 'examplemod' - + property 'forge.enabledGameTestNamespaces', 'tfmg' + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg" mods { - examplemod { + tfmg { source sourceSets.main } } @@ -60,34 +54,28 @@ minecraft { server { workingDirectory project.file('run') - + arg '-mixin.config=tfmg.mixins.json' property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'debug' - - property 'forge.enabledGameTestNamespaces', 'examplemod' - + property 'forge.enabledGameTestNamespaces', 'tfmg' + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg" mods { - examplemod { + tfmg { source sourceSets.main } } } - // This run config launches GameTestServer and runs all registered gametests, then exits. - // By default, the server will crash when no gametests are provided. - // The gametest system is also enabled by default for other run configs under the /test command. gameTestServer { workingDirectory project.file('run') - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'debug' - - property 'forge.enabledGameTestNamespaces', 'examplemod' - + property 'forge.enabledGameTestNamespaces', 'tfmg' + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg" mods { - examplemod { + tfmg { source sourceSets.main } } @@ -95,16 +83,11 @@ minecraft { 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', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') - + args '--mod', 'tfmg', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') mods { - examplemod { + tfmg { source sourceSets.main } } @@ -112,58 +95,70 @@ 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' - // } + + maven { + // location of the maven that hosts JEI files since January 2023 + // location of the maven for Vazkii's mods + name = "Jared's maven" + url = "https://maven.blamejared.com/" + } + + maven { + url "https://maven.tterrag.com/" + } + + + + + } 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:1.19.2-43.2.21' - // 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}") + minecraft 'net.minecraftforge:forge:1.19.2-43.2.3' - // For more info... - // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html - // http://www.gradle.org/docs/current/userguide/dependency_management.html + compileOnly fg.deobf("com.tterrag.registrate:Registrate:${registrate_version}") + implementation fg.deobf("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}") + + implementation fg.deobf("com.simibubi.create:create-${create_minecraft_version}:${create_version}:all") { transitive = false } + + compileOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}-common-api:${jei_version}") + compileOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}-forge-api:${jei_version}") + runtimeOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}-forge:${jei_version}") + + + + + annotationProcessor "org.spongepowered:mixin:0.8.5:processor" + testAnnotationProcessor "org.spongepowered:mixin:0.8.5:processor" } // Example for how to get properties into the manifest for reading at runtime. jar { manifest { attributes([ - "Specification-Title" : "examplemod", - "Specification-Vendor" : "examplemodsareus", + "Specification-Title" : "tfmg", + "Specification-Vendor" : "tfmgsareus", "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") + "Implementation-Vendor" : "tfmgsareus", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + "MixinConfigs": "tfmg.mixins.json" ]) } } -// Example configuration to allow publishing using the maven-publish plugin -// This is the preferred method to reobfuscate your jar file + 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') + publishing { publications { diff --git a/gradle.properties b/gradle.properties index 878bf1f7..5f6a3164 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,12 @@ -# 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=-Xmx3G -org.gradle.daemon=false \ No newline at end of file +org.gradle.daemon=false + +jei_minecraft_version = 1.19.2 +jei_version = 11.4.0.274 + +create_minecraft_version = 1.19.2 +flywheel_minecraft_version = 1.19.2 +flywheel_version = 0.6.9-18 +create_version = 0.5.1.c-36 + +registrate_version = MC1.19-1.1.5 \ No newline at end of file diff --git a/src/main/java/com/drmangotea/tfmg/CreateTFMG.java b/src/main/java/com/drmangotea/tfmg/CreateTFMG.java new file mode 100644 index 00000000..46116baf --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/CreateTFMG.java @@ -0,0 +1,37 @@ +package com.drmangotea.tfmg; + +import com.mojang.logging.LogUtils; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.event.server.ServerStartingEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import org.slf4j.Logger; + + +@Mod(CreateTFMG.MOD_ID) +public class CreateTFMG +{ + + public static final String MOD_ID = "tfmg"; + private static final Logger LOGGER = LogUtils.getLogger(); + + public CreateTFMG() + { + IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + + // + + + // + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onServerStarting(ServerStartingEvent event) + { + LOGGER.info("YEEEHAAW"); + } + +} diff --git a/src/main/java/com/example/examplemod/ExampleMod.java b/src/main/java/com/example/examplemod/ExampleMod.java deleted file mode 100644 index 803db879..00000000 --- a/src/main/java/com/example/examplemod/ExampleMod.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.example.examplemod; - -import com.mojang.logging.LogUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.material.Material; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.IEventBus; -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.event.server.ServerStartingEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; -import org.slf4j.Logger; - -// The value here should match an entry in the META-INF/mods.toml file -@Mod(ExampleMod.MODID) -public class ExampleMod -{ - // Define mod id in a common place for everything to reference - public static final String MODID = "examplemod"; - // Directly reference a slf4j logger - private static final Logger LOGGER = LogUtils.getLogger(); - // Create a Deferred Register to hold Blocks which will all be registered under the "examplemod" namespace - public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID); - // Create a Deferred Register to hold Items which will all be registered under the "examplemod" namespace - public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); - - // Creates a new Block with the id "examplemod:example_block", combining the namespace and path - public static final RegistryObject EXAMPLE_BLOCK = BLOCKS.register("example_block", () -> new Block(BlockBehaviour.Properties.of(Material.STONE))); - // Creates a new BlockItem with the id "examplemod:example_block", combining the namespace and path - public static final RegistryObject EXAMPLE_BLOCK_ITEM = ITEMS.register("example_block", () -> new BlockItem(EXAMPLE_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_BUILDING_BLOCKS))); - - public ExampleMod() - { - IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); - - // Register the commonSetup method for modloading - modEventBus.addListener(this::commonSetup); - - // Register the Deferred Register to the mod event bus so blocks get registered - BLOCKS.register(modEventBus); - // Register the Deferred Register to the mod event bus so items get registered - ITEMS.register(modEventBus); - - // Register ourselves for server and other game events we are interested in - MinecraftForge.EVENT_BUS.register(this); - } - - private void commonSetup(final FMLCommonSetupEvent event) - { - // Some common setup code - LOGGER.info("HELLO FROM COMMON SETUP"); - LOGGER.info("DIRT BLOCK >> {}", ForgeRegistries.BLOCKS.getKey(Blocks.DIRT)); - } - - // You can use SubscribeEvent and let the Event Bus discover methods to call - @SubscribeEvent - public void onServerStarting(ServerStartingEvent event) - { - // Do something when the server starts - LOGGER.info("HELLO from server starting"); - } - - // You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent - @Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) - public static class ClientModEvents - { - @SubscribeEvent - public static void onClientSetup(FMLClientSetupEvent event) - { - // Some client setup code - LOGGER.info("HELLO FROM CLIENT SETUP"); - LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName()); - } - } -} diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index a64d209f..d6012dd4 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,70 +1,43 @@ -# This is an example mods.toml file. It contains the data relating to the loading mods. -# There are several mandatory fields (#mandatory), and many more that are optional (#optional). -# The overall format is standard TOML format, v0.5.0. -# Note that there are a couple of TOML lists in this file. -# Find more information on toml format here: https://github.com/toml-lang/toml -# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml -modLoader="javafml" #mandatory -# A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion="[43,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. -# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. -# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. -license="All rights reserved" -# A URL to refer people to when problems occur with this mod -#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional -# A list of mods - how many allowed here is determined by the individual mod loader -[[mods]] #mandatory -# The modid of the mod -modId="examplemod" #mandatory -# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it -# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata -# see the associated build.gradle script for how to populate this completely automatically during a build -version="${file.jarVersion}" #mandatory - # A display name for the mod -displayName="Example Mod" #mandatory -# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ -#updateJSONURL="https://change.me.example.invalid/updates.json" #optional -# A URL for the "homepage" for this mod, displayed in the mod UI -#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional -# A file name (in the root of the mod JAR) containing a logo for display -logoFile="examplemod.png" #optional -# A text field displayed in the mod UI -credits="Thanks for this example mod goes to Java" #optional -# A text field displayed in the mod UI -authors="Love, Cheese and small house plants" #optional -# Display Test controls the display for your mod in the server connection screen -# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod. -# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod. -# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component. -# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value. -# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself. -#displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional) +modLoader="javafml" + +loaderVersion="[43,)" + +license="MIT" + +[[mods]] + +modId="tfmg" + +version="${file.jarVersion}" + +displayName="Create: The Factory Must Grow" + +logoFile="logo.png" + +#credits="Thanks for this example mod goes to Java" + +authors="DrMangoTea, Pepagg, MilkFur" -# The description text for the mod (multi line!) (#mandatory) description=''' -This is a long form description of the mod. You can write whatever you want here - -Have some lorem ipsum. - -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis lacinia magna. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sagittis luctus odio eu tempus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque volutpat ligula eget lacus auctor sagittis. In hac habitasse platea dictumst. Nunc gravida elit vitae sem vehicula efficitur. Donec mattis ipsum et arcu lobortis, eleifend sagittis sem rutrum. Cras pharetra quam eget posuere fermentum. Sed id tincidunt justo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. +description soon ''' -# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. -[[dependencies.examplemod]] #optional - # the modid of the dependency - modId="forge" #mandatory - # Does this dependency have to exist - if not, ordering below must be specified - mandatory=true #mandatory - # The version range of the dependency - versionRange="[43,)" #mandatory - # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory + +[[dependencies.tfmg]] + + modId="forge" + + mandatory=true + + versionRange="[43,)" + ordering="NONE" - # Side this dependency is applied on - BOTH, CLIENT or SERVER + side="BOTH" -# Here's another dependency -[[dependencies.examplemod]] + +[[dependencies.tfmg]] modId="minecraft" mandatory=true -# This version range declares a minimum of the current minecraft version up to but not including the next major version + versionRange="[1.19.2,1.20)" ordering="NONE" side="BOTH" diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index b643e13f..fb0efe63 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { - "description": "examplemod resources", + "description": "tfmg resources", "pack_format": 9, "forge:resource_pack_format": 9, "forge:data_pack_format": 10 diff --git a/src/main/resources/tfmg.mixins.json b/src/main/resources/tfmg.mixins.json new file mode 100644 index 00000000..fc003fd1 --- /dev/null +++ b/src/main/resources/tfmg.mixins.json @@ -0,0 +1,15 @@ + +{ + "required": true, + "minVersion": 0.8, + "package": "com.drmangotea.tfmg.mixins", + "compatibilityLevel": "JAVA_8", + "refmap": "tfmg.refmap.json", + "mixins": [ + + ], + + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file