Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
c5a10665b8
Spigot still maintains some partial implementation of "tick skipping", a practice in which the MinecraftServer.currentTick field is updated not by an increment of one per actual tick, but instead set to System.currentTimeMillis() / 50. This behaviour means that the tracked tick may "skip" a tick value in case a previous tick took more than the expected 50ms. To compensate for this in important paths, spigot/craftbukkit implements "wall-time". Instead of incrementing/decrementing ticks on block entities/entities by one for each call to their tick() method, they instead increment/decrement important values, like an ItemEntity's age or pickupDelay, by the difference of `currentTick - lastTick`, where `lastTick` is the value of `currentTick` during the last tick() call. These "fixes" however do not play nicely with minecraft's simulation distance as entities/block entities implementing the above behaviour would "catch up" their values when moving from a non-ticking chunk to a ticking one as their `lastTick` value remains stuck on the last tick in a ticking chunk and hence lead to a large "catch up" once ticked again. Paper completely removes the "tick skipping" behaviour (See patch "Further-improve-server-tick-loop"), making the above precautions completely unnecessary, which also rids paper of the previous described incompatibility with non-ticking chunks.
62 Zeilen
3.0 KiB
Diff
62 Zeilen
3.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Flo0 <flo.roma@web.de>
|
|
Date: Mon, 8 Apr 2024 16:43:16 +0200
|
|
Subject: [PATCH] API for checking sent chunks
|
|
|
|
|
|
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java
|
|
index 852d75a73dae7448cbe1e2f5e164b235efa8a969..a608f57ebca98eda88ad749d0aad021678be54f9 100644
|
|
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java
|
|
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java
|
|
@@ -1078,5 +1078,10 @@ public final class RegionizedPlayerChunkLoader {
|
|
|
|
// now all tickets should be removed, which is all of our external state
|
|
}
|
|
+
|
|
+ // For external checks
|
|
+ public it.unimi.dsi.fastutil.longs.LongOpenHashSet getSentChunksRaw() {
|
|
+ return this.sentChunks;
|
|
+ }
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index e02fa642f11809607e30e22b51c65373edd70842..ad740739437be632fc7fedec488a7d0c49534688 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -3483,6 +3483,35 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
}
|
|
// Paper end
|
|
|
|
+ // Paper start - Add chunk view API
|
|
+ @Override
|
|
+ public Set<java.lang.Long> getSentChunkKeys() {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks");
|
|
+ return it.unimi.dsi.fastutil.longs.LongSets.unmodifiable(
|
|
+ this.getHandle().moonrise$getChunkLoader().getSentChunksRaw().clone()
|
|
+ );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Set<org.bukkit.Chunk> getSentChunks() {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks");
|
|
+ final it.unimi.dsi.fastutil.longs.LongOpenHashSet rawChunkKeys = this.getHandle().moonrise$getChunkLoader().getSentChunksRaw();
|
|
+ final it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<org.bukkit.Chunk> chunks = new it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<>(rawChunkKeys.size());
|
|
+ final org.bukkit.World world = this.getWorld();
|
|
+
|
|
+ final it.unimi.dsi.fastutil.longs.LongIterator iter = this.getHandle().moonrise$getChunkLoader().getSentChunksRaw().longIterator();
|
|
+ while (iter.hasNext()) chunks.add(world.getChunkAt(iter.nextLong(), false));
|
|
+
|
|
+ return it.unimi.dsi.fastutil.objects.ObjectSets.unmodifiable(chunks);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isChunkSent(final long chunkKey) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks");
|
|
+ return this.getHandle().moonrise$getChunkLoader().getSentChunksRaw().contains(chunkKey);
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public Player.Spigot spigot()
|
|
{
|
|
return this.spigot;
|