9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-30 04:09:09 +00:00

Fix tracked merge history npe

This commit is contained in:
Samsuik
2025-10-26 00:37:12 +01:00
parent d0dd6c18ed
commit 7779a176bf

View File

@@ -55,9 +55,13 @@ public final class TrackedMergeHistory {
@Contract("_, false -> _; _, true -> !null")
private @Nullable PositionHistory getHistory(final Entity entity, final boolean create) {
final long position = entity.getPackedOriginPosition();
return this.historyMap.computeIfAbsent(position, p -> {
return create ? new PositionHistory(entity.level().getGameTime()) : null;
});
PositionHistory history = this.historyMap.get(position);
//noinspection ConstantValue
if (create && history == null) {
history = new PositionHistory(entity.level().getGameTime());
this.historyMap.put(position, history);
}
return history;
}
private static final class PositionHistory {