Skip to content

Commit 8380664

Browse files
committed
Add minimum inhabitedTime configuration to maps
1 parent f5ef2a8 commit 8380664

File tree

11 files changed

+61
-1
lines changed

11 files changed

+61
-1
lines changed

BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/MapConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public class MapConfig implements MapSettings {
4444
private transient Vector3i min = null;
4545
private transient Vector3i max = null;
4646

47+
private long minInhabitedTime = 0;
48+
4749
private boolean renderEdges = true;
4850

4951
private boolean saveHiresLayer = true;
@@ -108,6 +110,10 @@ public Vector3i getMaxPos() {
108110
return max;
109111
}
110112

113+
public long getMinInhabitedTime() {
114+
return minInhabitedTime;
115+
}
116+
111117
public boolean isRenderEdges() {
112118
return renderEdges;
113119
}

BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/WorldRegionRenderTask.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.flowpowered.math.vector.Vector2l;
2929
import de.bluecolored.bluemap.api.debug.DebugDump;
3030
import de.bluecolored.bluemap.core.map.BmMap;
31+
import de.bluecolored.bluemap.core.world.Chunk;
3132
import de.bluecolored.bluemap.core.world.Grid;
3233
import de.bluecolored.bluemap.core.world.Region;
3334

@@ -151,7 +152,9 @@ private boolean isAllChunksInTileGenerated(Vector2i tile) {
151152

152153
for (int x = minChunk.getX(); x <= maxChunk.getX(); x++) {
153154
for (int z = minChunk.getY(); z <= maxChunk.getY(); z++) {
154-
if (!map.getWorld().getChunk(x, z).isGenerated()) return false;
155+
Chunk chunk = map.getWorld().getChunk(x, z);
156+
if (!chunk.isGenerated()) return false;
157+
if (chunk.getInhabitedTime() < map.getMapSettings().getMinInhabitedTime()) return false;
155158
}
156159
}
157160

BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/maps/map.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ cave-detection-uses-block-light: false
6969
#min-y: 50
7070
${max-y-comment<<#>>}max-y: ${max-y}
7171

72+
# The minimum "inhabitedTime" value that a chunk must have to be rendered.
73+
# If you set this to a value greater than 0, bluemap will only render chunks that players have visited already.
74+
# Default is 0
75+
min-inhabited-time: 0
76+
7277
# Using this, BlueMap pretends that every Block out of the defined render-bounds is AIR,
7378
# this means you can see the blocks where the world is cut (instead of having a see-through/xray view).
7479
# This has only an effect if you set some render-bounds above.

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/MapSettings.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public interface MapSettings extends RenderSettings {
3737

3838
String getSkyColor();
3939

40+
long getMinInhabitedTime();
41+
4042
int getHiresTileSize();
4143

4244
int getLowresTileSize();

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil113.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
public class ChunkAnvil113 extends MCAChunk {
3939
private boolean isGenerated;
4040
private boolean hasLight;
41+
private long inhabitedTime;
4142
private Section[] sections;
4243
private int[] biomes;
4344

@@ -51,6 +52,8 @@ public ChunkAnvil113(MCAWorld world, CompoundTag chunkTag) {
5152
this.isGenerated = status.equals("full");
5253
this.hasLight = isGenerated;
5354

55+
this.inhabitedTime = levelData.getLong("InhabitedTime");
56+
5457
if (!isGenerated && getWorld().isIgnoreMissingLightData()) {
5558
isGenerated = !status.equals("empty");
5659
}
@@ -92,6 +95,11 @@ public boolean isGenerated() {
9295
return isGenerated;
9396
}
9497

98+
@Override
99+
public long getInhabitedTime() {
100+
return inhabitedTime;
101+
}
102+
95103
@Override
96104
public BlockState getBlockState(int x, int y, int z) {
97105
int sectionY = y >> 4;

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil115.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
public class ChunkAnvil115 extends MCAChunk {
3939
private boolean isGenerated;
4040
private boolean hasLight;
41+
private long inhabitedTime;
4142
private Section[] sections;
4243
private int[] biomes;
4344

@@ -51,6 +52,8 @@ public ChunkAnvil115(MCAWorld world, CompoundTag chunkTag) {
5152
this.isGenerated = status.equals("full");
5253
this.hasLight = isGenerated;
5354

55+
this.inhabitedTime = levelData.getLong("InhabitedTime");
56+
5457
if (!isGenerated && getWorld().isIgnoreMissingLightData()) {
5558
isGenerated = !status.equals("empty");
5659
}
@@ -92,6 +95,11 @@ public boolean isGenerated() {
9295
return isGenerated;
9396
}
9497

98+
@Override
99+
public long getInhabitedTime() {
100+
return inhabitedTime;
101+
}
102+
95103
@Override
96104
public BlockState getBlockState(int x, int y, int z) {
97105
int sectionY = y >> 4;

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil116.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public class ChunkAnvil116 extends MCAChunk {
4040
private boolean isGenerated;
4141
private boolean hasLight;
4242

43+
private long inhabitedTime;
44+
4345
private int sectionMin, sectionMax;
4446
private Section[] sections;
4547

@@ -55,6 +57,8 @@ public ChunkAnvil116(MCAWorld world, CompoundTag chunkTag) {
5557
this.isGenerated = status.equals("full");
5658
this.hasLight = isGenerated;
5759

60+
this.inhabitedTime = levelData.getLong("InhabitedTime");
61+
5862
if (!isGenerated && getWorld().isIgnoreMissingLightData()) {
5963
isGenerated = !status.equals("empty");
6064
}
@@ -109,6 +113,11 @@ public boolean isGenerated() {
109113
return isGenerated;
110114
}
111115

116+
@Override
117+
public long getInhabitedTime() {
118+
return inhabitedTime;
119+
}
120+
112121
@Override
113122
public BlockState getBlockState(int x, int y, int z) {
114123
int sectionY = y >> 4;

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil118.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public class ChunkAnvil118 extends MCAChunk {
4040
private boolean isGenerated;
4141
private boolean hasLight;
4242

43+
private long inhabitedTime;
44+
4345
private int sectionMin, sectionMax;
4446
private Section[] sections;
4547

@@ -51,6 +53,8 @@ public ChunkAnvil118(MCAWorld world, CompoundTag chunkTag) {
5153
this.isGenerated = status.equals("full");
5254
this.hasLight = isGenerated;
5355

56+
this.inhabitedTime = chunkTag.getLong("InhabitedTime");
57+
5458
if (!isGenerated && getWorld().isIgnoreMissingLightData()) {
5559
isGenerated = !status.equals("empty");
5660
}
@@ -95,6 +99,11 @@ public boolean isGenerated() {
9599
return isGenerated;
96100
}
97101

102+
@Override
103+
public long getInhabitedTime() {
104+
return inhabitedTime;
105+
}
106+
98107
@Override
99108
public BlockState getBlockState(int x, int y, int z) {
100109
int sectionY = y >> 4;

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/EmptyChunk.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public boolean isGenerated() {
3737
return false;
3838
}
3939

40+
@Override
41+
public long getInhabitedTime() {
42+
return 0;
43+
}
44+
4045
@Override
4146
public BlockState getBlockState(int x, int y, int z) {
4247
return BlockState.AIR;

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/MCAChunk.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public int getDataVersion() {
5959
return dataVersion;
6060
}
6161

62+
@Override
63+
public abstract long getInhabitedTime();
64+
6265
@Override
6366
public abstract BlockState getBlockState(int x, int y, int z);
6467

0 commit comments

Comments
 (0)