Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
McAlec1 committed Feb 7, 2024
1 parent b2a7d18 commit 9e3ee12
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 48 deletions.
4 changes: 2 additions & 2 deletions elements/McalecsVilager.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
},
"modelLayers": [],
"modelWidth": 0.6,
"modelHeight": 1.8,
"modelHeight": 1.95,
"modelShadowSize": 0.5,
"mountedYOffset": 0.3,
"mountedYOffset": 0.4,
"hasSpawnEgg": true,
"spawnEggBaseColor": {
"value": -6710887,
Expand Down
83 changes: 58 additions & 25 deletions models/mojmap-1.20.x/ModelVillager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,70 @@ public class ModelVillager<T extends Entity> extends EntityModel<T> {
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(
new ResourceLocation("modid", "villager"), "main");
private final ModelPart head;
private final ModelPart nose;
private final ModelPart headwear;
private final ModelPart headwear2;
private final ModelPart body;
private final ModelPart bodywear;
private final ModelPart arms;
private final ModelPart rightLeg;
private final ModelPart leftLeg;
private final ModelPart right_leg;
private final ModelPart left_leg;

public ModelVillager(ModelPart root) {
this.head = root.getChild("head");
this.nose = root.getChild("nose");
this.headwear = root.getChild("headwear");
this.headwear2 = root.getChild("headwear2");
this.body = root.getChild("body");
this.bodywear = root.getChild("bodywear");
this.arms = root.getChild("arms");
this.rightLeg = root.getChild("rightLeg");
this.leftLeg = root.getChild("leftLeg");
this.right_leg = root.getChild("right_leg");
this.left_leg = root.getChild("left_leg");
}

public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();

PartDefinition head = partdefinition.addOrReplaceChild("head",
CubeListBuilder.create().texOffs(0, 0)
.addBox(-4.0F, -9.5F, -4.0F, 8.0F, 10.0F, 8.0F, new CubeDeformation(0.0F)).texOffs(24, 0)
.addBox(-1.0F, -2.5F, -6.0F, 2.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)),
PartPose.offset(0.0F, 1.0F, 0.0F));
PartDefinition head = partdefinition.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 0).addBox(
-4.0F, -10.0F, -4.0F, 8.0F, 10.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, 0.0F));

PartDefinition body = partdefinition.addOrReplaceChild("body",
CubeListBuilder.create().texOffs(16, 20)
.addBox(-4.0F, -21.0F, -3.0F, 8.0F, 12.0F, 6.0F, new CubeDeformation(0.0F)).texOffs(0, 38)
.addBox(-4.0F, -21.0F, -3.0F, 8.0F, 20.0F, 6.0F, new CubeDeformation(0.3F)),
PartPose.offset(0.0F, 22.0F, 0.0F));
PartDefinition nose = partdefinition.addOrReplaceChild("nose", CubeListBuilder.create().texOffs(24, 0).addBox(
-1.0F, -1.0F, -6.0F, 2.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, -2.0F, 0.0F));

PartDefinition headwear = partdefinition.addOrReplaceChild("headwear", CubeListBuilder.create().texOffs(32, 0)
.addBox(-4.0F, -10.0F, -4.0F, 8.0F, 10.0F, 8.0F, new CubeDeformation(0.51F)),
PartPose.offset(0.0F, 0.0F, 0.0F));

PartDefinition headwear2 = partdefinition
.addOrReplaceChild("headwear2",
CubeListBuilder.create().texOffs(30, 47).addBox(-8.0F, -8.0F, -6.0F, 16.0F, 16.0F, 1.0F,
new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, -1.5708F, 0.0F, 0.0F));

PartDefinition body = partdefinition.addOrReplaceChild("body", CubeListBuilder.create().texOffs(16, 20).addBox(
-4.0F, 0.0F, -3.0F, 8.0F, 12.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, 0.0F));

PartDefinition bodywear = partdefinition.addOrReplaceChild("bodywear", CubeListBuilder.create().texOffs(0, 38)
.addBox(-4.0F, 0.0F, -3.0F, 8.0F, 20.0F, 6.0F, new CubeDeformation(0.5F)),
PartPose.offset(0.0F, 0.0F, 0.0F));

PartDefinition arms = partdefinition.addOrReplaceChild("arms",
CubeListBuilder.create().texOffs(44, 22)
.addBox(-8.0F, -4.9667F, -2.0F, 4.0F, 8.0F, 4.0F, new CubeDeformation(0.0F)).texOffs(44, 22)
.addBox(4.0F, -4.9667F, -2.0F, 4.0F, 8.0F, 4.0F, new CubeDeformation(0.0F)).texOffs(40, 38)
.addBox(-4.0F, -0.9667F, -2.0F, 8.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, 6.4667F, -3.0F, -0.7418F, 0.0F, 0.0F));
CubeListBuilder.create().texOffs(40, 38)
.addBox(-4.0F, 2.0F, -2.0F, 8.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)).texOffs(44, 22)
.addBox(-8.0F, -2.0F, -2.0F, 4.0F, 8.0F, 4.0F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, 2.95F, -1.05F, -0.7505F, 0.0F, 0.0F));

PartDefinition mirrored = arms.addOrReplaceChild("mirrored",
CubeListBuilder.create().texOffs(44, 22).mirror()
.addBox(4.0F, -23.05F, -3.05F, 4.0F, 8.0F, 4.0F, new CubeDeformation(0.0F)).mirror(false),
PartPose.offset(0.0F, 21.05F, 1.05F));

PartDefinition rightLeg = partdefinition.addOrReplaceChild("rightLeg", CubeListBuilder.create().texOffs(0, 22)
PartDefinition right_leg = partdefinition.addOrReplaceChild("right_leg", CubeListBuilder.create().texOffs(0, 22)
.addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)),
PartPose.offset(-2.0F, 12.0F, 0.0F));

PartDefinition leftLeg = partdefinition.addOrReplaceChild("leftLeg", CubeListBuilder.create().texOffs(0, 22)
PartDefinition left_leg = partdefinition.addOrReplaceChild("left_leg", CubeListBuilder.create().texOffs(0, 22)
.addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)),
PartPose.offset(2.0F, 12.0F, 0.0F));

Expand All @@ -59,17 +82,27 @@ public static LayerDefinition createBodyLayer() {
public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay,
float red, float green, float blue, float alpha) {
head.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
nose.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
headwear.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
headwear2.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
body.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
bodywear.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
arms.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
rightLeg.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
leftLeg.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
right_leg.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
left_leg.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
}

public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw,
float headPitch) {
this.head.yRot = netHeadYaw / (180F / (float) Math.PI);
this.head.xRot = headPitch / (180F / (float) Math.PI);
this.rightLeg.xRot = Mth.cos(limbSwing * 1.0F) * 1.0F * limbSwingAmount;
this.leftLeg.xRot = Mth.cos(limbSwing * 1.0F) * -1.0F * limbSwingAmount;
this.nose.yRot = netHeadYaw / (180F / (float) Math.PI);
this.nose.xRot = headPitch / (180F / (float) Math.PI);
this.headwear.yRot = netHeadYaw / (180F / (float) Math.PI);
this.headwear.xRot = headPitch / (180F / (float) Math.PI);
this.headwear2.yRot = netHeadYaw / (180F / (float) Math.PI);
this.headwear2.xRot = headPitch / (180F / (float) Math.PI);
this.left_leg.xRot = Mth.cos(limbSwing * 1.0F) * -1.0F * limbSwingAmount;
this.right_leg.xRot = Mth.cos(limbSwing * 1.0F) * 1.0F * limbSwingAmount;
}
}
58 changes: 39 additions & 19 deletions src/main/java/net/mcalec/mcalecs/client/model/ModelVillager.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,49 +24,69 @@ public class ModelVillager<T extends Entity> extends EntityModel<T> {
// the entity renderer and passed into this model's constructor
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(new ResourceLocation("mcalecs", "model_villager"), "main");
public final ModelPart head;
public final ModelPart nose;
public final ModelPart headwear;
public final ModelPart headwear2;
public final ModelPart body;
public final ModelPart bodywear;
public final ModelPart arms;
public final ModelPart rightLeg;
public final ModelPart leftLeg;
public final ModelPart right_leg;
public final ModelPart left_leg;

public ModelVillager(ModelPart root) {
this.head = root.getChild("head");
this.nose = root.getChild("nose");
this.headwear = root.getChild("headwear");
this.headwear2 = root.getChild("headwear2");
this.body = root.getChild("body");
this.bodywear = root.getChild("bodywear");
this.arms = root.getChild("arms");
this.rightLeg = root.getChild("rightLeg");
this.leftLeg = root.getChild("leftLeg");
this.right_leg = root.getChild("right_leg");
this.left_leg = root.getChild("left_leg");
}

public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();
PartDefinition head = partdefinition.addOrReplaceChild("head",
CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -9.5F, -4.0F, 8.0F, 10.0F, 8.0F, new CubeDeformation(0.0F)).texOffs(24, 0).addBox(-1.0F, -2.5F, -6.0F, 2.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)),
PartPose.offset(0.0F, 1.0F, 0.0F));
PartDefinition body = partdefinition.addOrReplaceChild("body",
CubeListBuilder.create().texOffs(16, 20).addBox(-4.0F, -21.0F, -3.0F, 8.0F, 12.0F, 6.0F, new CubeDeformation(0.0F)).texOffs(0, 38).addBox(-4.0F, -21.0F, -3.0F, 8.0F, 20.0F, 6.0F, new CubeDeformation(0.3F)),
PartPose.offset(0.0F, 22.0F, 0.0F));
PartDefinition arms = partdefinition.addOrReplaceChild("arms", CubeListBuilder.create().texOffs(44, 22).addBox(-8.0F, -4.9667F, -2.0F, 4.0F, 8.0F, 4.0F, new CubeDeformation(0.0F)).texOffs(44, 22)
.addBox(4.0F, -4.9667F, -2.0F, 4.0F, 8.0F, 4.0F, new CubeDeformation(0.0F)).texOffs(40, 38).addBox(-4.0F, -0.9667F, -2.0F, 8.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, 6.4667F, -3.0F, -0.7418F, 0.0F, 0.0F));
PartDefinition rightLeg = partdefinition.addOrReplaceChild("rightLeg", CubeListBuilder.create().texOffs(0, 22).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(-2.0F, 12.0F, 0.0F));
PartDefinition leftLeg = partdefinition.addOrReplaceChild("leftLeg", CubeListBuilder.create().texOffs(0, 22).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(2.0F, 12.0F, 0.0F));
PartDefinition head = partdefinition.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -10.0F, -4.0F, 8.0F, 10.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, 0.0F));
PartDefinition nose = partdefinition.addOrReplaceChild("nose", CubeListBuilder.create().texOffs(24, 0).addBox(-1.0F, -1.0F, -6.0F, 2.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, -2.0F, 0.0F));
PartDefinition headwear = partdefinition.addOrReplaceChild("headwear", CubeListBuilder.create().texOffs(32, 0).addBox(-4.0F, -10.0F, -4.0F, 8.0F, 10.0F, 8.0F, new CubeDeformation(0.51F)), PartPose.offset(0.0F, 0.0F, 0.0F));
PartDefinition headwear2 = partdefinition.addOrReplaceChild("headwear2", CubeListBuilder.create().texOffs(30, 47).addBox(-8.0F, -8.0F, -6.0F, 16.0F, 16.0F, 1.0F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, -1.5708F, 0.0F, 0.0F));
PartDefinition body = partdefinition.addOrReplaceChild("body", CubeListBuilder.create().texOffs(16, 20).addBox(-4.0F, 0.0F, -3.0F, 8.0F, 12.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, 0.0F));
PartDefinition bodywear = partdefinition.addOrReplaceChild("bodywear", CubeListBuilder.create().texOffs(0, 38).addBox(-4.0F, 0.0F, -3.0F, 8.0F, 20.0F, 6.0F, new CubeDeformation(0.5F)), PartPose.offset(0.0F, 0.0F, 0.0F));
PartDefinition arms = partdefinition.addOrReplaceChild("arms",
CubeListBuilder.create().texOffs(40, 38).addBox(-4.0F, 2.0F, -2.0F, 8.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)).texOffs(44, 22).addBox(-8.0F, -2.0F, -2.0F, 4.0F, 8.0F, 4.0F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.0F, 2.95F, -1.05F, -0.7505F, 0.0F, 0.0F));
PartDefinition mirrored = arms.addOrReplaceChild("mirrored", CubeListBuilder.create().texOffs(44, 22).mirror().addBox(4.0F, -23.05F, -3.05F, 4.0F, 8.0F, 4.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(0.0F, 21.05F, 1.05F));
PartDefinition right_leg = partdefinition.addOrReplaceChild("right_leg", CubeListBuilder.create().texOffs(0, 22).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(-2.0F, 12.0F, 0.0F));
PartDefinition left_leg = partdefinition.addOrReplaceChild("left_leg", CubeListBuilder.create().texOffs(0, 22).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(2.0F, 12.0F, 0.0F));
return LayerDefinition.create(meshdefinition, 64, 64);
}

@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
head.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
nose.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
headwear.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
headwear2.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
body.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
bodywear.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
arms.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
rightLeg.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
leftLeg.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
right_leg.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
left_leg.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
}

public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
this.head.yRot = netHeadYaw / (180F / (float) Math.PI);
this.head.xRot = headPitch / (180F / (float) Math.PI);
this.rightLeg.xRot = Mth.cos(limbSwing * 1.0F) * 1.0F * limbSwingAmount;
this.leftLeg.xRot = Mth.cos(limbSwing * 1.0F) * -1.0F * limbSwingAmount;
this.nose.yRot = netHeadYaw / (180F / (float) Math.PI);
this.nose.xRot = headPitch / (180F / (float) Math.PI);
this.headwear.yRot = netHeadYaw / (180F / (float) Math.PI);
this.headwear.xRot = headPitch / (180F / (float) Math.PI);
this.headwear2.yRot = netHeadYaw / (180F / (float) Math.PI);
this.headwear2.xRot = headPitch / (180F / (float) Math.PI);
this.left_leg.xRot = Mth.cos(limbSwing * 1.0F) * -1.0F * limbSwingAmount;
this.right_leg.xRot = Mth.cos(limbSwing * 1.0F) * 1.0F * limbSwingAmount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public boolean removeWhenFarAway(double distanceToClosestPlayer) {

@Override
public double getPassengersRidingOffset() {
return super.getPassengersRidingOffset() + 0.3;
return super.getPassengersRidingOffset() + 0.4;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class McalecsModEntities {
public static final RegistryObject<EntityType<McalecsVilagerEntity>> MCALECS_VILAGER = register("mcalecs_vilager",
EntityType.Builder.<McalecsVilagerEntity>of(McalecsVilagerEntity::new, MobCategory.CREATURE).setShouldReceiveVelocityUpdates(true).setTrackingRange(32).setUpdateInterval(3).setCustomClientFactory(McalecsVilagerEntity::new)

.sized(0.6f, 1.8f));
.sized(0.6f, 1.95f));
public static final RegistryObject<EntityType<BoykisserEntity>> BOYKISSER = register("boykisser",
EntityType.Builder.<BoykisserEntity>of(BoykisserEntity::new, MobCategory.CREATURE).setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(BoykisserEntity::new)

Expand Down

0 comments on commit 9e3ee12

Please sign in to comment.