22
33import com .mojang .blaze3d .systems .RenderSystem ;
44import net .minecraft .client .MinecraftClient ;
5+ import net .minecraft .client .gui .DrawContext ;
56import net .minecraft .client .render .DiffuseLighting ;
6- import net .minecraft .client .render .VertexConsumerProvider ;
77import net .minecraft .client .render .entity .EntityRenderDispatcher ;
88import net .minecraft .client .util .math .MatrixStack ;
99import net .minecraft .entity .LivingEntity ;
@@ -33,10 +33,10 @@ public void setEntity(LivingEntity entity) {
3333 updateScale ();
3434 }
3535
36- public void draw (MatrixStack matrix , float scale ) {
36+ public void draw (DrawContext drawContext , MatrixStack matrix , float scale ) {
3737 if (entity != null ) {
3838 try {
39- drawEntity (matrix , (int ) xOffset , (int ) yOffset , entityScale , -80 , -20 , entity , scale );
39+ drawEntity (drawContext , matrix , (int ) xOffset , (int ) yOffset , entityScale , -80 , -20 , entity , scale );
4040 } catch (Exception e ) {
4141 e .printStackTrace ();
4242 }
@@ -71,15 +71,14 @@ private void updateScale() {
7171 /**
7272 * copied from InventoryScreen.drawEntity() to expose the matrixStack
7373 */
74- public static void drawEntity (MatrixStack matrixStack2 , int x , int y , int size , float mouseX ,
75- float mouseY , LivingEntity entity , float scale ) {
74+ public static void drawEntity (DrawContext drawContext , MatrixStack matrixStack2 , int x , int y , int size ,
75+ float mouseX , float mouseY , LivingEntity entity , float scale ) {
7676 float f = (float ) Math .atan ((double ) (mouseX / 40.0F ));
7777 float g = (float ) Math .atan ((double ) (mouseY / 40.0F ));
7878 Matrix4fStack matrixStack = RenderSystem .getModelViewStack ();
7979 matrixStack .pushMatrix ();
8080 matrixStack .translate (x * scale , y * scale , 1050.0F * scale );
8181 matrixStack .scale (1.0F , 1.0F , -1.0F );
82- RenderSystem .applyModelViewMatrix ();
8382 matrixStack2 .push ();
8483 matrixStack2 .translate (0.0D , 0.0D , 1000.0D );
8584 matrixStack2 .scale ((float ) size , (float ) size , (float ) size );
@@ -102,13 +101,10 @@ public static void drawEntity(MatrixStack matrixStack2, int x, int y, int size,
102101 quaternion2 .conjugate ();
103102 entityRenderDispatcher .setRotation (quaternion2 );
104103 entityRenderDispatcher .setRenderShadows (false );
105- VertexConsumerProvider .Immediate immediate =
106- MinecraftClient .getInstance ().getBufferBuilders ().getEntityVertexConsumers ();
107- RenderSystem .runAsFancy (() -> {
108- entityRenderDispatcher .render (entity , 0.0D , 0.0D , 0.0D , 0.0F , 1.0F , matrixStack2 , immediate ,
109- 15728880 );
104+ drawContext .draw (vertexConsumerProvider -> {
105+ entityRenderDispatcher .render (entity , 0.0D , 0.0D , 0.0D , 1.0F , matrixStack2 ,
106+ vertexConsumerProvider , 15728880 );
110107 });
111- immediate .draw ();
112108 entityRenderDispatcher .setRenderShadows (true );
113109 entity .bodyYaw = h ;
114110 entity .setYaw (i );
@@ -117,7 +113,6 @@ public static void drawEntity(MatrixStack matrixStack2, int x, int y, int size,
117113 entity .headYaw = l ;
118114 matrixStack .popMatrix ();
119115 matrixStack2 .pop ();
120- RenderSystem .applyModelViewMatrix ();
121116 DiffuseLighting .enableGuiDepthLighting ();
122117 }
123118
0 commit comments