• Farming Simulator 2019 Mods
  • Game Mods
  • Minecraft Mods
  • News
  • Contact
  • Privacy Policy

Farming Simulator Mods - Game Mods

Gamerzdl.net

  • Farming Simulator 2019 Mods
  • Game Mods
  • Minecraft Mods
  • News
  • Contact
  • Privacy Policy
Home » Game Mods » How to Create Forge Mods: A Comprehensive Guide

How to Create Forge Mods: A Comprehensive Guide

02/07/2022 02/07/2022 admingamer 0 comment

Mods (short for ‘modifications’) can modify or add items, blocks, entities, and much more. Presumably, you already have an idea for a mod you want to create. If you’re looking to simply 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 if textures (colors and designs), models, music, sounds, languages, splashes, fonts are what you’re interested in – take a look at how to make a resource pack. Forking a favorite mod so it’s updated for newer versions of Minecraft is another popular option. In any case this guide will eventually cover only the most basic elements of

Creating a mod for Forge 1.12.2

Identifying your mod

This section 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.

The project as delivered with the MDK is called “examplemod” with the package name “com.example.examplemod”. You will 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 name in reverse order, or a name that is not a valid domain name if you do not own a domain name.

[TODO clearer instructions, set up MODID variable]

Setting up Item Registration

This section 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 call it ModItems, though in theory you could just add it to the main class. Having at least one class file (or, ideally, a package) to put registrations in without any non registration related code provides better organization for when you expand your mod.

Firstly, create a DeferredRegister of type Item. This is effectively a list that is used to register items. Then, in order to register an item, create a RegistryObject as shown below.

package com.example.examplemod;

import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

public class ModItems {
    public static final DeferredRegister<Item> ITEMS
        = DeferredRegister.create(ForgeRegistries.ITEMS, ExampleMod.MOD_ID);
            
    public static final RegistryObject<Item> ITEM_NAME = ITEMS.register("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 class like this:

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

then in your main class constructor add the code to create an event bus and register:

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

or you can do with this code below.

In your main class, set it up to automatically be called at the appropriate time, in the public ExampleMod() constructor:

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

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

JSON and Texture Files

Language File

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

inside en_us.json write:

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

the item.examplemod.ITEM_NAME needs to match the name you put inside ModItems class [where your items are].

Item Model File

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

Inside add the following.

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

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

Texture File

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

This is where you should add your texture image file.

Creating a Custom Block

Setting up Block Registration

Firstly, create a new DeferredRegister of type block which will be used to register any blocks. Make sure to import net.minecraft.block rather than any of the other options.

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

Next, you need to register the method with the IEventBus parameter. If you have a separate ModBlocks class then add the following method to it, otherwise add it to your already existing register method.

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

To create blocks easily add 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 name, Supplier<T> block) {
    RegistryObject<T> toReturn = BLOCKS.register(name, block);
    registerBlockItem(name, toReturn);
    return toReturn;
}
private static <T extends Block> void registerBlockItem(String name, RegistryObject<T> block) {
    ModItems.ITEMS.register(name, () -> new BlockItem(block.get(),
        new Item.Properties().group(ModItemGroup.TUTORIAL_GROUP)));
}

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

ModBlocks.register(eventBus);

Registering the Custom Block

The following code shows how to add a simple block.

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

resources/assests/examplemod/blockstates/example_block.JSON

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

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

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

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

{
  "parent": "block/cube_all",
  "textures": {
    "all": "examplemod:block/example_block"
  }
}
Associated Item Model JSON

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

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

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

Put your texture image here.

Creating a Custom Tool

Let’s make a simple spear, with damage ability similar to a stone sword.

So, to start off with we need to make a new directory called tools in your package. Next create a new Java enum called ModItemTier. In this file you need to type a variant of the following:

package com.example.examplemod;

import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.item.IItemTier;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;

import java.util.function.Supplier;

@MethodsReturnNonnullByDefault
public enum ModItemTier implements IItemTier {
    CUSTOMNAMEHERE(1, 131, 4.0F, 3.0F, 5, () -> Ingredient.fromItems(Items.FLINT));

    private final Supplier<Ingredient> repairmaterial;
    private final int enchantability;
    private final float attackDamage;
    private final float efficiency;
    private final 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() {
        return this.enchantability;
    }

    @Override
    public Ingredient getRepairMaterial() {
        return this.repairmaterial.get();
    }
}

Next, you need to register your item. Go to your item registry class[?] and make a new item like the one here:

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

.

The numbers are the base attack damage [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.

After this, you need to make a JSON file in src/main/resources/assets/examplemod/models/item called what you set earlier, like so:

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

Then, go to your textures folder and input the texture you will make in the next step. If you want to know more about durability I recommend this page.

Custom Layers over Vanilla Textures

This section 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.

Textures from Scratch

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

Creating a 32×32 pixel canvas in GIMP

This example is using a 32×32 pixel image and is made in GIMP.

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

Create a new layer, and delete the original canvas. If you don’t do that, then your image will have a white background.

Using a brush of 1×1 pixel, start drawing your item. Make sure to use separate layers for separate parts of the item to allow changes to be made easier.

When you’re done creating your art, press file to save. If you’re using GIMP or another advanced editor, it won’t save as a .png. For GIMP, it saves as a .xcf.

With the spear done, press file and then save. Note the lack of white in the background, and instead the blank .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 it is not saved as a .png, it will have a white background and won’t look correct.

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

If you’re following along with this tutorial and wish to use this image, you can download this finished pixel art here.

Creating a Custom Mob

Models from Scratch

The best way to model mobs is probably blockbench (blockbench website). Blockbench is a free modeling tool, and it would be much faster and easier than taking the other approach, which is slow. If you want to model with it, simply make a cube, position it, rotate it, size it, and make your model the way you want to make it. If you need more cubes, you can easily make a new one. This is probably the best method for this. It is fast, easy, and customizable.

Click to rate this post!
[Total: 0 Average: 0]

Bài viết liên quan

Best Gaming Laptops You Can Find At CES 2023
Best Free Video Games To Play On Consoles And PCs 
How To Quit Twitter: Just Use These Simple Tools 

Categories: Game Mods


Buy iphone cũ Apple

Previous Post: « Download The Plantation v1.0.1
Next Post: NBA 2K22 FAQ: Your Guide to the Ultimate Basketball Game »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Social

  • Email
  • Facebook

Featured Post:

Best Gaming Laptops You Can Find At CES 2023

Best Free Video Games To Play On Consoles And PCs 

Apple Search Engine

Apple Is Up To Launching Its Own Search Engine 

Video Game Players in EU

EU Is Making An Effort To Protect Video Game Players More 

Categories

Keywords:

Adventure and RPG Cut Down Trees Mods DaftPVF's Mods Fly Mods fs19 mod Minecraft Minecraft 1.2.5 Mods Minecraft 1.4.7 Mods Minecraft 1.5.2 Mods Minecraft 1.6.2 Mods Minecraft 1.6.4 Mods Minecraft 1.7.2 Mods Minecraft 1.7.10 Mods Minecraft 1.8.9 Mods Minecraft 1.9.4 Mods Minecraft 1.9.4 ModsShaders Mods Minecraft 1.10.2 Maps Minecraft 1.10.2 Mods Minecraft 1.11.2 Maps Minecraft 1.11.2 Mods Minecraft 1.12 Mods Minecraft 1.12.1 Mods Minecraft 1.12.2 Mods Minecraft 1.13.2 Maps Minecraft 1.13.2 Mods Minecraft 1.14.2 Mods Minecraft 1.14.3 Mods Minecraft 1.14.4 Mods Minecraft 1.15.1 Mods Minecraft 1.15.2 Mods Minecraft 1.16.1 Mods Minecraft 1.16.2 Mods Minecraft 1.16.3 Mods Minecraft 1.16.4 Mods Minecraft 1.16.5 Mods Minecraft 1.17 Mods Minecraft 1.17.1 Mods Minecraft API Minecraft Core Minecraft Library Minecraft Mods minecraft mods pc Minecraft X-Ray Seasons X-Ray Mods

Footer

New post

  • Best Gaming Laptops You Can Find At CES 2023
  • Best Free Video Games To Play On Consoles And PCs 
  • Apple Is Up To Launching Its Own Search Engine 
  • EU Is Making An Effort To Protect Video Game Players More 
  • How To Quit Twitter: Just Use These Simple Tools 
  • OnlyFans Teams Up With Spring To Launch Its Own Shopping Feature

Most popular query

Builders shaders 1.16.5 download

jade mod 1.16.5

minecraft tme shaders 1.12.2

hwyla forge minecraft

Animaker 3.0 Future video making upgrade

Latest comment

    Search

    Gamerzdl.net | Farming simulator 2019 mods | FS19 mods | LS19 mods | Sitemap

    Go to mobile version