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.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.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.monster.Zombie; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @Environment(EnvType.CLIENT) public class DrownedModel extends ZombieModel { public DrownedModel(ModelPart root) { super(root); } public static LayerDefinition createBodyLayer(CubeDeformation cubeDeformation) { MeshDefinition meshDefinition = HumanoidModel.createMesh(cubeDeformation, 0.0F); PartDefinition partDefinition = meshDefinition.getRoot(); partDefinition.addOrReplaceChild( "left_arm", CubeListBuilder.create().texOffs(32, 48).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, cubeDeformation), PartPose.offset(5.0F, 2.0F, 0.0F) ); partDefinition.addOrReplaceChild( "left_leg", CubeListBuilder.create().texOffs(16, 48).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, cubeDeformation), PartPose.offset(1.9F, 12.0F, 0.0F) ); return LayerDefinition.create(meshDefinition, 64, 64); } public void prepareMobModel(T entity, float limbSwing, float limbSwingAmount, float partialTick) { this.rightArmPose = HumanoidModel.ArmPose.EMPTY; this.leftArmPose = HumanoidModel.ArmPose.EMPTY; ItemStack itemStack = entity.getItemInHand(InteractionHand.MAIN_HAND); if (itemStack.is(Items.TRIDENT) && entity.isAggressive()) { if (entity.getMainArm() == HumanoidArm.RIGHT) { this.rightArmPose = HumanoidModel.ArmPose.THROW_SPEAR; } else { this.leftArmPose = HumanoidModel.ArmPose.THROW_SPEAR; } } super.prepareMobModel(entity, limbSwing, limbSwingAmount, partialTick); } /** * Sets this entity's model rotation angles */ public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { super.setupAnim(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch); if (this.leftArmPose == HumanoidModel.ArmPose.THROW_SPEAR) { this.leftArm.xRot = this.leftArm.xRot * 0.5F - (float) Math.PI; this.leftArm.yRot = 0.0F; } if (this.rightArmPose == HumanoidModel.ArmPose.THROW_SPEAR) { this.rightArm.xRot = this.rightArm.xRot * 0.5F - (float) Math.PI; this.rightArm.yRot = 0.0F; } if (this.swimAmount > 0.0F) { this.rightArm.xRot = this.rotlerpRad(this.swimAmount, this.rightArm.xRot, (float) (-Math.PI * 4.0 / 5.0)) + this.swimAmount * 0.35F * Mth.sin(0.1F * ageInTicks); this.leftArm.xRot = this.rotlerpRad(this.swimAmount, this.leftArm.xRot, (float) (-Math.PI * 4.0 / 5.0)) - this.swimAmount * 0.35F * Mth.sin(0.1F * ageInTicks); this.rightArm.zRot = this.rotlerpRad(this.swimAmount, this.rightArm.zRot, -0.15F); this.leftArm.zRot = this.rotlerpRad(this.swimAmount, this.leftArm.zRot, 0.15F); this.leftLeg.xRot = this.leftLeg.xRot - this.swimAmount * 0.55F * Mth.sin(0.1F * ageInTicks); this.rightLeg.xRot = this.rightLeg.xRot + this.swimAmount * 0.55F * Mth.sin(0.1F * ageInTicks); this.head.xRot = 0.0F; } } }