### Building a Minecraft Forge Mod Source: https://docs.minecraftforge.net/en/1.13.x/gettingstarted This command compiles your Minecraft Forge mod. It produces a .jar file in the build/libs directory, ready for distribution or placement in a Forge-enabled Minecraft setup. ```bash gradlew build ``` -------------------------------- ### Clone Minecraft Forge Repository Source: https://docs.minecraftforge.net/en/1.13.x/forgedev Clones the user's forked Minecraft Forge repository to a local directory. This command requires Git to be installed and configured on the system. Replace `` with your GitHub username. ```git git clone https://github.com//MinecraftForge Forge ``` -------------------------------- ### Running a Minecraft Forge Mod Client Source: https://docs.minecraftforge.net/en/1.13.x/gettingstarted This command launches Minecraft with your mod included. It utilizes generated run configurations and can be customized further via the ForgeGradle cookbook. ```bash gradlew runClient ``` -------------------------------- ### Running a Minecraft Forge Mod Server Source: https://docs.minecraftforge.net/en/1.13.x/gettingstarted This command starts a dedicated Minecraft server with your mod integrated. It launches the Minecraft server with its GUI. ```bash gradlew runServer ``` -------------------------------- ### Setup Forge Workspace in Eclipse Source: https://docs.minecraftforge.net/en/1.13.x/forgedev Initializes the Forge development environment using ForgeGradle within an Eclipse workspace. This involves running a Gradle task and importing projects into Eclipse. It's crucial to navigate to the cloned repository's directory before executing the Gradle command. ```bash ./gradlew setup ``` -------------------------------- ### IntelliJ IDEA: Forge Build Configuration Source: https://docs.minecraftforge.net/en/1.13.x/forgedev Configures the Forge build task within IntelliJ IDEA. This involves setting VM options for memory allocation during the decompilation process and specifying 'clean setup' for the tasks. ```text Tasks: clean setup VM Options: -Xmx3G -Xms3G ``` -------------------------------- ### IntelliJ IDEA: Rebuilding Project Source: https://docs.minecraftforge.net/en/1.13.x/forgedev Provides commands to rebuild the Forge project or specific test modules within IntelliJ IDEA, ensuring changes are compiled and reflected. ```text Build -> Build module 'Forge_test' Build -> Rebuild project ``` -------------------------------- ### ASM File Structure - JSON Example Source: https://docs.minecraftforge.net/en/1.13.x/animation/asm A basic example of an Animation State Machine (ASM) file in JSON format. It shows the required top-level keys: parameters, clips, states, transitions, and start_state. ```json { "parameters": { "anim_cycle": ["/", "#cycle_length"] }, "clips": { "default": ["apply", "forgedebugmodelanimation:block/rotatest@default", "#anim_cycle" ] }, "states": [ "default" ], "transitions": {}, "start_state": "default" } ``` -------------------------------- ### Minecraft Language File Example (JSON) Source: https://docs.minecraftforge.net/en/1.13.x/concepts/internationalization An example of a Minecraft language file in JSON format, mapping translation keys to displayable text strings for localization. ```json { "item.examplemod.example_item": "Example Item Name", "block.examplemod.example_block": "Example Block Name", "commands.examplemod.examplecommand.error": "examplecommand errored!" } ``` -------------------------------- ### Customizing Mod Information in build.gradle Source: https://docs.minecraftforge.net/en/1.13.x/gettingstarted This snippet shows how to modify the build.gradle file to customize your mod's build properties, such as its base name, Maven coordinates (group), and version number. ```gradle archivesBaseName = "your_mod_id" version = "1.0.0" group = "com.yourname" ``` -------------------------------- ### Item Translation Key Example Source: https://docs.minecraftforge.net/en/1.13.x/concepts/internationalization Demonstrates how an item's registry name corresponds to a translation key in a language file. This is used for displaying item names. ```json { "item.examplemod.example_item": "Example Item Name" } ``` -------------------------------- ### Capability Storage Implementation Source: https://docs.minecraftforge.net/en/1.13.x/datastorage/capabilities Provides an example of implementing the Capability.IStorage interface for saving and loading capability data. This includes methods for writing data to NBT and reading data from NBT. ```java private static class Storage implements Capability.IStorage { @Override public NBTBase writeNBT(Capability capability, IExampleCapability instance, EnumFacing side) { // return an NBT tag } @Override public void readNBT(Capability capability, IExampleCapability instance, EnumFacing side, NBTBase nbt) { // load from the NBT tag } } ``` -------------------------------- ### IntelliJ IDEA: Adding Test Output to Classpath Source: https://docs.minecraftforge.net/en/1.13.x/forgedev Adds the compiled test classes to the runtime classpath of the main Forge module. This allows the main application to access and run test mods. ```text Add JARs or directories -> Forge_test output path Scope: Runtime ``` -------------------------------- ### Generate Patches with Gradle Task Source: https://docs.minecraftforge.net/en/1.13.x/forgedev Initiates the generation of code patches for changes made to the Minecraft codebase within the 'Forge' project. This task is crucial for incorporating modifications into Vanilla Minecraft. ```bash gradle genPatches ``` -------------------------------- ### Minecraft Debug Profiler Commands Source: https://docs.minecraftforge.net/en/1.13.x/gettingstarted/debugprofiler These commands are used to start and stop the profiling process in Minecraft. It's recommended to let the profiler run for at least a minute to gather sufficient data. ```minecraft commands /debug start ``` ```minecraft commands /debug stop ``` -------------------------------- ### Minecraft Forge Constant Definition Example Source: https://docs.minecraftforge.net/en/1.13.x/utilities/recipes Shows how to define constants in a '_constants.json' file for use in recipes. This example defines a constant named 'SADDLE' representing the vanilla saddle item with its ingredient details. ```json [ { "name": "SADDLE", "ingredient": { "item": "minecraft:saddle", "data": 0 } } ] ``` -------------------------------- ### mcmod.info Example (JSON) Source: https://docs.minecraftforge.net/en/1.13.x/gettingstarted/structuring Defines the metadata for a Minecraft Forge mod. This JSON file is stored in src/main/resources/mcmod.info and provides details like mod ID, name, description, version, and author list. The 'mcversion' property specifies the Minecraft version compatibility. ```JSON [{ "modid": "examplemod", "name": "Example Mod", "description": "Lets you craft dirt into diamonds. This is a traditional mod that has existed for eons. It is ancient. The holy Notch created it. Jeb rainbowfied it. Dinnerbone made it upside down. Etc.", "version": "1.0.0.0", "mcversion": "1.10.2", "logoFile": "assets/examplemod/textures/logo.png", "url": "minecraftforge.net/", "updateJSON": "minecraftforge.net/versions.json", "authorList": ["Author"], "credits": "I'd like to thank my mother and father." }] ``` -------------------------------- ### Instance Event Handler Source: https://docs.minecraftforge.net/en/1.13.x/events/intro Example of an event handler class that listens for the EntityItemPickupEvent. This handler prints a message when an item is picked up. It requires the Forge API. ```java public class MyForgeEventHandler { @SubscribeEvent public void pickupItem(EntityItemPickupEvent event) { System.out.println("Item picked up!"); } } ``` -------------------------------- ### Update JSON Format Example Source: https://docs.minecraftforge.net/en/1.13.x/gettingstarted/autoupdate This JSON structure defines the update information for a mod, including homepage links, version-specific changelogs, and promotional version declarations for different Minecraft versions. ```JSON { "homepage": "", "": { "": "", // List all versions of your mod for the given Minecraft version, along with their changelogs ... }, ... "promos": { "-latest": "", // Declare the latest "bleeding-edge" version of your mod for the given Minecraft version "-recommended": "", // Declare the latest "stable" version of your mod for the given Minecraft version ... } } ``` -------------------------------- ### Get Public Key from Keystore Source: https://docs.minecraftforge.net/en/1.13.x/concepts/jarsigning Retrieves the public key associated with a specific alias (e.g., `signFiles`) from a keystore file (e.g., `examplestore.jks`). The output needs to be processed by removing colons and converting to lowercase for Forge compatibility. ```bash keytool -list -alias signFiles -keystore examplestore.jks ``` -------------------------------- ### Gradle Buildscript Setup for Signing Source: https://docs.minecraftforge.net/en/1.13.x/concepts/jarsigning Configures a Gradle task named `signJar` to sign the reobfuscated JAR file. It depends on the `reobfJar` task and specifies the input and output file paths using `jar.archivePath`. The `build` task is then set to depend on `signJar`. ```gradle task signJar(type: SignJar, dependsOn: reobfJar) { inputFile = jar.archivePath outputFile = jar.archivePath } build.dependsOn signJar ``` -------------------------------- ### Shapeless Crafting Recipe Ingredients (JSON) Source: https://docs.minecraftforge.net/en/1.13.x/utilities/recipes An example of the ingredients list for a shapeless crafting recipe in JSON format. It demonstrates how to include items and Ore Dictionary entries as requirements. ```json "ingredients": [ { "type": "forge:ore_dict", "ore": "gemDiamond" }, { "item": "minecraft:nether_star" } ], ``` -------------------------------- ### Minecraft Forge Recipe Key Example Source: https://docs.minecraftforge.net/en/1.13.x/utilities/recipes Defines a key for a crafting recipe pattern, mapping a placeholder character to specific items. It supports multiple items for a single placeholder, allowing for variations like different wood types for a button. ```json { "key": { "#": [ { "item": "minecraft:planks", "data": 0 }, { "item": "minecraft:planks", "data": 1 } ] } } ``` -------------------------------- ### Retrieving Update Check Results Source: https://docs.minecraftforge.net/en/1.13.x/gettingstarted/autoupdate This Java code demonstrates how to get the update check status for a mod using Forge's API. It retrieves a ModContainer and then uses ForgeVersion to get the status, target version, and changelog. ```Java ForgeVersion.Result result = ForgeVersion.getResult(modContainer); Status status = result.status; String targetVersion = result.targetVersion; List changelogLines = result.changelogLines; // Example of checking status: if (status == Status.OUTDATED) { // Mod is outdated, display a message or changelog } ``` -------------------------------- ### Minecraft Forge Conditional Recipe Example Source: https://docs.minecraftforge.net/en/1.13.x/utilities/recipes Demonstrates how to implement conditional recipes using the factory system. It shows how to add a 'conditions' array to a recipe, specifying a type of condition (e.g., 'forge:mod_loaded') and its parameters. ```json { "conditions": [ { "type": ":" } ] } ``` -------------------------------- ### Example Switch Statement with Metadata Source: https://docs.minecraftforge.net/en/1.13.x/blocks/states Illustrates the old, less intuitive method of handling block variations using raw metadata numbers and switch statements, highlighting the lack of semantic meaning without comments. ```java switch(meta) { case 0: // it's south and on the lower half of the block case 1: // it's south on the upper side of the block case 2: // it's north and on the lower half of the block case 3: // it's north and on the upper half of the block ... etc. } ``` -------------------------------- ### Pre-release and Release Candidate Versioning Source: https://docs.minecraftforge.net/en/1.13.x/conventions/versioning This describes versioning conventions for pre-release and release candidate builds. Pre-releases (e.g., `-betaX`) are for unfinished features and should have version components updated accordingly before appending the suffix. Release candidates (`-rcX`) are stable pre-release versions before an official release, typically only incrementing for bug fixes. Versions before the initial release are considered work-in-progress builds. ```text Pre-release: Append `-betaX` (e.g., `1.0.0-beta1`). Update version components before adding suffix. Release Candidate: Append `-rcX` (e.g., `1.0.0-rc1`). Typically for bug fixes on release candidates. ``` -------------------------------- ### Minecraft 1.9 Multipart Fence Blockstate JSON Excerpt Source: https://docs.minecraftforge.net/en/1.13.x/models/blockstates/introduction Illustrates the 'multipart' format introduced in Minecraft 1.9, allowing for more modular and conditional model application. This example defines a condition for when a fence model should be applied. ```json { "when": { "east": "true" }, "apply": { "model": "oak_fence_side", "y": 90, "uvlock": true } } ``` -------------------------------- ### Manual Code Profiling in Minecraft Forge Source: https://docs.minecraftforge.net/en/1.13.x/gettingstarted/debugprofiler This Java snippet demonstrates how to manually profile specific sections of your code using the `Profiler` class. You can obtain the `Profiler` instance from various game instances. ```java Profiler#startSection(yourSectionName : String); //The code you want to profile Profiler#endSection(); ``` -------------------------------- ### Registering Blocks with RegistryEvent Source: https://docs.minecraftforge.net/en/1.13.x/concepts/registries Example of an event handler that registers blocks to the game's registry. It subscribes to the RegistryEvent.Register for Block types and uses the registerAll method to add blocks. ```java @SubscribeEvent public void registerBlocks(RegistryEvent.Register event) { event.getRegistry().registerAll(block1, block2, ...); } ``` -------------------------------- ### Registering Event Listeners in Forge Mod Source: https://docs.minecraftforge.net/en/1.13.x/conventions/loadstages Demonstrates how to register an event listener for the FMLModLoadingEventBus within a Forge mod's constructor. This is a common pattern for initializing mod-specific setup. ```java @Mod("mymod") public class MyMod { public MyMod() { FMLModLoadingContext.get().getModEventBus().registerListener(this::commonSetup); } private void commonSetup(FMLCommonSetupEvent evt) { ... } } ``` -------------------------------- ### Getting and Setting Block States (Java) Source: https://docs.minecraftforge.net/en/1.13.x/blocks/states Shows how to interact with block states in the world using getBlockState() and setBlockState(). These methods are essential for world manipulation. ```java IBlockState state = world.getBlockState(pos); world.setBlockState(pos, state.withProperty(PROPERTY, NEW_VALUE)); ``` -------------------------------- ### Example Loot Entry JSON with Custom Elements Source: https://docs.minecraftforge.net/en/1.13.x/items/loot_tables An example of a loot entry JSON structure that utilizes custom loot conditions and functions. It demonstrates how to specify custom types, parameters, and entity properties within the loot table definition. ```json { "type": "item", "name": "mymod:myitem", "conditions": [ { "condition": "mymod:mycondition", "foo": 1 }, { "condition": "minecraft:entity_properties", "entity": "this", "properties": { "mymod:my_property": { "bar": 2 } } } ], "functions": [ { "function": "mymod:myfunction", "foobar": 3 } ] } ``` -------------------------------- ### Vanilla Minecraft Fence Blockstate JSON Excerpt (1.8) Source: https://docs.minecraftforge.net/en/1.13.x/models/blockstates/introduction An example snippet from an older Minecraft version (1.8) showing a single variant definition for a fence. This format requires explicit definition for every possible property combination, leading to verbose files. ```json "east=true,north=false,south=false,west=false": { "model": "oak_fence_n", "y": 90, "uvlock": true } ``` -------------------------------- ### Static Event Handler Source: https://docs.minecraftforge.net/en/1.13.x/events/intro An example of a static event handler method for the ArrowNockEvent. This method is marked as static and registered directly using the class itself. It requires the Forge API. ```java public class MyStaticForgeEventHandler { @SubscribeEvent public static void arrowNocked(ArrowNockEvent event) { System.out.println("Arrow nocked!"); } } ``` -------------------------------- ### Minecraft Forge Factory Definition Example Source: https://docs.minecraftforge.net/en/1.13.x/utilities/recipes Illustrates how to define custom recipe factories in a '_factories.json' file. It shows the structure for specifying a type (e.g., 'recipes', 'ingredients') and mapping a custom name to a fully qualified class name that implements the respective factory interface. ```json { "": { "": "" } } ``` -------------------------------- ### Example WorldSavedData Implementation (Java) Source: https://docs.minecraftforge.net/en/1.13.x/datastorage/worldsaveddata A basic skeleton for implementing the `WorldSavedData` class in Java. It shows the required constructors and the structure for overriding essential methods like `writeToNBT` and `readFromNBT` (though these are not explicitly shown in the skeleton). The `markDirty` method is crucial for indicating changes that need to be saved. ```java public class ExampleWorldSavedData extends WorldSavedData { private static final String DATA_NAME = MODID + "_ExampleData"; // Required constructors public ExampleWorldSavedData() { super(DATA_NAME); } public ExampleWorldSavedData(String s) { super(s); } // WorldSavedData methods } ``` -------------------------------- ### Using StateMap.Builder with withName in Java Source: https://docs.minecraftforge.net/en/1.13.x/models/using Demonstrates how to create a custom IStateMapper using the StateMap.Builder to map block states to ModelResourceLocations based on a specific property. This example uses the 'facing' property to determine the model path. ```java PropertyDirection PROP_FACING = PropertyDirection.create("facing"); // Start with a property IStateMapper mapper = new StateMap.Builder().withName(PROP_FACING).build(); // Use the builder ``` -------------------------------- ### Final Release Versioning Source: https://docs.minecraftforge.net/en/1.13.x/conventions/versioning This specifies how to denote the final build for a specific Minecraft version when support for that version is being dropped. The final build for a particular MCVERSION should include the `-final` suffix. This signals that players should upgrade to a newer version of the mod to continue receiving updates and bug fixes. ```text Example: `1.7.10-3.0.0.0-final` ``` -------------------------------- ### Example Armature File Structure (JSON) Source: https://docs.minecraftforge.net/en/1.13.x/animation/armature This JSON structure represents a complete armature file, defining joints and animation clips for a model. It includes details on joint names, their associated model elements and weights, and animation clip properties like looping, joint-specific animations, and events. ```json { "joints": { "stick": {"2": [1.0]}, "cube": {"3": [1.0]} }, "clips": { "default": { "loop": true, "joint_clips": { "stick": [ { "variable": "offset_x", "type": "uniform", "interpolation": "linear", "samples": [0, 0.6875, 0] } ], "cube": [ { "variable": "offset_x", "type": "uniform", "interpolation": "linear", "samples": [0, 0.6875, 0] }, { "variable": "axis_z", "type": "uniform", "interpolation": "nearest", "samples": [ 1 ] }, { "variable": "origin_x", "type": "uniform", "interpolation": "nearest", "samples": [ 0.15625 ] }, { "variable": "origin_y", "type": "uniform", "interpolation": "nearest", "samples": [ 0.40625 ] }, { "variable": "angle", "type": "uniform", "interpolation": "linear", "samples": [0, 120, 240, 0, 120, 240] } ] }, "events": {} } } } ``` -------------------------------- ### Creating Direction Property (Java) Source: https://docs.minecraftforge.net/en/1.13.x/blocks/states Provides examples of creating IProperty objects for block facing directions. This simplifies handling directional states for blocks like stairs or logs. ```java PropertyDirection.create("direction_name", EnumFacing.Plane.HORIZONTAL); ``` ```java PropertyDirection.create("direction_name", EnumFacing.Axis.X); ``` -------------------------------- ### Forge Blockstate Combined Property Variants (JSON) Source: https://docs.minecraftforge.net/en/1.13.x/models/blockstates/forgeBlockstates This JSON example shows how blockstate variants are combined when multiple properties are defined. Each property ('shiny', 'broken') has its own states ('true'/'false'), and the final variant merges definitions from all relevant states. ```json { "forge_marker": 1, "variants": { "shiny": { "true": { "textures": { "all": "some:shiny_texture" } }, "false": { "textures": { "all": "some:flat_texture" } } }, "broken": { "true": { "model": "some:broken_model" }, "false": { "model": "some:intact_model" } } } } ``` -------------------------------- ### Registering AnimationTESR for Blocks Source: https://docs.minecraftforge.net/en/1.13.x/animation/implementing This example shows how to bind a custom AnimationTESR to a block's TileEntity. It demonstrates overriding the handleEvents callback to manage block animations. Requires the AnimationTESR class and a TileEntity. ```java ClientRegistry.bindTileEntitySpecialRenderer(Chest.class, new AnimationTESR() { @Override public void handleEvents(Chest chest, float time, Iterable pastEvents) { chest.handleEvents(time, pastEvents); } }); ``` -------------------------------- ### UnannotatedHolder Class Example - Minecraft Forge Source: https://docs.minecraftforge.net/en/1.13.x/concepts/registries Illustrates scenarios with unannotated classes and fields. It shows how a field annotation with a namespace works independently, how an unannotated field in an unannotated class is ignored, and how an annotation lacking a namespace on an unannotated class will cause failure. ```java class UnannotatedHolder { // Note lack of annotation on this class. @ObjectHolder("minecraft:flame") public static final Enchantment flame = null; // No annotation on the class means that there is no preset namespace to inherit. // Field annotation supplies all the information for the object. // Object to be injected: "minecraft:flame" from the Enchantment registry. public static final Biome ice_flat = null; // No annotation on the class or the field. // Therefore this just gets ignored. @ObjectHolder("levitation") public static final Potion levitation = null; // No resource namespace in annotation, and no default specified by class annotation. // Therefore, THIS WILL FAIL. The field annotation needs a namespace, or the class needs an annotation. } ``` -------------------------------- ### Adding a Loot Entry to a Loot Pool (Java) Source: https://docs.minecraftforge.net/en/1.13.x/items/loot_tables This example shows how to create a LootEntryTable to reference a custom loot table JSON. This entry can then be added to a LootPool, allowing for recursive loot table drawing and flexible custom drops. ```java LootEntry entry = new LootEntryTable(new ResourceLocation("mymod:inject/simple_dungeon"), , , , ); // weight doesn't matter since it's the only entry in the pool. Other params set as you wish. LootPool pool = new LootPool(new LootEntry[] {entry}, , , , ); // Other params set as you wish. evt.getTable().addPool(pool); ``` -------------------------------- ### AnnotatedHolder Class Example - Minecraft Forge Source: https://docs.minecraftforge.net/en/1.13.x/concepts/registries Demonstrates injecting values from the 'minecraft' namespace into Block, Item, and ManaType registries using @ObjectHolder on both the class and fields. It shows how class-level namespaces are inherited and how field-level annotations can override or specify namespaces and resource paths. ```java @ObjectHolder("minecraft") // Resource namespace "minecraft" class AnnotatedHolder { public static final Block diamond_block = null; // public static final is required. // Type Block means that the Block registry will be queried. // diamond_block is the field name, and as the field is not annotated it is taken to be the resource path. // As there is no explicit namespace, "minecraft" is inherited from the class. // Object to be injected: "minecraft:diamond_block" from the Block registry. @ObjectHolder("ender_eye") public static final Item eye_of_ender = null; // Type Item means that the Item registry will be queried. // As the annotation has the value "ender_eye", that overrides the field's name. // As the namespace is not explicit, "minecraft" is inherited from the class. // Object to be injected: "minecraft:ender_eye" from the Item registry. @ObjectHolder("neomagicae:coffeinum") public static final ManaType coffeinum = null; // Type ManaType means that the ManaType registry will be queried. This is obviously a registry made by a mod. // As the annotation has the value "neomagicae:coffeinum", that overrides the field's name. // The namespace is explicit, and is "neomagicae", overriding the class's "minecraft" default. // Object to be injected: "neomagicae:coffeinum" from the ManaType registry. public static final Item ENDER_PEARL = null; // Note that the actual name is "minecraft:ender_pearl", not "minecraft:ENDER_PEARL". // However, since constructing a ResourceLocation lowercases the value, this will work. } ``` -------------------------------- ### Forge Blockstate Example with Custom Data Source: https://docs.minecraftforge.net/en/1.13.x/models/advanced/imodel This JSON snippet demonstrates the Forge blockstate format, specifically how to define and inherit custom data within model properties. The `custom` field allows for arbitrary JSON primitives, which are passed to the `process` method as an ImmutableMap after being converted to strings. ```json { "forge_marker": 1, "defaults": { "custom": { "__comment": "These can be any JSON primitives with any names, but models should only use what they understand.", "meaningOfLife": 42, "showQuestion": false }, "model": "examplemod:life_meaning" }, "variants": { "dying": { "true": { "__comment": "Custom data is inherited. Therefore, here `meaningOfLife` is inherited but `showQuestion` is overriden. The model itself remains inherited.", "custom": { "showQuestion": true } }, "false": {} } } } ``` -------------------------------- ### Using StateMap.Builder with ignore in Java Source: https://docs.minecraftforge.net/en/1.13.x/models/using Illustrates how to create an IStateMapper that ignores specific block properties when generating ModelResourceLocations. This example shows how to ignore 'out' and 'in' properties, demonstrating equivalence between merging and sequential calls. ```java PropertyDirection PROP_OUT = PropertyDirection.create("out"); PropertyDirection PROP_IN = PropertyDirection.create("in"); // These two are equivalent IStateMapper together = new StateMap.Builder().ignore(PROP_OUT, PROP_IN).build(); IStateMapper merged = new StateMap.Builder().ignore(PROP_OUT).ignore(PROP_IN).build(); ``` -------------------------------- ### Versioning Conventions for Minecraft Mod Updates Source: https://docs.minecraftforge.net/en/1.13.x/conventions/versioning This section details how to increment version numbers when updating mods for new Minecraft versions or when making various types of changes. It specifies that when any version component is incremented, all subsequent components should reset to zero. It also provides guidance on handling mods supporting multiple Minecraft versions simultaneously and marking versions that no longer receive support. ```text Examples of version increments: - MAJORMOD: Removing items, blocks, or mechanics; updating Minecraft version. - MAJORAPI: Changing enum order/variables, return types, or removing public methods. - MINOR: Adding items, blocks, or mechanics; deprecating public methods. - PATCH: Bugfixes. When MAJORMOD increments, MAJORAPI, MINOR, and PATCH reset to 0. When MAJORAPI increments, MINOR and PATCH reset to 0. When MINOR increments, PATCH resets to 0. If a mod upgrades to Minecraft version X and the old version only receives bug fixes, the PATCH variable is updated based on the version before the upgrade. If a mod is in active development for both old and new Minecraft versions, append the version to both build numbers. Example: 1.7.10-3.0.0.0 and 1.8-3.0.0.0. If no changes occur when building for a newer Minecraft version, all variables except MCVERSION remain the same. ``` -------------------------------- ### Registering a Capability Source: https://docs.minecraftforge.net/en/1.13.x/datastorage/capabilities Demonstrates the basic registration of a capability using CapabilityManager.INSTANCE.register. It outlines the three required parameters: the capability interface class, a storage implementation, and a default implementation factory. ```java CapabilityManager.INSTANCE.register(capability interface class, storage, default implementation factory); ``` -------------------------------- ### Get Physical Side Using FMLEnvironment.dist (Java) Source: https://docs.minecraftforge.net/en/1.13.x/concepts/sides Retrieves the physical side (client or server) on which the code is running. This value is determined at startup and is a reliable indicator of the physical environment. It's less commonly used directly, with `DistExecutor` or `FMLEnvironment.dist` checks being preferred for dispatching behavior. ```java Dist physicalSide = FMLEnvironment.dist; // Use physicalSide to determine client or server ``` -------------------------------- ### Custom Dungeon Loot Table JSON (JSON) Source: https://docs.minecraftforge.net/en/1.13.x/items/loot_tables An example JSON structure for a custom loot table. This defines a pool named 'main' with two entries: a 'minecraft:nether_star' with a weight of 40 and an 'empty' entry with a weight of 60, influencing the chances of an item spawning. ```json { "pools": [ { "name": "main", "rolls": 1, "entries": [ { "type": "item", "name": "minecraft:nether_star", "weight": 40 }, { "type": "empty", "weight": 60 } ] } ] } ``` -------------------------------- ### Getting or Loading WorldSavedData (Java) Source: https://docs.minecraftforge.net/en/1.13.x/datastorage/worldsaveddata This Java code snippet demonstrates a common pattern for retrieving or creating an instance of `WorldSavedData`. It checks if data exists using `MapStorage.getOrLoadData` and, if not found, creates a new instance and saves it. The choice between global and per-world storage is determined by the `IS_GLOBAL` constant. ```java public static ExampleWorldSavedData get(World world) { // The IS_GLOBAL constant is there for clarity, and should be simplified into the right branch. MapStorage storage = IS_GLOBAL ? world.getMapStorage() : world.getPerWorldStorage(); ExampleWorldSavedData instance = (ExampleWorldSavedData) storage.getOrLoadData(ExampleWorldSavedData.class, DATA_NAME); if (instance == null) { instance = new ExampleWorldSavedData(); storage.setData(DATA_NAME, instance); } return instance; } ``` -------------------------------- ### Minecraft Mod Versioning Format Source: https://docs.minecraftforge.net/en/1.13.x/conventions/versioning This format extends Semantic Versioning (MAJOR.MINOR.PATCH) to include the Minecraft version for mod compatibility. It uses MCVERSION-MAJORMOD.MAJORAPI.MINOR.PATCH, where each component signifies specific types of changes. MAJORMOD changes indicate breaking changes to the mod itself, MAJORAPI changes affect the mod's public API, MINOR changes are for new features or additions, and PATCH is for bug fixes. ```text MCVERSION-MAJORMOD.MAJORAPI.MINOR.PATCH ``` -------------------------------- ### Using Blockstate JSONs for Items - JSON Source: https://docs.minecraftforge.net/en/1.13.x/models/using Demonstrates how to use a blockstate JSON for an item model. This allows items to leverage block model features like submodels and variants. The example shows a workaround for the inability to reference models under 'models/item' by using the 'builtin/generated' model and applying custom transforms. ```json { "defaults": { "model": "builtin/generated", "__comment": "Get Forge to inject the default rotations and scales for an item in a player's hand, on the ground, etc.", "transform": "forge:default-item" } } ``` -------------------------------- ### Generate Keystore using Keytool Source: https://docs.minecraftforge.net/en/1.13.x/concepts/jarsigning Generates a keystore file (e.g., `examplestore.jks`) with a public and private key alias (e.g., `signFiles`). This keystore is used to sign JAR files. The key should be SHA-1 encoded. Requires Java Development Kit (JDK). ```bash keytool -genkey -alias signFiles -keystore examplestore.jks ``` -------------------------------- ### ResourceLocation Structure and Usage in Minecraft Source: https://docs.minecraftforge.net/en/1.13.x/models/introduction Demonstrates the structure of a ResourceLocation, which is used to identify files within Minecraft's asset system. It consists of a namespace and a path, typically formatted as 'namespace:path'. The namespace usually defaults to 'minecraft' if not specified, and paths are context-sensitive, often resolved under 'models' or 'textures'. All string components should be in snake_case. ```Java public class ResourceLocation { private final String namespace; private final String path; public ResourceLocation(String namespace, String path) { this.namespace = namespace; this.path = path; } public ResourceLocation(String path) { this("minecraft", path); } public String getNamespace() { return namespace; } public String getPath() { return path; } @Override public String toString() { return namespace + ":" + path; } } ``` -------------------------------- ### Default Capability Implementation Factory Source: https://docs.minecraftforge.net/en/1.13.x/datastorage/capabilities Shows how to create a factory for the default capability implementation. This factory implements the Callable interface to return new instances of the capability. ```java private static class Factory implements Callable { @Override public IExampleCapability call() throws Exception { return new Implementation(); } } ``` -------------------------------- ### Getting Property Value (Java) Source: https://docs.minecraftforge.net/en/1.13.x/blocks/states Illustrates how to retrieve the value of a specific property from an IBlockState object. This is useful for checking the current state of a block. ```java Integer value = blockState.get(PROPERTY_INTEGER); ``` -------------------------------- ### TextComponentHelper Create Method (Java) Source: https://docs.minecraftforge.net/en/1.13.x/concepts/internationalization Demonstrates using `TextComponentHelper.createComponentTranslation` in Java to create a localized and formatted `ITextComponent`, adapting to vanilla clients or using lazy localization. ```java net.minecraft.util.text.TextComponentHelper.createComponentTranslation(commandSender, "your.translation.key", arg1, arg2); ``` -------------------------------- ### ICustomModelLoader Interface Methods Source: https://docs.minecraftforge.net/en/1.13.x/models/advanced/icustommodelloader Demonstrates the core methods of the ICustomModelLoader interface: accepts, loadModel, and onResourceManagerReload. These methods are essential for custom model loading logic. ```java /** * Tests whether this ICustomModelLoader is willing to load the given ResourceLocation. * Preferably, this should be based on the ResourceLocation alone and not on the file contents. * If two ICustomModelLoaders accept the same ResourceLocation, a LoaderException is thrown. * Therefore, care should be taken to make sure that the namespace of the ICustomModelLoader is unique enough to avoid collisions. */ boolean accepts(ResourceLocation modelLocation); /** * Get the model for the given ResourceLocation. * Note that it doesn’t need to “load” anything. * For example, completely in-code models will simply instantiate the IModel class and totally ignore the file. */ IModel loadModel(ResourceLocation modelLocation) throws Exception; /** * Called whenever the resource packs are (re)loaded. * In this method, any caches the ICustomModelLoader keeps should be dumped. * Following this, loadModel will be called again to reload all the IModels, so if the IModels kept some caches in themselves, they do not need to be cleared. */ void onResourceManagerReload(ResourceManager resourceManager); ``` -------------------------------- ### Creating and Referencing SoundEvents in Java Source: https://docs.minecraftforge.net/en/1.13.x/effects/sounds Demonstrates how to create a `ResourceLocation` for a sound event and subsequently instantiate a `SoundEvent` object in Java. This `SoundEvent` serves as a reference for playing sounds. ```java ResourceLocation location = new ResourceLocation("mymod", "open_chest"); SoundEvent event = new SoundEvent(location); ``` -------------------------------- ### Minecraft Forge @Mod Annotation Source: https://docs.minecraftforge.net/en/1.13.x/gettingstarted/structuring The @Mod annotation marks a class as a Forge Mod entry point, carrying essential metadata and receiving event notifications. Key properties include modid, name, version, dependencies, and configuration for client/server sides. ```java @Mod( modid = "my_mod_id", name = "My Mod Name", version = "1.0.0", dependencies = "required-after:forge@[14.23.5.2860,)", useMetadata = true, clientSideOnly = false, serverSideOnly = false, acceptedMinecraftVersions = "[1.13]", acceptableRemoteVersions = "*", acceptableSaveVersions = "", certificateFingerprint = "", modLanguage = "java", modLanguageAdapter = "", canBeDeactivated = false, guiFactory = "com.example.MyGuiFactory", updateJSON = "http://example.com/updates.json" ) public class MyMod { // Mod content here } ``` -------------------------------- ### Create SimpleChannel Instance (Java) Source: https://docs.minecraftforge.net/en/1.13.x/networking/simpleimpl Defines a static SimpleChannel instance for sending custom packets. It requires a unique name, a protocol version supplier, and predicates for version compatibility checks. ```java private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel INSTANCE = NetworkRegistry.newSimpleChannel( new ResourceLocation("mymodid", "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); ``` -------------------------------- ### Accessing Unlisted Property in IBakedModel (Java) Source: https://docs.minecraftforge.net/en/1.13.x/models/advanced/extended-blockstates Example of retrieving an unlisted property from an IExtendedBlockState within a custom IBakedModel to select a submodel for rendering. It handles null states and uses a fallback model. ```java import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Nullable; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.EnumFacing; import net.minecraftforge.client.model.pipeline.IVertexConsumer; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IUnlistedProperty; public class CustomBakedModel implements IBakedModel { private final Map submodels = new HashMap<>(); // populated in a custom manner out of the scope of this article public static final IUnlistedProperty UNLISTED_PROP = new IUnlistedProperty() { @Override public String getName() { return "unlisted_prop"; } @Override public Class getType() { return String.class; } @Override public String getDefaultValue() { return "default"; } @Override public String toString() { return getName() + "(String)"; } }; @Override public List getQuads(@Nullable IBlockState state, EnumFacing facing, long rand) { IBakedModel fallback = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel(); if (state == null) return fallback.getQuads(state, facing, rand); IExtendedBlockState ex = (IExtendedBlockState) state; String id = ex.getValue(UNLISTED_PROP); return submodels.getOrDefault(id, fallback).getQuads(state, facing, rand); } // Other IBakedModel methods would be implemented here... @Override public boolean isAmbientOcclusion() { return false; } @Override public boolean isGui3d() { return false; } @Override public boolean isBuiltInRenderer() { return false; } @Override public net.minecraft.client.renderer.texture.TextureAtlasSprite getParticleTexture() { return Minecraft.getMinecraft().getTextureMapBlocks().getMissingTexture(); } @Override public void addInformation(net.minecraft.util.math.BlockPos blockPos, IBlockState iBlockState, java.util.List list, boolean b) {} @Override public net.minecraft.client.renderer.model.ItemCameraTransforms getItemTransform() { return net.minecraft.client.renderer.model.ItemCameraTransforms.DEFAULT; } @Override public net.minecraft.client.renderer.model.ItemOverrideList getOverrides() { return net.minecraft.client.renderer.model.ItemOverrideList.EMPTY; } @Override public void addVertexForFace(net.minecraft.client.renderer.vertex.VertexFormat vertexFormat, int i, int j, int k, int l, int m, int n, int o, float f, float f1, float f2, int p, int q, int r) {} @Override public boolean requiresPerVertexLighting() { return false; } @Override public void useExternalTESR(IVertexConsumer consumer) { // Not implemented for this example } } ``` -------------------------------- ### Get Loot Table by ResourceLocation - Java Source: https://docs.minecraftforge.net/en/1.13.x/items/loot_tables Retrieves a loot table from the game's resource manager using its ResourceLocation. This requires an active World instance to access the LootTableManager. The ResourceLocation specifies the mod and the loot table name. ```Java LootTable table = this.world.getLootTableManager().getLootTableFromLocation(new ResourceLocation("mymod:my_table")); // resolves to /assets/mymod/loot_tables/my_table.json ``` -------------------------------- ### Maven Coordinate Format Source: https://docs.minecraftforge.net/en/1.13.x/gettingstarted/dependencymanagement Defines the standard format for identifying artifacts within the Forge mod repository. This format is crucial for Forge to correctly archive, manage, and load mods and libraries. ```text groupId:artifactId:version:classifier@extention ``` -------------------------------- ### Create a TileEntityRendererFast (Java) Source: https://docs.minecraftforge.net/en/1.13.x/tileentities/tesr Shows how to implement a faster TileEntityRenderer by extending `TileEntityRendererFast` and `IForgeTileEntity#hasFastRenderer`. This approach batches rendering calls for improved performance but restricts direct OpenGL access. ```Java public class MyFastTER extends TileEntityRendererFast { @Override public void renderTileEntityFast(MyTileEntity tileEntity, double x, double y, double z, float partialTicks, int destroyStage, VertexBuffer buffer) { // Custom rendering logic using VertexBuffer } } // Ensure your TileEntity implements IForgeTileEntity with hasFastRenderer returning true: public class MyTileEntity extends TileEntity implements IForgeTileEntity { @Override public boolean hasFastRenderer() { return true; } // ... other TileEntity methods ... } // Registration is the same as a regular TER: ClientRegistry.bindTileEntitySpecialRenderer(MyTileEntity.class, new MyFastTER()); ``` -------------------------------- ### I18n Formatting (Client-Side Java) Source: https://docs.minecraftforge.net/en/1.13.x/concepts/internationalization Shows how to use the `I18n` class on the Minecraft client to localize and format text using a translation key and arguments. ```java String localizedText = net.minecraft.client.resources.I18n.format("your.translation.key", arg1, arg2); ``` -------------------------------- ### Loading ASM with Parameters - Java Source: https://docs.minecraftforge.net/en/1.13.x/animation/asm Demonstrates how to load an Animation State Machine (ASM) file using the ModelLoaderRegistry.loadASM method. It includes passing load-time parameters, specifically a VariableValue, to customize animation behavior. This is a client-side only API. ```java import net.minecraft.util.ResourceLocation; import com.google.common.collect.ImmutableMap; import net.minecraftforge.common.animation.facades.IAnimationStateMachine; import net.minecraftforge.common.animation.variable.VariableValue; // ... within a class ... @Nullable private final IAnimationStateMachine asm; private final VariableValue cycle = new VariableValue(4); public Spin() { asm = proxy.loadASM(new ResourceLocation(MODID, "asms/block/rotatest.json"), ImmutableMap.of("cycle_length", cycle)); } ``` -------------------------------- ### Registering Item Variants - Forge Java Source: https://docs.minecraftforge.net/en/1.13.x/models/advanced/introduction Manually marks models for loading for items in Minecraft Forge. This is crucial for custom item models. ```java ModelLoader.registerItemVariants(item, new ModelResourceLocation(item.getRegistryName(), "inventory")); ``` -------------------------------- ### Registering Event Handlers Source: https://docs.minecraftforge.net/en/1.13.x/events/intro Demonstrates how to register both instance and static event handlers to the MinecraftForge.EVENT_BUS. The registration process involves passing either an instance of the handler class or the class itself. ```java // For instance handlers: MinecraftForge.EVENT_BUS.register(new MyForgeEventHandler()); // For static handlers: MinecraftForge.EVENT_BUS.register(MyStaticForgeEventHandler.class); ``` -------------------------------- ### Implement IForgeRegistryEntry.Impl for Registration Source: https://docs.minecraftforge.net/en/1.13.x/concepts/registries Illustrates the recommended way to make a class eligible for registry by extending IForgeRegistryEntry.Impl. This provides default implementations for registry name handling. ```java public class MyObject extends IForgeRegistryEntry.Impl { // ... your class implementation ... public MyObject() { // The setRegistryName method can be called here or automatically // when using the default constructor of Impl if the modid is known. // For explicit naming: // this.setRegistryName("mymod", "my_object_name"); } } ``` -------------------------------- ### Send Packet to Server (Java) Source: https://docs.minecraftforge.net/en/1.13.x/networking/simpleimpl Demonstrates how to send a custom message packet from a client to the server using the established SimpleChannel instance. ```java INSTANCE.sendToServer(new MyMessage()); ``` -------------------------------- ### Accessing ModelManager - Forge Java Source: https://docs.minecraftforge.net/en/1.13.x/models/advanced/introduction Provides methods to access the ModelManager in Minecraft Forge, necessary for interacting with the model system. ```java Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager() ``` ```java Minecraft.getMinecraft().getBlockRenderDispatcher().getBlockModelShapes().getModelManager() ```