Collection of useful Minecraft Forge development related utilities.
npm install minecraft-forge-utilsnpx minecraft-forge-utils init
npx minecraft-forge-utils init
npx minecraft-forge-utils new
npx minecraft-forge-utils new which will ask for
npx minecraft-forge-utils create files color
npx minecraft-forge-utils create files wood
npx minecraft-forge-utils run
java
+++ models/item/[[ --block_name-- ]].json
@@@ create @@@
`
##### @@@ after: ... @@@
Adds the content after the give keyword, e.g:
`java
+++ block/ModBlocks.java
@@@ after:@TemplateEntryPoint("Register Blocks") @@@
`
##### @@@ before: ... @@@
Adds the content before the given keyword, e.g:
`java
+++ lang/en_us.json
@@@ before:"block.placeholder.text" @@@
`
##### @@@ copy:/.../ @@@
Copies the content from the given file, e.g:
`java
+++ textures/block/[[ --block_name-- ]].png
@@@ copy:/resources/textures/block/CustomBlock.png @@@
`
$3
Your java template should be end with .java, a simple example looks like:
`java
+++ block/[[ --BlockClassName-- ]].java
@@@ create @@@
package [[ --packageNamespace-- ]].block;
import net.minecraft.world.level.block.Block;
public class [[ --BlockClassName-- ]] extends Block {
public [[ --BlockClassName-- ]](Properties properties) {
super(properties);
}
}
+++ block/ModBlocks.java
@@@ after:@TemplateEntryPoint("Register Blocks") @@@
public static final RegistryObject [[ --BLOCK_NAME-- ]] =
BLOCKS.register("[[ --block_name-- ]]", () -> new [[ --BlockClassName-- ]](BlockBehaviour.Properties.of(Material.STONE)
.requiresCorrectToolForDrops().strength(3.0F, 6.0F).sound([[ --SoundType-- ]])));
+++ item/ModItems.java
@@@ after:@TemplateEntryPoint("Register Block Items") @@@
public static final RegistryObject- [[ --BLOCK_NAME-- ]] =
ITEMS.register("[[ --block_name-- ]]", () -> new BlockItem(ModBlocks.[[ --BLOCK_NAME-- ]].get(),
new Item.Properties().tab(CreativeModeTab.TAB_BUILDING_BLOCKS)));
`
$3
Resource templates should be end with .json, a simple example looks like:
`json
+++ models/block/[[ --block_name-- ]].json
@@@ create @@@
{
"parent": "block/cube_all",
"textures": {
"all": "[[ --ModId-- ]]:block/[[ --block_name-- ]]"
}
}
+++ models/item/[[ --block_name-- ]].json
@@@ create @@@
{
"parent": "[[ --ModId-- ]]:block/[[ --block_name-- ]]"
}
+++ blockstates/[[ --block_name-- ]].json
@@@ create @@@
{
"variants": {
"": { "model": "[[ --ModId-- ]]:block/[[ --block_name-- ]]" }
}
}
+++ textures/block/[[ --block_name-- ]].png
@@@ copy:/resources/textures/block/CustomBlock.png @@@
+++ lang/en_us.json
@@@ before:"block.placeholder.text" @@@
"block.[[ --ModId-- ]].[[ --block_name-- ]]": "[[ --BlockName-- ]]",
`
$3
Data templates should be end with .json, a simple example looks like:
`json
+++ [[ --ModId-- ]]/loot_tables/blocks/[[ --block_name-- ]].json
@@@ create @@@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"bonus_rolls": 0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "[[ --ModId-- ]]:[[ --block_name-- ]]"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}
+++ minecraft/tags/blocks/mineable/pickaxe.json
@@@ after:"values": [ @@@
"[[ --ModId-- ]]:[[ --block_name-- ]]",
+++ minecraft/tags/blocks/needs_iron_tool.json
@@@ after:"values": [ @@@
"[[ --ModId-- ]]:[[ --block_name-- ]]",
`
$3
Mixed templates should be end with .template. The template engine will try
it best to detect the correct paths based on the given information. But in some
cases it could be that it's not recognize the correct path and you need to split
the files for the specific use-case.
Full example:
`java
+++ block/ModBlocks.java
@@@ after:@TemplateEntryPoint("Register Blocks") @@@
public static final RegistryObject [[ --BLOCK_NAME-- ]]_HALF_SLAP =
BLOCKS.register([[ --block_name-- ]]_half_slab", () -> new HalfSlabBlock(Blocks.[[ --BLOCK_NAME-- ]]_BLOCK));
+++ items/ModItems.java
@@@ after:@TemplateEntryPoint("Register Block Items") @@@
public static final RegistryObject- [[ --BLOCK_NAME-- ]]_HALF_SLAP =
ITEMS.register("[[ --block_name-- ]]_slab", () -> new BlockItem(ModBlocks.[[ --BLOCK_NAME-- ]]_HALF_SLAP.get(),
new Item.Properties().tab(MaterialElementsTab.TAB_PANEL_PLATES)));
+++ blockstates/[[ --block_name-- ]].json
@@@ create @@@
{
"variants": {
"face=floor": {
"model": "[[ --ModId-- ]]:block/half_slab/[[ --block_name-- ]]_half_slab"
},
"face=wall,facing=north": {
"model": "[[ --ModId-- ]]:block/half_slab/[[ --block_name-- ]]_half_slab",
"x": 270,
"y": 180
},
"face=wall,facing=east": {
"model": "[[ --ModId-- ]]:block/half_slab/[[ --block_name-- ]]_half_slab",
"x": 270,
"y": 270
},
"face=wall,facing=south": {
"model": "[[ --ModId-- ]]:block/half_slab/[[ --block_name-- ]]_half_slab",
"x": 270
},
"face=wall,facing=west": {
"model": "[[ --ModId-- ]]:block/half_slab/[[ --block_name-- ]]_half_slab",
"x": 270,
"y": 90
},
"face=ceiling": {
"model": "[[ --ModId-- ]]:block/half_slab/[[ --block_name-- ]]_half_slab",
"x": 180
}
}
}
+++ models/block/half_slab/[[ --block_name-- ]]_half_slab.json
@@@ create @@@
{
"parent": "material_elements_panels_plates_slabs:block/template/half_slab",
"textures": {
"texture": "minecraft:block/[[ --block_name-- ]]_planks",
"particle": "minecraft:block/[[ --block_name-- ]]_planks"
}
}
+++ models/items/[[ --block_name-- ]]_half_slab.json
@@@ create @@@
{
"parent": "[[ --ModId-- ]]:block/half_slab/[[ --block_name-- ]]_half_slab"
}
+++ loot_tables/blocks/[[ --block_name-- ]].json
@@@ create @@@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"bonus_rolls": 0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"name": "[[ --ModId-- ]]:[[ --block_name-- ]]_half_slab"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}
+++ recipes/[[ --block_name-- ]]_from_[[ --block_name-- ]]_planks_by_stonecutter.json
@@@ create @@@
{
"type": "minecraft:stonecutting",
"ingredient": {
"item": "minecraft:[[ --block_name-- ]]_planks"
},
"result": "[[ --ModId-- ]]:[[ --block_name-- ]]_half_slab",
"count": 4
}
+++ recipes/[[ --block_name-- ]]_from_[[ --block_name-- ]]_slab_by_stonecutter.json
@@@ create @@@
{
"type": "minecraft:stonecutting",
"ingredient": {
"item": "minecraft:[[ --block_name-- ]]_slab"
},
"result": "[[ --ModId-- ]]:[[ --block_name-- ]]_half_slab",
"count": 2
}
+++ minecraft/tags/blocks/mineable/pickaxe.json
@@@ after:"values": [ @@@
"[[ --ModId-- ]]:[[ --block_name-- ]]",
+++ minecraft/tags/blocks/needs_iron_tool.json
@@@ after:"values": [ @@@
"[[ --ModId-- ]]:[[ --block_name-- ]]",
``