Skip to content

Commit cf31ed1

Browse files
committed
Rename methods, address review comments
1 parent b6e812c commit cf31ed1

10 files changed

Lines changed: 26 additions & 28 deletions

File tree

chunky/src/java/se/llbit/chunky/map/WorldMapLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void loadWorld(World newWorld) {
8383
boolean isSameWorld = !(this.world instanceof EmptyWorld) && newWorld.getWorldDirectory().equals(this.world.getWorldDirectory());
8484

8585
Optional<String> dimensionToLoad = Optional.of(world.currentDimension())
86-
.map(Dimension::id)
86+
.map(Dimension::getId)
8787
.filter(dimension -> newWorld.availableDimensions().contains(dimension))
8888
.or(newWorld::defaultDimension)
8989
.or(() -> newWorld.availableDimensions().stream().findFirst());

chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ public synchronized void loadChunks(TaskTracker taskTracker, World world, Collec
792792

793793
loadedWorld = world;
794794
worldPath = loadedWorld.getWorldDirectory().getAbsolutePath();
795-
worldDimension = world.currentDimension().id();
795+
worldDimension = world.currentDimension().getId();
796796

797797
if (chunksToLoad.isEmpty()) {
798798
return;

chunky/src/java/se/llbit/chunky/ui/ChunkMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ private void drawPlayers(GraphicsContext gc) {
585585
World world = mapLoader.getWorld();
586586
double blockScale = mapView.scale / 16.;
587587
for (PlayerEntityData player : world.currentDimension().getPlayerPositions()) {
588-
if (player.dimension.equals(world.currentDimension().id())) {
588+
if (player.dimension.equals(world.currentDimension().getId())) {
589589
int px = (int) QuickMath.floor(player.x * blockScale);
590590
int py = (int) QuickMath.floor(player.y);
591591
int pz = (int) QuickMath.floor(player.z * blockScale);

chunky/src/java/se/llbit/chunky/world/Dimension.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,15 @@ protected Dimension(World world, String dimensionId, Set<PlayerEntityData> playe
4848
this.timestamp = timestamp;
4949
}
5050

51-
public String id() {
51+
/**
52+
* @return A user presentable name of the dimension
53+
*/
54+
public abstract String getName();
55+
56+
/**
57+
* @return The dimension id, such as: {@code minecraft:overworld} (See {@link World#OVERWORLD_DIMENSION_ID})
58+
*/
59+
public String getId() {
5260
return dimensionId;
5361
}
5462

@@ -114,11 +122,6 @@ public Heightmap getHeightmap() {
114122
return heightmap;
115123
}
116124

117-
/**
118-
* @return A user presentable name of the dimension
119-
*/
120-
public abstract String toString();
121-
122125
/** Add a chunk deletion listener. */
123126
public void addChunkDeletionListener(ChunkDeletionListener listener) {
124127
synchronized (chunkDeletionListeners) {

chunky/src/java/se/llbit/chunky/world/EmptyDimension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public RegionChangeWatcher createRegionChangeWatcher(WorldMapLoader worldMapLoad
3838
return new MCRegionChangeWatcher(worldMapLoader, mapView);
3939
}
4040

41-
@Override public String toString() {
41+
@Override public String getName() {
4242
return "[empty dimension]";
4343
}
4444

chunky/src/java/se/llbit/chunky/world/ImposterCubicChunk.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private void loadSurfaceCubic(Map<Integer, Map<String, Tag>> data, ChunkData chu
113113

114114
int[] heightmapData = extractHeightmapDataCubic(null, chunkData);
115115
updateHeightmap(heightmap, position, chunkData, heightmapData, palette, yMax);
116-
surface = new SurfaceLayer(JavaWorld.VANILLA_DIMENSION_ID_TO_IDX.get(dimension.id()), chunkData, palette, biomePalette, yMin, yMax, heightmapData);
116+
surface = new SurfaceLayer(JavaWorld.VANILLA_DIMENSION_ID_TO_IDX.get(dimension.getId()), chunkData, palette, biomePalette, yMin, yMax, heightmapData);
117117
}
118118

119119
private int[] extractHeightmapDataCubic(Map<String, Tag> cubeData, ChunkData chunkData) {

chunky/src/java/se/llbit/chunky/world/JavaChunk.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private void loadSurface(@NotNull Tag data, ChunkData chunkData, int yMin, int y
133133
int[] heightmapData = extractHeightmapData(data, chunkData);
134134
updateHeightmap(heightmap, position, chunkData, heightmapData, palette, yMax);
135135

136-
surface = new SurfaceLayer(JavaWorld.VANILLA_DIMENSION_ID_TO_IDX.get(dimension.id()), chunkData, palette, biomePalette, yMin, yMax, heightmapData);
136+
surface = new SurfaceLayer(JavaWorld.VANILLA_DIMENSION_ID_TO_IDX.get(dimension.getId()), chunkData, palette, biomePalette, yMin, yMax, heightmapData);
137137
queueTopography();
138138
}
139139
} else {

chunky/src/java/se/llbit/chunky/world/JavaDimension.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public synchronized boolean reloadPlayerData() {
3333
boolean changed = ((JavaWorld) this.world).reloadPlayerData();
3434
if (changed) {
3535
this.setPlayerEntities(((JavaWorld) this.world).playerEntities.stream()
36-
.filter(player -> player.dimension.equals(this.id()))
36+
.filter(player -> player.dimension.equals(this.getId()))
3737
.collect(Collectors.toSet()));
3838
}
3939
return changed;
@@ -121,7 +121,7 @@ public boolean regionExistsWithinRange(RegionPosition pos, int minY, int maxY) {
121121
/**
122122
* @return File object pointing to the region file directory
123123
*/
124-
public synchronized File getRegionDirectory() {
124+
public File getRegionDirectory() {
125125
return new File(getDimensionDirectory(), "region");
126126
}
127127

@@ -134,12 +134,12 @@ public Date getLastModified() {
134134
*
135135
* @return File object pointing to the data directory
136136
*/
137-
protected synchronized File getDimensionDirectory() {
137+
protected File getDimensionDirectory() {
138138
return dimensionDirectory;
139139
}
140140

141141
@Override
142-
public String toString() {
142+
public String getName() {
143143
return dimensionDirectory.getName() ;
144144
}
145145
}

chunky/src/java/se/llbit/chunky/world/JavaWorld.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public class JavaWorld extends World {
7171
new String[] { NETHER_DIMENSION_ID, OVERWORLD_DIMENSION_ID, END_DIMENSION_ID }
7272
));
7373

74-
protected int versionId;
74+
protected final int versionId;
7575

7676
/**
7777
* In a java world player data is per-world and not per-dimension, so we store it here.
@@ -89,10 +89,12 @@ public class JavaWorld extends World {
8989
* @param seed
9090
* @param timestamp
9191
*/
92-
protected JavaWorld(String levelName, File worldDirectory, long seed, long timestamp, Set<PlayerEntityData> playerEntities, Vector3i spawnPos) {
92+
protected JavaWorld(String levelName, File worldDirectory, long seed, long timestamp, Set<PlayerEntityData> playerEntities, Vector3i spawnPos, int gameMode, int versionId) {
9393
super(levelName, worldDirectory, seed, timestamp);
9494
this.playerEntities = playerEntities;
9595
this.spawnPos = spawnPos;
96+
this.gameMode = gameMode;
97+
this.versionId = versionId;
9698
}
9799

98100
@Override
@@ -164,11 +166,7 @@ public static World loadWorld(File worldDirectory, LoggedWarnings warnings) {
164166
spawnPos = new Vector3i(0, 0, 0);
165167
}
166168

167-
JavaWorld world = new JavaWorld(levelName, worldDirectory, seed, modtime, playerEntities, spawnPos);
168-
world.gameMode = gameType.intValue(0);
169-
world.versionId = versionId.intValue();
170-
171-
return world;
169+
return new JavaWorld(levelName, worldDirectory, seed, modtime, playerEntities, spawnPos, gameType.intValue(0), versionId.intValue());
172170
} catch (FileNotFoundException e) {
173171
if (warnings == LoggedWarnings.NORMAL) {
174172
Log.infof("Could not find level.dat file for world %s!", levelName);
@@ -293,8 +291,8 @@ public synchronized void exportChunksToZip(File target, Collection<ChunkPosition
293291
progress.setJobSize(regionMap.size() + 1);
294292

295293
String regionDirectory =
296-
currentDim.id().equals(JavaWorld.OVERWORLD_DIMENSION_ID) ? currentDim.getDimensionDirectory().getName() :
297-
currentDim.getDimensionDirectory().getName() + "/DIM" + JavaWorld.VANILLA_DIMENSION_ID_TO_IDX.get(currentDim.id());
294+
currentDim.getId().equals(JavaWorld.OVERWORLD_DIMENSION_ID) ? currentDim.getDimensionDirectory().getName() :
295+
currentDim.getDimensionDirectory().getName() + "/DIM" + JavaWorld.VANILLA_DIMENSION_ID_TO_IDX.get(currentDim.getId());
298296
regionDirectory += "/region";
299297

300298
try (ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(target))) {

chunky/src/java/se/llbit/chunky/world/worldformat/WorldFormat.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ static Optional<World> loadWorld(File dir) {
3939
return worldsByFormat.values().stream().findFirst();
4040
}
4141

42-
/**
43-
* @return The user-recognisable name of the world format. Shown to the user if this format has issues or throws.
44-
*/
4542
String name();
4643

4744
/**

0 commit comments

Comments
 (0)