Skip to content

Commit

Permalink
Chicken head now uses chicken textured model data
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro270707 committed Feb 25, 2024
1 parent 047a10f commit be69233
Showing 1 changed file with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import net.minecraft.client.model.*;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.block.entity.SkullBlockEntityModel;
import net.minecraft.client.render.entity.model.ChickenEntityModel;
import net.minecraft.client.render.entity.model.EntityModelPartNames;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.MathHelper;
import org.joml.Vector3f;

@Environment(EnvType.CLIENT)
Expand All @@ -17,29 +19,35 @@ public class ChickenHeadEntityModel extends SkullBlockEntityModel implements Hea

public ChickenHeadEntityModel(ModelPart root) {
this.head = root.getChild(EntityModelPartNames.HEAD);
this.beak = this.head.getChild(EntityModelPartNames.BEAK);
this.wattle = this.head.getChild("red_thing"); // yes, mojang actually calls it a red thing
this.beak = root.getChild(EntityModelPartNames.BEAK);
this.wattle = root.getChild(ChickenEntityModel.RED_THING);
}

public static TexturedModelData getTexturedModelData() {
ModelData modelData = new ModelData();
ModelPartData modelPartData = modelData.getRoot();
ModelPartData modelPartData2 = modelPartData.addChild(EntityModelPartNames.HEAD, ModelPartBuilder.create().uv(0, 0).cuboid(-2.0F, -6.0F, -1.5F, 4.0F, 6.0F, 3.0F), ModelTransform.NONE);
modelPartData2.addChild(EntityModelPartNames.BEAK, ModelPartBuilder.create().uv(14, 0).cuboid(-2.0F, -4.0F, -3.5F, 4.0F, 2.0F, 2.0F), ModelTransform.NONE);
modelPartData2.addChild("red_thing", ModelPartBuilder.create().uv(14, 4).cuboid(-1.0F, -2.0F, -2.5F, 2.0F, 2.0F, 2.0F), ModelTransform.NONE);
return TexturedModelData.of(modelData, 64, 32);
return ChickenEntityModel.getTexturedModelData();
}

public Vector3f getHeadSizeInPixels() {
return new Vector3f(4.0f, 6.0f, 3.0f);
}

public void setHeadRotation(float animationProgress, float yaw, float pitch) {
this.head.yaw = yaw * 0.017453292F;
this.head.pitch = pitch * 0.017453292F;
yaw = yaw * 0.017453292f;
pitch = pitch * 0.017453292f;
float offsetZ = 0.5f;
this.head.setPivot(0.0f, 0.0f, 0.0f);
this.beak.setPivot(0.0f, 0.0f, 0.0f);
this.wattle.setPivot(0.0f, 0.0f, 0.0f);
this.head.translate(new Vector3f(offsetZ * MathHelper.sin(yaw), 0, offsetZ * MathHelper.cos(yaw)));
this.beak.translate(new Vector3f(offsetZ * MathHelper.sin(yaw), 0, offsetZ * MathHelper.cos(yaw)));
this.wattle.translate(new Vector3f(offsetZ * MathHelper.sin(yaw), 0, offsetZ * MathHelper.cos(yaw)));
this.head.yaw = this.beak.yaw = this.wattle.yaw = yaw;
this.head.pitch = this.beak.pitch = this.wattle.pitch = pitch;
}

public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
this.head.render(matrices, vertices, light, overlay, red, green, blue, alpha);
this.beak.render(matrices, vertices, light, overlay, red, green, blue, alpha);
this.wattle.render(matrices, vertices, light, overlay, red, green, blue, alpha);
}
}

0 comments on commit be69233

Please sign in to comment.