87 lines
		
	
	
	
		
			4 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			87 lines
		
	
	
	
		
			4 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package net.minecraft.client.model;
 | |
| 
 | |
| import net.fabricmc.api.EnvType;
 | |
| import net.fabricmc.api.Environment;
 | |
| import net.minecraft.client.model.geom.ModelPart;
 | |
| import net.minecraft.client.model.geom.PartPose;
 | |
| import net.minecraft.client.model.geom.builders.CubeListBuilder;
 | |
| import net.minecraft.client.model.geom.builders.LayerDefinition;
 | |
| import net.minecraft.client.model.geom.builders.MeshDefinition;
 | |
| import net.minecraft.client.model.geom.builders.PartDefinition;
 | |
| import net.minecraft.client.renderer.entity.state.PhantomRenderState;
 | |
| import net.minecraft.util.Mth;
 | |
| 
 | |
| @Environment(EnvType.CLIENT)
 | |
| public class PhantomModel extends EntityModel<PhantomRenderState> {
 | |
| 	private static final String TAIL_BASE = "tail_base";
 | |
| 	private static final String TAIL_TIP = "tail_tip";
 | |
| 	private final ModelPart leftWingBase;
 | |
| 	private final ModelPart leftWingTip;
 | |
| 	private final ModelPart rightWingBase;
 | |
| 	private final ModelPart rightWingTip;
 | |
| 	private final ModelPart tailBase;
 | |
| 	private final ModelPart tailTip;
 | |
| 
 | |
| 	public PhantomModel(ModelPart root) {
 | |
| 		super(root);
 | |
| 		ModelPart modelPart = root.getChild("body");
 | |
| 		this.tailBase = modelPart.getChild("tail_base");
 | |
| 		this.tailTip = this.tailBase.getChild("tail_tip");
 | |
| 		this.leftWingBase = modelPart.getChild("left_wing_base");
 | |
| 		this.leftWingTip = this.leftWingBase.getChild("left_wing_tip");
 | |
| 		this.rightWingBase = modelPart.getChild("right_wing_base");
 | |
| 		this.rightWingTip = this.rightWingBase.getChild("right_wing_tip");
 | |
| 	}
 | |
| 
 | |
| 	public static LayerDefinition createBodyLayer() {
 | |
| 		MeshDefinition meshDefinition = new MeshDefinition();
 | |
| 		PartDefinition partDefinition = meshDefinition.getRoot();
 | |
| 		PartDefinition partDefinition2 = partDefinition.addOrReplaceChild(
 | |
| 			"body", CubeListBuilder.create().texOffs(0, 8).addBox(-3.0F, -2.0F, -8.0F, 5.0F, 3.0F, 9.0F), PartPose.rotation(-0.1F, 0.0F, 0.0F)
 | |
| 		);
 | |
| 		PartDefinition partDefinition3 = partDefinition2.addOrReplaceChild(
 | |
| 			"tail_base", CubeListBuilder.create().texOffs(3, 20).addBox(-2.0F, 0.0F, 0.0F, 3.0F, 2.0F, 6.0F), PartPose.offset(0.0F, -2.0F, 1.0F)
 | |
| 		);
 | |
| 		partDefinition3.addOrReplaceChild(
 | |
| 			"tail_tip", CubeListBuilder.create().texOffs(4, 29).addBox(-1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 6.0F), PartPose.offset(0.0F, 0.5F, 6.0F)
 | |
| 		);
 | |
| 		PartDefinition partDefinition4 = partDefinition2.addOrReplaceChild(
 | |
| 			"left_wing_base",
 | |
| 			CubeListBuilder.create().texOffs(23, 12).addBox(0.0F, 0.0F, 0.0F, 6.0F, 2.0F, 9.0F),
 | |
| 			PartPose.offsetAndRotation(2.0F, -2.0F, -8.0F, 0.0F, 0.0F, 0.1F)
 | |
| 		);
 | |
| 		partDefinition4.addOrReplaceChild(
 | |
| 			"left_wing_tip",
 | |
| 			CubeListBuilder.create().texOffs(16, 24).addBox(0.0F, 0.0F, 0.0F, 13.0F, 1.0F, 9.0F),
 | |
| 			PartPose.offsetAndRotation(6.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.1F)
 | |
| 		);
 | |
| 		PartDefinition partDefinition5 = partDefinition2.addOrReplaceChild(
 | |
| 			"right_wing_base",
 | |
| 			CubeListBuilder.create().texOffs(23, 12).mirror().addBox(-6.0F, 0.0F, 0.0F, 6.0F, 2.0F, 9.0F),
 | |
| 			PartPose.offsetAndRotation(-3.0F, -2.0F, -8.0F, 0.0F, 0.0F, -0.1F)
 | |
| 		);
 | |
| 		partDefinition5.addOrReplaceChild(
 | |
| 			"right_wing_tip",
 | |
| 			CubeListBuilder.create().texOffs(16, 24).mirror().addBox(-13.0F, 0.0F, 0.0F, 13.0F, 1.0F, 9.0F),
 | |
| 			PartPose.offsetAndRotation(-6.0F, 0.0F, 0.0F, 0.0F, 0.0F, -0.1F)
 | |
| 		);
 | |
| 		partDefinition2.addOrReplaceChild(
 | |
| 			"head",
 | |
| 			CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -2.0F, -5.0F, 7.0F, 3.0F, 5.0F),
 | |
| 			PartPose.offsetAndRotation(0.0F, 1.0F, -7.0F, 0.2F, 0.0F, 0.0F)
 | |
| 		);
 | |
| 		return LayerDefinition.create(meshDefinition, 64, 64);
 | |
| 	}
 | |
| 
 | |
| 	public void setupAnim(PhantomRenderState renderState) {
 | |
| 		super.setupAnim(renderState);
 | |
| 		float f = renderState.flapTime * 7.448451F * (float) (Math.PI / 180.0);
 | |
| 		float g = 16.0F;
 | |
| 		this.leftWingBase.zRot = Mth.cos(f) * 16.0F * (float) (Math.PI / 180.0);
 | |
| 		this.leftWingTip.zRot = Mth.cos(f) * 16.0F * (float) (Math.PI / 180.0);
 | |
| 		this.rightWingBase.zRot = -this.leftWingBase.zRot;
 | |
| 		this.rightWingTip.zRot = -this.leftWingTip.zRot;
 | |
| 		this.tailBase.xRot = -(5.0F + Mth.cos(f * 2.0F) * 5.0F) * (float) (Math.PI / 180.0);
 | |
| 		this.tailTip.xRot = -(5.0F + Mth.cos(f * 2.0F) * 5.0F) * (float) (Math.PI / 180.0);
 | |
| 	}
 | |
| }
 |