11package eu .pb4 .enderscapepatch .impl .entity .model ;
22
3- import eu .pb4 .factorytools .api .virtualentity .emuvanilla .EntityValueExtraction ;
4- import eu .pb4 .factorytools .api .virtualentity .emuvanilla .model .*;
3+ import eu .pb4 .factorytools .api .virtualentity .emuvanilla2 .EntityValueExtraction ;
4+ import eu .pb4 .factorytools .api .virtualentity .emuvanilla2 .model .*;
55import net .bunten .enderscape .entity .drifter .Drifter ;
66import net .minecraft .util .Mth ;
77
@@ -19,63 +19,97 @@ public class DrifterModel extends EntityModel<Drifter> {
1919
2020 public DrifterModel (ModelPart root ) {
2121 super (root );
22- this . head = root .getChild ("head" );
23- this . leftLeg = this . head .getChild ("leftLeg" );
24- this . rightLeg = this . head .getChild ("rightLeg" );
25- this . stem = this . head .getChild ("stem" );
26- this . bell = this . stem .getChild ("bell" );
27- this . strandsN = this . bell .getChild ("strandsN" );
28- this . strandsW = this . bell .getChild ("strandsW" );
29- this . strandsS = this . bell .getChild ("strandsS" );
30- this . strandsE = this . bell .getChild ("strandsE" );
22+ head = root .getChild ("head" );
23+ leftLeg = head .getChild ("leftLeg" );
24+ rightLeg = head .getChild ("rightLeg" );
25+ stem = head .getChild ("stem" );
26+ bell = stem .getChild ("bell" );
27+ strandsN = bell .getChild ("strandsN" );
28+ strandsW = bell .getChild ("strandsW" );
29+ strandsS = bell .getChild ("strandsS" );
30+ strandsE = bell .getChild ("strandsE" );
3131 }
3232
33- public static TexturedModelData createLayer () {
34- Dilation dilation = Dilation .NONE ;
35- ModelData data = new ModelData ();
36- ModelPartData rootData = data .getRoot ();
37- ModelPartData headData = rootData .addChild ("head" , ModelPartBuilder .create ().uv (0 , 0 ).cuboid (-4.0F , -8.0F , -4.0F , 8.0F , 16.0F , 8.0F , dilation ), ModelTransform .origin (0.0F , 10.0F , 0.0F ));
38- headData .addChild ("leftLeg" , ModelPartBuilder .create ().uv (96 , 0 ).cuboid (-2.0F , 0.0F , -2.0F , 4.0F , 6.0F , 4.0F , dilation ), ModelTransform .origin (2.0F , 8.0F , 0.0F ));
39- headData .addChild ("rightLeg" , ModelPartBuilder .create ().uv (96 , 10 ).cuboid (-2.0F , 0.0F , -2.0F , 4.0F , 6.0F , 4.0F , dilation ), ModelTransform .origin (-2.0F , 8.0F , 0.0F ));
40- ModelPartData stemData = headData .addChild ("stem" , ModelPartBuilder .create ().uv (96 , 20 ).cuboid (-4.0F , -10.0F , 0.0F , 8.0F , 10.0F , 0.0F , dilation ), ModelTransform .origin (0.0F , -8.0F , 0.0F ));
41- stemData .addChild ("stem2" , ModelPartBuilder .create ().uv (96 , 20 ).cuboid (-4.0F , -10.0F , 0.0F , 8.0F , 10.0F , 0.0F , dilation ), ModelTransform .of (0.0F , 0.0F , 0.0F , 0.0F , -1.5708F , 0.0F ));
42- ModelPartData bellData = stemData .addChild ("bell" , ModelPartBuilder .create ().uv (0 , 0 ).cuboid (-16.0F , -16.0F , -16.0F , 32.0F , 16.0F , 32.0F , dilation ), ModelTransform .origin (0.0F , -10.0F , 0.0F ));
43- ModelPartBuilder strandBuilder = ModelPartBuilder .create ().uv (0 , 48 ).cuboid (-16.0F , 0.0F , 0.0F , 32.0F , 32.0F , 0.0F , dilation );
44- bellData .addChild ("strandsN" , strandBuilder , ModelTransform .of (0.0F , 0.0F , -15.0F , 0.0F , 0.0F , 0.0F ));
45- bellData .addChild ("strandsW" , strandBuilder , ModelTransform .of (15.0F , 0.0F , 0.0F , 0.0F , -1.5708F , 0.0F ));
46- bellData .addChild ("strandsS" , strandBuilder , ModelTransform .of (0.0F , 0.0F , 15.0F , 0.0F , 3.1416F , 0.0F ));
47- bellData .addChild ("strandsE" , strandBuilder , ModelTransform .of (-15.0F , 0.0F , 0.0F , 0.0F , 1.5708F , 0.0F ));
48- return TexturedModelData .of (data , 128 , 80 );
33+ public static LayerDefinition createDrifterLayer () {
34+ CubeDeformation dilation = CubeDeformation .NONE ;
35+
36+ MeshDefinition data = new MeshDefinition ();
37+ PartDefinition rootData = data .getRoot ();
38+
39+ PartDefinition headData = rootData .addOrReplaceChild ("head" , CubeListBuilder .create ().texOffs (0 , 0 ).addBox (-4 , -8 , -4 , 8 , 16 , 8 , dilation ), PartPose .offset (0 , 10 , 0 ));
40+
41+ headData .addOrReplaceChild ("leftLeg" , CubeListBuilder .create ().texOffs (96 , 0 ).addBox (-2 , 0 , -2 , 4 , 6 , 4 , dilation ), PartPose .offset (2 , 8 , 0 ));
42+ headData .addOrReplaceChild ("rightLeg" , CubeListBuilder .create ().texOffs (96 , 10 ).addBox (-2 , 0 , -2 , 4 , 6 , 4 , dilation ), PartPose .offset (-2 , 8 , 0 ));
43+
44+ PartDefinition stemData = headData .addOrReplaceChild ("stem" , CubeListBuilder .create ().texOffs (96 , 20 ).addBox (-4 , -10 , 0 , 8 , 10 , 0 , dilation ), PartPose .offset (0 , -8 , 0 ));
45+ stemData .addOrReplaceChild ("stem2" , CubeListBuilder .create ().texOffs (96 , 20 ).addBox (-4 , -10 , 0 , 8 , 10 , 0 , dilation ), PartPose .offsetAndRotation (0 , 0 , 0 , 0 , -1.5708F , 0 ));
46+
47+ PartDefinition bellData = stemData .addOrReplaceChild ("bell" , CubeListBuilder .create ().texOffs (0 , 0 ).addBox (-16 , -16 , -16 , 32 , 16 , 32 , dilation ), PartPose .offset (0 , -10 , 0 ));
48+ CubeListBuilder strandBuilder = CubeListBuilder .create ().texOffs (0 , 48 ).addBox (-16 , 0 , 0 , 32 , 32 , 0 , dilation );
49+
50+ bellData .addOrReplaceChild ("strandsN" , strandBuilder , PartPose .offsetAndRotation (0 , 0 , -15 , 0 , 0 , 0 ));
51+ bellData .addOrReplaceChild ("strandsW" , strandBuilder , PartPose .offsetAndRotation (15 , 0 , 0 , 0 , -1.5708F , 0 ));
52+ bellData .addOrReplaceChild ("strandsS" , strandBuilder , PartPose .offsetAndRotation (0 , 0 , 15 , 0 , 3.1416F , 0 ));
53+ bellData .addOrReplaceChild ("strandsE" , strandBuilder , PartPose .offsetAndRotation (-15 , 0 , 0 , 0 , 1.5708F , 0 ));
54+
55+ return LayerDefinition .create (data , 128 , 80 );
4956 }
5057
51- @ Override
52- public void setAngles (Drifter state ) {
53- super .setAngles (state );
58+ public static LayerDefinition createDriftletLayer () {
59+ CubeDeformation dilation = CubeDeformation .NONE ;
60+
61+ MeshDefinition data = new MeshDefinition ();
62+ PartDefinition rootData = data .getRoot ();
63+
64+ PartDefinition headData = rootData .addOrReplaceChild ("head" , CubeListBuilder .create ().texOffs (32 , 24 ).addBox (-4 , -7 , -4 , 8 , 7 , 8 , dilation ), PartPose .offset (0 , 20 , 0 ));
65+
66+ headData .addOrReplaceChild ("leftLeg" , CubeListBuilder .create ().texOffs (48 , 7 ).addBox (-1.5F , 0 , -1.5F , 3 , 4 , 3 , dilation ), PartPose .offset (1.5F , 0 , -0.5F ));
67+ headData .addOrReplaceChild ("rightLeg" , CubeListBuilder .create ().texOffs (48 , 0 ).addBox (-1.5F , 0 , -1.5F , 3 , 4 , 3 , dilation ), PartPose .offset (-1.5F , 0 , -0.5F ));
68+
69+ PartDefinition stemData = headData .addOrReplaceChild ("stem" , CubeListBuilder .create ().texOffs (0 , 0 ).addBox (-2 , -6 , -2 , 4 , 6 , 4 , dilation ), PartPose .offset (0 , -7 , 0 ));
70+ PartDefinition bellData = stemData .addOrReplaceChild ("bell" , CubeListBuilder .create ().texOffs (0 , 0 ).addBox (-8 , -8 , -8 , 16 , 8 , 16 , dilation ), PartPose .offset (0 , -2 , 0 ));
71+ CubeListBuilder strandBuilder = CubeListBuilder .create ().texOffs (0 , 24 ).addBox (-8 , 0 , 0 , 16 , 12 , 0 , dilation );
72+
73+ bellData .addOrReplaceChild ("strandsN" , strandBuilder , PartPose .offsetAndRotation (0 , 0 , -7 , 0 , 0 , 0 ));
74+ bellData .addOrReplaceChild ("strandsW" , strandBuilder , PartPose .offsetAndRotation (7 , 0 , 0 , 0 , -1.5708F , 0 ));
75+ bellData .addOrReplaceChild ("strandsS" , strandBuilder , PartPose .offsetAndRotation (0 , 0 , 7 , 0 , 3.1416F , 0 ));
76+ bellData .addOrReplaceChild ("strandsE" , strandBuilder , PartPose .offsetAndRotation (-7 , 0 , 0 , 0 , 1.5708F , 0 ));
5477
78+ return LayerDefinition .create (data , 64 , 48 );
79+ }
80+
81+ @ Override
82+ public void setupAnim (Drifter state ) {
5583 float age = state .tickCount ;
56- float animPos = state .walkAnimation .position (1 );
57- float animSpeed = state .walkAnimation .speed (1 );
58- this .head .yaw = EntityValueExtraction .getRelativeHeadYaw (state ) * 0.017453292F ;
59- this .head .pitch = state .getXRot () * 0.017453292F + Mth .sin (age * 0.2F ) * 0.1F ;
60- this .head .roll = 0.1F * Mth .sin (animPos * 0.8F ) * 2.0F * animSpeed * 0.25F ;
61- ModelPart var10000 = this .head ;
62- var10000 .pitch += 0.1F * Mth .sin (animPos * 0.8F ) * 4.0F * animSpeed * 0.25F ;
63- this .stem .pitch = -this .head .pitch ;
64- this .bell .pitch = Mth .sin (age * 0.2F + 1.5707964F ) * 0.1F ;
65- this .bell .roll = 0.1F * -(Mth .sin (animPos * 0.8F ) * 3.0F * animSpeed * 0.5F );
66- this .strandsN .pitch = -(this .head .pitch * 0.1F ) + Mth .sin (age * 0.1F + 1.5707964F ) * 0.3F ;
67- var10000 = this .strandsN ;
68- var10000 .pitch += 0.2F * Mth .sin (animPos * 0.8F ) * animSpeed * 0.5F ;
69- this .strandsW .pitch = this .strandsN .pitch ;
70- this .strandsS .pitch = this .strandsN .pitch ;
71- this .strandsE .pitch = this .strandsN .pitch ;
72- this .leftLeg .pitch = this .head .pitch / 2.0F + Mth .cos (animPos * 0.6662F + 1.5707964F ) * 0.6F * animSpeed ;
73- this .rightLeg .pitch = this .head .pitch / 2.0F + Mth .cos (animPos * 0.6662F ) * 0.6F * animSpeed ;
74- var10000 = this .leftLeg ;
75- var10000 .pitch += Mth .sin (age * 0.2F ) * 0.4F ;
76- var10000 = this .rightLeg ;
77- var10000 .pitch += Mth .sin (age * 0.2F + 1.5707964F ) * 0.4F ;
78- this .leftLeg .roll = -this .head .roll + 0.1F * Mth .sin (animPos * 0.4F + 1.5707964F ) * 4.0F * animSpeed * 0.5F ;
79- this .rightLeg .roll = -this .head .roll + 0.1F * Mth .sin (animPos * 0.4F ) * 4.0F * animSpeed * 0.5F ;
84+ float animPos = state .walkAnimation .position ();
85+ float animSpeed = state .walkAnimation .speed ();
86+
87+ if (state .isBaby ()) animPos *= 0.5F ;
88+
89+ head .yRot = (EntityValueExtraction .getRelativeHeadYaw (state ) * 0.017453292F );
90+ head .xRot = (state .getXRot () * 0.017453292F ) + (Mth .sin (age * 0.2F ) * 0.1F );
91+ head .zRot = 0.1F * Mth .sin (animPos * 0.8F ) * 2 * (animSpeed * 0.25F );
92+ head .xRot += 0.1F * Mth .sin (animPos * 0.8F ) * 4 * (animSpeed * 0.25F );
93+
94+ stem .xRot = -head .xRot ;
95+ bell .xRot = (Mth .sin (age * 0.2F + Mth .HALF_PI ) * 0.1F );
96+ bell .zRot = 0.1F * -(Mth .sin (animPos * 0.8F ) * 3 * (animSpeed * 0.5F ));
97+
98+ strandsN .xRot = -(head .xRot * 0.1F ) + (Mth .sin (age * 0.1F + Mth .HALF_PI ) * 0.3F );
99+
100+ strandsN .xRot += 0.2F * Mth .sin (animPos * 0.8F ) * (animSpeed * 0.5F );
101+
102+ strandsW .xRot = strandsN .xRot ;
103+ strandsS .xRot = strandsN .xRot ;
104+ strandsE .xRot = strandsN .xRot ;
105+
106+ leftLeg .xRot = (head .xRot / 2 ) + Mth .cos (animPos * 0.6662F + (Mth .PI / 2 )) * 0.6F * animSpeed ;
107+ rightLeg .xRot = (head .xRot / 2 ) + Mth .cos (animPos * 0.6662F ) * 0.6F * animSpeed ;
108+
109+ leftLeg .xRot += Mth .sin (age * 0.2F ) * 0.4F ;
110+ rightLeg .xRot += Mth .sin (age * 0.2F + Mth .HALF_PI ) * 0.4F ;
111+
112+ leftLeg .zRot = -head .zRot + 0.1F * Mth .sin (animPos * 0.4F + (Mth .PI / 2 )) * 4 * (animSpeed * 0.5F );
113+ rightLeg .zRot = -head .zRot + 0.1F * Mth .sin (animPos * 0.4F ) * 4 * (animSpeed * 0.5F );
80114 }
81115}
0 commit comments