Skip to content

Commit 544c57c

Browse files
committed
Map Changes
1 parent e3752c3 commit 544c57c

File tree

6 files changed

+166
-41
lines changed

6 files changed

+166
-41
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ This tells the JVM to accept preview bytecode and APIs. Functionally nothing els
2424
### Zoom
2525
Zoom further out on the SeedMap
2626

27+
### 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.
29+
30+
### Icon Text
31+
When hovering over location icons in the SeedMap it will display text telling you what the locations are.
32+
2733
### Added Elytra/End Ship Locations
2834
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
2935

@@ -39,4 +45,4 @@ Example: ```/sm:config blockhighlightesp set outlineColor #ff0000 outlineAlpha 0
3945

4046
### Highlight Timeout Setting
4147

42-
Can now change the default 5 minute render timeout with ```/sm:config esptimeout```
48+
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
@@ -90,6 +90,13 @@ private static Component getEspTimeoutComment() {
9090
return Component.translatable("config.espTimeout.comment");
9191
}
9292

93+
@Config(comment = "getClearSeedMapCachesOnCloseComment")
94+
public static boolean ClearSeedMapCachesOnClose = true;
95+
96+
private static Component getClearSeedMapCachesOnCloseComment() {
97+
return Component.translatable("config.clearSeedMapCachesOnClose.comment");
98+
}
99+
93100
@Config
94101
public static EspStyle BlockHighlightESP = EspStyle.useCommandColorDefaults();
95102

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class FeatureToggleWidget extends Button {
1111
private final MapFeature feature;
1212

1313
public FeatureToggleWidget(MapFeature feature, int x, int y) {
14-
super(x, y, feature.getTexture().width(), feature.getTexture().height(), Component.literal(feature.getName()), FeatureToggleWidget::onButtonPress, DEFAULT_NARRATION);
14+
super(x, y, feature.getTexture().width(), feature.getTexture().height(), feature.getDisplayName(), FeatureToggleWidget::onButtonPress, DEFAULT_NARRATION);
1515
this.feature = feature;
1616
}
1717

@@ -24,6 +24,10 @@ protected void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, flo
2424
SeedMapScreen.FeatureWidget.drawFeatureIcon(guiGraphics, this.feature.getTexture(), this.getX(), this.getY(), colour);
2525
}
2626

27+
public Component getTooltip() {
28+
return this.feature.getDisplayName();
29+
}
30+
2731
private static void onButtonPress(Button button) {
2832
if (!(button instanceof FeatureToggleWidget widget)) {
2933
return;

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

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,45 @@
22

33
import com.github.cubiomes.Cubiomes;
44
import dev.xpple.seedmapper.SeedMapper;
5+
import net.minecraft.network.chat.Component;
56
import net.minecraft.resources.ResourceLocation;
67

78
import java.util.Arrays;
89
import java.util.Map;
910
import java.util.stream.Collectors;
1011

1112
public enum MapFeature {
12-
DESERT_PYRAMID("desert_pyramid", Cubiomes.Desert_Pyramid(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_3(), "cubiomes_viewer_icons", 19, 20),
13-
JUNGLE_PYRAMID("jungle_pyramid", Cubiomes.Jungle_Pyramid(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_3(), "cubiomes_viewer_icons", 19, 20),
14-
SWAMP_HUT("swamp_hut", Cubiomes.Swamp_Hut(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_4(), "cubiomes_viewer_icons", 20, 20),
15-
STRONGHOLD("stronghold", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_8(), "cubiomes_viewer_icons", 19, 20),
16-
IGLOO("igloo", Cubiomes.Igloo(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_9(), "cubiomes_viewer_icons", 20, 20),
17-
VILLAGE("village", Cubiomes.Village(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_8(), "cubiomes_viewer_icons", 19, 20),
18-
OCEAN_RUIN("ocean_ruin", Cubiomes.Ocean_Ruin(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "cubiomes_viewer_icons", 19, 19),
19-
SHIPWRECK("shipwreck", Cubiomes.Shipwreck(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "cubiomes_viewer_icons", 19, 19),
20-
MONUMENT("monument", Cubiomes.Monument(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_8(), "cubiomes_viewer_icons", 20, 20),
21-
MANSION("mansion", Cubiomes.Mansion(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_11(), "cubiomes_viewer_icons", 20, 20),
22-
OUTPOST("pillager_outpost", Cubiomes.Outpost(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_14(), "cubiomes_viewer_icons", 19, 20),
23-
RUINED_PORTAL("ruined_portal", Cubiomes.Ruined_Portal(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_16_1(), "cubiomes_viewer_icons", 20, 20),
24-
RUINED_PORTAL_N("ruined_portal_n", Cubiomes.Ruined_Portal_N(), Cubiomes.DIM_NETHER(), Cubiomes.MC_1_16_1(), "cubiomes_viewer_icons", 20, 20),
25-
ANCIENT_CITY("ancient_city", Cubiomes.Ancient_City(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_19_2(), "cubiomes_viewer_icons", 20, 20),
26-
TREASURE("buried_treasure", Cubiomes.Treasure(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "cubiomes_viewer_icons", 19, 19),
27-
MINESHAFT("mineshaft", Cubiomes.Mineshaft(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_8(), "cubiomes_viewer_icons", 20, 19),
28-
DESERT_WELL("desert_well", Cubiomes.Desert_Well(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "cubiomes_viewer_icons", 20, 20),
29-
GEODE("geode", Cubiomes.Geode(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_17(), "cubiomes_viewer_icons", 20, 20),
30-
COPPER_ORE_VEIN("copper_ore_vein", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_18(), "feature_icons", 20, 20),
31-
IRON_ORE_VEIN("iron_ore_vein", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_18(), "feature_icons", 20, 20),
32-
CANYON("canyon", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "feature_icons", 20, 20),
33-
FORTRESS("fortress", Cubiomes.Fortress(), Cubiomes.DIM_NETHER(), Cubiomes.MC_1_0(), "cubiomes_viewer_icons", 20, 20),
34-
BASTION("bastion_remnant", Cubiomes.Bastion(), Cubiomes.DIM_NETHER(), Cubiomes.MC_1_16_1(), "cubiomes_viewer_icons", 20, 20),
35-
END_CITY("end_city", Cubiomes.End_City(), Cubiomes.DIM_END(), Cubiomes.MC_1_9(), "cubiomes_viewer_icons", 20, 20),
36-
END_CITY_SHIP("end_city_ship", Cubiomes.End_City(), Cubiomes.DIM_END(), Cubiomes.MC_1_9(), "cubiomes_viewer_icons", "elytra", 20, 20),
37-
END_GATEWAY("end_gateway", Cubiomes.End_Gateway(), Cubiomes.DIM_END(), Cubiomes.MC_1_13(), "cubiomes_viewer_icons", 20, 20),
38-
TRAIL_RUINS("trail_ruins", Cubiomes.Trail_Ruins(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_20(), "cubiomes_viewer_icons", 20, 20),
39-
TRIAL_CHAMBERS("trial_chambers", Cubiomes.Trial_Chambers(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_21_1(), "cubiomes_viewer_icons", 20, 20),
40-
SLIME_CHUNK("slime_chunk", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_7(), "feature_icons", 20, 20),
41-
WORLD_SPAWN("world_spawn", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_7(), "cubiomes_viewer_icons", 20, 20),
42-
WAYPOINT("waypoint", -1, Cubiomes.DIM_UNDEF(), Cubiomes.MC_B1_7(), "feature_icons", 20, 20),
13+
DESERT_PYRAMID("desert_pyramid", Cubiomes.Desert_Pyramid(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_3(), "Desert Pyramid", "cubiomes_viewer_icons", 19, 20),
14+
JUNGLE_PYRAMID("jungle_pyramid", Cubiomes.Jungle_Pyramid(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_3(), "Jungle Pyramid", "cubiomes_viewer_icons", 19, 20),
15+
SWAMP_HUT("swamp_hut", Cubiomes.Swamp_Hut(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_4(), "Swamp Hut", "cubiomes_viewer_icons", 20, 20),
16+
STRONGHOLD("stronghold", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_8(), "Stronghold", "cubiomes_viewer_icons", 19, 20),
17+
IGLOO("igloo", Cubiomes.Igloo(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_9(), "Igloo", "cubiomes_viewer_icons", 20, 20),
18+
VILLAGE("village", Cubiomes.Village(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_8(), "Village", "cubiomes_viewer_icons", 19, 20),
19+
OCEAN_RUIN("ocean_ruin", Cubiomes.Ocean_Ruin(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "Ocean Ruin", "cubiomes_viewer_icons", 19, 19),
20+
SHIPWRECK("shipwreck", Cubiomes.Shipwreck(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "Shipwreck", "cubiomes_viewer_icons", 19, 19),
21+
MONUMENT("monument", Cubiomes.Monument(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_8(), "Ocean Monument", "cubiomes_viewer_icons", 20, 20),
22+
MANSION("mansion", Cubiomes.Mansion(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_11(), "Woodland Mansion", "cubiomes_viewer_icons", 20, 20),
23+
OUTPOST("pillager_outpost", Cubiomes.Outpost(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_14(), "Pillager Outpost", "cubiomes_viewer_icons", 19, 20),
24+
RUINED_PORTAL("ruined_portal", Cubiomes.Ruined_Portal(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_16_1(), "Ruined Portal", "cubiomes_viewer_icons", 20, 20),
25+
RUINED_PORTAL_N("ruined_portal_n", Cubiomes.Ruined_Portal_N(), Cubiomes.DIM_NETHER(), Cubiomes.MC_1_16_1(), "Ruined Portal (Nether)", "cubiomes_viewer_icons", 20, 20),
26+
ANCIENT_CITY("ancient_city", Cubiomes.Ancient_City(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_19_2(), "Ancient City", "cubiomes_viewer_icons", 20, 20),
27+
TREASURE("buried_treasure", Cubiomes.Treasure(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "Buried Treasure", "cubiomes_viewer_icons", 19, 19),
28+
MINESHAFT("mineshaft", Cubiomes.Mineshaft(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_8(), "Mineshaft", "cubiomes_viewer_icons", 20, 19),
29+
DESERT_WELL("desert_well", Cubiomes.Desert_Well(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "Desert Well", "cubiomes_viewer_icons", 20, 20),
30+
GEODE("geode", Cubiomes.Geode(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_17(), "Geode", "cubiomes_viewer_icons", 20, 20),
31+
COPPER_ORE_VEIN("copper_ore_vein", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_18(), "Copper Ore Vein", "feature_icons", 20, 20),
32+
IRON_ORE_VEIN("iron_ore_vein", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_18(), "Iron Ore Vein", "feature_icons", 20, 20),
33+
CANYON("canyon", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_13(), "Canyon", "feature_icons", 20, 20),
34+
FORTRESS("fortress", Cubiomes.Fortress(), Cubiomes.DIM_NETHER(), Cubiomes.MC_1_0(), "Nether Fortress", "cubiomes_viewer_icons", 20, 20),
35+
BASTION("bastion_remnant", Cubiomes.Bastion(), Cubiomes.DIM_NETHER(), Cubiomes.MC_1_16_1(), "Bastion Remnant", "cubiomes_viewer_icons", 20, 20),
36+
END_CITY("end_city", Cubiomes.End_City(), Cubiomes.DIM_END(), Cubiomes.MC_1_9(), "End City", "cubiomes_viewer_icons", 20, 20),
37+
END_CITY_SHIP("end_city_ship", Cubiomes.End_City(), Cubiomes.DIM_END(), Cubiomes.MC_1_9(), "Elytra", "cubiomes_viewer_icons", "elytra", 20, 20),
38+
END_GATEWAY("end_gateway", Cubiomes.End_Gateway(), Cubiomes.DIM_END(), Cubiomes.MC_1_13(), "End Gateway", "cubiomes_viewer_icons", 20, 20),
39+
TRAIL_RUINS("trail_ruins", Cubiomes.Trail_Ruins(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_20(), "Trail Ruins", "cubiomes_viewer_icons", 20, 20),
40+
TRIAL_CHAMBERS("trial_chambers", Cubiomes.Trial_Chambers(), Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_1_21_1(), "Trial Chambers", "cubiomes_viewer_icons", 20, 20),
41+
SLIME_CHUNK("slime_chunk", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_7(), "Slime Chunk", "feature_icons", 20, 20),
42+
WORLD_SPAWN("world_spawn", -1, Cubiomes.DIM_OVERWORLD(), Cubiomes.MC_B1_7(), "World Spawn", "cubiomes_viewer_icons", 20, 20),
43+
WAYPOINT("waypoint", -1, Cubiomes.DIM_UNDEF(), Cubiomes.MC_B1_7(), "Waypoint", "feature_icons", 20, 20),
4344
;
4445

4546
public static final Map<String, MapFeature> BY_NAME = Arrays.stream(values())
@@ -49,17 +50,21 @@ public enum MapFeature {
4950
private final int structureId;
5051
private final int dimension;
5152
private final int availableSince;
53+
private final Component displayName;
54+
private final String translationKey;
5255
private final Texture texture;
5356

54-
MapFeature(String name, int structureId, int dimension, int availableSince, String directory, int textureWidth, int textureHeight) {
55-
this(name, structureId, dimension, availableSince, directory, name, textureWidth, textureHeight);
57+
MapFeature(String name, int structureId, int dimension, int availableSince, String displayName, String directory, int textureWidth, int textureHeight) {
58+
this(name, structureId, dimension, availableSince, displayName, directory, name, textureWidth, textureHeight);
5659
}
5760

58-
MapFeature(String name, int structureId, int dimension, int availableSince, String directory, String textureName, int textureWidth, int textureHeight) {
61+
MapFeature(String name, int structureId, int dimension, int availableSince, String displayName, String directory, String textureName, int textureWidth, int textureHeight) {
5962
this.name = name;
6063
this.structureId = structureId;
6164
this.dimension = dimension;
6265
this.availableSince = availableSince;
66+
this.translationKey = "seedMap.feature." + name;
67+
this.displayName = Component.translatableWithFallback(this.translationKey, displayName);
6368
this.texture = new Texture(textureName, directory, textureWidth, textureHeight);
6469
}
6570

@@ -79,6 +84,14 @@ public int availableSince() {
7984
return this.availableSince;
8085
}
8186

87+
public Component getDisplayName() {
88+
return this.displayName;
89+
}
90+
91+
public String getTranslationKey() {
92+
return this.translationKey;
93+
}
94+
8295
public Texture getTexture() {
8396
return this.texture;
8497
}

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

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
import net.minecraft.client.gui.components.EditBox;
5757
import net.minecraft.client.gui.components.PlayerFaceRenderer;
5858
import net.minecraft.client.gui.screens.Screen;
59+
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
60+
import net.minecraft.client.gui.screens.inventory.tooltip.DefaultTooltipPositioner;
5961
import net.minecraft.client.input.KeyEvent;
6062
import net.minecraft.client.input.MouseButtonEvent;
6163
import net.minecraft.client.player.LocalPlayer;
@@ -173,6 +175,9 @@ public class SeedMapScreen extends Screen {
173175
private static final int TELEPORT_FIELD_WIDTH = 70;
174176
private static final int WAYPOINT_NAME_FIELD_WIDTH = 100;
175177

178+
private static final int DEFAULT_HALF_VIEW_BLOCKS = 1000;
179+
private static final double LEGACY_DEFAULT_PIXELS_PER_BIOME = 4.0D;
180+
176181
private static final Object2ObjectMap<WorldIdentifier, Object2ObjectMap<TilePos, int[]>> biomeDataCache = new Object2ObjectOpenHashMap<>();
177182
private static final Object2ObjectMap<WorldIdentifier, Object2ObjectMap<ChunkPos, StructureData>> structureDataCache = new Object2ObjectOpenHashMap<>();
178183
public static final Object2ObjectMap<WorldIdentifier, TwoDTree> strongholdDataCache = new Object2ObjectOpenHashMap<>();
@@ -229,6 +234,7 @@ private static int scaleToPixels(int quartOffset) {
229234
private final List<MapFeature> toggleableFeatures;
230235
private final int featureIconsCombinedWidth;
231236

237+
private final List<FeatureToggleWidget> featureToggleWidgets = new ArrayList<>();
232238
private final ObjectSet<FeatureWidget> featureWidgets = new ObjectOpenHashSet<>();
233239

234240
private QuartPos2 mouseQuart;
@@ -245,6 +251,16 @@ private static int scaleToPixels(int quartOffset) {
245251

246252
private Registry<Enchantment> enchantmentsRegistry;
247253

254+
private void applyDefaultZoom() {
255+
if (Configs.PixelsPerBiome != LEGACY_DEFAULT_PIXELS_PER_BIOME) {
256+
return; // respect user/customized zoom and only override the legacy default
257+
}
258+
// Target 1000 blocks in each direction (250 quart positions) from the center.
259+
double targetHalfQuart = DEFAULT_HALF_VIEW_BLOCKS / (double) BIOME_SCALE;
260+
double targetPixelsPerBiome = (this.seedMapWidth / 2.0) / targetHalfQuart;
261+
Configs.PixelsPerBiome = Mth.clamp(targetPixelsPerBiome, MIN_PIXELS_PER_BIOME, MAX_PIXELS_PER_BIOME);
262+
}
263+
248264
public SeedMapScreen(long seed, int dimension, int version, BlockPos playerPos) {
249265
super(Component.empty());
250266
this.seed = seed;
@@ -321,6 +337,8 @@ protected void init() {
321337
this.seedMapWidth = 2 * (this.centerX - HORIZONTAL_PADDING);
322338
this.seedMapHeight = 2 * (this.centerY - VERTICAL_PADDING);
323339

340+
this.applyDefaultZoom();
341+
324342
this.createFeatureToggles();
325343
this.createTeleportField();
326344
this.createWaypointNameField();
@@ -505,6 +523,8 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
505523
coordinates = Component.translatable("seedMap.coordinatesCopied", coordinates);
506524
}
507525
guiGraphics.drawString(this.font, coordinates, HORIZONTAL_PADDING, VERTICAL_PADDING + this.seedMapHeight + 1, -1);
526+
527+
this.renderFeatureToggleTooltip(guiGraphics, mouseX, mouseY);
508528
}
509529

510530
private void drawTile(GuiGraphics guiGraphics, Tile tile) {
@@ -599,9 +619,20 @@ private Tile createSlimeChunkTile(TilePos tilePos, BitSet slimeChunkData) {
599619
return widget;
600620
}
601621

622+
private void renderFeatureToggleTooltip(GuiGraphics guiGraphics, int mouseX, int mouseY) {
623+
for (FeatureToggleWidget widget : this.featureToggleWidgets) {
624+
if (widget.isMouseOver(mouseX, mouseY)) {
625+
List<ClientTooltipComponent> tooltip = List.of(ClientTooltipComponent.create(widget.getTooltip().getVisualOrderText()));
626+
guiGraphics.renderTooltip(this.font, tooltip, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE, null);
627+
return;
628+
}
629+
}
630+
}
631+
602632
private void createFeatureToggles() {
603633
// TODO: replace with Gatherers API?
604634
// TODO: only calculate on resize?
635+
this.featureToggleWidgets.clear();
605636
int rows = Math.ceilDiv(this.featureIconsCombinedWidth, this.seedMapWidth);
606637
int togglesPerRow = Math.ceilDiv(this.toggleableFeatures.size(), rows);
607638
int toggleMinY = 1;
@@ -617,7 +648,9 @@ private void createFeatureTogglesInner(int row, int togglesPerRow, int maxToggle
617648
for (int toggle = 0; toggle < maxToggles; toggle++) {
618649
MapFeature feature = this.toggleableFeatures.get(row * togglesPerRow + toggle);
619650
MapFeature.Texture featureIcon = feature.getTexture();
620-
this.addRenderableWidget(new FeatureToggleWidget(feature, toggleMinX, toggleMinY));
651+
FeatureToggleWidget toggleWidget = new FeatureToggleWidget(feature, toggleMinX, toggleMinY);
652+
this.featureToggleWidgets.add(toggleWidget);
653+
this.addRenderableWidget(toggleWidget);
621654
toggleMinX += featureIcon.width() + HORIZONTAL_FEATURE_TOGGLE_SPACING;
622655
}
623656
}
@@ -1537,12 +1570,43 @@ private boolean handleWaypointNameFieldEnter(KeyEvent keyEvent) {
15371570
return true;
15381571
}
15391572

1573+
private void closeAndClearTiles(Object2ObjectMap<TilePos, Tile> tileCache) {
1574+
tileCache.values().forEach(Tile::close);
1575+
tileCache.clear();
1576+
}
1577+
1578+
private <K, V> void clearWorldCache(Object2ObjectMap<WorldIdentifier, Object2ObjectMap<K, V>> cache) {
1579+
Object2ObjectMap<K, V> removedCache = cache.remove(this.worldIdentifier);
1580+
if (removedCache != null) {
1581+
removedCache.clear();
1582+
}
1583+
}
1584+
1585+
private void dropWorldCaches() {
1586+
this.clearWorldCache(biomeDataCache);
1587+
this.clearWorldCache(structureDataCache);
1588+
this.clearWorldCache(oreVeinDataCache);
1589+
this.clearWorldCache(canyonDataCache);
1590+
this.clearWorldCache(slimeChunkDataCache);
1591+
spawnDataCache.remove(this.worldIdentifier);
1592+
strongholdDataCache.remove(this.worldIdentifier);
1593+
this.endCityShipCache.clear();
1594+
}
1595+
15401596
@Override
15411597
public void onClose() {
15421598
super.onClose();
1543-
this.biomeTileCache.values().forEach(Tile::close);
1544-
this.slimeChunkTileCache.values().forEach(Tile::close);
1545-
this.seedMapExecutor.close(this.arena::close);
1599+
if (Configs.ClearSeedMapCachesOnClose) {
1600+
this.closeAndClearTiles(this.biomeTileCache);
1601+
this.closeAndClearTiles(this.slimeChunkTileCache);
1602+
this.dropWorldCaches();
1603+
this.seedMapExecutor.close(() -> {
1604+
this.dropWorldCaches();
1605+
this.arena.close();
1606+
});
1607+
} else {
1608+
this.seedMapExecutor.close(this.arena::close);
1609+
}
15461610
Configs.save();
15471611
}
15481612

0 commit comments

Comments
 (0)