9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-28 19:39:17 +00:00

fix NPE on isParallelCancelledByPlugin

This commit is contained in:
Taiyou06
2025-04-28 20:47:15 +02:00
parent 1bddbe19f0
commit 92876d4b12
3 changed files with 19 additions and 11 deletions

View File

@@ -743,10 +743,10 @@ index b17c8a2f5294ac28cc05fb05c84a041b2c6c8721..0b8b4658dbbad1bacc13e97b4fc0cdce
serverPlayer.connection = player.connection;
serverPlayer.restoreFrom(player, keepInventory);
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 9bc978ca290ca772b0367e89b69fe16b502b0cd2..17ff57db6f90b3f4facef691ad4347e67a9f5836 100644
index 9bc978ca290ca772b0367e89b69fe16b502b0cd2..2f98d035b32d3a9b3366dbea0ac52b24d06dd373 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -3370,15 +3370,33 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3370,15 +3370,41 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
if (this.portalProcess != null) {
if (this.portalProcess.processPortalTeleportation(serverLevel, this, this.canUsePortal(false))) {
this.setPortalCooldown();
@@ -760,6 +760,12 @@ index 9bc978ca290ca772b0367e89b69fe16b502b0cd2..17ff57db6f90b3f4facef691ad4347e6
+ // TCRF SparklyPaper (Pathothingi) start - parallel world ticking
+ java.util.function.Consumer<Entity> portalEntityTask = entity -> {
+ assert entity.portalProcess != null;
+ // Leaf start - Fix NPE when portalProcess becomes null before task execution
+ if (entity.portalProcess == null) {
+ // Portal process was likely nulled out (e.g., expired) between scheduling and execution.
+ return;
+ }
+ // Leaf end - Fix NPE
+
+ if (entity.portalProcess.isParallelCancelledByPlugin()) {
+ entity.portalProcess = null;
@@ -775,8 +781,10 @@ index 9bc978ca290ca772b0367e89b69fe16b502b0cd2..17ff57db6f90b3f4facef691ad4347e6
+ entity.teleport(portalDestination);
+ }
+ }
+ if (this.portalProcess != null)
+ // Add another null check here just in case teleport() somehow nulled it (defensive)
+ if (entity.portalProcess != null) {
+ entity.portalProcess.confirmParallelAsHandled();
+ }
+ };
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled) {
+ this.portalProcess.setParallelAsScheduled();
@@ -787,7 +795,7 @@ index 9bc978ca290ca772b0367e89b69fe16b502b0cd2..17ff57db6f90b3f4facef691ad4347e6
} else if (this.portalProcess.hasExpired()) {
this.portalProcess = null;
}
@@ -3908,6 +3926,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3908,6 +3934,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}
private Entity teleportCrossDimension(ServerLevel level, TeleportTransition teleportTransition) {

View File

@@ -11,10 +11,10 @@ As part of: Airplane (https://github.com/TECHNOVE/Airplane)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 17ff57db6f90b3f4facef691ad4347e67a9f5836..075fcbcde23b5bb7b27ff622e8d188c3a2583973 100644
index 2f98d035b32d3a9b3366dbea0ac52b24d06dd373..90879616842cc61d15854b07f56f6fcb89f11074 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -4614,10 +4614,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4622,10 +4622,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
// Paper start - optimise collisions
public boolean updateFluidHeightAndDoFluidPushing(final TagKey<Fluid> fluid, final double flowScale) {
@@ -26,7 +26,7 @@ index 17ff57db6f90b3f4facef691ad4347e67a9f5836..075fcbcde23b5bb7b27ff622e8d188c3
final AABB boundingBox = this.getBoundingBox().deflate(1.0E-3);
final Level world = this.level;
@@ -4653,7 +4650,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4661,7 +4658,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
for (int currChunkX = minChunkX; currChunkX <= maxChunkX; ++currChunkX) {

View File

@@ -77,7 +77,7 @@ index 90bdcd168ad5b1a940f81b191bd59a34d3a33070..051bf2ec9c312460b1379cea0f8a2a3a
// Paper - rewrite chunk system
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 075fcbcde23b5bb7b27ff622e8d188c3a2583973..e5aa7c542b1e9c9362aa1feeeebef45919feac70 100644
index 90879616842cc61d15854b07f56f6fcb89f11074..0ae36986492d98f46ccf409f6b71ed9cfca488e7 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -243,6 +243,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -88,7 +88,7 @@ index 075fcbcde23b5bb7b27ff622e8d188c3a2583973..e5aa7c542b1e9c9362aa1feeeebef459
public static final float DEFAULT_BB_WIDTH = 0.6F;
public static final float DEFAULT_BB_HEIGHT = 1.8F;
public float moveDist;
@@ -5028,7 +5029,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -5036,7 +5037,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}
public final boolean isRemoved() {
@@ -103,7 +103,7 @@ index 075fcbcde23b5bb7b27ff622e8d188c3a2583973..e5aa7c542b1e9c9362aa1feeeebef459
}
@Nullable
@@ -5055,6 +5062,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -5063,6 +5070,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
if (this.removalReason == null) {
this.removalReason = removalReason;
@@ -115,7 +115,7 @@ index 075fcbcde23b5bb7b27ff622e8d188c3a2583973..e5aa7c542b1e9c9362aa1feeeebef459
}
if (this.removalReason.shouldDestroy()) {
@@ -5074,6 +5086,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -5082,6 +5094,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
public void unsetRemoved() {
this.removalReason = null;