[Java] Let's create a mod for Minecraft 1.16.1 [Basic file]

(This article is one of a series of commentary articles)

First article: Introduction Previous article: Introduction Next article:

Basic file

We will set the basic files. There are files that I copied and pasted in Last time, so I will change these for myself.

package name

Package Naming Convention #% E3% 83% 91% E3% 83% 83% E3% 82% B1% E3% 83% BC% E3% 82% B8% E5% 91% BD% E5% 90% 8D% E8% A6% 8F If you read% E7% B4% 84), you will be required to avoid conflicts by using your domain as a namespace. However, I don't have a domain, so I did the following.

Change before

  └ com
      └ example
          └ examplemod
              └ ExampleMod.java

After change

  └ jp
     └ koteko
          └ liveinwater
              └ LiveInWater.java

assets folder, data folder

Create a ʻassets \ liveinwaterfolder to place files such as textures and sound effects, and adata \ liveinwater` folder to place files such as recipes and drop tables.

   ├ assets
   │  └ liveinwater
   ├ data
   │  └ liveinwater
   │   └ mods.toml
   └ pack.mcmeta

pack.mcmeta The pack.mcmeta file is a file that describes the details of the resource pack. For details, refer to Wiki. Since 1.15, pack_format is 5. The comment line is unnecessary, so delete it.

After change

    "pack": {
        "description": "live in water Mod resources",
        "pack_format": 5

mods.toml The mods.toml file is a file that contains mod information. In addition to information such as dependencies, the information displayed on the screen when the mod is installed is also included here, so change it if necessary. It's long, but the explanation of each item is only written in comments, so read it carefully and set it appropriately. mandatory is required and ʻoptional` is optional.


# This is an example mods.toml file. It contains the data relating to the loading mods.
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
# The overall format is standard TOML format, v0.5.0.
# Note that there are a couple of TOML lists in this file.
# Find more information on toml format here:  https://github.com/toml-lang/toml
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="[32,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license="MIT License"
# A URL to refer people to when problems occur with this mod
#issueTrackerURL="http://my.issue.tracker/" #optional
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
modId="liveinwater" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
version="${file.jarVersion}" #mandatory
 # A display name for the mod
displayName="live in water Mod" #mandatory
# A URL to query for updates for this mod. See the JSON update specification <here>
#updateJSONURL="http://myurl.me/" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
#displayURL="http://example.com/" #optional
# A file name (in the root of the mod JAR) containing a logo for display
#logoFile="examplemod.png " #optional
# A text field displayed in the mod UI
#credits="Thanks for this example mod goes to Java" #optional
# A text field displayed in the mod UI
#authors="Love, Cheese and small house plants" #optional
# The description text for the mod (multi line!) (#mandatory)
live in water
 – deep, silent, sea.
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.liveinwater]] #optional
    # the modid of the dependency
    modId="forge" #mandatory
    # Does this dependency have to exist - if not, ordering below must be specified
    mandatory=true #mandatory
    # The version range of the dependency
    versionRange="[32,)" #mandatory
    # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
    # Side this dependency is applied on - BOTH, CLIENT or SERVER
# Here's another dependency

Regarding license, if you think about distribution in the future, you should carefully read the reference page etc. in the comment and set it properly. (I'm not familiar with it, so I set it as the MIT License.) Other non-essential items are commented out as appropriate.

Main file

LiveInWater.java (originally ʻExampleMod.java`) is the main class of the mod. Erase things that are obviously not used and make them cleaner.


package jp.koteko.liveinwater;

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class LiveInWater
    private static final Logger LOGGER = LogManager.getLogger();

    public LiveInWater() {


    private void setup(final FMLCommonSetupEvent event)
        LOGGER.info("SETUP START");

        LOGGER.info("SETUP END");

    private void doClientStuff(final FMLClientSetupEvent event) {
        // do something that can only be done on the client

    private void enqueueIMC(final InterModEnqueueEvent event)
        // some example code to dispatch IMC to another mod

    private void processIMC(final InterModProcessEvent event)
        // some example code to receive and process InterModComms from other mods

    public void onServerStarting(FMLServerStartingEvent event) {
        LOGGER.info("server starting");

Make sure the filename (LiveInWater.java) matches the class name (public class LiveInWater) and the constructor (public LiveInWater ()). Also, make sure that the modId specification (@Mod ("liveinwater ")) is the same as the one in mods.toml edited above. The image of what this class is doing is to put four life cycles on a rail and insert that rail onto the Forge. I'm not familiar with these treatments yet, so I'll leave four for the time being. Also, I think there was a code to register the block at the end, but I deleted it on this file because it would be cleaner to prepare a separate class.

Start confirmation

Finally, make sure that the game starts just in case. Once started, open mods and verify that the information has been updated. キャプチャ.PNG VERSION is NONE, but since it is given when actually constructing the mod jar file, it is NONE here.


Structuring Your Mod - Forge Documentation [Java] Let's create a mod for Minecraft 1.14.4 [0. Basic file] Minecraft 1.14.4 Forge Mod Creation Part 2 [Basic File Arrangement]

Next article

Recommended Posts

[Java] Let's create a mod for Minecraft 1.14.4 [0. Basic file]
[Java] Let's create a mod for Minecraft 1.16.1 [Basic file]
[Java] Let's create a mod for Minecraft 1.14.4 [Introduction]
[Java] Let's create a mod for Minecraft 1.16.1 [Introduction]
[Java] Let's create a mod for Minecraft 1.14.4 [99. Mod output]
[Java] Let's create a mod for Minecraft 1.14.4 [4. Add tools]
[Java] Let's create a mod for Minecraft 1.14.4 [5. Add armor]
[Java] Let's create a mod for Minecraft 1.14.4 [7. Add progress]
[Java] Let's create a mod for Minecraft 1.14.4 [6. Add recipe]
[Java] Let's create a mod for Minecraft 1.16.1 [Add item]
[Java] Let's create a mod for Minecraft 1.14.4 [1. Add items]
[Java] Let's create a mod for Minecraft 1.14.4 [2. Add block]
[Java] Let's create a mod for Minecraft 1.16.1 [Add block]
[Java] Let's create a mod for Minecraft 1.14.4 [3. Add creative tab]
[Java] Let's create a mod for Minecraft 1.16.1 [Add and generate trees]
[Java] Let's create a mod for Minecraft 1.14.4 [9. Add and generate trees]
[Java] Let's create a mod for Minecraft 1.14.4 [8. Add and generate ore]
[Java] Create a temporary file
Let's create a Java development environment (updating)
Let's create a timed process with Java Timer! !!
Let's create a super-simple web framework in Java
[Java] Create a filter
Let's create a versatile file storage (?) Operation library by abstracting file storage / acquisition in Java
[Beginner] Create a competitive game with basic Java knowledge
[Java basics] Let's make a triangle with a for statement
Create a java method [Memo] [java11]
How to create a lightweight container image for Java apps
[Java twig] Create a parser combinator for recursive descent parsing 2
Create a MOB using the Minecraft Java Mythicmobs plugin | Preparation 1
Let's create a file upload system using Azure Computer Vision API and Azure Storage Java SDK
Let's create a TODO application in Java 4 Implementation of posting function
Upload a file using Java HttpURLConnection
How to sign a Minecraft MOD
Let's create a TODO application in Java 6 Implementation of search function
Let's create a TODO application in Java 8 Implementation of editing function
Run a batch file from Java
Create a Java project using Eclipse
[Java] How to create a folder
Let's create a TODO application in Java 1 Brief explanation of MVC
Let's create a TODO application in Java 5 Switch the display of TODO
Create a fluentd server for testing
Let's install Docker on Windows 10 and create a verification environment for CentOS 8!
To create a Zip file while grouping database search results in Java
[Java] Create a jar file with both compressed and uncompressed with the jar command
[Java twig] Create a parser combinator for recursive descent parsing (also memoize)
Let's go with Watson Assistant (formerly Conversation) ⑤ Create a chatbot with Watson + Java + Slack
Create a java web application development environment with docker for mac part2
How to create a Maven repository for 2020
Why does Java call a file a class?
Create a TODO app in Java 7 Create Header
[Rails] Let's create a super simple Rails API
[Java] Let's make a DB access library!
Let's make a calculator application with Java ~ Create a display area in the window
[Note] Java: Create a simple project while learning how the configuration file works.
[Azure] I tried to create a Java application for free-Web App creation- [Beginner]
I made a Diff tool for Java files
How to create a database for H2 Database anywhere
Read a string in a PDF file with Java
A story about Java 11 support for Web services
Create a simple bulletin board with Java + MySQL
Review notes for Java 1.7 and later file copies