Skip to content

Commit d5b68db

Browse files
committed
Location Isolation + Fixed Duplicate Labels Due To Upstream Merge
1 parent ec54bf7 commit d5b68db

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,16 @@ My fork still remains different, has different commands and retains the opacity
7171

7272
![Map1](https://i.imgur.com/w5U6Aux.png) ![Map2](https://i.imgur.com/MXqXY5n.png)
7373

74+
### Location/Feature Isolation
75+
Ctrl+Click a location icon in SeedMap to isolate it (hide all other icons). Ctrl+Click the same icon again to restore your previous icon set.
76+
77+
You can Ctrl+Click other locations without losing your original selection, as long as you toggle the same icon off again (Ctrl+Click twice) and you don’t add or remove any locations in between.
78+
79+
Special case: Ctrl+Clicking the spawn icon also auto-centers the map on spawn. Your player icon will also remain on, so long as it was enabled to begin with.
80+
7481
### Icon Text
82+
This has been implemented in the [upstream](https://github.com/xpple/SeedMapper/commit/ccc9ec0e044465518e96e9b8d7ac458f671af1c5)! However my variant also covers the icons on the map itself.
83+
7584
When hovering over location icons in the SeedMap it will display text telling you what the locations are.
7685

7786
![Text](https://i.imgur.com/A5gCXgP.png)

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

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
package dev.xpple.seedmapper.seedmap;
22

33
import dev.xpple.seedmapper.config.Configs;
4+
import com.mojang.blaze3d.platform.InputConstants;
5+
import net.minecraft.client.Minecraft;
46
import net.minecraft.client.gui.GuiGraphics;
57
import net.minecraft.client.gui.components.Button;
6-
import net.minecraft.client.gui.components.Tooltip;
78
import net.minecraft.network.chat.Component;
89
import net.minecraft.util.ARGB;
10+
import org.lwjgl.glfw.GLFW;
911

1012
public class FeatureToggleWidget extends Button {
1113

1214
private final MapFeature feature;
15+
private static java.util.EnumSet<MapFeature> savedToggles = null;
16+
private static MapFeature isolatedFeature = null;
1317

1418
public FeatureToggleWidget(MapFeature feature, int x, int y) {
1519
super(x, y, feature.getDefaultTexture().width(), feature.getDefaultTexture().height(), Component.literal(feature.getName()), FeatureToggleWidget::onButtonPress, DEFAULT_NARRATION);
1620
this.feature = feature;
17-
this.setTooltip(Tooltip.create(Component.literal(this.feature.getName())));
1821
}
1922

2023
public Component getTooltip() {
@@ -36,8 +39,46 @@ private static void onButtonPress(Button button) {
3639
if (!(button instanceof FeatureToggleWidget widget)) {
3740
return;
3841
}
42+
if (isControlDown()) {
43+
if (savedToggles != null && isolatedFeature == widget.feature) {
44+
Configs.ToggledFeatures.clear();
45+
Configs.ToggledFeatures.addAll(savedToggles);
46+
savedToggles = null;
47+
isolatedFeature = null;
48+
return;
49+
}
50+
if (savedToggles == null) {
51+
savedToggles = java.util.EnumSet.copyOf(Configs.ToggledFeatures);
52+
}
53+
boolean keepPlayerIcon = Configs.ToggledFeatures.contains(MapFeature.PLAYER_ICON);
54+
Configs.ToggledFeatures.clear();
55+
Configs.ToggledFeatures.add(widget.feature);
56+
if (keepPlayerIcon) {
57+
Configs.ToggledFeatures.add(MapFeature.PLAYER_ICON);
58+
}
59+
isolatedFeature = widget.feature;
60+
if (widget.feature == MapFeature.WORLD_SPAWN) {
61+
centerOnWorldSpawnIfOpen();
62+
}
63+
return;
64+
}
65+
savedToggles = null;
66+
isolatedFeature = null;
3967
if (!Configs.ToggledFeatures.remove(widget.feature)) {
4068
Configs.ToggledFeatures.add(widget.feature);
4169
}
4270
}
71+
72+
private static boolean isControlDown() {
73+
var window = Minecraft.getInstance().getWindow();
74+
return InputConstants.isKeyDown(window, GLFW.GLFW_KEY_LEFT_CONTROL)
75+
|| InputConstants.isKeyDown(window, GLFW.GLFW_KEY_RIGHT_CONTROL);
76+
}
77+
78+
private static void centerOnWorldSpawnIfOpen() {
79+
Minecraft minecraft = Minecraft.getInstance();
80+
if (minecraft.screen instanceof SeedMapScreen screen) {
81+
screen.centerOnWorldSpawn();
82+
}
83+
}
4384
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,11 @@ protected void moveCenter(QuartPos2f newCenter) {
13161316
}
13171317
}
13181318

1319+
void centerOnWorldSpawn() {
1320+
BlockPos spawnPoint = spawnDataCache.computeIfAbsent(this.worldIdentifier, _ -> this.calculateSpawnData());
1321+
this.moveCenter(QuartPos2f.fromQuartPos(QuartPos2.fromBlockPos(spawnPoint)));
1322+
}
1323+
13191324
@Override
13201325
public void tick() {
13211326
super.tick();

0 commit comments

Comments
 (0)