BookModel.java

net.minecraft.client.model.object.book.BookModel

信息

  • 全限定名:net.minecraft.client.model.object.book.BookModel
  • 类型:public class
  • 包:net.minecraft.client.model.object.book
  • 源码路径:src/main/java/net/minecraft/client/model/object/book/BookModel.java
  • 起始行号:L16
  • 继承:Model<BookModel.State>
  • 职责:

    TODO

字段/常量

  • LEFT_PAGES

    • 类型: String
    • 修饰符: private static final
    • 源码定位: L17
    • 说明:

      TODO

  • RIGHT_PAGES

    • 类型: String
    • 修饰符: private static final
    • 源码定位: L18
    • 说明:

      TODO

  • FLIP_PAGE_1

    • 类型: String
    • 修饰符: private static final
    • 源码定位: L19
    • 说明:

      TODO

  • FLIP_PAGE_2

    • 类型: String
    • 修饰符: private static final
    • 源码定位: L20
    • 说明:

      TODO

  • leftLid

    • 类型: ModelPart
    • 修饰符: private final
    • 源码定位: L21
    • 说明:

      TODO

  • rightLid

    • 类型: ModelPart
    • 修饰符: private final
    • 源码定位: L22
    • 说明:

      TODO

  • leftPages

    • 类型: ModelPart
    • 修饰符: private final
    • 源码定位: L23
    • 说明:

      TODO

  • rightPages

    • 类型: ModelPart
    • 修饰符: private final
    • 源码定位: L24
    • 说明:

      TODO

  • flipPage1

    • 类型: ModelPart
    • 修饰符: private final
    • 源码定位: L25
    • 说明:

      TODO

  • flipPage2

    • 类型: ModelPart
    • 修饰符: private final
    • 源码定位: L26
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.client.model.object.book.BookModel.State
    • 类型: record
    • 修饰符: public
    • 源码定位: L76
    • 说明:

      TODO

构造器

public BookModel(ModelPart root) @ L28

  • 构造器名:BookModel
  • 源码定位:L28
  • 修饰符:public

参数:

  • root: ModelPart

说明:

TODO

方法

下面的方法块按源码顺序生成。

public static LayerDefinition createBodyLayer() @ L38

  • 方法名:createBodyLayer
  • 源码定位:L38
  • 返回类型:LayerDefinition
  • 修饰符:public static

参数:

说明:

TODO

public void setupAnim(BookModel.State state) @ L60

  • 方法名:setupAnim
  • 源码定位:L60
  • 返回类型:void
  • 修饰符:public

参数:

  • state: BookModel.State

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class BookModel extends Model<BookModel.State> {
    private static final String LEFT_PAGES = "left_pages";
    private static final String RIGHT_PAGES = "right_pages";
    private static final String FLIP_PAGE_1 = "flip_page1";
    private static final String FLIP_PAGE_2 = "flip_page2";
    private final ModelPart leftLid;
    private final ModelPart rightLid;
    private final ModelPart leftPages;
    private final ModelPart rightPages;
    private final ModelPart flipPage1;
    private final ModelPart flipPage2;
 
    public BookModel(ModelPart root) {
        super(root, RenderTypes::entitySolid);
        this.leftLid = root.getChild("left_lid");
        this.rightLid = root.getChild("right_lid");
        this.leftPages = root.getChild("left_pages");
        this.rightPages = root.getChild("right_pages");
        this.flipPage1 = root.getChild("flip_page1");
        this.flipPage2 = root.getChild("flip_page2");
    }
 
    public static LayerDefinition createBodyLayer() {
        MeshDefinition mesh = new MeshDefinition();
        PartDefinition root = mesh.getRoot();
        root.addOrReplaceChild(
            "left_lid", CubeListBuilder.create().texOffs(0, 0).addBox(-6.0F, -5.0F, -0.005F, 6.0F, 10.0F, 0.005F), PartPose.offset(0.0F, 0.0F, -1.0F)
        );
        root.addOrReplaceChild(
            "right_lid", CubeListBuilder.create().texOffs(16, 0).addBox(0.0F, -5.0F, -0.005F, 6.0F, 10.0F, 0.005F), PartPose.offset(0.0F, 0.0F, 1.0F)
        );
        root.addOrReplaceChild(
            "seam",
            CubeListBuilder.create().texOffs(12, 0).addBox(-1.0F, -5.0F, 0.0F, 2.0F, 10.0F, 0.005F),
            PartPose.rotation(0.0F, (float) (Math.PI / 2), 0.0F)
        );
        root.addOrReplaceChild("left_pages", CubeListBuilder.create().texOffs(0, 10).addBox(0.0F, -4.0F, -0.99F, 5.0F, 8.0F, 1.0F), PartPose.ZERO);
        root.addOrReplaceChild("right_pages", CubeListBuilder.create().texOffs(12, 10).addBox(0.0F, -4.0F, -0.01F, 5.0F, 8.0F, 1.0F), PartPose.ZERO);
        CubeListBuilder page = CubeListBuilder.create().texOffs(24, 10).addBox(0.0F, -4.0F, 0.0F, 5.0F, 8.0F, 0.005F);
        root.addOrReplaceChild("flip_page1", page, PartPose.ZERO);
        root.addOrReplaceChild("flip_page2", page, PartPose.ZERO);
        return LayerDefinition.create(mesh, 64, 32);
    }
 
    public void setupAnim(BookModel.State state) {
        super.setupAnim(state);
        float openness = state.openness;
        this.leftLid.yRot = (float) Math.PI + openness;
        this.rightLid.yRot = -openness;
        this.leftPages.yRot = openness;
        this.rightPages.yRot = -openness;
        this.flipPage1.yRot = openness - openness * 2.0F * state.pageFlip1;
        this.flipPage2.yRot = openness - openness * 2.0F * state.pageFlip2;
        this.leftPages.x = Mth.sin(openness);
        this.rightPages.x = Mth.sin(openness);
        this.flipPage1.x = Mth.sin(openness);
        this.flipPage2.x = Mth.sin(openness);
    }
 
    @OnlyIn(Dist.CLIENT)
    public record State(float openness, float pageFlip1, float pageFlip2) {
        public static BookModel.State forAnimation(float progress, float pageFlip1, float pageFlip2, float openness) {
            return new BookModel.State((Mth.sin(progress * 0.02F) * 0.1F + 1.25F) * openness, pageFlip1, pageFlip2);
        }
    }
}

引用的其他类

  • Model

    • 引用位置: 继承
  • ModelPart

    • 引用位置: 参数/字段
  • PartPose

    • 引用位置: 方法调用
    • 关联成员: PartPose.offset(), PartPose.rotation()
  • CubeListBuilder

    • 引用位置: 方法调用
    • 关联成员: CubeListBuilder.create()
  • LayerDefinition

    • 引用位置: 方法调用/返回值
    • 关联成员: LayerDefinition.create()
  • MeshDefinition

    • 引用位置: 构造调用
    • 关联成员: MeshDefinition()
  • Mth

    • 引用位置: 方法调用
    • 关联成员: Mth.sin()