7878import net .minecraft .world .level .levelgen .PositionalRandomFactory ;
7979import net .minecraft .world .level .levelgen .WorldgenRandom ;
8080import net .minecraft .world .level .levelgen .XoroshiroRandomSource ;
81+ import net .minecraft .world .phys .Vec2 ;
8182import org .jetbrains .annotations .Nullable ;
8283import org .joml .Matrix3x2f ;
8384
@@ -194,6 +195,7 @@ public class SeedMapScreen extends Screen {
194195 private final SeedMapCache <TilePos , BitSet > slimeChunkCache ;
195196
196197 private final BlockPos playerPos ;
198+ private final Vec2 playerRotation ;
197199
198200 private QuartPos2f centerQuart ;
199201
@@ -219,9 +221,11 @@ public class SeedMapScreen extends Screen {
219221 private @ Nullable FeatureWidget markerWidget = null ;
220222 private @ Nullable ChestLootWidget chestLootWidget = null ;
221223
224+ private static final ResourceLocation DIRECTION_ARROW_TEXTURE = ResourceLocation .fromNamespaceAndPath (SeedMapper .MOD_ID , "textures/gui/arrow.png" );
225+
222226 private Registry <Enchantment > enchantmentsRegistry ;
223227
224- public SeedMapScreen (long seed , int dimension , int version , BlockPos playerPos ) {
228+ public SeedMapScreen (long seed , int dimension , int version , BlockPos playerPos , Vec2 playerRotation ) {
225229 super (Component .empty ());
226230 this .seed = seed ;
227231 this .dimension = dimension ;
@@ -292,6 +296,7 @@ public SeedMapScreen(long seed, int dimension, int version, BlockPos playerPos)
292296 .orElseThrow ();
293297
294298 this .playerPos = playerPos ;
299+ this .playerRotation = playerRotation ;
295300
296301 this .centerQuart = QuartPos2f .fromQuartPos (QuartPos2 .fromBlockPos (this .playerPos ));
297302 this .mouseQuart = QuartPos2 .fromQuartPos2f (this .centerQuart );
@@ -453,13 +458,27 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
453458 }
454459
455460 // draw player position
456- QuartPos2f relPlayerQuart = QuartPos2f .fromQuartPos (QuartPos2 .fromBlockPos (this .playerPos )).subtract (this .centerQuart );
457- int playerMinX = this .centerX + Mth .floor (Configs .PixelsPerBiome * relPlayerQuart .x ()) - 10 ;
458- int playerMinY = this .centerY + Mth .floor (Configs .PixelsPerBiome * relPlayerQuart .z ()) - 10 ;
459- int playerMaxX = playerMinX + 20 ;
460- int playerMaxY = playerMinY + 20 ;
461- if (playerMinX >= HORIZONTAL_PADDING && playerMaxX <= HORIZONTAL_PADDING + this .seedMapWidth && playerMinY >= VERTICAL_PADDING && playerMaxY <= VERTICAL_PADDING + this .seedMapHeight ) {
462- PlayerFaceRenderer .draw (guiGraphics , this .minecraft .player .getSkin (), playerMinX , playerMinY , 20 );
461+ if (this .toggleableFeatures .contains (MapFeature .PLAYER_ICON ) && Configs .ToggledFeatures .contains (MapFeature .PLAYER_ICON )) {
462+ QuartPos2f relPlayerQuart = QuartPos2f .fromQuartPos (QuartPos2 .fromBlockPos (this .playerPos )).subtract (this .centerQuart );
463+ int playerMinX = this .centerX + Mth .floor (Configs .PixelsPerBiome * relPlayerQuart .x ()) - 10 ;
464+ int playerMinY = this .centerY + Mth .floor (Configs .PixelsPerBiome * relPlayerQuart .z ()) - 10 ;
465+ int playerMaxX = playerMinX + 20 ;
466+ int playerMaxY = playerMinY + 20 ;
467+ if (playerMinX >= HORIZONTAL_PADDING && playerMaxX <= HORIZONTAL_PADDING + this .seedMapWidth && playerMinY >= VERTICAL_PADDING && playerMaxY <= VERTICAL_PADDING + this .seedMapHeight ) {
468+ PlayerFaceRenderer .draw (guiGraphics , this .minecraft .player .getSkin (), playerMinX , playerMinY , 20 );
469+ }
470+
471+ // draw player direction arrow
472+ guiGraphics .pose ().pushMatrix ();
473+ guiGraphics .pose () // transformations are applied in reverse order
474+ .translate (10 , 10 )
475+ .translate (playerMinX , playerMinY )
476+ .rotate ((float ) (Math .toRadians (this .playerRotation .y ) + Math .PI ))
477+ .translate (-10 , -10 )
478+ .translate (0 , -30 )
479+ ;
480+ drawIcon (guiGraphics , DIRECTION_ARROW_TEXTURE , 0 , 0 , 20 , 20 , 0xFF_FFFFFF );
481+ guiGraphics .pose ().popMatrix ();
463482 }
464483
465484 // calculate spawn point
@@ -1125,15 +1144,19 @@ static void drawFeatureIcon(GuiGraphics guiGraphics, MapFeature.Texture texture,
11251144 int iconWidth = texture .width ();
11261145 int iconHeight = texture .height ();
11271146
1128- // Skip intersection checks (GuiRenderState.hasIntersection) you would otherwise get when calling
1129- // GuiGraphics.blit(RenderPipeline, ResourceLocation, int, int, float, float, int, int, int, int, int)
1130- // as these checks incur a significant performance hit
1131- GpuTextureView gpuTextureView = Minecraft .getInstance ().getTextureManager ().getTexture (texture .resourceLocation ()).getTextureView ();
1132- 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 ());
1133- guiGraphics .guiRenderState .submitBlitToCurrentLayer (renderState );
1147+ drawIcon (guiGraphics , texture .resourceLocation (), minX , minY , iconWidth , iconHeight , colour );
11341148 }
11351149 }
11361150
1151+ private static void drawIcon (GuiGraphics guiGraphics , ResourceLocation resourceLocation , int minX , int minY , int iconWidth , int iconHeight , int colour ) {
1152+ // Skip intersection checks (GuiRenderState.hasIntersection) you would otherwise get when calling
1153+ // GuiGraphics.blit(RenderPipeline, ResourceLocation, int, int, float, float, int, int, int, int, int)
1154+ // as these checks incur a significant performance hit
1155+ GpuTextureView gpuTextureView = Minecraft .getInstance ().getTextureManager ().getTexture (resourceLocation ).getTextureView ();
1156+ 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 ());
1157+ guiGraphics .guiRenderState .submitBlitToCurrentLayer (renderState );
1158+ }
1159+
11371160 private static final BiMap <Integer , ResourceKey <Level >> DIM_ID_TO_MC = ImmutableBiMap .of (
11381161 Cubiomes .DIM_OVERWORLD (), Level .OVERWORLD ,
11391162 Cubiomes .DIM_NETHER (), Level .NETHER ,
0 commit comments