Skip to content

Commit e9990e6

Browse files
crosby-moexpple
andauthored
skip intersection checks by directly submitting to current layer (xpple#104)
* skip intersection checks by directly submitting to current layer * oops, all slime chunks! * Add comment --------- Co-authored-by: Frederik van der Els <[email protected]>
1 parent fa86939 commit e9990e6

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/main/java/dev/xpple/seedmapper/seedmap/SeedMapScreen.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.google.common.collect.BiMap;
1818
import com.google.common.collect.ImmutableBiMap;
1919
import com.mojang.blaze3d.platform.InputConstants;
20+
import com.mojang.blaze3d.textures.GpuTextureView;
2021
import com.mojang.brigadier.exceptions.CommandSyntaxException;
2122
import dev.xpple.seedmapper.SeedMapper;
2223
import dev.xpple.seedmapper.command.arguments.CanyonCarverArgument;
@@ -47,6 +48,8 @@
4748
import net.minecraft.client.gui.GuiGraphics;
4849
import net.minecraft.client.gui.components.EditBox;
4950
import net.minecraft.client.gui.components.PlayerFaceRenderer;
51+
import net.minecraft.client.gui.render.TextureSetup;
52+
import net.minecraft.client.gui.render.state.BlitRenderState;
5053
import net.minecraft.client.gui.screens.Screen;
5154
import net.minecraft.client.input.KeyEvent;
5255
import net.minecraft.client.input.MouseButtonEvent;
@@ -76,6 +79,7 @@
7679
import net.minecraft.world.level.levelgen.WorldgenRandom;
7780
import net.minecraft.world.level.levelgen.XoroshiroRandomSource;
7881
import org.jetbrains.annotations.Nullable;
82+
import org.joml.Matrix3x2f;
7983

8084
import java.lang.foreign.Arena;
8185
import java.lang.foreign.MemoryLayout;
@@ -327,6 +331,8 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
327331
}
328332
}
329333

334+
guiGraphics.nextStratum();
335+
330336
int horChunkRadius = Math.ceilDiv(this.seedMapWidth / 2, SCALED_CHUNK_SIZE * Configs.PixelsPerBiome);
331337
int verChunkRadius = Math.ceilDiv(this.seedMapHeight / 2, SCALED_CHUNK_SIZE * Configs.PixelsPerBiome);
332338

@@ -364,6 +370,8 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
364370
}
365371
});
366372

373+
guiGraphics.nextStratum();
374+
367375
// draw strongholds
368376
if (this.toggleableFeatures.contains(MapFeature.STRONGHOLD) && Configs.ToggledFeatures.contains(MapFeature.STRONGHOLD)) {
369377
TwoDTree tree = strongholdDataCache.get(this.worldIdentifier);
@@ -1060,7 +1068,13 @@ public boolean equals(Object o) {
10601068
static void drawFeatureIcon(GuiGraphics guiGraphics, MapFeature.Texture texture, int minX, int minY, int colour) {
10611069
int iconWidth = texture.width();
10621070
int iconHeight = texture.height();
1063-
guiGraphics.blit(RenderPipelines.GUI_TEXTURED, texture.resourceLocation(), minX, minY, 0, 0, iconWidth, iconHeight, iconWidth, iconHeight, colour);
1071+
1072+
// Skip intersection checks (GuiRenderState.hasIntersection) you would otherwise get when calling
1073+
// GuiGraphics.blit(RenderPipeline, ResourceLocation, int, int, float, float, int, int, int, int, int)
1074+
// as these checks incur a significant performance hit
1075+
GpuTextureView gpuTextureView = Minecraft.getInstance().getTextureManager().getTexture(texture.resourceLocation()).getTextureView();
1076+
BlitRenderState renderState = new BlitRenderState(RenderPipelines.GUI_TEXTURED, TextureSetup.singleTexture(gpuTextureView), new Matrix3x2f(guiGraphics.pose()), minX, minY, minX + iconWidth, minY + iconHeight, 0, 1, 0, 1, colour, guiGraphics.scissorStack.peek());
1077+
guiGraphics.guiRenderState.submitBlitToCurrentLayer(renderState);
10641078
}
10651079
}
10661080

src/main/resources/seedmapper.aw

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
accessWidener v2 named
2-
accessible class net/minecraft/client/renderer/RenderType$CompositeRenderType
32
accessible class net/minecraft/client/renderer/RenderType$CompositeState
43

54
accessible field net/minecraft/world/level/biome/BiomeManager biomeZoomSeed J

0 commit comments

Comments
 (0)