[Java] Let's create a mod for Minecraft 1.14.4 [6. Add recipe]

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

First article: Introduction Previous article: 5. Adding Armor Next article: 7. Add progress

Add recipe

By the way, 1. Add item, 2. Add block, 4 Add tools, 5. Add armor and add various items. However, there is no recipe to craft these yet. This time we will add recipes for some patterns. In 1.14.4, adding recipes does not require writing code and can be added based on json.

Standard recipe

For example, let's add a sword recipe.

\src\main\resources
   ├ assets
   └ data
      └ example_mod
         ├ loot_tables
         └ recipes
            └ example_sword.json

Create a \ src \ main \ resources \ data \ recipes folder and place the recipe files in it.

example_sword.json


{
  "type": "minecraft:crafting_shaped",
  "pattern": [
    "#",
    "#",
    "X"
  ],
  "key": {
    "#": {
      "item": "example_mod:example_ingot"
    },
    "X": {
      "item": "minecraft:stick"
    }
  },
  "result": {
    "item": "example_mod:example_sword"
  }
}

You can make a standard recipe by giving minecraft: crafting_shaped to type. A standard recipe is a craft recipe in which the arrangement of ingredients is fixed. Use key to determine an arbitrary token (# and X here, but anything is fine) and the corresponding item, and use this token to place it in pattern in the form of a matrix of 3x3 or less. To decide. Specify the item obtained as a result of crafting in result. キャプチャ.PNG You can now make swords. In this example, only one row is used to arrange the materials, so you can make it vertically at any position as shown in the figure. Since "nothing" is indicated by a half-width space, you can explicitly do the following, but even in this case, it seems that you can also make one vertical column on the left or right.

python


  "pattern": [
    " # ",
    " # ",
    " X "
  ]

Amorphous recipe

Next, let's add an amorphous recipe that does not specify the arrangement of ingredients. A little unsuitable as an example, but consider a recipe that breaks down two blocks into 18 ingots.

\src\main\resources
   ├ assets
   └ data
      └ example_mod
         ├ loot_tables
         └ recipes
            └ example_ingot.json

example_ingot.json


{
  "type": "minecraft:crafting_shapeless",
  "ingredients": [
    {
      "item": "example_mod:example_block"
    },
    {
      "item": "example_mod:example_block"
    }
  ],
  "result": {
    "item": "example_mod:example_ingot",
    "count": 18
  }
}

By giving minecraft: crafting_shapeless to type, you can create an atypical recipe. ʻIngredientsis an array of materials, which lists the items used for crafting. resultis the same as the standard recipe. You can specify the number withcount` (default 1 was omitted in the previous section). キャプチャ.PNG The ingot was obtained from any arrangement.

Refining recipe

Next, add a recipe for refining with a kamado. For example, let's refine a diamond so that we can get an ingot.

\src\main\resources
   ├ assets
   └ data
      └ example_mod
         ├ loot_tables
         └ recipes
            └ furnace
               └ example_ingot.json

(It seems that all the files under recipes will be registered, so maybe the folder structure and file name are free.)

example_ingot.json


{
  "type": "minecraft:smelting",
  "ingredient": {
    "item": "minecraft:diamond"
  },
  "result": {
    "item": "example_mod:example_ingot"
  },
  "experience": 3.0,
  "cookingtime": 200
}

Add a refining recipe by specifying minecraft: smelting for type. ʻIngredient(** Note because it is singular **) is the material, andresult is the item after refining. ʻExperience is the experience value gained by refining, and cooking time is the refining time. By the way, vanilla iron is 0.7 and 200, respectively. キャプチャ.PNG I was able to refine it.

development

Q. Isn't it in the recipe book? ** A. Once made, it will be listed. If you want to put it first, you need to modify the part related to advancements **, but I have not learned it yet, so I hope to add it later.


Q. I want to make the same item from multiple materials ** A. There are three solutions. ** ** The first is to simply create as many json files as the recipe. Not recommended. The second is to pass multiple items to key or ʻingradient`.

X position is stick or oak_Either wood


{
  "type": "minecraft:crafting_shaped",
  "pattern": [
    "#",
    "#",
    "X"
  ],
  "key": {
    "#": {
      "item": "example_mod:example_ingot"
    },
    "X": [
      {
        "item": "minecraft:stick"
      },
      {
        "item": "minecraft:oak_wood"
      }
    ]
  },
  "result": {
    "item": "example_mod:example_sword"
  }
}

The material is diamond or gold_Either ingot


{
  "type": "minecraft:smelting",
  "ingredient": [
    {
      "item": "minecraft:diamond"
    },
    {
      "item": "minecraft:gold_ingot"
    }
  ],
  "result": {
    "item": "example_mod:example_ingot"
  },
  "experience": 3.0,
  "cookingtime": 200
}

(I wasn't sure if this method could be used for shapeless recipes. Doesn't it seem to work?)

The third method is to use tag. For example, vanilla charcoal crafts one item from all kinds of logs. The code is shown below.

charcoal.json


{
  "type": "minecraft:smelting",
  "ingredient": {
    "tag": "minecraft:logs"
  },
  "result": "minecraft:charcoal",
  "experience": 0.15,
  "cookingtime": 200
}

This tag is declared in net \ minecraft \ tags \ BlockTags.java. Of course, you can define new tags yourself, so it's a good idea to create a tag that summarizes alternative materials and use it to define recipes.


Q. I want to modify the vanilla recipe ** A. Easy to add. Difficult to change. ** ** In other words, it is easy to add C → B to A → B craft, but it is difficult to change to A → D craft. The former coexists with vanilla's if you simply add a new recipe, but the latter seems to give priority to vanilla even if you add a recipe with the same ingredients. Therefore, it seems that it is necessary to go back to the code that registers the recipe.


Q. I want to make a brewing recipe Probably, you can't add json base like above for brewing recipes. (Reference)

reference

Recipes - Forge Documentation Minecraft 1.14.4 Forge Mod Creation Part 9 [Add Recipe]

Next article

7. Add progress

Recommended Posts

[Java] Let's create a mod for Minecraft 1.14.4 [6. Add recipe]
[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.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.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.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] Let's create a mod for Minecraft 1.14.4 [0. Basic file]
[Java] Let's create a mod for Minecraft 1.14.4 [Extra edition]
[Java] Let's create a mod for Minecraft 1.16.1 [Basic 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 basics] Let's make a triangle with a for statement
Create a java method [Memo] [java11]
[Java] Create a temporary file
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 TODO application in Java 4 Implementation of posting function
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
minecraft1.14.4 MOD development memorandum 1 [Original recipe]
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!
[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
[Java] Create and apply a slide master
How to create a Maven repository for 2020
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
Java (add2)
Java (add)
Let's create a versatile file storage (?) Operation library by abstracting file storage / acquisition in Java
[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
A story about Java 11 support for Web services
Create a CSR with extended information in Java
Create a simple bulletin board with Java + MySQL
Let's create a REST API using WildFly Swarm.
[Windows] [IntelliJ] [Java] [Tomcat] Create a Tomcat9 environment with IntelliJ
Create a Lambda Container Image based on Java 15
[Java] Create something like a product search API
Let's create a RESTful email sending service + client