Update to 1.21.3

This commit is contained in:
Spottedleaf 2024-11-27 07:54:37 -08:00
parent 2e7bc0721a
commit be8908e2b2
24 changed files with 2725 additions and 2300 deletions

View File

@ -12,16 +12,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Git Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/actions/wrapper-validation@v4
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/actions/setup-gradle@v4
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
- name: Configure Git User Details
run: git config --global user.email "actions@github.com" && git config --global user.name "Github Actions"
- name: Apply Patches

View File

@ -3,7 +3,7 @@ import io.papermc.paperweight.tasks.RebuildGitPatches
plugins {
java
`maven-publish`
id("io.papermc.paperweight.patcher") version "1.7.3"
id("io.papermc.paperweight.patcher") version "1.7.5"
}
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"

View File

@ -1,8 +1,8 @@
group=dev.folia
version=1.21.1-R0.1-SNAPSHOT
mcVersion=1.21.1
version=1.21.3-R0.1-SNAPSHOT
mcVersion=1.21.3
paperRef=84281ceeefb9d294758a9a292ba6c01da40e8409
paperRef=afb5b13056ebbcdd3ae834c039046ecad4fa89eb
org.gradle.caching=true
org.gradle.parallel=true

Binary file not shown.

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

5
gradlew vendored
View File

@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

2
gradlew.bat vendored
View File

@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################

View File

@ -6,48 +6,14 @@ Subject: [PATCH] Force disable timings
Need a new profiler system with region threading
diff --git a/src/main/java/co/aikar/timings/Timings.java b/src/main/java/co/aikar/timings/Timings.java
index e81d0bc309de877ed2b5da6122f55c162e9b5f10..7760c779e97a0e95d5c3d255b25d949ac20df235 100644
index 95b7cdf0677ef71e6885fa78aa5c75bb500f5f53..89017af09ce32e7a66014fc3aeb50155921252a5 100644
--- a/src/main/java/co/aikar/timings/Timings.java
+++ b/src/main/java/co/aikar/timings/Timings.java
@@ -145,13 +145,14 @@ public final class Timings {
@@ -145,6 +145,7 @@ public final class Timings {
* @param enabled Should timings be reported
*/
public static void setTimingsEnabled(boolean enabled) {
+ enabled = false; // Folia - region threading - disable timings
timingsEnabled = enabled;
warnAboutDeprecationOnEnable();
reset();
}
private static void warnAboutDeprecationOnEnable() {
- if (timingsEnabled && !warnedAboutDeprecationOnEnable) {
+ if ((true || timingsEnabled) && !warnedAboutDeprecationOnEnable) { // Folia
Bukkit.getLogger().warning(PlainTextComponentSerializer.plainText().serialize(deprecationMessage()));
if (enabled && !warnedAboutDeprecationOnEnable) {
Bukkit.getLogger().severe(PlainTextComponentSerializer.plainText().serialize(deprecationMessage()));
warnedAboutDeprecationOnEnable = true;
}
@@ -159,8 +160,8 @@ public final class Timings {
public static Component deprecationMessage() {
return Component.text()
- .color(TextColor.color(0xffc93a))
- .append(Component.text("[!] The timings profiler has been enabled but has been scheduled for removal from Paper in the future."))
+ .color(TextColor.color(0xf39195)) // Folia
+ .append(Component.text("[!] The timings system cannot be enabled on Folia, and has been scheduled for removal from Paper in the future.")) // Folia
.append(Component.newline())
.append(Component.text(" We recommend migrating to the spark profiler."))
.append(Component.newline())
diff --git a/src/main/java/co/aikar/timings/TimingsCommand.java b/src/main/java/co/aikar/timings/TimingsCommand.java
index 95d87c9dbf2b237787294dfbe7fed87a36e6dedf..b83e5ff7ada8771fdf27ba9807c77ba6a4ce12da 100644
--- a/src/main/java/co/aikar/timings/TimingsCommand.java
+++ b/src/main/java/co/aikar/timings/TimingsCommand.java
@@ -56,8 +56,9 @@ public class TimingsCommand extends BukkitCommand {
if (!testPermission(sender)) {
return true;
}
- if (false) {
+ if (true) {
sender.sendMessage(Timings.deprecationMessage());
+ return true;
}
if (args.length < 1) {
sender.sendMessage(text("Usage: " + this.usageMessage, NamedTextColor.RED));

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 003bece642b682985625db93cad93026352bfc66..065352b383d6398382b4f14641859dbfe2e6a355 100644
index b878e7167cfcdea0e224c182b40abeadd339d3b3..9611e8e254b4fa9579dc9ffd5198182c43819c56 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 {

View File

@ -1,46 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Tue, 7 Mar 2023 14:34:09 -0800
Subject: [PATCH] Add API for checking ownership of region by position/entity
This may be useful for plugins which want to perform operations
over large areas outside of the buffer zone provided by the
regionaliser, as it is not guaranteed that anything outside
of the buffer zone is owned. Then, the plugins may use
the schedulers depending on the result of the ownership
check.
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index e20e4239a5a1f952e1c70e899549989d5e42f73c..60ac226b58981155649b7d67c11385a0c105eca0 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2916,6 +2916,14 @@ public final class Bukkit {
return server.isOwnedByCurrentRegion(entity);
}
// Paper end - Folia region threading API
+ // Folia start - region threading API
+ /**
+ * Returns whether the current thread is ticking the global region.
+ */
+ public static boolean isGlobalTickThread() {
+ return server.isGlobalTickThread();
+ }
+ // Folia end - region threading API
@NotNull
public static Server.Spigot spigot() {
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 6246251caf2c6f025c824b8e7a944b8d48751fa1..10f6eb1756de71960f1c0565366d5f262c7641f1 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2554,4 +2554,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
boolean isOwnedByCurrentRegion(@NotNull Entity entity);
// Paper end - Folia region threading API
+ // Folia start - region threading API
+ /**
+ * Returns whether the current thread is ticking the global region.
+ */
+ public boolean isGlobalTickThread();
+ // Folia end - region threading API
}

View File

@ -5,19 +5,19 @@ Subject: [PATCH] Build changes
diff --git a/build.gradle.kts b/build.gradle.kts
index de0474b8dce58cb419c00b7614d7dd66be832a02..c2f2ba1df68e9823c56287f1bea23fb6d6a781a2 100644
index faf3e3fd72e8c915e7a4803dacbe1bb576c6663e..142714c7d47eb5de937ad385c81968148a7e4828 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -13,7 +13,7 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) {
val alsoShade: Configuration by configurations.creating
@@ -25,7 +25,7 @@ abstract class MockitoAgentProvider : CommandLineArgumentProvider {
// Paper end - configure mockito agent that is needed in newer java versions
dependencies {
- implementation(project(":paper-api"))
+ implementation(project(":folia-api")) // Folia
// Paper start
implementation("org.jline:jline-terminal-jansi:3.21.0")
implementation("net.minecrell:terminalconsoleappender:1.3.0")
@@ -85,14 +85,14 @@ tasks.jar {
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 {
val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper
attributes(
"Main-Class" to "org.bukkit.craftbukkit.Main",
@ -36,7 +36,7 @@ index de0474b8dce58cb419c00b7614d7dd66be832a02..c2f2ba1df68e9823c56287f1bea23fb6
"Build-Number" to (build ?: ""),
"Build-Time" to Instant.now().toString(),
"Git-Branch" to gitBranch, // Paper
@@ -153,7 +153,7 @@ fun TaskContainer.registerRunTask(
@@ -172,7 +172,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

@ -6,7 +6,7 @@ Subject: [PATCH] Max pending logins
Should help the floodgates on launch
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 9451cccebf7acee3bd9f28f4f9d60412d1554ff4..8098b1a447a7c054e15edc09d2fa50e48f73e926 100644
index 7fdb9304de7cf1979d57e3fac32415d7c674609d..227d62a69a453d49c28568ecb41ecef85a35405b 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -117,7 +117,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
@ -19,7 +19,7 @@ index 9451cccebf7acee3bd9f28f4f9d60412d1554ff4..8098b1a447a7c054e15edc09d2fa50e4
// 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 45830e2f6b2f745430cb38e86678d066101656e4..98064cb4c99929ed109dac928c302c87631ad539 100644
index c681c814046e6993a9ff6fa3545c4748452c0fb2..577f41c32bc4ebeb8a040bb86a695a10c69b3ce8 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

@ -5,10 +5,10 @@ Subject: [PATCH] Add chunk system throughput counters to /tps
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkFullTask.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkFullTask.java
index fbdf721e8b4cfe6cef4ee60c53c680cbfc858d88..8581b8771b8cc89ff7bdb63fbfd5628a1e7d4762 100644
index 6ab353b0d2465c3680bb3c8d0852ba0f65c00fd2..4ad647a9f98cf1c11c45f85edcba3c29e343c236 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkFullTask.java
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkFullTask.java
@@ -28,6 +28,9 @@ public final class ChunkFullTask extends ChunkProgressionTask implements Runnabl
@@ -30,6 +30,9 @@ public final class ChunkFullTask extends ChunkProgressionTask implements Runnabl
private final ChunkAccess fromChunk;
private final PrioritisedExecutor.PrioritisedTask convertToFullTask;
@ -16,9 +16,9 @@ index fbdf721e8b4cfe6cef4ee60c53c680cbfc858d88..8581b8771b8cc89ff7bdb63fbfd5628a
+ public static final io.papermc.paper.util.IntervalledCounter chunkGenerates = new io.papermc.paper.util.IntervalledCounter(java.util.concurrent.TimeUnit.SECONDS.toNanos(15L));
+
public ChunkFullTask(final ChunkTaskScheduler scheduler, final ServerLevel world, final int chunkX, final int chunkZ,
final NewChunkHolder chunkHolder, final ChunkAccess fromChunk, final PrioritisedExecutor.Priority priority) {
final NewChunkHolder chunkHolder, final ChunkAccess fromChunk, final Priority priority) {
super(scheduler, world, chunkX, chunkZ);
@@ -41,6 +44,20 @@ public final class ChunkFullTask extends ChunkProgressionTask implements Runnabl
@@ -43,6 +46,20 @@ public final class ChunkFullTask extends ChunkProgressionTask implements Runnabl
return ChunkStatus.FULL;
}
@ -38,8 +38,8 @@ index fbdf721e8b4cfe6cef4ee60c53c680cbfc858d88..8581b8771b8cc89ff7bdb63fbfd5628a
+
@Override
public void run() {
// See Vanilla ChunkPyramid#LOADING_PYRAMID.FULL for what this function should be doing
@@ -55,6 +72,17 @@ public final class ChunkFullTask extends ChunkProgressionTask implements Runnabl
final PlatformHooks platformHooks = PlatformHooks.get();
@@ -59,6 +76,17 @@ public final class ChunkFullTask extends ChunkProgressionTask implements Runnabl
((ChunkSystemPoiManager)this.world.getPoiManager()).moonrise$checkConsistency(this.fromChunk);
}

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 4aefadd491f1c0c541d23fcaeaf03fd2ae995f3e..2ccc358daae43dcebf03db64526f17fbd9df23f8 100644
index ad358909318a7e52d43e9dfb5cc7e6aa5674b9fd..451d4cf162e39acd7ed215f82a5a84f6be6e166a 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3046,6 +3046,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3214,6 +3214,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 4aefadd491f1c0c541d23fcaeaf03fd2ae995f3e..2ccc358daae43dcebf03db64526f17fb
// CraftBukkit start
if (entity.getBukkitEntity() instanceof Vehicle && this.getBukkitEntity() instanceof LivingEntity) {
VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.getBukkitEntity());
@@ -3067,6 +3068,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3235,6 +3236,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return false;
}
// CraftBukkit end
@ -48,7 +48,7 @@ index 4aefadd491f1c0c541d23fcaeaf03fd2ae995f3e..2ccc358daae43dcebf03db64526f17fb
if (this.isPassenger()) {
this.stopRiding();
}
@@ -3150,6 +3152,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3318,6 +3320,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 4aefadd491f1c0c541d23fcaeaf03fd2ae995f3e..2ccc358daae43dcebf03db64526f17fb
CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
Entity orig = craft == null ? null : craft.getHandle();
if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
@@ -3177,6 +3180,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3345,6 +3348,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return false;
}
// CraftBukkit end
@ -98,10 +98,10 @@ index 591af9d0d2fdc9953415979fc97a4a00afd85885..4a0fd1e3203342b7a5ffde579947057f
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java
index 501e2aa3a10dae94c4a8d9dfcdc902e434fcca62..865419a80712e111aeb1e436ff9c27fa4b6f37fb 100644
index d0c30fd12aa9866900fe72b97d10c257479cf010..46d8cbe8d09cf43b489d0358498e937454d96e7b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java
@@ -130,6 +130,7 @@ public class CraftAbstractArrow extends AbstractProjectile implements AbstractAr
@@ -133,6 +133,7 @@ public class CraftAbstractArrow extends AbstractProjectile implements AbstractAr
@Override
public net.minecraft.world.entity.projectile.AbstractArrow getHandle() {
@ -270,7 +270,7 @@ index ab42bc721d5b6c17c2ca6c7153b757571aea05e8..e48528689d49c01aa2b0c1599c66f3c1
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java
index 88f2a9f310f30a08893f3fa68af13a54cf72fa7f..b0cf5c7ee2542985ea704da26d36b272271ad096 100644
index f9c113dc018702159345240d6d0de85767afa0c3..0872943dc4e5895728d12289cb23682c9bef290c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java
@@ -28,8 +28,16 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud
@ -303,7 +303,7 @@ index e7f2d8de25a489d7f52c78c750e6f7f9b8fee177..75191dd32bba12b5742702a2af151b10
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
index 9fe85d6f807e64cf02d8e1921672e3196f6d606f..8a95bc7b1250d47f518a62e625e78a7910ead7ff 100644
index 184fe8257e5ffb0ef090ffa2833786a4db8b59ea..6c5358f77be3e46860b0c3c49d36b25286af6851 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
@@ -20,8 +20,16 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
@ -324,7 +324,7 @@ index 9fe85d6f807e64cf02d8e1921672e3196f6d606f..8a95bc7b1250d47f518a62e625e78a79
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
index 071be344c3265a0cd52b31ffbb02ff7a70bdf231..0152b1ba40f505bfb5ba941f6d6d0a22d825519a 100644
index 15d50a284cafc2eb59239ca00926836526f09e06..dc455a211005f70754f3b99213b22e85821c216f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
@@ -26,6 +26,7 @@ public class CraftArrow extends CraftAbstractArrow implements Arrow {
@ -433,6 +433,27 @@ index a4c9c73691300880777483b0beb17e1bd6779d06..05951297aaed63c22f038703ad6fb68d
return (net.minecraft.world.entity.monster.Blaze) this.entity;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockAttachedEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockAttachedEntity.java
index 5b0dd9aae3fbd9257d0375a37a07c812199d64a2..d22538ecda7685093f400ee560ae53c206ed62b2 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockAttachedEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockAttachedEntity.java
@@ -8,8 +8,16 @@ public class CraftBlockAttachedEntity extends CraftEntity {
super(server, entity);
}
+ // Folia start - region threading
+ @Override
+ public BlockAttachedEntity getHandleRaw() {
+ return (BlockAttachedEntity)this.entity;
+ }
+ // Folia end - region threading
+
@Override
public BlockAttachedEntity getHandle() {
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading
return (BlockAttachedEntity) this.entity;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java
index dd91de8f24c27b9318c2a898a49991d74c100bff..b951571eda47da97ee73ba7d9b71b4f6cf0373d6 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java
@ -455,24 +476,24 @@ index dd91de8f24c27b9318c2a898a49991d74c100bff..b951571eda47da97ee73ba7d9b71b4f6
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java
index 01a9660de65688b7c1a4f9dafcb650774ce1853b..869524adfe5cb14b3cbd71a76f340bc9343b9e24 100644
index 2a2839c31989d127739d829159a8b6e5b9a5210b..fb87800c02d5ff9bcb197170c11e305273cea083 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java
@@ -102,8 +102,16 @@ public class CraftBoat extends CraftVehicle implements Boat, io.papermc.paper.en
@@ -101,8 +101,16 @@ public abstract class CraftBoat extends CraftVehicle implements Boat, io.papermc
return CraftBoat.boatStatusFromNms(this.getHandle().status);
}
+ // Folia start - region threading
+ @Override
+ public net.minecraft.world.entity.vehicle.Boat getHandleRaw() {
+ return (net.minecraft.world.entity.vehicle.Boat)this.entity;
+ public AbstractBoat getHandleRaw() {
+ return (AbstractBoat)this.entity;
+ }
+ // Folia end - region threading
+
@Override
public net.minecraft.world.entity.vehicle.Boat getHandle() {
public AbstractBoat getHandle() {
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading
return (net.minecraft.world.entity.vehicle.Boat) this.entity;
return (AbstractBoat) this.entity;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java
@ -488,10 +509,10 @@ index e8e4704304504e69c7964dcd4df8ce5db9e92bf6..20630858d00fa23e911ec38788df971a
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBreeze.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBreeze.java
index 3f3d087387d3169f352d7377c0e5a24668c3d17e..fd22213bc7a8461f5e698792c426384683fb3b7b 100644
index 7648e2c700a55f9c0b3539dc720903238d138d54..b21f1654ddd2a4d7c85baae44fef10842905fbf9 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBreeze.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBreeze.java
@@ -11,6 +11,7 @@ public class CraftBreeze extends CraftMonster implements Breeze {
@@ -13,6 +13,7 @@ public class CraftBreeze extends CraftMonster implements Breeze {
@Override
public net.minecraft.world.entity.monster.breeze.Breeze getHandle() {
@ -575,24 +596,24 @@ index 4f661fbdb860cf550da0d952b775fe6f990b43b3..2dfbfbbe98815a303516d88e6ea96b9f
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java
index e4f899a6a1d055b3ea17d1114ed0228fbba53352..4d9bb569b6a957c4ebd06f93d36a0f351961fd23 100644
index a1e04bb965f18ffd07e2f5bf827c5e4ddd6aeeda..8ba8189ddff9f35a60c31015cccf6480246cf21c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java
@@ -15,8 +15,16 @@ public class CraftChestBoat extends CraftBoat implements org.bukkit.entity.Chest
@@ -15,8 +15,16 @@ public abstract class CraftChestBoat extends CraftBoat implements org.bukkit.ent
this.inventory = new CraftInventory(entity);
}
+ // Folia start - region threading
+ @Override
+ public ChestBoat getHandleRaw() {
+ return (ChestBoat)this.entity;
+ public AbstractChestBoat getHandleRaw() {
+ return (AbstractChestBoat)this.entity;
+ }
+ // Folia end - region threading
+
@Override
public ChestBoat getHandle() {
public AbstractChestBoat getHandle() {
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading
return (ChestBoat) this.entity;
return (AbstractChestBoat) this.entity;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java
@ -700,6 +721,48 @@ index 7babc404e4920cd264206d4e83b1be6f841cdb8c..7a5312ab0fe3a21907a1d6b82fab9b4d
return (net.minecraft.world.entity.animal.Cow) this.entity;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreaking.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreaking.java
index 267f3c85058ef7c73e372c04493cfa6c907e44bb..df838d551fa08895e390eb793506e2f3697555f4 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreaking.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreaking.java
@@ -9,8 +9,16 @@ public class CraftCreaking extends CraftMonster implements org.bukkit.entity.Cre
super(server, entity);
}
+ // Folia start - region threading
+ @Override
+ public Creaking getHandleRaw() {
+ return (Creaking)this.entity;
+ }
+ // Folia end - region threading
+
@Override
public Creaking getHandle() {
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading
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
@ -769,10 +832,10 @@ index 48eeb1d9ba0ad6f895bfe507a6fbe4b9c9530e47..65301b94dc8d813c487deff24cd04b37
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java
index f93f8f6509b12eb9b1e07c829278bb0822dd7988..2c3c2d7f51c60a5ece610edd0bb00cba3b9d5981 100644
index 83867b9c5497e6e793b21c482646cc419587e182..55dfb073e4355e68855580f26464af6cf1c6ac33 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java
@@ -9,8 +9,16 @@ public class CraftDolphin extends CraftWaterMob implements Dolphin {
@@ -9,8 +9,16 @@ public class CraftDolphin extends CraftAgeable implements Dolphin {
super(server, entity);
}
@ -979,19 +1042,10 @@ index d657fd2c507a5b215aeab0a5f3e9c2ee892a27c8..399ef60ab5f1bf02b638c8c46a72d297
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 88dd653f3c7871cae5983f4a0f62af0f3dd1bd99..7be80f2774b5ec3d0bede096da8f2b6d1cf7b09b 100644
index 5168cf0d58013aecfd80d37fb698014f38f8e08d..982778c4828e79bc7a55745418beb04f9c56cc78 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -498,7 +498,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@Override
public UUID getUniqueId() {
- return this.getHandle().getUUID();
+ return this.getHandleRaw().getUUID(); // Folia - region threading
}
@Override
@@ -513,6 +513,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -514,6 +514,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
public Entity getHandle() {
@ -1189,7 +1243,7 @@ index 8117faa0c89a966d057f4bf251c03a09d1e8797e..7c3827e6ef608ff15be9bced4788b09f
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java
index c455deb4fd2a7684bcc01a8212c362a2375c190b..5f0ddb932df148859dc6a699082934cac8d48fcf 100644
index bb2b59ce9775a0d1dd9828885e57c14cf40d9f04..90dcbf746c5effa98c09059552674a3e428ac1b9 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java
@@ -14,8 +14,16 @@ public class CraftFox extends CraftAnimals implements Fox {
@ -1441,7 +1495,7 @@ index 9b6ff0f64966c78a3233860bb0840182b52f01bc..fb34651a9e4ed0cb05721d15524a26f8
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
index 7dcfb45c24d7743956be514c7d554e06aac77b3e..6a052ed8d66a62b42c98a3b1d60263dd8018fed1 100644
index e345cdbfab44a0f5da80d738798dbb4424b7ab5c..2a4ed66335e4fd88aefabb063ec04fe803bc728e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -298,8 +298,16 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@ -1677,10 +1731,10 @@ 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 57b71a3894638253c6d24d4967a96768834bb02b..a82e2be0d104fefbf9a213256b82b3354fd1c098 100644
index d0c409f4efad289e3e325f44b500fc72589d89d4..828d371cda28d68246c721a44331bd3f145db3a5 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -478,6 +478,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@@ -487,6 +487,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
this.getHandle().invulnerableTime = ticks;
}
@ -1694,7 +1748,7 @@ index 57b71a3894638253c6d24d4967a96768834bb02b..a82e2be0d104fefbf9a213256b82b335
@Override
public int getNoActionTicks() {
return this.getHandle().getNoActionTime();
@@ -491,6 +498,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@@ -500,6 +507,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override
public net.minecraft.world.entity.LivingEntity getHandle() {
@ -1787,10 +1841,10 @@ index e6782a48d22ba1e683e3fe463e970e8a5ed60fbd..afaa4570c1991cd4260ffcdba823ba24
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
index 8920af5a0dfe737c1f38d906b53e6a278456d2aa..5652ec4aea839fae3f8ea31d7cd5c80ecf129fb5 100644
index b42bce0c4f4b3aac2729cfdad392d863245ed693..d3ffa2b4402fdd005104d07d92e4066c6170615e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
@@ -86,8 +86,16 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
@@ -77,8 +77,16 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
}
// Paper end
@ -1850,7 +1904,7 @@ index 451f3a6f0b47493da3af3f5d6baced6a8c97f350..d4f98fe5eb5e463679ebc5b82b077c98
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java
index 1b41026ab638bb2764b19429706eb0aded5aad12..4d242bed3bd40c9749236e138f81d5e8583f7dc3 100644
index 1be1f6d23f2224d4d8720d40f2e530736b1bae81..eee08d53714b485bffd1398506ed0cb3b7002d2c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java
@@ -11,8 +11,16 @@ public class CraftMinecartFurnace extends CraftMinecart implements PoweredMineca
@ -1892,11 +1946,32 @@ index 3a3563a1bdbc0d84d973b3a04b50b78b4bc3d379..1e86ce7c1a3fc1f4eae2d8136fc0d879
return (net.minecraft.world.entity.vehicle.MinecartHopper) super.getHandle();
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java
index e8ece01669373ecf6552d33b2ed72668524e2650..fbb5c2e2a136cd03eb1f4b4b5ef289d6a6c39173 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java
@@ -162,8 +162,16 @@ final class CraftMinecartMobSpawner extends CraftMinecart implements SpawnerMine
this.getHandle().getSpawner().spawnRange = spawnRange;
}
+ // Folia start - region threading
+ @Override
+ public MinecartSpawner getHandleRaw() {
+ return (MinecartSpawner)this.entity;
+ }
+ // Folia end - region threading
+
@Override
public MinecartSpawner getHandle() {
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading
return (MinecartSpawner) this.entity;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java
index 79b608e89d4d1f76a58868c585bb87c82e2689b1..7884de5348f325ee12db41a521a042be4b33a793 100644
index 1fe06d3958295acc8211b7837b172262beb87f92..a35f88cf511c7d0231b1d973250b90b72eaec78c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java
@@ -42,8 +42,16 @@ public final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMi
@@ -62,8 +62,16 @@ public final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMi
this.getHandle().explode(power);
}
@ -1914,7 +1989,7 @@ index 79b608e89d4d1f76a58868c585bb87c82e2689b1..7884de5348f325ee12db41a521a042be
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
index 5f9f7e325e3e0276f7a475c4a4725cc0e1b54afd..b6721b3388a5c921e9e621798329f17434683a87 100644
index 778a9d3f8bfe5dba59e1e655e4eeb8822678b8cf..b4ec6c1f8ea5d5c34f2ecb2b066e49993ae79dc7 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
@@ -54,8 +54,16 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob, io.pape
@ -1965,7 +2040,7 @@ index 706c74c832f6893df3797023f68add31139c7d57..1cf155fc23f13691f86673eac3084d75
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
index 5c5b64bd058684520fa175bfd10622ff57856b7c..8acaa5f8153d643e2558110bb7be512514a27532 100644
index 596146ad7899c21645df8834ce5f0afd6c1b0604..78f6e16a745924419d5aad53f95d767d87bdf5d0 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
@@ -19,6 +19,13 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow, io.paperm
@ -2024,7 +2099,7 @@ index ecdac2cf74e99f0d69e053dece11ab891973dc2b..fa365c38c9e0f671df1481c8b36bc993
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java
index 98a4463c9f194f33f4f85d95a0b9fa061cf6faaf..50c1259a16db9f7f134ea6aeb43f29dc100214d3 100644
index b1b139b773b37e6ec2afea85c500387d6ba9800e..38c1eb97de420cd7dea6a9f76ef644ecdf8c30b8 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java
@@ -50,8 +50,16 @@ public class CraftPainting extends CraftHanging implements Painting {
@ -2234,10 +2309,10 @@ 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 149f442304b6af17b483822d4db1b8e760ecd556..12a2da086f249b3dbd61e5749b9856a2fce9ac7b 100644
index fecf7edb824581a7ccb90d196602b41bf22ed23f..b2ae1de0b18a7b5c684b04e3f81fdf071e013c61 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -669,7 +669,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -674,7 +674,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public void kick(net.kyori.adventure.text.Component message, org.bukkit.event.player.PlayerKickEvent.Cause cause) {
@ -2246,7 +2321,7 @@ index 149f442304b6af17b483822d4db1b8e760ecd556..12a2da086f249b3dbd61e5749b9856a2
final ServerGamePacketListenerImpl connection = this.getHandle().connection;
if (connection != null) {
connection.disconnect(message == null ? net.kyori.adventure.text.Component.empty() : message, cause);
@@ -2315,9 +2315,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -2327,9 +2327,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return this;
}
@ -2392,10 +2467,10 @@ index 09796ce15658e3f7c223a265a547a51ee729ed40..bfca2951d18f7451787877b5a6503b05
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java
index d4d8ce60098c74508e2de9541bf6534988779764..bf4b61e56345b1f2ee83d8aceaf66c199590c258 100644
index 7660cc21e936002ebb23510f0ec2b58d71e5157d..a13976b2712413ef9fdeecd1e3ca762238d4efd9 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java
@@ -9,8 +9,16 @@ public class CraftSalmon extends io.papermc.paper.entity.PaperSchoolableFish imp
@@ -10,8 +10,16 @@ public class CraftSalmon extends io.papermc.paper.entity.PaperSchoolableFish imp
super(server, entity);
}
@ -2728,10 +2803,10 @@ index b4afc37c21fc478df44fca7ec3fbc33d337dc6b7..bf3236f673118539d7cfb883bcdf84de
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java
index a6e3b61c391a8b266d2b030d9ba600ac6be76952..abc26a620552659fbcfbcbb90a3fd203f995c46f 100644
index 067a95ea50418601acfb8b9453d1291161bb706a..3a41ef5fdecee262f3e8899deec360c35ddf1b6f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java
@@ -9,8 +9,16 @@ public class CraftSquid extends CraftWaterMob implements Squid {
@@ -9,8 +9,16 @@ public class CraftSquid extends CraftAgeable implements Squid {
super(server, entity);
}
@ -2770,7 +2845,7 @@ index 9472a6f9c9584048abf1f8d11ab6254b7c7a287d..de8f656818192f35cca228724db3d17e
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
index dac3d34677688ac560bc1be2087a08479ef71b87..ec4ae01daa16139b4d2d42c3771eb51d00f55c0a 100644
index a61aec087fa7cec27a803668bdc1b9e6eb336755..1c3826dc868a78402531b6abdddd017c83dae853 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
@@ -42,8 +42,16 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed {
@ -3023,10 +3098,10 @@ index e9ec3455eabc473e104b5342a615a38c1ac25a4f..3a65ae7e6ac1894855e4eafecc9c2bb8
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java
index bd2987fa1fb194a581567134ed980e8fc043f435..46c4a33c4cb82049aa60fc7fc47707dcbd8c733e 100644
index 8e895d6f84f7d84b219f2424909dd42e5f08dec4..e2341684f56a14b3a05fa65d9ac7b3adb52d9077 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java
@@ -33,8 +33,16 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
@@ -34,8 +34,16 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
super(server, entity);
}
@ -3224,7 +3299,7 @@ index bc978391255c9414e06ff393f2e6707d329d020a..8d436a1453c8a66422c2a73576427317
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java
index 86574da257731de7646a712ed73384955fe35aa3..94b699c156884c28c017b528d07f21c041b4ceb1 100644
index ecd33b4add46acbe4e4f8879c0601220423d66ca..5b4c42eb9ade06ad2470e938a8717637e658e026 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java
@@ -31,8 +31,16 @@ public class CraftWolf extends CraftTameableAnimal implements Wolf {
@ -3266,7 +3341,7 @@ index c134c4bb8c0377ceb7f8a5c40c94fd6312a9e448..d334e4a3ea075670e0aa7ea1429ffe42
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
index 46336111dcf62a29390e724b1879c84c697076e9..dbb43c825724c3f13171e8991d53e7d40899670d 100644
index dfc2b40e20069705f92d86a6898e3e8348bf4dcd..9e158d32dc13f8890511de1496d9d5b4c1956e3b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
@@ -12,8 +12,16 @@ public class CraftZombie extends CraftMonster implements Zombie {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Throw UnsupportedOperationException() for broken APIs
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index f9b399214848098149eb1f3a4043028d242dd454..dee23b4b96b7f2c6af54a6affe385b183479f8cc 100644
index 7cc63a4a9759d3926f843cfedbc79986d1ece926..a8975cee866cf2c617b6d4976df71e5c20cf0e3d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1312,6 +1312,7 @@ public final class CraftServer implements Server {
@@ -1320,6 +1320,7 @@ public final class CraftServer implements Server {
@Override
public World createWorld(WorldCreator creator) {
@ -16,7 +16,7 @@ index f9b399214848098149eb1f3a4043028d242dd454..dee23b4b96b7f2c6af54a6affe385b18
Preconditions.checkState(this.console.getAllLevels().iterator().hasNext(), "Cannot create additional worlds on STARTUP");
//Preconditions.checkState(!this.console.isIteratingOverLevels, "Cannot create a world while worlds are being ticked"); // Paper - Cat - Temp disable. We'll see how this goes.
Preconditions.checkArgument(creator != null, "WorldCreator cannot be null");
@@ -1490,6 +1491,7 @@ public final class CraftServer implements Server {
@@ -1498,6 +1499,7 @@ public final class CraftServer implements Server {
@Override
public boolean unloadWorld(World world, boolean save) {
@ -53,7 +53,7 @@ index 253574890a9ed23d38a84680ba1eb221dc72b310..ce8b91f00f925960ad17f381162a1129
this.board.setDisplayObjective(CraftScoreboardTranslations.fromBukkitSlot(slot), null);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
index b3e1adeb932da9b3bed16acd94e2f16da48a7c72..46a8262f21ef95714c122240ee86f01858010047 100644
index f3184be3853dfc4df4ae4b8af764dfef07628ef4..99ba4d19b72a66ea1fc83fda16d37aaa0f154abb 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
@@ -42,6 +42,7 @@ public final class CraftScoreboardManager implements ScoreboardManager {

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 d518487433088f090edb0d12e222b85f0c93b792..db232ac0cc27ddff4bc25ba9b9a5f3a1996fc4e8 100644
index 35b18a9ecce6c7b743badbf384f40b48f2fc73be..54bafb8f67361525484c5c58ee8e6568c0801477 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1936,7 +1936,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -1966,7 +1966,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
Direction enumdirection = (Direction) iterator.next();
BlockPos blockposition1 = pos.relative(enumdirection);
@ -22,23 +22,23 @@ index d518487433088f090edb0d12e222b85f0c93b792..db232ac0cc27ddff4bc25ba9b9a5f3a1
if (iblockdata.is(Blocks.COMPARATOR)) {
diff --git a/src/main/java/net/minecraft/world/level/block/DetectorRailBlock.java b/src/main/java/net/minecraft/world/level/block/DetectorRailBlock.java
index 9d69e439ff853465303c2abd896e6c5314752e1e..69e1748d9d40a8cbf672ba49a8a01e9ff847efd9 100644
index fa1c4defd0d4e4cd888eb26eed131539d0ed573f..afd09a54ee3962943cdf4150a41817fdb0da6615 100644
--- a/src/main/java/net/minecraft/world/level/block/DetectorRailBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/DetectorRailBlock.java
@@ -134,9 +134,9 @@ public class DetectorRailBlock extends BaseRailBlock {
@@ -135,9 +135,9 @@ public class DetectorRailBlock extends BaseRailBlock {
while (iterator.hasNext()) {
BlockPos blockposition1 = (BlockPos) iterator.next();
- BlockState iblockdata1 = world.getBlockState(blockposition1);
+ BlockState iblockdata1 = !ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor((ServerLevel)world, blockposition1) ? null : world.getBlockStateIfLoaded(blockposition1); // Folia - block updates in unloaded chunks
- world.neighborChanged(iblockdata1, blockposition1, iblockdata1.getBlock(), pos, false);
+ if (iblockdata1 != null) world.neighborChanged(iblockdata1, blockposition1, iblockdata1.getBlock(), pos, false); // Folia - block updates in unloaded chunks
- world.neighborChanged(iblockdata1, blockposition1, iblockdata1.getBlock(), (Orientation) null, false);
+ if (iblockdata1 != null) world.neighborChanged(iblockdata1, blockposition1, iblockdata1.getBlock(), (Orientation) null, false); // Folia - block updates in unloaded chunks
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/PoweredRailBlock.java b/src/main/java/net/minecraft/world/level/block/PoweredRailBlock.java
index 9603d8c84ff483030dc08e82d3579b89e5c1f6e9..e2d1f25010d4ec8051c8635440b6c9bfa1e6ae88 100644
index b763361a8f0f1b46093d5dd9afe8dba0cadf9c78..78c6fc0755b149515a98163cb7c68589595c365c 100644
--- a/src/main/java/net/minecraft/world/level/block/PoweredRailBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/PoweredRailBlock.java
@@ -104,9 +104,9 @@ public class PoweredRailBlock extends BaseRailBlock {
@ -54,60 +54,59 @@ index 9603d8c84ff483030dc08e82d3579b89e5c1f6e9..e2d1f25010d4ec8051c8635440b6c9bf
} else {
RailShape blockpropertytrackposition1 = (RailShape) iblockdata.getValue(PoweredRailBlock.SHAPE);
diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
index c4471342eea4f9e2b0916fc1c5f1b24bc07757fd..25b4764358f0a20418d268625609d05c4aa01037 100644
index 0020e7bb7b19179a898cd8835d12cfa37eccdcc2..cf3307a3e30c08e741e25ef5757d6597089f6919 100644
--- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
@@ -199,8 +199,9 @@ public class RedStoneWireBlock extends Block {
while (iterator.hasNext()) {
Direction enumdirection = (Direction) iterator.next();
RedstoneSide blockpropertyredstoneside = (RedstoneSide) state.getValue((Property) RedStoneWireBlock.PROPERTY_BY_DIRECTION.get(enumdirection));
+ BlockState currState; blockposition_mutableblockposition.setWithOffset(pos, enumdirection); // Folia - block updates in unloaded chunks
- if (blockpropertyredstoneside != RedstoneSide.NONE && !world.getBlockState(blockposition_mutableblockposition.setWithOffset(pos, enumdirection)).is((Block) this)) {
+ if (blockpropertyredstoneside != RedstoneSide.NONE && (currState = (world instanceof net.minecraft.server.level.ServerLevel serverLevel && !ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(serverLevel, pos) ? null : world.getBlockStateIfLoaded(blockposition_mutableblockposition))) != null && !currState.is((Block) this)) { // Folia - block updates in unloaded chunks
blockposition_mutableblockposition.move(Direction.DOWN);
BlockState iblockdata1 = world.getBlockState(blockposition_mutableblockposition);
@@ -237,7 +237,8 @@ public class RedStoneWireBlock extends Block {
for (Direction direction : Direction.Plane.HORIZONTAL) {
RedstoneSide redstoneSide = state.getValue(PROPERTY_BY_DIRECTION.get(direction));
- if (redstoneSide != RedstoneSide.NONE && !world.getBlockState(mutableBlockPos.setWithOffset(pos, direction)).is(this)) {
+ BlockState currState; mutableBlockPos.setWithOffset(pos, direction); // Folia - block updates in unloaded chunks
+ if (redstoneSide != RedstoneSide.NONE && (currState = (world instanceof net.minecraft.server.level.ServerLevel serverLevel && !ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(serverLevel, pos) ? null : world.getBlockStateIfLoaded(mutableBlockPos.setWithOffset(pos, direction)))) != null && !currState.is(this)) { // Folia - block updates in unloaded chunks
mutableBlockPos.move(Direction.DOWN);
BlockState blockState = world.getBlockState(mutableBlockPos);
if (blockState.is(this)) {
diff --git a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
index 2c9640001dba727981ad336eefade6d438eeb0ac..67bd721c4f9b22e07f9ab75ca019b4c9e9080a4c 100644
index 63b12dcb1b86e15607ebbaa157d7a330c089862d..d1d8360f1ae931b22e1712b498ae66b7649be90d 100644
--- a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
+++ b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
@@ -119,7 +119,8 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
@Override
@@ -124,7 +124,8 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
public boolean runNext(Level world) {
BlockPos blockPos = this.sourcePos.relative(NeighborUpdater.UPDATE_ORDER[this.idx++]);
Direction direction = NeighborUpdater.UPDATE_ORDER[this.idx++];
BlockPos blockPos = this.sourcePos.relative(direction);
- BlockState blockState = world.getBlockState(blockPos);
+ BlockState blockState = !ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor((net.minecraft.server.level.ServerLevel)world, blockPos) ? null : world.getBlockStateIfLoaded(blockPos); // Folia - block updates in unloaded chunks
+ if (blockState != null) { // Folia - block updates in unloaded chunks
// Paper start - Call BlockPhysicsEvent
try {
org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent(
@@ -134,6 +135,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
world.lastPhysicsProblem = blockPos;
Orientation orientation = null;
if (world.enabledFeatures().contains(FeatureFlags.REDSTONE_EXPERIMENTS)) {
if (this.orientation == null) {
@@ -137,6 +138,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
}
// Paper end - Call BlockPhysicsEvent
NeighborUpdater.executeUpdate(world, blockState, blockPos, this.sourceBlock, orientation, false, this.sourcePos); // Paper - Add source block to BlockPhysicsEvent
+ } // Folia - block updates in unloaded chunks
if (this.idx < NeighborUpdater.UPDATE_ORDER.length && NeighborUpdater.UPDATE_ORDER[this.idx] == this.skipDirection) {
this.idx++;
}
@@ -150,7 +152,9 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
@@ -153,7 +155,9 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
implements CollectingNeighborUpdater.NeighborUpdates {
@Override
public boolean runNext(Level world) {
+ if (ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor((net.minecraft.server.level.ServerLevel)world, this.pos) && world.getChunkIfLoaded(this.pos) != null) { // Folia - block updates in unloaded chunks
NeighborUpdater.executeShapeUpdate(world, this.direction, this.state, this.pos, this.neighborPos, this.updateFlags, this.updateLimit);
NeighborUpdater.executeShapeUpdate(world, this.direction, this.pos, this.neighborPos, this.neighborState, this.updateFlags, this.updateLimit);
+ } // Folia - block updates in unloaded chunks
return false;
}
}
@@ -158,8 +162,8 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
static record SimpleNeighborUpdate(BlockPos pos, Block block, BlockPos neighborPos) implements CollectingNeighborUpdater.NeighborUpdates {
@@ -161,8 +165,8 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
static record SimpleNeighborUpdate(BlockPos pos, Block block, @Nullable Orientation orientation) implements CollectingNeighborUpdater.NeighborUpdates {
@Override
public boolean runNext(Level world) {
- BlockState blockState = world.getBlockState(this.pos);
- NeighborUpdater.executeUpdate(world, blockState, this.pos, this.block, this.neighborPos, false);
- NeighborUpdater.executeUpdate(world, blockState, this.pos, this.block, this.orientation, false);
+ BlockState blockState = !ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor((net.minecraft.server.level.ServerLevel)world, this.pos) ? null : world.getBlockStateIfLoaded(this.pos); // Folia - block updates in unloaded chunks
+ if (blockState != null) NeighborUpdater.executeUpdate(world, blockState, this.pos, this.block, this.neighborPos, false); // Folia - block updates in unloaded chunks
+ if (blockState != null) NeighborUpdater.executeUpdate(world, blockState, this.pos, this.block, this.orientation, false); // Folia - block updates in unloaded chunks
return false;
}
}

View File

@ -7,10 +7,10 @@ The returned TE may be in the world, in which case it is unsafe
for the current thread to modify or access its contents.
diff --git a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
index d7d332d8ba3442887e80d2c3d7bddb9de2674c2d..f135ed136aa01bf18b4bd107109db8f8ebf440d2 100644
index 1eb8022f3e31603322e6c56516304afc9a11bbec..87ddae289972b8e0dd0b48a07e23c627b598bae3 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
@@ -92,6 +92,11 @@ public class ImposterProtoChunk extends ProtoChunk implements ca.spottedleaf.moo
@@ -91,6 +91,11 @@ public class ImposterProtoChunk extends ProtoChunk implements ca.spottedleaf.moo
@Nullable
@Override
public BlockEntity getBlockEntity(BlockPos pos) {

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 00b3c3c60f67d129058a888b7bd5e7fb031063da..e4a68f43c1a48fe8193623c646eb40bc5f664c76 100644
index f2884eefe00a35e19c83e069f65490dff95144a8..19eb204e5d3cd6ef8f2a31fae32e75dbf07ffb96 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -709,7 +709,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
@@ -799,7 +799,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 00b3c3c60f67d129058a888b7bd5e7fb031063da..e4a68f43c1a48fe8193623c646eb40bc
// 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 551ad6757e76ec9c731488f0355d4950ad1b0bd4..9b8fd458c851d72901568845d973330ed58260a9 100644
index 77eab187d4d6e22e5f8722029107c5613a9a7300..b63393c131f736cd51666c675ac18918e038eca6 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -4451,6 +4451,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -4605,6 +4605,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
});

View File

@ -9,10 +9,10 @@ raid before it's completion, it would throw an exception due to not being on the
same region thread anymore.
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java
index e1987d1d6e5fd05e155c05dd1fdaf569e303d74a..909d1966b2f22c65ef4b887521b3b0e772f2a7ee 100644
index 5ff4a4af7f166f5f977efe41263ca487fe1b270b..1df579db8286113f8412fe678259fb53098e57ed 100644
--- a/src/main/java/net/minecraft/world/entity/raid/Raid.java
+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java
@@ -429,14 +429,22 @@ public class Raid {
@@ -423,14 +423,22 @@ public class Raid {
LivingEntity entityliving = (LivingEntity) entity;
if (!entity.isSpectator()) {

View File

@ -6,21 +6,21 @@ Subject: [PATCH] Sync vehicle position to player position on player data load
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/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 98064cb4c99929ed109dac928c302c87631ad539..20eeae6e968ecb5d67f16d0d2f56632e038a89b4 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -516,7 +516,13 @@ public abstract class PlayerList {
if (optional.isPresent() && ((CompoundTag) optional.get()).contains("RootVehicle", 10)) {
CompoundTag nbttagcompound = ((CompoundTag) optional.get()).getCompound("RootVehicle");
ServerLevel finalWorldServer = worldserver1; // CraftBukkit - decompile error
+ Vec3 playerPos = player.position(); // Paper - force sync root vehicle to player position
Entity entity = EntityType.loadEntityRecursive(nbttagcompound.getCompound("Entity"), worldserver1, (entity1) -> {
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 19eb204e5d3cd6ef8f2a31fae32e75dbf07ffb96..68a88928a3aae9d2ea6cd18088ede0a54c31d0d2 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -925,7 +925,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");
+ Vec3 playerPos = this.position(); // Paper - force sync root vehicle to player position
Entity entity = EntityType.loadEntityRecursive(nbttagcompound.getCompound("Entity"), worldserver, EntitySpawnReason.LOAD, (entity1) -> {
+ // Paper start - force sync root vehicle to player position
+ if (entity1.distanceToSqr(player) > (5.0 * 5.0)) {
+ if (entity1.distanceToSqr(ServerPlayer.this) > (5.0 * 5.0)) {
+ entity1.setPosRaw(playerPos.x, playerPos.y, playerPos.z, true);
+ }
+ // Paper end - force sync root vehicle to player position
return !finalWorldServer.addWithUUID(entity1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT) ? null : entity1; // CraftBukkit - decompile error // Paper - Entity#getEntitySpawnReason
return !worldserver.addWithUUID(entity1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT) ? null : entity1; // CraftBukkit - decompile error // Paper - Entity#getEntitySpawnReason
});

View File

@ -190,7 +190,7 @@ index 0000000000000000000000000000000000000000..19c13bd372711bce978a463f85130f1e
+}
diff --git a/src/main/java/ca/spottedleaf/leafprofiler/LProfilerRegistry.java b/src/main/java/ca/spottedleaf/leafprofiler/LProfilerRegistry.java
new file mode 100644
index 0000000000000000000000000000000000000000..1d4f1bdb12d0f1371b62a484b535afd7dcbe1cd7
index 0000000000000000000000000000000000000000..cf81748afe993e486ce27ae65e0148071b029423
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/leafprofiler/LProfilerRegistry.java
@@ -0,0 +1,118 @@
@ -301,11 +301,11 @@ index 0000000000000000000000000000000000000000..1d4f1bdb12d0f1371b62a484b535afd7
+ public static final int MISC_MOB_SPAWN_TICK = GLOBAL_REGISTRY.createType(ProfileType.TIMER, "Misc Mob Spawn Tick");
+ public static final int BROADCAST_BLOCK_CHANGES = GLOBAL_REGISTRY.createType(ProfileType.TIMER, "Broadcast Block Changes");
+ public static final int ENTITY_TRACKER_TICK = GLOBAL_REGISTRY.createType(ProfileType.TIMER, "Entity Tracker Tick");
+ public static final int TRACKED_UNLOADED_ENTITY_COUNTS = GLOBAL_REGISTRY.createType(ProfileType.COUNTER, "Total Untracked Unloaded Entities");
+ public static final int TRACKED_ENTITY_COUNTS = GLOBAL_REGISTRY.createType(ProfileType.COUNTER, "Total Tracked Entities");
+ public static final int POI_MANAGER_TICK = GLOBAL_REGISTRY.createType(ProfileType.TIMER, "POI Manager Tick");
+ public static final int PROCESS_UNLOADS = GLOBAL_REGISTRY.createType(ProfileType.TIMER, "Process Unloads");
+ public static final int BLOCK_EVENT_TICK = GLOBAL_REGISTRY.createType(ProfileType.TIMER, "Block Event Tick");
+ public static final int ACTIVATE_ENTITIES = GLOBAL_REGISTRY.createType(ProfileType.TIMER, "Activate Entities");
+ public static final int ENTITY_TICK = GLOBAL_REGISTRY.createType(ProfileType.TIMER, "Entity Tick");
+ public static final int DRAGON_FIGHT_TICK = GLOBAL_REGISTRY.createType(ProfileType.TIMER, "Dragon Fight Tick");
+ public static final int TILE_ENTITY = GLOBAL_REGISTRY.createType(ProfileType.TIMER, "Tile Entities");
@ -927,10 +927,10 @@ index 0000000000000000000000000000000000000000..95c0e6416afafbb633f0a30ae22df166
+ ) {}
+}
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 4b36209f016b025087da359ab49e44bd677cd937..707d4aa8a56f2fc33456f3441c4daf973a27ef2d 100644
index 3a476713964002734a9e67fd9b6dfa497b590657..e176d2d2387e171ff163853131dcf8d1af9a268d 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
@@ -1442,7 +1442,9 @@ public final class ChunkHolderManager {
@@ -1459,7 +1459,9 @@ public final class ChunkHolderManager {
}
public boolean processTicketUpdates() {
@ -941,10 +941,10 @@ index 4b36209f016b025087da359ab49e44bd677cd937..707d4aa8a56f2fc33456f3441c4daf97
private static final ThreadLocal<List<ChunkProgressionTask>> CURRENT_TICKET_UPDATE_SCHEDULING = new ThreadLocal<>();
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java
index 3210d4cb97301d6fa5ffe76fd7c263ab7aa0a8be..60399be0046dbb06be643461c8f3ce1491542dfd 100644
index 9e7e10fe46dbbd03d690a65af6ae719d1665bc6a..6edbe46c5c2eb74bca7e437474a6e992f45a04f8 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java
@@ -1672,6 +1672,8 @@ public final class NewChunkHolder {
@@ -1680,6 +1680,8 @@ public final class NewChunkHolder {
public SaveStat save(final boolean shutdown) {
TickThread.ensureTickThread(this.world, this.chunkX, this.chunkZ, "Cannot save data off-main");
@ -953,14 +953,14 @@ index 3210d4cb97301d6fa5ffe76fd7c263ab7aa0a8be..60399be0046dbb06be643461c8f3ce14
ChunkAccess chunk = this.getCurrentChunk();
PoiChunk poi = this.getPoiChunk();
@@ -1718,6 +1720,7 @@ public final class NewChunkHolder {
}
return executedUnloadTask | canSaveChunk | canSaveEntities | canSavePOI ? new SaveStat(executedUnloadTask || canSaveChunk, canSaveEntities, canSavePOI): null;
@@ -1738,6 +1740,7 @@ public final class NewChunkHolder {
canSavePOI | executedUnloadTasks[MoonriseRegionFileIO.RegionFileType.POI_DATA.ordinal()]
)
: null;
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CHUNK_SAVE); } // Folia - profiler
}
static final class AsyncChunkSerializeTask implements Runnable {
private boolean saveChunk(final ChunkAccess chunk, final boolean unloading) {
diff --git a/src/main/java/io/papermc/paper/command/PaperCommands.java b/src/main/java/io/papermc/paper/command/PaperCommands.java
index a587d83b78af4efc484f939529acf70834f60d7e..45f76aaaa7dedb77a83b4a2c87905bf9a099a93c 100644
--- a/src/main/java/io/papermc/paper/command/PaperCommands.java
@ -1360,13 +1360,13 @@ index 0000000000000000000000000000000000000000..e36fd244f71a92d11c6ee45944948be5
+ }
+}
diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
index fbc619a132c6ca6b1abab51ac230be29367e9c6e..97817400b70b2579f3a8750f7f33197a5db7ba94 100644
index d6eb8f495688a1b65a4c419aa3ee655cd8eb322a..f338b273613840ed366ab13b528373e7091631e8 100644
--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java
+++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
@@ -53,7 +53,10 @@ public class PacketUtils {
@@ -52,7 +52,10 @@ public class PacketUtils {
if (listener instanceof ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // CraftBukkit - Don't handle sync packets for kicked players
if (listener.shouldHandleMessage(packet)) {
co.aikar.timings.Timing timing = co.aikar.timings.MinecraftTimings.getPacketTiming(packet); // Paper - timings
try (co.aikar.timings.Timing ignored = timing.startTiming()) { // Paper - timings
try {
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
+ final int packetTimerId = profiler.getOrCreateTimerAndStart(() -> "Packet Handler: ".concat(io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(packet.getClass().getName()))); try { // Folia - profiler
packet.handle(listener);
@ -1375,100 +1375,109 @@ index fbc619a132c6ca6b1abab51ac230be29367e9c6e..97817400b70b2579f3a8750f7f33197a
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 84f1f7956065de039837ceeaeee30259a7df4118..4ed79a51c89d54a7b2ab65a99b5b09cc807f4d4e 100644
index ee55c53d40dbf51f47627a6b56060e32fd215353..b261d166eb09386275ba52372cca56fceaac002b 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1654,6 +1654,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1712,6 +1712,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) {
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
if (region != null) {
region.world.getCurrentWorldData().updateTickData();
if (region.world.checkInitialised.get() != ServerLevel.WORLD_INIT_CHECKED) {
@@ -1689,10 +1690,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle foliaProfiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
// Folia end - region threading
org.spigotmc.WatchdogThread.tick(); // Spigot
long i = startTime; // Folia - region threading
@@ -1750,6 +1751,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
}
+
// Folia start - region threading
if (region != null) {
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.INTERNAL_TICK_TASKS); try { // Folia - profiler
region.world.getCurrentWorldData().updateTickData();
@@ -1773,10 +1775,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) {
+ foliaProfiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.INTERNAL_TICK_TASKS); try { // Folia - profiler
region.getTaskQueueData().drainTasks();
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.INTERNAL_TICK_TASKS); } // Folia - profiler
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.PLUGIN_TICK_TASKS); try { // Folia - profiler
+ } finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.INTERNAL_TICK_TASKS); } // Folia - profiler
+ foliaProfiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.PLUGIN_TICK_TASKS); try { // Folia - profiler
((io.papermc.paper.threadedregions.scheduler.FoliaRegionScheduler)Bukkit.getRegionScheduler()).tick();
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.PLUGIN_TICK_TASKS); } // Folia - profiler
+ } finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.PLUGIN_TICK_TASKS); } // Folia - profiler
// now run all the entity schedulers
// TODO there has got to be a more efficient variant of this crap
+ long tickedEntitySchedulers = 0L; // Folia - profiler
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_SCHEDULER_TICK); try { // Folia - profiler
+ foliaProfiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_SCHEDULER_TICK); try { // Folia - profiler
for (Entity entity : region.world.getCurrentWorldData().getLocalEntitiesCopy()) {
if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity) || entity.isRemoved()) {
continue;
@@ -1700,8 +1707,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1784,8 +1792,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
org.bukkit.craftbukkit.entity.CraftEntity bukkit = entity.getBukkitEntityRaw();
if (bukkit != null) {
bukkit.taskScheduler.executeTick();
+ ++tickedEntitySchedulers; // Folia - profiler
}
}
+ profiler.addCounter(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_SCHEDULERS_TICKED, tickedEntitySchedulers); // Folia - profiler
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_SCHEDULER_TICK); } // Folia - profiler
+ foliaProfiler.addCounter(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_SCHEDULERS_TICKED, tickedEntitySchedulers); // Folia - profiler
+ } finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_SCHEDULER_TICK); } // Folia - profiler
}
// Folia end - region threading
@@ -1721,6 +1731,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
if (region == null) this.tickRateManager.tick(); // Folia - region threading
@@ -1804,6 +1815,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
this.profiler.push("save");
profiler.push("save");
final boolean fullSave = autosavePeriod > 0 && io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick() % autosavePeriod == 0; // Folia - region threading
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.AUTOSAVE); try { // Folia - profiler
+ foliaProfiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.AUTOSAVE); try { // Folia - profiler
try {
this.isSaving = true;
if (playerSaveInterval > 0) {
@@ -1734,6 +1745,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1817,6 +1829,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
} finally {
this.isSaving = false;
}
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.AUTOSAVE); } // Folia - profiler
this.profiler.pop();
+ } finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.AUTOSAVE); } // Folia - profiler
profiler.pop();
// Paper end - Incremental chunk and player saving
// Paper start - move executeAll() into full server tick timing
@@ -1807,6 +1819,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1899,6 +1912,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
public void tickChildren(BooleanSupplier shouldKeepTicking, io.papermc.paper.threadedregions.TickRegions.TickRegionData region) { // Folia - region threading
protected void tickChildren(BooleanSupplier shouldKeepTicking, io.papermc.paper.threadedregions.TickRegions.TickRegionData region) { // Folia - region threading
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
final io.papermc.paper.threadedregions.RegionizedWorldData regionizedWorldData = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegionizedWorldData(); // Folia - regionised ticking
if (region == null) this.getPlayerList().getPlayers().forEach((entityplayer) -> { // Folia - region threading
entityplayer.connection.suspendFlushing();
@@ -1875,7 +1888,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
ProfilerFiller gameprofilerfiller = Profiler.get();
@@ -1963,7 +1977,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
gameprofilerfiller.push("tick");
try {
worldserver.timings.doTick.startTiming(); // Spigot
+ profiler.startTimer(worldserver.tickTimerId); try { // Folia - profiler
worldserver.tick(shouldKeepTicking, region); // Folia - region threading
+ } finally { profiler.stopTimer(worldserver.tickTimerId); } // Folia - profiler
worldserver.timings.doTick.stopTiming(); // Spigot
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
@@ -1893,7 +1908,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.profiler.popPush("connection");
MinecraftTimings.connectionTimer.startTiming(); // Spigot // Paper
if (region == null) this.getConnection().tick(); // Folia - region threading
@@ -1978,8 +1994,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");
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CONNECTION_TICK); try { // Folia - profiler
if (region == null) this.tickConnection(); // Folia - region threading
if (region != null) regionizedWorldData.tickConnections(); // Folia - region threading
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CONNECTION_TICK); } // Folia - profiler
MinecraftTimings.connectionTimer.stopTiming(); // Spigot // Paper
this.profiler.popPush("players");
MinecraftTimings.playerListTimer.startTiming(); // Spigot // Paper
gameprofilerfiller.popPush("players");
if (false) this.playerList.tick(); // Folia - region threading
if (SharedConstants.IS_RUNNING_IN_IDE && this.tickRateManager.runsNormally()) {
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 6f746f5ce9751dce4912f7633c126788eb684bd0..74524dcd4539a31e9d0037cd607ffbfce02f414c 100644
index 48fc7676252dbff47f59b65e6b9d9410e25778c5..dd63a17cdbf758aec2110924ef38ee3c1bc18fd1 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -392,13 +392,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -406,13 +406,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
protected void tick(BooleanSupplier shouldKeepTicking) {
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
ProfilerFiller gameprofilerfiller = this.level.getProfiler();
ProfilerFiller gameprofilerfiller = Profiler.get();
gameprofilerfiller.push("poi");
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.POI_MANAGER_TICK); try { // Folia - profiler
@ -1482,7 +1491,7 @@ index 6f746f5ce9751dce4912f7633c126788eb684bd0..74524dcd4539a31e9d0037cd607ffbfc
}
gameprofilerfiller.pop();
@@ -900,13 +905,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -947,12 +952,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper start - optimise entity tracker
private void newTrackerTick() {
@ -1492,7 +1501,6 @@ index 6f746f5ce9751dce4912f7633c126788eb684bd0..74524dcd4539a31e9d0037cd607ffbfc
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TRACKER_TICK); try { // Folia - profiler
+ // Folia end - profiler
final io.papermc.paper.threadedregions.RegionizedWorldData worldData = this.level.getCurrentWorldData(); // Folia - region threading
final ca.spottedleaf.moonrise.common.misc.NearbyPlayers nearbyPlayers = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getNearbyPlayers();
final ca.spottedleaf.moonrise.patches.chunk_system.level.entity.server.ServerEntityLookup entityLookup = (ca.spottedleaf.moonrise.patches.chunk_system.level.entity.server.ServerEntityLookup)((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getEntityLookup();;
final ca.spottedleaf.moonrise.common.list.ReferenceList<net.minecraft.world.entity.Entity> trackerEntities = worldData.trackerEntities; // Folia - region threading
@ -1502,157 +1510,134 @@ index 6f746f5ce9751dce4912f7633c126788eb684bd0..74524dcd4539a31e9d0037cd607ffbfc
final Entity entity = trackerEntitiesRaw[i];
final ChunkMap.TrackedEntity tracker = ((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity)entity).moonrise$getTrackedEntity();
if (tracker == null) {
@@ -928,6 +938,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -964,6 +974,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
tracker.serverEntity.sendChanges();
}
((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerTrackedEntity)tracker).moonrise$clearPlayers();
}
+ profiler.addCounter(ca.spottedleaf.leafprofiler.LProfilerRegistry.TRACKED_ENTITY_COUNTS, (long)totalEntities); // Folia - profiler
+ profiler.addCounter(ca.spottedleaf.leafprofiler.LProfilerRegistry.TRACKED_UNLOADED_ENTITY_COUNTS, (long)unloadedEntitiesRaw.length); // Folia - profiler
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TRACKER_TICK); } // Folia - profiler
}
// 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 b0e41b79d357f7e1b189985b4752accc78f05bbb..f7311d6efc2119b9dbe062a439850a890c9bf6b8 100644
index f58dadcf5f3822fd18a0d1dfb775b3d7cd7abde9..220db29a8901fbbfbec2b95be994f0ea0144b98d 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -397,19 +397,26 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -455,18 +455,25 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@Override
public void tick(BooleanSupplier shouldKeepTicking, boolean tickChunks) {
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
this.level.getProfiler().push("purge");
this.level.timings.doChunkMap.startTiming(); // Spigot
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CHUNK_HOLDER_MANAGER_TICK); try { // Folia - profiler
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle foliaProfiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
ProfilerFiller gameprofilerfiller = Profiler.get();
gameprofilerfiller.push("purge");
+ foliaProfiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CHUNK_HOLDER_MANAGER_TICK); try { // Folia - profiler
if (this.level.tickRateManager().runsNormally() || !tickChunks || this.level.spigotConfig.unloadFrozenChunks) { // Spigot
this.distanceManager.purgeStaleTickets();
}
this.runDistanceManagerUpdates();
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CHUNK_HOLDER_MANAGER_TICK); } // Folia - profiler
this.level.timings.doChunkMap.stopTiming(); // Spigot
this.level.getProfiler().popPush("chunks");
+ } finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CHUNK_HOLDER_MANAGER_TICK); } // Folia - profiler
gameprofilerfiller.popPush("chunks");
if (tickChunks) {
this.level.timings.chunks.startTiming(); // Paper - timings
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.PLAYER_CHUNK_LOADER_TICK); try { // Folia - profiler
+ foliaProfiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.PLAYER_CHUNK_LOADER_TICK); try { // Folia - profiler
((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getPlayerChunkLoader().tick(); // Paper - rewrite chunk system
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.PLAYER_CHUNK_LOADER_TICK); } // Folia - profiler
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CHUNK_TICK); try { // Folia - profiler
+ } finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.PLAYER_CHUNK_LOADER_TICK); } // Folia - profiler
+ foliaProfiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CHUNK_TICK); try { // Folia - profiler
this.tickChunks();
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CHUNK_TICK); } // Folia - profiler
this.level.timings.chunks.stopTiming(); // Paper - timings
+ } finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CHUNK_TICK); } // Folia - profiler
this.chunkMap.tick();
}
@@ -424,6 +431,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -478,6 +485,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
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
long chunksTicked = 0; // Paper - rewrite chunk system
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle foliaProfiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
//long i = this.level.getGameTime(); // Folia - region threading
long j = 1L; // Folia - region threading
@@ -436,6 +444,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
gameprofilerfiller.push("filteringLoadedChunks");
// Paper start - chunk tick iteration optimisations
List<ServerChunkCache.ChunkAndHolder> list;
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CHUNK_TICK_COLLECT_CHUNKS); try { // Folia - profiler
{
final ca.spottedleaf.moonrise.common.list.ReferenceList<net.minecraft.server.level.ServerChunkCache.ChunkAndHolder> tickingChunks =
((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel) this.level).moonrise$getTickingChunks();
@@ -452,6 +461,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
regionizedWorldData.iterationCopy, size // Folia - region threading
);
@@ -491,7 +499,9 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
try {
gameprofilerfiller.push("filteringTickingChunks");
+ foliaProfiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CHUNK_TICK_COLLECT_CHUNKS); try { // Folia - profiler
this.collectTickingChunks(list);
+ } finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CHUNK_TICK_COLLECT_CHUNKS); } // Folia - profiler
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
}
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CHUNK_TICK_COLLECT_CHUNKS); } // Folia - profiler
// Paper end - chunk tick iteration optimisations
Iterator iterator = null; // Paper - chunk tick iteration optimisations
if (this.level.getServer().tickRateManager().runsNormally()) this.level.timings.chunkTicks.startTiming(); // Paper
@@ -465,6 +475,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
}
+ foliaProfiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.BROADCAST_BLOCK_CHANGES); try { // Folia - profiler
this.broadcastChangedChunks(gameprofilerfiller);
+ } finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.BROADCAST_BLOCK_CHANGES); } // Folia - profiler
gameprofilerfiller.pop();
}
}
@@ -552,11 +564,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
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle foliaProfiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
profiler.popPush("naturalSpawnCount");
int j = this.distanceManager.getNaturalSpawnChunkCount();
// Paper start - Optional per player mob spawns
int naturalSpawnChunkCount = k;
final int naturalSpawnChunkCount = j;
NaturalSpawner.SpawnState spawnercreature_d; // moved down
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.MOB_SPAWN_ENTITY_COUNT); try { // Folia - profiler
+ foliaProfiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.MOB_SPAWN_ENTITY_COUNT); try { // Folia - profiler
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
@@ -484,6 +495,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -576,6 +590,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
}
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.MOB_SPAWN_ENTITY_COUNT); } // Folia - profiler
+ } finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.MOB_SPAWN_ENTITY_COUNT); } // Folia - profiler
// Paper end - Optional per player mob spawns
this.level.timings.countNaturalMobs.stopTiming(); // Paper - timings
@@ -505,6 +517,9 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit
Iterator iterator1 = list.iterator();
regionizedWorldData.lastSpawnState = spawnercreature_d; // Folia - region threading
@@ -603,6 +618,9 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
Iterator iterator = chunks.iterator();
+ long spawnChunkCount = 0L; // Folia - profiler
+ long randomChunkCount = 0L; // Folia - profiler
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.SPAWN_AND_RANDOM_TICK); try { // Folia - profiler
while (iterator1.hasNext()) {
ServerChunkCache.ChunkAndHolder chunkproviderserver_a = (ServerChunkCache.ChunkAndHolder) iterator1.next();
LevelChunk chunk1 = chunkproviderserver_a.chunk;
@@ -513,10 +528,12 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
if (true && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkcoordintpair)) { // Paper - rewrite chunk system
chunk1.incrementInhabitedTime(j);
if (flag && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkcoordintpair, true)) { // Spigot
+ ++spawnChunkCount; // Folia - profiler
NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1);
+ foliaProfiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.SPAWN_AND_RANDOM_TICK); try { // Folia - profiler
while (iterator.hasNext()) {
LevelChunk chunk = (LevelChunk) iterator.next();
ChunkPos chunkcoordintpair = chunk.getPos();
@@ -616,10 +634,15 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
this.level.tickChunk(chunk, k);
}
}
+ foliaProfiler.addCounter(ca.spottedleaf.leafprofiler.LProfilerRegistry.SPAWN_CHUNK_COUNT, spawnChunkCount); // Folia - profiler
+ foliaProfiler.addCounter(ca.spottedleaf.leafprofiler.LProfilerRegistry.RANDOM_CHUNK_TICK_COUNT, randomChunkCount); // Folia - profiler
+ } finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.SPAWN_AND_RANDOM_TICK); } // Folia - profiler
if (true) { // Paper - rewrite chunk system
+ ++randomChunkCount; // Folia - profiler
this.level.tickChunk(chunk1, l);
// Paper start - rewrite chunk system
if ((++chunksTicked & 7L) == 0L) {
@@ -526,19 +543,25 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
}
}
}
+ profiler.addCounter(ca.spottedleaf.leafprofiler.LProfilerRegistry.SPAWN_CHUNK_COUNT, spawnChunkCount); // Folia - profiler
+ profiler.addCounter(ca.spottedleaf.leafprofiler.LProfilerRegistry.RANDOM_CHUNK_TICK_COUNT, randomChunkCount); // Folia - profiler
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.SPAWN_AND_RANDOM_TICK); } // Folia - profiler
this.level.timings.chunkTicks.stopTiming(); // Paper
gameprofilerfiller.popPush("customSpawners");
profiler.popPush("customSpawners");
if (flag) {
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.MISC_MOB_SPAWN_TICK); try { // Folia - profiler
try (co.aikar.timings.Timing ignored = this.level.timings.miscMobSpawning.startTiming()) { // Paper - timings
+ foliaProfiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.MISC_MOB_SPAWN_TICK); try { // Folia - profiler
this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies);
} // Paper - timings
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.MISC_MOB_SPAWN_TICK); } // Folia - profiler
}
+ } finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.MISC_MOB_SPAWN_TICK); } // Folia - profiler
}
gameprofilerfiller.popPush("broadcast");
// Paper start - chunk tick iteration optimisations
this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.BROADCAST_BLOCK_CHANGES); try { // Folia - profiler
{
final it.unimi.dsi.fastutil.objects.ObjectArrayList<net.minecraft.server.level.ServerChunkCache.ChunkAndHolder> chunks = (it.unimi.dsi.fastutil.objects.ObjectArrayList<net.minecraft.server.level.ServerChunkCache.ChunkAndHolder>)list;
final ServerChunkCache.ChunkAndHolder[] raw = chunks.elements();
@@ -552,6 +575,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
holder.holder().broadcastChanges(holder.chunk());
}
}
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.BROADCAST_BLOCK_CHANGES); } // Folia - profiler
this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing
// Paper end - chunk tick iteration optimisations
gameprofilerfiller.pop();
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index f03f968d1526fbcff1ae87376370ba5976c2b807..90d78ddf8518c0df307cdaa8b7cfb5549491c6e5 100644
index f8d865c7127e7a05bb8ce34b86bc41eed8b9de23..2d721d9f4bf6e4e7c9168b5f1605edb98bbb2fc8 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -709,6 +709,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -725,6 +725,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
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
ProfilerFiller gameprofilerfiller = this.getProfiler();
ProfilerFiller gameprofilerfiller = Profiler.get();
regionizedWorldData.setHandlingTick(true); // Folia - regionised ticking
@@ -737,9 +738,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -753,22 +754,32 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
if (!this.isDebug() && flag) {
j = regionizedWorldData.getRedstoneGameTime(); // Folia - region threading
gameprofilerfiller.push("blockTicks");
@ -1665,60 +1650,53 @@ index f03f968d1526fbcff1ae87376370ba5976c2b807..90d78ddf8518c0df307cdaa8b7cfb554
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.FLUID_TICK); } // Folia - profiler
gameprofilerfiller.pop();
}
this.timings.scheduledBlocks.stopTiming(); // Paper
@@ -747,18 +752,24 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
gameprofilerfiller.popPush("raid");
if (flag) {
this.timings.raids.startTiming(); // Paper - timings
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.RAIDS_TICK); try { // Folia - profiler
this.raids.tick();
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.RAIDS_TICK); } // Folia - profiler
this.timings.raids.stopTiming(); // Paper - timings
}
gameprofilerfiller.popPush("chunkSource");
this.timings.chunkProviderTick.startTiming(); // Paper - timings
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CHUNK_PROVIDER_TICK); try { // Folia - profiler
this.getChunkSource().tick(shouldKeepTicking, true);
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.CHUNK_PROVIDER_TICK); } // Folia - profiler
this.timings.chunkProviderTick.stopTiming(); // Paper - timings
gameprofilerfiller.popPush("blockEvents");
if (flag) {
this.timings.doSounds.startTiming(); // Spigot
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.BLOCK_EVENT_TICK); try { // Folia - profiler
this.runBlockEvents();
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.BLOCK_EVENT_TICK); } // Folia - profiler
this.timings.doSounds.stopTiming(); // Spigot
}
@@ -774,6 +785,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
regionizedWorldData.setHandlingTick(false); // Folia - regionised ticking
@@ -782,6 +793,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
if (flag1 || this.emptyTime++ < 300) {
gameprofilerfiller.push("entities");
this.timings.tickEntities.startTiming(); // Spigot
if (this.dragonFight != null && flag) {
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.DRAGON_FIGHT_TICK); try { // Folia - profiler
if (ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this, this.dragonFight.origin)) { // Folia - region threading
gameprofilerfiller.push("dragonFight");
this.dragonFight.tick();
@@ -786,10 +798,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -794,9 +806,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
fightCenter
);
} // Folia end - region threading
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.DRAGON_FIGHT_TICK); } // Folia - profiler
}
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ACTIVATE_ENTITIES); try { // Folia - profiler
org.spigotmc.ActivationRange.activateEntities(this); // Spigot
this.timings.entityTick.startTiming(); // Spigot
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ACTIVATE_ENTITIES); } // Folia - profiler
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TICK); try { // Folia - profiler
regionizedWorldData.forEachTickingEntity((entity) -> { // Folia - regionised ticking
if (!entity.isRemoved()) {
if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed
@@ -817,10 +831,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
if (!tickratemanager.isEntityFrozen(entity)) {
@@ -822,8 +838,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
}
}
});
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TICK); } // Folia - profiler
this.timings.entityTick.stopTiming(); // Spigot
this.timings.tickEntities.stopTiming(); // Spigot
gameprofilerfiller.pop();
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.TILE_ENTITY); try { // Folia - profiler
this.tickBlockEntities();
@ -1726,7 +1704,7 @@ index f03f968d1526fbcff1ae87376370ba5976c2b807..90d78ddf8518c0df307cdaa8b7cfb554
}
gameprofilerfiller.push("entityManagement");
@@ -880,12 +897,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -885,12 +904,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
}
public void tickCustomSpawners(boolean spawnMonsters, boolean spawnAnimals) {
@ -1742,78 +1720,79 @@ index f03f968d1526fbcff1ae87376370ba5976c2b807..90d78ddf8518c0df307cdaa8b7cfb554
}
}
@@ -1352,6 +1372,11 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
// Paper start- timings
final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity);
timer = isActive ? entity.getType().tickTimer.startTiming() : entity.getType().inactiveTickTimer.startTiming(); // Paper
+ // Folia start - timer
@@ -1345,6 +1367,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
});
gameprofilerfiller.incrementCounter("tickNonPassenger");
final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity); // Paper - EAR 2
+ // Folia start - profiler
+ final int timerId = isActive ? entity.getType().tickTimerId : entity.getType().inactiveTickTimerId;
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler();
+ profiler.startTimer(timerId);
+ // Folia end - timer
try {
// Paper end - timings
entity.setOldPosAndRot();
@@ -1377,7 +1402,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
+ try {
+ // Folia end - profiler
if (isActive) { // Paper - EAR 2
entity.tick();
// Folia start - region threading
@@ -1359,6 +1387,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
// Folia end - region threading
} else { entity.inactiveTick(); } // Paper - EAR 2
this.getProfiler().pop();
- } finally { timer.stopTiming(); } // Paper - timings
+ } finally { timer.stopTiming(); profiler.stopTimer(timerId); } // Paper - timings // Folia - timer
gameprofilerfiller.pop();
+ } finally { profiler.stopTimer(timerId); } // Folia - timer
Iterator iterator = entity.getPassengers().iterator();
while (iterator.hasNext()) {
@@ -1401,6 +1426,11 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
// Paper - EAR 2
final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(passenger);
co.aikar.timings.Timing timer = isActive ? passenger.getType().passengerTickTimer.startTiming() : passenger.getType().passengerInactiveTickTimer.startTiming(); // Paper
+ // Folia start - timer
@@ -1377,6 +1406,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
+ // Folia start - profiler
+ final int timerId = isActive ? passenger.getType().tickTimerId : passenger.getType().inactiveTickTimerId;
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler();
+ profiler.startTimer(timerId);
+ // Folia end - timer
try {
// Paper end
+ try {
+ // Folia end - profiler
passenger.setOldPosAndRot();
@@ -1440,7 +1470,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
this.tickPassenger(passenger, entity2);
++passenger.tickCount;
ProfilerFiller gameprofilerfiller = Profiler.get();
@@ -1414,6 +1449,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
this.tickPassenger(passenger, entity2, isActive); // Paper - EAR 2
}
- } finally { timer.stopTiming(); }// Paper - EAR2 timings
+ } finally { timer.stopTiming(); profiler.stopTimer(timerId); }// Paper - EAR2 timings // Folia - timer
+ } finally { profiler.stopTimer(timerId); } // Folia - profiler
}
} 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 20eeae6e968ecb5d67f16d0d2f56632e038a89b4..9acb477df682a27b4340e4068d6b81df1925fc0b 100644
index 577f41c32bc4ebeb8a040bb86a695a10c69b3ce8..12ae1c610f59f13416753e237fd0d7073bcd372b 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -1299,6 +1299,7 @@ public abstract class PlayerList {
@@ -1258,6 +1258,7 @@ public abstract class PlayerList {
public void saveAll(int interval) {
io.papermc.paper.util.MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
MinecraftTimings.savePlayers.startTiming(); // Paper
int numSaved = 0;
long now = System.nanoTime(); // Folia - region threading
@@ -1310,7 +1311,9 @@ public abstract class PlayerList {
long timeInterval = (long)interval * io.papermc.paper.threadedregions.TickRegionScheduler.TIME_BETWEEN_TICKS; // Folia - region threading
@@ -1268,7 +1269,9 @@ public abstract class PlayerList {
}
// Folia end - region threading
if (interval == -1 || now - entityplayer.lastSave >= timeInterval) { // Folia - region threading
if (interval == -1 || now - player.lastSave >= timeInterval) { // Folia - region threading
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.PLAYER_SAVE); try { // Folia - profiler
this.save(entityplayer);
this.save(player);
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.PLAYER_SAVE); } // Folia - profiler
// Folia start - region threading
if (interval != -1 && max != -1 && ++numSaved >= max) {
break;
if (interval != -1 && ++numSaved >= io.papermc.paper.configuration.GlobalConfiguration.get().playerAutoSave.maxPerTick()) { break; }
}
// 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 cb61462d4691a055a4b25f7b953609d8a154fdfe..c74a01a8551457507441d266b6923b4248560abf 100644
index c8c2394558952d7ca57d29874485251b8f2b3400..0d18403c6c25555f78e2d6810520839f30258c8e 100644
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
@@ -338,6 +338,13 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
@@ -412,7 +412,20 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(id));
}
- public EntityType(EntityType.EntityFactory<T> factory, MobCategory spawnGroup, boolean saveable, boolean summonable, boolean fireImmune, boolean spawnableFarFromPlayer, ImmutableSet<Block> canSpawnInside, EntityDimensions dimensions, float spawnBoxScale, int maxTrackDistance, int trackTickInterval, String translationKey, Optional<ResourceKey<LootTable>> lootTable, FeatureFlagSet requiredFeatures) {
+ // Folia start - profiler
+ public final int tickTimerId;
+ public final int inactiveTickTimerId;
@ -1821,14 +1800,8 @@ index cb61462d4691a055a4b25f7b953609d8a154fdfe..c74a01a8551457507441d266b6923b42
+ public final int passengerInactiveTickTimerId;
+ // Folia end - profiler
+
public EntityType(EntityType.EntityFactory<T> factory, MobCategory spawnGroup, boolean saveable, boolean summonable, boolean fireImmune, boolean spawnableFarFromPlayer, ImmutableSet<Block> canSpawnInside, EntityDimensions dimensions, float spawnBoxScale, int maxTrackDistance, int trackTickInterval, FeatureFlagSet requiredFeatures) {
// Paper start
this(factory, spawnGroup, saveable, summonable, fireImmune, spawnableFarFromPlayer, canSpawnInside, dimensions, spawnBoxScale, maxTrackDistance, trackTickInterval, requiredFeatures, "custom");
@@ -348,6 +355,12 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
this.passengerTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "passengerTick");
this.passengerInactiveTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "passengerInactiveTick");
// Paper end
+ // Folia start - profiler
+ public EntityType(EntityType.EntityFactory<T> factory, MobCategory spawnGroup, boolean saveable, boolean summonable, boolean fireImmune, boolean spawnableFarFromPlayer, ImmutableSet<Block> canSpawnInside, EntityDimensions dimensions, float spawnBoxScale, int maxTrackDistance, int trackTickInterval, String translationKey, Optional<ResourceKey<LootTable>> lootTable, FeatureFlagSet requiredFeatures, String id) {
+ this.tickTimerId = ca.spottedleaf.leafprofiler.LProfilerRegistry.GLOBAL_REGISTRY.getOrCreateTimer("Entity Tick: " + id);
+ this.inactiveTickTimerId = ca.spottedleaf.leafprofiler.LProfilerRegistry.GLOBAL_REGISTRY.getOrCreateTimer("Inactive Entity Tick: " + id);
+ this.passengerTickTimerId = ca.spottedleaf.leafprofiler.LProfilerRegistry.GLOBAL_REGISTRY.getOrCreateTimer("Passenger Entity Tick: " + id);
@ -1837,11 +1810,20 @@ index cb61462d4691a055a4b25f7b953609d8a154fdfe..c74a01a8551457507441d266b6923b42
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
Util.fetchChoiceType(References.ENTITY_TREE, registryKey.location().toString());
}
- return new EntityType<>(this.factory, this.category, this.serialize, this.summon, this.fireImmune, this.canSpawnFarFromPlayer, this.immuneTo, this.dimensions.withAttachments(this.attachments), this.spawnDimensionsScale, this.clientTrackingRange, this.updateInterval, (String) this.descriptionId.get(registryKey), (Optional) this.lootTable.get(registryKey), this.requiredFeatures);
+ return new EntityType<>(this.factory, this.category, this.serialize, this.summon, this.fireImmune, this.canSpawnFarFromPlayer, this.immuneTo, this.dimensions.withAttachments(this.attachments), this.spawnDimensionsScale, this.clientTrackingRange, this.updateInterval, (String) this.descriptionId.get(registryKey), (Optional) this.lootTable.get(registryKey), this.requiredFeatures, registryKey.toString()); // Folia - profiler
}
}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index db232ac0cc27ddff4bc25ba9b9a5f3a1996fc4e8..3e739362046d624dd46412f7c50a7220d26593cf 100644
index 54bafb8f67361525484c5c58ee8e6568c0801477..3d96f7ae648b47cc7494578d9776e7ea6dee0964 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -203,6 +203,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -204,6 +204,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;
}
@ -1850,104 +1832,84 @@ index db232ac0cc27ddff4bc25ba9b9a5f3a1996fc4e8..3e739362046d624dd46412f7c50a7220
+ // Folia end - profiler
@Override
public void moonrise$setEntityLookup(final ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup entityLookup) {
@@ -787,6 +790,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
this.maxSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMaxSection(this);
// Paper end - optimise collisions
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
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
+ // Folia start - profiler
+ this.tickTimerId = ca.spottedleaf.leafprofiler.LProfilerRegistry.GLOBAL_REGISTRY.getOrCreateTimer("Tick World: " + resourcekey.location().toString());
+ // Folia end - profiler
}
// Paper start - Cancel hit for vanished players
@@ -1406,17 +1412,21 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -1480,14 +1486,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
}
protected void tickBlockEntities() {
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
ProfilerFiller gameprofilerfiller = this.getProfiler();
ProfilerFiller gameprofilerfiller = Profiler.get();
gameprofilerfiller.push("blockEntities");
this.timings.tileEntityPending.startTiming(); // Spigot
final io.papermc.paper.threadedregions.RegionizedWorldData regionizedWorldData = this.getCurrentWorldData(); // Folia - regionised ticking
regionizedWorldData.seTtickingBlockEntities(true); // Folia - regionised ticking
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.TILE_ENTITY_PENDING); try { // Folia - profiler
regionizedWorldData.pushPendingTickingBlockEntities(); // Folia - regionised ticking
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.TILE_ENTITY_PENDING); } // Folia - profiler
List<TickingBlockEntity> blockEntityTickers = regionizedWorldData.getBlockEntityTickers(); // Folia - regionised ticking
this.timings.tileEntityPending.stopTiming(); // Spigot
this.timings.tileEntityTick.startTiming(); // Spigot
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.TILE_ENTITY_TICK); try { // Folia - profiler
// Spigot start
// Iterator<TickingBlockEntity> iterator = this.blockEntityTickers.iterator();
boolean flag = this.tickRateManager().runsNormally();
@@ -1445,6 +1455,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -1516,6 +1526,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
}
}
blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075 // Folia - regionised ticking
+ } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.TILE_ENTITY_TICK); } // Folia - profiler
this.timings.tileEntityTick.stopTiming(); // Spigot
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 96b99aab3720e5bdf293fd4a95944c7218ce43c0..e7691f856f85469c06f2b5a2a3db3120ec6f193d 100644
index dea945a9b278353647dca3ed001158c198dab668..422c9aeb761092496089a1b2e1dd9c5fe8f5b2bc 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
@@ -283,10 +283,17 @@ public class BlockEntityType<T extends BlockEntity> {
@@ -245,10 +245,14 @@ public class BlockEntityType<T extends BlockEntity> {
}
Type<?> type = Util.fetchChoiceType(References.BLOCK_ENTITY, id);
- return Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id, builder.build(type));
+ return Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id, builder.build(type, id)); // Folia - profiler
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
}
public BlockEntityType(BlockEntityType.BlockEntitySupplier<? extends T> factory, Set<Block> blocks, Type<?> type) {
- private BlockEntityType(BlockEntityType.BlockEntitySupplier<? extends T> factory, Set<Block> blocks) {
+ // Folia start - profiler
+ this(factory, blocks, type, "custom");
+ }
+ public final int tileEntityTimingId;
+ public BlockEntityType(BlockEntityType.BlockEntitySupplier<? extends T> factory, Set<Block> blocks, Type<?> type, String id) {
+ 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.factory = factory;
this.validBlocks = blocks;
this.dataType = type;
@@ -331,7 +338,12 @@ public class BlockEntityType<T extends BlockEntity> {
}
public BlockEntityType<T> build(Type<?> type) {
- return new BlockEntityType<>(this.factory, this.validBlocks, type);
+ // Folia start - profiler
+ return this.build(type, "custom");
+ }
+ public BlockEntityType<T> build(Type<?> type, String id) {
+ return new BlockEntityType<>(this.factory, this.validBlocks, type, id);
+ // Folia end - profiler
}
}
}
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 27e68ed3a508f16f53422c5aa1631b804c8eff9e..ea95a382561dcf2bb958a08351d493087a49336a 100644
index 877f68f9abfc659f489d6571efc1b431e1240ed6..4bccb94cf953ebd4dfd4f1620ad1784ef235356f 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -1044,11 +1044,14 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
@@ -1074,10 +1074,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
BlockPos blockposition = this.blockEntity.getBlockPos();
if (LevelChunk.this.isTicking(blockposition)) {
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
+ final int timerId = this.blockEntity.getType().tileEntityTimingId; // Folia - profiler
try {
ProfilerFiller gameprofilerfiller = LevelChunk.this.level.getProfiler();
ProfilerFiller gameprofilerfiller = Profiler.get();
gameprofilerfiller.push(this::getType);
this.blockEntity.tickTimer.startTiming(); // Spigot
+ profiler.startTimer(timerId); try { // Folia - profiler
BlockState iblockdata = LevelChunk.this.getBlockState(blockposition);
if (this.blockEntity.getType().isValid(iblockdata)) {
@@ -1063,6 +1066,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
@@ -1092,6 +1095,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
}
// Paper end - Remove the Block Entity if it's invalid
}
@ -1956,10 +1918,10 @@ index 27e68ed3a508f16f53422c5aa1631b804c8eff9e..ea95a382561dcf2bb958a08351d49308
gameprofilerfiller.pop();
} catch (Throwable throwable) {
diff --git a/src/main/java/net/minecraft/world/ticks/LevelTicks.java b/src/main/java/net/minecraft/world/ticks/LevelTicks.java
index ea161048b68de3c8cdcba5f4cb66eb1531364b2e..073d8176a7ee347f81edb18292de26629ca95e06 100644
index 3fc6b4f93885fe447ed068bc5e0784daad655696..7d3067a7df48171f6c8cda12d5da6d721c085a60 100644
--- a/src/main/java/net/minecraft/world/ticks/LevelTicks.java
+++ b/src/main/java/net/minecraft/world/ticks/LevelTicks.java
@@ -250,6 +250,12 @@ public class LevelTicks<T> implements LevelTickAccess<T> {
@@ -248,6 +248,12 @@ public class LevelTicks<T> implements LevelTickAccess<T> {
}
private void runCollectedTicks(BiConsumer<BlockPos, T> ticker) {

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Disable spark profiler
It's not thread-safe. The plugin instead needs to be used.
diff --git a/src/main/java/io/papermc/paper/SparksFly.java b/src/main/java/io/papermc/paper/SparksFly.java
index 19c4aa20617f555d02f9c1c5a93b7204ab7251d8..4b30b05dcd99176715d49133fb99b96383a0ecbc 100644
index 2ad5b9b0b7e18780ee73310451d9fa73f44c4bdb..b332645ed65928100f580221d8a9948bc77e362e 100644
--- a/src/main/java/io/papermc/paper/SparksFly.java
+++ b/src/main/java/io/papermc/paper/SparksFly.java
@@ -109,7 +109,7 @@ public final class SparksFly {
@@ -116,7 +116,7 @@ public final class SparksFly {
private void enable() {
if (!this.enabled) {
@ -18,7 +18,7 @@ index 19c4aa20617f555d02f9c1c5a93b7204ab7251d8..4b30b05dcd99176715d49133fb99b963
this.enabled = true;
this.spark.enable();
} else {
@@ -161,7 +161,7 @@ public final class SparksFly {
@@ -168,7 +168,7 @@ public final class SparksFly {
}
public static boolean isPluginPreferred() {

View File