Update to 1.21.4

This commit is contained in:
Spottedleaf 2024-12-03 19:38:16 -08:00
parent e1601057b3
commit ff947a77c7
11 changed files with 526 additions and 546 deletions

View File

@ -1,8 +1,8 @@
group=dev.folia
version=1.21.3-R0.1-SNAPSHOT
mcVersion=1.21.3
version=1.21.4-R0.1-SNAPSHOT
mcVersion=1.21.4
paperRef=c2294d7067959d264eb8ad275557f194a3e2656f
paperRef=5a362b875938eb0764f6e8f5bf1352722aa15a98
org.gradle.caching=true
org.gradle.parallel=true

View File

@ -7,7 +7,7 @@ Add both a location based scheduler, an entity based scheduler,
and a global region scheduler.
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
index b878e7167cfcdea0e224c182b40abeadd339d3b3..9611e8e254b4fa9579dc9ffd5198182c43819c56 100644
index 001465eedafa51ac027a4db51cba6223edfe1171..468f5646da7bc413a6e91e82379e6554cc8b459d 100644
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
@@ -557,9 +557,9 @@ public final class SimplePluginManager implements PluginManager {
@ -23,7 +23,7 @@ index b878e7167cfcdea0e224c182b40abeadd339d3b3..9611e8e254b4fa9579dc9ffd5198182c
}
diff --git a/src/main/java/org/bukkit/scheduler/BukkitScheduler.java b/src/main/java/org/bukkit/scheduler/BukkitScheduler.java
index 487b5ca23159b531475c3d650894be707b49914e..31b90d1c2259a8f200b0589909dbbfe4cc526989 100644
index 5c277ac7a61df8106f7c13a1ad8ccb1509338699..446c115f19c4dde0d5e269f8d120bc51ad3898e0 100644
--- a/src/main/java/org/bukkit/scheduler/BukkitScheduler.java
+++ b/src/main/java/org/bukkit/scheduler/BukkitScheduler.java
@@ -7,6 +7,15 @@ import java.util.function.Consumer;

View File

@ -31,7 +31,7 @@ index 3c768d5ccf490e962d9638e92d4ea7c85670bad8..2dbc9fc268850c85e4e8d38da05586a0
+
}
diff --git a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
index a857e46fa6f0c212db93193e1fdd8b0ea9c33c38..90cd9568363a7532d600b627de605c12a7b816c7 100644
index 6dfd51996893ca82b11a540cc18234e0b504f7ba..ff313bf0374c318971860a26f1629f708a5fec26 100644
--- a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
+++ b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
@@ -267,6 +267,19 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Build changes
diff --git a/build.gradle.kts b/build.gradle.kts
index faf3e3fd72e8c915e7a4803dacbe1bb576c6663e..142714c7d47eb5de937ad385c81968148a7e4828 100644
index 2da91ed6363c0851e4c459188f5e8ef5475e0c97..8d2b5fec6fe27dca3ce01ba1ce50506179fc3b4d 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -25,7 +25,7 @@ abstract class MockitoAgentProvider : CommandLineArgumentProvider {
@ -14,10 +14,10 @@ index faf3e3fd72e8c915e7a4803dacbe1bb576c6663e..142714c7d47eb5de937ad385c8196814
dependencies {
- implementation(project(":paper-api"))
+ implementation(project(":folia-api")) // Folia
implementation("ca.spottedleaf:concurrentutil:0.0.2") // Paper - Add ConcurrentUtil dependency
// Paper start
implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21
@@ -99,14 +99,14 @@ tasks.jar {
@@ -100,14 +100,14 @@ tasks.jar {
val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper
attributes(
"Main-Class" to "org.bukkit.craftbukkit.Main",
@ -36,7 +36,7 @@ index faf3e3fd72e8c915e7a4803dacbe1bb576c6663e..142714c7d47eb5de937ad385c8196814
"Build-Number" to (build ?: ""),
"Build-Time" to Instant.now().toString(),
"Git-Branch" to gitBranch, // Paper
@@ -172,7 +172,7 @@ fun TaskContainer.registerRunTask(
@@ -173,7 +173,7 @@ fun TaskContainer.registerRunTask(
name: String,
block: JavaExec.() -> Unit
): TaskProvider<JavaExec> = register<JavaExec>(name) {

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@ index 7fdb9304de7cf1979d57e3fac32415d7c674609d..227d62a69a453d49c28568ecb41ecef8
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 384c876fd25340ea7099bcfb9939e9e475c186a0..c5b67dccdd15d3d8a7d950d397eeffba392bec17 100644
index b449de44b1911e2ff0701956bfba53fb5d2ed44e..c1574cdea90731dec4d24b15979209cce0c581af 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -175,6 +175,17 @@ public abstract class PlayerList {

View File

@ -29,10 +29,10 @@ index 41bf71d116ffc5431586ce54abba7f8def6c1dcf..1cf9a7677449ab8f03fb23d835e3fadc
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index ad358909318a7e52d43e9dfb5cc7e6aa5674b9fd..451d4cf162e39acd7ed215f82a5a84f6be6e166a 100644
index 75929ae02677637500229b7b635479f92e3bd177..20fe53cc8e9edfc7b7d50f23379e0044e520c84d 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3214,6 +3214,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3244,6 +3244,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) {
return false;
} else {
@ -40,7 +40,7 @@ index ad358909318a7e52d43e9dfb5cc7e6aa5674b9fd..451d4cf162e39acd7ed215f82a5a84f6
// CraftBukkit start
if (entity.getBukkitEntity() instanceof Vehicle && this.getBukkitEntity() instanceof LivingEntity) {
VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.getBukkitEntity());
@@ -3235,6 +3236,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3265,6 +3266,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return false;
}
// CraftBukkit end
@ -48,7 +48,7 @@ index ad358909318a7e52d43e9dfb5cc7e6aa5674b9fd..451d4cf162e39acd7ed215f82a5a84f6
if (this.isPassenger()) {
this.stopRiding();
}
@@ -3318,6 +3320,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3348,6 +3350,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
} else {
// CraftBukkit start
@ -56,7 +56,7 @@ index ad358909318a7e52d43e9dfb5cc7e6aa5674b9fd..451d4cf162e39acd7ed215f82a5a84f6
CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
Entity orig = craft == null ? null : craft.getHandle();
if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
@@ -3345,6 +3348,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3375,6 +3378,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return false;
}
// CraftBukkit end
@ -742,27 +742,6 @@ index 267f3c85058ef7c73e372c04493cfa6c907e44bb..df838d551fa08895e390eb793506e2f3
return (Creaking) this.entity;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreakingTransient.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreakingTransient.java
index 17d55c41fa9c5f836e47e3c2a6947960411417c2..f1c6c8df621bca8c84af41cccd546f8925f4b104 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreakingTransient.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreakingTransient.java
@@ -9,8 +9,16 @@ public class CraftCreakingTransient extends CraftCreaking implements org.bukkit.
super(server, entity);
}
+ // Folia start - region threading
+ @Override
+ public CreakingTransient getHandleRaw() {
+ return (CreakingTransient)this.entity;
+ }
+ // Folia end - region threading
+
@Override
public CreakingTransient getHandle() {
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading
return (CreakingTransient) this.entity;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java
index 664d9c1793b823ed03f198a936f2ebd9b7695898..6cbe6b6438296b6137ceea01b21ab6a69da2cc9c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java
@ -1731,7 +1710,7 @@ index e9f471e60af0725ec34e2985d63ae9ea9f88590a..cd824fc65ac2b1fe55710da4700f7c31
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index d0c409f4efad289e3e325f44b500fc72589d89d4..828d371cda28d68246c721a44331bd3f145db3a5 100644
index 4f98d138a275a6c34528b7a5148ef265bc38d6b5..228f7fbce72b7828905e21f21525371a92ec07d4 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -487,6 +487,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@ -1968,10 +1947,10 @@ index e8ece01669373ecf6552d33b2ed72668524e2650..fbb5c2e2a136cd03eb1f4b4b5ef289d6
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java
index 1fe06d3958295acc8211b7837b172262beb87f92..a35f88cf511c7d0231b1d973250b90b72eaec78c 100644
index 15184e7fc3aeb388fb9de6be2ad72f98fee52044..f18093c5ccacfb55e7c6133cf5212c464e41ead4 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java
@@ -62,8 +62,16 @@ public final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMi
@@ -72,8 +72,16 @@ public final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMi
this.getHandle().explode(power);
}
@ -2309,7 +2288,7 @@ index 2638c341bc02f201f7ab17fdebcdbdf3a7ec05bf..074b2919be2b5544b0a46e6cd32f6c57
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 33e710ed34832876edb138b13cf259c18052333a..b18a2733a03d908b4faa16b2d829d1b96b2d9411 100644
index 5ebcd6b8edc76572a3fffead4735fd5824a083f1..95047bf77be54af6968a6e77f13dd01aa989b4d8 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -674,7 +674,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {

View File

@ -9,10 +9,10 @@ add explicit block update suppression techniques, it's better
than the server crashing.
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 35b18a9ecce6c7b743badbf384f40b48f2fc73be..54bafb8f67361525484c5c58ee8e6568c0801477 100644
index fc180c3f68a40e909f7e357a6fcd06858b870e97..7c18c298e26b2920ea588fc6a16c0baaea9f6fe5 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1966,7 +1966,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -1969,7 +1969,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
Direction enumdirection = (Direction) iterator.next();
BlockPos blockposition1 = pos.relative(enumdirection);

View File

@ -9,10 +9,10 @@ data deserialization and is racey even in Vanilla. But in Folia,
some accesses may throw and as such we need to fix this directly.
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index cb34ed2fe8d1bc087d57eca39f71286d81c7bb71..8c4f658ce87ef49d2b46e50d5957933e1b912b82 100644
index ea3b3f624ab9f4fbdc6ff4e90076b5616728f6ca..759eb33a5b63cae7913907f06e67e0736f50dc13 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -796,7 +796,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
@@ -794,7 +794,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
this.getBukkitEntity().readExtraData(nbt); // CraftBukkit
if (this.isSleeping()) {
@ -22,10 +22,10 @@ index cb34ed2fe8d1bc087d57eca39f71286d81c7bb71..8c4f658ce87ef49d2b46e50d5957933e
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 77eab187d4d6e22e5f8722029107c5613a9a7300..b63393c131f736cd51666c675ac18918e038eca6 100644
index e6871fb4b58910043e88ea45564363aa854eb0ca..73af15d18180b4df3fa0614b323f2397f5543db5 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -4605,6 +4605,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -4612,6 +4612,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
});

View File

@ -7,10 +7,10 @@ This allows the player to be re-positioned before logging into
the world without causing thread checks to trip on Folia.
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 8c4f658ce87ef49d2b46e50d5957933e1b912b82..fb3ea176726fa01c2ab7220432121db4ad5e54ae 100644
index 759eb33a5b63cae7913907f06e67e0736f50dc13..b6f3078fa688ca61cfd45d856b95c160cfe7b2da 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -922,7 +922,13 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
@@ -920,7 +920,13 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
if (world instanceof ServerLevel) {
ServerLevel worldserver = (ServerLevel) world;
CompoundTag nbttagcompound = ((CompoundTag) nbt.get()).getCompound("RootVehicle");

View File

@ -1015,10 +1015,10 @@ index 0000000000000000000000000000000000000000..6e9b04613c5c867a74fa4f266a8ae8e6
+ ) {}
+}
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
index 3a476713964002734a9e67fd9b6dfa497b590657..e176d2d2387e171ff163853131dcf8d1af9a268d 100644
index dbb5b6ee36a54d6682b2a6d9389aee721b95d506..811479551bad422123ad1b09329e6fc8e12c7c4e 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
@@ -1459,7 +1459,9 @@ public final class ChunkHolderManager {
@@ -1461,7 +1461,9 @@ public final class ChunkHolderManager {
}
public boolean processTicketUpdates() {
@ -1463,10 +1463,10 @@ index d6eb8f495688a1b65a4c419aa3ee655cd8eb322a..f338b273613840ed366ab13b528373e7
if (exception instanceof ReportedException) {
ReportedException reportedexception = (ReportedException) exception;
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 28b3a1d2d2bb4bac8abc6f7ca877ce133110a455..ce51c9e98aabf6d4a2a5c8c4eff80608c0dc9bd3 100644
index 9fa5c1628f2df441de47a38e732e7b033c3e2448..be6dc4c066efd66279301f5796451105e323089a 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1713,6 +1713,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1714,6 +1714,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
// Folia start - region threading
public void tickServer(long startTime, long scheduledEnd, long targetBuffer,
io.papermc.paper.threadedregions.TickRegions.TickRegionData region) {
@ -1474,7 +1474,7 @@ index 28b3a1d2d2bb4bac8abc6f7ca877ce133110a455..ce51c9e98aabf6d4a2a5c8c4eff80608
// Folia end - region threading
org.spigotmc.WatchdogThread.tick(); // Spigot
long i = startTime; // Folia - region threading
@@ -1751,6 +1752,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1752,6 +1753,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
}
@ -1482,7 +1482,7 @@ index 28b3a1d2d2bb4bac8abc6f7ca877ce133110a455..ce51c9e98aabf6d4a2a5c8c4eff80608
// Folia start - region threading
if (region != null) {
region.world.getCurrentWorldData().updateTickData();
@@ -1774,10 +1776,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1775,10 +1777,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
new com.destroystokyo.paper.event.server.ServerTickStartEvent((int)region.getCurrentTick()).callEvent(); // Paper - Server Tick Events // Folia - region threading
// Folia start - region threading
if (region != null) {
@ -1499,7 +1499,7 @@ index 28b3a1d2d2bb4bac8abc6f7ca877ce133110a455..ce51c9e98aabf6d4a2a5c8c4eff80608
for (Entity entity : region.world.getCurrentWorldData().getLocalEntitiesCopy()) {
if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity) || entity.isRemoved()) {
continue;
@@ -1785,8 +1793,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1786,8 +1794,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
org.bukkit.craftbukkit.entity.CraftEntity bukkit = entity.getBukkitEntityRaw();
if (bukkit != null) {
bukkit.taskScheduler.executeTick();
@ -1511,7 +1511,7 @@ index 28b3a1d2d2bb4bac8abc6f7ca877ce133110a455..ce51c9e98aabf6d4a2a5c8c4eff80608
}
// Folia end - region threading
if (region == null) this.tickRateManager.tick(); // Folia - region threading
@@ -1805,6 +1816,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1806,6 +1817,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
profiler.push("save");
final boolean fullSave = autosavePeriod > 0 && io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick() % autosavePeriod == 0; // Folia - region threading
@ -1519,7 +1519,7 @@ index 28b3a1d2d2bb4bac8abc6f7ca877ce133110a455..ce51c9e98aabf6d4a2a5c8c4eff80608
try {
this.isSaving = true;
if (playerSaveInterval > 0) {
@@ -1818,6 +1830,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1819,6 +1831,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
} finally {
this.isSaving = false;
}
@ -1527,7 +1527,7 @@ index 28b3a1d2d2bb4bac8abc6f7ca877ce133110a455..ce51c9e98aabf6d4a2a5c8c4eff80608
profiler.pop();
// Paper end - Incremental chunk and player saving
@@ -1900,6 +1913,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1901,6 +1914,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
protected void tickChildren(BooleanSupplier shouldKeepTicking, io.papermc.paper.threadedregions.TickRegions.TickRegionData region) { // Folia - region threading
@ -1535,7 +1535,7 @@ index 28b3a1d2d2bb4bac8abc6f7ca877ce133110a455..ce51c9e98aabf6d4a2a5c8c4eff80608
final io.papermc.paper.threadedregions.RegionizedWorldData regionizedWorldData = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegionizedWorldData(); // Folia - regionised ticking
ProfilerFiller gameprofilerfiller = Profiler.get();
@@ -1964,7 +1978,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1965,7 +1979,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
gameprofilerfiller.push("tick");
try {
@ -1545,7 +1545,7 @@ index 28b3a1d2d2bb4bac8abc6f7ca877ce133110a455..ce51c9e98aabf6d4a2a5c8c4eff80608
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
@@ -1979,8 +1995,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1980,8 +1996,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
if (region == null) this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked // Folia - region threading
gameprofilerfiller.popPush("connection");
@ -1608,10 +1608,10 @@ index 1668011de11a5ed513815fa1b547ff3a7636cc13..74cd86aea1a82f169cb50dac14a8973c
// Paper end - optimise entity tracker
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 16001634fef7573e5363d2903e2b665bc12d3431..a5fc3187438467d24a3143a01188824bb7120b2a 100644
index 1a43c6fba5eea514dd6cf406f600dc254282da35..ca47a512452ae425160e30dc7c4a79f40aa97a26 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -455,18 +455,25 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -462,18 +462,25 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@Override
public void tick(BooleanSupplier shouldKeepTicking, boolean tickChunks) {
@ -1637,7 +1637,7 @@ index 16001634fef7573e5363d2903e2b665bc12d3431..a5fc3187438467d24a3143a01188824b
this.chunkMap.tick();
}
@@ -478,6 +485,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -485,6 +492,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
private void tickChunks() {
io.papermc.paper.threadedregions.RegionizedWorldData regionizedWorldData = this.level.getCurrentWorldData(); // Folia - region threading
@ -1645,7 +1645,7 @@ index 16001634fef7573e5363d2903e2b665bc12d3431..a5fc3187438467d24a3143a01188824b
//long i = this.level.getGameTime(); // Folia - region threading
long j = 1L; // Folia - region threading
@@ -491,7 +499,9 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -498,7 +506,9 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
try {
gameprofilerfiller.push("filteringTickingChunks");
@ -1655,7 +1655,7 @@ index 16001634fef7573e5363d2903e2b665bc12d3431..a5fc3187438467d24a3143a01188824b
gameprofilerfiller.popPush("shuffleChunks");
// Paper start - chunk tick iteration optimisation
this.shuffleRandom.setSeed(this.level.random.nextLong());
@@ -504,7 +514,9 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -511,7 +521,9 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
}
}
@ -1665,7 +1665,7 @@ index 16001634fef7573e5363d2903e2b665bc12d3431..a5fc3187438467d24a3143a01188824b
gameprofilerfiller.pop();
}
}
@@ -552,11 +564,13 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -559,11 +571,13 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
private void tickChunks(ProfilerFiller profiler, long timeDelta, List<LevelChunk> chunks) {
io.papermc.paper.threadedregions.RegionizedWorldData regionizedWorldData = this.level.getCurrentWorldData(); // Folia - region threading
@ -1679,7 +1679,7 @@ index 16001634fef7573e5363d2903e2b665bc12d3431..a5fc3187438467d24a3143a01188824b
if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled
// re-set mob counts
for (ServerPlayer player : this.level.getLocalPlayers()) { // Folia - region threading
@@ -576,6 +590,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -583,6 +597,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
} else {
spawnercreature_d = NaturalSpawner.createState(naturalSpawnChunkCount, regionizedWorldData.getLoadedEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false); // Folia - region threading - note: function only cares about loaded entities, doesn't need all
}
@ -1687,7 +1687,7 @@ index 16001634fef7573e5363d2903e2b665bc12d3431..a5fc3187438467d24a3143a01188824b
// Paper end - Optional per player mob spawns
regionizedWorldData.lastSpawnState = spawnercreature_d; // Folia - region threading
@@ -602,6 +617,9 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -609,6 +624,9 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
Iterator iterator = chunks.iterator();
@ -1697,7 +1697,7 @@ index 16001634fef7573e5363d2903e2b665bc12d3431..a5fc3187438467d24a3143a01188824b
while (iterator.hasNext()) {
LevelChunk chunk = (LevelChunk) iterator.next();
ChunkPos chunkcoordintpair = chunk.getPos();
@@ -615,10 +633,15 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -622,10 +640,15 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
this.level.tickChunk(chunk, k);
}
}
@ -1714,10 +1714,10 @@ index 16001634fef7573e5363d2903e2b665bc12d3431..a5fc3187438467d24a3143a01188824b
}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index cb2c0358fb462c4a5ebf94299119c2081dc5f78f..cd1af13c91b215d896618fa0f2790da1a53ea80a 100644
index 6fe476d8014ab7540309d0b1c7ef6377cea94d8c..c682c92842168d47856075dd84e53d2c180298a0 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -725,6 +725,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -726,6 +726,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
public void tick(BooleanSupplier shouldKeepTicking, io.papermc.paper.threadedregions.TickRegions.TickRegionData region) { // Folia - regionised ticking
final io.papermc.paper.threadedregions.RegionizedWorldData regionizedWorldData = this.getCurrentWorldData(); // Folia - regionised ticking
@ -1725,7 +1725,7 @@ index cb2c0358fb462c4a5ebf94299119c2081dc5f78f..cd1af13c91b215d896618fa0f2790da1
ProfilerFiller gameprofilerfiller = Profiler.get();
regionizedWorldData.setHandlingTick(true); // Folia - regionised ticking
@@ -753,22 +754,32 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -754,22 +755,32 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
if (!this.isDebug() && flag) {
j = regionizedWorldData.getRedstoneGameTime(); // Folia - region threading
gameprofilerfiller.push("blockTicks");
@ -1758,7 +1758,7 @@ index cb2c0358fb462c4a5ebf94299119c2081dc5f78f..cd1af13c91b215d896618fa0f2790da1
}
regionizedWorldData.setHandlingTick(false); // Folia - regionised ticking
@@ -782,6 +793,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -783,6 +794,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
if (flag1 || this.emptyTime++ < 300) {
gameprofilerfiller.push("entities");
if (this.dragonFight != null && flag) {
@ -1766,7 +1766,7 @@ index cb2c0358fb462c4a5ebf94299119c2081dc5f78f..cd1af13c91b215d896618fa0f2790da1
if (ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this, this.dragonFight.origin)) { // Folia - region threading
gameprofilerfiller.push("dragonFight");
this.dragonFight.tick();
@@ -794,9 +806,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -795,9 +807,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
fightCenter
);
} // Folia end - region threading
@ -1780,7 +1780,7 @@ index cb2c0358fb462c4a5ebf94299119c2081dc5f78f..cd1af13c91b215d896618fa0f2790da1
regionizedWorldData.forEachTickingEntity((entity) -> { // Folia - regionised ticking
if (!entity.isRemoved()) {
if (!tickratemanager.isEntityFrozen(entity)) {
@@ -822,8 +838,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -823,8 +839,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
}
}
});
@ -1792,7 +1792,7 @@ index cb2c0358fb462c4a5ebf94299119c2081dc5f78f..cd1af13c91b215d896618fa0f2790da1
}
gameprofilerfiller.push("entityManagement");
@@ -885,12 +904,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -886,12 +905,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
}
public void tickCustomSpawners(boolean spawnMonsters, boolean spawnAnimals) {
@ -1808,7 +1808,7 @@ index cb2c0358fb462c4a5ebf94299119c2081dc5f78f..cd1af13c91b215d896618fa0f2790da1
}
}
@@ -1345,6 +1367,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1346,6 +1368,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
});
gameprofilerfiller.incrementCounter("tickNonPassenger");
final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity); // Paper - EAR 2
@ -1821,7 +1821,7 @@ index cb2c0358fb462c4a5ebf94299119c2081dc5f78f..cd1af13c91b215d896618fa0f2790da1
if (isActive) { // Paper - EAR 2
entity.tick();
// Folia start - region threading
@@ -1359,6 +1387,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1360,6 +1388,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
// Folia end - region threading
} else { entity.inactiveTick(); } // Paper - EAR 2
gameprofilerfiller.pop();
@ -1829,7 +1829,7 @@ index cb2c0358fb462c4a5ebf94299119c2081dc5f78f..cd1af13c91b215d896618fa0f2790da1
Iterator iterator = entity.getPassengers().iterator();
while (iterator.hasNext()) {
@@ -1377,6 +1406,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1378,6 +1407,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
private void tickPassenger(Entity vehicle, Entity passenger, boolean isActive) { // Paper - EAR 2
if (!passenger.isRemoved() && passenger.getVehicle() == vehicle) {
if (passenger instanceof Player || this.getCurrentWorldData().hasEntityTickingEntity(passenger)) { // Folia - region threading
@ -1842,7 +1842,7 @@ index cb2c0358fb462c4a5ebf94299119c2081dc5f78f..cd1af13c91b215d896618fa0f2790da1
passenger.setOldPosAndRot();
++passenger.tickCount;
ProfilerFiller gameprofilerfiller = Profiler.get();
@@ -1414,6 +1449,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1415,6 +1450,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
this.tickPassenger(passenger, entity2, isActive); // Paper - EAR 2
}
@ -1851,7 +1851,7 @@ index cb2c0358fb462c4a5ebf94299119c2081dc5f78f..cd1af13c91b215d896618fa0f2790da1
} else {
passenger.stopRiding();
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index c5b67dccdd15d3d8a7d950d397eeffba392bec17..995ea080be9ee8e3b246723e115e312d2f0984bb 100644
index c1574cdea90731dec4d24b15979209cce0c581af..a809622f43a45fd77bbb07a24f21c841a90dc07a 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -1258,6 +1258,7 @@ public abstract class PlayerList {
@ -1873,7 +1873,7 @@ index c5b67dccdd15d3d8a7d950d397eeffba392bec17..995ea080be9ee8e3b246723e115e312d
}
// Paper end - Incremental chunk and player saving
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
index c8c2394558952d7ca57d29874485251b8f2b3400..0d18403c6c25555f78e2d6810520839f30258c8e 100644
index d23914a3ab3723d532ae867db6b954c843030f75..635c9c7a8c8307c2bc845a8e1f24aacb526a3c92 100644
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
@@ -412,7 +412,20 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
@ -1898,7 +1898,7 @@ index c8c2394558952d7ca57d29874485251b8f2b3400..0d18403c6c25555f78e2d6810520839f
this.builtInRegistryHolder = BuiltInRegistries.ENTITY_TYPE.createIntrusiveHolder(this);
this.factory = factory;
this.category = spawnGroup;
@@ -963,7 +976,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
@@ -977,7 +990,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
Util.fetchChoiceType(References.ENTITY_TREE, registryKey.location().toString());
}
@ -1908,10 +1908,10 @@ index c8c2394558952d7ca57d29874485251b8f2b3400..0d18403c6c25555f78e2d6810520839f
}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 54bafb8f67361525484c5c58ee8e6568c0801477..3d96f7ae648b47cc7494578d9776e7ea6dee0964 100644
index 7c18c298e26b2920ea588fc6a16c0baaea9f6fe5..456f15e44e41d65338c0346594be2b0042b84005 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -204,6 +204,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -205,6 +205,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
public final ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup moonrise$getEntityLookup() {
return this.entityLookup;
}
@ -1921,7 +1921,7 @@ index 54bafb8f67361525484c5c58ee8e6568c0801477..3d96f7ae648b47cc7494578d9776e7ea
@Override
public final void moonrise$setEntityLookup(final ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup entityLookup) {
@@ -936,6 +939,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -937,6 +940,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime);
this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : com.destroystokyo.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray
this.entityLookup = new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.dfl.DefaultEntityLookup(this); // Paper - rewrite chunk system
@ -1931,7 +1931,7 @@ index 54bafb8f67361525484c5c58ee8e6568c0801477..3d96f7ae648b47cc7494578d9776e7ea
}
// Paper start - Cancel hit for vanished players
@@ -1480,14 +1486,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -1481,14 +1487,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
}
protected void tickBlockEntities() {
@ -1950,7 +1950,7 @@ index 54bafb8f67361525484c5c58ee8e6568c0801477..3d96f7ae648b47cc7494578d9776e7ea
// Spigot start
// Iterator<TickingBlockEntity> iterator = this.blockEntityTickers.iterator();
boolean flag = this.tickRateManager().runsNormally();
@@ -1516,6 +1526,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -1517,6 +1527,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
}
}
blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075 // Folia - regionised ticking
@ -1959,31 +1959,33 @@ index 54bafb8f67361525484c5c58ee8e6568c0801477..3d96f7ae648b47cc7494578d9776e7ea
regionizedWorldData.seTtickingBlockEntities(false); // Folia - regionised ticking
gameprofilerfiller.pop();
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java
index dea945a9b278353647dca3ed001158c198dab668..422c9aeb761092496089a1b2e1dd9c5fe8f5b2bc 100644
index 63c5bc786010d96dc121ee14dbac99253b3c8168..47e9a10c8d1f12dff335cda787ce720357bdd969 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java
@@ -245,10 +245,14 @@ public class BlockEntityType<T extends BlockEntity> {
@@ -81,11 +81,14 @@ public class BlockEntityType<T extends BlockEntity> {
BlockEntityType.LOGGER.warn("Block entity type {} requires at least one valid block to be defined!", id);
}
Util.fetchChoiceType(References.BLOCK_ENTITY, id);
- return Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id, new BlockEntityType<>(blockEntitySupplier, Set.of(blocks)));
+ return Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id, new BlockEntityType<>(blockEntitySupplier, Set.of(blocks), id)); // Folia - profiler
}
- Util.fetchChoiceType(References.BLOCK_ENTITY, id);
- return (BlockEntityType) Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id, new BlockEntityType<>(factory, Set.of(blocks)));
- }
- private BlockEntityType(BlockEntityType.BlockEntitySupplier<? extends T> factory, Set<Block> blocks) {
+ return (BlockEntityType) Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id, new BlockEntityType<>(factory, Set.of(blocks), id)); // Folia - profiler
+ }
+ // Folia start - profiler
+ public final int tileEntityTimingId;
+ private BlockEntityType(BlockEntityType.BlockEntitySupplier<? extends T> factory, Set<Block> blocks, String id) {
+ this.tileEntityTimingId = ca.spottedleaf.leafprofiler.LProfilerRegistry.GLOBAL_REGISTRY.getOrCreateTimer("Tile Entity Tick: " + id);
+ // Folia end - profiler
this.builtInRegistryHolder = BuiltInRegistries.BLOCK_ENTITY_TYPE.createIntrusiveHolder(this);
this.factory = factory;
this.validBlocks = blocks;
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 877f68f9abfc659f489d6571efc1b431e1240ed6..4bccb94cf953ebd4dfd4f1620ad1784ef235356f 100644
index 2c421ddb759eae4fbf2f2420d3b8cab22e854b85..6003e3495e61073c39928918b9d9f4c2e20f3a49 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -1074,10 +1074,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
@@ -1079,10 +1079,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
BlockPos blockposition = this.blockEntity.getBlockPos();
if (LevelChunk.this.isTicking(blockposition)) {
@ -1997,7 +1999,7 @@ index 877f68f9abfc659f489d6571efc1b431e1240ed6..4bccb94cf953ebd4dfd4f1620ad1784e
BlockState iblockdata = LevelChunk.this.getBlockState(blockposition);
if (this.blockEntity.getType().isValid(iblockdata)) {
@@ -1092,6 +1095,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
@@ -1097,6 +1100,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
}
// Paper end - Remove the Block Entity if it's invalid
}