From 63f8fd3068cb7a005c86d1821cb937b5a95a0c4a Mon Sep 17 00:00:00 2001 From: Griefed Date: Mon, 6 Nov 2023 16:40:01 +0100 Subject: [PATCH] Setup Forge and Fabric generation --- .github/workflows/build.yml | 57 ++++ README.md | 39 ++- build.gradle | 6 +- buildSrc/build.gradle | 21 ++ buildSrc/settings.gradle | 0 .../generation/BlockAndItemCodeGenerator.java | 46 +++ .../de/griefed/generation/CodeGeneration.java | 56 ++++ .../griefed/generation/CommonGeneration.java | 19 ++ .../griefed/generation/FabricGeneration.java | 145 +++++++++ .../griefed/generation/ForgeGeneration.java | 124 ++++++++ .../generation/ModloaderGeneration.java | 270 +++++++++++++++++ .../griefed/generation/StringTemplates.java | 276 ++++++++++++++++++ .../generation/blocks/BlockDefinition.java | 45 +++ .../blocks/BlockDefinitionParser.java | 24 ++ .../griefed/addemall}/CommonClass.java | 26 +- .../griefed/addemall}/Constants.java | 6 +- .../addemall}/mixin/MixinMinecraft.java | 5 +- .../griefed/addemall}/platform/Services.java | 6 +- .../platform/services/IPlatformHelper.java | 2 +- ...lemod.mixins.json => addemall.mixins.json} | 4 +- .../blockstates/tutorial_sand_block.json | 5 + .../blockstates/tutorial_stone_block.json | 5 + .../blockstates/tutorial_wool_block.json | 5 + .../resources/assets/addemall/lang/en_us.json | 17 ++ .../models/block/tutorial_sand_block.json | 6 + .../models/block/tutorial_stone_block.json | 6 + .../models/block/tutorial_wool_block.json | 6 + .../models/item/tutorial_sand_block.json | 3 + .../models/item/tutorial_stone_block.json | 3 + .../models/item/tutorial_wool_block.json | 3 + .../textures/block/tutorial_sand_block.png | Bin 0 -> 483 bytes .../textures/block/tutorial_stone_block.png | Bin 0 -> 482 bytes .../textures/block/tutorial_wool_block.png | Bin 0 -> 483 bytes definitions/assets/blocks/tutorial_sand.png | Bin 0 -> 483 bytes definitions/assets/blocks/tutorial_stone.png | Bin 0 -> 482 bytes definitions/assets/blocks/tutorial_wool.png | Bin 0 -> 483 bytes definitions/blocks.json | 32 ++ definitions/items.json | 0 fabric/build.gradle | 2 +- .../com/example/examplemod/ExampleMod.java | 18 -- .../de/griefed/addemall/AddEmAllFabric.java | 28 ++ .../de/griefed/addemall/block/ModBlocks.java | 58 ++++ .../de/griefed/addemall/item/ModItems.java | 38 +++ .../addemall}/mixin/MixinTitleScreen.java | 4 +- .../platform/FabricPlatformHelper.java | 4 +- ...amplemod.platform.services.IPlatformHelper | 1 - ...addemall.platform.services.IPlatformHelper | 1 + ...ixins.json => addemall.fabric.mixins.json} | 4 +- fabric/src/main/resources/fabric.mod.json | 2 +- .../com/example/examplemod/ExampleMod.java | 19 -- .../de/griefed/addemall/AddEmAllForge.java | 58 ++++ .../de/griefed/addemall/block/ModBlocks.java | 52 ++++ .../de/griefed/addemall/item/ModItems.java | 21 ++ .../addemall}/mixin/MixinTitleScreen.java | 4 +- .../platform/ForgePlatformHelper.java | 4 +- forge/src/main/resources/META-INF/mods.toml | 51 ++-- ...amplemod.platform.services.IPlatformHelper | 1 - ...addemall.platform.services.IPlatformHelper | 1 + ...mixins.json => addemall.forge.mixins.json} | 2 +- gradle.properties | 26 +- settings.gradle | 5 +- 61 files changed, 1549 insertions(+), 123 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 buildSrc/build.gradle create mode 100644 buildSrc/settings.gradle create mode 100644 buildSrc/src/main/java/de/griefed/generation/BlockAndItemCodeGenerator.java create mode 100644 buildSrc/src/main/java/de/griefed/generation/CodeGeneration.java create mode 100644 buildSrc/src/main/java/de/griefed/generation/CommonGeneration.java create mode 100644 buildSrc/src/main/java/de/griefed/generation/FabricGeneration.java create mode 100644 buildSrc/src/main/java/de/griefed/generation/ForgeGeneration.java create mode 100644 buildSrc/src/main/java/de/griefed/generation/ModloaderGeneration.java create mode 100644 buildSrc/src/main/java/de/griefed/generation/StringTemplates.java create mode 100644 buildSrc/src/main/java/de/griefed/generation/blocks/BlockDefinition.java create mode 100644 buildSrc/src/main/java/de/griefed/generation/blocks/BlockDefinitionParser.java rename common/src/main/java/{com/example/examplemod => de/griefed/addemall}/CommonClass.java (66%) rename common/src/main/java/{com/example/examplemod => de/griefed/addemall}/Constants.java (53%) rename common/src/main/java/{com/example/examplemod => de/griefed/addemall}/mixin/MixinMinecraft.java (81%) rename common/src/main/java/{com/example/examplemod => de/griefed/addemall}/platform/Services.java (91%) rename common/src/main/java/{com/example/examplemod => de/griefed/addemall}/platform/services/IPlatformHelper.java (94%) rename common/src/main/resources/{examplemod.mixins.json => addemall.mixins.json} (77%) create mode 100644 common/src/main/resources/assets/addemall/blockstates/tutorial_sand_block.json create mode 100644 common/src/main/resources/assets/addemall/blockstates/tutorial_stone_block.json create mode 100644 common/src/main/resources/assets/addemall/blockstates/tutorial_wool_block.json create mode 100644 common/src/main/resources/assets/addemall/lang/en_us.json create mode 100644 common/src/main/resources/assets/addemall/models/block/tutorial_sand_block.json create mode 100644 common/src/main/resources/assets/addemall/models/block/tutorial_stone_block.json create mode 100644 common/src/main/resources/assets/addemall/models/block/tutorial_wool_block.json create mode 100644 common/src/main/resources/assets/addemall/models/item/tutorial_sand_block.json create mode 100644 common/src/main/resources/assets/addemall/models/item/tutorial_stone_block.json create mode 100644 common/src/main/resources/assets/addemall/models/item/tutorial_wool_block.json create mode 100644 common/src/main/resources/assets/addemall/textures/block/tutorial_sand_block.png create mode 100644 common/src/main/resources/assets/addemall/textures/block/tutorial_stone_block.png create mode 100644 common/src/main/resources/assets/addemall/textures/block/tutorial_wool_block.png create mode 100644 definitions/assets/blocks/tutorial_sand.png create mode 100644 definitions/assets/blocks/tutorial_stone.png create mode 100644 definitions/assets/blocks/tutorial_wool.png create mode 100644 definitions/blocks.json create mode 100644 definitions/items.json delete mode 100644 fabric/src/main/java/com/example/examplemod/ExampleMod.java create mode 100644 fabric/src/main/java/de/griefed/addemall/AddEmAllFabric.java create mode 100644 fabric/src/main/java/de/griefed/addemall/block/ModBlocks.java create mode 100644 fabric/src/main/java/de/griefed/addemall/item/ModItems.java rename fabric/src/main/java/{com/example/examplemod => de/griefed/addemall}/mixin/MixinTitleScreen.java (89%) rename fabric/src/main/java/{com/example/examplemod => de/griefed/addemall}/platform/FabricPlatformHelper.java (81%) delete mode 100644 fabric/src/main/resources/META-INF/services/com.example.examplemod.platform.services.IPlatformHelper create mode 100644 fabric/src/main/resources/META-INF/services/de.griefed.addemall.platform.services.IPlatformHelper rename fabric/src/main/resources/{examplemod.fabric.mixins.json => addemall.fabric.mixins.json} (77%) delete mode 100644 forge/src/main/java/com/example/examplemod/ExampleMod.java create mode 100644 forge/src/main/java/de/griefed/addemall/AddEmAllForge.java create mode 100644 forge/src/main/java/de/griefed/addemall/block/ModBlocks.java create mode 100644 forge/src/main/java/de/griefed/addemall/item/ModItems.java rename forge/src/main/java/{com/example/examplemod => de/griefed/addemall}/mixin/MixinTitleScreen.java (89%) rename forge/src/main/java/{com/example/examplemod => de/griefed/addemall}/platform/ForgePlatformHelper.java (81%) delete mode 100644 forge/src/main/resources/META-INF/services/com.example.examplemod.platform.services.IPlatformHelper create mode 100644 forge/src/main/resources/META-INF/services/de.griefed.addemall.platform.services.IPlatformHelper rename forge/src/main/resources/{examplemod.forge.mixins.json => addemall.forge.mixins.json} (85%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c2f5cb5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,57 @@ +# This workflow will build a package using Gradle + +name: Check Builds For Errors + +on: [ pull_request, push ] + +jobs: + build: + continue-on-error: true + strategy: + matrix: + # Use these Java versions + java: [ 17 ] + # and run on both Linux and Windows + os: [ ubuntu-20.04, windows-latest ] + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Validate gradle wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v3 + with: + distribution: adopt + java-version: ${{ matrix.java }} + + - name: Make gradle wrapper executable + if: ${{ runner.os != 'Windows' }} + run: chmod +x ./gradlew + + - name: Build Fabric + run: ./gradlew :Fabric:build + - name: Capture Fabric build artifacts + uses: actions/upload-artifact@v3 + with: + name: Artifacts + path: Fabric/build/libs/ + + - name: Build Forge + run: ./gradlew :Forge:build + - name: Capture Forge build artifacts + uses: actions/upload-artifact@v3 + with: + name: Artifacts + path: Forge/build/libs/ + + - name: Build Quilt + run: ./gradlew :Quilt:build + - name: Capture Quilt build artifacts + uses: actions/upload-artifact@v3 + with: + name: Artifacts + path: Forge/build/libs/ diff --git a/README.md b/README.md index c4412ac..0de36d9 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,36 @@ -# MultiLoader Template +## AddEmAll -This project provides a Gradle project template that can compile mods for both Forge and Fabric using a common sourceset. This project does not require any third party libraries or dependencies. If you have any questions or want to discuss the project join our [Discord](https://discord.myceliummod.network). + + -## Getting Started +Assortment of blocks I want to use. + +## What does this mod do? + +This mod adds an assortment of blocks I would like to use in Minecraft. Mainly blocks inspired by the aesthetic of Half Life 2's Citadel, +as well as other things good for decorative purposes. + +## Other Information: + +- Report Bugs at https://github.com/Griefed/AddEmAll/issues +- You can include this mod in your modpack as long as you don't claim the mod as your own. + +# Development ## IntelliJ IDEA This guide will show how to import the MultiLoader Template into IntelliJ IDEA. The setup process is roughly equivalent to setting up Forge and Fabric independently and should be very familiar to anyone who has worked with their MDKs. 1. Clone or download this repository to your computer. -2. Configure the project by editing the `group`, `mod_name`, `mod_author`, and `mod_id` properties in the `gradle.properties` file. You will also need to change the `rootProject.name` property in `settings.gradle`, this should match the folder name of your project, or else IDEA may complain. -3. Open the template's root folder as a new project in IDEA. This is the folder that contains this README file and the gradlew executable. -4. If your default JVM/JDK is not Java 17 you will encounter an error when opening the project. This error is fixed by going to `File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM`and changing the value to a valid Java 17 JVM. You will also need to set the Project SDK to Java 17. This can be done by going to `File > Project Structure > Project SDK`. Once both have been set open the Gradle tab in IDEA and click the refresh button to reload the project. -5. Open the Gradle tab in IDEA if it has not already been opened. Navigate to `Your Project > Common > Tasks > vanilla gradle > decompile`. Run this task to decompile Minecraft. -6. Open the Gradle tab in IDEA if it has not already been opened. Navigate to `Your Project > Forge > Tasks > forgegradle runs > genIntellijRuns`. Run this task to set up run configurations for Forge. -7. Open your Run/Debug Configurations. Under the Application category there should now be options to run Forge and Fabric projects. Select one of the client options and try to run it. -8. Assuming you were able to run the game in step 7 your workspace should now be set up. - -### Eclipse -While it is possible to use this template in Eclipse it is not recommended. During the development of this template multiple critical bugs and quirks related to Eclipse were found at nearly every level of the required build tools. While we continue to work with these tools to report and resolve issues support for projects like these are not there yet. For now Eclipse is considered unsupported by this project. The development cycle for build tools is notoriously slow so there are no ETAs available. +2. Open the template's root folder as a new project in IDEA. This is the folder that contains this README file and the gradlew executable. +3. If your default JVM/JDK is not Java 17 you will encounter an error when opening the project. This error is fixed by going to `File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM`and changing the value to a valid Java 17 JVM. You will also need to set the Project SDK to Java 17. This can be done by going to `File > Project Structure > Project SDK`. Once both have been set open the Gradle tab in IDEA and click the refresh button to reload the project. +4. Open the Gradle tab in IDEA if it has not already been opened. Navigate to `Your Project > Common > Tasks > vanilla gradle > decompile`. Run this task to decompile Minecraft. +5. Open the Gradle tab in IDEA if it has not already been opened. Navigate to `Your Project > Forge > Tasks > forgegradle runs > genIntellijRuns`. Run this task to set up run configurations for Forge. +6. Open your Run/Debug Configurations. Under the Application category there should now be options to run Forge and Fabric projects. Select one of the client options and try to run it. +7. Assuming you were able to run the game in step 7 your workspace should now be set up. ## Development Guide When using this template the majority of your mod is developed in the Common project. The Common project is compiled against the vanilla game and is used to hold code that is shared between the different loader-specific versions of your mod. The Common project has no knowledge or access to ModLoader specific code, apis, or concepts. Code that requires something from a specific loader must be done through the project that is specific to that loader, such as the Forge or Fabric project. diff --git a/build.gradle b/build.gradle index 42f0d73..7c375b8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,14 @@ +import de.griefed.generation.BlockAndItemCodeGenerator + plugins { - id 'fabric-loom' version '1.2-SNAPSHOT' apply(false) + id 'fabric-loom' version '1.3-SNAPSHOT' apply(false) id 'net.minecraftforge.gradle' version '[6.0,6.2)' apply(false) id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' apply(false) id("org.spongepowered.mixin") version "0.7-SNAPSHOT" apply(false) } +apply plugin: BlockAndItemCodeGenerator + subprojects { apply plugin: 'java' diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 0000000..bff6923 --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,21 @@ +plugins { + id 'java' +} + +group = 'de.griefed' +version = '0.0.1' + +repositories { + mavenCentral() +} + +dependencies { + implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.3' + testImplementation platform('org.junit:junit-bom:5.9.1') + testImplementation 'org.junit.jupiter:junit-jupiter' +} + +test { + useJUnitPlatform() +} + diff --git a/buildSrc/settings.gradle b/buildSrc/settings.gradle new file mode 100644 index 0000000..e69de29 diff --git a/buildSrc/src/main/java/de/griefed/generation/BlockAndItemCodeGenerator.java b/buildSrc/src/main/java/de/griefed/generation/BlockAndItemCodeGenerator.java new file mode 100644 index 0000000..e532ba0 --- /dev/null +++ b/buildSrc/src/main/java/de/griefed/generation/BlockAndItemCodeGenerator.java @@ -0,0 +1,46 @@ +package de.griefed.generation; + +import com.fasterxml.jackson.core.json.JsonReadFeature; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import de.griefed.generation.blocks.BlockDefinitionParser; +import org.gradle.api.Plugin; +import org.gradle.api.Project; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Properties; + +/** + * Generates Forge, Fabric and Quilt block-implementations from block-definitions in a JSON-file.
+ * See definitions/blocks.json
+ * Take note that textures for blocks must be present in definitions/blocks and the name of the textures + * must match the ID of the block. + */ +public class BlockAndItemCodeGenerator implements Plugin { + private final ObjectMapper objectMapper = new ObjectMapper() + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY) + .enable(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature()); + + public void apply(Project project) { + project.getTasks().register("blockAndItemCodeGen", task -> task.doLast(s -> System.out.println("Hello from plugin " + this.getClass().getName()))); + try { + Properties gradleProperties = new Properties(); + gradleProperties.load(new FileInputStream(new File(project.getRootDir(),"gradle.properties"))); + String modName = gradleProperties.getProperty("mod_name"); + BlockDefinitionParser parser = new BlockDefinitionParser(project, objectMapper); + + CommonGeneration common = new CommonGeneration(project.findProject("common"), modName, parser, objectMapper); + FabricGeneration fabric = new FabricGeneration(project.findProject("fabric"), modName, parser, objectMapper); + ForgeGeneration forge = new ForgeGeneration(project.findProject("forge"), modName, parser, objectMapper); + + common.run(); + fabric.run(); + forge.run(); + } catch (IOException e) { + throw new RuntimeException("Error generating block and item code.", e); + } + } +} diff --git a/buildSrc/src/main/java/de/griefed/generation/CodeGeneration.java b/buildSrc/src/main/java/de/griefed/generation/CodeGeneration.java new file mode 100644 index 0000000..b6aba0f --- /dev/null +++ b/buildSrc/src/main/java/de/griefed/generation/CodeGeneration.java @@ -0,0 +1,56 @@ +package de.griefed.generation; + +import java.io.IOException; + +public interface CodeGeneration { + + void run() throws IOException; + + /** + * Create the ModBlocks-class inside the your.group.modid.block-package. + * Depending on the modloader, the template from which this class is generated differs. + * The functionality stays the same: The generated class allows for registering all custom blocks defined in + * the definitions/blocks.json-file.
+ * Do not manually edit the generated file! + * @throws IOException when the file could not be created or edited. + */ + void createModBlocksClass() throws IOException; + + /** + * Create the ModItems-class inside the your.group.modid.item-package. + * Depending on the modloader, the template from which this class is generated differs. + * The functionality stays the same: The generated class allows for registering all custom items defined in + * the definitions/items.json-file, as well as all items for any blocks defined in the + * definitions/blocks.json-file. + * @throws IOException when the file could not be created or edited. + */ + void createModItemsClass() throws IOException; + + /** + * Create the modloader main-class housing the registration events, making sure that all blocks and items + * actually get registered. The class gets created inside the your.group.modid-package. + * @throws IOException when the file could not be created or edited. + */ + void createModloaderClass() throws IOException; + + /** + * Update the ModBlocks-class to register all defined blocks. + * @throws IOException when the file could not be created or edited. + */ + void updateModBlocksClass() throws IOException; + + /** + * Update the ModItems-class to register all defined blocks and items. + * @throws IOException when the file could not be created or edited. + */ + void updateModItemsClass() throws IOException; + + /** + * Updates the modloaders main-class, more specifically the area inside said class which is reserved for updates + * by this method. The generated code will ensure that all mods registered in the ModBlocks-class will get added + * to the game by the respective modloader. + * @throws IOException when the file could not be created or edited. + */ + void updateModloaderMain() throws IOException; + +} diff --git a/buildSrc/src/main/java/de/griefed/generation/CommonGeneration.java b/buildSrc/src/main/java/de/griefed/generation/CommonGeneration.java new file mode 100644 index 0000000..be4fe3c --- /dev/null +++ b/buildSrc/src/main/java/de/griefed/generation/CommonGeneration.java @@ -0,0 +1,19 @@ +package de.griefed.generation; + +import com.fasterxml.jackson.databind.ObjectMapper; +import de.griefed.generation.blocks.BlockDefinitionParser; +import org.gradle.api.Project; + +import java.io.IOException; + +public class CommonGeneration extends ModloaderGeneration { + protected CommonGeneration(Project project, String modName, BlockDefinitionParser parser, ObjectMapper objectMapper) { + super(project, modName, parser, objectMapper); + } + + public void run() throws IOException { + updateTranslations(); + createBlockFiles(); + createItemFiles(); + } +} diff --git a/buildSrc/src/main/java/de/griefed/generation/FabricGeneration.java b/buildSrc/src/main/java/de/griefed/generation/FabricGeneration.java new file mode 100644 index 0000000..6eb7314 --- /dev/null +++ b/buildSrc/src/main/java/de/griefed/generation/FabricGeneration.java @@ -0,0 +1,145 @@ +package de.griefed.generation; + +import com.fasterxml.jackson.databind.ObjectMapper; +import de.griefed.generation.blocks.BlockDefinition; +import de.griefed.generation.blocks.BlockDefinitionParser; +import org.gradle.api.Project; + +import java.io.IOException; +import java.util.regex.Pattern; + +public class FabricGeneration extends ModloaderGeneration implements CodeGeneration { + + public static final Pattern ADD_CODE_REPLACE = Pattern.compile("/\\*###GENERATED ADD CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###\\*/.*/\\*###GENERATED ADD CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###\\*/", Pattern.DOTALL); + + public FabricGeneration(Project project, String modName, BlockDefinitionParser parser, ObjectMapper objectMapper) { + super(project, modName, parser, objectMapper); + } + + private final String modBlockClassTemplate = StringTemplates.FABRIC_MOD_BLOCK_CLASS + .replace("GROUP", getGroup()) + .replace("MODLOADERCLASS", getModloaderClass().getName().replace(".java", "")); + + private final String modItemsClassTemplate = StringTemplates.FABRIC_MOD_ITEMS_CLASS + .replace("GROUP", getGroup()) + .replace("MODLOADERCLASS", getModloaderClass().getName().replace(".java", "")); + + private final String modloaderClassTemplate = StringTemplates.FABRIC_MODLOADER_CLASS + .replace("GROUP", getGroup()) + .replace("MODNAME", getModName()) + .replace("SUBNAME", getSubName()) + .replace("MODID", getId()); + + @Override + public void run() throws IOException { + createModBlockPackage(); + createItemPackage(); + createModBlocksClass(); + createModItemsClass(); + createModloaderClass(); + updateModBlocksClass(); + updateModItemsClass(); + updateModloaderMain(); + } + + @Override + public void createModBlocksClass() throws IOException { + if (!getModBlocksClass().exists() && getModBlocksClass().createNewFile()) { + System.out.println("ModBlock-class created: " + getModBlocksClass().getAbsolutePath()); + writeToFile(getModBlocksClass(), modBlockClassTemplate); + } + } + + @Override + public void createModItemsClass() throws IOException { + if (!getModItemsClass().exists() && getModItemsClass().createNewFile()) { + System.out.println("ModItems-class created: " + getModItemsClass().getAbsolutePath()); + writeToFile(getModItemsClass(), modItemsClassTemplate); + } + } + + @Override + public void createModloaderClass() throws IOException { + if (!getModloaderClass().exists() && getModloaderClass().createNewFile()) { + System.out.println("ModItems-class created: " + getModloaderClass().getAbsolutePath()); + writeToFile(getModloaderClass(), modloaderClassTemplate); + } + } + + /* + public static final Block TANZANITE_BLOCK = registerBlock("tanzanite_block", + new Block(FabricBlockSettings.of(Material.METAL).strength(4f).requiresTool()), ItemGroups.BUILDING_BLOCKS); + */ + + @Override + public void updateModBlocksClass() throws IOException { + String modBlocks = readFromFile(getModBlocksClass()); + StringBuilder blocks = new StringBuilder(); + StringBuilder registration; + for (BlockDefinition block : getBlockDefinitionParser().getBlocks()) { + registration = new StringBuilder(); + registration.append("\n\tpublic static final Block ").append(block.getId().toUpperCase()).append("_BLOCK = registerBlock(\"").append(block.getId()).append("_block\",\n") + .append("\t\t\tnew Block(FabricBlockSettings.of(Material.").append(block.getMaterial()).append(").strength(").append(block.getStrength()).append("f).luminance(").append(block.getLightLevel()).append(")\n") + .append("\t\t\t\t\t.hardness(").append(block.getExplosionResistance()).append(")"); + if (block.isRequiresCorrectTool()) { + registration.append(".requiresTool()"); + } + if (block.isInstabreak()) { + registration.append(".breakInstantly()"); + } + registration.append("\n\t\t\t\t\t), ItemGroups.BUILDING_BLOCKS);\n"); + blocks.append(registration); + } + modBlocks = CODE_REPLACE + .matcher(modBlocks) + .replaceAll("/*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/" + + blocks + + "\t/*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/"); + writeToFile(getModBlocksClass(), modBlocks); + } + + @Override + public void updateModItemsClass() throws IOException { + String modItems = readFromFile(getModItemsClass()); + StringBuilder items = new StringBuilder(); + StringBuilder itemsAdd = new StringBuilder(); + StringBuilder registration; + StringBuilder add; + /*for (ItemDefinition item : getItemDefinitionParser().getItems()) { + //registration + registration = new StringBuilder(); + registration.append("\n\tpublic static final Item ").append(item.getId().toUpperCase()).append(" = registerItem(\"").append(item.getId()).append("\",\n") + .append("\t\t\tnew Item(new FabricItemSettings()));"); + registration.append("\n"); + items.append(registration); + //add + add = new StringBuilder(); + add.append("\t\t\taddToItemGroup(ItemGroups.").append(item.getItemGroup()).append(", ").append(item.getId().toUpperCase()).append(");\n"); + itemsAdd.append(add); + }*/ + modItems = CODE_REPLACE + .matcher(modItems) + .replaceAll("/*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/\n\n" + + items + + "\t/*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/"); + modItems = ADD_CODE_REPLACE + .matcher(modItems) + .replaceAll("/*###GENERATED ADD CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST*/\n\n" + + itemsAdd + + "\t\t/*###GENERATED ADD CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST*/"); + writeToFile(getModItemsClass(), modItems); + } + + @Override + public void updateModloaderMain() throws IOException { + String modloaderMain = readFromFile(getModloaderClass()); + modloaderMain = CODE_REPLACE + .matcher(modloaderMain) + .replaceAll(""" + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + \t\tModItems.registerModItems(); + \t\tModBlocks.registerModBlocks(); + \t\t/*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/"""); + writeToFile(getModloaderClass(), modloaderMain); + } +} diff --git a/buildSrc/src/main/java/de/griefed/generation/ForgeGeneration.java b/buildSrc/src/main/java/de/griefed/generation/ForgeGeneration.java new file mode 100644 index 0000000..a140d4d --- /dev/null +++ b/buildSrc/src/main/java/de/griefed/generation/ForgeGeneration.java @@ -0,0 +1,124 @@ +package de.griefed.generation; + +import com.fasterxml.jackson.databind.ObjectMapper; +import de.griefed.generation.blocks.BlockDefinition; +import de.griefed.generation.blocks.BlockDefinitionParser; +import org.gradle.api.Project; + +import java.io.IOException; + +public class ForgeGeneration extends ModloaderGeneration implements CodeGeneration { + public ForgeGeneration(Project project, String modName, BlockDefinitionParser parser, ObjectMapper objectMapper) { + super(project, modName, parser, objectMapper); + } + + private final String modBlockClassTemplate = StringTemplates.FORGE_MOD_BLOCK_CLASS + .replace("GROUP", getGroup()) + .replace("MODLOADERCLASS", getModloaderClass().getName().replace(".java", "")); + + private final String modItemsClassTemplate = StringTemplates.FORGE_MOD_ITEMS_CLASS + .replace("GROUP", getGroup()) + .replace("MODLOADERCLASS", getModloaderClass().getName().replace(".java", "")); + + private final String modloaderClassTemplate = StringTemplates.FORGE_MODLOADER_CLASS + .replace("GROUP", getGroup()) + .replace("MODNAME", getModName()) + .replace("SUBNAME", getSubName()) + .replace("MODID", getId()); + + @Override + public void run() throws IOException { + createModBlockPackage(); + createItemPackage(); + createModBlocksClass(); + createModItemsClass(); + createModloaderClass(); + updateModBlocksClass(); + updateModItemsClass(); + updateModloaderMain(); + } + + @Override + public void createModBlocksClass() throws IOException { + if (!getModBlocksClass().exists() && getModBlocksClass().createNewFile()) { + System.out.println("ModBlock-class created: " + getModBlocksClass().getAbsolutePath()); + writeToFile(getModBlocksClass(), modBlockClassTemplate); + } + } + + @Override + public void createModItemsClass() throws IOException { + if (!getModItemsClass().exists() && getModItemsClass().createNewFile()) { + System.out.println("ModItems-class created: " + getModItemsClass().getAbsolutePath()); + writeToFile(getModItemsClass(), modItemsClassTemplate); + } + } + + @Override + public void createModloaderClass() throws IOException { + if (!getModloaderClass().exists() && getModloaderClass().createNewFile()) { + System.out.println("ModItems-class created: " + getModloaderClass().getAbsolutePath()); + writeToFile(getModloaderClass(), modloaderClassTemplate); + } + } + + @Override + public void updateModBlocksClass() throws IOException { + String modBlocks = readFromFile(getModBlocksClass()); + StringBuilder blocks = new StringBuilder(); + StringBuilder registration; + for (BlockDefinition block : getBlockDefinitionParser().getBlocks()) { + registration = new StringBuilder(); + registration.append("\n\tpublic static final RegistryObject ").append(block.getId().toUpperCase()).append("_BLOCK = registerBlock(\"").append(block.getId()).append("_block\",\n") + .append("\t\t\t() -> new Block(BlockBehaviour.Properties.of(Material.").append(block.getMaterial()).append(")\n") + .append("\t\t\t\t\t.strength(").append(block.getStrength()).append("f).lightLevel(state -> ").append(block.getLightLevel()).append(")").append(".explosionResistance(").append(block.getExplosionResistance()).append("f)\n\t\t\t\t\t"); + if (block.isRequiresCorrectTool()) { + registration.append(".requiresCorrectToolForDrops()"); + } + if (block.isInstabreak()) { + registration.append(".instabreak()"); + } + registration.append("), CreativeModeTab.TAB_BUILDING_BLOCKS);\n"); + blocks.append(registration); + } + modBlocks = CODE_REPLACE + .matcher(modBlocks) + .replaceAll("/*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/" + + blocks + + "\t/*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/"); + writeToFile(getModBlocksClass(), modBlocks); + } + + @Override + public void updateModItemsClass() throws IOException { + String modItems = readFromFile(getModItemsClass()); + StringBuilder items = new StringBuilder(); + StringBuilder registration; + /*for (ItemDefinition item : getItemDefinitionParser().getItems()) { + registration = new StringBuilder(); + registration.append("\n\tpublic static final RegistryObject ").append(item.getId().toUpperCase()).append(" = ITEMS.register(\"").append(item.getId()).append("\",\n") + .append("\t\t\t() -> new Item(new Item.Properties()));"); + registration.append("\n"); + items.append(registration); + }*/ + modItems = CODE_REPLACE + .matcher(modItems) + .replaceAll("/*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/\n\n" + + items + + "\t/*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/"); + writeToFile(getModItemsClass(), modItems); + } + + @Override + public void updateModloaderMain() throws IOException { + String modloaderMain = readFromFile(getModloaderClass()); + modloaderMain = CODE_REPLACE + .matcher(modloaderMain) + .replaceAll(""" + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + \t\tModItems.register(modEventBus); + \t\tModBlocks.register(modEventBus); + \t\t/*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/"""); + writeToFile(getModloaderClass(), modloaderMain); + } +} diff --git a/buildSrc/src/main/java/de/griefed/generation/ModloaderGeneration.java b/buildSrc/src/main/java/de/griefed/generation/ModloaderGeneration.java new file mode 100644 index 0000000..811321c --- /dev/null +++ b/buildSrc/src/main/java/de/griefed/generation/ModloaderGeneration.java @@ -0,0 +1,270 @@ +package de.griefed.generation; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import de.griefed.generation.blocks.BlockDefinition; +import de.griefed.generation.blocks.BlockDefinitionParser; +import org.gradle.api.Project; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; +import java.util.regex.Pattern; + +public abstract class ModloaderGeneration { + + public static final Pattern CODE_REPLACE = Pattern.compile("/\\*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###\\*/.*/\\*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###\\*/", Pattern.DOTALL); + public static final Pattern LANG_REPLACE = Pattern.compile("\"DO\\.NOT\\.EDIT\\.MANUALLY\\.BEGIN\": \"BEGIN\".*\"DO\\.NOT\\.EDIT\\.MANUALLY\\.END\": \"END\"", Pattern.DOTALL); + + private final Project project; + private final String modName; + private final String subName; + private final BlockDefinitionParser blockDefinitionParser; + private final ObjectMapper objectMapper; + + private final String group; + private final File groupDirectory; + private final String modloader; + private final String id; + private final File modBlocksClass; + private final File modItemsClass; + private final File blocksGroup; + private final File itemGroup; + private final File modloaderClass; + private final File assetsDirectory; + private final File translationsFile; + + protected ModloaderGeneration(Project project, String modName, BlockDefinitionParser parser, ObjectMapper objectMapper) { + this.project = project; + this.blockDefinitionParser = parser; + this.modName = modName; + this.subName = modName + project.getName().substring(0,1).toUpperCase() + project.getName().substring(1); + this.objectMapper = objectMapper; + + this.group = project.getGroup().toString(); + this.groupDirectory = new File(project.getProjectDir(), "src/main/java/" + group.replace(".", "/")); + this.modloader = project.getName(); + this.id = group.substring(group.lastIndexOf(".") + 1); + this.blocksGroup = new File(groupDirectory, "block"); + this.modBlocksClass = new File(blocksGroup, "ModBlocks.java"); + this.itemGroup = new File(groupDirectory, "item"); + this.modItemsClass = new File(itemGroup, "ModItems.java"); + this.modloaderClass = new File(groupDirectory, subName + ".java"); + this.assetsDirectory = new File(project.getProjectDir(),"src/main/resources/assets/" + id); + this.translationsFile = new File(assetsDirectory, "lang/en_us.json"); + } + + /** + * Create the your.group.modid.block-package + */ + protected void createModBlockPackage() { + if (!blocksGroup.exists() && blocksGroup.mkdirs()) { + System.out.println("Group-directory created " + blocksGroup.getAbsolutePath()); + } + } + + /** + * Create the your.group.modid.item-package + */ + protected void createItemPackage() { + if (!itemGroup.exists() && itemGroup.mkdirs()) { + System.out.println("Item-directory created: " + itemGroup.getAbsolutePath()); + } + } + + public void writeToFile(File file, String text) throws IOException { + try (FileWriter fileWriter = new FileWriter(file)) { + BufferedWriter bufferedWriter = new BufferedWriter(fileWriter); + bufferedWriter.write(text); + bufferedWriter.close(); + } + } + + public String readFromFile(File file) throws IOException { + StringBuilder sb = new StringBuilder(); + try(BufferedReader br = new BufferedReader(new FileReader(file))) { + String line = br.readLine(); + while (line != null) { + sb.append(line); + sb.append(System.lineSeparator()); + line = br.readLine(); + } + } + return sb.toString(); + + } + + /** + * Create all translations required for our blocks and items to work. + * @throws IOException when the file could not be created or edited. + */ + protected void updateTranslations() throws IOException { + if (!translationsFile.exists() && translationsFile.getParentFile().mkdirs() && translationsFile.createNewFile()) { + writeToFile( + translationsFile, + StringTemplates.TRANSLATION.replace("GENERATED_TRANSLATION_CODE",buildTranslationText()) + ); + } else { + String translations = readFromFile(getTranslationsFile()); + if (translations.contains("\"DO.NOT.EDIT.MANUALLY.BEGIN\": \"BEGIN\",") && translations.contains("\"DO.NOT.EDIT.MANUALLY.END\": \"END\"")) { + //translations file from our generation + translations = LANG_REPLACE + .matcher(translations) + .replaceAll("\"DO.NOT.EDIT.MANUALLY.BEGIN\": \"BEGIN\",\n" + + buildTranslationText() + "\n" + + "\"DO.NOT.EDIT.MANUALLY.END\": \"END\""); + writeToFile(this.translationsFile,translations); + } else { + //translations not from our generation, add our block + ObjectNode translationNode = (ObjectNode) objectMapper.readTree(this.translationsFile); + String itemPrefix = "\"item." + id + "."; + String blockPrefix = "\"block." + id + "."; + translationNode.put("DO.NOT.EDIT.MANUALLY.BEGIN","BEGIN"); + for (BlockDefinition block : blockDefinitionParser.getBlocks()) { + translationNode.put(itemPrefix + block.getId() + "_block", block.getTranslation()); + translationNode.put(blockPrefix + block.getId() + "_block", block.getTranslation()); + } + translationNode.put("DO.NOT.EDIT.MANUALLY.END", "END"); + objectMapper.writeValue(this.translationsFile, translationNode); + } + } + } + + private String buildTranslationText() { + StringBuilder translations = new StringBuilder(); + String itemPrefix = "\"item." + id + "."; + String blockPrefix = "\"block." + id + "."; + for (BlockDefinition block : blockDefinitionParser.getBlocks()) { + //add item + //key + translations.append("\n").append(itemPrefix).append(block.getId()).append("_block").append("\":"); + //value + translations.append(" \"").append(block.getTranslation()).append("\",\n"); + //add block + //key + translations.append("\n").append(blockPrefix).append(block.getId()).append("_block").append("\":"); + //value + translations.append(" \"").append(block.getTranslation()).append("\",\n"); + } + return translations.toString(); + } + + /** + * Create all files required for the added blocks to work.
+ * @throws IOException when the file could not be created or edited. + */ + public void createBlockFiles() throws IOException { + File blockstatesDir = new File(assetsDirectory, "blockstates"); + File blockModelsDir = new File(assetsDirectory, "models/block"); + File itemModelsDir = new File(assetsDirectory, "models/item"); + File itemTexturesDir = new File(assetsDirectory, "textures/item"); + File blockTexturesDir = new File(assetsDirectory, "textures/block"); + blockstatesDir.mkdirs(); + blockModelsDir.mkdirs(); + itemModelsDir.mkdirs(); + itemTexturesDir.mkdirs(); + blockTexturesDir.mkdirs(); + String blockstatesTemp = "BLOCKID_block.json"; + String blockModelTemp = "BLOCKID_block.json"; + String itemBlockModelTemp = "BLOCKID_block.json"; + String blockTextureTemp = "BLOCKID_block.png"; + File blockstate; + File blockModel; + File itemBlockModel; + File blockTexture; + File textureSource; + for (BlockDefinition block : blockDefinitionParser.getBlocks()) { + //blockstate + blockstate = new File(blockstatesDir, blockstatesTemp.replace("BLOCKID", block.getId())); + writeToFile(blockstate, StringTemplates.BLOCKSTATE.replace("MODID", id).replace("BLOCKID", block.getId())); + //block model + blockModel = new File(blockModelsDir, blockModelTemp.replace("BLOCKID", block.getId())); + writeToFile(blockModel, StringTemplates.BLOCK_MODELS.replace("MODID", id).replace("BLOCKID", block.getId())); + //item block model + itemBlockModel = new File(itemModelsDir, itemBlockModelTemp.replace("BLOCKID", block.getId())); + writeToFile(itemBlockModel, StringTemplates.BLOCK_MODELS_ITEM.replace("MODID", id).replace("BLOCKID", block.getId())); + //block texture + blockTexture = new File(blockTexturesDir, blockTextureTemp.replace("BLOCKID", block.getId())); + textureSource = new File(blockDefinitionParser.getAssetsDirectory(), block.getId() + ".png"); + Files.copy(textureSource.toPath(), blockTexture.toPath(), StandardCopyOption.REPLACE_EXISTING); + } + } + + /** + * Create all files required for the added items to work.
+ * Depending on the modloader, this creates various json-files inside the resources/assets-directory. + * @throws IOException when the file could not be created or edited. + */ + public void createItemFiles() throws IOException { + /*File itemModelsDir = new File(getAssetsDirectory(), "models/item"); + String itemModelTemp = "BLOCKID.json"; + File itemModel; + for (ItemDefinition item : getItemDefinitionParser().getItems()) { + //item model + itemModel = new File(itemModelsDir, itemModelTemp.replace("BLOCKID", block.getId())); + writeToFile(itemModel, StringTemplates.FORGE_MODELS_ITEM.replace("MODID", getId()).replace("BLOCKID", block.getId())); + }*/ + } + + public Project getProject() { + return project; + } + + public String getModName() { + return modName; + } + + public String getSubName() { + return subName; + } + + public BlockDefinitionParser getBlockDefinitionParser() { + return blockDefinitionParser; + } + + public ObjectMapper getObjectMapper() { + return objectMapper; + } + + public String getGroup() { + return group; + } + + public File getGroupDirectory() { + return groupDirectory; + } + + public String getModloader() { + return modloader; + } + + public String getId() { + return id; + } + + public File getModBlocksClass() { + return modBlocksClass; + } + + public File getModItemsClass() { + return modItemsClass; + } + + public File getBlocksGroup() { + return blocksGroup; + } + + public File getItemGroup() { + return itemGroup; + } + + public File getModloaderClass() { + return modloaderClass; + } + + public File getAssetsDirectory() { return assetsDirectory; } + + public File getTranslationsFile() { + return translationsFile; + } +} diff --git a/buildSrc/src/main/java/de/griefed/generation/StringTemplates.java b/buildSrc/src/main/java/de/griefed/generation/StringTemplates.java new file mode 100644 index 0000000..3d7e8a7 --- /dev/null +++ b/buildSrc/src/main/java/de/griefed/generation/StringTemplates.java @@ -0,0 +1,276 @@ +package de.griefed.generation; + +public class StringTemplates { + public static final String FORGE_MOD_BLOCK_CLASS = """ + package GROUP.block; + + import GROUP.MODLOADERCLASS; + import GROUP.item.ModItems; + 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.state.BlockBehaviour; + import net.minecraft.world.level.material.Material; + import net.minecraftforge.eventbus.api.IEventBus; + import net.minecraftforge.registries.DeferredRegister; + import net.minecraftforge.registries.ForgeRegistries; + import net.minecraftforge.registries.RegistryObject; + + import java.util.function.Supplier; + + public class ModBlocks { + public static final DeferredRegister BLOCKS = + DeferredRegister.create(ForgeRegistries.BLOCKS, MODLOADERCLASS.MOD_ID); + + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + GENERATED_BLOCKS_CODE + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + + private static RegistryObject registerBlock(String name, Supplier block, CreativeModeTab tab) { + RegistryObject toReturn = BLOCKS.register(name, block); + registerBlockItem(name, toReturn, tab); + return toReturn; + } + + private static RegistryObject registerBlockItem(String name, RegistryObject block, CreativeModeTab tab) { + return ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties().tab(tab))); + } + + public static void register(IEventBus eventBus) { + BLOCKS.register(eventBus); + } + } + """; + + public static final String FORGE_MOD_ITEMS_CLASS = """ + package GROUP.item; + + import GROUP.MODLOADERCLASS; + import net.minecraft.world.item.Item; + import net.minecraftforge.eventbus.api.IEventBus; + import net.minecraftforge.registries.DeferredRegister; + import net.minecraftforge.registries.ForgeRegistries; + import net.minecraftforge.registries.RegistryObject; + + public class ModItems { + public static final DeferredRegister ITEMS = + DeferredRegister.create(ForgeRegistries.ITEMS, MODLOADERCLASS.MOD_ID); + + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + GENERATED_ITEMS_CODE + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + + public static void register(IEventBus eventBus) { + ITEMS.register(eventBus); + } + } + """; + + public static final String FORGE_MODLOADER_CLASS = """ + package GROUP; + + import com.mojang.logging.LogUtils; + import GROUP.block.ModBlocks; + import GROUP.item.ModItems; + import net.minecraftforge.common.MinecraftForge; + import net.minecraftforge.eventbus.api.IEventBus; + import net.minecraftforge.eventbus.api.SubscribeEvent; + import net.minecraftforge.event.entity.player.ItemTooltipEvent; + import net.minecraftforge.fml.common.Mod; + import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; + import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; + import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; + import org.slf4j.Logger; + + // The value here should match an entry in the META-INF/mods.toml file + @Mod(Constants.MOD_ID) + public class SUBNAME { + public static final String MOD_ID = "MODID"; + private static final Logger LOGGER = LogUtils.getLogger(); + + // Very Important Comment + public SUBNAME() { + // Use Forge to bootstrap the Common mod. + Constants.LOG.info("Hello world!"); + LOGGER.info("Hello Forge World!"); + CommonClass.init(); + + IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + GENERATED_CONSTRUCTOR_CODE + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + + modEventBus.addListener(this::commonSetup); + + MinecraftForge.EVENT_BUS.register(this); + MinecraftForge.EVENT_BUS.addListener(this::onItemTooltip); + } + + private void commonSetup(final FMLCommonSetupEvent event) { + + } + + // You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent + @Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) + public static class ClientModEvents { + @SubscribeEvent + public static void onClientSetup(FMLClientSetupEvent event) { + + } + } + + private void onItemTooltip(ItemTooltipEvent event) { + CommonClass.onItemTooltip(event.getItemStack(), event.getFlags(), event.getToolTip()); + } + } + """; + + public static final String BLOCKSTATE = """ + { + "variants": { + "": { "model": "MODID:block/BLOCKID_block" } + } + } + """; + + public static final String BLOCK_MODELS = """ + { + "parent": "block/cube_all", + "textures": { + "all": "MODID:block/BLOCKID_block" + } + } + """; + + public static final String BLOCK_MODELS_ITEM = """ + { + "parent": "MODID:block/BLOCKID_block" + } + """; + + public static final String TRANSLATION = """ + { + "DO.NOT.EDIT.MANUALLY.BEGIN": "BEGIN", + GENERATED_TRANSLATION_CODE + "DO.NOT.EDIT.MANUALLY.END": "END" + } + """; + + public static final String FABRIC_MOD_BLOCK_CLASS = """ + package GROUP.block; + + import net.fabricmc.fabric.api.item.v1.FabricItemSettings; + import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; + import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; + import GROUP.MODLOADERCLASS; + import net.minecraft.block.Block; + import net.minecraft.block.Material; + import net.minecraft.item.BlockItem; + import net.minecraft.item.Item; + import net.minecraft.item.ItemGroup; + import net.minecraft.item.ItemGroups; + import net.minecraft.registry.Registries; + import net.minecraft.registry.Registry; + import net.minecraft.util.Identifier; + + public class ModBlocks { + + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + GENERATED_BLOCKS_CODE + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + + private static Block registerBlockWithoutItem(String name, Block block) { + return Registry.register(Registries.BLOCK, new Identifier(MODLOADERCLASS.MOD_ID, name), block); + } + + private static Block registerBlock(String name, Block block, ItemGroup tab) { + registerBlockItem(name, block, tab); + return Registry.register(Registries.BLOCK, new Identifier(MODLOADERCLASS.MOD_ID, name), block); + } + + private static Item registerBlockItem(String name, Block block, ItemGroup tab) { + Item item = Registry.register(Registries.ITEM, new Identifier(MODLOADERCLASS.MOD_ID, name), + new BlockItem(block, new FabricItemSettings())); + ItemGroupEvents.modifyEntriesEvent(tab).register(entries -> entries.add(item)); + return item; + } + + public static void registerModBlocks() { + MODLOADERCLASS.LOGGER.debug("Registering ModBlocks for " + MODLOADERCLASS.MOD_ID); + } + } + """; + + public static final String FABRIC_MOD_ITEMS_CLASS = """ + package GROUP.item; + + import net.fabricmc.fabric.api.item.v1.FabricItemSettings; + import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; + import GROUP.MODLOADERCLASS; + import net.minecraft.item.Item; + import net.minecraft.item.ItemGroup; + import net.minecraft.item.ItemGroups; + import net.minecraft.registry.Registries; + import net.minecraft.registry.Registry; + import net.minecraft.util.Identifier; + + public class ModItems { + + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + GENERATED_ITEMS_CODE + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + + private static Item registerItem(String name, Item item) { + return Registry.register(Registries.ITEM, new Identifier(MODLOADERCLASS.MOD_ID, name), item); + } + + public static void addItemsToItemGroups() { + /*###GENERATED ADD CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + GENERATED_ITEMS_ADD_CODE + /*###GENERATED ADD CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + } + + public static void addToItemGroup(ItemGroup group, Item item) { + ItemGroupEvents.modifyEntriesEvent(group).register(entries -> entries.add(item)); + } + + public static void registerModItems() { + TutorialMod.LOGGER.debug("Registering Mod Items for " + TutorialMod.MOD_ID); + + addItemsToItemGroups(); + } + } + """; + + public static final String FABRIC_MODLOADER_CLASS = """ + package GROUP; + + import net.fabricmc.api.ModInitializer; + import GROUP.block.ModBlocks; + import GROUP.item.ModItems; + import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback; + import org.slf4j.Logger; + import org.slf4j.LoggerFactory; + + // Very important comment + public class SUBNAME implements ModInitializer { + public static final String MOD_ID = "MODID"; + public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); + + @Override + public void onInitialize() { + Constants.LOG.info("Hello world!"); + LOGGER.info("Hello Fabric World!"); + CommonClass.init(); + + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + GENERATED_ITEMS_CODE + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + + ItemTooltipCallback.EVENT.register(CommonClass::onItemTooltip); + } + } + """; +} diff --git a/buildSrc/src/main/java/de/griefed/generation/blocks/BlockDefinition.java b/buildSrc/src/main/java/de/griefed/generation/blocks/BlockDefinition.java new file mode 100644 index 0000000..1370a76 --- /dev/null +++ b/buildSrc/src/main/java/de/griefed/generation/blocks/BlockDefinition.java @@ -0,0 +1,45 @@ +package de.griefed.generation.blocks; + +public class BlockDefinition { + + private String id; + private String translation; + private String material; + private int strength; + private int lightLevel; + private int explosionResistance; + private boolean requiresCorrectTool; + private boolean instabreak; + + public String getId() { + return id; + } + + public String getTranslation() { + return translation; + } + + public String getMaterial() { + return material; + } + + public int getStrength() { + return strength; + } + + public int getLightLevel() { + return lightLevel; + } + + public int getExplosionResistance() { + return explosionResistance; + } + + public boolean isRequiresCorrectTool() { + return requiresCorrectTool; + } + + public boolean isInstabreak() { + return instabreak; + } +} diff --git a/buildSrc/src/main/java/de/griefed/generation/blocks/BlockDefinitionParser.java b/buildSrc/src/main/java/de/griefed/generation/blocks/BlockDefinitionParser.java new file mode 100644 index 0000000..fa6f373 --- /dev/null +++ b/buildSrc/src/main/java/de/griefed/generation/blocks/BlockDefinitionParser.java @@ -0,0 +1,24 @@ +package de.griefed.generation.blocks; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.gradle.api.Project; + +import java.io.File; +import java.io.IOException; + +public class BlockDefinitionParser { + + private final BlockDefinition[] definitions; + private final File assetsDirectory; + + public BlockDefinitionParser(Project project, ObjectMapper objectMapper) throws IOException { + this.definitions = objectMapper.readValue(new File(project.getRootDir(), "definitions/blocks.json"), BlockDefinition[].class); + this.assetsDirectory = new File(project.getRootDir(),"definitions/assets/blocks"); + } + + public BlockDefinition[] getBlocks() { + return definitions; + } + + public File getAssetsDirectory() { return assetsDirectory; } +} diff --git a/common/src/main/java/com/example/examplemod/CommonClass.java b/common/src/main/java/de/griefed/addemall/CommonClass.java similarity index 66% rename from common/src/main/java/com/example/examplemod/CommonClass.java rename to common/src/main/java/de/griefed/addemall/CommonClass.java index 7cd816f..99da086 100644 --- a/common/src/main/java/com/example/examplemod/CommonClass.java +++ b/common/src/main/java/de/griefed/addemall/CommonClass.java @@ -1,8 +1,13 @@ -package com.example.examplemod; +package de.griefed.addemall; -import com.example.examplemod.platform.Services; -import net.minecraft.core.registries.BuiltInRegistries; +import de.griefed.addemall.platform.Services; +import net.minecraft.network.chat.Component; +import net.minecraft.world.food.FoodProperties; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.item.TooltipFlag; + +import java.util.List; // This class is part of the common project meaning it is shared between all supported loaders. Code written here can only // import and access the vanilla codebase, libraries used by vanilla, and optionally third party libraries that provide @@ -23,9 +28,20 @@ public static void init() { // your own abstraction layer. You can learn more about this in our provided services class. In this example // we have an interface in the common code and use a loader specific implementation to delegate our call to // the platform specific approach. - if (Services.PLATFORM.isModLoaded("examplemod")) { + if (Services.PLATFORM.isModLoaded("addemall")) { + + Constants.LOG.info("Hello to addemall"); + } + } + + public static void onItemTooltip(ItemStack stack, TooltipFlag context, List tooltip) { + if (!stack.isEmpty()) { + final FoodProperties food = stack.getItem().getFoodProperties(); - Constants.LOG.info("Hello to examplemod"); + if (food != null) { + tooltip.add(Component.literal("Nutrition: " + food.getNutrition())); + tooltip.add(Component.literal("Saturation: " + food.getSaturationModifier())); + } } } } \ No newline at end of file diff --git a/common/src/main/java/com/example/examplemod/Constants.java b/common/src/main/java/de/griefed/addemall/Constants.java similarity index 53% rename from common/src/main/java/com/example/examplemod/Constants.java rename to common/src/main/java/de/griefed/addemall/Constants.java index 9d3c196..0b199cc 100644 --- a/common/src/main/java/com/example/examplemod/Constants.java +++ b/common/src/main/java/de/griefed/addemall/Constants.java @@ -1,11 +1,11 @@ -package com.example.examplemod; +package de.griefed.addemall; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class Constants { - public static final String MOD_ID = "examplemod"; - public static final String MOD_NAME = "ExampleMod"; + public static final String MOD_ID = "addemall"; + public static final String MOD_NAME = "AddEmAll"; public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME); } \ No newline at end of file diff --git a/common/src/main/java/com/example/examplemod/mixin/MixinMinecraft.java b/common/src/main/java/de/griefed/addemall/mixin/MixinMinecraft.java similarity index 81% rename from common/src/main/java/com/example/examplemod/mixin/MixinMinecraft.java rename to common/src/main/java/de/griefed/addemall/mixin/MixinMinecraft.java index 91d9161..efa0265 100644 --- a/common/src/main/java/com/example/examplemod/mixin/MixinMinecraft.java +++ b/common/src/main/java/de/griefed/addemall/mixin/MixinMinecraft.java @@ -1,8 +1,7 @@ -package com.example.examplemod.mixin; +package de.griefed.addemall.mixin; -import com.example.examplemod.Constants; +import de.griefed.addemall.Constants; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.TitleScreen; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; diff --git a/common/src/main/java/com/example/examplemod/platform/Services.java b/common/src/main/java/de/griefed/addemall/platform/Services.java similarity index 91% rename from common/src/main/java/com/example/examplemod/platform/Services.java rename to common/src/main/java/de/griefed/addemall/platform/Services.java index b3a1530..bf35fbc 100644 --- a/common/src/main/java/com/example/examplemod/platform/Services.java +++ b/common/src/main/java/de/griefed/addemall/platform/Services.java @@ -1,7 +1,7 @@ -package com.example.examplemod.platform; +package de.griefed.addemall.platform; -import com.example.examplemod.Constants; -import com.example.examplemod.platform.services.IPlatformHelper; +import de.griefed.addemall.Constants; +import de.griefed.addemall.platform.services.IPlatformHelper; import java.util.ServiceLoader; diff --git a/common/src/main/java/com/example/examplemod/platform/services/IPlatformHelper.java b/common/src/main/java/de/griefed/addemall/platform/services/IPlatformHelper.java similarity index 94% rename from common/src/main/java/com/example/examplemod/platform/services/IPlatformHelper.java rename to common/src/main/java/de/griefed/addemall/platform/services/IPlatformHelper.java index 3553cac..a0ed9e3 100644 --- a/common/src/main/java/com/example/examplemod/platform/services/IPlatformHelper.java +++ b/common/src/main/java/de/griefed/addemall/platform/services/IPlatformHelper.java @@ -1,4 +1,4 @@ -package com.example.examplemod.platform.services; +package de.griefed.addemall.platform.services; public interface IPlatformHelper { diff --git a/common/src/main/resources/examplemod.mixins.json b/common/src/main/resources/addemall.mixins.json similarity index 77% rename from common/src/main/resources/examplemod.mixins.json rename to common/src/main/resources/addemall.mixins.json index 3bc0b93..e3e42ce 100644 --- a/common/src/main/resources/examplemod.mixins.json +++ b/common/src/main/resources/addemall.mixins.json @@ -1,13 +1,13 @@ { "required": true, "minVersion": "0.8", - "package": "com.example.examplemod.mixin", + "package": "de.griefed.addemall.mixin", "refmap": "${mod_id}.refmap.json", "compatibilityLevel": "JAVA_17", "mixins": [ ], "client": [ - "MixinMinecraft" + "MixinMinecraft" ], "server": [ ], diff --git a/common/src/main/resources/assets/addemall/blockstates/tutorial_sand_block.json b/common/src/main/resources/assets/addemall/blockstates/tutorial_sand_block.json new file mode 100644 index 0000000..b0e3c25 --- /dev/null +++ b/common/src/main/resources/assets/addemall/blockstates/tutorial_sand_block.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": { "model": "addemall:block/tutorial_sand_block" } + } +} diff --git a/common/src/main/resources/assets/addemall/blockstates/tutorial_stone_block.json b/common/src/main/resources/assets/addemall/blockstates/tutorial_stone_block.json new file mode 100644 index 0000000..963ee24 --- /dev/null +++ b/common/src/main/resources/assets/addemall/blockstates/tutorial_stone_block.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": { "model": "addemall:block/tutorial_stone_block" } + } +} diff --git a/common/src/main/resources/assets/addemall/blockstates/tutorial_wool_block.json b/common/src/main/resources/assets/addemall/blockstates/tutorial_wool_block.json new file mode 100644 index 0000000..83a4820 --- /dev/null +++ b/common/src/main/resources/assets/addemall/blockstates/tutorial_wool_block.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": { "model": "addemall:block/tutorial_wool_block" } + } +} diff --git a/common/src/main/resources/assets/addemall/lang/en_us.json b/common/src/main/resources/assets/addemall/lang/en_us.json new file mode 100644 index 0000000..ffebac1 --- /dev/null +++ b/common/src/main/resources/assets/addemall/lang/en_us.json @@ -0,0 +1,17 @@ +{ + "DO.NOT.EDIT.MANUALLY.BEGIN": "BEGIN", + +"item.addemall.tutorial_stone_block": "Tutorial Stone", + +"block.addemall.tutorial_stone_block": "Tutorial Stone", + +"item.addemall.tutorial_wool_block": "Tutorial Wool", + +"block.addemall.tutorial_wool_block": "Tutorial Wool", + +"item.addemall.tutorial_sand_block": "Tutorial Sand", + +"block.addemall.tutorial_sand_block": "Tutorial Sand", + +"DO.NOT.EDIT.MANUALLY.END": "END" +} diff --git a/common/src/main/resources/assets/addemall/models/block/tutorial_sand_block.json b/common/src/main/resources/assets/addemall/models/block/tutorial_sand_block.json new file mode 100644 index 0000000..f2d0a9c --- /dev/null +++ b/common/src/main/resources/assets/addemall/models/block/tutorial_sand_block.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "addemall:block/tutorial_sand_block" + } +} diff --git a/common/src/main/resources/assets/addemall/models/block/tutorial_stone_block.json b/common/src/main/resources/assets/addemall/models/block/tutorial_stone_block.json new file mode 100644 index 0000000..a5575f6 --- /dev/null +++ b/common/src/main/resources/assets/addemall/models/block/tutorial_stone_block.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "addemall:block/tutorial_stone_block" + } +} diff --git a/common/src/main/resources/assets/addemall/models/block/tutorial_wool_block.json b/common/src/main/resources/assets/addemall/models/block/tutorial_wool_block.json new file mode 100644 index 0000000..ba51c89 --- /dev/null +++ b/common/src/main/resources/assets/addemall/models/block/tutorial_wool_block.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "addemall:block/tutorial_wool_block" + } +} diff --git a/common/src/main/resources/assets/addemall/models/item/tutorial_sand_block.json b/common/src/main/resources/assets/addemall/models/item/tutorial_sand_block.json new file mode 100644 index 0000000..fb692ff --- /dev/null +++ b/common/src/main/resources/assets/addemall/models/item/tutorial_sand_block.json @@ -0,0 +1,3 @@ +{ + "parent": "addemall:block/tutorial_sand_block" +} diff --git a/common/src/main/resources/assets/addemall/models/item/tutorial_stone_block.json b/common/src/main/resources/assets/addemall/models/item/tutorial_stone_block.json new file mode 100644 index 0000000..c0842df --- /dev/null +++ b/common/src/main/resources/assets/addemall/models/item/tutorial_stone_block.json @@ -0,0 +1,3 @@ +{ + "parent": "addemall:block/tutorial_stone_block" +} diff --git a/common/src/main/resources/assets/addemall/models/item/tutorial_wool_block.json b/common/src/main/resources/assets/addemall/models/item/tutorial_wool_block.json new file mode 100644 index 0000000..485c224 --- /dev/null +++ b/common/src/main/resources/assets/addemall/models/item/tutorial_wool_block.json @@ -0,0 +1,3 @@ +{ + "parent": "addemall:block/tutorial_wool_block" +} diff --git a/common/src/main/resources/assets/addemall/textures/block/tutorial_sand_block.png b/common/src/main/resources/assets/addemall/textures/block/tutorial_sand_block.png new file mode 100644 index 0000000000000000000000000000000000000000..32926452e3dcf4aad3927b3b751eb23e0aba255f GIT binary patch literal 483 zcmV<90UZ8`P)EX>4Tx04R}tkv&MmKpe$iQ;VV%5j%)DWT=8*7Zq_VRV;#q(pG5I!Q|2}Xws0R zxHt-~1qVMCs}3&Cx;nTDg5U>;tBaGOibq^n3?;bkx9)Hhls^u2g@DIN`^{2LmXCAjq-)8 z%L?Z$&T6H`TKD8H4Cb|!G}md4B90{_kc0>sHIz|-g$S)0DJD|1AM@~!IQ}HLWO9|k z$gzMbR7j2={11M2YZj)b+@xR(2)x+##~9GP3pDGt{e5iP%@e@?3|wh#f3*S3eUe^p zYvChcU>mr&Zfo)$aJd5vKk1SoIg+2IP$&TJXY@@uVCWX;U2}VD?c?+T$WT|yH^9Lm zFkYnWb&q%VboTb|nO1*4d)jiU{pSY70000QNklYDI47Ke6u`tlA{f;$s$uA8 Z000KP0kpM9Z36%R002ovPDHLkV1jNS(j))? literal 0 HcmV?d00001 diff --git a/common/src/main/resources/assets/addemall/textures/block/tutorial_stone_block.png b/common/src/main/resources/assets/addemall/textures/block/tutorial_stone_block.png new file mode 100644 index 0000000000000000000000000000000000000000..822b5dd757a46f874ed2e85421a35927d9680298 GIT binary patch literal 482 zcmV<80UiE{P)EX>4Tx04R}tkv&MmKpe$iQ;VV%5j%)DWT=8*7Zq_VRV;#q(pG5I!Q|2}Xws0R zxHt-~1qVMCs}3&Cx;nTDg5U>;tBaGOibq^n3?;bkx9)Hhls^u2g@DIN`^{2LmXCAjq-)8 z%L?Z$&T6H`TKD8H4Cb|!G}md4B90{_kc0>sHIz|-g$S)0DJD|1AM@~!IQ}HLWO9|k z$gzMbR7j2={11M2YZj)b+@xR(2)x+##~9GP3pDGt{e5iP%@e@?3|wh#f3*S3eUe^p zYvChcU>mr&Zfo)$aJd5vKk1SoIg+2IP$&TJXY@@uVCWX;U2}VD?c?+T$WT|yH^9Lm zFkYnWb&q%VboTb|nO1*4d)jiU{pSY70000PNklX|Nl9TK1u!v?2u3xGY8W~i Y0LY~QObjEX>4Tx04R}tkv&MmKpe$iQ;VV%5j%)DWT=8*7Zq_VRV;#q(pG5I!Q|2}Xws0R zxHt-~1qVMCs}3&Cx;nTDg5U>;tBaGOibq^n3?;bkx9)Hhls^u2g@DIN`^{2LmXCAjq-)8 z%L?Z$&T6H`TKD8H4Cb|!G}md4B90{_kc0>sHIz|-g$S)0DJD|1AM@~!IQ}HLWO9|k z$gzMbR7j2={11M2YZj)b+@xR(2)x+##~9GP3pDGt{e5iP%@e@?3|wh#f3*S3eUe^p zYvChcU>mr&Zfo)$aJd5vKk1SoIg+2IP$&TJXY@@uVCWX;U2}VD?c?+T$WT|yH^9Lm zFkYnWb&q%VboTb|nO1*4d)jiU{pSY70000QNklXIpRkaD6u`tlA{f;$s$uA8 Z007}~0jL#+-+TZ7002ovPDHLkV1kq=)5ZV* literal 0 HcmV?d00001 diff --git a/definitions/assets/blocks/tutorial_sand.png b/definitions/assets/blocks/tutorial_sand.png new file mode 100644 index 0000000000000000000000000000000000000000..32926452e3dcf4aad3927b3b751eb23e0aba255f GIT binary patch literal 483 zcmV<90UZ8`P)EX>4Tx04R}tkv&MmKpe$iQ;VV%5j%)DWT=8*7Zq_VRV;#q(pG5I!Q|2}Xws0R zxHt-~1qVMCs}3&Cx;nTDg5U>;tBaGOibq^n3?;bkx9)Hhls^u2g@DIN`^{2LmXCAjq-)8 z%L?Z$&T6H`TKD8H4Cb|!G}md4B90{_kc0>sHIz|-g$S)0DJD|1AM@~!IQ}HLWO9|k z$gzMbR7j2={11M2YZj)b+@xR(2)x+##~9GP3pDGt{e5iP%@e@?3|wh#f3*S3eUe^p zYvChcU>mr&Zfo)$aJd5vKk1SoIg+2IP$&TJXY@@uVCWX;U2}VD?c?+T$WT|yH^9Lm zFkYnWb&q%VboTb|nO1*4d)jiU{pSY70000QNklYDI47Ke6u`tlA{f;$s$uA8 Z000KP0kpM9Z36%R002ovPDHLkV1jNS(j))? literal 0 HcmV?d00001 diff --git a/definitions/assets/blocks/tutorial_stone.png b/definitions/assets/blocks/tutorial_stone.png new file mode 100644 index 0000000000000000000000000000000000000000..822b5dd757a46f874ed2e85421a35927d9680298 GIT binary patch literal 482 zcmV<80UiE{P)EX>4Tx04R}tkv&MmKpe$iQ;VV%5j%)DWT=8*7Zq_VRV;#q(pG5I!Q|2}Xws0R zxHt-~1qVMCs}3&Cx;nTDg5U>;tBaGOibq^n3?;bkx9)Hhls^u2g@DIN`^{2LmXCAjq-)8 z%L?Z$&T6H`TKD8H4Cb|!G}md4B90{_kc0>sHIz|-g$S)0DJD|1AM@~!IQ}HLWO9|k z$gzMbR7j2={11M2YZj)b+@xR(2)x+##~9GP3pDGt{e5iP%@e@?3|wh#f3*S3eUe^p zYvChcU>mr&Zfo)$aJd5vKk1SoIg+2IP$&TJXY@@uVCWX;U2}VD?c?+T$WT|yH^9Lm zFkYnWb&q%VboTb|nO1*4d)jiU{pSY70000PNklX|Nl9TK1u!v?2u3xGY8W~i Y0LY~QObjEX>4Tx04R}tkv&MmKpe$iQ;VV%5j%)DWT=8*7Zq_VRV;#q(pG5I!Q|2}Xws0R zxHt-~1qVMCs}3&Cx;nTDg5U>;tBaGOibq^n3?;bkx9)Hhls^u2g@DIN`^{2LmXCAjq-)8 z%L?Z$&T6H`TKD8H4Cb|!G}md4B90{_kc0>sHIz|-g$S)0DJD|1AM@~!IQ}HLWO9|k z$gzMbR7j2={11M2YZj)b+@xR(2)x+##~9GP3pDGt{e5iP%@e@?3|wh#f3*S3eUe^p zYvChcU>mr&Zfo)$aJd5vKk1SoIg+2IP$&TJXY@@uVCWX;U2}VD?c?+T$WT|yH^9Lm zFkYnWb&q%VboTb|nO1*4d)jiU{pSY70000QNklXIpRkaD6u`tlA{f;$s$uA8 Z007}~0jL#+-+TZ7002ovPDHLkV1kq=)5ZV* literal 0 HcmV?d00001 diff --git a/definitions/blocks.json b/definitions/blocks.json new file mode 100644 index 0000000..303572f --- /dev/null +++ b/definitions/blocks.json @@ -0,0 +1,32 @@ +[ + { + "id": "tutorial_stone", + "translation": "Tutorial Stone", + "material": "STONE", + "strength": 6, + "lightLevel": 0, + "explosionResistance": 8, + "requiresCorrectTool": true, + "instabreak": false + }, + { + "id": "tutorial_wool", + "translation": "Tutorial Wool", + "material": "WOOL", + "strength": 4, + "lightLevel": 5, + "explosionResistance": 6, + "requiresCorrectTool": false, + "instabreak": false + }, + { + "id": "tutorial_sand", + "translation": "Tutorial Sand", + "material": "SAND", + "strength": 2, + "lightLevel": 12, + "explosionResistance": 2, + "requiresCorrectTool": false, + "instabreak": true + } +] diff --git a/definitions/items.json b/definitions/items.json new file mode 100644 index 0000000..e69de29 diff --git a/fabric/build.gradle b/fabric/build.gradle index d1fd2e0..2b6f247 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -11,7 +11,7 @@ dependencies { minecraft "com.mojang:minecraft:${minecraft_version}" mappings loom.officialMojangMappings() modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}+${minecraft_version}" implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1' implementation project(":common") } diff --git a/fabric/src/main/java/com/example/examplemod/ExampleMod.java b/fabric/src/main/java/com/example/examplemod/ExampleMod.java deleted file mode 100644 index e53f1a7..0000000 --- a/fabric/src/main/java/com/example/examplemod/ExampleMod.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.example.examplemod; - -import net.fabricmc.api.ModInitializer; - -public class ExampleMod implements ModInitializer { - - @Override - public void onInitialize() { - - // This method is invoked by the Fabric mod loader when it is ready - // to load your mod. You can access Fabric and Common code in this - // project. - - // Use Fabric to bootstrap the Common mod. - Constants.LOG.info("Hello Fabric world!"); - CommonClass.init(); - } -} diff --git a/fabric/src/main/java/de/griefed/addemall/AddEmAllFabric.java b/fabric/src/main/java/de/griefed/addemall/AddEmAllFabric.java new file mode 100644 index 0000000..554c8cd --- /dev/null +++ b/fabric/src/main/java/de/griefed/addemall/AddEmAllFabric.java @@ -0,0 +1,28 @@ +package de.griefed.addemall; + +import net.fabricmc.api.ModInitializer; +import de.griefed.addemall.block.ModBlocks; +import de.griefed.addemall.item.ModItems; +import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +// Very important comment +public class AddEmAllFabric implements ModInitializer { + public static final String MOD_ID = "addemall"; + public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); + + @Override + public void onInitialize() { + Constants.LOG.info("Hello world!"); + LOGGER.info("Hello Fabric World!"); + CommonClass.init(); + + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + ModItems.registerModItems(); + ModBlocks.registerModBlocks(); + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + + ItemTooltipCallback.EVENT.register(CommonClass::onItemTooltip); + } +} diff --git a/fabric/src/main/java/de/griefed/addemall/block/ModBlocks.java b/fabric/src/main/java/de/griefed/addemall/block/ModBlocks.java new file mode 100644 index 0000000..1768cc2 --- /dev/null +++ b/fabric/src/main/java/de/griefed/addemall/block/ModBlocks.java @@ -0,0 +1,58 @@ +package de.griefed.addemall.block; + +import net.fabricmc.fabric.api.item.v1.FabricItemSettings; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; +import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import de.griefed.addemall.AddEmAllFabric; +import net.minecraft.block.Block; +import net.minecraft.block.Material; +import net.minecraft.core.Registry; +import net.minecraft.world.item.*; +import net.minecraft.item.BlockItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemGroups; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; +import net.minecraft.world.level.block.Block; + +public class ModBlocks { + + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + public static final Block TUTORIAL_STONE_BLOCK = registerBlock("tutorial_stone_block", + new Block(FabricBlockSettings.of(Material.STONE).strength(6f).luminance(0) + .hardness(8).requiresTool() + ), ItemGroups.BUILDING_BLOCKS); + + public static final Block TUTORIAL_WOOL_BLOCK = registerBlock("tutorial_wool_block", + new Block(FabricBlockSettings.of(Material.WOOL).strength(4f).luminance(5) + .hardness(6) + ), ItemGroups.BUILDING_BLOCKS); + + public static final Block TUTORIAL_SAND_BLOCK = registerBlock("tutorial_sand_block", + new Block(FabricBlockSettings.of(Material.SAND).strength(2f).luminance(12) + .hardness(2).breakInstantly() + ), ItemGroups.BUILDING_BLOCKS); + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + + private static Block registerBlockWithoutItem(String name, Block block) { + return Registry.register(Registry.BLOCK, new Identifier(AddEmAllFabric.MOD_ID, name), block); + } + + private static Block registerBlock(String name, Block block, ItemGroup tab) { + registerBlockItem(name, block, tab); + return Registry.register(Registry.BLOCK, new Identifier(AddEmAllFabric.MOD_ID, name), block); + } + + private static Item registerBlockItem(String name, Block block, ItemGroup tab) { + Item item = Registry.register(Registry.ITEM, new Identifier(AddEmAllFabric.MOD_ID, name), + new BlockItem(block, new FabricItemSettings())); + ItemGroupEvents.modifyEntriesEvent(tab).register(entries -> entries.add(item)); + return item; + } + + public static void registerModBlocks() { + AddEmAllFabric.LOGGER.debug("Registering ModBlocks for " + AddEmAllFabric.MOD_ID); + } +} diff --git a/fabric/src/main/java/de/griefed/addemall/item/ModItems.java b/fabric/src/main/java/de/griefed/addemall/item/ModItems.java new file mode 100644 index 0000000..af60ce2 --- /dev/null +++ b/fabric/src/main/java/de/griefed/addemall/item/ModItems.java @@ -0,0 +1,38 @@ +package de.griefed.addemall.item; + +import net.fabricmc.fabric.api.item.v1.FabricItemSettings; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; +import de.griefed.addemall.AddEmAllFabric; +import net.minecraft.item.Item; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemGroups; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; + +public class ModItems { + + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + + private static Item registerItem(String name, Item item) { + return Registry.register(Registries.ITEM, new Identifier(AddEmAllFabric.MOD_ID, name), item); + } + + public static void addItemsToItemGroups() { + /*###GENERATED ADD CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST*/ + + /*###GENERATED ADD CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST*/ + } + + public static void addToItemGroup(ItemGroup group, Item item) { + ItemGroupEvents.modifyEntriesEvent(group).register(entries -> entries.add(item)); + } + + public static void registerModItems() { + TutorialMod.LOGGER.debug("Registering Mod Items for " + TutorialMod.MOD_ID); + + addItemsToItemGroups(); + } +} diff --git a/fabric/src/main/java/com/example/examplemod/mixin/MixinTitleScreen.java b/fabric/src/main/java/de/griefed/addemall/mixin/MixinTitleScreen.java similarity index 89% rename from fabric/src/main/java/com/example/examplemod/mixin/MixinTitleScreen.java rename to fabric/src/main/java/de/griefed/addemall/mixin/MixinTitleScreen.java index 3680cdb..dea9fce 100644 --- a/fabric/src/main/java/com/example/examplemod/mixin/MixinTitleScreen.java +++ b/fabric/src/main/java/de/griefed/addemall/mixin/MixinTitleScreen.java @@ -1,6 +1,6 @@ -package com.example.examplemod.mixin; +package de.griefed.addemall.mixin; -import com.example.examplemod.Constants; +import de.griefed.addemall.Constants; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.TitleScreen; import org.spongepowered.asm.mixin.Mixin; diff --git a/fabric/src/main/java/com/example/examplemod/platform/FabricPlatformHelper.java b/fabric/src/main/java/de/griefed/addemall/platform/FabricPlatformHelper.java similarity index 81% rename from fabric/src/main/java/com/example/examplemod/platform/FabricPlatformHelper.java rename to fabric/src/main/java/de/griefed/addemall/platform/FabricPlatformHelper.java index 1a3371f..a747573 100644 --- a/fabric/src/main/java/com/example/examplemod/platform/FabricPlatformHelper.java +++ b/fabric/src/main/java/de/griefed/addemall/platform/FabricPlatformHelper.java @@ -1,6 +1,6 @@ -package com.example.examplemod.platform; +package de.griefed.addemall.platform; -import com.example.examplemod.platform.services.IPlatformHelper; +import de.griefed.addemall.platform.services.IPlatformHelper; import net.fabricmc.loader.api.FabricLoader; public class FabricPlatformHelper implements IPlatformHelper { diff --git a/fabric/src/main/resources/META-INF/services/com.example.examplemod.platform.services.IPlatformHelper b/fabric/src/main/resources/META-INF/services/com.example.examplemod.platform.services.IPlatformHelper deleted file mode 100644 index 30c54ee..0000000 --- a/fabric/src/main/resources/META-INF/services/com.example.examplemod.platform.services.IPlatformHelper +++ /dev/null @@ -1 +0,0 @@ -com.example.examplemod.platform.FabricPlatformHelper \ No newline at end of file diff --git a/fabric/src/main/resources/META-INF/services/de.griefed.addemall.platform.services.IPlatformHelper b/fabric/src/main/resources/META-INF/services/de.griefed.addemall.platform.services.IPlatformHelper new file mode 100644 index 0000000..23eede3 --- /dev/null +++ b/fabric/src/main/resources/META-INF/services/de.griefed.addemall.platform.services.IPlatformHelper @@ -0,0 +1 @@ +de.griefed.addemall.platform.FabricPlatformHelper \ No newline at end of file diff --git a/fabric/src/main/resources/examplemod.fabric.mixins.json b/fabric/src/main/resources/addemall.fabric.mixins.json similarity index 77% rename from fabric/src/main/resources/examplemod.fabric.mixins.json rename to fabric/src/main/resources/addemall.fabric.mixins.json index ad174ea..c76b458 100644 --- a/fabric/src/main/resources/examplemod.fabric.mixins.json +++ b/fabric/src/main/resources/addemall.fabric.mixins.json @@ -1,13 +1,13 @@ { "required": true, "minVersion": "0.8", - "package": "com.example.examplemod.mixin", + "package": "de.griefed.addemall.mixin", "refmap": "${mod_id}.refmap.json", "compatibilityLevel": "JAVA_17", "mixins": [ ], "client": [ - "MixinTitleScreen" + "MixinTitleScreen" ], "server": [ ], diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index c446af6..841241d 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -16,7 +16,7 @@ "environment": "*", "entrypoints": { "main": [ - "com.example.examplemod.ExampleMod" + "de.griefed.addemall.AddEmAll" ] }, "mixins": [ diff --git a/forge/src/main/java/com/example/examplemod/ExampleMod.java b/forge/src/main/java/com/example/examplemod/ExampleMod.java deleted file mode 100644 index 06f3628..0000000 --- a/forge/src/main/java/com/example/examplemod/ExampleMod.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.example.examplemod; - -import net.minecraftforge.fml.common.Mod; - -@Mod(Constants.MOD_ID) -public class ExampleMod { - - public ExampleMod() { - - // This method is invoked by the Forge mod loader when it is ready - // to load your mod. You can access Forge and Common code in this - // project. - - // Use Forge to bootstrap the Common mod. - Constants.LOG.info("Hello Forge world!"); - CommonClass.init(); - - } -} \ No newline at end of file diff --git a/forge/src/main/java/de/griefed/addemall/AddEmAllForge.java b/forge/src/main/java/de/griefed/addemall/AddEmAllForge.java new file mode 100644 index 0000000..64548f3 --- /dev/null +++ b/forge/src/main/java/de/griefed/addemall/AddEmAllForge.java @@ -0,0 +1,58 @@ +package de.griefed.addemall; + +import com.mojang.logging.LogUtils; +import de.griefed.addemall.block.ModBlocks; +import de.griefed.addemall.item.ModItems; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; +import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import org.slf4j.Logger; + +// The value here should match an entry in the META-INF/mods.toml file +@Mod(Constants.MOD_ID) +public class AddEmAllForge { + public static final String MOD_ID = "addemall"; + private static final Logger LOGGER = LogUtils.getLogger(); + + // Very Important Comment + public AddEmAllForge() { + // Use Forge to bootstrap the Common mod. + Constants.LOG.info("Hello world!"); + LOGGER.info("Hello Forge World!"); + CommonClass.init(); + + IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + ModItems.register(modEventBus); + ModBlocks.register(modEventBus); + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + + modEventBus.addListener(this::commonSetup); + + MinecraftForge.EVENT_BUS.register(this); + MinecraftForge.EVENT_BUS.addListener(this::onItemTooltip); + } + + private void commonSetup(final FMLCommonSetupEvent event) { + + } + + // You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent + @Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) + public static class ClientModEvents { + @SubscribeEvent + public static void onClientSetup(FMLClientSetupEvent event) { + + } + } + + private void onItemTooltip(ItemTooltipEvent event) { + CommonClass.onItemTooltip(event.getItemStack(), event.getFlags(), event.getToolTip()); + } +} diff --git a/forge/src/main/java/de/griefed/addemall/block/ModBlocks.java b/forge/src/main/java/de/griefed/addemall/block/ModBlocks.java new file mode 100644 index 0000000..85f26c7 --- /dev/null +++ b/forge/src/main/java/de/griefed/addemall/block/ModBlocks.java @@ -0,0 +1,52 @@ +package de.griefed.addemall.block; + +import de.griefed.addemall.AddEmAllForge; +import de.griefed.addemall.item.ModItems; +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.state.BlockBehaviour; +import net.minecraft.world.level.material.Material; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; + +import java.util.function.Supplier; + +public class ModBlocks { + public static final DeferredRegister BLOCKS = + DeferredRegister.create(ForgeRegistries.BLOCKS, AddEmAllForge.MOD_ID); + + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + public static final RegistryObject TUTORIAL_STONE_BLOCK = registerBlock("tutorial_stone_block", + () -> new Block(BlockBehaviour.Properties.of(Material.STONE) + .strength(6f).lightLevel(state -> 0).explosionResistance(8f) + .requiresCorrectToolForDrops()), CreativeModeTab.TAB_BUILDING_BLOCKS); + + public static final RegistryObject TUTORIAL_WOOL_BLOCK = registerBlock("tutorial_wool_block", + () -> new Block(BlockBehaviour.Properties.of(Material.WOOL) + .strength(4f).lightLevel(state -> 5).explosionResistance(6f) + ), CreativeModeTab.TAB_BUILDING_BLOCKS); + + public static final RegistryObject TUTORIAL_SAND_BLOCK = registerBlock("tutorial_sand_block", + () -> new Block(BlockBehaviour.Properties.of(Material.SAND) + .strength(2f).lightLevel(state -> 12).explosionResistance(2f) + .instabreak()), CreativeModeTab.TAB_BUILDING_BLOCKS); + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + + private static RegistryObject registerBlock(String name, Supplier block, CreativeModeTab tab) { + RegistryObject toReturn = BLOCKS.register(name, block); + registerBlockItem(name, toReturn, tab); + return toReturn; + } + + private static RegistryObject registerBlockItem(String name, RegistryObject block, CreativeModeTab tab) { + return ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties().tab(tab))); + } + + public static void register(IEventBus eventBus) { + BLOCKS.register(eventBus); + } +} diff --git a/forge/src/main/java/de/griefed/addemall/item/ModItems.java b/forge/src/main/java/de/griefed/addemall/item/ModItems.java new file mode 100644 index 0000000..28aba91 --- /dev/null +++ b/forge/src/main/java/de/griefed/addemall/item/ModItems.java @@ -0,0 +1,21 @@ +package de.griefed.addemall.item; + +import de.griefed.addemall.AddEmAllForge; +import net.minecraft.world.item.Item; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; + +public class ModItems { + public static final DeferredRegister ITEMS = + DeferredRegister.create(ForgeRegistries.ITEMS, AddEmAllForge.MOD_ID); + + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + + /*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/ + + public static void register(IEventBus eventBus) { + ITEMS.register(eventBus); + } +} diff --git a/forge/src/main/java/com/example/examplemod/mixin/MixinTitleScreen.java b/forge/src/main/java/de/griefed/addemall/mixin/MixinTitleScreen.java similarity index 89% rename from forge/src/main/java/com/example/examplemod/mixin/MixinTitleScreen.java rename to forge/src/main/java/de/griefed/addemall/mixin/MixinTitleScreen.java index a2e0c4b..7dc51d3 100644 --- a/forge/src/main/java/com/example/examplemod/mixin/MixinTitleScreen.java +++ b/forge/src/main/java/de/griefed/addemall/mixin/MixinTitleScreen.java @@ -1,6 +1,6 @@ -package com.example.examplemod.mixin; +package de.griefed.addemall.mixin; -import com.example.examplemod.Constants; +import de.griefed.addemall.Constants; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.TitleScreen; import org.spongepowered.asm.mixin.Mixin; diff --git a/forge/src/main/java/com/example/examplemod/platform/ForgePlatformHelper.java b/forge/src/main/java/de/griefed/addemall/platform/ForgePlatformHelper.java similarity index 81% rename from forge/src/main/java/com/example/examplemod/platform/ForgePlatformHelper.java rename to forge/src/main/java/de/griefed/addemall/platform/ForgePlatformHelper.java index 22ef9e4..56dcbb7 100644 --- a/forge/src/main/java/com/example/examplemod/platform/ForgePlatformHelper.java +++ b/forge/src/main/java/de/griefed/addemall/platform/ForgePlatformHelper.java @@ -1,6 +1,6 @@ -package com.example.examplemod.platform; +package de.griefed.addemall.platform; -import com.example.examplemod.platform.services.IPlatformHelper; +import de.griefed.addemall.platform.services.IPlatformHelper; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.loading.FMLLoader; diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 1325953..4ee7c4b 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -1,26 +1,27 @@ -modLoader = "javafml" #mandatory -loaderVersion = "${forge_loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See https://files.minecraftforge.net/ for a list of versions. -license = "${license}" # Review your options at https://choosealicense.com/. -#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional -[[mods]] #mandatory -modId = "${mod_id}" #mandatory -version = "${version}" #mandatory -displayName = "${mod_name}" #mandatory -#updateJSONURL="https://change.me.example.invalid/updates.json" #optional (see https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/) -#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional (displayed in the mod UI) -logoFile = "${mod_id}.png" #optional (needs to be in the root of your mod jar (root of your 'resources' folder)) -credits = "Thanks for this example mod goes to Java" #optional -authors = "${mod_author}" #optional -description = '''${description}''' #mandatory (Supports multiline text) -[[dependencies.${mod_id}]] #optional -modId = "forge" #mandatory -mandatory = true #mandatory -versionRange = "${forge_version_range}" #mandatory -ordering = "NONE" # The order that this dependency should load in relation to your mod, required to be either 'BEFORE' or 'AFTER' if the dependency is not mandatory -side = "BOTH" # Side this dependency is applied on - 'BOTH', 'CLIENT' or 'SERVER' +modLoader = "javafml" +loaderVersion = "${forge_loader_version_range}" +license = "${license}" +issueTrackerURL="https://github.com/Griefed/AddEmAll/issues" + +[[mods]] + modId = "${mod_id}" + version = "${version}" + displayName = "${mod_name}" + displayURL="https://github.com/Griefed/AddEmAll" + logoFile = "${mod_id}.png" + credits="jaredlll08,Darkhax,Witixin1512,Hubry,Aegide,AlgorithmLX,lukebemish" + authors = "${mod_author}" + description = '''${description}''' + [[dependencies.${mod_id}]] -modId = "minecraft" -mandatory = true -versionRange = "${minecraft_version_range}" -ordering = "NONE" -side = "BOTH" + modId = "forge" + mandatory = true + versionRange = "${forge_version_range}" + ordering = "NONE" + side = "BOTH" +[[dependencies.${mod_id}]] + modId = "minecraft" + mandatory = true + versionRange = "${minecraft_version_range}" + ordering = "NONE" + side = "BOTH" diff --git a/forge/src/main/resources/META-INF/services/com.example.examplemod.platform.services.IPlatformHelper b/forge/src/main/resources/META-INF/services/com.example.examplemod.platform.services.IPlatformHelper deleted file mode 100644 index ff2910d..0000000 --- a/forge/src/main/resources/META-INF/services/com.example.examplemod.platform.services.IPlatformHelper +++ /dev/null @@ -1 +0,0 @@ -com.example.examplemod.platform.ForgePlatformHelper \ No newline at end of file diff --git a/forge/src/main/resources/META-INF/services/de.griefed.addemall.platform.services.IPlatformHelper b/forge/src/main/resources/META-INF/services/de.griefed.addemall.platform.services.IPlatformHelper new file mode 100644 index 0000000..ce7883c --- /dev/null +++ b/forge/src/main/resources/META-INF/services/de.griefed.addemall.platform.services.IPlatformHelper @@ -0,0 +1 @@ +de.griefed.addemall.platform.ForgePlatformHelper \ No newline at end of file diff --git a/forge/src/main/resources/examplemod.forge.mixins.json b/forge/src/main/resources/addemall.forge.mixins.json similarity index 85% rename from forge/src/main/resources/examplemod.forge.mixins.json rename to forge/src/main/resources/addemall.forge.mixins.json index 95882ac..2dbcc20 100644 --- a/forge/src/main/resources/examplemod.forge.mixins.json +++ b/forge/src/main/resources/addemall.forge.mixins.json @@ -1,7 +1,7 @@ { "required": true, "minVersion": "0.8", - "package": "com.example.examplemod.mixin", + "package": "de.griefed.addemall.mixin", "refmap": "${mod_id}.refmap.json", "compatibilityLevel": "JAVA_17", "mixins": [ diff --git a/gradle.properties b/gradle.properties index a666da8..9a34fcd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,28 +3,28 @@ # Every field you add must be added to the root build.gradle expandProps map. # Project -version=1.0.0 -group=com.example.examplemod +version=0.0.1 +group=de.griefed.addemall # Common -minecraft_version=1.20 +minecraft_version=1.19.2 # Forge -forge_version=46.0.12 -forge_loader_version_range=[46,) -forge_version_range=[46,) -minecraft_version_range=[1.20, 1.21) +forge_version=43.2.21 +forge_loader_version_range=[43,) +forge_version_range=[43,) +minecraft_version_range=[1.19,) # Fabric -fabric_version=0.83.0+1.20 -fabric_loader_version=0.14.21 +fabric_version=0.76.1 +fabric_loader_version=0.14.24 # Mod options -mod_name=ExampleMod -mod_author=Jared -mod_id=examplemod +mod_name=AddEmAll +mod_author=Griefed +mod_id=addemall license=C0-1.0 -description=The description of your mod. \nAccepts multilines. +description=Assortment of blocks I want to use. # Gradle org.gradle.jvmargs=-Xmx3G diff --git a/settings.gradle b/settings.gradle index fece66e..6c1adae 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,11 +17,12 @@ pluginManagement { } plugins { - id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' } // This should match the folder name of the project, or else IDEA may complain (see https://youtrack.jetbrains.com/issue/IDEA-317606) -rootProject.name = 'MultiLoader-Template' +rootProject.name = 'AddEmAll' include("common") include("fabric") include("forge") +