Skip to content

Commit 5b75aa2

Browse files
fix: more minor code improvements
1 parent 3cb5ed0 commit 5b75aa2

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

common/src/main/java/dev/ftb/mods/ftbchunks/client/FTBChunksClientConfig.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import dev.ftb.mods.ftbchunks.client.map.MapMode;
88
import dev.ftb.mods.ftbchunks.client.minimap.MinimapComponentConfig;
99
import dev.ftb.mods.ftbchunks.client.minimap.components.*;
10-
import dev.ftb.mods.ftbchunks.util.HeightUtils;
1110
import dev.ftb.mods.ftblibrary.config.manager.ConfigManager;
1211
import dev.ftb.mods.ftblibrary.snbt.SNBTCompoundTag;
1312
import dev.ftb.mods.ftblibrary.snbt.config.*;
@@ -113,10 +112,10 @@ static void saveConfig() {
113112
ConfigManager.getInstance().save(KEY);
114113
}
115114

116-
class ChunkPosCustomYSetValue extends BaseValue<Set<HeightUtils.ChunkPosWithMinY>> {
115+
class ChunkPosCustomYSetValue extends BaseValue<Set<ChunkPosWithMinY>> {
117116
private final HashMap<Long, Integer> lookup = new HashMap<>();
118117

119-
protected ChunkPosCustomYSetValue(@Nullable SNBTConfig c, String n, Set<HeightUtils.ChunkPosWithMinY> def) {
118+
protected ChunkPosCustomYSetValue(@Nullable SNBTConfig c, String n, Set<ChunkPosWithMinY> def) {
120119
super(c, n, def);
121120
super.set(new HashSet<>());
122121
}
@@ -125,7 +124,7 @@ protected ChunkPosCustomYSetValue(@Nullable SNBTConfig c, String n, Set<HeightUt
125124
public void write(SNBTCompoundTag tag) {
126125
var listTag = new ListTag();
127126

128-
for (HeightUtils.ChunkPosWithMinY pos : get()) {
127+
for (ChunkPosWithMinY pos : get()) {
129128
var posTag = new SNBTCompoundTag();
130129
posTag.putInt("x", pos.chunkX());
131130
posTag.putInt("z", pos.chunkZ());
@@ -139,26 +138,32 @@ public void write(SNBTCompoundTag tag) {
139138
@Override
140139
public void read(SNBTCompoundTag tag) {
141140
var list = tag.getList(key, SNBTCompoundTag.class);
142-
Set<HeightUtils.ChunkPosWithMinY> set = new HashSet<>();
141+
Set<ChunkPosWithMinY> set = new HashSet<>();
143142

144143
for (SNBTCompoundTag posTag : list) {
145144
int x = posTag.getInt("x");
146145
int z = posTag.getInt("z");
147146
int minY = posTag.getInt("min_y");
148-
set.add(new HeightUtils.ChunkPosWithMinY(x, z, minY));
147+
set.add(new ChunkPosWithMinY(x, z, minY));
149148
}
150149

151150
set(set);
151+
}
152+
153+
@Override
154+
public void set(Set<ChunkPosWithMinY> value) {
155+
super.set(value);
152156

153-
// Rebuild lookup
154157
lookup.clear();
155-
for (HeightUtils.ChunkPosWithMinY pos : set) {
158+
for (ChunkPosWithMinY pos : value) {
156159
lookup.put(ChunkPos.asLong(pos.chunkX(), pos.chunkZ()), pos.minY());
157160
}
158161
}
159162

160-
public HashMap<Long, Integer> lookup() {
161-
return lookup;
163+
public Map<Long, Integer> lookup() {
164+
return Collections.unmodifiableMap(lookup);
162165
}
163166
}
167+
168+
record ChunkPosWithMinY(int chunkX, int chunkZ, int minY) {}
164169
}

common/src/main/java/dev/ftb/mods/ftbchunks/util/HeightUtils.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,4 @@ private static int getMinYFromChunkOrConfig(int x, int z) {
9494
.getOrDefault(chunkPos, FTBChunksClientConfig.OVERRIDE_MIN_Y_LEVEL_VALUE.get());
9595
}
9696

97-
public record ChunkPosWithMinY(int chunkX, int chunkZ, int minY) {}
9897
}

0 commit comments

Comments
 (0)