【Minecraft】Fabric Mod development complete process 3 - Recipe and mining level

new formula


Workbench Recipe

In order to facilitate you to quickly create recipes, you can directly go to this website to create your own recipe table by dragging and dropping, it will automatically generate a json file, which is very convenient!
After that, you only need to modify the corresponding item block to our custom
https://crafting.thedestruc7i0n.ca/


Disorder Synthesis Recipe

This recipe is used to break down gem blocks into individual ingots

Note that it minecraft:crafting_shapelessmeans disorderly synthesis

{
    
    
	"type": "minecraft:crafting_shapeless",
	"ingredients": [
		{
    
    
			"item": "tutorialmod:zer_block"
		}
	],
	"result": {
    
    
		"item": "tutorialmod:zer_ingot",
		"count": 9
	}
}

Ordered Synthesis Recipe

The recipe for synthesizing a block with 9 ingots is shown below

{
    
    
	"type": "minecraft:crafting_shaped",
	"pattern": ["###", "###", "###"],
	"key": {
    
    
		"#": {
    
    
			"item": "tutorialmod:zer_ingot"
		}
	},
	"result": {
    
    
		"item": "tutorialmod:zer_block",
		"count": 1
	}
}

Furnace Recipe

The furnace recipe is very simple, there are only three, one is the ordinary furnace recipe, the other is the blast furnace recipe, and of course there is a smoker recipe (but our custom items are all ores, and the smoker cannot be used)

The following is the common furnace recipe (smelting)

{
    
    
	"type": "minecraft:smelting",
	"category": "misc",
	"cookingtime": 200,
	"experience": 1,
	"group": "zer",
	"ingredient": {
    
    
		"item": "tutorialmod:zer_diamond"
	},
	"result": "tutorialmod:zer_ingot"
}

This is the blast furnace recipe (blasting)

{
    
    
	"type": "minecraft:blasting",
	"category": "misc",
	"cookingtime": 100,
	"experience": 0.7,
	"group": "copper_ingot",
	"ingredient": {
    
    
		"item": "minecraft:copper_ore"
	},
	"result": "minecraft:copper_ingot"
}

Digging levels and drops


Excavation level

The mining level is used to determine whether the blocks you generate can be mined, and what tools can be used for mining

This step is different from the previous MOD development. Due to the iteration of the MC version, there are many content updates, so you must follow the specified steps one by one~


Standard grade configuration

First create these folders and json files as shown in the figure below.
The root directory data and asstes are at the same level!

insert image description here

The default content of the json file is:

{
    
    
	"replace": false,
	"values": []
}

The four files under the mineable folder correspond to the corresponding blocks that can be destroyed by axes, hoes, pickaxes, and shovels

Insert the id of your newly registered custom box into values, which means you can use this type of tool to destroy

For example, if I want to use pickaxe, that is, a pickaxe to destroy gemstones, then I should pickaxe.jsonwrite in it:

{
    
    
	"replace": false,
	"values": ["tutorialmod:zer_block", "tutorialmod:raw_zer_block"]
}

Any file starting with "needs" indicates which level of tools the block can be mined.
Currently there are only four levels:

  • level_4 The highest level, that is, the nether alloy tool can be destroyed
  • diamond
  • iron
  • stone

For example, if I want my block to be destroyed only by stone material tools, then I need to needs_stone_tool.jsonwrite the corresponding id in it

{
    
    
	"replace": false,
	"values": [
		"tutorialmod:zer_block",
		"tutorialmod:zer_ore",
		"tutorialmod:nether_zer_ore"
	]
}

All in all, you need to set it twice:

  1. For the first time, set in the corresponding tool json file to determine the best tool for the block to be broken
  2. The second time, set in the corresponding tool level json file to determine the tool level that the block can be destroyed

error-prone analysis

needs_tool_level_4.jsonA block that can be destroyed by netherite tools, this file can only be written in the fixed folder shown in the picture above!

All the file and folder names shown in the picture above are dead rules! Don't change it! Just copy it! ! !


Loot and Drops

For some special blocks, we need to set different types of drops

  • Normal block: Drops the block itself
  • Ore Cube: Drop a certain amount of raw ore

Please configure the drop configuration under this folder: tutorialmod/loot_tables/blocks, each block corresponds to a drop method!

insert image description here


normal block drop

Here is a website to quickly generate loot_tabels, which can improve development efficiency: https://misode.github.io/loot-table/

For example, if you dig an ordinary block and drop it directly, then you don’t need to set too much, just copy the code below and
the place you want to modify is where I added the comment

code listzer_block.json

{
    
    
	"type": "minecraft:block",
	"pools": [
		{
    
    
			"bonus_rolls": 0.0,
			"conditions": [
				{
    
    
					"condition": "minecraft:survives_explosion"
				}
			],
			"entries": [
				{
    
    
					"type": "minecraft:item",
					"name": "tutorialmod:zer_block" // 把他修改为方块ID
				}
			],
			"rolls": 1.0
		}
	]
}

ore block drop

After the ore is mined, any number of ore raw ore will drop, and this range needs to be manually specified

Similarly, you only need to modify the comment part of the code below, and the rest can be directly applied by default

{
    
    
	"type": "minecraft:block",
	"pools": [
		{
    
    
			"bonus_rolls": 0.0,
			"entries": [
				{
    
    
					"type": "minecraft:alternatives",
					"children": [
						{
    
    
							"type": "minecraft:item",
							"conditions": [
								{
    
    
									"condition": "minecraft:match_tool",
									"predicate": {
    
    
										"enchantments": [
											{
    
    
												"enchantment": "minecraft:silk_touch",
												"levels": {
    
    
													"min": 1
												}
											}
										]
									}
								}
							],
							// 设置你的方块ID
							"name": "tutorialmod:end_stone_zer_ore"
						},
						{
    
    
							"type": "minecraft:item",
							"functions": [
								{
    
    
									"add": false,
									"count": {
    
    
										"type": "minecraft:uniform",
										// 挖掘后掉落物的数量范围
										"max": 6.0,
										"min": 4.0
									},
									"function": "minecraft:set_count"
								},
								{
    
    
									"enchantment": "minecraft:fortune",
									"formula": "minecraft:ore_drops",
									"function": "minecraft:apply_bonus"
								},
								{
    
    
									"function": "minecraft:explosion_decay"
								}
							],
							// 挖掘后掉落的物品或者方块
							"name": "tutorialmod:zer_diamond"
						}
					]
				}
			],
			"rolls": 1.0
		}
	],
	"random_sequence": "minecraft:blocks/copper_ore"
}

Guess you like

Origin blog.csdn.net/delete_you/article/details/132209444