提供: Minecraft Modding Wiki
この編集を取り消せます。
下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 | 編集中の文章 | ||
3行目: | 3行目: | ||
{{チュートリアルカテゴリー|type=Entity| difficulty=1}} | {{チュートリアルカテゴリー|type=Entity| difficulty=1}} | ||
==エンティティの追加== | ==エンティティの追加== | ||
− | [[Fabric/Entity追加|Entity追加 1.15. | + | [[Fabric/Entity追加|Entity追加 1.15.2まで]]としていることは同じであり、1.16に対応させたチュートリアルである。 |
<br>以前と少し変わっただけで殆ど変わっていない。 | <br>以前と少し変わっただけで殆ど変わっていない。 | ||
11行目: | 11行目: | ||
===ソースコード=== | ===ソースコード=== | ||
メインのクラス | メインのクラス | ||
+ | いろいろなものを登録するところ。 | ||
+ | 他のクラスを呼び出して1つ1つキレイにクラスを分けることもできる。 | ||
*Main.java | *Main.java | ||
<source lang="java"> | <source lang="java"> | ||
37行目: | 39行目: | ||
Registry.ENTITY_TYPE, | Registry.ENTITY_TYPE, | ||
new Identifier(mod_id, "example_mob"), | new Identifier(mod_id, "example_mob"), | ||
− | FabricEntityTypeBuilder.<RubyEntity>create(SpawnGroup.AMBIENT, RubyEntity::new).dimensions(EntityDimensions.fixed(0.75f, 0.75f)).build() // | + | FabricEntityTypeBuilder.<RubyEntity>create(SpawnGroup.AMBIENT, RubyEntity::new).dimensions(EntityDimensions.fixed(0.75f, 0.75f)).build() //ここだけ以前のバージョン(1.15.2まで)とは違います。 |
); | ); | ||
@Override | @Override | ||
public void onInitialize(){ | public void onInitialize(){ | ||
− | + | //つくったエンティティのスポーンエッグを登録(スポーンエッグを作らない場合はなくてもよい) | |
EntityRendererRegistry.INSTANCE.register(example_mob, (entityRenderDispatcher, context) -> new ExampleRenderer(entityRenderDispatcher)); | EntityRendererRegistry.INSTANCE.register(example_mob, (entityRenderDispatcher, context) -> new ExampleRenderer(entityRenderDispatcher)); | ||
− | |||
Registry.register(Registry.ITEM, new Identifier(mod_id, "example_mob_spawn_egg"), new SpawnEggItem(example_mob , 0x0DA70B, 0x73420E, new Item.Settings().group(ItemGroup.MISC))); | Registry.register(Registry.ITEM, new Identifier(mod_id, "example_mob_spawn_egg"), new SpawnEggItem(example_mob , 0x0DA70B, 0x73420E, new Item.Settings().group(ItemGroup.MISC))); | ||
85行目: | 86行目: | ||
public Identifier getTexture(ExampleEntity entity) { | public Identifier getTexture(ExampleEntity entity) { | ||
//テクスチャの場所を指定 | //テクスチャの場所を指定 | ||
− | return new Identifier("example | + | return new Identifier("example:textures/entity/example_entity.png"); |
} | } | ||
} | } | ||
94行目: | 95行目: | ||
FabricEntityTypeBuilder.<RubyEntity>create(SpawnGroup.MONSTER, RubyEntity::new).dimensions(EntityDimensions.fixed(0.75f, 0.75f)).build() | FabricEntityTypeBuilder.<RubyEntity>create(SpawnGroup.MONSTER, RubyEntity::new).dimensions(EntityDimensions.fixed(0.75f, 0.75f)).build() | ||
</source> | </source> | ||
− | + | 今回はこれだけ変わっているのでこれだけ解説する。 | |
− | MONSTERはモンスターのスポーンの仕方となる(暗いところにスポーン) | + | -以前はEntityCategoryだったがSpawnGroupに変わった |
+ | MONSTERはモンスターのスポーンの仕方となる(暗いところにスポーン) | ||
CREATUREは動物のスポーンの仕方となる(草原などにスポーン) | CREATUREは動物のスポーンの仕方となる(草原などにスポーン) |