Skip to content

Commit facb495

Browse files
committed
Minimap Fix
1 parent 74cd6e9 commit facb495

File tree

4 files changed

+45
-6
lines changed

4 files changed

+45
-6
lines changed

src/main/java/dev/xpple/seedmapper/SeedMapper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,14 @@ public void onInitializeClient() {
8383
SeedDatabaseHelper.fetchSeeds();
8484

8585
KeyMapping keyMapping = KeyBindingHelper.registerKeyBinding(new KeyMapping("key.seedMap", InputConstants.KEY_M, KeyMapping.Category.GAMEPLAY));
86+
KeyMapping minimapKeyMapping = KeyBindingHelper.registerKeyBinding(new KeyMapping("key.seedMapMinimap", InputConstants.KEY_COMMA, KeyMapping.Category.GAMEPLAY));
8687
ClientTickEvents.END_CLIENT_TICK.register(minecraft -> {
8788
while (keyMapping.consumeClick()) {
8889
minecraft.player.connection.sendCommand("sm:seedmap");
8990
}
91+
while (minimapKeyMapping.consumeClick()) {
92+
minecraft.player.connection.sendCommand("sm:minimap");
93+
}
9094
});
9195

9296
ClientCommandRegistrationCallback.EVENT.register(SeedMapper::registerCommands);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ private static void setPixelsPerBiome(double pixelsPerBiome) {
6464
}
6565

6666
@Config(setter = @Config.Setter("setMinimapOffsetX"))
67-
public static int SeedMapMinimapOffsetX = 5;
67+
public static int SeedMapMinimapOffsetX = 4;
6868

6969
private static void setMinimapOffsetX(int offsetX) {
7070
SeedMapMinimapOffsetX = Math.max(0, offsetX);
7171
}
7272

7373
@Config(setter = @Config.Setter("setMinimapOffsetY"))
74-
public static int SeedMapMinimapOffsetY = 5;
74+
public static int SeedMapMinimapOffsetY = 4;
7575

7676
private static void setMinimapOffsetY(int offsetY) {
7777
SeedMapMinimapOffsetY = Math.max(0, offsetY);
@@ -92,10 +92,10 @@ private static void setMinimapHeight(int height) {
9292
}
9393

9494
@Config
95-
public static boolean SeedMapMinimapRotateWithPlayer = false;
95+
public static boolean SeedMapMinimapRotateWithPlayer = true;
9696

9797
@Config(setter = @Config.Setter("setMinimapPixelsPerBiome"))
98-
public static double SeedMapMinimapPixelsPerBiome = 2.0D;
98+
public static double SeedMapMinimapPixelsPerBiome = 1.5D;
9999

100100
private static void setMinimapPixelsPerBiome(double pixelsPerBiome) {
101101
SeedMapMinimapPixelsPerBiome = Math.clamp(pixelsPerBiome, SeedMapScreen.MIN_PIXELS_PER_BIOME, SeedMapScreen.MAX_PIXELS_PER_BIOME);

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import net.minecraft.core.BlockPos;
1010
import net.minecraft.util.Mth;
1111
import net.minecraft.world.phys.Vec3;
12+
import org.joml.Matrix3x2fStack;
1213

1314
public class SeedMapMinimapScreen extends SeedMapScreen {
1415

@@ -62,7 +63,7 @@ public void renderToHud(GuiGraphics guiGraphics, LocalPlayer player, float parti
6263

6364
this.setFeatureIconRenderingEnabled(false);
6465
this.setMarkerRenderingEnabled(false);
65-
this.setPlayerIconRenderingEnabled(!rotateWithPlayer);
66+
this.setPlayerIconRenderingEnabled(false);
6667

6768
var pose = guiGraphics.pose();
6869
pose.pushMatrix();
@@ -72,6 +73,7 @@ public void renderToHud(GuiGraphics guiGraphics, LocalPlayer player, float parti
7273
pose.translate((float) -centerX, (float) -centerY);
7374
}
7475
pose.translate((float) translateX, (float) translateY);
76+
this.featureWidgets.clear();
7577
this.renderSeedMap(guiGraphics, Integer.MIN_VALUE, Integer.MIN_VALUE, partialTick);
7678
pose.popMatrix();
7779

@@ -82,6 +84,8 @@ public void renderToHud(GuiGraphics guiGraphics, LocalPlayer player, float parti
8284
this.renderMinimapIcons(guiGraphics, translateX, translateY, centerX, centerY, rotationRadians);
8385
if (rotateWithPlayer) {
8486
this.drawCenterCross(guiGraphics, centerX, centerY);
87+
} else {
88+
this.drawCenteredPlayerDirectionArrow(guiGraphics, centerX, centerY, 6.0D, partialTick);
8589
}
8690

8791
guiGraphics.disableScissor();

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ private boolean handleMapFeatureLeftClicked(MouseButtonEvent mouseButtonEvent, b
15721572
return true;
15731573
}
15741574

1575-
private void drawPlayerDirectionArrow(GuiGraphics guiGraphics, int playerMinX, int playerMinY, float partialTick) {
1575+
protected void drawPlayerDirectionArrow(GuiGraphics guiGraphics, int playerMinX, int playerMinY, float partialTick) {
15761576
LocalPlayer player = this.minecraft.player;
15771577
if (player == null) {
15781578
return;
@@ -1613,6 +1613,37 @@ private void drawPlayerDirectionArrow(GuiGraphics guiGraphics, int playerMinX, i
16131613
poseStack.popMatrix();
16141614
}
16151615

1616+
protected void drawCenteredPlayerDirectionArrow(GuiGraphics guiGraphics, double centerX, double centerY, double iconHalf, float partialTick) {
1617+
LocalPlayer player = this.minecraft.player;
1618+
if (player == null) {
1619+
return;
1620+
}
1621+
Vec3 look = player.getViewVector(partialTick);
1622+
double dirX = look.x;
1623+
double dirZ = look.z;
1624+
double length = Math.hypot(dirX, dirZ);
1625+
if (length < 1.0E-4D) {
1626+
return;
1627+
}
1628+
double normX = dirX / length;
1629+
double normZ = dirZ / length;
1630+
1631+
double arrowScale = (PLAYER_DIRECTION_ARROW_DRAW_HEIGHT / PLAYER_DIRECTION_ARROW_TEXTURE_HEIGHT) * (iconHalf / 10.0D);
1632+
float angle = (float) Math.atan2(normX, -normZ);
1633+
1634+
Matrix3x2fStack poseStack = guiGraphics.pose();
1635+
poseStack.pushMatrix();
1636+
poseStack.translate((float) centerX, (float) centerY);
1637+
poseStack.rotate(angle);
1638+
poseStack.scale((float) arrowScale, (float) arrowScale);
1639+
poseStack.translate(-PLAYER_DIRECTION_ARROW_TEXTURE_WIDTH / 2.0F, -PLAYER_DIRECTION_ARROW_TEXTURE_HEIGHT / 2.0F);
1640+
1641+
GpuTextureView gpuTextureView = Minecraft.getInstance().getTextureManager().getTexture(PLAYER_DIRECTION_ARROW_TEXTURE).getTextureView();
1642+
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());
1643+
guiGraphics.guiRenderState.submitBlitToCurrentLayer(renderState);
1644+
poseStack.popMatrix();
1645+
}
1646+
16161647
private boolean hasEndCityShip(BlockPos pos) {
16171648
int biome = Cubiomes.getBiomeAt(this.biomeGenerator, BIOME_SCALE, QuartPos.fromBlock(pos.getX()), QuartPos.fromBlock(320), QuartPos.fromBlock(pos.getZ()));
16181649
try (Arena tempArena = Arena.ofConfined()) {

0 commit comments

Comments
 (0)