|
|
|
|
@@ -374,30 +374,245 @@ index b28083be4384d6c5efbdce898a0e9d7a2f5bd3d3..76b8d42ae530b59cdaba0583365a557d
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
|
|
|
|
|
index 0c99bffa769d53562a10d23c4a9b37dc59c7f478..6094b9f2d4a686a4c639c739d182aba7aac430e8 100644
|
|
|
|
|
index 0c99bffa769d53562a10d23c4a9b37dc59c7f478..16d3191fb6f90a5ea05090b951e265dff6a489f1 100644
|
|
|
|
|
--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
|
|
|
|
|
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
|
|
|
|
|
@@ -1208,6 +1208,27 @@ public final class ChunkHolderManager {
|
|
|
|
|
@@ -71,36 +71,49 @@ public final class ChunkHolderManager {
|
|
|
|
|
private static final long PROBE_MARKER = Long.MIN_VALUE + 1;
|
|
|
|
|
public final ReentrantAreaLock ticketLockArea;
|
|
|
|
|
|
|
|
|
|
- private final ConcurrentLong2ReferenceChainedHashTable<SortedArraySet<Ticket<?>>> tickets = new ConcurrentLong2ReferenceChainedHashTable<>();
|
|
|
|
|
- private final ConcurrentLong2ReferenceChainedHashTable<Long2IntOpenHashMap> sectionToChunkToExpireCount = new ConcurrentLong2ReferenceChainedHashTable<>();
|
|
|
|
|
+ // DivineMC start - Chunk System optimization
|
|
|
|
|
+ private final ConcurrentLong2ReferenceChainedHashTable<SortedArraySet<Ticket<?>>> tickets = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(20, 0.9F);
|
|
|
|
|
+ private final ConcurrentLong2ReferenceChainedHashTable<Long2IntOpenHashMap> sectionToChunkToExpireCount = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(20, 0.9F);
|
|
|
|
|
+ // DivineMC end - Chunk System optimization
|
|
|
|
|
final ChunkUnloadQueue unloadQueue;
|
|
|
|
|
|
|
|
|
|
- private final ConcurrentLong2ReferenceChainedHashTable<NewChunkHolder> chunkHolders = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(16384, 0.25f);
|
|
|
|
|
+ private final ConcurrentLong2ReferenceChainedHashTable<NewChunkHolder> chunkHolders = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(20, 0.9F); // DivineMC - Chunk System optimization
|
|
|
|
|
private final ServerLevel world;
|
|
|
|
|
private final ChunkTaskScheduler taskScheduler;
|
|
|
|
|
private long currentTick;
|
|
|
|
|
|
|
|
|
|
- private final ArrayDeque<NewChunkHolder> pendingFullLoadUpdate = new ArrayDeque<>();
|
|
|
|
|
- private final ObjectRBTreeSet<NewChunkHolder> autoSaveQueue = new ObjectRBTreeSet<>((final NewChunkHolder c1, final NewChunkHolder c2) -> {
|
|
|
|
|
- if (c1 == c2) {
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
+ // DivineMC start - Chunk System optimization
|
|
|
|
|
+ public static class LevelHolderData {
|
|
|
|
|
+ private final java.util.concurrent.ConcurrentLinkedDeque<NewChunkHolder> pendingFullLoadUpdate = new java.util.concurrent.ConcurrentLinkedDeque<>();
|
|
|
|
|
+ private final ObjectRBTreeSet<NewChunkHolder> autoSaveQueue = new ObjectRBTreeSet<>((final NewChunkHolder c1, final NewChunkHolder c2) -> {
|
|
|
|
|
+ if (c1 == c2) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
- final int saveTickCompare = Long.compare(c1.lastAutoSave, c2.lastAutoSave);
|
|
|
|
|
+ final int saveTickCompare = Long.compare(c1.lastAutoSave, c2.lastAutoSave);
|
|
|
|
|
|
|
|
|
|
- if (saveTickCompare != 0) {
|
|
|
|
|
- return saveTickCompare;
|
|
|
|
|
- }
|
|
|
|
|
+ if (saveTickCompare != 0) {
|
|
|
|
|
+ return saveTickCompare;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
- final long coord1 = CoordinateUtils.getChunkKey(c1.chunkX, c1.chunkZ);
|
|
|
|
|
- final long coord2 = CoordinateUtils.getChunkKey(c2.chunkX, c2.chunkZ);
|
|
|
|
|
+ final long coord1 = CoordinateUtils.getChunkKey(c1.chunkX, c1.chunkZ);
|
|
|
|
|
+ final long coord2 = CoordinateUtils.getChunkKey(c2.chunkX, c2.chunkZ);
|
|
|
|
|
|
|
|
|
|
- if (coord1 == coord2) {
|
|
|
|
|
- throw new IllegalStateException("Duplicate chunkholder in auto save queue");
|
|
|
|
|
- }
|
|
|
|
|
+ if (coord1 == coord2) {
|
|
|
|
|
+ throw new IllegalStateException("Duplicate chunkholder in auto save queue");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
- return Long.compare(coord1, coord2);
|
|
|
|
|
- });
|
|
|
|
|
+ return Long.compare(coord1, coord2);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public LevelHolderData getData() {
|
|
|
|
|
+ if (this.world == null) {
|
|
|
|
|
+ throw new RuntimeException("World was null!");
|
|
|
|
|
+ }
|
|
|
|
|
+ return world.chunkHolderData;
|
|
|
|
|
+ }
|
|
|
|
|
+ // DivineMC end - Chunk System optimization
|
|
|
|
|
|
|
|
|
|
public ChunkHolderManager(final ServerLevel world, final ChunkTaskScheduler taskScheduler) {
|
|
|
|
|
this.world = world;
|
|
|
|
|
@@ -222,26 +235,29 @@ public final class ChunkHolderManager {
|
|
|
|
|
this.taskScheduler.setShutdown(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- void ensureInAutosave(final NewChunkHolder holder) {
|
|
|
|
|
- if (!this.autoSaveQueue.contains(holder)) {
|
|
|
|
|
+ // DivineMC start - Chunk System optimization
|
|
|
|
|
+ synchronized void ensureInAutosave(final NewChunkHolder holder) {
|
|
|
|
|
+ final LevelHolderData data = getData();
|
|
|
|
|
+ if (!data.autoSaveQueue.contains(holder)) {
|
|
|
|
|
holder.lastAutoSave = this.currentTick;
|
|
|
|
|
- this.autoSaveQueue.add(holder);
|
|
|
|
|
+ data.autoSaveQueue.add(holder);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- public void autoSave() {
|
|
|
|
|
+ public synchronized void autoSave() {
|
|
|
|
|
+ final LevelHolderData data = getData();
|
|
|
|
|
final List<NewChunkHolder> reschedule = new ArrayList<>();
|
|
|
|
|
final long currentTick = this.currentTick;
|
|
|
|
|
final long maxSaveTime = currentTick - Math.max(1L, PlatformHooks.get().configAutoSaveInterval(this.world));
|
|
|
|
|
final int maxToSave = PlatformHooks.get().configMaxAutoSavePerTick(this.world);
|
|
|
|
|
- for (int autoSaved = 0; autoSaved < maxToSave && !this.autoSaveQueue.isEmpty();) {
|
|
|
|
|
- final NewChunkHolder holder = this.autoSaveQueue.first();
|
|
|
|
|
+ for (int autoSaved = 0; autoSaved < maxToSave && !data.autoSaveQueue.isEmpty();) {
|
|
|
|
|
+ final NewChunkHolder holder = data.autoSaveQueue.first();
|
|
|
|
|
|
|
|
|
|
if (holder.lastAutoSave > maxSaveTime) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- this.autoSaveQueue.remove(holder);
|
|
|
|
|
+ data.autoSaveQueue.remove(holder);
|
|
|
|
|
|
|
|
|
|
holder.lastAutoSave = currentTick;
|
|
|
|
|
if (holder.save(false) != null) {
|
|
|
|
|
@@ -255,10 +271,11 @@ public final class ChunkHolderManager {
|
|
|
|
|
|
|
|
|
|
for (final NewChunkHolder holder : reschedule) {
|
|
|
|
|
if (holder.getChunkStatus().isOrAfter(FullChunkStatus.FULL)) {
|
|
|
|
|
- this.autoSaveQueue.add(holder);
|
|
|
|
|
+ data.autoSaveQueue.add(holder);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
+ // DivineMC end - Chunk System optimization
|
|
|
|
|
|
|
|
|
|
public void saveAllChunks(final boolean flush, final boolean shutdown, final boolean logProgress) {
|
|
|
|
|
final List<NewChunkHolder> holders = this.getChunkHolders();
|
|
|
|
|
@@ -317,13 +334,9 @@ public final class ChunkHolderManager {
|
|
|
|
|
}
|
|
|
|
|
if (logProgress) {
|
|
|
|
|
final long currTime = System.nanoTime();
|
|
|
|
|
- if ((currTime - lastLog) > TimeUnit.SECONDS.toNanos(10L)) {
|
|
|
|
|
+ if ((currTime - lastLog) > TimeUnit.SECONDS.toNanos(5L)) { // DivineMC - Log a bit more frequently
|
|
|
|
|
lastLog = currTime;
|
|
|
|
|
- LOGGER.info(
|
|
|
|
|
- "Saved " + savedChunk + " block chunks, " + savedEntity + " entity chunks, " + savedPoi
|
|
|
|
|
- + " poi chunks in world '" + WorldUtil.getWorldName(this.world) + "', progress: "
|
|
|
|
|
- + format.format((double)(i+1)/(double)len * 100.0)
|
|
|
|
|
- );
|
|
|
|
|
+ LOGGER.info("Saved {} block chunks, {} entity chunks, {} poi chunks in world '{}', progress: {}", savedChunk, savedEntity, savedPoi, ca.spottedleaf.moonrise.common.util.WorldUtil.getWorldName(this.world), format.format((double) (i + 1) / (double) len * 100.0)); // DivineMC - Beautify log
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -425,8 +438,8 @@ public final class ChunkHolderManager {
|
|
|
|
|
final Long2ObjectOpenHashMap<SortedArraySet<Ticket<?>>> ret = new Long2ObjectOpenHashMap<>();
|
|
|
|
|
final Long2ObjectOpenHashMap<LongArrayList> sections = new Long2ObjectOpenHashMap<>();
|
|
|
|
|
final int sectionShift = this.taskScheduler.getChunkSystemLockShift();
|
|
|
|
|
- for (final PrimitiveIterator.OfLong iterator = this.tickets.keyIterator(); iterator.hasNext();) {
|
|
|
|
|
- final long coord = iterator.nextLong();
|
|
|
|
|
+ for (final Iterator<Long> iterator = this.tickets.keyIterator(); iterator.hasNext();) { // DivineMC - Chunk System optimization
|
|
|
|
|
+ final long coord = iterator.next(); // DivineMC - Chunk System optimization
|
|
|
|
|
sections.computeIfAbsent(
|
|
|
|
|
CoordinateUtils.getChunkKey(
|
|
|
|
|
CoordinateUtils.getChunkX(coord) >> sectionShift,
|
|
|
|
|
@@ -523,7 +536,7 @@ public final class ChunkHolderManager {
|
|
|
|
|
chunkZ >> sectionShift
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
- this.sectionToChunkToExpireCount.computeIfAbsent(sectionKey, (final long keyInMap) -> {
|
|
|
|
|
+ this.sectionToChunkToExpireCount.computeIfAbsent(sectionKey, (keyInMap) -> { // DivineMC - Chunk System optimization
|
|
|
|
|
return new Long2IntOpenHashMap();
|
|
|
|
|
}).addTo(chunkKey, 1);
|
|
|
|
|
}
|
|
|
|
|
@@ -567,7 +580,7 @@ public final class ChunkHolderManager {
|
|
|
|
|
|
|
|
|
|
final ReentrantAreaLock.Node ticketLock = lock ? this.ticketLockArea.lock(chunkX, chunkZ) : null;
|
|
|
|
|
try {
|
|
|
|
|
- final SortedArraySet<Ticket<?>> ticketsAtChunk = this.tickets.computeIfAbsent(chunk, (final long keyInMap) -> {
|
|
|
|
|
+ final SortedArraySet<Ticket<?>> ticketsAtChunk = this.tickets.computeIfAbsent(chunk, (keyInMap) -> { // DivineMC - Chunk System optimization
|
|
|
|
|
return SortedArraySet.create(4);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -697,8 +710,8 @@ public final class ChunkHolderManager {
|
|
|
|
|
|
|
|
|
|
final Long2ObjectOpenHashMap<LongArrayList> sections = new Long2ObjectOpenHashMap<>();
|
|
|
|
|
final int sectionShift = this.taskScheduler.getChunkSystemLockShift();
|
|
|
|
|
- for (final PrimitiveIterator.OfLong iterator = this.tickets.keyIterator(); iterator.hasNext();) {
|
|
|
|
|
- final long coord = iterator.nextLong();
|
|
|
|
|
+ for (final Iterator<Long> iterator = this.tickets.keyIterator(); iterator.hasNext();) { // DivineMC - Chunk System optimization
|
|
|
|
|
+ final long coord = iterator.next(); // DivineMC - Chunk System optimization
|
|
|
|
|
sections.computeIfAbsent(
|
|
|
|
|
CoordinateUtils.getChunkKey(
|
|
|
|
|
CoordinateUtils.getChunkX(coord) >> sectionShift,
|
|
|
|
|
@@ -746,8 +759,8 @@ public final class ChunkHolderManager {
|
|
|
|
|
return removeDelay <= 0L;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
- for (final PrimitiveIterator.OfLong iterator = this.sectionToChunkToExpireCount.keyIterator(); iterator.hasNext();) {
|
|
|
|
|
- final long sectionKey = iterator.nextLong();
|
|
|
|
|
+ for (final Iterator<Long> iterator = this.sectionToChunkToExpireCount.keyIterator(); iterator.hasNext();) { // DivineMC - Chunk System optimization
|
|
|
|
|
+ final long sectionKey = iterator.next(); // DivineMC - Chunk System optimization
|
|
|
|
|
|
|
|
|
|
if (!this.sectionToChunkToExpireCount.containsKey(sectionKey)) {
|
|
|
|
|
// removed concurrently
|
|
|
|
|
@@ -1033,7 +1046,7 @@ public final class ChunkHolderManager {
|
|
|
|
|
}
|
|
|
|
|
if (!TickThread.isTickThreadFor(world)) { // DivineMC - parallel world ticking
|
|
|
|
|
this.taskScheduler.scheduleChunkTask(() -> {
|
|
|
|
|
- final ArrayDeque<NewChunkHolder> pendingFullLoadUpdate = ChunkHolderManager.this.pendingFullLoadUpdate;
|
|
|
|
|
+ final java.util.Deque<NewChunkHolder> pendingFullLoadUpdate = ChunkHolderManager.this.getData().pendingFullLoadUpdate; // DivineMC - Chunk System optimization
|
|
|
|
|
for (int i = 0, len = changedFullStatus.size(); i < len; ++i) {
|
|
|
|
|
pendingFullLoadUpdate.add(changedFullStatus.get(i));
|
|
|
|
|
}
|
|
|
|
|
@@ -1041,16 +1054,16 @@ public final class ChunkHolderManager {
|
|
|
|
|
ChunkHolderManager.this.processPendingFullUpdate();
|
|
|
|
|
}, Priority.HIGHEST);
|
|
|
|
|
} else {
|
|
|
|
|
- final ArrayDeque<NewChunkHolder> pendingFullLoadUpdate = this.pendingFullLoadUpdate;
|
|
|
|
|
+ final java.util.Deque<NewChunkHolder> pendingFullLoadUpdate = this.getData().pendingFullLoadUpdate; // DivineMC - Chunk System optimization
|
|
|
|
|
for (int i = 0, len = changedFullStatus.size(); i < len; ++i) {
|
|
|
|
|
pendingFullLoadUpdate.add(changedFullStatus.get(i));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- private void removeChunkHolder(final NewChunkHolder holder) {
|
|
|
|
|
+ private synchronized void removeChunkHolder(final NewChunkHolder holder) { // DivineMC - Chunk System optimization
|
|
|
|
|
holder.onUnload();
|
|
|
|
|
- this.autoSaveQueue.remove(holder);
|
|
|
|
|
+ this.getData().autoSaveQueue.remove(holder); // DivineMC - Chunk System optimization
|
|
|
|
|
PlatformHooks.get().onChunkHolderDelete(this.world, holder.vanillaChunkHolder);
|
|
|
|
|
this.chunkHolders.remove(CoordinateUtils.getChunkKey(holder.chunkX, holder.chunkZ));
|
|
|
|
|
}
|
|
|
|
|
@@ -1208,6 +1221,27 @@ public final class ChunkHolderManager {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // DivineMC start - Chunk System optimization
|
|
|
|
|
+ public final org.agrona.collections.Object2ObjectHashMap<Long, NewChunkHolder> blockTickingChunkHolders = new org.agrona.collections.Object2ObjectHashMap<>(16384, 0.25f);
|
|
|
|
|
+ public final org.agrona.collections.Object2ObjectHashMap<Long, NewChunkHolder> entityTickingChunkHolders = new org.agrona.collections.Object2ObjectHashMap<>(16384, 0.25f);
|
|
|
|
|
+ public final java.util.Set<Long> blockTickingChunkHolders = java.util.Collections.synchronizedSet(new org.agrona.collections.ObjectHashSet<>(1384, 0.75f));
|
|
|
|
|
+ public final java.util.Set<Long> entityTickingChunkHolders = java.util.Collections.synchronizedSet(new org.agrona.collections.ObjectHashSet<>(1384, 0.75f));
|
|
|
|
|
+
|
|
|
|
|
+ public void markBlockTicking(NewChunkHolder newChunkHolder) {
|
|
|
|
|
+ this.blockTickingChunkHolders.put(newChunkHolder.getCachedLongPos(), newChunkHolder);
|
|
|
|
|
+ public void markBlockTicking(@org.jetbrains.annotations.NotNull NewChunkHolder newChunkHolder) {
|
|
|
|
|
+ this.blockTickingChunkHolders.add(newChunkHolder.getCachedLongPos());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void markNonBlockTickingIfPossible(NewChunkHolder newChunkHolder) {
|
|
|
|
|
+ public void markNonBlockTickingIfPossible(@org.jetbrains.annotations.NotNull NewChunkHolder newChunkHolder) {
|
|
|
|
|
+ this.blockTickingChunkHolders.remove(newChunkHolder.getCachedLongPos());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void markEntityTicking(NewChunkHolder newChunkHolder) {
|
|
|
|
|
+ this.entityTickingChunkHolders.put(newChunkHolder.getCachedLongPos(), newChunkHolder);
|
|
|
|
|
+ public void markEntityTicking(@org.jetbrains.annotations.NotNull NewChunkHolder newChunkHolder) {
|
|
|
|
|
+ this.entityTickingChunkHolders.add(newChunkHolder.getCachedLongPos());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void markNonEntityTickingIfPossible(NewChunkHolder newChunkHolder) {
|
|
|
|
|
+ public void markNonEntityTickingIfPossible(@org.jetbrains.annotations.NotNull NewChunkHolder newChunkHolder) {
|
|
|
|
|
+ this.entityTickingChunkHolders.remove(newChunkHolder.getCachedLongPos());
|
|
|
|
|
+ }
|
|
|
|
|
+ // DivineMC end - Chunk System optimization
|
|
|
|
|
@@ -405,6 +620,25 @@ index 0c99bffa769d53562a10d23c4a9b37dc59c7f478..6094b9f2d4a686a4c639c739d182aba7
|
|
|
|
|
public enum TicketOperationType {
|
|
|
|
|
ADD, REMOVE, ADD_IF_REMOVED, ADD_AND_REMOVE
|
|
|
|
|
}
|
|
|
|
|
@@ -1381,7 +1415,7 @@ public final class ChunkHolderManager {
|
|
|
|
|
|
|
|
|
|
// only call on tick thread
|
|
|
|
|
private boolean processPendingFullUpdate() {
|
|
|
|
|
- final ArrayDeque<NewChunkHolder> pendingFullLoadUpdate = this.pendingFullLoadUpdate;
|
|
|
|
|
+ final java.util.Deque<NewChunkHolder> pendingFullLoadUpdate = this.getData().pendingFullLoadUpdate; // DivineMC - Chunk System optimization
|
|
|
|
|
|
|
|
|
|
boolean ret = false;
|
|
|
|
|
|
|
|
|
|
@@ -1417,8 +1451,7 @@ public final class ChunkHolderManager {
|
|
|
|
|
final JsonArray allTicketsJson = new JsonArray();
|
|
|
|
|
ret.add("tickets", allTicketsJson);
|
|
|
|
|
|
|
|
|
|
- for (final Iterator<ConcurrentLong2ReferenceChainedHashTable.TableEntry<SortedArraySet<Ticket<?>>>> iterator = this.tickets.entryIterator();
|
|
|
|
|
- iterator.hasNext();) {
|
|
|
|
|
+ for (final Iterator<ConcurrentLong2ReferenceChainedHashTable.TableEntry<SortedArraySet<Ticket<?>>>> iterator = this.tickets.entryIterator(); iterator.hasNext();) { // DivineMC - Chunk System optimization
|
|
|
|
|
final ConcurrentLong2ReferenceChainedHashTable.TableEntry<SortedArraySet<Ticket<?>>> coordinateTickets = iterator.next();
|
|
|
|
|
final long coordinate = coordinateTickets.getKey();
|
|
|
|
|
final SortedArraySet<Ticket<?>> tickets = coordinateTickets.getValue();
|
|
|
|
|
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java
|
|
|
|
|
index e4a5fa25ed368fc4662c30934da2963ef446d782..6da0ea5cd83a00578223e0a19f952c917bcbcdae 100644
|
|
|
|
|
--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java
|
|
|
|
|
@@ -513,78 +747,106 @@ index e97e7d276faf055c89207385d3820debffb06463..4aeb75a2cdcfb4206bab3eee5ad674dd
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
diff --git a/net/minecraft/server/level/DistanceManager.java b/net/minecraft/server/level/DistanceManager.java
|
|
|
|
|
index 5eab6179ce3913cb4e4d424f910ba423faf21c85..189205fbeed7673398fa6f7706864d3723467811 100644
|
|
|
|
|
index 5eab6179ce3913cb4e4d424f910ba423faf21c85..4b1efd53e423bdfe90d5efd472823869fc87e73b 100644
|
|
|
|
|
--- a/net/minecraft/server/level/DistanceManager.java
|
|
|
|
|
+++ b/net/minecraft/server/level/DistanceManager.java
|
|
|
|
|
@@ -178,14 +178,14 @@ public abstract class DistanceManager implements ca.spottedleaf.moonrise.patches
|
|
|
|
|
@@ -178,15 +178,13 @@ public abstract class DistanceManager implements ca.spottedleaf.moonrise.patches
|
|
|
|
|
|
|
|
|
|
public boolean inEntityTickingRange(long chunkPos) {
|
|
|
|
|
// Paper start - rewrite chunk system
|
|
|
|
|
- final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkHolderManager().getChunkHolder(chunkPos);
|
|
|
|
|
+ final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkHolderManager().entityTickingChunkHolders.get(chunkPos); // DivineMC - Chunk System optimization
|
|
|
|
|
return chunkHolder != null && chunkHolder.isEntityTickingReady();
|
|
|
|
|
- return chunkHolder != null && chunkHolder.isEntityTickingReady();
|
|
|
|
|
+ return this.moonrise$getChunkHolderManager().entityTickingChunkHolders.contains(chunkPos); // DivineMC - Chunk System optimization
|
|
|
|
|
// Paper end - rewrite chunk system
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean inBlockTickingRange(long chunkPos) {
|
|
|
|
|
// Paper start - rewrite chunk system
|
|
|
|
|
- final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkHolderManager().getChunkHolder(chunkPos);
|
|
|
|
|
+ final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkHolderManager().blockTickingChunkHolders.get(chunkPos); // DivineMC - Chunk System optimization
|
|
|
|
|
return chunkHolder != null && chunkHolder.isTickingReady();
|
|
|
|
|
- return chunkHolder != null && chunkHolder.isTickingReady();
|
|
|
|
|
+ return this.moonrise$getChunkHolderManager().blockTickingChunkHolders.contains(chunkPos); // DivineMC - Chunk System optimization
|
|
|
|
|
// Paper end - rewrite chunk system
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
|
|
|
|
index 2678bf59d557f085c7265e2f3eb038647723d35e..b30d6968fba2ab4d9cde0ac9d4f1cfc629c65359 100644
|
|
|
|
|
index 2678bf59d557f085c7265e2f3eb038647723d35e..cce12dce852457325ed6e57e5a4cc00555631ea6 100644
|
|
|
|
|
--- a/net/minecraft/server/level/ServerChunkCache.java
|
|
|
|
|
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
|
|
|
|
@@ -441,7 +441,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
|
|
|
@@ -441,8 +441,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
|
|
|
|
|
|
|
|
public boolean isPositionTicking(long chunkPos) {
|
|
|
|
|
// Paper start - rewrite chunk system
|
|
|
|
|
- final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder newChunkHolder = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(chunkPos);
|
|
|
|
|
+ final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder newChunkHolder = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().chunkHolderManager.blockTickingChunkHolders.get(chunkPos); // DivineMC Chunk System optimization
|
|
|
|
|
return newChunkHolder != null && newChunkHolder.isTickingReady();
|
|
|
|
|
- return newChunkHolder != null && newChunkHolder.isTickingReady();
|
|
|
|
|
+ return ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().chunkHolderManager.blockTickingChunkHolders.contains(chunkPos); // DivineMC - Chunk System optimization
|
|
|
|
|
// Paper end - rewrite chunk system
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
|
|
|
index a3f363d0c86142e03edc7fc6e2ff6ed81de8ed65..57668810e86b1f293c661d01c2486a3da7256c1e 100644
|
|
|
|
|
index a3f363d0c86142e03edc7fc6e2ff6ed81de8ed65..e5ef117e3fb3dd822a7d69e2e47fa25416be38b7 100644
|
|
|
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
|
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
|
|
|
@@ -857,7 +857,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
|
|
|
@@ -183,6 +183,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
|
|
|
public final ServerChunkCache chunkSource;
|
|
|
|
|
private final MinecraftServer server;
|
|
|
|
|
public final net.minecraft.world.level.storage.PrimaryLevelData serverLevelData; // CraftBukkit - type
|
|
|
|
|
+ public final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkHolderManager.LevelHolderData chunkHolderData; // DivineMC - Chunk System optimization
|
|
|
|
|
private int lastSpawnChunkRadius;
|
|
|
|
|
final EntityTickList entityTickList = new EntityTickList(this); // DivineMC - parallel world ticking
|
|
|
|
|
// Paper - rewrite chunk system
|
|
|
|
|
@@ -691,6 +692,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
|
|
|
// Paper start - rewrite chunk system
|
|
|
|
|
this.moonrise$setEntityLookup(new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.server.ServerEntityLookup((ServerLevel)(Object)this, ((ServerLevel)(Object)this).new EntityCallbacks()));
|
|
|
|
|
this.chunkTaskScheduler = new ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler((ServerLevel)(Object)this);
|
|
|
|
|
+ this.chunkHolderData = new ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkHolderManager.LevelHolderData(); // DivineMC - Chunk System optimization
|
|
|
|
|
this.entityDataController = new ca.spottedleaf.moonrise.patches.chunk_system.io.datacontroller.EntityDataController(
|
|
|
|
|
new ca.spottedleaf.moonrise.patches.chunk_system.io.datacontroller.EntityDataController.EntityRegionFileStorage(
|
|
|
|
|
new RegionStorageInfo(levelStorageAccess.getLevelId(), dimension, "entities"),
|
|
|
|
|
@@ -857,8 +859,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
|
|
|
@Override
|
|
|
|
|
public boolean shouldTickBlocksAt(long chunkPos) {
|
|
|
|
|
// Paper start - rewrite chunk system
|
|
|
|
|
- final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder holder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(chunkPos);
|
|
|
|
|
+ final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder holder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.blockTickingChunkHolders.get(chunkPos); // DivineMC - Chunk System optimization
|
|
|
|
|
return holder != null && holder.isTickingReady();
|
|
|
|
|
- return holder != null && holder.isTickingReady();
|
|
|
|
|
+ return this.moonrise$getChunkTaskScheduler().chunkHolderManager.blockTickingChunkHolders.contains(chunkPos); // DivineMC - Chunk System optimization
|
|
|
|
|
// Paper end - rewrite chunk system
|
|
|
|
|
}
|
|
|
|
|
@@ -2567,7 +2567,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
|
|
|
|
|
|
|
|
@@ -2567,30 +2568,25 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
|
|
|
|
|
|
|
|
private boolean isPositionTickingWithEntitiesLoaded(long chunkPos) {
|
|
|
|
|
// Paper start - rewrite chunk system
|
|
|
|
|
- final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(chunkPos);
|
|
|
|
|
+ final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.blockTickingChunkHolders.get(chunkPos); // DivineMC - Chunk System optimization
|
|
|
|
|
// isTicking implies the chunk is loaded, and the chunk is loaded now implies the entities are loaded
|
|
|
|
|
return chunkHolder != null && chunkHolder.isTickingReady();
|
|
|
|
|
- // isTicking implies the chunk is loaded, and the chunk is loaded now implies the entities are loaded
|
|
|
|
|
- return chunkHolder != null && chunkHolder.isTickingReady();
|
|
|
|
|
+ return this.moonrise$getChunkTaskScheduler().chunkHolderManager.blockTickingChunkHolders.contains(chunkPos); // DivineMC - Chunk System optimization
|
|
|
|
|
// Paper end - rewrite chunk system
|
|
|
|
|
@@ -2582,14 +2582,14 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isPositionEntityTicking(BlockPos pos) {
|
|
|
|
|
// Paper start - rewrite chunk system
|
|
|
|
|
- final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(pos));
|
|
|
|
|
- return chunkHolder != null && chunkHolder.isEntityTickingReady();
|
|
|
|
|
+ return this.moonrise$getChunkTaskScheduler().chunkHolderManager.entityTickingChunkHolders.contains(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(pos)); // DivineMC - Chunk System optimization
|
|
|
|
|
// Paper end - rewrite chunk system
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isNaturalSpawningAllowed(BlockPos pos) {
|
|
|
|
|
// Paper start - rewrite chunk system
|
|
|
|
|
- final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(pos));
|
|
|
|
|
+ final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.entityTickingChunkHolders.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(pos)); // DivineMC - Chunk System optimization
|
|
|
|
|
return chunkHolder != null && chunkHolder.isEntityTickingReady();
|
|
|
|
|
- return chunkHolder != null && chunkHolder.isEntityTickingReady();
|
|
|
|
|
+ return this.moonrise$getChunkTaskScheduler().chunkHolderManager.entityTickingChunkHolders.contains(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(pos)); // DivineMC - Chunk System optimization
|
|
|
|
|
// Paper end - rewrite chunk system
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isNaturalSpawningAllowed(ChunkPos chunkPos) {
|
|
|
|
|
// Paper start - rewrite chunk system
|
|
|
|
|
- final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkPos));
|
|
|
|
|
+ final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.entityTickingChunkHolders.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkPos)); // DivineMC - Chunk System optimization
|
|
|
|
|
return chunkHolder != null && chunkHolder.isEntityTickingReady();
|
|
|
|
|
- return chunkHolder != null && chunkHolder.isEntityTickingReady();
|
|
|
|
|
+ return this.moonrise$getChunkTaskScheduler().chunkHolderManager.entityTickingChunkHolders.contains(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkPos)); // DivineMC - Chunk System optimization
|
|
|
|
|
// Paper end - rewrite chunk system
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diff --git a/net/minecraft/world/level/LevelReader.java b/net/minecraft/world/level/LevelReader.java
|
|
|
|
|
index 26c8c1e5598daf3550aef05b12218c47bda6618b..94c824ab1457939c425e1f99929d3222ee2c18a0 100644
|
|
|
|
|
--- a/net/minecraft/world/level/LevelReader.java
|
|
|
|
|
|