0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Minecraftのmodでモブの大きさを変えてスポーンさせる方法

Posted at

自分用のメモ

概要

blockbenchで作ったモデルの大きさを変えてモブをスポーンさせる方法

##動作環境 2021/05/12

Version
Windows11 22H2
Visual Studio Code 1.76.1
OpenJDK 17.0.2
Minecraft 1.19.2
Forge 43.2.0

結論

EntityModelを継承したクラスのコンストラクタ内でModelPartクラスのxScale,yScale,zScaleフィールドを変更するとできる。

プログラム

public class SampleModel<T extends Entity> extends EntityModel<T>{
    public final ModelPart root;
    private boolean init;

    public SampleModel(ModelPart root){
        this.root = root;
        //大きさをfloat型で指定(デフォルトは1.0F)
        root.xScale = 0.5F;
		root.yScale = 0.5F;
		root.zScale = 0.5F;
        //モデルを小さくすると浮かぶためy座標を下げる
        root.y += 10.0F;
    }

詳細

blockbenchで作ったモデルをインポートすると、コンストラクタでrootを受け取りその子だけを使っているが、rootを変数に格納してまとめてscaleを変更することでまとめて大きさ変更することができる。

注意点

scaleの変更はおそらくモデルの中心を基準に行われるため、scaleを小さくすると浮かび大きくすると沈んでしまう。
そのため、scaleを変更すると同時にyの値も変更するといい。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?