Fix 2 incorrect threading checks (#17)

* Fix 2 incorrect threading checks

* Fix bad catcher methods, fix missing async catcher

---------

Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
This commit is contained in:
Jake Potrebic 2023-03-31 17:15:16 -07:00 committed by GitHub
parent fbf832bc05
commit 508a6688e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18748,7 +18748,7 @@ index 4705d7066207250c03a5f98eef61554c901f2e35..17b3c16008d801fa61cb3e7d89f31a4e
public void unsetRemoved() {
this.removalReason = null;
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index dcfb71b5a53df789e366fea2080921d677549a2e..485e5c3f1348f9e79f48f6ec3fad34fa58dcfe73 100644
index dcfb71b5a53df789e366fea2080921d677549a2e..4f8062432cfe6480664e674fde0255f07b15c73a 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -464,7 +464,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@ -18789,6 +18789,15 @@ index dcfb71b5a53df789e366fea2080921d677549a2e..485e5c3f1348f9e79f48f6ec3fad34fa
String s = nbt.getString("Team");
PlayerTeam scoreboardteam = this.level.getScoreboard().getPlayerTeam(s);
if (!level.paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof net.minecraft.world.entity.player.Player)) { scoreboardteam = null; } // Paper
@@ -1117,7 +1120,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
public boolean addEffect(MobEffectInstance mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause) {
- org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot
+ io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot add effects to entities asynchronously"); // Folia - region threading
if (this.isTickingEffects) {
this.effectsToProcess.add(new ProcessableEffect(mobeffect, cause));
return true;
@@ -2266,7 +2269,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@Nullable
@ -20068,6 +20077,22 @@ index fabce3bc592b1b172b227395a07febdbb66ec3c9..ebdbadc1dba41f47ba4795ea43020b80
double d1 = raid1.getCenter().distSqr(pos);
if (raid1.isActive() && d1 < d0) {
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java b/src/main/java/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java
index 1fe630118981b02092054af3c5c6227a889ee3c2..57ecc5e506c895fe701cb24c9b503d6009602a26 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java
@@ -145,5 +145,11 @@ public class MinecartCommandBlock extends AbstractMinecart {
return (org.bukkit.craftbukkit.entity.CraftMinecartCommand) MinecartCommandBlock.this.getBukkitEntity();
}
// CraftBukkit end
+ // Folia start
+ @Override
+ public void threadCheck() {
+ io.papermc.paper.util.TickThread.ensureTickThread(MinecartCommandBlock.this, "Asynchronous sendSystemMessage to a command block");
+ }
+ // Folia end
}
}
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java b/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java
index 1b8f22805af87dc08e0dea9fd93a5f93c0b05107..00bc99948ddd67bb85c3797f869064540a8b1213 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java
@ -20275,7 +20300,7 @@ index c6d2f764efa9b8bec730bbe757d480e365b25ccc..af9313a3b3aaa0af4f2a2f4fb2424dc3
}
diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
index 888936385196a178ab8b730fd5e4fff4a5466428..df4632a6ddef8744df160163c99bdcdd6225dd97 100644
index 888936385196a178ab8b730fd5e4fff4a5466428..7f09f2864c73c8e144475f2168e4a9d9b8aa4642 100644
--- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
+++ b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
@@ -111,6 +111,7 @@ public abstract class BaseCommandBlock implements CommandSource {
@ -20286,6 +20311,20 @@ index 888936385196a178ab8b730fd5e4fff4a5466428..df4632a6ddef8744df160163c99bdcdd
if (!world.isClientSide && world.getGameTime() != this.lastExecution) {
if ("Searge".equalsIgnoreCase(this.command)) {
this.lastOutput = Component.literal("#itzlipofutzli");
@@ -169,10 +170,12 @@ public abstract class BaseCommandBlock implements CommandSource {
}
+ public void threadCheck() {} // Folia
+
@Override
public void sendSystemMessage(Component message) {
if (this.trackOutput) {
- org.spigotmc.AsyncCatcher.catchOp("sendSystemMessage to a command block"); // Paper
+ this.threadCheck(); // Folia
SimpleDateFormat simpledateformat = BaseCommandBlock.TIME_FORMAT;
Date date = new Date();
diff --git a/src/main/java/net/minecraft/world/level/EntityGetter.java b/src/main/java/net/minecraft/world/level/EntityGetter.java
index 3b959f42d958bf0f426853aee56753d6c455fcdb..b1a6a66ed02706c1adc36dcedfa415f5a24a25a0 100644
--- a/src/main/java/net/minecraft/world/level/EntityGetter.java
@ -21576,6 +21615,23 @@ index c57efcb9a79337ec791e4e8f6671612f0a82b441..526d1bfd5ad0de7bcfd0c2da902515f3
boolean flag2 = blockEntity.brewTime <= 0; // == -> <=
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/world/level/block/entity/CommandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/CommandBlockEntity.java
index a33d98a3ab2d00256e3c85b3de3680b4765df8d3..b311d150b0e4f1e36ba22042b02d8acd2cd5ce8c 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/CommandBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/CommandBlockEntity.java
@@ -56,6 +56,12 @@ public class CommandBlockEntity extends BlockEntity {
return new CommandSourceStack(this, Vec3.atCenterOf(CommandBlockEntity.this.worldPosition), new Vec2(0.0F, enumdirection.toYRot()), this.getLevel(), 2, this.getName().getString(), this.getName(), this.getLevel().getServer(), (Entity) null);
}
+ // Folia start
+ @Override
+ public void threadCheck() {
+ io.papermc.paper.util.TickThread.ensureTickThread((ServerLevel) CommandBlockEntity.this.level, CommandBlockEntity.this.worldPosition, "Asynchronous sendSystemMessage to a command block");
+ }
+ // Folia end
};
public CommandBlockEntity(BlockPos pos, BlockState state) {
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
index 963a596154091b79ca139af6274aa323518ad1ad..57b11cb78270a8094f772da497ad3264a0a67db1 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java