Skip to content

Commit 4ac69d8

Browse files
committed
Added Directional Arrow + Other Fixes
1 parent d66cb35 commit 4ac69d8

File tree

5 files changed

+87
-17
lines changed

5 files changed

+87
-17
lines changed

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ Original Repo: https://github.com/xpple/SeedMapper/
66

77
This project is a friendly, independent fork of Seedmapper. I have not proposed any improvements or features to the upstream but I am welcome to them incorporating my changes. I will sporatically maintain this project and re-base/sync with the upstream project.
88

9-
## Installation and pre-requisites
9+
## Compiling
1010

11-
See original [repo](https://github.com/xpple/SeedMapper) for the project. A precompiled version of my fork will be made available for download.
11+
Original instructions do not apply. Clone and compile as normal. I have included the Cubiome and JExtract files already.
1212

1313
## Improvements
1414

15-
![Screenshot](https://i.imgur.com/m1lzryd.png)
16-
1715
### Java 21
1816
Project now builds against Java 21 LTS, however, Minecraft/Fabric must have the flag ```--enable-preview``` added to the Java arguments.
1917

@@ -22,17 +20,26 @@ This tells the JVM to accept preview bytecode and APIs. Functionally nothing els
2220
![Flag](https://i.imgur.com/rOsP2H0.png)
2321

2422
### Zoom
25-
Zoom further out on the SeedMap
23+
Zoom further out on the SeedMap. Limited to approx 30,000x30,000. I suggest enabling the clear cache setting below.
24+
25+
![Zoomies](https://i.imgur.com/utIgDkp.png)
26+
27+
### Directional Arrow
28+
Around your player icon in the SeedMap there will be a little arrow showing you which direction you're facing. This is toggleable with ```/sm:config ShowPlayerDirectionArrow```.
29+
30+
![Arrow](https://i.imgur.com/pkodE8d.png)
2631

2732
### Memory Handling
28-
Added a config option ```/sm:config ClearSeedMapCachesOnClose``` to clear tiles, per‑world locations and any other relevant caches. When enabled, this prevents FPS dips from garbage collection on large caches after zooming out far and then closing the map.
33+
Added a config option ```/sm:config ClearSeedMapCachesOnClose``` to clear tiles, per‑world locations and any other relevant caches. When enabled, this prevents FPS dips from garbage collection on large caches after zooming out far and then closing the map. Opening the map again will result it in being loaded like its the first time, at smaller zoom levels this isn't a problem.
2934

3035
### Icon Text
3136
When hovering over location icons in the SeedMap it will display text telling you what the locations are.
3237

38+
![Text](https://i.imgur.com/A5gCXgP.png)
39+
3340
### Added Elytra/End Ship Locations
3441
Can now find Elytra via locating End Ships with the locate command ```/sm:locate feature end_city_ship``` or simply selecting the Elytra icon in the SeedMap
35-
This has now been implemented by upstream. I have however kept my original Elytra icon, because we aren't going to the ships for anything else are we?
42+
This has now been implemented by upstream. They have unified both End City Ships and End Cities together. I have utilised their change but kept my original Elytra icon, because we aren't going to the ships for anything else are we?
3643

3744
### Export SeedMap
3845
- Added **Export JSON** button on the top right of the SeedMap screen which will export all selected locations to a JSON
@@ -44,6 +51,8 @@ Configurable ESP settings allowing for custom colors, fill (imperfect) and trans
4451

4552
Example: ```/sm:config blockhighlightesp set outlineColor #ff0000 outlineAlpha 0.5 fillEnabled true fillColor #00ff00 fillAlpha 0.35```
4653

54+
![ESP](https://i.imgur.com/S9KeYpR.png)
55+
4756
### Highlight Timeout Setting
4857

4958
Can now change the default 5 minute render timeout with ```/sm:config esptimeout```

src/main/java/dev/xpple/seedmapper/config/Configs.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ private static void setPixelsPerBiome(double pixelsPerBiome) {
6363
PixelsPerBiome = Math.clamp(pixelsPerBiome, SeedMapScreen.MIN_PIXELS_PER_BIOME, SeedMapScreen.MAX_PIXELS_PER_BIOME);
6464
}
6565

66+
@Config(comment = "getPlayerDirectionArrowComment")
67+
public static boolean ShowPlayerDirectionArrow = true;
68+
69+
private static Component getPlayerDirectionArrowComment() {
70+
return Component.translatable("config.showPlayerDirectionArrow.comment");
71+
}
72+
6673
@Config(chatRepresentation = "listToggledFeatures")
6774
public static EnumSet<MapFeature> ToggledFeatures = Util.make(() -> {
6875
EnumSet<MapFeature> toggledFeatures = EnumSet.allOf(MapFeature.class);

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

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@
8989
import net.minecraft.world.level.levelgen.PositionalRandomFactory;
9090
import net.minecraft.world.level.levelgen.WorldgenRandom;
9191
import net.minecraft.world.level.levelgen.XoroshiroRandomSource;
92+
import net.minecraft.world.phys.Vec3;
9293
import org.jetbrains.annotations.Nullable;
9394
import org.slf4j.Logger;
9495
import org.joml.Matrix3x2f;
96+
import org.joml.Matrix3x2fStack;
9597
import org.joml.Vector2i;
9698

9799
import java.lang.foreign.Arena;
@@ -209,6 +211,13 @@ public class SeedMapScreen extends Screen {
209211
return new Vector2i(x, y);
210212
};
211213

214+
private static final ResourceLocation PLAYER_DIRECTION_ARROW_TEXTURE = ResourceLocation.fromNamespaceAndPath(SeedMapper.MOD_ID, "textures/feature_icons/arrow.png");
215+
private static final int PLAYER_DIRECTION_ARROW_TEXTURE_WIDTH = 100;
216+
private static final int PLAYER_DIRECTION_ARROW_TEXTURE_HEIGHT = 101;
217+
private static final double PLAYER_DIRECTION_ARROW_DRAW_HEIGHT = 12.0D;
218+
private static final double PLAYER_DIRECTION_ARROW_TIP_OFFSET = 15.0D;
219+
private static final double PLAYER_DIRECTION_ARROW_PIVOT_Y = 99.0D;
220+
212221
private static int tileSizePixels() {
213222
double baseSize = TilePos.TILE_SIZE_CHUNKS * (double) SCALED_CHUNK_SIZE;
214223
double pixelsPerBiome = Math.max(MIN_PIXELS_PER_BIOME, Configs.PixelsPerBiome);
@@ -527,16 +536,6 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
527536
});
528537
}
529538

530-
// draw player position
531-
QuartPos2f relPlayerQuart = QuartPos2f.fromQuartPos(QuartPos2.fromBlockPos(this.playerPos)).subtract(this.centerQuart);
532-
int playerMinX = this.centerX + Mth.floor(Configs.PixelsPerBiome * relPlayerQuart.x()) - 10;
533-
int playerMinY = this.centerY + Mth.floor(Configs.PixelsPerBiome * relPlayerQuart.z()) - 10;
534-
int playerMaxX = playerMinX + 20;
535-
int playerMaxY = playerMinY + 20;
536-
if (playerMinX >= HORIZONTAL_PADDING && playerMaxX <= HORIZONTAL_PADDING + this.seedMapWidth && playerMinY >= VERTICAL_PADDING && playerMaxY <= VERTICAL_PADDING + this.seedMapHeight) {
537-
PlayerFaceRenderer.draw(guiGraphics, this.minecraft.player.getSkin(), playerMinX, playerMinY, 20);
538-
}
539-
540539
// calculate spawn point
541540
if (this.toggleableFeatures.contains(MapFeature.WORLD_SPAWN) && Configs.ToggledFeatures.contains(MapFeature.WORLD_SPAWN)) {
542541
BlockPos spawnPoint = spawnDataCache.computeIfAbsent(this.worldIdentifier, ignored -> this.calculateSpawnData());
@@ -548,6 +547,19 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
548547
FeatureWidget.drawFeatureIcon(guiGraphics, this.markerWidget.featureTexture, this.markerWidget.x, this.markerWidget.y, -1);
549548
}
550549

550+
// draw player position last so it always appears on top
551+
QuartPos2f relPlayerQuart = QuartPos2f.fromQuartPos(QuartPos2.fromBlockPos(this.playerPos)).subtract(this.centerQuart);
552+
int playerMinX = this.centerX + Mth.floor(Configs.PixelsPerBiome * relPlayerQuart.x()) - 10;
553+
int playerMinY = this.centerY + Mth.floor(Configs.PixelsPerBiome * relPlayerQuart.z()) - 10;
554+
int playerMaxX = playerMinX + 20;
555+
int playerMaxY = playerMinY + 20;
556+
if (playerMinX >= HORIZONTAL_PADDING && playerMaxX <= HORIZONTAL_PADDING + this.seedMapWidth && playerMinY >= VERTICAL_PADDING && playerMaxY <= VERTICAL_PADDING + this.seedMapHeight) {
557+
PlayerFaceRenderer.draw(guiGraphics, this.minecraft.player.getSkin(), playerMinX, playerMinY, 20);
558+
if (Configs.ShowPlayerDirectionArrow) {
559+
this.drawPlayerDirectionArrow(guiGraphics, playerMinX, playerMinY, partialTick);
560+
}
561+
}
562+
551563
// draw chest loot widget
552564
if (this.chestLootWidget != null) {
553565
this.chestLootWidget.render(guiGraphics, mouseX, mouseY, this.font);
@@ -1435,6 +1447,47 @@ private boolean handleMapFeatureLeftClicked(MouseButtonEvent mouseButtonEvent, b
14351447
return true;
14361448
}
14371449

1450+
private void drawPlayerDirectionArrow(GuiGraphics guiGraphics, int playerMinX, int playerMinY, float partialTick) {
1451+
LocalPlayer player = this.minecraft.player;
1452+
if (player == null) {
1453+
return;
1454+
}
1455+
Vec3 look = player.getViewVector(partialTick);
1456+
double dirX = look.x;
1457+
double dirZ = look.z;
1458+
double length = Math.hypot(dirX, dirZ);
1459+
if (length < 1.0E-4D) {
1460+
return;
1461+
}
1462+
double normX = dirX / length;
1463+
double normZ = dirZ / length;
1464+
1465+
double centerX = playerMinX + 10.0D;
1466+
double centerY = playerMinY + 10.0D;
1467+
double iconHalf = 10.0D;
1468+
1469+
double arrowScale = PLAYER_DIRECTION_ARROW_DRAW_HEIGHT / PLAYER_DIRECTION_ARROW_TEXTURE_HEIGHT;
1470+
double pivotToTip = PLAYER_DIRECTION_ARROW_PIVOT_Y * arrowScale;
1471+
double desiredTipDistance = iconHalf + PLAYER_DIRECTION_ARROW_TIP_OFFSET;
1472+
double pivotDistance = Math.max(0.0D, desiredTipDistance - pivotToTip);
1473+
double pivotX = centerX + normX * pivotDistance;
1474+
double pivotY = centerY + normZ * pivotDistance;
1475+
1476+
float angle = (float) Math.atan2(normX, -normZ);
1477+
1478+
Matrix3x2fStack poseStack = guiGraphics.pose();
1479+
poseStack.pushMatrix();
1480+
poseStack.translate((float) pivotX, (float) pivotY);
1481+
poseStack.rotate(angle);
1482+
poseStack.scale((float) arrowScale, (float) arrowScale);
1483+
poseStack.translate(-PLAYER_DIRECTION_ARROW_TEXTURE_WIDTH / 2.0F, (float) -PLAYER_DIRECTION_ARROW_PIVOT_Y);
1484+
1485+
GpuTextureView gpuTextureView = Minecraft.getInstance().getTextureManager().getTexture(PLAYER_DIRECTION_ARROW_TEXTURE).getTextureView();
1486+
BlitRenderState renderState = new BlitRenderState(RenderPipelines.GUI_TEXTURED, TextureSetup.singleTexture(gpuTextureView), new Matrix3x2f(poseStack), 0, 0, PLAYER_DIRECTION_ARROW_TEXTURE_WIDTH, PLAYER_DIRECTION_ARROW_TEXTURE_HEIGHT, 0, 1, 0, 1, -1, guiGraphics.scissorStack.peek());
1487+
guiGraphics.guiRenderState.submitBlitToCurrentLayer(renderState);
1488+
poseStack.popMatrix();
1489+
}
1490+
14381491
private boolean hasEndCityShip(BlockPos pos) {
14391492
int biome = Cubiomes.getBiomeAt(this.biomeGenerator, BIOME_SCALE, QuartPos.fromBlock(pos.getX()), QuartPos.fromBlock(320), QuartPos.fromBlock(pos.getZ()));
14401493
try (Arena tempArena = Arena.ofConfined()) {

src/main/resources/assets/seedmapper/lang/en_us.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
"config.oreAirCheck.comment": "Whether or not SeedMapper should use in-game air checks to invalidate ore positions.",
9797
"config.devMode.comment": "Enables certain debug commands.",
9898
"config.clearSeedMapCachesOnClose.comment": "If enabled, closing the seed map frees all cached tiles and structures immediately instead of keeping them for faster re-open.",
99+
"config.showPlayerDirectionArrow.comment": "Draws a small arrow outside your icon to show the direction you're facing on the seed map.",
99100
"config.blockHighlightEsp.comment": "Controls the ESP colors used for highlighted block clusters.",
100101
"config.oreVeinEsp.comment": "Controls the ESP colors used for ore vein highlights.",
101102
"config.terrainEsp.comment": "Controls the ESP colors used for terrain outlines.",
3.04 KB
Loading

0 commit comments

Comments
 (0)