104 lines
		
	
	
	
		
			4.2 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			104 lines
		
	
	
	
		
			4.2 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package net.minecraft.client.model;
 | |
| 
 | |
| import com.mojang.blaze3d.vertex.PoseStack;
 | |
| 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.CubeDeformation;
 | |
| 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.WitchRenderState;
 | |
| import net.minecraft.util.Mth;
 | |
| 
 | |
| @Environment(EnvType.CLIENT)
 | |
| public class WitchModel extends EntityModel<WitchRenderState> implements HeadedModel, VillagerLikeModel {
 | |
| 	protected final ModelPart nose;
 | |
| 	private final ModelPart head;
 | |
| 	private final ModelPart hat;
 | |
| 	private final ModelPart hatRim;
 | |
| 	private final ModelPart rightLeg;
 | |
| 	private final ModelPart leftLeg;
 | |
| 	private final ModelPart arms;
 | |
| 
 | |
| 	public WitchModel(ModelPart root) {
 | |
| 		super(root);
 | |
| 		this.head = root.getChild("head");
 | |
| 		this.hat = this.head.getChild("hat");
 | |
| 		this.hatRim = this.hat.getChild("hat_rim");
 | |
| 		this.nose = this.head.getChild("nose");
 | |
| 		this.rightLeg = root.getChild("right_leg");
 | |
| 		this.leftLeg = root.getChild("left_leg");
 | |
| 		this.arms = root.getChild("arms");
 | |
| 	}
 | |
| 
 | |
| 	public static LayerDefinition createBodyLayer() {
 | |
| 		MeshDefinition meshDefinition = VillagerModel.createBodyModel();
 | |
| 		PartDefinition partDefinition = meshDefinition.getRoot();
 | |
| 		PartDefinition partDefinition2 = partDefinition.addOrReplaceChild(
 | |
| 			"head", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -10.0F, -4.0F, 8.0F, 10.0F, 8.0F), PartPose.ZERO
 | |
| 		);
 | |
| 		PartDefinition partDefinition3 = partDefinition2.addOrReplaceChild(
 | |
| 			"hat", CubeListBuilder.create().texOffs(0, 64).addBox(0.0F, 0.0F, 0.0F, 10.0F, 2.0F, 10.0F), PartPose.offset(-5.0F, -10.03125F, -5.0F)
 | |
| 		);
 | |
| 		PartDefinition partDefinition4 = partDefinition3.addOrReplaceChild(
 | |
| 			"hat2",
 | |
| 			CubeListBuilder.create().texOffs(0, 76).addBox(0.0F, 0.0F, 0.0F, 7.0F, 4.0F, 7.0F),
 | |
| 			PartPose.offsetAndRotation(1.75F, -4.0F, 2.0F, -0.05235988F, 0.0F, 0.02617994F)
 | |
| 		);
 | |
| 		PartDefinition partDefinition5 = partDefinition4.addOrReplaceChild(
 | |
| 			"hat3",
 | |
| 			CubeListBuilder.create().texOffs(0, 87).addBox(0.0F, 0.0F, 0.0F, 4.0F, 4.0F, 4.0F),
 | |
| 			PartPose.offsetAndRotation(1.75F, -4.0F, 2.0F, -0.10471976F, 0.0F, 0.05235988F)
 | |
| 		);
 | |
| 		partDefinition5.addOrReplaceChild(
 | |
| 			"hat4",
 | |
| 			CubeListBuilder.create().texOffs(0, 95).addBox(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F, new CubeDeformation(0.25F)),
 | |
| 			PartPose.offsetAndRotation(1.75F, -2.0F, 2.0F, (float) (-Math.PI / 15), 0.0F, 0.10471976F)
 | |
| 		);
 | |
| 		PartDefinition partDefinition6 = partDefinition2.getChild("nose");
 | |
| 		partDefinition6.addOrReplaceChild(
 | |
| 			"mole", CubeListBuilder.create().texOffs(0, 0).addBox(0.0F, 3.0F, -6.75F, 1.0F, 1.0F, 1.0F, new CubeDeformation(-0.25F)), PartPose.offset(0.0F, -2.0F, 0.0F)
 | |
| 		);
 | |
| 		return LayerDefinition.create(meshDefinition, 64, 128);
 | |
| 	}
 | |
| 
 | |
| 	public void setupAnim(WitchRenderState renderState) {
 | |
| 		super.setupAnim(renderState);
 | |
| 		this.head.yRot = renderState.yRot * (float) (Math.PI / 180.0);
 | |
| 		this.head.xRot = renderState.xRot * (float) (Math.PI / 180.0);
 | |
| 		this.rightLeg.xRot = Mth.cos(renderState.walkAnimationPos * 0.6662F) * 1.4F * renderState.walkAnimationSpeed * 0.5F;
 | |
| 		this.leftLeg.xRot = Mth.cos(renderState.walkAnimationPos * 0.6662F + (float) Math.PI) * 1.4F * renderState.walkAnimationSpeed * 0.5F;
 | |
| 		float f = 0.01F * (renderState.entityId % 10);
 | |
| 		this.nose.xRot = Mth.sin(renderState.ageInTicks * f) * 4.5F * (float) (Math.PI / 180.0);
 | |
| 		this.nose.zRot = Mth.cos(renderState.ageInTicks * f) * 2.5F * (float) (Math.PI / 180.0);
 | |
| 		if (renderState.isHoldingItem) {
 | |
| 			this.nose.setPos(0.0F, 1.0F, -1.5F);
 | |
| 			this.nose.xRot = -0.9F;
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	public ModelPart getNose() {
 | |
| 		return this.nose;
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public ModelPart getHead() {
 | |
| 		return this.head;
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public void hatVisible(boolean hatVisible) {
 | |
| 		this.head.visible = hatVisible;
 | |
| 		this.hat.visible = hatVisible;
 | |
| 		this.hatRim.visible = hatVisible;
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public void translateToArms(PoseStack poseStack) {
 | |
| 		this.root.translateAndRotate(poseStack);
 | |
| 		this.arms.translateAndRotate(poseStack);
 | |
| 	}
 | |
| }
 |