Simple Entity๏ƒ

Note

You can find the complete source code for this tutorial in the Stone Golem system of the System Template Examples respository.

stone_golem.png

This tutorial describes how to create a simple entity using System Template. The setup assumes youโ€™re utilizing the default Auto Map settings.

System File Structure๏ƒ

๐Ÿ“ stone_golem
    ๐Ÿ“ visuals
        ๐Ÿ—’๏ธ stone_golem.animation.json
        ๐Ÿ–ผ๏ธ stone_golem.entity.png
        ๐Ÿ—’๏ธ stone_golem.geo.json
    ๐Ÿ—’๏ธ _map.py
    ๐Ÿ—’๏ธ _scope.json
    ๐Ÿ—’๏ธ stone_golem.behavior.json
    ๐Ÿ—’๏ธ stone_golem.entity.json
    ๐Ÿ—’๏ธ stone_golem.rp_ac.json

System Configuration๏ƒ

The systemโ€™s configuration is defined in the _scope.json and _map.py files.

_scope.json๏ƒ

{}

For this simple example, only the _map.py file is utilized. Although the _scope.json file is still required, it contains an empty object since no custom variables are defined.

_map.py๏ƒ

[
    # Visuals
    {
        "source": "visuals/*.geo.json",
        "target": AUTO_FLAT
    },
    
    {
        "source": "visuals/*.animation.json",
        "target": AUTO_FLAT
    },
    {
        "source": "visuals/*.entity.png",
        "target": AUTO_FLAT
    },
    # Entity definition
    {
        "source": "stone_golem.behavior.json",
        "target": AUTO_FLAT
    },
    {
        "source": "stone_golem.entity.json",
        "target": AUTO_FLAT
    },
    {
        "source": "stone_golem.rp_ac.json",
        "target": AUTO_FLAT
    }
]

In the _map.py file, the mapping between source and target files is defined. All target locations are determined by file names, using the auto mapping feature.

The files responsible for the entityโ€™s appearance reside in the visuals folder. This practice of grouping models, textures, and animations in a folder improves system manageability, especially when using external modeling tools like Blockbench or Mcblend. The AUTO_FLAT mapping omits the visuals folder from the target path and alters the texture file extension from .entity.png to just .png (assuming that youโ€™re using the default Auto Map settings).

The entity definition files contain everything necessary for the entity to function in the game. Although the system uses AUTO_FLAT mapping, the regular AUTO mapping would function similarly since the files are located in the root folder.

System Files๏ƒ

In this example, no variables or code generation features are utilized. The systemโ€™s files remain identical to what they would be if you were working directly with a resource pack and behavior pack. The primary advantage of using System Template for such systems lies in having all files conveniently grouped and easily shareable with others.

stone_golem.animation.json๏ƒ

{
	"format_version": "1.8.0",
	"animations": {
		"animation.stone_golem.walk": {
			"loop": true,
			"anim_time_update": "q.modified_distance_moved*0.2",
			"bones": {
				"leg_l": {
					"rotation": ["math.sin(q.anim_time*360+180)*30", 0, 0]
				},
				"leg_r": {
					"rotation": ["math.sin(q.anim_time*360)*30", 0, 0]
				},
				"arm_l": {
					"rotation": ["math.sin(q.anim_time*360)*30", 0, 0]
				},
				"arm_r": {
					"rotation": ["math.sin(q.anim_time*360+180)*30", 0, 0]
				}
			}
		},
		"animation.stone_golem.look_at_target": {
			"loop": true,
			"bones": {
				"head": {
					"rotation": [
						"q.target_x_rotation",
						"q.target_y_rotation",
						0.0
					]
				}
			}
		}
	}
}

stone_golem.entity.png๏ƒ

stone_golem.entity.png

stone_golem.geo.json๏ƒ

{
	"format_version": "1.16.0",
	"minecraft:geometry": [
		{
			"description": {
				"identifier": "geometry.stone_golem",
				"visible_bounds_width": 2.0,
				"visible_bounds_height": 2.0,
				"visible_bounds_offset": [0, 1, 0],
				"texture_width": 64,
				"texture_height": 64
			},
			"bones": [
				{
					"name": "root",
					"pivot": [0, 0, 0],
					"rotation": [0, 0, 0]
				},
				{
					"name": "leg_l",
					"parent": "root",
					"pivot": [1.95, 3.107, 0],
					"rotation": [0, 0, 0],
					"cubes": [
						{
							"uv": [26.0, 26.0],
							"size": [3, 3, 3],
							"origin": [0, 0, -1.5],
							"pivot": [1.5, 3, 0],
							"rotation": [0, 0, 0],
							"mirror": true
						}
					]
				},
				{
					"name": "leg_r",
					"parent": "root",
					"pivot": [-1.95, 3.107, 0],
					"rotation": [0, 0, 0],
					"cubes": [
						{
							"uv": [29.0, 14.0],
							"size": [3, 3, 3],
							"origin": [-3, 0, -1.5],
							"pivot": [-1.5, 3, 0],
							"rotation": [0, 0, 0]
						}
					]
				},
				{
					"name": "torso",
					"parent": "root",
					"pivot": [0, 2.975, 0],
					"rotation": [0, 0, 0],
					"cubes": [
						{
							"uv": [0.0, 16.0],
							"size": [9, 6, 4],
							"origin": [-4.5, 5, -2.1],
							"pivot": [0, 5, -0.1],
							"rotation": [0, 0, 0]
						},
						{
							"uv": [26.0, 20.0],
							"size": [6, 3, 3],
							"origin": [-3, 3.2, -1.5],
							"pivot": [0, 3, 0],
							"rotation": [0, 0, 0],
							"inflate": 0.2
						}
					]
				},
				{
					"name": "head",
					"parent": "torso",
					"pivot": [0, 10.975, 0],
					"rotation": [0, 0, 0],
					"cubes": [
						{
							"uv": [0.0, 0.0],
							"size": [8, 8, 8],
							"origin": [-4, 11.192, -4],
							"pivot": [0, 11.192, 0],
							"rotation": [0, 0, 0]
						}
					]
				},
				{
					"name": "arm_l",
					"parent": "torso",
					"pivot": [6, 9.975, 0],
					"rotation": [0, 0, 0],
					"cubes": [
						{
							"uv": [14.0, 26.0],
							"size": [3, 6.999, 3],
							"origin": [4.5, 4.001, -1.5],
							"pivot": [6, 11, 0],
							"rotation": [0, 0, 0],
							"mirror": true
						}
					]
				},
				{
					"name": "arm_r",
					"parent": "torso",
					"pivot": [-6, 9.975, 0],
					"rotation": [0, 0, 0],
					"cubes": [
						{
							"uv": [0.0, 26.0],
							"size": [3, 6.999, 3],
							"origin": [-7.5, 4.001, -1.5],
							"pivot": [-6, 11, 0],
							"rotation": [0, 0, 0]
						}
					]
				}
			]
		}
	]
}

stone_golem.behavior.json๏ƒ

{
	"format_version": "1.20.30",
	"minecraft:entity": {
		"description": {
			"identifier": "nusiq:stone_golem",
			"is_spawnable": true,
			"is_summonable": true
		},
		"components": {
			"minecraft:collision_box": {
				"height": 1.2,
				"width": 0.6
			},
			"minecraft:health": {
				"value": 8,
				"max": 8
			},
			"minecraft:healable": {
				"force_use": false,
				"items": [
					{
						"item": "minecraft:diamond"
					}
				]
			},
			"minecraft:breathable": {
				"total_supply": 15,
				"breathes_air": true,
				"breathes_water": true,
				"breathes_lava": true,
				"breathes_solids": true,
				"generates_bubbles": false
			},
			"minecraft:movement": {
				"max": 0.2
			},
			"minecraft:movement.basic": {},
			"minecraft:jump.static": {
				"jump_power": 0.42
			},
			"minecraft:navigation.walk": {
				"avoid_damage_blocks": true,
				"avoid_sun": true,
				"can_breach": false,
				"can_break_doors": false,
				"can_float": false,
				"can_sink": true
			},
			"minecraft:follow_range": {
				"value": 16,
				"max": 24
			},
			"minecraft:behavior.panic": {
				"priority": 0
			},
			"minecraft:behavior.tempt": {
				"priority": 1,
				"can_get_scared": false,
				"can_tempt_vertically": true,
				"items": ["diamond"],
				"within_radius": 0
			},
			"minecraft:behavior.random_stroll": {
				"priority": 2,
				"interval": 120,
				"xz_dist": 10,
				"y_dist": 7
			},
			"minecraft:behavior.random_look_around": {
				"priority": 3
			},
			"minecraft:physics": {}
		}
	}
}

stone_golem.entity.json๏ƒ

{
	"format_version": "1.20.30",
	"minecraft:client_entity": {
		"description": {
			"identifier": "nusiq:stone_golem",
			"materials": {
				"default": "entity_alphatest"
			},
			"textures": {
				"default": "textures/entity/stone_golem"
			},
			"geometry": {
				"default": "geometry.stone_golem"
			},
			"animations": {
				"walk_controller": "controller.animation.stone_golem.walk",
				"walk": "animation.stone_golem.walk",
				"look_at_target": "animation.stone_golem.look_at_target"
			},
			"scripts": {
				"animate": ["walk_controller", "look_at_target"]
			},
			"render_controllers": ["controller.render.default"],
			"spawn_egg": {
				"base_color": "#288483",
				"overlay_color": "#2B7135"
			}
		}
	}
}

stone_golem.rp_ac.json๏ƒ

{
	"format_version": "1.20.30",
	"animation_controllers": {
		"controller.animation.stone_golem.walk": {
			"states": {
				"default": {
					"transitions": [
						{
							"walk": "q.modified_move_speed > 0.1"
						}
					]
				},
				"walk": {
					"animations": ["walk"],
					"transitions": [
						{
							"default": "q.modified_move_speed < 0.05"
						}
					]
				}
			}
		}
	}
}