18
18
import net .minecraft .client .player .LocalPlayer ;
19
19
import net .minecraft .network .chat .CommonComponents ;
20
20
import net .minecraft .network .chat .Component ;
21
+ import net .minecraft .world .entity .LivingEntity ;
22
+ import org .joml .Quaternionf ;
23
+ import org .joml .Vector3f ;
21
24
import org .samo_lego .fabrictailor .casts .TailoredPlayer ;
22
25
import org .samo_lego .fabrictailor .client .screen .tabs .CapeTab ;
23
26
import org .samo_lego .fabrictailor .client .screen .tabs .LocalSkinTab ;
@@ -234,28 +237,10 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta)
234
237
float f = (float ) Math .atan (mousex / 40.0f );
235
238
float g = (float ) Math .atan (mousey / 40.0f );
236
239
237
- float yBodyRot = player .yBodyRot ;
238
- float yRot = player .getYRot ();
239
- float xRot = player .getXRot ();
240
- float yHeadRotO = player .yHeadRotO ;
241
- float yHeadRot = player .yHeadRot ;
242
-
243
- player .yBodyRot += 180.0f ;
244
- player .setYRot (yRot + 180f );
245
- player .setXRot (xRot + 180.0f );
246
- player .yHeadRot += 180.0f ;
247
- player .yHeadRotO += 180.0f ;
248
-
249
-
250
240
int x = this .startX + 24 ;
251
241
int y = this .startY - 76 ;
252
- InventoryScreen . renderEntityInInventoryFollowsMouse (guiGraphics , x , y , x + 75 , y + 208 , 48 , 1.0f , - mouseX - 2 , mouseY - 16 , this .minecraft .player );
242
+ renderEntityInInventoryFollowsMouseBackwards (guiGraphics , x , y , x + 75 , y + 208 , 48 , 1.0f , mouseX + 2 , mouseY - 16 , this .minecraft .player );
253
243
254
- player .yBodyRot = yBodyRot ;
255
- player .setYRot (yRot );
256
- player .setXRot (xRot );
257
- player .yHeadRotO = yHeadRotO ;
258
- player .yHeadRot = yHeadRot ;
259
244
} else {
260
245
// Drawing Player
261
246
// Luckily vanilla code is available
@@ -265,6 +250,41 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta)
265
250
}
266
251
}
267
252
253
+ public void renderEntityInInventoryFollowsMouseBackwards (GuiGraphics guiGraphics , int i , int j , int k , int l , int m , float f , float g , float h , LivingEntity livingEntity ) {
254
+ float mousex = -(((float ) width / 2 ) - 75 - g );
255
+ float mousey = ((float ) height / 2 ) - h ;
256
+ float n = (float ) (i + k ) / 2.0F ;
257
+ float o = (float ) (j + l ) / 2.0F ;
258
+ float p = (float ) Math .atan (mousex / 40.0f );
259
+ float q = (float ) Math .atan (mousey / 40.0f );
260
+ guiGraphics .enableScissor (i , j , k , l );
261
+ //float p = (float) Math.atan((double) ((n - g) / 40.0F));
262
+ //float q = (float) Math.atan((double) ((o - h) / 40.0F));
263
+ Quaternionf quaternionf = (new Quaternionf ()).rotateZ (3.1415927F );
264
+ Quaternionf quaternionf2 = (new Quaternionf ()).rotateX (q * 20.0F * 0.017453292F );
265
+ quaternionf .mul (quaternionf2 );
266
+ float r = livingEntity .yBodyRot ;
267
+ float s = livingEntity .getYRot ();
268
+ float t = livingEntity .getXRot ();
269
+ float u = livingEntity .yHeadRotO ;
270
+ float v = livingEntity .yHeadRot ;
271
+ livingEntity .yBodyRot = p * 40.0F ;
272
+ livingEntity .setYRot (p * 40.0F );
273
+ livingEntity .setXRot (-q * 40.0F );
274
+ livingEntity .yHeadRot = livingEntity .getYRot ();
275
+ livingEntity .yHeadRotO = livingEntity .getYRot ();
276
+ float w = livingEntity .getScale ();
277
+ Vector3f vector3f = new Vector3f (0.0F , livingEntity .getBbHeight () / 2.0F + f * w , 0.0F );
278
+ float x = (float ) m / w ;
279
+ InventoryScreen .renderEntityInInventory (guiGraphics , n , o , x , vector3f , quaternionf , quaternionf2 , livingEntity );
280
+ livingEntity .yBodyRot = r ;
281
+ livingEntity .setYRot (s );
282
+ livingEntity .setXRot (t );
283
+ livingEntity .yHeadRotO = u ;
284
+ livingEntity .yHeadRot = v ;
285
+ guiGraphics .disableScissor ();
286
+ }
287
+
268
288
/**
269
289
* Draws tabs.
270
290
*
0 commit comments