papermc/patches/removed/1.18/0388-Optimise-TickListServer-by-rewriting-it.patch

1128 lines
50 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Fri, 14 Feb 2020 01:24:39 -0800
Subject: [PATCH] Optimise TickListServer by rewriting it
In my profiling TickListServer showed up as
~10% for saving chunks and ~5% for the scheduling
of items on a server with ~90 players at
view distance = 5. Most of the performance
loss is unneccessary.
TickListServer has numerous performance issues:
1. Handling scheduled items is O(nlogn)
2. Getting scheduled items for a chunk is O(n),
with n being the the number of scheduled items
for all chunks (hits saving very hard)
3. Checking if an item is scheduled for the current tick is O(n),
with n being the number of items scheduled for current tick
4. Items not in ticking chunks are churned in the scheduler
The biggest issues are 4 & 2.
We solve 1 by splitting up scheduled items into short and long scheduled,
where we expect the vast majority of our entries to be in the short scheduled
set. Handling short scheduled items is O(n) due to how the comparison
process is reduced to mapping. See TickListServerInterval. However,
this isn't memory-efficient - which is why long scheduled exists.
Long scheduled is handled the same as TickListServer.
2 is solved by mapping what entries are in what chunks.
3 is solved by mapping what blocks have what scheduled for them.
4 is solved by moving the items that are not in ticking chunks
into a map of entries for that chunk. Once the chunk is moved
to ticking, the items are re-scheduled.
This patch has also added two flags to debug excessive tick delays:
-Dpaper.ticklist-warn-on-excessive-delay=true (false by default)
and -Dpaper.ticklist-excessive-delay-threshold=ticks which
sets the excessive tick delay to the specified ticks (defaults to
60 * 20 ticks, aka 60 seconds)
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 26c5ae72f63d930bf6de2ec18a964ddfeca16379..e9954fa75412a7077950e3813af4b201c084f68f 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -375,6 +375,13 @@ public class PaperConfig {
2021-06-11 12:02:28 +00:00
maxBookTotalSizeMultiplier = getDouble("settings.book-size.total-multiplier", maxBookTotalSizeMultiplier);
}
+ public static boolean useOptimizedTickList = true;
+ private static void useOptimizedTickList() {
+ if (config.contains("settings.use-optimized-ticklist")) { // don't add default, hopefully temporary config
+ useOptimizedTickList = config.getBoolean("settings.use-optimized-ticklist");
+ }
+ }
+
public static boolean asyncChunks = false;
private static void asyncChunks() {
ConfigurationSection section;
diff --git a/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java b/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java
new file mode 100644
2021-07-16 16:18:04 +00:00
index 0000000000000000000000000000000000000000..5fdaefc128956581be4bb9b34199fd6410563991
2021-06-11 12:02:28 +00:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java
@@ -0,0 +1,628 @@
+package com.destroystokyo.paper.server.ticklist;
+
+import java.util.function.Function;
+import net.minecraft.CrashReport;
+import net.minecraft.CrashReportCategory;
+import net.minecraft.ReportedException;
+import net.minecraft.core.BlockPos;
+import net.minecraft.nbt.ListTag;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.MCUtil;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.level.ServerChunkCache;
+import net.minecraft.server.level.ServerLevel;
+import net.minecraft.world.level.ChunkPos;
+import net.minecraft.world.level.ServerTickList;
+import net.minecraft.world.level.TickNextTickData;
+import net.minecraft.world.level.TickPriority;
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.levelgen.structure.BoundingBox;
+import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
+import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectRBTreeSet;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+
+public final class PaperTickList<T> extends ServerTickList<T> { // extend to avoid breaking ABI
+
+ // in the order the state is expected to change (mostly)
+ public static final int STATE_UNSCHEDULED = 1 << 0;
+ public static final int STATE_SCHEDULED = 1 << 1; // scheduled for some tick
+ public static final int STATE_PENDING_TICK = 1 << 2; // for this tick
+ public static final int STATE_TICKING = 1 << 3;
+ public static final int STATE_TICKED = 1 << 4; // after this, it gets thrown back to unscheduled
+ public static final int STATE_CANCELLED_TICK = 1 << 5; // still gets moved to unscheduled after tick
+
+ private static final int SHORT_SCHEDULE_TICK_THRESHOLD = 20 * 20 + 1; // 20 seconds
+
+ private final ServerLevel world;
+ private final Predicate<T> excludeFromScheduling;
+ private final Function<T, ResourceLocation> getMinecraftKeyFrom;
+ //private final Function<MinecraftKey, T> getObjectFronMinecraftKey;
+ private final Consumer<TickNextTickData<T>> tickFunction;
+
+ private final co.aikar.timings.Timing timingCleanup; // Paper
+ private final co.aikar.timings.Timing timingTicking; // Paper
+ private final co.aikar.timings.Timing timingFinished;
+
+ // note: remove ops / add ops suck on fastutil, a chained hashtable implementation would work better, but Long...
+ // try to alleviate with a very small load factor
+ private final Long2ObjectOpenHashMap<ArrayList<TickNextTickData<T>>> entriesByBlock = new Long2ObjectOpenHashMap<>(1024, 0.25f);
+ private final Long2ObjectOpenHashMap<ObjectRBTreeSet<TickNextTickData<T>>> entriesByChunk = new Long2ObjectOpenHashMap<>(1024, 0.25f);
+ private final Long2ObjectOpenHashMap<ArrayList<TickNextTickData<T>>> pendingChunkTickLoad = new Long2ObjectOpenHashMap<>(1024, 0.5f);
+
+ // fastutil has O(1) first/last while TreeMap/TreeSet are log(n)
+ private final ObjectRBTreeSet<TickNextTickData<T>> longScheduled = new ObjectRBTreeSet<>(TickListServerInterval.ENTRY_COMPARATOR);
+
+ private final ArrayDeque<TickNextTickData<T>> toTickThisTick = new ArrayDeque<>();
+
+ private final TickListServerInterval<T>[] shortScheduled = new TickListServerInterval[SHORT_SCHEDULE_TICK_THRESHOLD];
+ {
+ for (int i = 0, len = this.shortScheduled.length; i < len; ++i) {
+ this.shortScheduled[i] = new TickListServerInterval<>();
+ }
+ }
+ private int shortScheduledIndex;
+
+ private long currentTick;
+
+ private static final boolean WARN_ON_EXCESSIVE_DELAY = Boolean.getBoolean("paper.ticklist-warn-on-excessive-delay");
+ private static final long EXCESSIVE_DELAY_THRESHOLD = Long.getLong("paper.ticklist-excessive-delay-threshold", 60 * 20).longValue(); // 1 min dfl
+
+ // assume index < length
+ private static int getWrappedIndex(final int start, final int length, final int index) {
+ final int next = start + index;
+ return next < length ? next : next - length;
+ }
+
+ private static int getNextIndex(final int curr, final int length) {
+ final int next = curr + 1;
+ return next < length ? next : 0;
+ }
+
+ public PaperTickList(final ServerLevel world, final Predicate<T> excludeFromScheduling, final Function<T, ResourceLocation> getMinecraftKeyFrom,
+ final Consumer<TickNextTickData<T>> tickFunction, final String timingsType) {
+ super(world, excludeFromScheduling, getMinecraftKeyFrom, tickFunction, timingsType);
+ this.world = world;
+ this.excludeFromScheduling = excludeFromScheduling;
+ this.getMinecraftKeyFrom = getMinecraftKeyFrom;
+ this.tickFunction = tickFunction;
+ this.timingCleanup = co.aikar.timings.WorldTimingsHandler.getTickList(world, timingsType + " - Cleanup"); // Paper
+ this.timingTicking = co.aikar.timings.WorldTimingsHandler.getTickList(world, timingsType + " - Ticking"); // Paper
+ this.timingFinished = co.aikar.timings.WorldTimingsHandler.getTickList(world, timingsType + " - Finish");
+ this.currentTick = this.world.getGameTime();
+ }
+
+ private void queueEntryForTick(final TickNextTickData<T> entry, final ServerChunkCache chunkProvider) {
+ if (entry.tickState == STATE_SCHEDULED) {
2021-07-16 16:18:04 +00:00
+ if (chunkProvider.isPositionTickingWithEntitiesLoaded(entry.pos)) {
2021-06-11 12:02:28 +00:00
+ this.toTickThisTick.add(entry);
+ entry.tickState = STATE_PENDING_TICK;
+ } else {
+ // we dump them to a map to avoid constantly re-scheduling them
+ this.addToNotTickingReady(entry);
+ }
+ }
+ }
+
+ private void addToNotTickingReady(final TickNextTickData<T> entry) {
2021-06-13 22:05:18 +00:00
+ this.pendingChunkTickLoad.computeIfAbsent(MCUtil.getCoordinateKey(entry.pos), (long keyInMap) -> {
2021-06-11 12:02:28 +00:00
+ return new ArrayList<>();
+ }).add(entry);
+ }
+
+ private void addToSchedule(final TickNextTickData<T> entry) {
2021-06-13 22:05:18 +00:00
+ long delay = entry.triggerTick - (this.currentTick + 1);
2021-06-11 12:02:28 +00:00
+ if (delay < SHORT_SCHEDULE_TICK_THRESHOLD) {
+ if (delay < 0) {
+ // longScheduled orders by tick time, short scheduled does not
+ this.longScheduled.add(entry);
+ } else {
+ this.shortScheduled[getWrappedIndex(this.shortScheduledIndex, SHORT_SCHEDULE_TICK_THRESHOLD, (int)delay)].addEntryLast(entry);
+ }
+ } else {
+ this.longScheduled.add(entry);
+ }
+ }
+
+ private void removeEntry(final TickNextTickData<T> entry) {
+ entry.tickState = STATE_CANCELLED_TICK;
+ // short/long scheduled will skip the entry
+
2021-06-13 22:05:18 +00:00
+ final BlockPos pos = entry.pos;
2021-06-11 12:02:28 +00:00
+ final long blockKey = MCUtil.getBlockKey(pos);
+
+ final ArrayList<TickNextTickData<T>> currentEntries = this.entriesByBlock.get(blockKey);
+
+ if (currentEntries.size() == 1) {
+ // it should contain our entry
+ this.entriesByBlock.remove(blockKey);
+ } else {
+ // it's more likely that this entry is at the start of the list than the end
+ for (int i = 0, len = currentEntries.size(); i < len; ++i) {
+ final TickNextTickData<T> currentEntry = currentEntries.get(i);
+ if (currentEntry == entry) {
+ currentEntries.remove(i);
+ break;
+ }
+ }
+ }
+
2021-06-13 22:05:18 +00:00
+ final long chunkKey = MCUtil.getCoordinateKey(entry.pos);
2021-06-11 12:02:28 +00:00
+
+ ObjectRBTreeSet<TickNextTickData<T>> set = this.entriesByChunk.get(chunkKey);
+
+ set.remove(entry);
+
+ if (set.isEmpty()) {
+ this.entriesByChunk.remove(chunkKey);
+ }
+
+ ArrayList<TickNextTickData<T>> pendingTickingLoad = this.pendingChunkTickLoad.get(chunkKey);
+
+ if (pendingTickingLoad != null) {
+ for (int i = 0, len = pendingTickingLoad.size(); i < len; ++i) {
+ if (pendingTickingLoad.get(i) == entry) {
+ pendingTickingLoad.remove(i);
+ break;
+ }
+ }
+
+ if (pendingTickingLoad.isEmpty()) {
+ this.pendingChunkTickLoad.remove(chunkKey);
+ }
+ }
+
2021-06-13 22:05:18 +00:00
+ long delay = entry.triggerTick - (this.currentTick + 1);
2021-06-11 12:02:28 +00:00
+ if (delay >= SHORT_SCHEDULE_TICK_THRESHOLD) {
+ this.longScheduled.remove(entry);
+ }
+ }
+
+ public void onChunkSetTicking(final int chunkX, final int chunkZ) {
+ final ArrayList<TickNextTickData<T>> pending = this.pendingChunkTickLoad.remove(MCUtil.getCoordinateKey(chunkX, chunkZ));
+ if (pending == null) {
+ return;
+ }
+
+ for (int i = 0, size = pending.size(); i < size; ++i) {
+ final TickNextTickData<T> entry = pending.get(i);
+ // already in all the relevant reference maps, just need to add to longScheduled or shortScheduled
+ this.addToSchedule(entry);
+ }
+ }
+
+ private void prepare() {
+ final long currentTick = this.currentTick;
+
+ final ServerChunkCache chunkProvider = this.world.getChunkSource();
+
+ // here we setup what's going to tick
+
+ // we don't remove items from shortScheduled (but do from longScheduled) because they're cleared at the end of
+ // this tick
2021-06-13 22:05:18 +00:00
+ if (this.longScheduled.isEmpty() || this.longScheduled.first().triggerTick > currentTick) {
2021-06-11 12:02:28 +00:00
+ // nothing in longScheduled to worry about
+ final TickListServerInterval<T> interval = this.shortScheduled[this.shortScheduledIndex];
+ for (int i = 0, len = interval.byPriority.length; i < len; ++i) {
+ for (final Iterator<TickNextTickData<T>> iterator = interval.byPriority[i].iterator(); iterator.hasNext();) {
+ this.queueEntryForTick(iterator.next(), chunkProvider);
+ }
+ }
+ } else {
+ final TickListServerInterval<T> interval = this.shortScheduled[this.shortScheduledIndex];
+
+ // combine interval and longScheduled, keeping order
+ final Comparator<TickNextTickData<T>> comparator = (Comparator)TickListServerInterval.ENTRY_COMPARATOR;
+ final Iterator<TickNextTickData<T>> longScheduledIterator = this.longScheduled.iterator();
+ TickNextTickData<T> longCurrent = longScheduledIterator.next();
+
+ for (int i = 0, len = interval.byPriority.length; i < len; ++i) {
+ for (final Iterator<TickNextTickData<T>> iterator = interval.byPriority[i].iterator(); iterator.hasNext();) {
+ final TickNextTickData<T> shortCurrent = iterator.next();
+ if (longCurrent != null) {
+ // drain longCurrent until we can add shortCurrent
+ while (comparator.compare(longCurrent, shortCurrent) <= 0) {
+ this.queueEntryForTick(longCurrent, chunkProvider);
+ longScheduledIterator.remove();
+ if (longScheduledIterator.hasNext()) {
+ longCurrent = longScheduledIterator.next();
2021-06-13 22:05:18 +00:00
+ if (longCurrent.triggerTick > currentTick) {
2021-06-11 12:02:28 +00:00
+ longCurrent = null;
+ break;
+ }
+ } else {
+ longCurrent = null;
+ break;
+ }
+ }
+ }
+ this.queueEntryForTick(shortCurrent, chunkProvider);
+ }
+ }
+
+ // add remaining from long scheduled
+ for (;;) {
2021-06-13 22:05:18 +00:00
+ if (longCurrent == null || longCurrent.triggerTick > currentTick) {
2021-06-11 12:02:28 +00:00
+ break;
+ }
+ longScheduledIterator.remove();
+ this.queueEntryForTick(longCurrent, chunkProvider);
+
+ if (longScheduledIterator.hasNext()) {
+ longCurrent = longScheduledIterator.next();
+ } else {
+ break;
+ }
+ }
+ }
+ }
+
+ private boolean warnedAboutDesync;
+
+ @Override
+ public void nextTick() {
+ ++this.currentTick;
+ if (this.currentTick != this.world.getGameTime()) {
+ if (!this.warnedAboutDesync) {
+ this.warnedAboutDesync = true;
+ MinecraftServer.LOGGER.error("World tick desync detected! Expected " + this.currentTick + " ticks, but got " + this.world.getGameTime() + " ticks for world '" + this.world.getWorld().getName() + "'", new Throwable());
+ MinecraftServer.LOGGER.error("Preventing redstone from breaking by refusing to accept new tick time");
+ }
+ }
+ }
+
+ @Override
+ public void tick() {
+ final ServerChunkCache chunkProvider = this.world.getChunkSource();
+
+ this.world.getProfiler().push("cleaning");
+ this.timingCleanup.startTiming();
+
+ this.prepare();
+
+ // this must be done here in case something schedules in the tick code
+ this.shortScheduled[this.shortScheduledIndex].clear();
+ this.shortScheduledIndex = getNextIndex(this.shortScheduledIndex, SHORT_SCHEDULE_TICK_THRESHOLD);
+
+ this.timingCleanup.stopTiming();
+ this.world.getProfiler().popPush("ticking");
+ this.timingTicking.startTiming();
+
+ for (final TickNextTickData<T> toTick : this.toTickThisTick) {
+ if (toTick.tickState != STATE_PENDING_TICK) {
+ // onTickEnd gets called at end of tick
+ continue;
+ }
+ try {
2021-07-16 16:18:04 +00:00
+ if (chunkProvider.isPositionTickingWithEntitiesLoaded(toTick.pos)) {
2021-06-11 12:02:28 +00:00
+ toTick.tickState = STATE_TICKING;
+ this.tickFunction.accept(toTick);
+ if (toTick.tickState == STATE_TICKING) {
+ toTick.tickState = STATE_TICKED;
+ } // else it's STATE_CANCELLED_TICK
+ } else {
+ // re-schedule eventually
+ toTick.tickState = STATE_SCHEDULED;
+ this.addToNotTickingReady(toTick);
+ }
+ } catch (final Throwable thr) {
+ // start copy from TickListServer // TODO check on update
+ CrashReport crashreport = CrashReport.forThrowable(thr, "Exception while ticking");
+ CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Block being ticked");
+
2021-06-13 22:05:18 +00:00
+ CrashReportCategory.populateBlockDetails(crashreportsystemdetails, this.world, toTick.pos, (BlockState) null);
2021-06-11 12:02:28 +00:00
+ throw new ReportedException(crashreport);
+ // end copy from TickListServer
+ }
+ }
+
+ this.timingTicking.stopTiming();
+ this.world.getProfiler().pop();
+ this.timingFinished.startTiming();
+
+ // finished ticking, actual cleanup time
+ for (int i = 0, len = this.toTickThisTick.size(); i < len; ++i) {
+ final TickNextTickData<T> entry = this.toTickThisTick.poll();
+ if (entry.tickState != STATE_SCHEDULED) {
+ // some entries get re-scheduled due to their chunk not being loaded/at correct status, so do not
+ // call onTickEnd for them
+ this.onTickEnd(entry);
+ }
+ }
+
+ this.timingFinished.stopTiming();
+ }
+
+ private void onTickEnd(final TickNextTickData<T> entry) {
+ if (entry.tickState == STATE_CANCELLED_TICK) {
+ return;
+ }
+ entry.tickState = STATE_UNSCHEDULED;
+
2021-06-13 22:05:18 +00:00
+ final BlockPos pos = entry.pos;
2021-06-11 12:02:28 +00:00
+ final long blockKey = MCUtil.getBlockKey(pos);
+
+ final ArrayList<TickNextTickData<T>> currentEntries = this.entriesByBlock.get(blockKey);
+
+ if (currentEntries.size() == 1) {
+ // it should contain our entry
+ this.entriesByBlock.remove(blockKey);
+ } else {
+ // it's more likely that this entry is at the start of the list than the end
+ for (int i = 0, len = currentEntries.size(); i < len; ++i) {
+ final TickNextTickData<T> currentEntry = currentEntries.get(i);
+ if (currentEntry == entry) {
+ currentEntries.remove(i);
+ break;
+ }
+ }
+ }
+
2021-06-13 22:05:18 +00:00
+ final long chunkKey = MCUtil.getCoordinateKey(entry.pos);
2021-06-11 12:02:28 +00:00
+
+ ObjectRBTreeSet<TickNextTickData<T>> set = this.entriesByChunk.get(chunkKey);
+
+ set.remove(entry);
+
+ if (set.isEmpty()) {
+ this.entriesByChunk.remove(chunkKey);
+ }
+
+ // already removed from longScheduled or shortScheduled
+ }
+
+ @Override
2021-06-13 22:05:18 +00:00
+ public boolean willTickThisTick(final BlockPos blockposition, final T data) {
2021-06-11 12:02:28 +00:00
+ final ArrayList<TickNextTickData<T>> entries = this.entriesByBlock.get(MCUtil.getBlockKey(blockposition));
+
+ if (entries == null) {
+ return false;
+ }
+
+ for (int i = 0, size = entries.size(); i < size; ++i) {
+ final TickNextTickData<T> entry = entries.get(i);
2021-06-13 22:05:18 +00:00
+ if (entry.getType() == data && entry.tickState == STATE_PENDING_TICK) {
2021-06-11 12:02:28 +00:00
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
2021-06-13 22:05:18 +00:00
+ public boolean hasScheduledTick(final BlockPos blockposition, final T data) {
2021-06-11 12:02:28 +00:00
+ final ArrayList<TickNextTickData<T>> entries = this.entriesByBlock.get(MCUtil.getBlockKey(blockposition));
+
+ if (entries == null) {
+ return false;
+ }
+
+ for (int i = 0, size = entries.size(); i < size; ++i) {
+ final TickNextTickData<T> entry = entries.get(i);
2021-06-13 22:05:18 +00:00
+ if (entry.getType() == data && entry.tickState == STATE_SCHEDULED) {
2021-06-11 12:02:28 +00:00
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
2021-06-13 22:05:18 +00:00
+ public void scheduleTick(BlockPos blockPosition, T t, int i, TickPriority tickListPriority) {
2021-06-11 12:02:28 +00:00
+ this.schedule(blockPosition, t, i + this.currentTick, tickListPriority);
+ }
+
+ public void schedule(final TickNextTickData<T> entry) {
2021-06-13 22:05:18 +00:00
+ this.schedule(entry.pos, entry.getType(), entry.triggerTick, entry.priority);
2021-06-11 12:02:28 +00:00
+ }
+
+ public void schedule(final BlockPos pos, final T data, final long targetTick, final TickPriority priority) {
+ final TickNextTickData<T> entry = new TickNextTickData<>(pos, data, targetTick, priority);
2021-06-13 22:05:18 +00:00
+ if (this.excludeFromScheduling.test(entry.getType())) {
2021-06-11 12:02:28 +00:00
+ return;
+ }
+
+ if (WARN_ON_EXCESSIVE_DELAY) {
2021-06-13 22:05:18 +00:00
+ final long delay = entry.triggerTick - this.currentTick;
2021-06-11 12:02:28 +00:00
+ if (delay >= EXCESSIVE_DELAY_THRESHOLD) {
+ MinecraftServer.LOGGER.warn("Entry " + entry.toString() + " has been scheduled with an excessive delay of: " + delay, new Throwable());
+ }
+ }
+
+ final long blockKey = MCUtil.getBlockKey(pos);
+
+ final ArrayList<TickNextTickData<T>> currentEntries = this.entriesByBlock.computeIfAbsent(blockKey, (long keyInMap) -> new ArrayList<>(3));
+
+ if (currentEntries.isEmpty()) {
+ currentEntries.add(entry);
+ } else {
+ for (int i = 0, size = currentEntries.size(); i < size; ++i) {
+ final TickNextTickData<T> currentEntry = currentEntries.get(i);
+
+ // entries are only blocked from scheduling if currentEntry.equals(toSchedule) && currentEntry is scheduled to tick (NOT including pending)
2021-06-13 22:05:18 +00:00
+ if (currentEntry.getType() == entry.getType() && currentEntry.tickState == STATE_SCHEDULED) {
2021-06-11 12:02:28 +00:00
+ // can't add
+ return;
+ }
+ }
+ currentEntries.add(entry);
+ }
+
+ entry.tickState = STATE_SCHEDULED;
+
2021-06-13 22:05:18 +00:00
+ this.entriesByChunk.computeIfAbsent(MCUtil.getCoordinateKey(entry.pos), (final long keyInMap) -> {
2021-06-11 12:02:28 +00:00
+ return new ObjectRBTreeSet<>(TickListServerInterval.ENTRY_COMPARATOR);
+ }).add(entry);
+
+ this.addToSchedule(entry);
+ }
+
+ public void scheduleAll(final Iterator<TickNextTickData<T>> iterator) {
+ while (iterator.hasNext()) {
+ this.schedule(iterator.next());
+ }
+ }
+
+ // this is not the standard interception calculation, but it's the one vanilla uses
+ // i.e the y value is ignored? the x, z calc isn't correct?
+ // however for the copy op they use the correct intersection, after using this one of course...
+ private static boolean isBlockInSortof(final BoundingBox boundingBox, final BlockPos pos) {
2021-06-13 22:05:18 +00:00
+ return pos.getX() >= boundingBox.minX() && pos.getX() < boundingBox.maxX() && pos.getZ() >= boundingBox.minZ() && pos.getZ() < boundingBox.maxZ();
2021-06-11 12:02:28 +00:00
+ }
+
+ @Override
2021-06-13 22:05:18 +00:00
+ public List<TickNextTickData<T>> fetchTicksInArea(final BoundingBox structureboundingbox, final boolean removeReturned, final boolean excludeTicked) {
+ if (structureboundingbox.minX() == structureboundingbox.maxX() || structureboundingbox.minZ() == structureboundingbox.maxZ()) {
2021-06-11 12:02:28 +00:00
+ return Collections.emptyList(); // vanilla behaviour, check isBlockInSortof above
+ }
+
2021-06-13 22:05:18 +00:00
+ final int lowerChunkX = structureboundingbox.minX() >> 4;
+ final int upperChunkX = (structureboundingbox.maxX() - 1) >> 4; // subtract 1 since maxX is exclusive
+ final int lowerChunkZ = structureboundingbox.minZ() >> 4;
+ final int upperChunkZ = (structureboundingbox.maxZ() - 1) >> 4; // subtract 1 since maxZ is exclusive
2021-06-11 12:02:28 +00:00
+
+ final int xChunksLength = (upperChunkX - lowerChunkX + 1);
+ final int zChunksLength = (upperChunkZ - lowerChunkZ + 1);
+
+ final ObjectRBTreeSet<TickNextTickData<T>>[] containingChunks = new ObjectRBTreeSet[xChunksLength * zChunksLength];
+
+ final int offset = (xChunksLength * -lowerChunkZ - lowerChunkX);
+ int totalEntries = 0;
+ for (int currChunkX = lowerChunkX; currChunkX <= upperChunkX; ++currChunkX) {
+ for (int currChunkZ = lowerChunkZ; currChunkZ <= upperChunkZ; ++currChunkZ) {
+ // todo optimize
+ //final int index = (currChunkX - lowerChunkX) + xChunksLength * (currChunkZ - lowerChunkZ);
+ final int index = offset + currChunkX + xChunksLength * currChunkZ;
+ final ObjectRBTreeSet<TickNextTickData<T>> set = containingChunks[index] = this.entriesByChunk.get(MCUtil.getCoordinateKey(currChunkX, currChunkZ));
+ if (set != null) {
+ totalEntries += set.size();
+ }
+ }
+ }
+
+ final List<TickNextTickData<T>> ret = new ArrayList<>(totalEntries);
+
+ final int matchOne = (STATE_SCHEDULED | STATE_PENDING_TICK) | (excludeTicked ? 0 : (STATE_TICKING | STATE_TICKED));
+
+ MCUtil.mergeSortedSets((TickNextTickData<T> entry) -> {
2021-06-13 22:05:18 +00:00
+ if (!isBlockInSortof(structureboundingbox, entry.pos)) {
2021-06-11 12:02:28 +00:00
+ return;
+ }
+ final int tickState = entry.tickState;
+ if ((tickState & matchOne) == 0) {
+ return;
+ }
+
+ ret.add(entry);
+ return;
+ }, TickListServerInterval.ENTRY_COMPARATOR, containingChunks);
+
+ if (removeReturned) {
+ for (TickNextTickData<T> entry : ret) {
+ this.removeEntry(entry);
+ }
+ }
+
+ return ret;
+ }
+
+ @Override
+ public void copy(BoundingBox structureboundingbox, BlockPos blockposition) {
+ // start copy from TickListServer // TODO check on update
2021-06-13 22:05:18 +00:00
+ List<TickNextTickData<T>> list = this.fetchTicksInArea(structureboundingbox, false, false);
2021-06-11 12:02:28 +00:00
+ Iterator<TickNextTickData<T>> iterator = list.iterator();
+
+ while (iterator.hasNext()) {
+ TickNextTickData<T> nextticklistentry = iterator.next();
+
2021-06-13 22:05:18 +00:00
+ if (structureboundingbox.isInside( nextticklistentry.pos)) {
+ BlockPos blockposition1 = nextticklistentry.pos.offset(blockposition);
+ T t0 = nextticklistentry.getType();
2021-06-11 12:02:28 +00:00
+
2021-06-13 22:05:18 +00:00
+ this.schedule(new TickNextTickData<>(blockposition1, t0, nextticklistentry.triggerTick, nextticklistentry.priority));
2021-06-11 12:02:28 +00:00
+ }
+ }
+ // end copy from TickListServer
+ }
+
+ @Override
2021-06-13 22:05:18 +00:00
+ public List<TickNextTickData<T>> fetchTicksInChunk(ChunkPos chunkPos, boolean removeReturned, boolean excludeTicked) {
2021-06-11 12:02:28 +00:00
+ // Vanilla DOES get the entries 2 blocks out of the chunk too, but that doesn't matter since we ignore chunks
+ // not at ticking status, and ticking status requires neighbours loaded
+ // so with this method we will reduce scheduler churning
+ final int matchOne = (STATE_SCHEDULED | STATE_PENDING_TICK) | (excludeTicked ? 0 : (STATE_TICKING | STATE_TICKED));
+
+ final ObjectRBTreeSet<TickNextTickData<T>> entries = this.entriesByChunk.get(MCUtil.getCoordinateKey(chunkPos));
+
+ if (entries == null) {
+ return Collections.emptyList();
+ }
+
+ final List<TickNextTickData<T>> ret = new ArrayList<>(entries.size());
+
+ for (TickNextTickData<T> entry : entries) {
+ if ((entry.tickState & matchOne) == 0) {
+ continue;
+ }
+ ret.add(entry);
+ }
+
+ if (removeReturned) {
+ for (TickNextTickData<T> entry : ret) {
+ this.removeEntry(entry);
+ }
+ }
+
+ return ret;
+ }
+
+ @Override
2021-06-13 22:05:18 +00:00
+ public ListTag save(ChunkPos chunkcoordintpair) {
2021-06-11 12:02:28 +00:00
+ // start copy from TickListServer // TODO check on update
2021-06-13 22:05:18 +00:00
+ List<TickNextTickData<T>> list = this.fetchTicksInChunk(chunkcoordintpair, false, true);
2021-06-11 12:02:28 +00:00
+
2021-06-13 22:05:18 +00:00
+ return ServerTickList.saveTickList(this.getMinecraftKeyFrom, list, this.currentTick);
2021-06-11 12:02:28 +00:00
+ // end copy from TickListServer
+ }
+
+ @Override
2021-06-13 22:05:18 +00:00
+ public int size() {
2021-06-11 12:02:28 +00:00
+ // good thing this is only used in debug reports // TODO check on update
+ int ret = 0;
+
+ for (TickNextTickData<T> entry : this.longScheduled) {
+ if (entry.tickState == STATE_SCHEDULED) {
+ ++ret;
+ }
+ }
+
+ for (Iterator<Long2ObjectMap.Entry<ArrayList<TickNextTickData<T>>>> iterator = this.pendingChunkTickLoad.long2ObjectEntrySet().iterator(); iterator.hasNext();) {
+ ArrayList<TickNextTickData<T>> list = iterator.next().getValue();
+
+ for (TickNextTickData<T> entry : list) {
+ if (entry.tickState == STATE_SCHEDULED) {
+ ++ret;
+ }
+ }
+ }
+
+ for (TickListServerInterval<T> interval : this.shortScheduled) {
+ for (Iterable<TickNextTickData<T>> set : interval.byPriority) {
+ for (TickNextTickData<T> entry : set) {
+ if (entry.tickState == STATE_SCHEDULED) {
+ ++ret;
+ }
+ }
+ }
+ }
+
+ return ret;
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/server/ticklist/TickListServerInterval.java b/src/main/java/com/destroystokyo/paper/server/ticklist/TickListServerInterval.java
new file mode 100644
2021-06-13 22:05:18 +00:00
index 0000000000000000000000000000000000000000..a1e6f49274a7ae8057a9112e0dd6597a8e58e6da
2021-06-11 12:02:28 +00:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/server/ticklist/TickListServerInterval.java
@@ -0,0 +1,41 @@
+package com.destroystokyo.paper.server.ticklist;
+
+import com.destroystokyo.paper.util.set.LinkedSortedSet;
+import java.util.Comparator;
+import net.minecraft.world.level.TickNextTickData;
+import net.minecraft.world.level.TickPriority;
+
+// represents a set of entries to tick at a specified time
+public final class TickListServerInterval<T> {
+
+ public static final int TOTAL_PRIORITIES = TickPriority.values().length;
+ public static final Comparator<TickNextTickData<?>> ENTRY_COMPARATOR_BY_ID = (entry1, entry2) -> {
+ return Long.compare(entry1.getId(), entry2.getId());
+ };
2021-06-13 22:05:18 +00:00
+ public static final Comparator<TickNextTickData<?>> ENTRY_COMPARATOR = (Comparator)TickNextTickData.createTimeComparator();
2021-06-11 12:02:28 +00:00
+
+ // we do not record the interval, this class is meant to be used on a ring buffer
+
+ // inlined enum map for TickListPriority
+ public final LinkedSortedSet<TickNextTickData<T>>[] byPriority = new LinkedSortedSet[TOTAL_PRIORITIES];
+
+ {
+ for (int i = 0, len = this.byPriority.length; i < len; ++i) {
+ this.byPriority[i] = new LinkedSortedSet<>(ENTRY_COMPARATOR_BY_ID);
+ }
+ }
+
+ public void addEntryLast(final TickNextTickData<T> entry) {
2021-06-13 22:05:18 +00:00
+ this.byPriority[entry.priority.ordinal()].addLast(entry);
2021-06-11 12:02:28 +00:00
+ }
+
+ public void addEntryFirst(final TickNextTickData<T> entry) {
2021-06-13 22:05:18 +00:00
+ this.byPriority[entry.priority.ordinal()].addFirst(entry);
2021-06-11 12:02:28 +00:00
+ }
+
+ public void clear() {
+ for (int i = 0, len = this.byPriority.length; i < len; ++i) {
+ this.byPriority[i].clear(); // O(1) clear
+ }
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/util/set/LinkedSortedSet.java b/src/main/java/com/destroystokyo/paper/util/set/LinkedSortedSet.java
new file mode 100644
index 0000000000000000000000000000000000000000..118988c39e58f28e8a2851792b9c014f341f06fc
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/util/set/LinkedSortedSet.java
@@ -0,0 +1,142 @@
+package com.destroystokyo.paper.util.set;
+
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+public final class LinkedSortedSet<E> implements Iterable<E> {
+
+ public final Comparator<? super E> comparator;
+
+ protected Link<E> head;
+ protected Link<E> tail;
+
+ public LinkedSortedSet() {
+ this((Comparator)Comparator.naturalOrder());
+ }
+
+ public LinkedSortedSet(final Comparator<? super E> comparator) {
+ this.comparator = comparator;
+ }
+
+ public void clear() {
+ this.head = this.tail = null;
+ }
+
+ @Override
+ public Iterator<E> iterator() {
+ return new Iterator<E>() {
+
+ Link<E> next = LinkedSortedSet.this.head;
+
+ @Override
+ public boolean hasNext() {
+ return this.next != null;
+ }
+
+ @Override
+ public E next() {
+ final Link<E> next = this.next;
+ if (next == null) {
+ throw new NoSuchElementException();
+ }
+ this.next = next.next;
+ return next.element;
+ }
+ };
+ }
+
+ public boolean addLast(final E element) {
+ final Comparator<? super E> comparator = this.comparator;
+
+ Link<E> curr = this.tail;
+ if (curr != null) {
+ int compare;
+
+ while ((compare = comparator.compare(element, curr.element)) < 0) {
+ Link<E> prev = curr;
+ curr = curr.prev;
+ if (curr != null) {
+ continue;
+ }
+ this.head = prev.prev = new Link<>(element, null, prev);
+ return true;
+ }
+
+ if (compare != 0) {
+ // insert after curr
+ final Link<E> next = curr.next;
+ final Link<E> insert = new Link<>(element, curr, next);
+ curr.next = insert;
+
+ if (next == null) {
+ this.tail = insert;
+ } else {
+ next.prev = insert;
+ }
+ return true;
+ }
+
+ return false;
+ } else {
+ this.head = this.tail = new Link<>(element);
+ return true;
+ }
+ }
+
+ public boolean addFirst(final E element) {
+ final Comparator<? super E> comparator = this.comparator;
+
+ Link<E> curr = this.head;
+ if (curr != null) {
+ int compare;
+
+ while ((compare = comparator.compare(element, curr.element)) > 0) {
+ Link<E> prev = curr;
+ curr = curr.next;
+ if (curr != null) {
+ continue;
+ }
+ this.tail = prev.next = new Link<>(element, prev, null);
+ return true;
+ }
+
+ if (compare != 0) {
+ // insert before curr
+ final Link<E> prev = curr.prev;
+ final Link<E> insert = new Link<>(element, prev, curr);
+ curr.prev = insert;
+
+ if (prev == null) {
+ this.head = insert;
+ } else {
+ prev.next = insert;
+ }
+ return true;
+ }
+
+ return false;
+ } else {
+ this.head = this.tail = new Link<>(element);
+ return true;
+ }
+ }
+
+ protected static final class Link<E> {
+ public E element;
+ public Link<E> prev;
+ public Link<E> next;
+
+ public Link() {}
+
+ public Link(final E element) {
+ this.element = element;
+ }
+
+ public Link(final E element, final Link<E> prev, final Link<E> next) {
+ this.element = element;
+ this.prev = prev;
+ this.next = next;
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index 84f370e887a3e7ff49296bdf8d6d8de9cc194cfb..daeb5b175d17492f382d23af58a9cc46fbb49e60 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
2021-06-13 22:05:18 +00:00
@@ -86,6 +86,19 @@ public class ChunkHolder {
return null;
}
// Paper end - no-tick view distance
+ // Paper start
+ public final boolean isEntityTickingReady() {
+ return this.isEntityTickingReady;
+ }
+
+ public final boolean isTickingReady() {
+ return this.isTickingReady;
+ }
+
+ public final boolean isFullChunkReady() {
+ return this.isFullChunkReady;
+ }
+ // Paper end
2021-06-11 12:02:28 +00:00
2021-06-13 22:05:18 +00:00
public ChunkHolder(ChunkPos pos, int level, LevelHeightAccessor world, LevelLightEngine lightingProvider, ChunkHolder.LevelChangeListener levelUpdateListener, ChunkHolder.PlayerProvider playersWatchingChunkProvider) {
this.futures = new AtomicReferenceArray(ChunkHolder.CHUNK_STATUSES.size());
Merge tuinity (#6413) This PR contains all of Tuinity's patches. Very notable ones are: - Highly optimised collisions - Optimised entity lookups by bounding box (Mojang made regressions in 1.17, this brings it back to 1.16) - Starlight https://github.com/PaperMC/Starlight - Rewritten dataconverter system https://github.com/PaperMC/DataConverter - Random block ticking optimisation (wrongly dropped from Paper 1.17) - Chunk ticking optimisations - Anything else I've forgotten in the 60 or so patches If you are a previous Tuinity user, your config will not migrate. You must do it yourself. The config options have simply been moved into paper.yml, so it will be an easy migration. However, please note that the chunk loading options in tuinity.yml are NOT compatible with the options in paper.yml. * Port tuinity, initial patchset * Update gradle to 7.2 jmp said it fixes rebuildpatches not working for me. it fucking better * Completely clean apply * Remove tuinity config, add per player api patch * Remove paper reobf mappings patch * Properly update gradlew * Force clean rebuild * Mark fixups Comments and ATs still need to be done * grep -r "Tuinity" * Fixup * Ensure gameprofile lastaccess is written only under the state lock * update URL for dataconverter * Only clean rebuild tuinity patches might fix merge conflicts * Use UTF-8 for gradlew * Clean rb patches again * Convert block ids used as item ids Neither the converters of pre 1.13 nor DFU handled these cases, as by the time they were written the game at the time didn't consider these ids valid - they would be air. Because of this, some worlds have logspam since only DataConverter (not DFU or legacy converters) will warn when an invalid id has been seen. While quite a few do need to now be considered as air, quite a lot do not. So it makes sense to add conversion for these items, instead of simply suppressing or ignoring the logs. I've now added id -> string conversion for all block ids that could be used as items that existed in the game before 1.7.10 (I have no interest in tracking down the exact version block ids stopped working) that were on https://minecraft-ids.grahamedgecombe.com/ Items that did not directly convert to new items will be instead converted to air: stems, wheat crops, piston head, tripwire wire block * Fix LightPopulated parsing in V1466 The DFU code was checking if the number existed, not if it didn't exist. I misread the original code. * Always parse protochunk light sources unless it is marked as non-lit Chunks not marked as lit will always go through the light engine, so they should always have their block sources parsed. * Update custom names to JSON for players Missed this fix from CB, as it was inside the DataFixers class. I decided to double check all of the CB changes again: DataFixers.java was the only area I missed, as I had inspected all datafixer diffs and implemented them all into DataConverter. I also checked Bootstrap.java again, and re-evaluated their changes. I had previously done this, but determined that they were all bad. The changes to make standing_sign block map to oak_sign block in V1450 is bad, because that's not the item id V1450 accepts. Only in 1.14 did oak_sign even exist, and as expected there is a converter to rename all existing sign items/blocks. The fix to register the portal block under id 1440 is useless, as the flattenning logic will default to the lowest registered id - which is the exact blockstate that CB registers into 1440. So it just doesn't do anything. The extra item ids in the id -> string converter are already added, but I found this from EMC originally. The change for the spawn egg id 23 -> Arrow is just wrong, that id DOES correspond to TippedArrow, NOT Arrow. As expected, the spawn egg already has a dedicated mapping for Arrow, which is id 10 - which was Arrow's entity id. I also ported a fix for the cooked_fished id update. This doesn't really matter since there is already a dataconverter to fix this, but the game didn't accept cooked_fished at the time. So I see no harm. * Review all converters and walkers - Refactor V99 to have helper methods for defining entity/tile entity types - Automatically namespace all ids that should be namespaced. While vanilla never saved non-namespaced data for things that are namespaced, plugins/users might have. - Synchronised the identity ensure map in HelperBlockFlatteningV1450 - Code style consistency - Add missing log warning in V102 for ITEM_NAME type conversion - Use getBoolean instead of getByte - Use ConverterAbstractEntityRename for V143 TippedArrow -> Arrow rename, as it will affect ENTITY_NAME type - Always set isVillager to false in V502 for Zombie - Register V808's converter under subversion 1 like DFU - Register a breakpoint for V1.17.1. In the future, all final versions of major releases will have a breakpoint so that the work required to determine if a converter needs a breakpoint is minimal - Validate that a dataconverter is only registered for a version that is registered - ConverterFlattenTileEntity is actually ConverterFlattenEntity It even registered the converters under TILE_ENTITY, instead of ENTITY. - Fix id comparison in V1492 STRUCTURE_FEATURE renamer - Use ConverterAbstractStatsRename for V1510 stats renamer At the time I had written that class, the abstract renamer didn't exist. - Ensure OwnerUUID is at least set to empty string in V1904 if the ocelot is converted to a cat (this is likely so that it retains a collar) - Use generic read/write for Records in V1946 Records is actually a list, not a map. So reading map was invalid. * Always set light to zero when propagating decrease This fixes an almost infinite loop where light values would be spam queued on a very small subset on blocks. This also likely fixes the memory issues people were seeing. * re-organize patches * Apply and fix conflicts * Revert some patches getChunkAt retains chunks so that plugins don't spam loads revert mc-4 fix will remain unless issues pop up * Shuffle iterated chunks if per player is not enabled Can help with some mob spawning stacking up at locations * Make per player default, migrate all configs * Adjust comments in fixups * Rework config for player chunk loader Old config is not compatible. Move all configs to be under `settings` in paper.yml The player chunk loader has been modified to less aggressively load chunks, but to send chunks at higher rates compared to tuinity. There are new config entries to tune this behavior. * Add back old constructor to CompressionEncoder/Decoder (fixes Tuinity #358) * Raise chunk loading default limits * Reduce worldgen thread workers for lower core count cpus * Raise limits for chunk loading config Also place it under `chunk-loading` * Disable max chunk send rate by default * Fix conflicts and rebuild patches * Drop default send rate again Appears to be still causing problems for no known reason * Raise chunk send limits to 100 per player While a low limit fixes ping issues for some people, most people do not suffer from this issue and thus should not suffer from an extremely slow load-in rate. * Rebase part 1 Autosquash the fixups * Move not implemented up * Fixup mc-dev fixes Missed this one * Rebase per player viewdistance api into the original api patch * Remove old light engine patch part 1 The prioritisation must be kept from it, so that part has been rebased into the priority patch. Part 2 will deal with rebasing all of the patches _after_ * Rebase remaining patches for old light patch removal * Remove other mid tick patch * Remove Optimize-PlayerChunkMap-memory-use-for-visibleChunks.patch Replaced by `Do not copy visible chunks` * Revert AT for Vec3i setX/Y/Z The class is immutable. set should not be exposed * Remove old IntegerUtil class * Replace old CraftChunk#getEntities patch * Remove import for SWMRNibbleArray in ChunkAccess * Finished merge checklist * Remove ensureTickThread impl in urgency patch Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com> Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
2021-08-31 11:02:11 +00:00
@@ -541,6 +554,11 @@ public class ChunkHolder {
// Paper start - ticking chunk set
ChunkHolder.this.chunkMap.level.getChunkSource().tickingChunks.add(chunk);
// Paper end - ticking chunk set
2021-06-11 12:02:28 +00:00
+ // Paper start - rewrite ticklistserver
+ if (ChunkHolder.this.chunkMap.level.entityManager.areEntitiesLoaded(this.pos.longKey)) {
+ ChunkHolder.this.chunkMap.level.onChunkSetTicking(ChunkHolder.this.pos.x, ChunkHolder.this.pos.z);
+ }
2021-06-11 12:02:28 +00:00
+ // Paper end - rewrite ticklistserver
2021-06-13 22:05:18 +00:00
});
2021-06-11 12:02:28 +00:00
});
2021-06-13 22:05:18 +00:00
// Paper end
2021-06-11 12:02:28 +00:00
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
2021-10-03 01:42:30 +00:00
index c6213a7dfcf9aeccdb546eaf74fa8eb119a6a32c..ec0d8e58a518a20634b902769251d6d04750433e 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
Merge tuinity (#6413) This PR contains all of Tuinity's patches. Very notable ones are: - Highly optimised collisions - Optimised entity lookups by bounding box (Mojang made regressions in 1.17, this brings it back to 1.16) - Starlight https://github.com/PaperMC/Starlight - Rewritten dataconverter system https://github.com/PaperMC/DataConverter - Random block ticking optimisation (wrongly dropped from Paper 1.17) - Chunk ticking optimisations - Anything else I've forgotten in the 60 or so patches If you are a previous Tuinity user, your config will not migrate. You must do it yourself. The config options have simply been moved into paper.yml, so it will be an easy migration. However, please note that the chunk loading options in tuinity.yml are NOT compatible with the options in paper.yml. * Port tuinity, initial patchset * Update gradle to 7.2 jmp said it fixes rebuildpatches not working for me. it fucking better * Completely clean apply * Remove tuinity config, add per player api patch * Remove paper reobf mappings patch * Properly update gradlew * Force clean rebuild * Mark fixups Comments and ATs still need to be done * grep -r "Tuinity" * Fixup * Ensure gameprofile lastaccess is written only under the state lock * update URL for dataconverter * Only clean rebuild tuinity patches might fix merge conflicts * Use UTF-8 for gradlew * Clean rb patches again * Convert block ids used as item ids Neither the converters of pre 1.13 nor DFU handled these cases, as by the time they were written the game at the time didn't consider these ids valid - they would be air. Because of this, some worlds have logspam since only DataConverter (not DFU or legacy converters) will warn when an invalid id has been seen. While quite a few do need to now be considered as air, quite a lot do not. So it makes sense to add conversion for these items, instead of simply suppressing or ignoring the logs. I've now added id -> string conversion for all block ids that could be used as items that existed in the game before 1.7.10 (I have no interest in tracking down the exact version block ids stopped working) that were on https://minecraft-ids.grahamedgecombe.com/ Items that did not directly convert to new items will be instead converted to air: stems, wheat crops, piston head, tripwire wire block * Fix LightPopulated parsing in V1466 The DFU code was checking if the number existed, not if it didn't exist. I misread the original code. * Always parse protochunk light sources unless it is marked as non-lit Chunks not marked as lit will always go through the light engine, so they should always have their block sources parsed. * Update custom names to JSON for players Missed this fix from CB, as it was inside the DataFixers class. I decided to double check all of the CB changes again: DataFixers.java was the only area I missed, as I had inspected all datafixer diffs and implemented them all into DataConverter. I also checked Bootstrap.java again, and re-evaluated their changes. I had previously done this, but determined that they were all bad. The changes to make standing_sign block map to oak_sign block in V1450 is bad, because that's not the item id V1450 accepts. Only in 1.14 did oak_sign even exist, and as expected there is a converter to rename all existing sign items/blocks. The fix to register the portal block under id 1440 is useless, as the flattenning logic will default to the lowest registered id - which is the exact blockstate that CB registers into 1440. So it just doesn't do anything. The extra item ids in the id -> string converter are already added, but I found this from EMC originally. The change for the spawn egg id 23 -> Arrow is just wrong, that id DOES correspond to TippedArrow, NOT Arrow. As expected, the spawn egg already has a dedicated mapping for Arrow, which is id 10 - which was Arrow's entity id. I also ported a fix for the cooked_fished id update. This doesn't really matter since there is already a dataconverter to fix this, but the game didn't accept cooked_fished at the time. So I see no harm. * Review all converters and walkers - Refactor V99 to have helper methods for defining entity/tile entity types - Automatically namespace all ids that should be namespaced. While vanilla never saved non-namespaced data for things that are namespaced, plugins/users might have. - Synchronised the identity ensure map in HelperBlockFlatteningV1450 - Code style consistency - Add missing log warning in V102 for ITEM_NAME type conversion - Use getBoolean instead of getByte - Use ConverterAbstractEntityRename for V143 TippedArrow -> Arrow rename, as it will affect ENTITY_NAME type - Always set isVillager to false in V502 for Zombie - Register V808's converter under subversion 1 like DFU - Register a breakpoint for V1.17.1. In the future, all final versions of major releases will have a breakpoint so that the work required to determine if a converter needs a breakpoint is minimal - Validate that a dataconverter is only registered for a version that is registered - ConverterFlattenTileEntity is actually ConverterFlattenEntity It even registered the converters under TILE_ENTITY, instead of ENTITY. - Fix id comparison in V1492 STRUCTURE_FEATURE renamer - Use ConverterAbstractStatsRename for V1510 stats renamer At the time I had written that class, the abstract renamer didn't exist. - Ensure OwnerUUID is at least set to empty string in V1904 if the ocelot is converted to a cat (this is likely so that it retains a collar) - Use generic read/write for Records in V1946 Records is actually a list, not a map. So reading map was invalid. * Always set light to zero when propagating decrease This fixes an almost infinite loop where light values would be spam queued on a very small subset on blocks. This also likely fixes the memory issues people were seeing. * re-organize patches * Apply and fix conflicts * Revert some patches getChunkAt retains chunks so that plugins don't spam loads revert mc-4 fix will remain unless issues pop up * Shuffle iterated chunks if per player is not enabled Can help with some mob spawning stacking up at locations * Make per player default, migrate all configs * Adjust comments in fixups * Rework config for player chunk loader Old config is not compatible. Move all configs to be under `settings` in paper.yml The player chunk loader has been modified to less aggressively load chunks, but to send chunks at higher rates compared to tuinity. There are new config entries to tune this behavior. * Add back old constructor to CompressionEncoder/Decoder (fixes Tuinity #358) * Raise chunk loading default limits * Reduce worldgen thread workers for lower core count cpus * Raise limits for chunk loading config Also place it under `chunk-loading` * Disable max chunk send rate by default * Fix conflicts and rebuild patches * Drop default send rate again Appears to be still causing problems for no known reason * Raise chunk send limits to 100 per player While a low limit fixes ping issues for some people, most people do not suffer from this issue and thus should not suffer from an extremely slow load-in rate. * Rebase part 1 Autosquash the fixups * Move not implemented up * Fixup mc-dev fixes Missed this one * Rebase per player viewdistance api into the original api patch * Remove old light engine patch part 1 The prioritisation must be kept from it, so that part has been rebased into the priority patch. Part 2 will deal with rebasing all of the patches _after_ * Rebase remaining patches for old light patch removal * Remove other mid tick patch * Remove Optimize-PlayerChunkMap-memory-use-for-visibleChunks.patch Replaced by `Do not copy visible chunks` * Revert AT for Vec3i setX/Y/Z The class is immutable. set should not be exposed * Remove old IntegerUtil class * Replace old CraftChunk#getEntities patch * Remove import for SWMRNibbleArray in ChunkAccess * Finished merge checklist * Remove ensureTickThread impl in urgency patch Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com> Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
2021-08-31 11:02:11 +00:00
@@ -218,6 +218,18 @@ public class ServerChunkCache extends ChunkSource {
2021-06-13 22:05:18 +00:00
}, this.mainThreadProcessor);
2021-06-11 12:02:28 +00:00
}
// Paper end
+ // Paper start - rewrite ticklistserver
+ public final boolean isPositionTickingReady(long pos) {
+ final ChunkHolder chunkHolder = this.chunkMap.getUpdatingChunkIfPresent(pos);
+ return chunkHolder != null && chunkHolder.isTickingReady();
+ }
+
2021-07-16 16:18:04 +00:00
+ public final boolean isPositionTickingWithEntitiesLoaded(BlockPos pos) {
+ final long position = net.minecraft.server.MCUtil.getCoordinateKey(pos);
+ final ChunkHolder chunkHolder = this.chunkMap.getUpdatingChunkIfPresent(position);
+ return chunkHolder != null && chunkHolder.isTickingReady() && this.level.entityManager.areEntitiesLoaded(position);
2021-06-11 12:02:28 +00:00
+ }
+ // Paper end - rewrite ticklistserver
2021-06-13 22:05:18 +00:00
Merge tuinity (#6413) This PR contains all of Tuinity's patches. Very notable ones are: - Highly optimised collisions - Optimised entity lookups by bounding box (Mojang made regressions in 1.17, this brings it back to 1.16) - Starlight https://github.com/PaperMC/Starlight - Rewritten dataconverter system https://github.com/PaperMC/DataConverter - Random block ticking optimisation (wrongly dropped from Paper 1.17) - Chunk ticking optimisations - Anything else I've forgotten in the 60 or so patches If you are a previous Tuinity user, your config will not migrate. You must do it yourself. The config options have simply been moved into paper.yml, so it will be an easy migration. However, please note that the chunk loading options in tuinity.yml are NOT compatible with the options in paper.yml. * Port tuinity, initial patchset * Update gradle to 7.2 jmp said it fixes rebuildpatches not working for me. it fucking better * Completely clean apply * Remove tuinity config, add per player api patch * Remove paper reobf mappings patch * Properly update gradlew * Force clean rebuild * Mark fixups Comments and ATs still need to be done * grep -r "Tuinity" * Fixup * Ensure gameprofile lastaccess is written only under the state lock * update URL for dataconverter * Only clean rebuild tuinity patches might fix merge conflicts * Use UTF-8 for gradlew * Clean rb patches again * Convert block ids used as item ids Neither the converters of pre 1.13 nor DFU handled these cases, as by the time they were written the game at the time didn't consider these ids valid - they would be air. Because of this, some worlds have logspam since only DataConverter (not DFU or legacy converters) will warn when an invalid id has been seen. While quite a few do need to now be considered as air, quite a lot do not. So it makes sense to add conversion for these items, instead of simply suppressing or ignoring the logs. I've now added id -> string conversion for all block ids that could be used as items that existed in the game before 1.7.10 (I have no interest in tracking down the exact version block ids stopped working) that were on https://minecraft-ids.grahamedgecombe.com/ Items that did not directly convert to new items will be instead converted to air: stems, wheat crops, piston head, tripwire wire block * Fix LightPopulated parsing in V1466 The DFU code was checking if the number existed, not if it didn't exist. I misread the original code. * Always parse protochunk light sources unless it is marked as non-lit Chunks not marked as lit will always go through the light engine, so they should always have their block sources parsed. * Update custom names to JSON for players Missed this fix from CB, as it was inside the DataFixers class. I decided to double check all of the CB changes again: DataFixers.java was the only area I missed, as I had inspected all datafixer diffs and implemented them all into DataConverter. I also checked Bootstrap.java again, and re-evaluated their changes. I had previously done this, but determined that they were all bad. The changes to make standing_sign block map to oak_sign block in V1450 is bad, because that's not the item id V1450 accepts. Only in 1.14 did oak_sign even exist, and as expected there is a converter to rename all existing sign items/blocks. The fix to register the portal block under id 1440 is useless, as the flattenning logic will default to the lowest registered id - which is the exact blockstate that CB registers into 1440. So it just doesn't do anything. The extra item ids in the id -> string converter are already added, but I found this from EMC originally. The change for the spawn egg id 23 -> Arrow is just wrong, that id DOES correspond to TippedArrow, NOT Arrow. As expected, the spawn egg already has a dedicated mapping for Arrow, which is id 10 - which was Arrow's entity id. I also ported a fix for the cooked_fished id update. This doesn't really matter since there is already a dataconverter to fix this, but the game didn't accept cooked_fished at the time. So I see no harm. * Review all converters and walkers - Refactor V99 to have helper methods for defining entity/tile entity types - Automatically namespace all ids that should be namespaced. While vanilla never saved non-namespaced data for things that are namespaced, plugins/users might have. - Synchronised the identity ensure map in HelperBlockFlatteningV1450 - Code style consistency - Add missing log warning in V102 for ITEM_NAME type conversion - Use getBoolean instead of getByte - Use ConverterAbstractEntityRename for V143 TippedArrow -> Arrow rename, as it will affect ENTITY_NAME type - Always set isVillager to false in V502 for Zombie - Register V808's converter under subversion 1 like DFU - Register a breakpoint for V1.17.1. In the future, all final versions of major releases will have a breakpoint so that the work required to determine if a converter needs a breakpoint is minimal - Validate that a dataconverter is only registered for a version that is registered - ConverterFlattenTileEntity is actually ConverterFlattenEntity It even registered the converters under TILE_ENTITY, instead of ENTITY. - Fix id comparison in V1492 STRUCTURE_FEATURE renamer - Use ConverterAbstractStatsRename for V1510 stats renamer At the time I had written that class, the abstract renamer didn't exist. - Ensure OwnerUUID is at least set to empty string in V1904 if the ocelot is converted to a cat (this is likely so that it retains a collar) - Use generic read/write for Records in V1946 Records is actually a list, not a map. So reading map was invalid. * Always set light to zero when propagating decrease This fixes an almost infinite loop where light values would be spam queued on a very small subset on blocks. This also likely fixes the memory issues people were seeing. * re-organize patches * Apply and fix conflicts * Revert some patches getChunkAt retains chunks so that plugins don't spam loads revert mc-4 fix will remain unless issues pop up * Shuffle iterated chunks if per player is not enabled Can help with some mob spawning stacking up at locations * Make per player default, migrate all configs * Adjust comments in fixups * Rework config for player chunk loader Old config is not compatible. Move all configs to be under `settings` in paper.yml The player chunk loader has been modified to less aggressively load chunks, but to send chunks at higher rates compared to tuinity. There are new config entries to tune this behavior. * Add back old constructor to CompressionEncoder/Decoder (fixes Tuinity #358) * Raise chunk loading default limits * Reduce worldgen thread workers for lower core count cpus * Raise limits for chunk loading config Also place it under `chunk-loading` * Disable max chunk send rate by default * Fix conflicts and rebuild patches * Drop default send rate again Appears to be still causing problems for no known reason * Raise chunk send limits to 100 per player While a low limit fixes ping issues for some people, most people do not suffer from this issue and thus should not suffer from an extremely slow load-in rate. * Rebase part 1 Autosquash the fixups * Move not implemented up * Fixup mc-dev fixes Missed this one * Rebase per player viewdistance api into the original api patch * Remove old light engine patch part 1 The prioritisation must be kept from it, so that part has been rebased into the priority patch. Part 2 will deal with rebasing all of the patches _after_ * Rebase remaining patches for old light patch removal * Remove other mid tick patch * Remove Optimize-PlayerChunkMap-memory-use-for-visibleChunks.patch Replaced by `Do not copy visible chunks` * Revert AT for Vec3i setX/Y/Z The class is immutable. set should not be exposed * Remove old IntegerUtil class * Replace old CraftChunk#getEntities patch * Remove import for SWMRNibbleArray in ChunkAccess * Finished merge checklist * Remove ensureTickThread impl in urgency patch Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com> Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
2021-08-31 11:02:11 +00:00
// Paper start
// this will try to avoid chunk neighbours for lighting
2021-06-11 12:02:28 +00:00
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 527ae7af221c031b4cdf481f097e9062c41af5ac..a19b3c039751da14f044f05fb5ebfa08c051abe4 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
Merge tuinity (#6413) This PR contains all of Tuinity's patches. Very notable ones are: - Highly optimised collisions - Optimised entity lookups by bounding box (Mojang made regressions in 1.17, this brings it back to 1.16) - Starlight https://github.com/PaperMC/Starlight - Rewritten dataconverter system https://github.com/PaperMC/DataConverter - Random block ticking optimisation (wrongly dropped from Paper 1.17) - Chunk ticking optimisations - Anything else I've forgotten in the 60 or so patches If you are a previous Tuinity user, your config will not migrate. You must do it yourself. The config options have simply been moved into paper.yml, so it will be an easy migration. However, please note that the chunk loading options in tuinity.yml are NOT compatible with the options in paper.yml. * Port tuinity, initial patchset * Update gradle to 7.2 jmp said it fixes rebuildpatches not working for me. it fucking better * Completely clean apply * Remove tuinity config, add per player api patch * Remove paper reobf mappings patch * Properly update gradlew * Force clean rebuild * Mark fixups Comments and ATs still need to be done * grep -r "Tuinity" * Fixup * Ensure gameprofile lastaccess is written only under the state lock * update URL for dataconverter * Only clean rebuild tuinity patches might fix merge conflicts * Use UTF-8 for gradlew * Clean rb patches again * Convert block ids used as item ids Neither the converters of pre 1.13 nor DFU handled these cases, as by the time they were written the game at the time didn't consider these ids valid - they would be air. Because of this, some worlds have logspam since only DataConverter (not DFU or legacy converters) will warn when an invalid id has been seen. While quite a few do need to now be considered as air, quite a lot do not. So it makes sense to add conversion for these items, instead of simply suppressing or ignoring the logs. I've now added id -> string conversion for all block ids that could be used as items that existed in the game before 1.7.10 (I have no interest in tracking down the exact version block ids stopped working) that were on https://minecraft-ids.grahamedgecombe.com/ Items that did not directly convert to new items will be instead converted to air: stems, wheat crops, piston head, tripwire wire block * Fix LightPopulated parsing in V1466 The DFU code was checking if the number existed, not if it didn't exist. I misread the original code. * Always parse protochunk light sources unless it is marked as non-lit Chunks not marked as lit will always go through the light engine, so they should always have their block sources parsed. * Update custom names to JSON for players Missed this fix from CB, as it was inside the DataFixers class. I decided to double check all of the CB changes again: DataFixers.java was the only area I missed, as I had inspected all datafixer diffs and implemented them all into DataConverter. I also checked Bootstrap.java again, and re-evaluated their changes. I had previously done this, but determined that they were all bad. The changes to make standing_sign block map to oak_sign block in V1450 is bad, because that's not the item id V1450 accepts. Only in 1.14 did oak_sign even exist, and as expected there is a converter to rename all existing sign items/blocks. The fix to register the portal block under id 1440 is useless, as the flattenning logic will default to the lowest registered id - which is the exact blockstate that CB registers into 1440. So it just doesn't do anything. The extra item ids in the id -> string converter are already added, but I found this from EMC originally. The change for the spawn egg id 23 -> Arrow is just wrong, that id DOES correspond to TippedArrow, NOT Arrow. As expected, the spawn egg already has a dedicated mapping for Arrow, which is id 10 - which was Arrow's entity id. I also ported a fix for the cooked_fished id update. This doesn't really matter since there is already a dataconverter to fix this, but the game didn't accept cooked_fished at the time. So I see no harm. * Review all converters and walkers - Refactor V99 to have helper methods for defining entity/tile entity types - Automatically namespace all ids that should be namespaced. While vanilla never saved non-namespaced data for things that are namespaced, plugins/users might have. - Synchronised the identity ensure map in HelperBlockFlatteningV1450 - Code style consistency - Add missing log warning in V102 for ITEM_NAME type conversion - Use getBoolean instead of getByte - Use ConverterAbstractEntityRename for V143 TippedArrow -> Arrow rename, as it will affect ENTITY_NAME type - Always set isVillager to false in V502 for Zombie - Register V808's converter under subversion 1 like DFU - Register a breakpoint for V1.17.1. In the future, all final versions of major releases will have a breakpoint so that the work required to determine if a converter needs a breakpoint is minimal - Validate that a dataconverter is only registered for a version that is registered - ConverterFlattenTileEntity is actually ConverterFlattenEntity It even registered the converters under TILE_ENTITY, instead of ENTITY. - Fix id comparison in V1492 STRUCTURE_FEATURE renamer - Use ConverterAbstractStatsRename for V1510 stats renamer At the time I had written that class, the abstract renamer didn't exist. - Ensure OwnerUUID is at least set to empty string in V1904 if the ocelot is converted to a cat (this is likely so that it retains a collar) - Use generic read/write for Records in V1946 Records is actually a list, not a map. So reading map was invalid. * Always set light to zero when propagating decrease This fixes an almost infinite loop where light values would be spam queued on a very small subset on blocks. This also likely fixes the memory issues people were seeing. * re-organize patches * Apply and fix conflicts * Revert some patches getChunkAt retains chunks so that plugins don't spam loads revert mc-4 fix will remain unless issues pop up * Shuffle iterated chunks if per player is not enabled Can help with some mob spawning stacking up at locations * Make per player default, migrate all configs * Adjust comments in fixups * Rework config for player chunk loader Old config is not compatible. Move all configs to be under `settings` in paper.yml The player chunk loader has been modified to less aggressively load chunks, but to send chunks at higher rates compared to tuinity. There are new config entries to tune this behavior. * Add back old constructor to CompressionEncoder/Decoder (fixes Tuinity #358) * Raise chunk loading default limits * Reduce worldgen thread workers for lower core count cpus * Raise limits for chunk loading config Also place it under `chunk-loading` * Disable max chunk send rate by default * Fix conflicts and rebuild patches * Drop default send rate again Appears to be still causing problems for no known reason * Raise chunk send limits to 100 per player While a low limit fixes ping issues for some people, most people do not suffer from this issue and thus should not suffer from an extremely slow load-in rate. * Rebase part 1 Autosquash the fixups * Move not implemented up * Fixup mc-dev fixes Missed this one * Rebase per player viewdistance api into the original api patch * Remove old light engine patch part 1 The prioritisation must be kept from it, so that part has been rebased into the priority patch. Part 2 will deal with rebasing all of the patches _after_ * Rebase remaining patches for old light patch removal * Remove other mid tick patch * Remove Optimize-PlayerChunkMap-memory-use-for-visibleChunks.patch Replaced by `Do not copy visible chunks` * Revert AT for Vec3i setX/Y/Z The class is immutable. set should not be exposed * Remove old IntegerUtil class * Replace old CraftChunk#getEntities patch * Remove import for SWMRNibbleArray in ChunkAccess * Finished merge checklist * Remove ensureTickThread impl in urgency patch Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com> Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
2021-08-31 11:02:11 +00:00
@@ -381,6 +381,15 @@ public class ServerLevel extends Level implements WorldGenLevel {
2021-06-11 12:02:28 +00:00
}
// Paper end
+ // Paper start - rewrite ticklistserver
+ public void onChunkSetTicking(int chunkX, int chunkZ) {
2021-06-11 12:02:28 +00:00
+ if (com.destroystokyo.paper.PaperConfig.useOptimizedTickList) {
+ ((com.destroystokyo.paper.server.ticklist.PaperTickList) this.blockTicks).onChunkSetTicking(chunkX, chunkZ);
+ ((com.destroystokyo.paper.server.ticklist.PaperTickList) this.liquidTicks).onChunkSetTicking(chunkX, chunkZ);
+ }
+ }
+ // Paper end - rewrite ticklistserver
+
// Add env and gen to constructor, WorldData -> WorldDataServer
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, ServerLevelData iworlddataserver, ResourceKey<Level> resourcekey, DimensionType dimensionmanager, ChunkProgressListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<CustomSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
2021-06-13 22:05:18 +00:00
// Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error
Merge tuinity (#6413) This PR contains all of Tuinity's patches. Very notable ones are: - Highly optimised collisions - Optimised entity lookups by bounding box (Mojang made regressions in 1.17, this brings it back to 1.16) - Starlight https://github.com/PaperMC/Starlight - Rewritten dataconverter system https://github.com/PaperMC/DataConverter - Random block ticking optimisation (wrongly dropped from Paper 1.17) - Chunk ticking optimisations - Anything else I've forgotten in the 60 or so patches If you are a previous Tuinity user, your config will not migrate. You must do it yourself. The config options have simply been moved into paper.yml, so it will be an easy migration. However, please note that the chunk loading options in tuinity.yml are NOT compatible with the options in paper.yml. * Port tuinity, initial patchset * Update gradle to 7.2 jmp said it fixes rebuildpatches not working for me. it fucking better * Completely clean apply * Remove tuinity config, add per player api patch * Remove paper reobf mappings patch * Properly update gradlew * Force clean rebuild * Mark fixups Comments and ATs still need to be done * grep -r "Tuinity" * Fixup * Ensure gameprofile lastaccess is written only under the state lock * update URL for dataconverter * Only clean rebuild tuinity patches might fix merge conflicts * Use UTF-8 for gradlew * Clean rb patches again * Convert block ids used as item ids Neither the converters of pre 1.13 nor DFU handled these cases, as by the time they were written the game at the time didn't consider these ids valid - they would be air. Because of this, some worlds have logspam since only DataConverter (not DFU or legacy converters) will warn when an invalid id has been seen. While quite a few do need to now be considered as air, quite a lot do not. So it makes sense to add conversion for these items, instead of simply suppressing or ignoring the logs. I've now added id -> string conversion for all block ids that could be used as items that existed in the game before 1.7.10 (I have no interest in tracking down the exact version block ids stopped working) that were on https://minecraft-ids.grahamedgecombe.com/ Items that did not directly convert to new items will be instead converted to air: stems, wheat crops, piston head, tripwire wire block * Fix LightPopulated parsing in V1466 The DFU code was checking if the number existed, not if it didn't exist. I misread the original code. * Always parse protochunk light sources unless it is marked as non-lit Chunks not marked as lit will always go through the light engine, so they should always have their block sources parsed. * Update custom names to JSON for players Missed this fix from CB, as it was inside the DataFixers class. I decided to double check all of the CB changes again: DataFixers.java was the only area I missed, as I had inspected all datafixer diffs and implemented them all into DataConverter. I also checked Bootstrap.java again, and re-evaluated their changes. I had previously done this, but determined that they were all bad. The changes to make standing_sign block map to oak_sign block in V1450 is bad, because that's not the item id V1450 accepts. Only in 1.14 did oak_sign even exist, and as expected there is a converter to rename all existing sign items/blocks. The fix to register the portal block under id 1440 is useless, as the flattenning logic will default to the lowest registered id - which is the exact blockstate that CB registers into 1440. So it just doesn't do anything. The extra item ids in the id -> string converter are already added, but I found this from EMC originally. The change for the spawn egg id 23 -> Arrow is just wrong, that id DOES correspond to TippedArrow, NOT Arrow. As expected, the spawn egg already has a dedicated mapping for Arrow, which is id 10 - which was Arrow's entity id. I also ported a fix for the cooked_fished id update. This doesn't really matter since there is already a dataconverter to fix this, but the game didn't accept cooked_fished at the time. So I see no harm. * Review all converters and walkers - Refactor V99 to have helper methods for defining entity/tile entity types - Automatically namespace all ids that should be namespaced. While vanilla never saved non-namespaced data for things that are namespaced, plugins/users might have. - Synchronised the identity ensure map in HelperBlockFlatteningV1450 - Code style consistency - Add missing log warning in V102 for ITEM_NAME type conversion - Use getBoolean instead of getByte - Use ConverterAbstractEntityRename for V143 TippedArrow -> Arrow rename, as it will affect ENTITY_NAME type - Always set isVillager to false in V502 for Zombie - Register V808's converter under subversion 1 like DFU - Register a breakpoint for V1.17.1. In the future, all final versions of major releases will have a breakpoint so that the work required to determine if a converter needs a breakpoint is minimal - Validate that a dataconverter is only registered for a version that is registered - ConverterFlattenTileEntity is actually ConverterFlattenEntity It even registered the converters under TILE_ENTITY, instead of ENTITY. - Fix id comparison in V1492 STRUCTURE_FEATURE renamer - Use ConverterAbstractStatsRename for V1510 stats renamer At the time I had written that class, the abstract renamer didn't exist. - Ensure OwnerUUID is at least set to empty string in V1904 if the ocelot is converted to a cat (this is likely so that it retains a collar) - Use generic read/write for Records in V1946 Records is actually a list, not a map. So reading map was invalid. * Always set light to zero when propagating decrease This fixes an almost infinite loop where light values would be spam queued on a very small subset on blocks. This also likely fixes the memory issues people were seeing. * re-organize patches * Apply and fix conflicts * Revert some patches getChunkAt retains chunks so that plugins don't spam loads revert mc-4 fix will remain unless issues pop up * Shuffle iterated chunks if per player is not enabled Can help with some mob spawning stacking up at locations * Make per player default, migrate all configs * Adjust comments in fixups * Rework config for player chunk loader Old config is not compatible. Move all configs to be under `settings` in paper.yml The player chunk loader has been modified to less aggressively load chunks, but to send chunks at higher rates compared to tuinity. There are new config entries to tune this behavior. * Add back old constructor to CompressionEncoder/Decoder (fixes Tuinity #358) * Raise chunk loading default limits * Reduce worldgen thread workers for lower core count cpus * Raise limits for chunk loading config Also place it under `chunk-loading` * Disable max chunk send rate by default * Fix conflicts and rebuild patches * Drop default send rate again Appears to be still causing problems for no known reason * Raise chunk send limits to 100 per player While a low limit fixes ping issues for some people, most people do not suffer from this issue and thus should not suffer from an extremely slow load-in rate. * Rebase part 1 Autosquash the fixups * Move not implemented up * Fixup mc-dev fixes Missed this one * Rebase per player viewdistance api into the original api patch * Remove old light engine patch part 1 The prioritisation must be kept from it, so that part has been rebased into the priority patch. Part 2 will deal with rebasing all of the patches _after_ * Rebase remaining patches for old light patch removal * Remove other mid tick patch * Remove Optimize-PlayerChunkMap-memory-use-for-visibleChunks.patch Replaced by `Do not copy visible chunks` * Revert AT for Vec3i setX/Y/Z The class is immutable. set should not be exposed * Remove old IntegerUtil class * Replace old CraftChunk#getEntities patch * Remove import for SWMRNibbleArray in ChunkAccess * Finished merge checklist * Remove ensureTickThread impl in urgency patch Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com> Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
2021-08-31 11:02:11 +00:00
@@ -397,13 +406,19 @@ public class ServerLevel extends Level implements WorldGenLevel {
2021-06-13 22:05:18 +00:00
DefaultedRegistry registryblocks = Registry.BLOCK;
Objects.requireNonNull(registryblocks);
- this.blockTicks = new ServerTickList<>(this, predicate, Registry.BLOCK::getKey, this::tickBlock, "Blocks"); // CraftBukkit - decompile error // Paper - Timings
+ // this.blockTicks = new ServerTickList<>(this, predicate, Registry.BLOCK::getKey, this::tickBlock, "Blocks"); // CraftBukkit - decompile error // Paper - Timings // Paper - copied down
Predicate<Fluid> predicate2 = (fluidtype) -> { // CraftBukkit - decompile error
return fluidtype == null || fluidtype == Fluids.EMPTY;
};
registryblocks = Registry.FLUID;
Objects.requireNonNull(registryblocks);
2021-06-11 12:02:28 +00:00
+ if (com.destroystokyo.paper.PaperConfig.useOptimizedTickList) {
2021-06-13 22:05:18 +00:00
+ this.blockTicks = new com.destroystokyo.paper.server.ticklist.PaperTickList<>(this, predicate, Registry.BLOCK::getKey, this::tickBlock, "Blocks"); // Paper - Timings
+ this.liquidTicks = new com.destroystokyo.paper.server.ticklist.PaperTickList<>(this, predicate2, Registry.FLUID::getKey, this::tickLiquid, "Fluids"); // Paper timings
2021-06-11 12:02:28 +00:00
+ } else {
2021-06-13 22:05:18 +00:00
+ this.blockTicks = new ServerTickList<>(this, predicate, Registry.BLOCK::getKey, this::tickBlock, "Blocks"); // CraftBukkit - decompile error // Paper - Timings & copied from above
this.liquidTicks = new ServerTickList<>(this, predicate2, Registry.FLUID::getKey, this::tickLiquid, "Fluids"); // CraftBukkit - decompile error // Paper - Timings
2021-06-11 12:02:28 +00:00
+ }
2021-06-13 22:05:18 +00:00
this.navigatingMobs = new ObjectOpenHashSet();
2021-06-11 12:02:28 +00:00
this.blockEvents = new ObjectLinkedOpenHashSet();
2021-06-13 22:05:18 +00:00
this.dragonParts = new Int2ObjectOpenHashMap();
Merge tuinity (#6413) This PR contains all of Tuinity's patches. Very notable ones are: - Highly optimised collisions - Optimised entity lookups by bounding box (Mojang made regressions in 1.17, this brings it back to 1.16) - Starlight https://github.com/PaperMC/Starlight - Rewritten dataconverter system https://github.com/PaperMC/DataConverter - Random block ticking optimisation (wrongly dropped from Paper 1.17) - Chunk ticking optimisations - Anything else I've forgotten in the 60 or so patches If you are a previous Tuinity user, your config will not migrate. You must do it yourself. The config options have simply been moved into paper.yml, so it will be an easy migration. However, please note that the chunk loading options in tuinity.yml are NOT compatible with the options in paper.yml. * Port tuinity, initial patchset * Update gradle to 7.2 jmp said it fixes rebuildpatches not working for me. it fucking better * Completely clean apply * Remove tuinity config, add per player api patch * Remove paper reobf mappings patch * Properly update gradlew * Force clean rebuild * Mark fixups Comments and ATs still need to be done * grep -r "Tuinity" * Fixup * Ensure gameprofile lastaccess is written only under the state lock * update URL for dataconverter * Only clean rebuild tuinity patches might fix merge conflicts * Use UTF-8 for gradlew * Clean rb patches again * Convert block ids used as item ids Neither the converters of pre 1.13 nor DFU handled these cases, as by the time they were written the game at the time didn't consider these ids valid - they would be air. Because of this, some worlds have logspam since only DataConverter (not DFU or legacy converters) will warn when an invalid id has been seen. While quite a few do need to now be considered as air, quite a lot do not. So it makes sense to add conversion for these items, instead of simply suppressing or ignoring the logs. I've now added id -> string conversion for all block ids that could be used as items that existed in the game before 1.7.10 (I have no interest in tracking down the exact version block ids stopped working) that were on https://minecraft-ids.grahamedgecombe.com/ Items that did not directly convert to new items will be instead converted to air: stems, wheat crops, piston head, tripwire wire block * Fix LightPopulated parsing in V1466 The DFU code was checking if the number existed, not if it didn't exist. I misread the original code. * Always parse protochunk light sources unless it is marked as non-lit Chunks not marked as lit will always go through the light engine, so they should always have their block sources parsed. * Update custom names to JSON for players Missed this fix from CB, as it was inside the DataFixers class. I decided to double check all of the CB changes again: DataFixers.java was the only area I missed, as I had inspected all datafixer diffs and implemented them all into DataConverter. I also checked Bootstrap.java again, and re-evaluated their changes. I had previously done this, but determined that they were all bad. The changes to make standing_sign block map to oak_sign block in V1450 is bad, because that's not the item id V1450 accepts. Only in 1.14 did oak_sign even exist, and as expected there is a converter to rename all existing sign items/blocks. The fix to register the portal block under id 1440 is useless, as the flattenning logic will default to the lowest registered id - which is the exact blockstate that CB registers into 1440. So it just doesn't do anything. The extra item ids in the id -> string converter are already added, but I found this from EMC originally. The change for the spawn egg id 23 -> Arrow is just wrong, that id DOES correspond to TippedArrow, NOT Arrow. As expected, the spawn egg already has a dedicated mapping for Arrow, which is id 10 - which was Arrow's entity id. I also ported a fix for the cooked_fished id update. This doesn't really matter since there is already a dataconverter to fix this, but the game didn't accept cooked_fished at the time. So I see no harm. * Review all converters and walkers - Refactor V99 to have helper methods for defining entity/tile entity types - Automatically namespace all ids that should be namespaced. While vanilla never saved non-namespaced data for things that are namespaced, plugins/users might have. - Synchronised the identity ensure map in HelperBlockFlatteningV1450 - Code style consistency - Add missing log warning in V102 for ITEM_NAME type conversion - Use getBoolean instead of getByte - Use ConverterAbstractEntityRename for V143 TippedArrow -> Arrow rename, as it will affect ENTITY_NAME type - Always set isVillager to false in V502 for Zombie - Register V808's converter under subversion 1 like DFU - Register a breakpoint for V1.17.1. In the future, all final versions of major releases will have a breakpoint so that the work required to determine if a converter needs a breakpoint is minimal - Validate that a dataconverter is only registered for a version that is registered - ConverterFlattenTileEntity is actually ConverterFlattenEntity It even registered the converters under TILE_ENTITY, instead of ENTITY. - Fix id comparison in V1492 STRUCTURE_FEATURE renamer - Use ConverterAbstractStatsRename for V1510 stats renamer At the time I had written that class, the abstract renamer didn't exist. - Ensure OwnerUUID is at least set to empty string in V1904 if the ocelot is converted to a cat (this is likely so that it retains a collar) - Use generic read/write for Records in V1946 Records is actually a list, not a map. So reading map was invalid. * Always set light to zero when propagating decrease This fixes an almost infinite loop where light values would be spam queued on a very small subset on blocks. This also likely fixes the memory issues people were seeing. * re-organize patches * Apply and fix conflicts * Revert some patches getChunkAt retains chunks so that plugins don't spam loads revert mc-4 fix will remain unless issues pop up * Shuffle iterated chunks if per player is not enabled Can help with some mob spawning stacking up at locations * Make per player default, migrate all configs * Adjust comments in fixups * Rework config for player chunk loader Old config is not compatible. Move all configs to be under `settings` in paper.yml The player chunk loader has been modified to less aggressively load chunks, but to send chunks at higher rates compared to tuinity. There are new config entries to tune this behavior. * Add back old constructor to CompressionEncoder/Decoder (fixes Tuinity #358) * Raise chunk loading default limits * Reduce worldgen thread workers for lower core count cpus * Raise limits for chunk loading config Also place it under `chunk-loading` * Disable max chunk send rate by default * Fix conflicts and rebuild patches * Drop default send rate again Appears to be still causing problems for no known reason * Raise chunk send limits to 100 per player While a low limit fixes ping issues for some people, most people do not suffer from this issue and thus should not suffer from an extremely slow load-in rate. * Rebase part 1 Autosquash the fixups * Move not implemented up * Fixup mc-dev fixes Missed this one * Rebase per player viewdistance api into the original api patch * Remove old light engine patch part 1 The prioritisation must be kept from it, so that part has been rebased into the priority patch. Part 2 will deal with rebasing all of the patches _after_ * Rebase remaining patches for old light patch removal * Remove other mid tick patch * Remove Optimize-PlayerChunkMap-memory-use-for-visibleChunks.patch Replaced by `Do not copy visible chunks` * Revert AT for Vec3i setX/Y/Z The class is immutable. set should not be exposed * Remove old IntegerUtil class * Replace old CraftChunk#getEntities patch * Remove import for SWMRNibbleArray in ChunkAccess * Finished merge checklist * Remove ensureTickThread impl in urgency patch Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com> Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
2021-08-31 11:02:11 +00:00
@@ -689,7 +704,9 @@ public class ServerLevel extends Level implements WorldGenLevel {
2021-06-11 12:02:28 +00:00
if (this.tickTime) {
long i = this.levelData.getGameTime() + 1L;
2021-06-13 22:05:18 +00:00
- this.serverLevelData.setGameTime(i);
+ this.serverLevelData.setGameTime(i); ; // Paper - diff on change, we want the below to be ran right after this
2021-06-11 12:02:28 +00:00
+ this.blockTicks.nextTick(); // Paper
+ this.liquidTicks.nextTick(); // Paper
2021-06-13 22:05:18 +00:00
this.serverLevelData.getScheduledEvents().tick(this.server, i);
2021-06-11 12:02:28 +00:00
if (this.levelData.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
this.setDayTime(this.levelData.getDayTime() + 1L);
diff --git a/src/main/java/net/minecraft/world/level/ChunkTickList.java b/src/main/java/net/minecraft/world/level/ChunkTickList.java
2021-06-13 22:05:18 +00:00
index 1a05edf041cf4aeee7c165fec564ce45adbdd5c7..febc837d324cbe2cd83aea6c1e0d298c70f45f78 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/level/ChunkTickList.java
+++ b/src/main/java/net/minecraft/world/level/ChunkTickList.java
2021-06-13 22:05:18 +00:00
@@ -15,7 +15,7 @@ public class ChunkTickList<T> implements TickList<T> {
2021-06-11 12:02:28 +00:00
2021-06-13 22:05:18 +00:00
public ChunkTickList(Function<T, ResourceLocation> identifierProvider, List<TickNextTickData<T>> scheduledTicks, long startTime) {
this(identifierProvider, scheduledTicks.stream().map((tickNextTickData) -> {
- return new ChunkTickList.ScheduledTick(tickNextTickData.getType(), tickNextTickData.pos, (int)(tickNextTickData.triggerTick - startTime), tickNextTickData.priority);
+ return new ChunkTickList.ScheduledTick<>(tickNextTickData.getType(), tickNextTickData.pos, (int)(tickNextTickData.triggerTick - startTime), tickNextTickData.priority); // Paper - decompile error
}).collect(Collectors.toList()));
}
2021-06-11 12:02:28 +00:00
2021-06-13 22:05:18 +00:00
@@ -56,6 +56,7 @@ public class ChunkTickList<T> implements TickList<T> {
return listTag;
2021-06-11 12:02:28 +00:00
}
+ private static final int MAX_TICK_DELAY = Integer.getInteger("paper.ticklist-max-tick-delay", -1).intValue(); // Paper - clean up broken entries
2021-06-13 22:05:18 +00:00
public static <T> ChunkTickList<T> create(ListTag ticks, Function<T, ResourceLocation> function, Function<ResourceLocation, T> function2) {
2021-06-11 12:02:28 +00:00
List<ChunkTickList.ScheduledTick<T>> list = Lists.newArrayList();
2021-06-13 22:05:18 +00:00
@@ -64,7 +65,14 @@ public class ChunkTickList<T> implements TickList<T> {
T object = function2.apply(new ResourceLocation(compoundTag.getString("i")));
if (object != null) {
BlockPos blockPos = new BlockPos(compoundTag.getInt("x"), compoundTag.getInt("y"), compoundTag.getInt("z"));
- list.add(new ChunkTickList.ScheduledTick<>(object, blockPos, compoundTag.getInt("t"), TickPriority.byValue(compoundTag.getInt("p"))));
2021-06-11 12:02:28 +00:00
+ // Paper start - clean up broken entries
2021-06-13 22:05:18 +00:00
+ int delay = compoundTag.getInt("t");
2021-06-11 12:02:28 +00:00
+ if (MAX_TICK_DELAY > 0 && delay > MAX_TICK_DELAY) {
2021-06-13 22:05:18 +00:00
+ net.minecraft.server.MinecraftServer.LOGGER.warn("Dropping tick for pos " + blockPos + ", tick delay " + delay);
2021-06-11 12:02:28 +00:00
+ continue;
+ }
+ // Paper end - clean up broken entries
2021-06-13 22:05:18 +00:00
+ list.add(new ChunkTickList.ScheduledTick<>(object, blockPos, delay, TickPriority.byValue(compoundTag.getInt("p"))));
2021-06-11 12:02:28 +00:00
}
}
diff --git a/src/main/java/net/minecraft/world/level/ServerTickList.java b/src/main/java/net/minecraft/world/level/ServerTickList.java
2021-10-03 01:42:30 +00:00
index dfd41db804acde50339de9b18566b845401d7cbe..0f61dd3a3115f68ccd2c7cb4c9309f5ace96a406 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/level/ServerTickList.java
+++ b/src/main/java/net/minecraft/world/level/ServerTickList.java
@@ -51,6 +51,9 @@ public class ServerTickList<T> implements TickList<T> {
this.ticker = tickConsumer;
}
2021-06-11 12:02:28 +00:00
+ // Paper start
+ public void nextTick() {}
+ // Paper end
public void tick() {
int i = this.tickNextTickList.size();
diff --git a/src/main/java/net/minecraft/world/level/TickNextTickData.java b/src/main/java/net/minecraft/world/level/TickNextTickData.java
2021-06-17 19:52:26 +00:00
index 3b8c04f6ffd7e6c197465aa1caf633ba92529472..1007bfc9c19641f42afd5526cfe7bdb61906d1a0 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/level/TickNextTickData.java
+++ b/src/main/java/net/minecraft/world/level/TickNextTickData.java
2021-06-13 22:05:18 +00:00
@@ -9,7 +9,9 @@ public class TickNextTickData<T> {
public final BlockPos pos;
public final long triggerTick;
public final TickPriority priority;
2021-06-11 12:02:28 +00:00
- private final long c;
2021-06-17 19:52:26 +00:00
+ private final long c; @Deprecated public final long getId() { return this.c; } // Paper - OBFHELPER
2021-06-11 12:02:28 +00:00
+ private final int hash; // Paper
+ public int tickState; // Paper
public TickNextTickData(BlockPos pos, T t) {
this(pos, t, 0L, TickPriority.NORMAL);
2021-06-13 22:05:18 +00:00
@@ -21,6 +23,7 @@ public class TickNextTickData<T> {
2021-06-11 12:02:28 +00:00
this.type = t;
this.triggerTick = time;
this.priority = priority;
+ this.hash = this.computeHash(); // Paper
}
2021-06-13 22:05:18 +00:00
@Override
@@ -35,17 +38,27 @@ public class TickNextTickData<T> {
2021-06-11 12:02:28 +00:00
2021-06-13 22:05:18 +00:00
@Override
2021-06-11 12:02:28 +00:00
public int hashCode() {
2021-06-13 22:05:18 +00:00
+ // Paper start - optimize hashcode
2021-06-11 12:02:28 +00:00
+ return this.hash;
+ }
+ public final int computeHash() {
+ // Paper end - optimize hashcode
return this.pos.hashCode();
}
2021-06-13 22:05:18 +00:00
public static <T> Comparator<TickNextTickData<T>> createTimeComparator() {
- return Comparator.<TickNextTickData<T>>comparingLong((tickNextTickData) -> { // Paper - decompile fix
- return tickNextTickData.triggerTick;
- }).thenComparing((tickNextTickData) -> {
- return tickNextTickData.priority;
- }).thenComparingLong((tickNextTickData) -> {
- return tickNextTickData.c;
2021-06-11 12:02:28 +00:00
- });
2021-06-13 22:05:18 +00:00
+ // Paper start - let's not use more functional code for no reason.
+ return (Comparator) (Comparator<TickNextTickData>) (TickNextTickData nextticklistentry, TickNextTickData nextticklistentry1) -> {
+ int i = Long.compare(nextticklistentry.triggerTick, nextticklistentry1.triggerTick);
2021-06-11 12:02:28 +00:00
+
+ if (i != 0) {
+ return i;
+ } else {
2021-06-13 22:05:18 +00:00
+ i = nextticklistentry.priority.compareTo(nextticklistentry1.priority);
2021-06-11 12:02:28 +00:00
+ return i != 0 ? i : Long.compare(nextticklistentry.getId(), nextticklistentry1.getId());
+ }
+ };
2021-06-13 22:05:18 +00:00
+ // Paper end - let's not use more functional code for no reason.
2021-06-11 12:02:28 +00:00
}
2021-06-13 22:05:18 +00:00
@Override
diff --git a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
index f698723f8f7feecc749df10a316118184391f31a..be65a8a5a853d4e014d44730a48ccf247acf08d2 100644
--- a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
+++ b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
@@ -308,6 +308,12 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
List<Entity> entities = this.getEntities(chunkentities.getPos()); // PAIL rename getChunkPos
CraftEventFactory.callEntitiesLoadEvent(((EntityStorage) this.permanentStorage).level, chunkentities.getPos(), entities);
// CraftBukkit end
+ // Paper start - rewrite ServerTickList
+ final net.minecraft.server.level.ServerLevel level = ((net.minecraft.world.level.chunk.storage.EntityStorage) this.permanentStorage).level;
+ if (level.chunkSource.isPositionTickingReady(chunkentities.getPos().longKey)) {
+ level.onChunkSetTicking(chunkentities.getPos().x, chunkentities.getPos().z);
+ }
+ // Paper end
}
}