Skip to content

Commit de00a67

Browse files
committed
Updated World Border Settings
1 parent d494fcc commit de00a67

File tree

5 files changed

+78
-5
lines changed

5 files changed

+78
-5
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ You can adjust your own maximum zoom (I recommend 6000) using the command ```/sm
2222
### World Border Limit
2323
Limit the SeedMap and Minimap to a server's world border size so the map only shows that area (centered at 0,0).
2424

25-
Set it with ```/sm:config WorldBorder set 8000``` to show a border from -8000 to +8000 on both axes. Use 0 to disable.
25+
Set it with ```/sm:config WorldBorder set 8000``` to show a border from -8000 to +8000 on both axes for all dimensions. Use 0 to disable.
26+
27+
You can also override per dimension:
28+
- ```/sm:config WorldBorderOverworld set 8000```
29+
- ```/sm:config WorldBorderNether set 8000```
30+
- ```/sm:config WorldBorderEnd set 8000```
31+
32+
Per-dimension values take priority when set; use 0 to fall back to the global border.
2633

2734
### Double Click Recenter
2835
Double clicking anywhere on the map will recenter the map to the players location.

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import dev.xpple.betterconfig.api.BetterConfigAPI;
55
import dev.xpple.betterconfig.api.Config;
66
import dev.xpple.betterconfig.api.ModConfig;
7+
import com.github.cubiomes.Cubiomes;
78
import dev.xpple.seedmapper.SeedMapper;
89
import dev.xpple.seedmapper.command.arguments.SeedResolutionArgument;
910
import dev.xpple.seedmapper.render.RenderManager;
@@ -151,6 +152,51 @@ private static void setWorldBorder(int worldBorder) {
151152
WorldBorder = Math.max(0, worldBorder);
152153
}
153154

155+
@Config(comment = "getWorldBorderOverworldComment", setter = @Config.Setter("setWorldBorderOverworld"))
156+
public static int WorldBorderOverworld = 0;
157+
158+
private static Component getWorldBorderOverworldComment() {
159+
return Component.translatable("config.worldBorder.overworld.comment");
160+
}
161+
162+
private static void setWorldBorderOverworld(int worldBorder) {
163+
WorldBorderOverworld = Math.max(0, worldBorder);
164+
}
165+
166+
@Config(comment = "getWorldBorderNetherComment", setter = @Config.Setter("setWorldBorderNether"))
167+
public static int WorldBorderNether = 0;
168+
169+
private static Component getWorldBorderNetherComment() {
170+
return Component.translatable("config.worldBorder.nether.comment");
171+
}
172+
173+
private static void setWorldBorderNether(int worldBorder) {
174+
WorldBorderNether = Math.max(0, worldBorder);
175+
}
176+
177+
@Config(comment = "getWorldBorderEndComment", setter = @Config.Setter("setWorldBorderEnd"))
178+
public static int WorldBorderEnd = 0;
179+
180+
private static Component getWorldBorderEndComment() {
181+
return Component.translatable("config.worldBorder.end.comment");
182+
}
183+
184+
private static void setWorldBorderEnd(int worldBorder) {
185+
WorldBorderEnd = Math.max(0, worldBorder);
186+
}
187+
188+
public static int getWorldBorderForDimension(int dimension) {
189+
int globalDimension = 0;
190+
if (dimension == Cubiomes.DIM_OVERWORLD()) {
191+
globalDimension = WorldBorderOverworld;
192+
} else if (dimension == Cubiomes.DIM_NETHER()) {
193+
globalDimension = WorldBorderNether;
194+
} else if (dimension == Cubiomes.DIM_END()) {
195+
globalDimension = WorldBorderEnd;
196+
}
197+
return globalDimension > 0 ? globalDimension : WorldBorder;
198+
}
199+
154200
private static double clampSeedMapZoom(double pixelsPerBiome) {
155201
double min = Math.max(SeedMapScreen.MIN_PIXELS_PER_BIOME, SeedMapMinPixelsPerBiome);
156202
return Math.clamp(pixelsPerBiome, min, SeedMapScreen.MAX_PIXELS_PER_BIOME);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ public static void refreshIfOpenWithGeneratorFlags(int generatorFlags) {
109109
refreshIfOpenInternal(generatorFlags);
110110
}
111111

112+
public static void refreshCompletedStructuresIfOpen() {
113+
Minecraft minecraft = Minecraft.getInstance();
114+
minecraft.execute(() -> {
115+
if (INSTANCE.minimapScreen == null) return;
116+
INSTANCE.minimapScreen.refreshCompletedStructuresFromConfig();
117+
});
118+
}
119+
112120
private static void refreshIfOpenInternal(@Nullable Integer generatorFlagsOverride) {
113121
Minecraft minecraft = Minecraft.getInstance();
114122
minecraft.execute(() -> {

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,15 @@ private static double tileSizePixels() {
207207
}
208208

209209
private boolean isWorldBorderEnabled() {
210-
return Configs.WorldBorder > 0;
210+
return this.worldBorderHalfBlocks() > 0;
211211
}
212212

213213
private double worldBorderHalfBlocks() {
214-
return Configs.WorldBorder;
214+
return Configs.getWorldBorderForDimension(this.dimension);
215215
}
216216

217217
private double worldBorderHalfQuart() {
218-
return Configs.WorldBorder / 4.0D;
218+
return this.worldBorderHalfBlocks() / 4.0D;
219219
}
220220

221221
private boolean isWithinWorldBorder(BlockPos pos) {
@@ -2189,6 +2189,15 @@ private void setStructureCompleted(MapFeature feature, BlockPos pos, boolean com
21892189
}
21902190
Configs.setSeedMapCompletedStructures(this.structureCompletionKey, this.completedStructures);
21912191
Configs.save();
2192+
try {
2193+
SeedMapMinimapManager.refreshCompletedStructuresIfOpen();
2194+
} catch (Throwable ignored) {
2195+
}
2196+
}
2197+
2198+
void refreshCompletedStructuresFromConfig() {
2199+
this.completedStructures.clear();
2200+
this.completedStructures.addAll(Configs.getSeedMapCompletedStructures(this.structureCompletionKey));
21922201
}
21932202

21942203
protected void drawCompletionOverlay(GuiGraphics guiGraphics, FeatureWidget widget, int x, int y, int width, int height) {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@
9898
"config.oreAirCheck.comment": "Whether or not SeedMapper should use in-game air checks to invalidate ore positions.",
9999
"config.devMode.comment": "Enables certain debug commands.",
100100
"config.manualWaypointCompassOverlay.comment": "Set the waypoint compass overlay to be manually toggled instead of automatic.",
101-
"config.worldBorder.comment": "Limits the seed map to a square world border radius in blocks. Use 0 to disable.",
101+
"config.worldBorder.comment": "Limits the seed map to a square world border radius in blocks for all dimensions unless overridden. Use 0 to disable.",
102+
"config.worldBorder.overworld.comment": "Overrides the world border radius in the Overworld. Use 0 to use the global border.",
103+
"config.worldBorder.nether.comment": "Overrides the world border radius in the Nether. Use 0 to use the global border.",
104+
"config.worldBorder.end.comment": "Overrides the world border radius in the End. Use 0 to use the global border.",
102105

103106
"key.category.seedmapper.seedmapper": "SeedMapper",
104107
"key.seedMap": "Seed map",

0 commit comments

Comments
 (0)