Suppress entire CB passenger events if the entity is not valid

The event is not being called, so the checks will not do
anything. We need to bypass the checks so that we do not trip
the thread check.
This commit is contained in:
Spottedleaf 2023-03-19 17:41:24 -07:00
parent 7e948a6179
commit 106a4affdc

View File

@ -51,45 +51,41 @@ index d9687722e02dfd4088c7030abbf5008eb0a092c8..62484ebf4550b05182f693a3180bbac5
TickThread.ensureTickThread(thisEntity, "May not tick entity scheduler asynchronously"); TickThread.ensureTickThread(thisEntity, "May not tick entity scheduler asynchronously");
final List<ScheduledTask> toRun; final List<ScheduledTask> toRun;
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 58d39268a2608901a14696d36f3c59d8d6ac06e7..5b0f8e68b5e72a48119dd2cbe41e2d500fe6ccc8 100644 index 58d39268a2608901a14696d36f3c59d8d6ac06e7..021177d19384ef898667b8a374cd3838f6bd311c 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2757,7 +2757,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @@ -2756,6 +2756,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
// CraftBukkit start
com.google.common.base.Preconditions.checkState(!entity.passengers.contains(this), "Circular entity riding! %s %s", this, entity); com.google.common.base.Preconditions.checkState(!entity.passengers.contains(this), "Circular entity riding! %s %s", this, entity);
+ if (this.valid) { // Folia - region threading - suppress entire event logic during worldgen
CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle(); CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
- Entity orig = craft == null ? null : craft.getHandle(); Entity orig = craft == null ? null : craft.getHandle();
+ Entity orig = craft == null ? null : craft.getHandleRaw(); // Folia - region threading
if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) { if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
VehicleEnterEvent event = new VehicleEnterEvent( @@ -2783,6 +2784,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
(Vehicle) this.getBukkitEntity(), if (event.isCancelled()) {
@@ -2768,7 +2768,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return false;
Bukkit.getPluginManager().callEvent(event); }
} + } // Folia - region threading - suppress entire event logic during worldgen
CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle(); // Spigot end
- Entity n = craftn == null ? null : craftn.getHandle(); if (this.passengers.isEmpty()) {
+ Entity n = craftn == null ? null : craftn.getHandleRaw(); // Folia - region threading this.passengers = ImmutableList.of(entity);
if (event.isCancelled() || n != orig) { @@ -2810,6 +2812,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return false; throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
}
@@ -2811,7 +2811,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
} else { } else {
// CraftBukkit start // CraftBukkit start
+ if (this.valid) { // Folia - region threading - suppress entire event logic during worldgen
CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle(); CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
- Entity orig = craft == null ? null : craft.getHandle(); Entity orig = craft == null ? null : craft.getHandle();
+ Entity orig = craft == null ? null : craft.getHandleRaw(); // Folia - region threading
if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) { if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
VehicleExitEvent event = new VehicleExitEvent( @@ -2837,6 +2840,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
(Vehicle) this.getBukkitEntity(), if (event.isCancelled()) {
@@ -2822,7 +2822,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return false;
Bukkit.getPluginManager().callEvent(event); }
} + } // Folia - region threading - suppress entire event logic during worldgen
CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle(); // Spigot end
- Entity n = craftn == null ? null : craftn.getHandle(); if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
+ Entity n = craftn == null ? null : craftn.getHandleRaw(); // Folia - region threading this.passengers = ImmutableList.of();
if (event.isCancelled() || n != orig) {
return false;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java
index 825fdc6162797ade8e76e1ca3a863ed5fb48f936..f812ad4a4d6c640c3f3f2d5766ee2b5882583cc5 100644 index 825fdc6162797ade8e76e1ca3a863ed5fb48f936..f812ad4a4d6c640c3f3f2d5766ee2b5882583cc5 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java --- a/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java