Skip to content

Commit 11c31e2

Browse files
crosby-moexpple
authored andcommitted
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 5668c99 commit 11c31e2

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.google.common.collect.BiMap;
2222
import com.google.common.collect.ImmutableBiMap;
2323
import com.mojang.blaze3d.platform.InputConstants;
24+
import com.mojang.blaze3d.textures.GpuTextureView;
2425
import com.mojang.brigadier.exceptions.CommandSyntaxException;
2526
import com.mojang.logging.LogUtils;
2627
import dev.xpple.seedmapper.SeedMapper;
@@ -56,6 +57,8 @@
5657
import net.minecraft.client.gui.components.Button;
5758
import net.minecraft.client.gui.components.EditBox;
5859
import net.minecraft.client.gui.components.PlayerFaceRenderer;
60+
import net.minecraft.client.gui.render.TextureSetup;
61+
import net.minecraft.client.gui.render.state.BlitRenderState;
5962
import net.minecraft.client.gui.screens.Screen;
6063
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
6164
import net.minecraft.client.gui.screens.inventory.tooltip.DefaultTooltipPositioner;
@@ -88,6 +91,7 @@
8891
import net.minecraft.world.level.levelgen.XoroshiroRandomSource;
8992
import org.jetbrains.annotations.Nullable;
9093
import org.slf4j.Logger;
94+
import org.joml.Matrix3x2f;
9195

9296
import java.lang.foreign.Arena;
9397
import java.lang.foreign.MemoryLayout;
@@ -383,9 +387,10 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
383387
}
384388
}
385389

386-
double scaledChunkSpan = SCALED_CHUNK_SIZE * Math.max(MIN_PIXELS_PER_BIOME, Configs.PixelsPerBiome);
387-
int horChunkRadius = (int) Math.ceil((this.seedMapWidth / 2.0) / scaledChunkSpan);
388-
int verChunkRadius = (int) Math.ceil((this.seedMapHeight / 2.0) / scaledChunkSpan);
390+
guiGraphics.nextStratum();
391+
392+
int horChunkRadius = Math.ceilDiv(this.seedMapWidth / 2, SCALED_CHUNK_SIZE * Configs.PixelsPerBiome);
393+
int verChunkRadius = Math.ceilDiv(this.seedMapHeight / 2, SCALED_CHUNK_SIZE * Configs.PixelsPerBiome);
389394

390395
// compute structures
391396
Configs.ToggledFeatures.stream()
@@ -431,6 +436,8 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
431436
}
432437
});
433438

439+
guiGraphics.nextStratum();
440+
434441
// draw strongholds
435442
if (this.toggleableFeatures.contains(MapFeature.STRONGHOLD) && Configs.ToggledFeatures.contains(MapFeature.STRONGHOLD)) {
436443
TwoDTree tree = strongholdDataCache.get(this.worldIdentifier);
@@ -1668,7 +1675,13 @@ public boolean equals(Object o) {
16681675
static void drawFeatureIcon(GuiGraphics guiGraphics, MapFeature.Texture texture, int minX, int minY, int colour) {
16691676
int iconWidth = texture.width();
16701677
int iconHeight = texture.height();
1671-
guiGraphics.blit(RenderPipelines.GUI_TEXTURED, texture.resourceLocation(), minX, minY, 0, 0, iconWidth, iconHeight, iconWidth, iconHeight, colour);
1678+
1679+
// Skip intersection checks (GuiRenderState.hasIntersection) you would otherwise get when calling
1680+
// GuiGraphics.blit(RenderPipeline, ResourceLocation, int, int, float, float, int, int, int, int, int)
1681+
// as these checks incur a significant performance hit
1682+
GpuTextureView gpuTextureView = Minecraft.getInstance().getTextureManager().getTexture(texture.resourceLocation()).getTextureView();
1683+
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());
1684+
guiGraphics.guiRenderState.submitBlitToCurrentLayer(renderState);
16721685
}
16731686
}
16741687

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)