Inspired by 2020's April Fools' 20w14infinite Snapshot, this mod brings endless randomly generated dimensions into Minecraft.
at master 142 lines 6.1 kB view raw
1// Made with Blockbench 4.11.2 2package net.lerariemann.infinity.entity.client; 3 4import com.mojang.blaze3d.vertex.PoseStack; 5import com.mojang.blaze3d.vertex.VertexConsumer; 6import net.lerariemann.infinity.entity.custom.AntEntity; 7import net.lerariemann.infinity.util.InfinityMethods; 8import net.minecraft.client.model.*; 9import net.minecraft.client.model.geom.ModelLayerLocation; 10import net.minecraft.client.model.geom.ModelPart; 11import net.minecraft.client.model.geom.PartPose; 12import net.minecraft.client.model.geom.builders.CubeDeformation; 13import net.minecraft.client.model.geom.builders.CubeListBuilder; 14import net.minecraft.client.model.geom.builders.LayerDefinition; 15import net.minecraft.client.model.geom.builders.MeshDefinition; 16import net.minecraft.client.model.geom.builders.PartDefinition; 17import net.minecraft.util.Mth; 18import org.jetbrains.annotations.NotNull; 19 20public class AntModel 21 //? if >1.21.4 { 22 extends EntityModel<AntEntityRenderState> 23 //?} else { 24 /*extends EntityModel<AntEntity> 25 *///?} 26 { 27 public static final ModelLayerLocation MODEL_LAYER = 28 new ModelLayerLocation(InfinityMethods.getId("ant"), "main"); 29 30 private final ModelPart body; 31 private final ModelPart head; 32 private final ModelPart front_left_leg; 33 private final ModelPart center_left_leg; 34 private final ModelPart back_left_leg; 35 private final ModelPart front_right_leg; 36 private final ModelPart center_right_leg; 37 private final ModelPart back_right_leg; 38 39 public AntModel(ModelPart root) { 40 //? if >1.21.2 41 super(root); 42 this.body = root.getChild("body"); 43 this.head = body.getChild("head"); 44 this.front_left_leg = body.getChild("front_left_leg"); 45 this.center_left_leg = body.getChild("center_left_leg"); 46 this.back_left_leg = body.getChild("back_left_leg"); 47 this.front_right_leg = body.getChild("front_right_leg"); 48 this.center_right_leg = body.getChild("center_right_leg"); 49 this.back_right_leg = body.getChild("back_right_leg"); 50 } 51 public static LayerDefinition getTexturedModelData() { 52 MeshDefinition modelData = new MeshDefinition(); 53 PartDefinition root = modelData.getRoot(); 54 PartDefinition body = root.addOrReplaceChild("body", CubeListBuilder.create().texOffs(0, 11).addBox(-2.0F, -5.75F, 3.0F, 4.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)) 55 .texOffs(0, 0).addBox(-1.0F, -4.0F, -5.0F, 2.0F, 2.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); 56 57 body.addOrReplaceChild("head", CubeListBuilder.create().texOffs(16, 11).addBox(-1.5F, -1.75F, -3.0F, 3.0F, 3.0F, 3.0F, new CubeDeformation(0.0F)) 58 .texOffs(0, 0) 59 .addBox(2.0F, -3.75F, -1.0F, -1.0F, 3.0F, 1.0F, new CubeDeformation(0.0F)) 60 .texOffs(0, 0) 61 .addBox(-1.0F, -3.75F, -1.0F, -1.0F, 3.0F, 1.0F, new CubeDeformation(0.0F)), 62 PartPose.offset(0.0F, -3.0F, -4.0F)); 63 64 body.addOrReplaceChild("front_left_leg", CubeListBuilder.create() 65 .texOffs(16, 17) 66 .addBox(-0.5F, -0.5F, -1.5F, 7.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)), 67 PartPose.offsetAndRotation(0.5F, -2.5F, -1.5F, 0.0F, 0.2182F, 0.3054F)); 68 body.addOrReplaceChild("center_left_leg", CubeListBuilder.create() 69 .texOffs(0, 19) 70 .addBox(-0.5F, -0.5F, -0.5F, 7.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)), 71 PartPose.offsetAndRotation(0.5F, -2.5F, -0.5F, 0.0F, 0.0F, 0.3054F)); 72 body.addOrReplaceChild("back_left_leg", CubeListBuilder.create() 73 .texOffs(16, 19) 74 .addBox(-0.5F, -0.5F, -0.5F, 7.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)), 75 PartPose.offsetAndRotation(0.5F, -2.5F, 1.5F, 0.0F, -0.2182F, 0.3054F)); 76 body.addOrReplaceChild("front_right_leg", CubeListBuilder.create() 77 .texOffs(0, 21) 78 .addBox(-6.5F, -0.5F, -0.5F, 7.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)), 79 PartPose.offsetAndRotation(-0.5F, -2.5F, -2.5F, 0.0F, -0.2182F, -0.3054F)); 80 body.addOrReplaceChild("center_right_leg", CubeListBuilder.create() 81 .texOffs(16, 21) 82 .addBox(-6.5F, -0.5F, -0.5F, 7.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)), 83 PartPose.offsetAndRotation(-0.5F, -2.5F, -0.5F, 0.0F, 0.0F, -0.3054F)); 84 body.addOrReplaceChild("back_right_leg", CubeListBuilder.create() 85 .texOffs(22, 0) 86 .addBox(-6.5F, -0.5F, -0.5F, 7.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)), 87 PartPose.offsetAndRotation(-0.5F, -2.5F, 1.5F, 0.0F, 0.2182F, -0.3054F)); 88 89 return LayerDefinition.create(modelData, 64, 64); 90 } 91 92 93 //? if =1.21.1 { 94 /*@Override 95 public void renderToBuffer(PoseStack matrices, VertexConsumer vertices, int light, int overlay, int color) { 96 body.render(matrices, vertices, light, overlay, color); 97 } 98 *///?} else if =1.20.1 { 99 /*public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { 100 body.render(poseStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); 101 } 102 *///?} 103 104 //? if <1.21.2 { 105 /*public @NotNull ModelPart root() { 106 return body; 107 } 108 *///?} 109 110 111 @Override 112 public void setupAnim( 113 //? if <1.21.2 { 114 /*AntEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch 115 *///?} else { 116 AntEntityRenderState entity 117 //?} 118 ) { 119 //? if >1.21.2 { 120 var headYaw = entity.headYaw; 121 var headPitch = entity.headPitch; 122 var limbAngle = entity.limbAngle; 123 var limbDistance = entity.limbDistance; 124 //?} 125 this.root().getAllParts().forEach(ModelPart::resetPose); 126 127 this.head.yRot = Mth.clamp(headYaw, -30.0F, 30.0F) * 0.017453292F; 128 this.head.xRot = Mth.clamp(headPitch, -25.0F, 45.0F) * 0.017453292F; 129 130 float pi = 3.1415927F; 131 float speed = Math.min(0.5f, 3.0f * limbDistance); 132 float yawFront = Mth.cos(limbAngle * 0.6662F) * speed; 133 float yawCenter = Mth.cos(limbAngle * 0.6662F + pi / 4) * speed; 134 float yawBack = Mth.cos(limbAngle * 0.6662F + pi / 2) * speed; 135 front_left_leg.yRot += yawFront; 136 center_left_leg.yRot += yawCenter; 137 back_left_leg.yRot += yawBack; 138 front_right_leg.yRot -= yawFront; 139 center_right_leg.yRot -= yawCenter; 140 back_right_leg.yRot -= yawBack; 141 } 142}