3
3
package dev .cammiescorner .camsbackpacks .client .models ;
4
4
5
5
import com .google .common .collect .ImmutableList ;
6
- import net .minecraft .client .model .*;
7
- import net .minecraft .client .render .entity .model .AnimalModel ;
8
- import net .minecraft .entity .LivingEntity ;
9
-
10
- public class BackpackModel <T extends LivingEntity > extends AnimalModel <T > {
11
- private final ModelPart root ;
12
-
13
- public BackpackModel (ModelPart root ) {
14
- this .root = root .getChild ("root" );
15
- }
16
-
17
- public static TexturedModelData getTexturedModelData () {
18
- ModelData modelData = new ModelData ();
19
- ModelPartData modelPartData = modelData .getRoot ();
20
- ModelPartData modelPartData1 = modelPartData .addChild ("root" , ModelPartBuilder .create (), ModelTransform .pivot (0.0F , 0.0F , 0.0F ));
21
- ModelPartData modelPartData2 = modelPartData1 .addChild ("straps" , ModelPartBuilder .create ().uv (0 , 0 ).cuboid (-4.5F , -0.3F , -3.0F , 9.0F , 12.0F , 5.0F ), ModelTransform .pivot (0.0F , 0.0F , 0.0F ));
22
- ModelPartData modelPartData3 = modelPartData2 .addChild ("backpack" , ModelPartBuilder .create ().uv (28 , 0 ).cuboid (-4.5F , -3.0F , 2.0F , 9.0F , 16.0F , 6.0F ), ModelTransform .pivot (0.0F , 0.0F , 0.0F ));
23
- modelPartData3 .addChild ("pocketRight" , ModelPartBuilder .create ().uv (0 , 17 ).cuboid (3.5F , 7.0F , 3.0F , 3.0F , 5.0F , 4.0F ), ModelTransform .pivot (0.0F , 0.0F , 0.0F ));
24
- modelPartData3 .addChild ("pocketLeft" , ModelPartBuilder .create ().uv (0 , 17 ).cuboid (-6.5F , 7.0F , 3.0F , 3.0F , 5.0F , 4.0F ), ModelTransform .pivot (0.0F , 0.0F , 0.0F ));
25
- modelPartData3 .addChild ("backPocket" , ModelPartBuilder .create ().uv (14 , 20 ).cuboid (-3.0F , 1.0F , 8.0F , 6.0F , 8.0F , 2.0F ), ModelTransform .pivot (0.0F , 0.0F , 0.0F ));
26
-
27
- return TexturedModelData .of (modelData , 64 , 32 );
28
- }
29
-
30
- @ Override
31
- public void setAngles (T entity , float limbAngle , float limbDistance , float animationProgress , float headYaw , float headPitch ) {
32
- if (entity .isInSneakingPose ()) {
33
- root .pitch = 0.5F ;
34
- root .pivotY = 3.2F ;
35
- }
36
- else {
37
- root .pitch = 0.0F ;
38
- root .pivotY = 0.0F ;
39
- }
40
- }
41
-
42
- @ Override
43
- protected Iterable <ModelPart > getHeadParts () {
44
- return ImmutableList .of ();
45
- }
46
-
47
- @ Override
48
- protected Iterable <ModelPart > getBodyParts () {
49
- return ImmutableList .of (root );
50
- }
51
- }
6
+ import net .minecraft .client .model .AgeableListModel ;
7
+ import net .minecraft .client .model .geom .ModelPart ;
8
+ import net .minecraft .client .model .geom .PartPose ;
9
+ import net .minecraft .client .model .geom .builders .CubeListBuilder ;
10
+ import net .minecraft .client .model .geom .builders .LayerDefinition ;
11
+ import net .minecraft .client .model .geom .builders .MeshDefinition ;
12
+ import net .minecraft .client .model .geom .builders .PartDefinition ;
13
+ import net .minecraft .world .entity .LivingEntity ;
14
+
15
+ public class BackpackModel <T extends LivingEntity > extends AgeableListModel <T > {
16
+ private final ModelPart root ;
17
+
18
+ public BackpackModel (ModelPart root ) {
19
+ this .root = root .getChild ("root" );
20
+ }
21
+
22
+ public static LayerDefinition getTexturedModelData () {
23
+ MeshDefinition modelData = new MeshDefinition ();
24
+ PartDefinition modelPartData = modelData .getRoot ();
25
+ PartDefinition modelPartData1 = modelPartData .addOrReplaceChild ("root" , CubeListBuilder .create (), PartPose .offset (0.0F , 0.0F , 0.0F ));
26
+ PartDefinition modelPartData2 = modelPartData1 .addOrReplaceChild ("straps" , CubeListBuilder .create ().texOffs (0 , 0 ).addBox (-4.5F , -0.3F , -3.0F , 9.0F , 12.0F , 5.0F ), PartPose .offset (0.0F , 0.0F , 0.0F ));
27
+ PartDefinition modelPartData3 = modelPartData2 .addOrReplaceChild ("backpack" , CubeListBuilder .create ().texOffs (28 , 0 ).addBox (-4.5F , -3.0F , 2.0F , 9.0F , 16.0F , 6.0F ), PartPose .offset (0.0F , 0.0F , 0.0F ));
28
+ modelPartData3 .addOrReplaceChild ("pocketRight" , CubeListBuilder .create ().texOffs (0 , 17 ).addBox (3.5F , 7.0F , 3.0F , 3.0F , 5.0F , 4.0F ), PartPose .offset (0.0F , 0.0F , 0.0F ));
29
+ modelPartData3 .addOrReplaceChild ("pocketLeft" , CubeListBuilder .create ().texOffs (0 , 17 ).addBox (-6.5F , 7.0F , 3.0F , 3.0F , 5.0F , 4.0F ), PartPose .offset (0.0F , 0.0F , 0.0F ));
30
+ modelPartData3 .addOrReplaceChild ("backPocket" , CubeListBuilder .create ().texOffs (14 , 20 ).addBox (-3.0F , 1.0F , 8.0F , 6.0F , 8.0F , 2.0F ), PartPose .offset (0.0F , 0.0F , 0.0F ));
31
+
32
+ return LayerDefinition .create (modelData , 64 , 32 );
33
+ }
34
+
35
+ @ Override
36
+ public void setupAnim (T entity , float limbSwing , float limbSwingAmount , float ageInTicks , float netHeadYaw , float headPitch ) {
37
+ if (entity .isCrouching ()) {
38
+ root .xRot = 0.5F ;
39
+ root .y = 3.2F ;
40
+ } else {
41
+ root .xRot = 0.0F ;
42
+ root .y = 0.0F ;
43
+ }
44
+ }
45
+
46
+ @ Override
47
+ protected Iterable <ModelPart > headParts () {
48
+ return ImmutableList .of ();
49
+ }
50
+
51
+ @ Override
52
+ protected Iterable <ModelPart > bodyParts () {
53
+ return ImmutableList .of (root );
54
+ }
55
+ }
0 commit comments