Skip to content

Commit fa23099

Browse files
committed
Always print message when sub-levels unload
1 parent 24c19a0 commit fa23099

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

common/src/main/java/dev/ryanhcode/sable/sublevel/storage/holding/SubLevelHoldingChunkMap.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ private GlobalSavedSubLevelPointer moveAndSaveSubLevel(final @Nullable ServerSub
332332
final MinecraftServer server = this.level.getServer();
333333
if (server instanceof final SableToastableServer toastable) {
334334
toastable.sable$reportSubLevelSaveFailure(data);
335-
return null;
336335
}
336+
return null;
337337
}
338338

339339
if (VERBOSE) {
@@ -407,7 +407,7 @@ private GlobalSavedSubLevelPointer moveAndSaveSubLevel(final @Nullable ServerSub
407407
* @param create whether to create a new holding chunk if it doesn't exist
408408
*/
409409
@Contract("_, true -> !null")
410-
private SubLevelHoldingChunk getOrLoadHoldingChunk(final ChunkPos chunkPos, final boolean create) {
410+
private @Nullable SubLevelHoldingChunk getOrLoadHoldingChunk(final ChunkPos chunkPos, final boolean create) {
411411
final long longKey = chunkPos.toLong();
412412
final SubLevelHoldingChunk holdingChunk = this.loadedHoldingChunks.get(longKey);
413413

@@ -522,9 +522,14 @@ private void processUnloads() {
522522
}
523523

524524
public void moveToUnloaded(final ServerSubLevel subLevel, final ChunkPos pos) {
525+
// When sub-levels unload there is no logs indicating that it unloaded. This then leads to people
526+
// making issues on the tracker, so always print this message saying the sub-level was unloaded
525527
if (VERBOSE) {
526528
Sable.LOGGER.info("Sub-level {} with pointer {} detected unloaded chunk, moving to {}", subLevel, subLevel.getLastSerializationPointer(), pos);
529+
} else {
530+
Sable.LOGGER.info("Sub-level {} with pointer {} detected unloaded chunk, unloading", subLevel.getUniqueId(), subLevel.getLastSerializationPointer());
527531
}
532+
528533
final Collection<ServerSubLevel> chain = SubLevelHelper.getLoadingDependencyChain(subLevel);
529534
final List<UUID> uuids = chain.stream().map(SubLevel::getUniqueId).toList();
530535

common/src/main/java/dev/ryanhcode/sable/sublevel/tracking_points/SubLevelTrackingPointSavedData.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package dev.ryanhcode.sable.sublevel.tracking_points;
22

33
import dev.ryanhcode.sable.Sable;
4-
import dev.ryanhcode.sable.api.SubLevelHelper;
5-
import dev.ryanhcode.sable.api.entity.EntitySubLevelUtil;
64
import dev.ryanhcode.sable.api.sublevel.ServerSubLevelContainer;
75
import dev.ryanhcode.sable.api.sublevel.SubLevelContainer;
86
import dev.ryanhcode.sable.api.sublevel.SubLevelObserver;
@@ -26,6 +24,7 @@
2624
import net.minecraft.server.level.ServerPlayer;
2725
import net.minecraft.world.level.saveddata.SavedData;
2826
import net.minecraft.world.phys.Vec3;
27+
import org.jetbrains.annotations.NotNull;
2928
import org.jetbrains.annotations.Nullable;
3029
import org.joml.Vector3d;
3130
import org.joml.Vector3dc;
@@ -43,17 +42,13 @@ private SubLevelTrackingPointSavedData(final ServerLevel level) {
4342
}
4443

4544
public static SubLevelTrackingPointSavedData getOrLoad(final ServerLevel level) {
46-
final SubLevelTrackingPointSavedData data = level.getDataStorage().computeIfAbsent(
45+
return level.getDataStorage().computeIfAbsent(
4746
new Factory<>(
48-
() -> {
49-
return new SubLevelTrackingPointSavedData(level);
50-
},
47+
() -> new SubLevelTrackingPointSavedData(level),
5148
(tag, provider) -> SubLevelTrackingPointSavedData.load(level, tag),
5249
null
5350
),
5451
SubLevelTrackingPointSavedData.FILE_ID);
55-
56-
return data;
5752
}
5853

5954
private static SubLevelTrackingPointSavedData load(final ServerLevel level, final CompoundTag tag) {
@@ -91,7 +86,7 @@ private static SubLevelTrackingPointSavedData load(final ServerLevel level, fina
9186
}
9287

9388
@Override
94-
public CompoundTag save(final CompoundTag compoundTag, final HolderLookup.Provider provider) {
89+
public @NotNull CompoundTag save(final @NotNull CompoundTag compoundTag, final HolderLookup.@NotNull Provider provider) {
9590
final SubLevelContainer container = SubLevelContainer.getContainer(this.level);
9691
assert container != null : "Sub-level container is null";
9792

@@ -259,7 +254,6 @@ public void removeTrackingPoint(final UUID key) {
259254

260255
@Nullable
261256
public TrackingPoint getTrackingPoint(final UUID uuid) {
262-
final TrackingPoint point = this.trackingPoints.get(uuid);
263-
return point;
257+
return this.trackingPoints.get(uuid);
264258
}
265259
}

0 commit comments

Comments
 (0)