banner



How To Register Items Forge 1.12 Mod

This article is about creating mods for Java Edition. For the Bedrock Edition add together-ons, see Add-on.

Paper JE2 BE2.png

Information icon.svg

Gear (item).gif

This commodity is a work in progress.

Please help in the expansion or creation of this article by expanding or improving it. The talk page may contain suggestions.

Contents

  • ane Overview
    • 1.1 Things you are not to practise
  • 2 Commencement steps with Forge
    • ii.1 A note well-nigh placeholders
    • ii.2 1. Create a folder for your project
    • ii.3 2. Obtain a "source distribution"
    • 2.4 3. Copy key files to your projection binder
    • 2.5 three½. A note about mappings
    • 2.six 4. Import the gradle projection
    • 2.7 5. Designate the JDK
    • 2.8 6. Gear up upward workspace
    • two.9 vii. Configure Run settings
  • three Creating a mod for Forge
    • 3.1 Identifying your mod
    • iii.2 Setting up Item Registration
      • three.2.1 JSON and Texture Files
        • 3.2.1.1 Language File
        • 3.two.1.2 Particular Model File
        • three.2.1.3 Texture File
    • 3.3 Creating a Custom Block
      • 3.3.1 Setting up Block Registration
      • three.3.2 Registering the Custom Block
        • 3.3.2.one Blockstates JSON
        • 3.3.2.2 Language File
        • 3.iii.2.three Block Model JSON
        • three.iii.2.4 Associated Particular Model JSON
        • three.iii.2.5 Texture
    • three.4 Creating a Custom Tool
      • 3.4.1 Custom Layers over Vanilla Textures
      • 3.iv.2 Textures from Scratch
    • iii.5 Creating a Custom Mob
      • 3.5.1 Models from Scratch
    • 3.6 Creating a Config file
    • 3.seven Sharing Your Mod
  • 4 Further Reading
  • 5 Additional Info
  • half-dozen See also

Overview [ ]

Mods (short for 'modifications') can modify or add items, blocks, entities, and much more. Presumably, you already have an idea for a mod y'all want to create. If you simply want to add custom advancements, functions, loot tables, structures, recipes or tags to your game, look into how to make a Data pack, which does not require programming. Or look into how to make a resource pack if you lot simply want to customize textures (colors and designs), models, music, sounds, languages, splashes, fonts, or the end verse form. Or mayhap yous desire to 'fork' a favorite mod to update for newer versions of Minecraft. In any case, this guide will eventually cover simply the virtually basic elements of creating an item and creating an entity (a moving thing similar a villager, sheep, zombie, etc.), and distributing the resulting mod package.

Minecraft mods consist of jar files (example: yournewmod.jar) which contain class files, JSON files, and image files, to proper noun a few of the most mutual.

  • Grade files are specific to the Coffee programming language. A few Java tutorials to endeavor are w3schools (web and mobile), SoloLearn (web and mobile), and kodevelopment(web). You will need an IDE (Integrated Evolution Environment) such as IntelliJ or Eclipse to read or create class files. This tutorial will focus on IntelliJ Idea Community Edition 2019.
  • JSON files are a means of detailing the characteristics of objects used by Java course files. JSON is much simpler than Coffee. You will need a text editor such as Notepad++, Vim, or Emacs to read or create JSON files. Yous probably already take a bones text editor on your computer, merely in that location are many advantages to using other ones instead.
  • Image files you may exist familiar with include .bmp and .jpg formats, but Minecraft requires .png format (example: yournewlogo.png) in multiples of sixteen pixels square (case: 16x16, 32x32, 64x64). You will need an image editor such as Paint.NET or GIMP to edit or create .png files. Y'all probably already have MS Paint on your reckoner, but GIMP has so much more functionality, and Paint.NET is quite convenient. There are besides several websites with tools for creating pixel fine art.

If yous have been playing Minecraft Coffee Edition, you probably already accept JRE (Coffee Runtime Environment). To develop a mod, y'all will need to find JDK (Java Development Kit), which includes the JRE and an emulator. Create a gratuitous account at oracle.com and download JDK Standard Edition version eight. Then follow the instructions for installing it, and brand note of the location information technology installs to. Pay detail attention to the section on Updating the PATH Environment Variable.

With a Java Development Kit installed, and the IntelliJ Integrated Development Environment to manipulate Java with, you lot now have the tools to develop custom software that can be used in a multifariousness of applications. While working on a mod, go on working through Java tutorials. The lessons will enable you to put your ideas into activeness, while the ideas will make the lessons more interesting and memorable.

One more tool y'all should fix before starting a mod is the Forge MDK (Mod Development Kit). Forge is a collection of useful resources and modern loader, designed specifically to simplify compatibility betwixt Minecraft Java Edition and multiple community-created mods. This tutorial will focus on the MDK for version 1.12.2 of Minecraft Java Edition, although Forge for ane.fourteen.4 has been around for some time. An alternative to Forge is Fabric, but Java is nevertheless used to lawmaking mods either way.

Things you are not to do [ ]

At that place are some things that you should exist conscientious to not practise when creating a mod. Keep this list in heed:

  • Don't do annihilation that violates Mojang Studios' terms of use for Minecraft.
  • Don't release Minecraft versions or modifications that let you to play without having bought Minecraft from Mojang Studios.
  • Don't release the de-compiled source code of Minecraft in whatsoever way.
  • Don't alter existing mods without permission from that modernistic'due south author(south). Check their License, usually available in the author's GitHub repository. If you lot can't notice the license, and so yous exercise not have permission to share a modified version with anybody. Y'all may tinker with the files for personal utilize only.

First steps with Forge [ ]

This wiki article aims to provide a foolproof walk-through of a few key elements of Forge'due south tutorial: https://mcforge.readthedocs.io. Bookmark their page, every bit information technology addresses many problems this article will not. Moreover, there'due south more than one valid way to accomplish the desired result; this wiki article will focus on the simplest, which is probably not the most efficient or elegant. If yous follow precisely the steps outlined hither, you should soon have a functional modernistic, which you can then tinker with to your heart's content. If y'all use Linux, Forge'southward tutorial will probably exist more useful for you. If y'all use Windows, read on.

A note well-nigh placeholders [ ]

This tutorial will use "You" to represent the User profile you are logged in with; if you copy-paste paths from this tutorial, be certain to supercede "You" with your own Windows username. This tutorial will use "yournewmod" to represent sections y'all should supplant with the modern proper name yous choose for your projection.

1. Create a folder for your project [ ]

Navigate to C:/Users/You lot/Documents and create a new folder. The name of this folder may be changed easily later.

2. Obtain a "source distribution" [ ]

Visit https://files.minecraftforge.net and make certain the version selected is the version for which y'all want to create a mod. In the large "Download Recommended" box, click on the small MDK box. A dialog box volition appear, asking where you lot want to save the file, and what to name it. Choose whatsoever convenient location, but leave the name unchanged.

three. Copy key files to your project binder [ ]

Open up the forge-1.16.five-...-mdk folder (with or without unzipping information technology first) and copy-paste the following 5 files from this folder[ more information needed ] to the project folder y'all created in the beginning step:

  • the src folder
  • the gradle folder
  • gradlew
  • gradlew.bat
  • build.gradle

iii½. A note about mappings [ ]

There are two different sets of mappings available for method names - "MCP" community-based mappings, and "Official" mappings based in function on the official Obfuscation maps (though class names are different for technical reasons). The default in the MDK has recently been changed to 'official', but this tutorial will utilise the MCP mappings for now because role parameter names are not available in the official mappings.

Modify the following line in build.gradle line 34

                        mappings            channel            :            '            official            '            ,            version            :            '            i.16.5            '          

to

                        mappings            aqueduct            :            '            snapshot            '            ,            version            :            '            20210309            -            one.16.v            '          

On line 51 of ExampleMod.java, change options to gameSettings (or simply annotate or delete the line)

four. Import the gradle project [ ]

Open up/Run the IntelliJ Thought program. In the landing screen, click on Open up. A dialog box will announced, asking which file to import. Navigate to your projection folder and select "build.Gradle," then click OK.

five. Designate the JDK [ ]

In the side by side window, click in the "Gradle JVM" field and navigate to the JDK files y'all installed earlier. If you got version 8 update 282, select the folder named "jdk1.viii.0_282." Click OK and wait for the build to end, Showing the results in the bottom field.

[TODO: I didn't get another window, need to verify what happens on a fresh Thought install]

[Note: Confirming that on IntelliJ IDEA 2021.1.2 window doesn't appear, nigh likely that it detects JDK itself, so it will only appear if information technology failed to locate appropriate JDK]

6. Set upwardly workspace [ ]

No Dependencies needed to be Installed. Move to adjacent step as new update in Forge command setupDecompWorkspace is not needed

vii. Configure Run settings [ ]

Subsequently refreshing gradle, open the gradle panel and double-click the "genIntellijRuns" entry in the "fg_runs" folder. This will create new run configurations that allow your mod to be run. Next, open the "Edit configurations" window of Run settings and look approximately halfway downwardly, for "Use classpath of module." Click on its dropdown field, and select the option that ends with .main, then click Employ. If the settings you just finished editing were for the Minecraft Client, click on Minecraft Server and repeat the steps to gear up the classpath. [TODO: Is this necessary anymore? Information technology was already ready]

Yous tin can now select and run runClient in the run configuration drop downwards carte. This will kickoff the Launcher with your modernistic included. When yous go to the landing menu, yous tin check whether your mod is present.

Creating a mod for Forge [ ]

Identifying your mod [ ]

Gear (item).gif

This section is a work in progress.

Please help in the expansion or creation of this article by expanding or improving it. The talk folio may comprise suggestions.

The project equally delivered with the MDK is called "examplemod" with the packet name "com.case.examplemod". You volition need to rename this to your own names in the following places - rename the class files - build.gradle - META-INF/mods.toml

Package names should be based on a domain proper name in reverse club, or a proper noun that is non a valid domain name if yous do non own a domain name.

[TODO clearer instructions, set MODID variable]

Setting upwardly Item Registration [ ]

Gear (item).gif

This department is a work in progress.

Please help in the expansion or creation of this article by expanding or improving it. The talk page may contain suggestions.

You can create a class to put your definitions in. Here we telephone call it ModItems, though in theory y'all could but add information technology to the main course. Having at least one class file (or, ideally, a package) to put registrations in without any non registration related code provides better organisation for when you expand your mod.

Firstly, create a DeferredRegister of type Detail. This is effectively a list that is used to register items. Then, in social club to annals an detail, create a RegistryObject as shown beneath.

                        package            com.example.examplemod            ;            import            cyberspace.minecraft.item.Item            ;            import            internet.minecraft.item.ItemGroup            ;            import            net.minecraftforge.fml.RegistryObject            ;            import            internet.minecraftforge.registries.DeferredRegister            ;            import            cyberspace.minecraftforge.registries.ForgeRegistries            ;            public            class            ModItems            {            public            static            last            DeferredRegister            <            Item            >            ITEMS            =            DeferredRegister            .            create            (            ForgeRegistries            .            ITEMS            ,            ExampleMod            .            MOD_ID            );            public            static            final            RegistryObject            <            Particular            >            ITEM_NAME            =            ITEMS            .            annals            (            "ITEM_NAME"            ,            ()            ->            new            Item            (            new            Item            .            Properties            ().            tab            (            CreativeModeTab            .            TAB_MISC            )));            }          

If you want to add more options add . [dot] at the end of ,, CreativeModeTab.TAB_MISC) "

when its completed register item in your item course like this:

                        public            static            void            register            (            IEventBus            eventBus            ){            ITEMS            .            register            (            eventBus            );            }          

then in your main form constructor add the lawmaking to create an outcome jitney and register:

                        IEventBus            eventBus            =            FMLJavaModLoadingContext            .            get            ().            getModEventBus            ();            ModItems            .            annals            (            eventBus            );          

or you can do with this lawmaking below.

In your master form, set it upwards to automatically be called at the appropriate time, in the public ExampleMod() constructor:

                        ModItems            .            ITEMS            .            register            (            FMLJavaModLoadingContext            .            become            ().            getModEventBus            ());          

And now you need to interpret this item. Inside resources add together a directory named assets and inside add lang like this

JSON and Texture Files [ ]

Language File [ ]

resource\assets\examplemod\lang\en_us.json (<- en_us.json is the language)

within en_us.json write:

                        {            "detail.examplemod.ITEM_NAME"            :            "TRANSLATED_NAME"            ,            }          

the item.examplemod.ITEM_NAME needs to lucifer the proper name you put within ModItems class [where your items are].

Item Model File [ ]

resources\assets\examplemod\models\particular\item_name.json

Inside add together the following.

                        {            "parent"            :            "detail/generated"            ,            "textures"            :            {            "layer0"            :            "tutorialmod:item/item_name"            }            }          

detail/generated is the default with no special features for rendering.

Texture File [ ]

resources\assets\examplemod\textures\item\item_name.png

This is where yous should add your texture paradigm file.

Creating a Custom Block [ ]

Setting up Cake Registration [ ]

Firstly, create a new DeferredRegister of type cake which will be used to annals any blocks. Make certain to import internet.minecraft.block rather than any of the other options.

                        public            static            terminal            DeferredRegister            <            Cake            >            BLOCKS            =            DeferredRegister            .            create            (            ForgeRegistries            .            BLOCKS            ,            ExampleMod            .            MOD_ID            );          

Side by side, you lot need to annals the method with the IEventBus parameter. If you have a separate ModBlocks class then add the post-obit method to information technology, otherwise add it to your already existing register method.

                        public            static            void            annals            (            IEventBus            eventBus            )            {            BLOCKS            .            register            (            eventBus            );            }          

To create blocks hands add together the following two helper methods to your class. registerBlock registers the block while registerBlockItem registers the associated item.

                        private            static            <            T            extends            Block            >            RegistryObject            <            T            >            registerBlock            (            String            proper name            ,            Supplier            <            T            >            block            )            {            RegistryObject            <            T            >            toReturn            =            BLOCKS            .            register            (            name            ,            cake            );            registerBlockItem            (            proper name            ,            toReturn            );            return            toReturn            ;            }            individual            static            <            T            extends            Block            >            void            registerBlockItem            (            String            name            ,            RegistryObject            <            T            >            block            )            {            ModItems            .            ITEMS            .            register            (            name            ,            ()            ->            new            BlockItem            (            block            .            get            (),            new            Item            .            Properties            ().            grouping            (            ModItemGroup            .            TUTORIAL_GROUP            )));            }          

Finally, like with items add the register call to your main course.

                        ModBlocks            .            register            (            eventBus            );          

Registering the Custom Block [ ]

The following lawmaking shows how to add together a simple block.

                        public            static            final            RegistryObject            <            Block            >            EXAMPLE_BLOCK            =            registerBlock            (            "example_block"            ,            ()            ->            new            Block            (            AbstractBlock            .            Properties            .            create            (            Material            .            Rock            ).            harvestLevel            (            ii            ).            harvestTool            (            ToolType            .            PICKAXE            ).            setRequiresTool            ().            hardnessAndResistance            (            5f            )));          
Blockstates JSON [ ]

resource/assests/examplemod/blockstates/example_block.JSON

                        {            "variants"            :            {            ""            :            {            "model"            :            "examplemod:block/example_block"            }            }            }          
Language File [ ]

resource\assets\examplemod\lang\en_us.json (<- en_us.json is the linguistic communication)

                        "block.examplemod.example_block"            :            "Example Block"            ,          
Block Model JSON [ ]

resources\assets\examplemod\models\block\example_block.json

                        {            "parent"            :            "cake/cube_all"            ,            "textures"            :            {            "all"            :            "examplemod:cake/example_block"            }            }          
Associated Particular Model JSON [ ]

resources\avails\examplemod\models\item\example_block.json

                        {            "parent"            :            "examplemod:block/example_block"            }          
Texture [ ]

resources\assets\examplemod\textures\block\example_block.png

Put your texture epitome here.

Creating a Custom Tool [ ]

Allow's make a uncomplicated spear, with damage ability similar to a stone sword.

So, to get-go off with we demand to make a new directory called tools in your package. Side by side create a new Java enum called ModItemTier. In this file you demand to type a variant of the following:

                        package            com.example.examplemod            ;            import            mcp.MethodsReturnNonnullByDefault            ;            import            internet.minecraft.particular.IItemTier            ;            import            cyberspace.minecraft.item.Items            ;            import            net.minecraft.item.crafting.Ingredient            ;            import            java.util.function.Supplier            ;            @MethodsReturnNonnullByDefault            public            enum            ModItemTier            implements            IItemTier            {            CUSTOMNAMEHERE            (            one            ,            131            ,            4.0F            ,            3.0F            ,            v            ,            ()            ->            Ingredient            .            fromItems            (            Items            .            FLINT            ));            individual            final            Supplier            <            Ingredient            >            repairmaterial            ;            private            concluding            int            enchantability            ;            individual            final            float            attackDamage            ;            private            final            float            efficiency            ;            private            concluding            int            maxUses            ;            private            final            int            harvestLevel            ;            ModItemTier            (            int            harvestLevel            ,            int            maxUses            ,            float            efficiency            ,            float            attackDamage            ,            int            enchantability            ,            Supplier            <            Ingredient            >            repairmaterial            )            {            this            .            harvestLevel            =            harvestLevel            ;            this            .            maxUses            =            maxUses            ;            this            .            efficiency            =            efficiency            ;            this            .            attackDamage            =            attackDamage            ;            this            .            enchantability            =            enchantability            ;            this            .            repairmaterial            =            repairmaterial            ;            }            @Override            public            int            getMaxUses            ()            {            return            this            .            maxUses            ;            }            @Override            public            float            getEfficiency            ()            {            return            this            .            efficiency            ;            }            @Override            public            float            getAttackDamage            ()            {            return            this            .            attackDamage            ;            }            @Override            public            int            getHarvestLevel            ()            {            return            this            .            harvestLevel            ;            }            @Override            public            int            getEnchantability            ()            {            render            this            .            enchantability            ;            }            @Override            public            Ingredient            getRepairMaterial            ()            {            render            this            .            repairmaterial            .            get            ();            }            }          

Next, you need to register your item. Become to your item registry class[?] and make a new detail like the i hither:

                        public            static            final            RegistryObject            <            SwordItem            >            NAME_SPEAR            =            ITEMS            .            annals            (            "name_spear"            ,            ()            ->            new            SwordItem            (            ModItemTier            .            CUSTOMNAMEHERE            ,            5            ,            -            2.8f            ,            (            new            Detail            .            Properties            ()).            tab            (            ItemGroup            .            TAB_COMBAT            )));          

.

The numbers are the base attack impairment [added to the damage set in the ItemTier] and the speed modifier, the values chosen for the example are intermediate between a sword and an axe.

Afterwards this, y'all need to brand a JSON file in src/main/resources/avails/examplemod/models/item called what you gear up earlier, similar then:

                        {            "parent"            :            "detail/handheld"            ,            "textures"            :            {            "layer0"            :            "examplemod:item/name_spear"            }            }          

Then, become to your textures folder and input the texture you will make in the next stride. If you want to know more nearly immovability I recommend this page.

Custom Layers over Vanilla Textures [ ]

Gear (item).gif

This department is a work in progress.

Please help in the expansion or creation of this article by expanding or improving information technology. The talk folio may incorporate suggestions.

Textures from Scratch [ ]

Open an image editor, preferably one that supports transparency, and create a new epitome, with a size that is a multiple of 16x16 (eg. 32x32, 64x64. etc.)

Creating a 32x32 pixel canvas in GIMP

This example is using a 32x32 pixel prototype and is fabricated in GIMP.

Create your file, making sure it is in pixels and not inches, millimetres, or whatever other measurement.

Create a new layer, and delete the original canvas. If yous don't practice that, and then your epitome volition take a white groundwork.

Using a brush of 1x1 pixel, start cartoon your item. Make sure to utilise divide layers for split parts of the particular to allow changes to exist made easier.


When y'all're done creating your fine art, press file to save. If you're using GIMP or some other avant-garde editor, it won't salvage every bit a .png. For GIMP, information technology saves as a .xcf.

With the spear done, press file and then relieve. Note the lack of white in the background, and instead the bare .png background.

Navigate to the export dropdown or press ctrl+e on Windows or ⌘+E for macOS. This is to export the file. Make sure you export as a .png, not a .jpg or any other file extension. If information technology is non saved as a .png, it volition take a white background and won't expect right.

Exporting the art of the stone spear to desktop. Notation that information technology is being exported as a .png. Certain parts censored for privacy.


If you're following along with this tutorial and wish to use this epitome, you tin download this finished pixel fine art here.

Creating a Custom Mob [ ]

Models from Scratch [ ]

The best style to model mobs is probably blockbench (blockbench website). Blockbench is a costless modeling tool, and information technology would exist much faster and easier than taking the other arroyo, which is irksome. If you want to model with it, simply brand a cube, position it, rotate it, size information technology, and make your model the way you want to make it. If you demand more cubes, you lot can easily make a new one. This is probably the best method for this. It is fast, easy, and customizable.

Creating a Config file [ ]

Gear (item).gif

This section is a piece of work in progress.

Please aid in the expansion or creation of this article by expanding or improving it. The talk page may contain suggestions.

Sharing Your Modern [ ]

Gear (item).gif

This section is a piece of work in progress.

Please help in the expansion or creation of this article by expanding or improving it. The talk page may contain suggestions.

To build your mod, run gradlew build or ./gradlew build for macOS. This will output a file in build/libs with the name [archivesBaseName]-[version].jar. This file can exist placed in the mods folder of a forge enabled Minecraft setup, and distributed. And so you tin can upload your mod to CurseForge

Further Reading [ ]

Gear (item).gif

This section is a work in progress.

Please aid in the expansion or creation of this article past expanding or improving it. The talk page may contain suggestions.

https://mcforge.readthedocs.io/en/latest/gettingstarted/

Additional Info [ ]

Gear (item).gif

This section is a work in progress.

Please help in the expansion or creation of this article past expanding or improving it. The talk page may contain suggestions.

Recommended:

  • create a GitHub business relationship to manage versions of your modernistic and collaborate with other developers.
  • further tutorials (in video course, for version i.15.2)
  • text tutorials for ane.sixteen.v, ane.17.1, and i.xviii.2

Come across also [ ]

  • Tutorials/Loading a resource pack
  • Tutorials/Creating a resources pack
  • Tutorials/Installing a data pack
  • Tutorials/Creating a data pack

How To Register Items Forge 1.12 Mod,

Source: https://minecraft.fandom.com/wiki/Tutorials/Creating_Forge_mods

Posted by: martinezbain1998.blogspot.com

0 Response to "How To Register Items Forge 1.12 Mod"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel