Rebase on latest

This commit is contained in:
Spottedleaf 2024-12-20 09:36:39 -08:00
parent 45c905b928
commit 3af380ba08
6 changed files with 138 additions and 123 deletions

View file

@ -22768,7 +22768,7 @@ index 0000000000000000000000000000000000000000..689ce367164e79e0426eeecb81dbbc52
+ private SaveUtil() {}
+}
diff --git a/io/papermc/paper/FeatureHooks.java b/io/papermc/paper/FeatureHooks.java
index 764daee7cd619c56314bcea9a4c35702afcb262d..e54355728183c594643f2e28ba2e92b1502882ac 100644
index d3aebc7f833764351c8e5fe1fad1aa2f8718ca37..046a6304ea7e9dd66cb9d4cb004a582f13018295 100644
--- a/io/papermc/paper/FeatureHooks.java
+++ b/io/papermc/paper/FeatureHooks.java
@@ -1,6 +1,8 @@
@ -22780,7 +22780,7 @@ index 764daee7cd619c56314bcea9a4c35702afcb262d..e54355728183c594643f2e28ba2e92b1
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongSet;
import it.unimi.dsi.fastutil.longs.LongSets;
@@ -30,9 +32,12 @@ import org.bukkit.World;
@@ -31,9 +33,12 @@ import org.bukkit.World;
public final class FeatureHooks {
public static void initChunkTaskScheduler(final boolean useParallelGen) {
@ -23356,7 +23356,7 @@ index 47b1fafd91b39e73c4e9134b0b8048000fba108a..76994c1491221c06cca5405ba239e6ff
}
}
diff --git a/net/minecraft/server/Main.java b/net/minecraft/server/Main.java
index 4437283a5d157eede121b98be0112c1067eded5e..e627618f2368258d7cb9cd35908d0f42a9c504f5 100644
index 47c62090b421ebea1253ee3f1c896ed84119cea6..e738405e5112584e02e01df2d5ede2676fa1bffb 100644
--- a/net/minecraft/server/Main.java
+++ b/net/minecraft/server/Main.java
@@ -320,6 +320,7 @@ public class Main {
@ -23368,7 +23368,7 @@ index 4437283a5d157eede121b98be0112c1067eded5e..e627618f2368258d7cb9cd35908d0f42
thread1 -> {
DedicatedServer dedicatedServer1 = new DedicatedServer(
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..b4dcb4178b49af49cf6e654788efda3dd10c767e 100644
index 5649482a8b85056bc009b868e19ca11f21d59fbf..0c35921acebd88f3a9a37676e47e7482dfea6d9c 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -173,7 +173,7 @@ import net.minecraft.world.phys.Vec2;
@ -23380,7 +23380,7 @@ index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..b4dcb4178b49af49cf6e654788efda3d
private static MinecraftServer SERVER; // Paper
public static final Logger LOGGER = LogUtils.getLogger();
public static final net.kyori.adventure.text.logger.slf4j.ComponentLogger COMPONENT_LOGGER = net.kyori.adventure.text.logger.slf4j.ComponentLogger.logger(LOGGER.getName()); // Paper
@@ -316,6 +316,77 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -318,6 +318,77 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
return minecraftServer;
}
@ -23458,7 +23458,7 @@ index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..b4dcb4178b49af49cf6e654788efda3d
public MinecraftServer(
// CraftBukkit start
joptsimple.OptionSet options,
@@ -626,7 +697,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -628,7 +699,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.forceDifficulty();
for (ServerLevel serverLevel : this.getAllLevels()) {
this.prepareLevels(serverLevel.getChunkSource().chunkMap.progressListener, serverLevel);
@ -23467,7 +23467,7 @@ index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..b4dcb4178b49af49cf6e654788efda3d
this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(serverLevel.getWorld()));
}
@@ -825,6 +896,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -827,6 +898,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
public abstract boolean shouldRconBroadcast();
public boolean saveAllChunks(boolean suppressLog, boolean flush, boolean forced) {
@ -23479,7 +23479,7 @@ index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..b4dcb4178b49af49cf6e654788efda3d
boolean flag = false;
for (ServerLevel serverLevel : this.getAllLevels()) {
@@ -832,7 +908,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -834,7 +910,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
LOGGER.info("Saving chunks for level '{}'/{}", serverLevel, serverLevel.dimension().location());
}
@ -23488,7 +23488,7 @@ index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..b4dcb4178b49af49cf6e654788efda3d
flag = true;
}
@@ -923,7 +999,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -925,7 +1001,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
}
@ -23497,7 +23497,7 @@ index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..b4dcb4178b49af49cf6e654788efda3d
this.nextTickTimeNanos = Util.getNanos() + TimeUtil.NANOSECONDS_PER_MILLISECOND;
for (ServerLevel serverLevelx : this.getAllLevels()) {
@@ -934,17 +1010,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -936,17 +1012,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.waitUntilNextTick();
}
@ -23516,7 +23516,7 @@ index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..b4dcb4178b49af49cf6e654788efda3d
this.isSaving = false;
this.resources.close();
@@ -963,6 +1029,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -966,6 +1032,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.getProfileCache().save(false); // Paper - Perf: Async GameProfileCache saving
}
// Spigot end
@ -23531,7 +23531,7 @@ index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..b4dcb4178b49af49cf6e654788efda3d
}
public String getLocalIp() {
@@ -1133,6 +1207,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1130,6 +1204,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
profilerFiller.push("tick");
this.tickFrame.start();
this.tickServer(flag ? () -> false : this::haveTime);
@ -23545,7 +23545,7 @@ index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..b4dcb4178b49af49cf6e654788efda3d
this.tickFrame.end();
profilerFiller.popPush("nextTickWait");
this.mayHaveDelayedTasks = true;
@@ -1305,6 +1386,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1302,6 +1383,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
private boolean pollTaskInternal() {
if (super.pollTask()) {
@ -23553,7 +23553,7 @@ index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..b4dcb4178b49af49cf6e654788efda3d
return true;
} else {
boolean ret = false; // Paper - force execution of all worlds, do not just bias the first
@@ -2425,6 +2507,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -2422,6 +2504,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
}
@ -23567,10 +23567,10 @@ index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..b4dcb4178b49af49cf6e654788efda3d
// CraftBukkit start
public boolean isDebugging() {
diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
index 1ad96b964cdcf10b9f81d32d07e03c1a0ab6fe0a..ab356d1afb352f1f134d25dfa17ce5476a2039cd 100644
index 72409db938babd2da64a20746911cb8d45452d7f..fbc9b4d99bd1913a243a8d0424eb6f165e535747 100644
--- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -432,7 +432,33 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@@ -433,7 +433,33 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
return level.dimension() != Level.NETHER || this.getProperties().allowNether;
}
@ -23605,7 +23605,7 @@ index 1ad96b964cdcf10b9f81d32d07e03c1a0ab6fe0a..ab356d1afb352f1f134d25dfa17ce547
}
diff --git a/net/minecraft/server/level/ChunkHolder.java b/net/minecraft/server/level/ChunkHolder.java
index cc63e49b7d1b4ba6e8df87aff4cf71036d3de5c5..a37cc96ec26c92a60b0f0ca43d48705cd2bb072e 100644
index b95de132c53f82d270de396787dda3be8bc6c910..656041c9539b6834b4d37b353eb6b810a7763ff4 100644
--- a/net/minecraft/server/level/ChunkHolder.java
+++ b/net/minecraft/server/level/ChunkHolder.java
@@ -29,27 +29,112 @@ import net.minecraft.world.level.chunk.LevelChunkSection;
@ -23775,7 +23775,7 @@ index cc63e49b7d1b4ba6e8df87aff4cf71036d3de5c5..a37cc96ec26c92a60b0f0ca43d48705c
}
@Nullable
public LevelChunk getTickingChunk() {
public final LevelChunk getTickingChunk() { // Paper - final for inline
- return this.getTickingChunkFuture().getNow(UNLOADED_LEVEL_CHUNK).orElse(null);
+ // Paper start - rewrite chunk system
+ if (this.newChunkHolder.isTickingReady()) {
@ -24086,7 +24086,7 @@ index e823b8aac00158892538083bc877ccf99895909a..7d871318065f19540748363809de8265
private static final ChunkStep FULL_CHUNK_STEP = ChunkPyramid.GENERATION_PYRAMID.getStepTo(ChunkStatus.FULL);
public static final int RADIUS_AROUND_FULL_CHUNK = FULL_CHUNK_STEP.accumulatedDependencies().getRadius();
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
index 8c1eea5339b650bd1527b5b3aa010c12d70a6de1..86aaf32de5d80ee222cbe7eff0f6c119a032e04f 100644
index ad665c7535c615d2b03a3e7864be435f933235dd..9faf0ece0f074b8709b4e4fad0cab3e9c2224276 100644
--- a/net/minecraft/server/level/ChunkMap.java
+++ b/net/minecraft/server/level/ChunkMap.java
@@ -96,7 +96,7 @@ import net.minecraft.world.level.storage.LevelStorageSource;
@ -24745,7 +24745,7 @@ index 8c1eea5339b650bd1527b5b3aa010c12d70a6de1..86aaf32de5d80ee222cbe7eff0f6c119
+ throw new UnsupportedOperationException(); // Paper - rewrite chunk system
}
public void setServerViewDistance(int viewDistance) { // Paper - publi
public void setServerViewDistance(int viewDistance) {
- int i = Mth.clamp(viewDistance, 2, 32);
- if (i != this.serverViewDistance) {
- this.serverViewDistance = i;
@ -25253,7 +25253,7 @@ index 8c1eea5339b650bd1527b5b3aa010c12d70a6de1..86aaf32de5d80ee222cbe7eff0f6c119
public void updatePlayers(List<ServerPlayer> playersList) {
diff --git a/net/minecraft/server/level/DistanceManager.java b/net/minecraft/server/level/DistanceManager.java
index e50e96861c0aefdb0a79674b7790798f2571010e..73599e8adbee0957c1318ee6688e49b9873d2411 100644
index 8ec20e372570d5eb720cdcdaed9c92946033be9b..5eab6179ce3913cb4e4d424f910ba423faf21c85 100644
--- a/net/minecraft/server/level/DistanceManager.java
+++ b/net/minecraft/server/level/DistanceManager.java
@@ -34,56 +34,56 @@ import net.minecraft.world.level.ChunkPos;
@ -25349,7 +25349,7 @@ index e50e96861c0aefdb0a79674b7790798f2571010e..73599e8adbee0957c1318ee6688e49b9
private static int getTicketLevelAt(SortedArraySet<Ticket<?>> tickets) {
return !tickets.isEmpty() ? tickets.first().getTicketLevel() : ChunkLevel.MAX_LEVEL + 1;
@@ -98,81 +98,15 @@ public abstract class DistanceManager {
@@ -98,77 +98,15 @@ public abstract class DistanceManager {
protected abstract ChunkHolder updateChunkScheduling(long chunkPos, int i, @Nullable ChunkHolder newLevel, int holder);
public boolean runAllUpdates(ChunkMap chunkMap) {
@ -25405,7 +25405,7 @@ index e50e96861c0aefdb0a79674b7790798f2571010e..73599e8adbee0957c1318ee6688e49b9
+ return this.moonrise$getChunkHolderManager().processTicketUpdates(); // Paper - rewrite chunk system
}
boolean addTicket(long chunkPos, Ticket<?> ticket) { // CraftBukkit - void -> boolean
void addTicket(long chunkPos, Ticket<?> ticket) {
- SortedArraySet<Ticket<?>> tickets = this.getTickets(chunkPos);
- int ticketLevelAt = getTicketLevelAt(tickets);
- Ticket<?> ticket1 = tickets.addOrGet(ticket);
@ -25413,15 +25413,12 @@ index e50e96861c0aefdb0a79674b7790798f2571010e..73599e8adbee0957c1318ee6688e49b9
- if (ticket.getTicketLevel() < ticketLevelAt) {
- this.ticketTracker.update(chunkPos, ticket.getTicketLevel(), true);
- }
- return ticket == ticket1; // CraftBukkit
+ return this.moonrise$getChunkHolderManager().addTicketAtLevel((TicketType)ticket.getType(), chunkPos, ticket.getTicketLevel(), ticket.key); // Paper - rewrite chunk system
+ this.moonrise$getChunkHolderManager().addTicketAtLevel((TicketType)ticket.getType(), chunkPos, ticket.getTicketLevel(), ticket.key); // Paper - rewrite chunk system
}
boolean removeTicket(long chunkPos, Ticket<?> ticket) { // CraftBukkit - void -> boolean
void removeTicket(long chunkPos, Ticket<?> ticket) {
- SortedArraySet<Ticket<?>> tickets = this.getTickets(chunkPos);
- boolean removed = false; // CraftBukkit
- if (tickets.remove(ticket)) {
- removed = true; // CraftBukkit
- }
-
- if (tickets.isEmpty()) {
@ -25429,38 +25426,57 @@ index e50e96861c0aefdb0a79674b7790798f2571010e..73599e8adbee0957c1318ee6688e49b9
- }
-
- this.ticketTracker.update(chunkPos, getTicketLevelAt(tickets), false);
- return removed; // CraftBukkit
+ return this.moonrise$getChunkHolderManager().removeTicketAtLevel((TicketType)ticket.getType(), chunkPos, ticket.getTicketLevel(), ticket.key); // Paper - rewrite chunk system
+ this.moonrise$getChunkHolderManager().removeTicketAtLevel((TicketType)ticket.getType(), chunkPos, ticket.getTicketLevel(), ticket.key); // Paper - rewrite chunk system
}
public <T> void addTicket(TicketType<T> type, ChunkPos pos, int level, T value) {
@@ -189,12 +123,7 @@ public abstract class DistanceManager {
this.addRegionTicketAtDistance(type, pos, distance, value);
@@ -181,68 +119,43 @@ public abstract class DistanceManager {
}
public <T> boolean addRegionTicketAtDistance(TicketType<T> type, ChunkPos pos, int distance, T value) {
- // CraftBukkit end
public <T> void addRegionTicket(TicketType<T> type, ChunkPos pos, int distance, T value) {
- Ticket<T> ticket = new Ticket<>(type, ChunkLevel.byStatus(FullChunkStatus.FULL) - distance, value);
- long packedChunkPos = pos.toLong();
- final boolean addded = this.addTicket(packedChunkPos, ticket); // CraftBukkit
- this.addTicket(packedChunkPos, ticket); // Paper - diff on change above
- this.tickingTicketsTracker.addTicket(packedChunkPos, ticket);
- return addded; // CraftBukkit
+ return this.moonrise$getChunkHolderManager().addTicketAtLevel(type, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - distance, value); // Paper - rewrite chunk system
+ this.moonrise$getChunkHolderManager().addTicketAtLevel(type, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - distance, value); // Paper - rewrite chunk system
}
public <T> void removeRegionTicket(TicketType<T> type, ChunkPos pos, int distance, T value) {
@@ -202,37 +131,29 @@ public abstract class DistanceManager {
removeRegionTicketAtDistance(type, pos, distance, value);
}
public <T> boolean removeRegionTicketAtDistance(TicketType<T> type, ChunkPos pos, int distance, T value) {
- // CraftBukkit end
- Ticket<T> ticket = new Ticket<>(type, ChunkLevel.byStatus(FullChunkStatus.FULL) - distance, value);
- long packedChunkPos = pos.toLong();
- final boolean removed = this.removeTicket(packedChunkPos, ticket); // CraftBukkit
- this.removeTicket(packedChunkPos, ticket); // Paper - diff on change above
- this.tickingTicketsTracker.removeTicket(packedChunkPos, ticket);
- return removed; // CraftBukkit
+ return this.moonrise$getChunkHolderManager().removeTicketAtLevel(type, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - distance, value); // Paper - rewrite chunk system
+ this.moonrise$getChunkHolderManager().removeTicketAtLevel(type, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - distance, value); // Paper - rewrite chunk system
}
// Paper start
public boolean addPluginRegionTicket(final ChunkPos pos, final org.bukkit.plugin.Plugin value) {
- Ticket<org.bukkit.plugin.Plugin> ticket = new Ticket<>(TicketType.PLUGIN_TICKET, ChunkLevel.byStatus(FullChunkStatus.FULL) - 2, value); // Copied from below and keep in-line with force loading, add at level 31
- final long packedChunkPos = pos.toLong();
- final Set<Ticket<?>> tickets = this.getTickets(packedChunkPos);
- if (tickets.contains(ticket)) {
- return false;
- }
- this.addTicket(packedChunkPos, ticket);
- this.tickingTicketsTracker.addTicket(packedChunkPos, ticket);
- return true;
+ return this.moonrise$getChunkHolderManager().addTicketAtLevel(TicketType.PLUGIN_TICKET, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - 2, value); // Paper - rewrite chunk system
}
public boolean removePluginRegionTicket(final ChunkPos pos, final org.bukkit.plugin.Plugin value) {
- Ticket<org.bukkit.plugin.Plugin> ticket = new Ticket<>(TicketType.PLUGIN_TICKET, ChunkLevel.byStatus(FullChunkStatus.FULL) - 2, value); // Copied from below and keep in-line with force loading, add at level 31
- final long packedChunkPos = pos.toLong();
- final Set<Ticket<?>> tickets = this.tickets.get(packedChunkPos); // Don't use getTickets, we don't want to create a new set
- if (tickets == null || !tickets.contains(ticket)) {
- return false;
- }
- this.removeTicket(packedChunkPos, ticket);
- this.tickingTicketsTracker.removeTicket(packedChunkPos, ticket);
- return true;
+ return this.moonrise$getChunkHolderManager().removeTicketAtLevel(TicketType.PLUGIN_TICKET, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - 2, value); // Paper - rewrite chunk system
}
// Paper end
private SortedArraySet<Ticket<?>> getTickets(long chunkPos) {
- return this.tickets.computeIfAbsent(chunkPos, l -> SortedArraySet.create(4));
+ throw new UnsupportedOperationException(); // Paper - rewrite chunk system
@ -25494,9 +25510,9 @@ index e50e96861c0aefdb0a79674b7790798f2571010e..73599e8adbee0957c1318ee6688e49b9
}
public void removePlayer(SectionPos sectionPos, ServerPlayer player) {
@@ -246,136 +167,90 @@ public abstract class DistanceManager {
@@ -254,136 +167,90 @@ public abstract class DistanceManager {
if (set == null || set.isEmpty()) {
// Paper end - some state corruption happens here, don't crash, clean up gracefully
// Paper end - some state corruption happens here, don't crash, clean up gracefully
this.playersPerChunk.remove(packedChunkPos);
- this.naturalSpawnChunkCounter.update(packedChunkPos, Integer.MAX_VALUE, false);
- this.playerTicketManager.update(packedChunkPos, Integer.MAX_VALUE, false);
@ -25661,7 +25677,7 @@ index e50e96861c0aefdb0a79674b7790798f2571010e..73599e8adbee0957c1318ee6688e49b9
class ChunkTicketTracker extends ChunkTracker {
private static final int MAX_LEVEL = ChunkLevel.MAX_LEVEL + 1;
@@ -420,7 +295,7 @@ public abstract class DistanceManager {
@@ -428,7 +295,7 @@ public abstract class DistanceManager {
public int runDistanceUpdates(int toUpdateCount) {
return this.runUpdates(toUpdateCount);
}
@ -25670,7 +25686,7 @@ index e50e96861c0aefdb0a79674b7790798f2571010e..73599e8adbee0957c1318ee6688e49b9
class FixedPlayerDistanceChunkTracker extends ChunkTracker {
protected final Long2ByteMap chunks = new Long2ByteOpenHashMap();
@@ -479,6 +354,7 @@ public abstract class DistanceManager {
@@ -487,6 +354,7 @@ public abstract class DistanceManager {
}
}
@ -25678,7 +25694,7 @@ index e50e96861c0aefdb0a79674b7790798f2571010e..73599e8adbee0957c1318ee6688e49b9
class PlayerTicketTracker extends DistanceManager.FixedPlayerDistanceChunkTracker {
private int viewDistance;
private final Long2IntMap queueLevels = Long2IntMaps.synchronize(new Long2IntOpenHashMap());
@@ -555,5 +431,5 @@ public abstract class DistanceManager {
@@ -563,5 +431,5 @@ public abstract class DistanceManager {
private boolean haveTicketFor(int level) {
return level <= this.viewDistance;
}
@ -26019,7 +26035,7 @@ index cb66209c64b855dedf2e4e114a7716da13bc4587..da1366fdc4889d6a3befd43d81a19a81
}
}
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
index 796b5f8541b0cf84482ab2b5a60adde544d43593..7ce641cc34ef95e248e62ebf0b7fdfb8b2924256 100644
index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..6c9c7c3124d5990ea34368eb4578eac695abd658 100644
--- a/net/minecraft/server/level/ServerChunkCache.java
+++ b/net/minecraft/server/level/ServerChunkCache.java
@@ -52,7 +52,7 @@ import net.minecraft.world.level.storage.DimensionDataStorage;
@ -26174,7 +26190,7 @@ index 796b5f8541b0cf84482ab2b5a60adde544d43593..7ce641cc34ef95e248e62ebf0b7fdfb8
- for (int i = 0; i < 4; i++) {
- if (packedChunkPos == this.lastChunkPos[i] && chunkStatus == this.lastChunkStatus[i]) {
- ChunkAccess chunkAccess = this.lastChunk[i];
- if (chunkAccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime
- if (chunkAccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime
- return chunkAccess;
- }
- }
@ -26519,7 +26535,7 @@ index 796b5f8541b0cf84482ab2b5a60adde544d43593..7ce641cc34ef95e248e62ebf0b7fdfb8
}
}
diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
index 4c891706c2a3efc8e8c44fc1c031e8a1d21efb60..d38ddfd7afba189a489701e62b5fa6db8df87a9d 100644
index 70f6d068b3f3665b282d9750310c883839120ab2..870b9efd445ddadb3725e88351555ad986ce7c72 100644
--- a/net/minecraft/server/level/ServerEntity.java
+++ b/net/minecraft/server/level/ServerEntity.java
@@ -91,6 +91,11 @@ public class ServerEntity {
@ -26535,7 +26551,7 @@ index 4c891706c2a3efc8e8c44fc1c031e8a1d21efb60..d38ddfd7afba189a489701e62b5fa6db
if (!passengers.equals(this.lastPassengers)) {
this.broadcastAndSend(new ClientboundSetPassengersPacket(this.entity)); // CraftBukkit
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 08ee3583a07b6e4e877e530d422e386597bce6de..3927f5603d18f1c42eb29d916f287b6ef3f39612 100644
index cdda7f6272cfc48638df4e0e51b496e91ed77ba5..ffb5bfdd76a92bac61c7c352fdded4200d13b3ae 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -170,7 +170,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
@ -27296,7 +27312,7 @@ index 08ee3583a07b6e4e877e530d422e386597bce6de..3927f5603d18f1c42eb29d916f287b6e
}
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
index 940509d1f31aedf20b8f5b9192c34ad004875728..b455e0e0fea949bee1953324ae530c19405c5d3b 100644
index 6238729e91ae4fd44a4e0bc73d4f042498c4cb8d..bf4deeac50197eeb83c5b1e458b609aac5ad8a97 100644
--- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java
@@ -178,7 +178,7 @@ import net.minecraft.world.scores.Team;
@ -27308,7 +27324,7 @@ index 940509d1f31aedf20b8f5b9192c34ad004875728..b455e0e0fea949bee1953324ae530c19
private static final Logger LOGGER = LogUtils.getLogger();
private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_XZ = 32;
private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y = 10;
@@ -387,6 +387,36 @@ public class ServerPlayer extends Player {
@@ -388,6 +388,36 @@ public class ServerPlayer extends Player {
public @Nullable String clientBrandName = null; // Paper - Brand support
public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event
@ -27776,7 +27792,7 @@ index 4eb040006f5d41b47e5ac9df5d9f19c4315d6343..7fa41dea184b01891f45d8e404bc1cba
this.generatingStep = generatingStep;
this.cache = cache;
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index d227714de0fe13544779fae6cf0e9ff6af5469c7..4722230e74e0778ebdb2cfd383764b34004e9568 100644
index bafeeab3edbc73f6f86474e18ab4a3d96ce17157..d322794c0d49daa212b8691f8f60f2276fe25a92 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -1318,7 +1318,7 @@ public abstract class PlayerList {
@ -28172,7 +28188,7 @@ index 8cc5c0716392ba06501542ff5cbe71ee43979e5d..09fd99c9cbd23b5f3c899bfb00c9b896
+ // Paper end - block counting
}
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 5a67aa9f1fe103e5622ed6fa93bc4bc25ddbb688..77d2c86c8bb20e96e0eed32c430ef0c1d122428b 100644
index d5b0db3095a563dd101a1b12b150401a7dc59f8e..eb333032d8117d8dec4a15f3f2803166431633bc 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -135,7 +135,7 @@ import net.minecraft.world.scores.ScoreHolder;
@ -28266,7 +28282,7 @@ index 5a67aa9f1fe103e5622ed6fa93bc4bc25ddbb688..77d2c86c8bb20e96e0eed32c430ef0c1
}
// Paper end - Share random for entities to make them more random
public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason
@@ -425,6 +381,156 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -419,6 +375,156 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return this.dimensions.makeBoundingBox(x, y, z);
}
// Paper end
@ -28647,7 +28663,7 @@ index 5a67aa9f1fe103e5622ed6fa93bc4bc25ddbb688..77d2c86c8bb20e96e0eed32c430ef0c1
}
public InteractionResult interact(Player player, InteractionHand hand) {
@@ -4063,15 +4298,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4062,15 +4297,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}
public Iterable<Entity> getIndirectPassengers() {
@ -28673,7 +28689,7 @@ index 5a67aa9f1fe103e5622ed6fa93bc4bc25ddbb688..77d2c86c8bb20e96e0eed32c430ef0c1
}
public int countPlayerPassengers() {
@@ -4209,77 +4446,136 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4208,77 +4445,136 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return Mth.lerp(partialTick, this.yRotO, this.yRot);
}
@ -28864,7 +28880,7 @@ index 5a67aa9f1fe103e5622ed6fa93bc4bc25ddbb688..77d2c86c8bb20e96e0eed32c430ef0c1
public boolean touchingUnloadedChunk() {
AABB aabb = this.getBoundingBox().inflate(1.0);
@@ -4430,6 +4726,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4429,6 +4725,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
this.setPosRaw(x, y, z, false);
}
public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) {
@ -28880,7 +28896,7 @@ index 5a67aa9f1fe103e5622ed6fa93bc4bc25ddbb688..77d2c86c8bb20e96e0eed32c430ef0c1
if (!checkPosition(this, x, y, z)) {
return;
}
@@ -4558,6 +4863,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4557,6 +4862,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@Override
public final void setRemoved(Entity.RemovalReason removalReason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) {
@ -28893,7 +28909,7 @@ index 5a67aa9f1fe103e5622ed6fa93bc4bc25ddbb688..77d2c86c8bb20e96e0eed32c430ef0c1
org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause);
// CraftBukkit end
final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
@@ -4569,7 +4880,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4568,7 +4879,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
this.stopRiding();
}
@ -28902,7 +28918,7 @@ index 5a67aa9f1fe103e5622ed6fa93bc4bc25ddbb688..77d2c86c8bb20e96e0eed32c430ef0c1
this.levelCallback.onRemove(removalReason);
this.onRemoval(removalReason);
// Paper start - Folia schedulers
@@ -4603,7 +4914,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4602,7 +4913,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
public boolean shouldBeSaved() {
return (this.removalReason == null || this.removalReason.shouldSave())
&& !this.isPassenger()
@ -29150,7 +29166,7 @@ index 324cc0686f0f5b1371b2bbea5b8c8fdb1f363006..39cd1e3d8192d7077d6b7864d3393309
this(setDirty, true, ImmutableList.of());
}
diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java
index 613675c86787dd1147e140f1ef4d17b09ab9a74b..5cc19a67c7a29f1bda8cdd6921201f47fe6bf91f 100644
index 33f6d6862731d22d6d3eeb7cf39a4a42049afae3..a3cc0001a949597e345d7919c3f6109fa4a949ad 100644
--- a/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/net/minecraft/world/entity/decoration/ArmorStand.java
@@ -316,7 +316,7 @@ public class ArmorStand extends LivingEntity {
@ -29300,7 +29316,7 @@ index 300f3ed58109219d97846082941b860585f66fed..e81195df621159da67136f020fa7a6d3
// Paper start - Affects Spawning API
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 872c3b8826f436b15f6ab0a3619692c5202eadc3..b5efce6faf35dbfee9aa6c17f2e7e9befe6a2040 100644
index 0e4ab448755632696c4326f1df9f3855cd38a64d..72646473019424de969756ae1d0e9f789310889b 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -79,6 +79,7 @@ import net.minecraft.world.level.storage.LevelData;
@ -29992,17 +30008,16 @@ index 872c3b8826f436b15f6ab0a3619692c5202eadc3..b5efce6faf35dbfee9aa6c17f2e7e9be
this.sendBlockUpdated(blockposition, iblockdata1, iblockdata, i);
}
@@ -836,6 +1470,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// Iterator<TickingBlockEntity> iterator = this.blockEntityTickers.iterator();
@@ -835,6 +1469,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// Spigot start
boolean runsNormally = this.tickRateManager().runsNormally();
+ int tickedEntities = 0; // Paper - rewrite chunk system
+
int tilesThisCycle = 0;
var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<TickingBlockEntity>(); // Paper - Fix MC-117075; use removeAll
toRemove.add(null); // Paper - Fix MC-117075
@@ -850,6 +1486,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// Spigot end
for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters
@@ -845,6 +1480,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll
} else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) {
tickingBlockEntity.tick();
+ // Paper start - rewrite chunk system
@ -30013,7 +30028,7 @@ index 872c3b8826f436b15f6ab0a3619692c5202eadc3..b5efce6faf35dbfee9aa6c17f2e7e9be
}
}
this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075
@@ -870,6 +1511,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -865,6 +1505,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
// Paper end - Prevent block entity and entity crashes
}
@ -30021,7 +30036,7 @@ index 872c3b8826f436b15f6ab0a3619692c5202eadc3..b5efce6faf35dbfee9aa6c17f2e7e9be
}
// Paper start - Option to prevent armor stands from doing entity lookups
@@ -877,7 +1519,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -872,7 +1513,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public boolean noCollision(@Nullable Entity entity, AABB box) {
if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand && !entity.level().paperConfig().entities.armorStands.doCollisionEntityLookups)
return false;
@ -30037,7 +30052,7 @@ index 872c3b8826f436b15f6ab0a3619692c5202eadc3..b5efce6faf35dbfee9aa6c17f2e7e9be
}
// Paper end - Option to prevent armor stands from doing entity lookups
@@ -1015,7 +1664,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -1010,7 +1658,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
if (this.isOutsideBuildHeight(pos)) {
return null;
} else {
@ -30046,7 +30061,7 @@ index 872c3b8826f436b15f6ab0a3619692c5202eadc3..b5efce6faf35dbfee9aa6c17f2e7e9be
? null
: this.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE);
}
@@ -1108,22 +1757,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -1103,22 +1751,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public List<Entity> getEntities(@Nullable Entity entity, AABB boundingBox, Predicate<? super Entity> predicate) {
Profiler.get().incrementCounter("getEntities");
List<Entity> list = Lists.newArrayList();
@ -30077,7 +30092,7 @@ index 872c3b8826f436b15f6ab0a3619692c5202eadc3..b5efce6faf35dbfee9aa6c17f2e7e9be
}
@Override
@@ -1137,33 +1780,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -1132,33 +1774,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
this.getEntities(entityTypeTest, bounds, predicate, output, Integer.MAX_VALUE);
}
@ -30217,10 +30232,10 @@ index 2709803b9266ff4a2034d83321cd0ba4e30fc0aa..26c8c1e5598daf3550aef05b12218c47
ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk);
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index 8b91574d4679f4e5a01b4bc3651069cd489b0336..fc08543bf5c8cbe338991795a9da28e997a5d9d1 100644
index 3619509d51ebd2e5e36fe4b67e76c94a8d272d1b..7b132c55caf9d3c3df3b0a123f4b5bfc7ae35984 100644
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -64,6 +64,249 @@ public class ServerExplosion implements Explosion {
@@ -63,6 +63,249 @@ public class ServerExplosion implements Explosion {
public float yield;
// CraftBukkit end
public boolean excludeSourceFromDamage = true; // Paper - Allow explosions to damage source
@ -30470,7 +30485,7 @@ index 8b91574d4679f4e5a01b4bc3651069cd489b0336..fc08543bf5c8cbe338991795a9da28e9
public ServerExplosion(
ServerLevel level,
@@ -135,63 +378,102 @@ public class ServerExplosion implements Explosion {
@@ -134,63 +377,102 @@ public class ServerExplosion implements Explosion {
}
private List<BlockPos> calculateExplodedPositions() {
@ -30514,7 +30529,7 @@ index 8b91574d4679f4e5a01b4bc3651069cd489b0336..fc08543bf5c8cbe338991795a9da28e9
- if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockPos, blockState, f)) {
- set.add(blockPos);
- // Paper start - prevent headless pistons from forming
- if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && blockState.getBlock() == Blocks.MOVING_PISTON) {
- if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && blockState.is(Blocks.MOVING_PISTON)) {
- net.minecraft.world.level.block.entity.BlockEntity extension = this.level.getBlockEntity(blockPos);
- if (extension instanceof net.minecraft.world.level.block.piston.PistonMovingBlockEntity blockEntity && blockEntity.isSourcePiston()) {
- net.minecraft.core.Direction direction = blockState.getValue(net.minecraft.world.level.block.piston.PistonHeadBlock.FACING);
@ -30620,7 +30635,7 @@ index 8b91574d4679f4e5a01b4bc3651069cd489b0336..fc08543bf5c8cbe338991795a9da28e9
}
private void hurtEntities() {
@@ -372,6 +654,14 @@ public class ServerExplosion implements Explosion {
@@ -371,6 +653,14 @@ public class ServerExplosion implements Explosion {
return;
}
// CraftBukkit end
@ -30635,7 +30650,7 @@ index 8b91574d4679f4e5a01b4bc3651069cd489b0336..fc08543bf5c8cbe338991795a9da28e9
this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center);
List<BlockPos> list = this.calculateExplodedPositions();
this.hurtEntities();
@@ -385,6 +675,13 @@ public class ServerExplosion implements Explosion {
@@ -384,6 +674,13 @@ public class ServerExplosion implements Explosion {
if (this.fire) {
this.createFire(list);
}
@ -30649,7 +30664,7 @@ index 8b91574d4679f4e5a01b4bc3651069cd489b0336..fc08543bf5c8cbe338991795a9da28e9
}
private static void addOrAppendStack(List<ServerExplosion.StackCollector> stackCollectors, ItemStack stack, BlockPos pos) {
@@ -475,12 +772,12 @@ public class ServerExplosion implements Explosion {
@@ -474,12 +771,12 @@ public class ServerExplosion implements Explosion {
// Paper start - Optimize explosions
private float getBlockDensity(Vec3 vec3d, Entity entity) {
if (!this.level.paperConfig().environment.optimizeExplosions) {
@ -30705,7 +30720,7 @@ index 8d98cba3830dc5dfb5cae9a6f5fedfffee0d2cd8..73962e79a0f3d892e3155443a1b84508
public interface NoiseBiomeSource {
diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java
index 3eedc6c2a1325a0fd1baa14e246aeda27de4117d..34177f27680612055526553c849777067882ad74 100644
index 91d7d250f7c3de8a71aef26e23c12764b06b322b..0d36b1ac7d54283af71f2494accded11c059dba5 100644
--- a/net/minecraft/world/level/block/Block.java
+++ b/net/minecraft/world/level/block/Block.java
@@ -259,7 +259,7 @@ public class Block extends BlockBehaviour implements ItemLike {
@ -30718,10 +30733,10 @@ index 3eedc6c2a1325a0fd1baa14e246aeda27de4117d..34177f27680612055526553c84977706
public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) {
diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java
index e0c3d8923f56c059b5d6111ab2ff01be3566f6d9..73b913da595e7ad2de8f363f342de98f6c647b71 100644
index 25e49a24cedfa8ad04245d59fcac3231bcd62103..061d94a35d957ca72a01bae959d38aab59b1a64d 100644
--- a/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -417,7 +417,7 @@ public abstract class BlockBehaviour implements FeatureElement {
@@ -416,7 +416,7 @@ public abstract class BlockBehaviour implements FeatureElement {
return this.properties.destroyTime;
}
@ -30730,7 +30745,7 @@ index e0c3d8923f56c059b5d6111ab2ff01be3566f6d9..73b913da595e7ad2de8f363f342de98f
private static final Direction[] DIRECTIONS = Direction.values();
private static final VoxelShape[] EMPTY_OCCLUSION_SHAPES = Util.make(new VoxelShape[DIRECTIONS.length], shape -> Arrays.fill(shape, Shapes.empty()));
private static final VoxelShape[] FULL_BLOCK_OCCLUSION_SHAPES = Util.make(
@@ -456,6 +456,76 @@ public abstract class BlockBehaviour implements FeatureElement {
@@ -455,6 +455,76 @@ public abstract class BlockBehaviour implements FeatureElement {
private boolean propagatesSkylightDown;
private int lightBlock;
@ -30807,7 +30822,7 @@ index e0c3d8923f56c059b5d6111ab2ff01be3566f6d9..73b913da595e7ad2de8f363f342de98f
protected BlockStateBase(Block owner, Reference2ObjectArrayMap<Property<?>, Comparable<?>> values, MapCodec<BlockState> propertiesCodec) {
super(owner, values, propertiesCodec);
BlockBehaviour.Properties properties = owner.properties;
@@ -534,6 +604,41 @@ public abstract class BlockBehaviour implements FeatureElement {
@@ -533,6 +603,41 @@ public abstract class BlockBehaviour implements FeatureElement {
this.propagatesSkylightDown = this.owner.propagatesSkylightDown(this.asState());
this.lightBlock = this.owner.getLightBlock(this.asState());
@ -31197,7 +31212,7 @@ index 92350434746f06bbf4a161c6bc42602de7b45220..1c24f38d21da1be9740512981f219924
public Property.Value<T> value(T value) {
diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java
index bc688ad1097ef4159dfc5f96d963a9fa63262e20..6e0210f32c679e3a33256cb05dc282f2e8b7d856 100644
index 860d1c9729c4ee97ec6f40f7aa969829070b27c0..94de1217d18e1a7a0fb7b83f21436eaf0a5998c6 100644
--- a/net/minecraft/world/level/chunk/ChunkAccess.java
+++ b/net/minecraft/world/level/chunk/ChunkAccess.java
@@ -57,7 +57,7 @@ import net.minecraft.world.ticks.SavedTick;
@ -31288,11 +31303,11 @@ index bc688ad1097ef4159dfc5f96d963a9fa63262e20..6e0210f32c679e3a33256cb05dc282f2
@@ -116,6 +167,16 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh
this.replaceMissingSections(biomeRegistry, this.sections); // Paper - Anti-Xray - make it a non-static method
this.biomeRegistry = biomeRegistry; // Craftbukkit
this.biomeRegistry = biomeRegistry; // CraftBukkit
+ // Paper start - rewrite chunk system
+ if (!((Object)this instanceof ImposterProtoChunk)) {
+ this.starlight$setBlockNibbles(ca.spottedleaf.moonrise.patches.starlight.light.StarLightEngine.getFilledEmptyLight(heightLimitView));
+ this.starlight$setSkyNibbles(ca.spottedleaf.moonrise.patches.starlight.light.StarLightEngine.getFilledEmptyLight(heightLimitView));
+ this.starlight$setBlockNibbles(ca.spottedleaf.moonrise.patches.starlight.light.StarLightEngine.getFilledEmptyLight(levelHeightAccessor));
+ this.starlight$setSkyNibbles(ca.spottedleaf.moonrise.patches.starlight.light.StarLightEngine.getFilledEmptyLight(levelHeightAccessor));
+ }
+ // Paper end - rewrite chunk system
+ // Paper start - get block chunk optimisation
@ -31352,7 +31367,7 @@ index bc688ad1097ef4159dfc5f96d963a9fa63262e20..6e0210f32c679e3a33256cb05dc282f2
public record PackedTicks(List<SavedTick<Block>> blocks, List<SavedTick<Fluid>> fluids) {
diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java
index 89f027f0edf2ca59966efe209e567108665cbe0c..7944c2bb854ee52a55d7c54e5f814e87d709e70e 100644
index 65117a9cb9d1b8684cae8d36ea3b8e2050fb928c..a9d65e28b849c9660a14ef7c16ed17bd5182bd7e 100644
--- a/net/minecraft/world/level/chunk/ChunkGenerator.java
+++ b/net/minecraft/world/level/chunk/ChunkGenerator.java
@@ -116,7 +116,7 @@ public abstract class ChunkGenerator {
@ -31515,7 +31530,7 @@ index e7c0f4da8508fbca467326f475668d66454d7b77..41856c98d97e7eb0782f8e441b9a269a
@Override
public BlockEntity getBlockEntity(BlockPos pos) {
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
index d1d0dc13eecb0e0eb3a7839b570a5fe7f62f3fba..72c0e031443ca42c2cfafddea9e04cfa4f93a0eb 100644
index 96b0342ab7b922aa16d07b6c00542e6cb66c974a..aff0937ad7eb81d9e32f56aa337a4ec7551f0faa 100644
--- a/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
@@ -52,7 +52,7 @@ import net.minecraft.world.ticks.LevelChunkTicks;
@ -32582,10 +32597,10 @@ index 889e188e920edb284f04b264bcdd06146f54a4cb..2199a9e2a0141c646d108f2687a27f1d
private final Long2ObjectLinkedOpenHashMap<CompletableFuture<BitSet>> regionCacheForBlender = new Long2ObjectLinkedOpenHashMap<>();
private static final int REGION_CACHE_SIZE = 1024;
diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java
index 7491644233d52dc56d83de5ad3373f6a9a455378..b76f0fcecd3de1e7a802a6006c8851d94ba35329 100644
index 783a2d80f6197dd0af0dc81909f0353a8ea2ecf4..7da388ffab162c282cad0f297bb7304f3c2abbaf 100644
--- a/net/minecraft/world/level/chunk/storage/RegionFile.java
+++ b/net/minecraft/world/level/chunk/storage/RegionFile.java
@@ -23,7 +23,7 @@ import net.minecraft.util.profiling.jfr.JvmProfiler;
@@ -22,7 +22,7 @@ import net.minecraft.util.profiling.jfr.JvmProfiler;
import net.minecraft.world.level.ChunkPos;
import org.slf4j.Logger;
@ -32594,7 +32609,7 @@ index 7491644233d52dc56d83de5ad3373f6a9a455378..b76f0fcecd3de1e7a802a6006c8851d9
private static final Logger LOGGER = LogUtils.getLogger();
private static final int SECTOR_BYTES = 4096;
@VisibleForTesting
@@ -46,6 +46,21 @@ public class RegionFile implements AutoCloseable {
@@ -45,6 +45,21 @@ public class RegionFile implements AutoCloseable {
@VisibleForTesting
protected final RegionBitmap usedSectors = new RegionBitmap();
@ -32616,7 +32631,7 @@ index 7491644233d52dc56d83de5ad3373f6a9a455378..b76f0fcecd3de1e7a802a6006c8851d9
public RegionFile(RegionStorageInfo info, Path path, Path externalFileDir, boolean sync) throws IOException {
this(info, path, externalFileDir, RegionFileVersion.getCompressionFormat(), sync); // Paper - Configurable region compression format
}
@@ -205,6 +220,16 @@ public class RegionFile implements AutoCloseable {
@@ -204,6 +219,16 @@ public class RegionFile implements AutoCloseable {
@Nullable
private DataInputStream createExternalChunkInputStream(ChunkPos chunkPos, byte versionByte) throws IOException {
@ -32633,7 +32648,7 @@ index 7491644233d52dc56d83de5ad3373f6a9a455378..b76f0fcecd3de1e7a802a6006c8851d9
Path externalChunkPath = this.getExternalChunkPath(chunkPos);
if (!Files.isRegularFile(externalChunkPath)) {
LOGGER.error("External chunk path {} is not file", externalChunkPath);
@@ -399,9 +424,28 @@ public class RegionFile implements AutoCloseable {
@@ -398,9 +423,28 @@ public class RegionFile implements AutoCloseable {
}
}
@ -32663,7 +32678,7 @@ index 7491644233d52dc56d83de5ad3373f6a9a455378..b76f0fcecd3de1e7a802a6006c8851d9
public ChunkBuffer(final ChunkPos pos) {
super(8096);
super.write(0);
@@ -418,7 +462,7 @@ public class RegionFile implements AutoCloseable {
@@ -417,7 +461,7 @@ public class RegionFile implements AutoCloseable {
int i = this.count - 5 + 1;
JvmProfiler.INSTANCE.onRegionFileWrite(RegionFile.this.info, this.pos, RegionFile.this.version, i);
byteBuffer.putInt(0, i);
@ -33498,7 +33513,7 @@ index 342c83309b19c64d86e0dd97c1756c96be52772b..423779a2b690f387a4f0bd07b97b50e0
}
}
diff --git a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
index b50de067a2a968926bdda4174e42f2973c84ff8b..8b81257328771ad23b90d7670f13713f93eefa96 100644
index 29d9f6e54421c539e9e55ab9f51b4c872da3fbb8..d77016287f5f9a0964d56f05d2d5256ef2e6e86c 100644
--- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
+++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
@@ -78,7 +78,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
@ -33800,7 +33815,7 @@ index ca23af013967b50420ebee178878ea79333de53b..83c3ec06be51f632b7c1b682cfa8dce7
public int getLightSectionCount() {
diff --git a/net/minecraft/world/level/material/FlowingFluid.java b/net/minecraft/world/level/material/FlowingFluid.java
index b9ad980b9a203bbc295f780bf54941f19a2f6525..19beef65b292c474f3a25b6c3ff679e31c17c7f4 100644
index 130ef38a50f1df1faa26b433b0c605a4507f71af..f6daca279788c3d983a9ee213df85d5d93fc6eed 100644
--- a/net/minecraft/world/level/material/FlowingFluid.java
+++ b/net/minecraft/world/level/material/FlowingFluid.java
@@ -45,6 +45,48 @@ public abstract class FlowingFluid extends Fluid {

View file

@ -48,10 +48,10 @@ index db31989ebe3d7021cfd2311439e9a00f819b0841..1373977b339405ef59bb3ea03d195285
serverEntity.getLastSentYRot(),
entity.getType(),
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
index f8f145cd9614f7e38d6aa72501fe31837340a8bb..fa48e63fea42f387dcd154c08af54cfb0d3b08af 100644
index 9faf0ece0f074b8709b4e4fad0cab3e9c2224276..d22459cb1d46ea7c969aa05cb9d7d12466e173da 100644
--- a/net/minecraft/server/level/ChunkMap.java
+++ b/net/minecraft/server/level/ChunkMap.java
@@ -1419,6 +1419,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1208,6 +1208,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.serverEntity.addPairing(player);
}
// Paper end - entity tracking events
@ -60,7 +60,7 @@ index f8f145cd9614f7e38d6aa72501fe31837340a8bb..fa48e63fea42f387dcd154c08af54cfb
} else if (this.seenBy.remove(player.connection)) {
this.serverEntity.removePairing(player);
diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
index 4c891706c2a3efc8e8c44fc1c031e8a1d21efb60..66f7926a2639ade41cb89419e38e12053314c982 100644
index 870b9efd445ddadb3725e88351555ad986ce7c72..a4da36060ca75968f5831adfc3f7117281649b7a 100644
--- a/net/minecraft/server/level/ServerEntity.java
+++ b/net/minecraft/server/level/ServerEntity.java
@@ -90,6 +90,13 @@ public class ServerEntity {
@ -75,9 +75,9 @@ index 4c891706c2a3efc8e8c44fc1c031e8a1d21efb60..66f7926a2639ade41cb89419e38e1205
+ // Paper end - fix desync when a player is added to the tracker
+
public void sendChanges() {
List<Entity> passengers = this.entity.getPassengers();
if (!passengers.equals(this.lastPassengers)) {
@@ -125,7 +132,7 @@ public class ServerEntity {
// Paper start - optimise collisions
if (((ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity)this.entity).moonrise$isHardColliding()) {
@@ -130,7 +137,7 @@ public class ServerEntity {
this.sendDirtyEntityData();
}
@ -86,7 +86,7 @@ index 4c891706c2a3efc8e8c44fc1c031e8a1d21efb60..66f7926a2639ade41cb89419e38e1205
byte b = Mth.packDegrees(this.entity.getYRot());
byte b1 = Mth.packDegrees(this.entity.getXRot());
boolean flag = Math.abs(b - this.lastSentYRot) >= 1 || Math.abs(b1 - this.lastSentXRot) >= 1;
@@ -160,7 +167,7 @@ public class ServerEntity {
@@ -165,7 +172,7 @@ public class ServerEntity {
long l1 = this.positionCodec.encodeY(vec3);
long l2 = this.positionCodec.encodeZ(vec3);
boolean flag5 = l < -32768L || l > 32767L || l1 < -32768L || l1 > 32767L || l2 < -32768L || l2 > 32767L;
@ -95,7 +95,7 @@ index 4c891706c2a3efc8e8c44fc1c031e8a1d21efb60..66f7926a2639ade41cb89419e38e1205
this.wasOnGround = this.entity.onGround();
this.teleportDelay = 0;
packet = ClientboundEntityPositionSyncPacket.of(this.entity);
@@ -225,6 +232,7 @@ public class ServerEntity {
@@ -230,6 +237,7 @@ public class ServerEntity {
}
this.entity.hasImpulse = false;

View file

@ -8,7 +8,7 @@ Areas affected by lag comepnsation:
- Eating food items
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index 5649482a8b85056bc009b868e19ca11f21d59fbf..f4fba4e2d12c7ab4b4eb9858cd738a9678a2d203 100644
index 0c35921acebd88f3a9a37676e47e7482dfea6d9c..1ff57c17f7fe3af3fb7fc5fbc5148ca333b5e618 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -301,6 +301,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@ -19,7 +19,7 @@ index 5649482a8b85056bc009b868e19ca11f21d59fbf..f4fba4e2d12c7ab4b4eb9858cd738a96
public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) {
ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system
@@ -1561,6 +1562,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1643,6 +1644,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
for (ServerLevel serverLevel : this.getAllLevels()) {
serverLevel.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
serverLevel.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent
@ -28,10 +28,10 @@ index 5649482a8b85056bc009b868e19ca11f21d59fbf..f4fba4e2d12c7ab4b4eb9858cd738a96
/* Drop global time updates
if (this.tickCount % 20 == 0) {
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 4d20bda4cba578c47216d450c99389b744a59008..47b7d487467225505e3f20cea92e114331d660fd 100644
index ffb5bfdd76a92bac61c7c352fdded4200d13b3ae..651a65aaa37f2cf26d54f75529cbda71e6fc2bc4 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -2362,4 +2362,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -2678,4 +2678,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
return this.server.getPlayerList().getPlayer(uuid);
}
// Paper end - check global player list where appropriate
@ -49,7 +49,7 @@ index 4d20bda4cba578c47216d450c99389b744a59008..47b7d487467225505e3f20cea92e1143
+ // Paper end - lag compensation
}
diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java
index fd7ad2b1bffe3880def0f0c9a7ed8de5088ecd71..e753849002b48d4a498dc93349e331bc26d39aff 100644
index bf2a4c03afb73367a6d2530c78ff9f7c06f7f6a6..6207f45e7b84af4e6a2e4eb7b9fabf6b1e22a63a 100644
--- a/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -111,7 +111,7 @@ public class ServerPlayerGameMode {

View file

@ -2326,7 +2326,7 @@ index 0000000000000000000000000000000000000000..298076a0db4e6ee6e4775ac43bf749d9
+ }
+}
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 47b7d487467225505e3f20cea92e114331d660fd..c38eda42b33cfa4792625f40ebde6f30e591119b 100644
index 651a65aaa37f2cf26d54f75529cbda71e6fc2bc4..61347004cb5b220e5596c053181a01ba5dd2b744 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -214,6 +214,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@ -2337,7 +2337,7 @@ index 47b7d487467225505e3f20cea92e114331d660fd..c38eda42b33cfa4792625f40ebde6f30
public LevelChunk getChunkIfLoaded(int x, int z) {
return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately
@@ -2213,6 +2214,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -2529,6 +2530,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
return this.chunkSource.getGenerator().getSeaLevel();
}
@ -2352,10 +2352,10 @@ index 47b7d487467225505e3f20cea92e114331d660fd..c38eda42b33cfa4792625f40ebde6f30
@Override
public void onCreated(Entity entity) {
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 0e4ab448755632696c4326f1df9f3855cd38a64d..8abb17d30373fab80b466891abd16b31ab536f64 100644
index 72646473019424de969756ae1d0e9f789310889b..d5d18ff7c4c75ab50b3af624b831cb077584f9d1 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -1396,6 +1396,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -2099,6 +2099,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
public abstract FuelValues fuelValues();

View file

@ -204,10 +204,10 @@ index 6475509689439636275b06b9eac33f0922d8fcfd..6c398c91909f42e352e80d0781549df9
int i = this.inventory.findSlotMatchingCraftingIngredient(item, item1);
if (i == -1) {
diff --git a/net/minecraft/world/entity/player/Inventory.java b/net/minecraft/world/entity/player/Inventory.java
index e8522f5ccd69ff5513782a31a3b53219bc17b0e5..80fa9153bdce9b0728cc1ee8908fe5481e84a1f8 100644
index 8a29d771046667db22fba166fa5337de1896cd0d..839cbb67d3d38960d9114a4db5bab911b66a573c 100644
--- a/net/minecraft/world/entity/player/Inventory.java
+++ b/net/minecraft/world/entity/player/Inventory.java
@@ -178,12 +178,12 @@ public class Inventory implements Container, Nameable {
@@ -185,12 +185,12 @@ public class Inventory implements Container, Nameable {
return !stack.isDamaged() && !stack.isEnchanted() && !stack.has(DataComponents.CUSTOM_NAME);
}