19
19
import net .minecraft .util .math .RotationAxis ;
20
20
import nourl .mythicmetals .armor .MythicArmor ;
21
21
import nourl .mythicmetals .client .models .MythicModelHandler ;
22
+ import nourl .mythicmetals .client .models .StarPlatCloakModel ;
22
23
import nourl .mythicmetals .client .rendering .RenderingContext ;
23
24
import org .spongepowered .asm .mixin .Mixin ;
25
+ import org .spongepowered .asm .mixin .Unique ;
24
26
import org .spongepowered .asm .mixin .injection .At ;
25
27
import org .spongepowered .asm .mixin .injection .Inject ;
26
28
import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
@@ -37,41 +39,103 @@ public CapeFeatureRendererMixin(FeatureRendererContext<AbstractClientPlayerEntit
37
39
public void render (MatrixStack ms , VertexConsumerProvider vertices , int light , AbstractClientPlayerEntity player , float f , float g , float h , float j , float k , float l , CallbackInfo ci ) {
38
40
if (!player .isPartVisible (PlayerModelPart .CAPE ) || player .getCapeTexture () != null ) return ;
39
41
if (RenderingContext .elytraRendered || !LivingEntityFeatureRenderEvents .ALLOW_CAPE_RENDER .invoker ().allowCapeRender (player )) return ;
42
+
43
+ // Custom Hallowed Cape when no other cape is present
40
44
if (player .getEquippedStack (EquipmentSlot .CHEST ).getItem () == MythicArmor .HALLOWED .getChestplate ().asItem ()) {
41
- ms .push ();
42
- ms .translate (0.0 , 0.0 , 0.125 );
43
- double x = MathHelper .lerp (h , player .prevCapeX , player .capeX )
44
- - MathHelper .lerp (h , player .prevX , player .getX ());
45
- double y = MathHelper .lerp (h , player .prevCapeY , player .capeY )
46
- - MathHelper .lerp (h , player .prevY , player .getY ());
47
- double z = MathHelper .lerp (h , player .prevCapeZ , player .capeZ )
48
- - MathHelper .lerp (h , player .prevZ , player .getZ ());
49
- float yaw = player .prevBodyYaw + (player .bodyYaw - player .prevBodyYaw );
50
- double o = MathHelper .sin (yaw * (float ) (Math .PI / 180.0 ));
51
- double p = -MathHelper .cos (yaw * (float ) (Math .PI / 180.0 ));
52
- float q = (float )y * 10.0F ;
53
- q = MathHelper .clamp (q , -6.0F , 32.0F );
54
- float r = (float )(x * o + z * p ) * 100.0F ;
55
- r = MathHelper .clamp (r , 0.0F , 150.0F );
56
- float s = (float )(x * p - z * o ) * 100.0F ;
57
- s = MathHelper .clamp (s , -20.0F , 20.0F );
58
- if (r < 0.0F ) {
59
- r = 0.0F ;
60
- }
61
-
62
- float t = MathHelper .lerp (h , player .prevStrideDistance , player .strideDistance );
63
- q += MathHelper .sin (MathHelper .lerp (h , player .prevHorizontalSpeed , player .horizontalSpeed ) * 6.0F ) * 32.0F * t ;
64
- if (player .isInSneakingPose ()) {
65
- q += 25.0F ;
66
- }
67
-
68
- ms .multiply (RotationAxis .POSITIVE_X .rotationDegrees (6.0F + r / 2.0F + q ));
69
- ms .multiply (RotationAxis .POSITIVE_Z .rotationDegrees (s / 2.0F ));
70
- ms .multiply (RotationAxis .POSITIVE_Y .rotationDegrees (180.0F - s / 2.0F ));
71
- VertexConsumer vertexConsumer = vertices .getBuffer (RenderLayer .getEntitySolid (MythicModelHandler .HALLOWED_CAPE ));
72
- this .getContextModel ().renderCape (ms , vertexConsumer , light , OverlayTexture .DEFAULT_UV );
73
- ms .pop ();
45
+ mythicmetals$renderHallowedCape (ms , vertices , light , player , f , g , h , j , k , l );
46
+ ci .cancel ();
47
+ return ;
48
+ }
49
+ // Custom Star Platinum Cloak when no other cape is present
50
+ if (player .getEquippedStack (EquipmentSlot .CHEST ).getItem () == MythicArmor .STAR_PLATINUM .getChestplate ().asItem ()) {
51
+ mythicmetals$renderStarPlatCape (ms , vertices , light , player , f , g , h , j , k , l );
74
52
ci .cancel ();
75
53
}
76
54
}
55
+
56
+ @ Unique
57
+ private void mythicmetals$renderStarPlatCape (MatrixStack ms , VertexConsumerProvider vertices , int light , AbstractClientPlayerEntity player , float f , float g , float h , float j , float k , float l ) {
58
+ double x = MathHelper .lerpAngleDegrees (h / 2 , (float ) player .prevCapeX , (float ) player .capeX )
59
+ - MathHelper .lerpAngleDegrees (h / 2 , (float ) player .prevX , (float ) player .getX ());
60
+ double y = MathHelper .lerpAngleDegrees (h / 2 , (float ) player .prevCapeY , (float ) player .capeY )
61
+ - MathHelper .lerpAngleDegrees (h / 2 , (float ) player .prevY , (float ) player .getY ());
62
+ double z = MathHelper .lerpAngleDegrees (h / 2 , (float ) player .prevCapeZ , (float ) player .capeZ )
63
+ - MathHelper .lerpAngleDegrees (h / 2 , (float ) player .prevZ , (float ) player .getZ ());
64
+ float yaw = player .prevBodyYaw + (player .bodyYaw - player .prevBodyYaw );
65
+ double o = MathHelper .sin (yaw * (float ) (Math .PI / 180.0 ));
66
+ double p = -MathHelper .cos (yaw * (float ) (Math .PI / 180.0 ));
67
+ float q = (float ) y * 10.0F ;
68
+ q = MathHelper .clamp (q , -6.0F , 32.0F );
69
+ float r = (float ) (x * o + z * p ) * 100.0F ;
70
+ r = MathHelper .clamp (r , 0.0F , 150.0F );
71
+ float capeZOffset = (float ) (x * p - z * o ) * 100.0F ;
72
+ capeZOffset = MathHelper .clamp (capeZOffset , -20.0F , 20.0F );
73
+ if (r < 0.0F ) {
74
+ r = 0.0F ;
75
+ }
76
+
77
+
78
+ float t = MathHelper .lerp (h , player .prevStrideDistance , player .strideDistance );
79
+ q += MathHelper .sin (MathHelper .lerp (h , player .prevHorizontalSpeed , player .horizontalSpeed ) * 6.0F ) * 32.0F * t ;
80
+
81
+ if (player .isInSneakingPose ()) {
82
+ q += 25.0F ;
83
+ }
84
+
85
+ float backCapeRotation = MathHelper .clamp (6.0F + r / 2.0F + q , -30 , 60 );
86
+ VertexConsumer vertexConsumer = vertices .getBuffer (RenderLayer .getEntitySolid (MythicModelHandler .STAR_PLATINUM_CLOAK ));
87
+
88
+ // Transform and render the custom cape
89
+ ms .push ();
90
+ ms .translate (0 , -0.05 , 0.0 ); // Push up and backwards, then rotate
91
+ ms .multiply (RotationAxis .POSITIVE_X .rotationDegrees (backCapeRotation ));
92
+ ms .multiply (RotationAxis .POSITIVE_Z .rotationDegrees (capeZOffset / 2.0F ));
93
+ ms .multiply (RotationAxis .POSITIVE_Y .rotationDegrees (180.0F - capeZOffset / 1.25F ));
94
+ ms .translate (0 , 0.05 , -0.370 ); // Move back down
95
+ if (player .isInSneakingPose ()) {
96
+ ms .translate (0 , 0.15 , 0.125 );
97
+ }
98
+
99
+
100
+ StarPlatCloakModel .CAPE_MODEL .render (ms , vertexConsumer , light , OverlayTexture .DEFAULT_UV );
101
+ ms .pop ();
102
+ }
103
+
104
+ // [VanillaCopy] render the cape
105
+ @ Unique
106
+ private void mythicmetals$renderHallowedCape (MatrixStack ms , VertexConsumerProvider vertices , int light , AbstractClientPlayerEntity player , float f , float g , float h , float j , float k , float l ) {
107
+ ms .push ();
108
+ ms .translate (0.0 , 0.0 , 0.125 );
109
+ double x = MathHelper .lerp (h , player .prevCapeX , player .capeX )
110
+ - MathHelper .lerp (h , player .prevX , player .getX ());
111
+ double y = MathHelper .lerp (h , player .prevCapeY , player .capeY )
112
+ - MathHelper .lerp (h , player .prevY , player .getY ());
113
+ double z = MathHelper .lerp (h , player .prevCapeZ , player .capeZ )
114
+ - MathHelper .lerp (h , player .prevZ , player .getZ ());
115
+ float yaw = player .prevBodyYaw + (player .bodyYaw - player .prevBodyYaw );
116
+ double o = MathHelper .sin (yaw * (float ) (Math .PI / 180.0 ));
117
+ double p = -MathHelper .cos (yaw * (float ) (Math .PI / 180.0 ));
118
+ float q = (float )y * 10.0F ;
119
+ q = MathHelper .clamp (q , -6.0F , 32.0F );
120
+ float r = (float )(x * o + z * p ) * 100.0F ;
121
+ r = MathHelper .clamp (r , 0.0F , 150.0F );
122
+ float s = (float )(x * p - z * o ) * 100.0F ;
123
+ s = MathHelper .clamp (s , -20.0F , 20.0F );
124
+ if (r < 0.0F ) {
125
+ r = 0.0F ;
126
+ }
127
+
128
+ float t = MathHelper .lerp (h , player .prevStrideDistance , player .strideDistance );
129
+ q += MathHelper .sin (MathHelper .lerp (h , player .prevHorizontalSpeed , player .horizontalSpeed ) * 6.0F ) * 32.0F * t ;
130
+ if (player .isInSneakingPose ()) {
131
+ q += 25.0F ;
132
+ }
133
+
134
+ ms .multiply (RotationAxis .POSITIVE_X .rotationDegrees (6.0F + r / 2.0F + q ));
135
+ ms .multiply (RotationAxis .POSITIVE_Z .rotationDegrees (s / 2.0F ));
136
+ ms .multiply (RotationAxis .POSITIVE_Y .rotationDegrees (180.0F - s / 2.0F ));
137
+ VertexConsumer vertexConsumer = vertices .getBuffer (RenderLayer .getEntitySolid (MythicModelHandler .HALLOWED_CAPE ));
138
+ this .getContextModel ().renderCape (ms , vertexConsumer , light , OverlayTexture .DEFAULT_UV );
139
+ ms .pop ();
140
+ }
77
141
}
0 commit comments