Skip to content

Commit

Permalink
added a clear method to each map renderer which is invoked when the c…
Browse files Browse the repository at this point in the history
…aches are cleared.
  • Loading branch information
omergunr100 committed Jan 14, 2025
1 parent 3dfd0cb commit 168e52b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public static void clearCaches() {
for (IClientCache cache : caches.keySet()) {
cache.clear();
}
GroupingMapRenderer.getInstance().clear();
}

public static void saveCaches() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ public abstract boolean addMarker(String name, String id, ResourceKey<Level> dim
public abstract boolean doShowLayer(String name);

public abstract void setLayerActive(String name, boolean active);

public abstract void clear();
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,11 @@ public void setLayerActive(String name, boolean active) {
renderer.setLayerActive(name, active);
}
}

@Override
public void clear() {
for (GenericMapRenderer renderer : rendererList) {
renderer.clear();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ public boolean doShowLayer(String name) {
public void setLayerActive(String name, boolean active) {
FTBChunksOptions.toggleLayer(name, active);
}

@Override
public void clear() {
oreElements.clear();
fluidElements.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ public void setLayerActive(String name, boolean active) {
JourneyMapPlugin.getOptions().toggleLayer(name, active);
}

@Override
public void clear() {
var api = JourneyMapPlugin.getJmApi();
markers.forEach((id, marker) -> api.remove(marker));
markers.clear();
}

private MarkerOverlay createMarker(String name, String id, ResourceKey<Level> dim, GeneratedVeinMetadata vein) {
BlockPos center = vein.center();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,10 @@ public boolean doShowLayer(String name) {
public void setLayerActive(String name, boolean active) {
XaerosMapPlugin.toggleOption(name, active);
}

@Override
public void clear() {
oreElements.clear();
fluidElements.clear();
}
}

0 comments on commit 168e52b

Please sign in to comment.