アドオン作りの基礎 - エンティティ編#1
目次は右上の「≡」から!
手順をふんで、できるだけ簡単にエンティティの作り方を解説します!
前回の記事(アドオンづくりの基礎#2)の
「追加するコンテンツのフォルダ」まで手順を進めているのが前提です。
エンティティを追加するためにはビヘイビアパックとリソースパックの両方を作る必要があるので分けて説明しますが、
どっちでの作業なのか注意して進めてください。
ビヘイビア
● エンティティの本体を作る
entitiesフォルダの中にsimple_entity.jsonを新規作成します。ファイルの名前は自由です。
ビヘイビア
┣ manifest.json
┣ pack_icon.png
┗ entities
┗simple_entity.json
Dat
entities/simple_entity.json
{
"format_version": "1.17.20",
"minecraft:entity": {
"description": {
"identifier": "ex:simple_entity",
"is_spawnable": true,
"is_summonable": true,
"is_experimental": false
},
"components": {
"minecraft:attack": { "damage": 3 },
"minecraft:can_climb": {},
"minecraft:collision_box": { "width": 0.6, "height": 1.9 },
"minecraft:conditional_bandwidth_optimization": {},
"minecraft:despawn": { "despawn_from_distance": {} },
"minecraft:health": { "value": 20, "max": 20 },
"minecraft:is_hidden_when_invisible": {},
"minecraft:loot": { "table": "loot_tables/entities/simple_entity.json" },
"minecraft:nameable": {},
"minecraft:physics": {},
"minecraft:breathable": {
"total_supply": 15,
"suffocate_time": 0
},
"minecraft:hurt_on_condition": {
"damage_conditions": [
{
"filters": { "test": "in_lava", "subject": "self", "operator": "==", "value": true },
"cause": "lava",
"damage_per_tick": 4
}
]
},
"minecraft:pushable": {
"is_pushable": true,
"is_pushable_by_piston": true
},
"minecraft:type_family": {
"family": [ "monster", "mob" ]
},
"minecraft:jump.static": {},
"minecraft:movement.basic": {},
"minecraft:navigation.walk": {
"is_amphibious": true,
"can_pass_doors": true,
"can_walk": true,
"can_break_doors": true
},
"minecraft:behavior.hurt_by_target": { "priority": 1 },
"minecraft:behavior.nearest_attackable_target": {
"priority": 2,
"must_see": true,
"reselect_targets": true,
"within_radius": 25.0,
"must_see_forget_duration": 17.0,
"entity_types": [
{
"filters": {
"any_of": [
{ "test": "is_family", "subject": "other", "value": "player" },
{ "test": "is_family", "subject": "other", "value": "snowgolem" },
{ "test": "is_family", "subject": "other", "value": "irongolem" }
]
},
"max_dist": 35
},
{
"filters": {
"any_of": [
{ "test": "is_family", "subject": "other", "value": "villager" },
{ "test": "is_family", "subject": "other", "value": "wandering_trader" }
]
},
"max_dist": 35,
"must_see": false
}
]
},
"minecraft:behavior.melee_attack": { "priority": 3 },
"minecraft:behavior.random_stroll": {
"priority": 7,
"speed_multiplier": 1
},
"minecraft:behavior.look_at_player": {
"priority": 8,
"look_distance": 6,
"probability": 0.02
},
"minecraft:behavior.random_look_around": { "priority": 9 }
}
}
}
エンティティに関してはかなり量が多いです。
● 内容の意味
{
"format_version": "1.17.20",
"minecraft:entity": {
"description": {
"identifier": "~#M(83ffd9)(アドオンID)M#~:~#M(83ffd9)(エンティティのID)M#~",
"is_spawnable": true,
"is_summonable": true,
"is_experimental": false
},
"components": {
"minecraft:attack": { "damage": ~#M(83ffd9)3M#~ }, // 攻撃力
"minecraft:can_climb": {},
"minecraft:collision_box": { "width": ~#M(83ffd9)0.6M#~, "height": ~#M(83ffd9)1.9M#~ }, // 当たり判定の幅、高さ
"minecraft:conditional_bandwidth_optimization": {},
"minecraft:despawn": { "despawn_from_distance": {} },
"minecraft:health": { "value": ~#M(83ffd9)20M#~, "max": ~#M(83ffd9)20M#~ }, // 体力の現在の値、最大値
"minecraft:is_hidden_when_invisible": {},
"minecraft:loot": { "table": "~#M(83ffd9)loot_tables/entities/zombie.jsonM#~" }, // (※1)
"minecraft:nameable": {},
"minecraft:physics": {},
"minecraft:breathable": {
"total_supply": 15,
"suffocate_time": 0
},
"minecraft:hurt_on_condition": {
"damage_conditions": [
{
"filters": { "test": "in_lava", "subject": "self", "operator": "==", "value": true },
"cause": "lava",
"damage_per_tick": 4
}
]
},
"minecraft:pushable": {
"is_pushable": true,
"is_pushable_by_piston": true
},
"minecraft:type_family": {
"family": [ "monster", "mob" ]
},
// 以下AIに関するコンポーネント群
"minecraft:jump.static": {},
"minecraft:movement.basic": {},
"minecraft:navigation.walk": {
"is_amphibious": true,
"can_pass_doors": true,
"can_walk": true,
"can_break_doors": true
},
"minecraft:behavior.hurt_by_target": { "priority": 1 },
"minecraft:behavior.nearest_attackable_target": {
"priority": 2,
"must_see": true,
"reselect_targets": true,
"within_radius": 25.0,
"must_see_forget_duration": 17.0,
"entity_types": [
{
"filters": {
"any_of": [
{ "test": "is_family", "subject": "other", "value": "player" },
{ "test": "is_family", "subject": "other", "value": "snowgolem" },
{ "test": "is_family", "subject": "other", "value": "irongolem" }
]
},
"max_dist": 35
}
]
},
"minecraft:behavior.melee_attack": { "priority": 3 },
"minecraft:behavior.random_stroll": {
"priority": 4,
"speed_multiplier": 1
},
"minecraft:behavior.look_at_player": {
"priority": 5,
"look_distance": 6,
"probability": 0.02
},
"minecraft:behavior.random_look_around": { "priority": 6 }
}
}
}
アドオンIDとエンティティのIDは書き方を守って各自で決めてください。
書き方
アドオンID
アドオン全体で共通のID
エンティティID
個別のID(バニラとカブらないほうがよい)
基本の書式
- アルファベット、数字、「_」「-」以外は使わない
- 頭文字はアルファベット
- アルファベットの大文字は使わないほうがいい
基本なので、説明が書いていないところはとりあえず書いとけばいいみたいに思ってください。
(※1) エンティティを倒したときにドロップするアイテムを決める、ルートテーブルを指定します。
オリジナルのルートテーブルを作る場合は:ルートテーブルの作り方
● ビヘイビアは完成
あとはこの記事(アドオンづくりの基礎#2)の
「圧縮」以降の手順になります。
リソース
● テクスチャを用意
リソースパックのtexturesフォルダ(なければ新規作成)の中にentityフォルダを作ります。
その中にテクスチャファイルを入れてください。今回は「simple_entity.png」であるとします。
リソース
┣ manifest.json
┣ pack_icon.png
┗ textures
┗ entity
┗ simple_entity.png
● エンティティ本体と様々なリソース情報を紐づけ
リソースパックのentityフォルダ内にsimple_entity.entity.jsonを新規作成します。名前は自由です。
リソース
┣ manifest.json
┣ pack_icon.png
┣ textures
┃ ┗ entity
┃ ┗ simple_entity.png
┗ entity
┗ simple_entity.entity.json
Res
entity/simple_entity.entity.json
{
"format_version": "1.10.0",
"minecraft:client_entity": {
"description": {
"identifier": "ex:simple_entity",
"materials": { "default": "entity_alphatest" },
"textures": { "default": "textures/entity/simple_entity" },
"geometry": { "default": "geometry.humanoid.custom" },
"scripts": {
"pre_animation": [
"variable.tcos0 = (Math.cos(query.modified_distance_moved * 38.17) * query.modified_move_speed / variable.gliding_speed_value) * 57.3;"
],
"animate": [
"controller_humanoid_baby_big_head",
"controller_look_at_target",
"controller_move",
"controller_riding",
"controller_holding",
"controller_brandish_spear",
"controller_charging",
"controller_attack",
"controller_sneaking",
"controller_bob",
"controller_damage_nearby_mobs",
"controller_bow_and_arrow",
"controller_use_item_progress",
"controller_zombie_attack_bare_hand",
"controller_swimming"
]
},
"animations": {
"humanoid_big_head": "animation.humanoid.big_head",
"look_at_target_default": "animation.humanoid.look_at_target.default",
"look_at_target_gliding": "animation.humanoid.look_at_target.gliding",
"look_at_target_swimming": "animation.humanoid.look_at_target.swimming",
"move": "animation.humanoid.move",
"riding.arms": "animation.humanoid.riding.arms",
"riding.legs": "animation.humanoid.riding.legs",
"holding": "animation.humanoid.holding",
"brandish_spear": "animation.humanoid.brandish_spear",
"charging": "animation.humanoid.charging",
"attack.rotations": "animation.humanoid.attack.rotations",
"sneaking": "animation.humanoid.sneaking",
"bob": "animation.humanoid.bob",
"damage_nearby_mobs": "animation.humanoid.damage_nearby_mobs",
"bow_and_arrow": "animation.humanoid.bow_and_arrow",
"use_item_progress": "animation.humanoid.use_item_progress",
"zombie_attack_bare_hand": "animation.zombie.attack_bare_hand",
"swimming": "animation.zombie.swimming",
"controller_humanoid_baby_big_head": "controller.animation.humanoid.baby_big_head",
"controller_look_at_target": "controller.animation.humanoid.look_at_target",
"controller_move": "controller.animation.humanoid.move",
"controller_riding": "controller.animation.humanoid.riding",
"controller_holding": "controller.animation.humanoid.holding",
"controller_brandish_spear": "controller.animation.humanoid.brandish_spear",
"controller_charging": "controller.animation.humanoid.charging",
"controller_attack": "controller.animation.humanoid.attack",
"controller_sneaking": "controller.animation.humanoid.sneaking",
"controller_bob": "controller.animation.humanoid.bob",
"controller_damage_nearby_mobs": "controller.animation.humanoid.damage_nearby_mobs",
"controller_bow_and_arrow": "controller.animation.humanoid.bow_and_arrow",
"controller_use_item_progress": "controller.animation.humanoid.use_item_progress",
"controller_zombie_attack_bare_hand": "controller.animation.zombie.attack_bare_hand",
"controller_swimming": "controller.animation.zombie.swimming"
},
"render_controllers": [ "controller.render.zombie" ],
"enable_attachables": true
}
}
}
● 内容の意味
{
"format_version": "1.10.0",
"minecraft:client_entity": {
"description": {
"identifier": "~#M(83ffd9)ex:simple_entityM#~", // エンティティのフルID
"enable_attachables": true,
"materials": { "default": "entity_alphatest" },
"textures": { "default": "textures/entity/~#M(83ffd9)(テクスチャ名)M#~" },
// 以下、中上級者向け項目
"geometry": { "default": "geometry.humanoid.custom" },
"scripts": {
"pre_animation": [
"variable.tcos0 = (Math.cos(query.modified_distance_moved * 38.17) * query.modified_move_speed / variable.gliding_speed_value) * 57.3;"
],
"animate": [
// (省略)
]
},
"animations": {
// (省略)
},
"render_controllers": [ "controller.render.zombie" ]
}
}
}
こちらも同様に、基礎の段階ですべて説明できるものではないので大部分はコピペしたままでOKです。
● リソースも完成
あとはこの記事(アドオンづくりの基礎#2)の
「圧縮」以降の手順になります。
完成!
作ったパックを両方ともインポートして確認してみましょう!
以下のことに気をつけてください:
- ワールドの設定で「試験的なゲームプレイ」をオンにする
- ビヘイビアパックとリソースパックの両方を忘れずに適用する
二つ目以降のエンティティの追加のしかた
ファイル自体を増やすのか、ファイルの中身を増やすのかに注意してください。
● エンティティ本体(ビヘイビア)
ファイル自体をまたentitiesフォルダ内に新規作成してください。
ビヘイビア
┣ pack_icon.png
┣ manifest.json
┗ entities
┣ simple_entity.json
┣ myentity_2.json
:
┗ myentity_n.json
● 本体と様々な情報を紐づけ(リソース)
ファイル自体をまたentityフォルダ内に新規作成してください。
リソース
┣ manifest.json
┣ pack_icon.png
┣ textures
┗ entity
┣ simple_entity.entity.json
┣ myentity_2.entity.json
:
┗ myentity_n.entity.json