1919import net .minecraft .client .player .LocalPlayer ;
2020import net .minecraft .client .player .RemotePlayer ;
2121import net .minecraft .client .renderer .CoreShaders ;
22- import net .minecraft .client .renderer .MultiBufferSource ;
2322import net .minecraft .client .renderer .texture .OverlayTexture ;
2423import net .minecraft .client .resources .sounds .SimpleSoundInstance ;
2524import net .minecraft .core .BlockPos ;
4645import sh .okx .civmodern .common .events .PostRenderGameOverlayEvent ;
4746
4847import java .net .URL ;
49- import java .util .ArrayList ;
5048import java .util .Collections ;
5149import java .util .HashSet ;
52- import java .util .List ;
5350import java .util .Random ;
5451import java .util .Set ;
5552import java .util .UUID ;
56- import java .util .function .Consumer ;
5753
5854import static org .lwjgl .opengl .GL11 .*;
5955
@@ -258,28 +254,25 @@ public void render(GuiGraphics guiGraphics, float delta) {
258254 private void renderBoatsMinecarts (GuiGraphics guiGraphics , float delta ) {
259255 Minecraft minecraft = Minecraft .getInstance ();
260256
261- List <Consumer <MultiBufferSource >> consumers = new ArrayList <>();
262-
263257 for (Entity entity : minecraft .level .entitiesForRendering ()) {
264258 if (entity instanceof Boat boat ) {
265- consumers . add ( renderEntity (guiGraphics , minecraft .player , boat , delta , boat .getPickResult (), 1.0f , 0.9f ) );
259+ renderEntity (guiGraphics , minecraft .player , boat , delta , boat .getPickResult (), 1.0f , 0.9f );
266260 } else if (entity instanceof Minecart minecart ) {
267- consumers . add ( renderEntity (guiGraphics , minecraft .player , minecart , delta , new ItemStack (Items .MINECART , 1 ), 1.1f , 0.9f ) );
261+ renderEntity (guiGraphics , minecraft .player , minecart , delta , new ItemStack (Items .MINECART , 1 ), 1.1f , 0.9f );
268262 }
269263 }
270- guiGraphics .drawSpecial ( s -> consumers . forEach ( v -> v . accept ( s )) );
264+ guiGraphics .flush ( );
271265 }
272266
273267 private void renderItems (GuiGraphics guiGraphics , float delta ) {
274268 Minecraft minecraft = Minecraft .getInstance ();
275269
276- List <Consumer <MultiBufferSource >> consumers = new ArrayList <>();
277270 for (Entity entity : minecraft .level .entitiesForRendering ()) {
278271 if (entity instanceof ItemEntity item ) {
279- consumers . add ( renderEntity (guiGraphics , minecraft .player , item , delta , item .getItem (), 0f , 0.9f ) );
272+ renderEntity (guiGraphics , minecraft .player , item , delta , item .getItem (), 0f , 0.9f );
280273 }
281274 }
282- guiGraphics .drawSpecial ( s -> consumers . forEach ( v -> v . accept ( s )) );
275+ guiGraphics .flush ( );
283276 }
284277
285278 private double rescale (double dx , double dz ) {
@@ -291,7 +284,7 @@ private double rescale(double dx, double dz) {
291284 return (1 / distance ) * ld ;
292285 }
293286
294- private Consumer < MultiBufferSource > renderEntity (GuiGraphics guiGraphics , Player player , Entity entity , float delta , ItemStack item , float blit , float entityScale ) {
287+ private void renderEntity (GuiGraphics guiGraphics , Player player , Entity entity , float delta , ItemStack item , float blit , float entityScale ) {
295288 double scale = config .getRadarSize () / config .getRange ();
296289
297290 double px = player .xOld + (player .getX () - player .xOld ) * delta ;
@@ -302,28 +295,29 @@ private Consumer<MultiBufferSource> renderEntity(GuiGraphics guiGraphics, Player
302295 double dx = px - x ;
303296 double dz = pz - z ;
304297 if (dx * dx + dz * dz > config .getRange () * config .getRange ()) {
305- return s -> {} ;
298+ return ;
306299 }
307300
308301 double logscale = rescale (dx , dz );
309302
310- return source -> {
311- guiGraphics .pose ().pushPose ();
312- guiGraphics .pose ().translate (dx * scale * logscale , dz * scale * logscale , 150 );
313- if (config .isNorthUp ()) {
314- guiGraphics .pose ().mulPose (Axis .ZP .rotationDegrees (180 ));
315- } else {
316- guiGraphics .pose ().mulPose (Axis .ZP .rotationDegrees (player .getViewYRot (delta )));
317- }
318- guiGraphics .pose ().translate (0 , 0 , blit );
319- guiGraphics .pose ().scale (config .getIconSize () * entityScale , config .getIconSize () * entityScale , 1 );
320- guiGraphics .pose ().mulPose (new Matrix4f ().scaling (1.0f , -1.0f , 1.0f ));
321- guiGraphics .pose ().scale (16.0f , 16.0f , 16.0f );
322- Lighting .setupForFlatItems ();
323- Minecraft .getInstance ().getItemRenderer ().renderStatic (player , item , ItemDisplayContext .GUI , false , guiGraphics .pose (), source , Minecraft .getInstance ().level , 0xF000F0 , OverlayTexture .NO_OVERLAY , 0 );
324- Lighting .setupFor3DItems ();
325- guiGraphics .pose ().popPose ();
326- };
303+ guiGraphics .pose ().pushPose ();
304+ guiGraphics .pose ().translate (dx * scale * logscale , dz * scale * logscale , 150 );
305+ if (config .isNorthUp ()) {
306+ guiGraphics .pose ().mulPose (Axis .ZP .rotationDegrees (180 ));
307+ } else {
308+ guiGraphics .pose ().mulPose (Axis .ZP .rotationDegrees (player .getViewYRot (delta )));
309+ }
310+ guiGraphics .pose ().translate (0 , 0 , blit );
311+ guiGraphics .pose ().scale (config .getIconSize () * entityScale , config .getIconSize () * entityScale , 1 );
312+ guiGraphics .pose ().mulPose (new Matrix4f ().scaling (1.0f , -1.0f , 1.0f ));
313+ guiGraphics .pose ().scale (16.0f , 16.0f , 16.0f );
314+
315+ Lighting .setupForFlatItems ();
316+ guiGraphics .drawSpecial (source ->
317+ Minecraft .getInstance ().getItemRenderer ().renderStatic (player , item , ItemDisplayContext .GUI , false , guiGraphics .pose (), source , Minecraft .getInstance ().level , 0xF000F0 , OverlayTexture .NO_OVERLAY , 0 ));
318+ Lighting .setupFor3DItems ();
319+
320+ guiGraphics .pose ().popPose ();
327321 }
328322
329323 private void renderPlayers (GuiGraphics guiGraphics , float delta ) {
0 commit comments