From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sun, 19 Mar 2023 14:35:46 -0700 Subject: [PATCH] Make CraftEntity#getHandle and overrides perform thread checks While these checks are painful, it should assist in debugging threading issues for plugins. diff --git a/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java b/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java index 41bf71d116ffc5431586ce54abba7f8def6c1dcf..519da6886613b8460e989767b1a21e3126cb1894 100644 --- a/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java +++ b/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java @@ -11,8 +11,16 @@ public class PaperSchoolableFish extends CraftFish implements SchoolableFish { super(server, entity); } + // Folia start - region threading + @Override + public AbstractSchoolingFish getHandleRaw() { + return (AbstractSchoolingFish)this.entity; + } + // Folia end - region threading + @Override public AbstractSchoolingFish getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (AbstractSchoolingFish) super.getHandle(); } diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 6b101ccddc811483cc1b8652685313baa06cae30..8b28f6fed78cbad95b7943efb05099edd9eeed57 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -2819,6 +2819,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) { return false; } else { + if (this.valid) { // Folia - region threading - suppress entire event logic during worldgen // CraftBukkit start if (entity.getBukkitEntity() instanceof Vehicle && this.getBukkitEntity() instanceof LivingEntity) { VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.getBukkitEntity()); @@ -2840,6 +2841,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (event.isCancelled()) { return false; } + } // Folia - region threading - suppress entire event logic during worldgen // Spigot end if (this.isPassenger()) { this.stopRiding(); @@ -2922,6 +2924,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); } else { // CraftBukkit start + if (this.valid) { // Folia - region threading - suppress entire event logic during worldgen CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle(); Entity orig = craft == null ? null : craft.getHandle(); if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) { @@ -2949,6 +2952,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (event.isCancelled()) { return false; } + } // Folia - region threading - suppress entire event logic during worldgen // Spigot end if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { this.passengers = ImmutableList.of(); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java index 5e82b2d57833fea1adb342f5c8d25f55491945cb..2c46527dfe832919b055579a0876a043c06d8b67 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.entity; +import net.minecraft.world.entity.Entity; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Projectile; @@ -42,6 +43,13 @@ public abstract class AbstractProjectile extends CraftEntity implements Projecti this.getHandle().hasBeenShot = beenShot; } + // Folia start - region threading + @Override + public net.minecraft.world.entity.projectile.Projectile getHandleRaw() { + return (net.minecraft.world.entity.projectile.Projectile)this.entity; + } + // Folia end - region threading + @Override public boolean canHitEntity(org.bukkit.entity.Entity entity) { return this.getHandle().canHitEntity(((CraftEntity) entity).getHandle()); @@ -59,6 +67,7 @@ public abstract class AbstractProjectile extends CraftEntity implements Projecti @Override public net.minecraft.world.entity.projectile.Projectile getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.projectile.Projectile) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java index 90a989c7c9de6f9ba55ab640761915e98320642a..c43ce4c9f6d011a7403dd37ff62953aba29852aa 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java @@ -17,8 +17,16 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.horse.AbstractHorse getHandleRaw() { + return (net.minecraft.world.entity.animal.horse.AbstractHorse)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.horse.AbstractHorse getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.horse.AbstractHorse) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java index 5beaa2bb0d58fe477ce8d2de8b77600d3b416d8c..fa1bc80ae320c6d04acc20d6dec7df52a39d9920 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java @@ -15,8 +15,17 @@ public abstract class CraftAbstractSkeleton extends CraftMonster implements Abst throw new UnsupportedOperationException("Not supported."); } // Paper start + + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.AbstractSkeleton getHandleRaw() { + return (net.minecraft.world.entity.monster.AbstractSkeleton)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.AbstractSkeleton getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.AbstractSkeleton) super.getHandle(); } // Paper end diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java index 762354681315e4c74e414bf7d677b5422385161e..e3d57d4f65d1f3c03f407d497ff360dcd40a0fb1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java @@ -17,8 +17,16 @@ public class CraftAbstractVillager extends CraftAgeable implements AbstractVilla super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.npc.AbstractVillager getHandleRaw() { + return (net.minecraft.world.entity.npc.AbstractVillager)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.npc.AbstractVillager getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (Villager) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java index f6d9ccc993a067e554d6a7ef98c5fff1392efaef..69118f8ff00755ba1c31845a2704dd95fa2aee6e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java @@ -63,8 +63,16 @@ public class CraftAgeable extends CraftCreature implements Ageable { } } + // Folia start - region threading + @Override + public AgeableMob getHandleRaw() { + return (AgeableMob)this.entity; + } + // Folia end - region threading + @Override public AgeableMob getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (AgeableMob) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java index debccfa7cb5517a877c06b13468db57534ace77e..18044b45cc001739406f8151c54f06b5d70d17e0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java @@ -17,8 +17,16 @@ public class CraftAllay extends CraftCreature implements org.bukkit.entity.Allay super(server, entity); } + // Folia start - region threading + @Override + public Allay getHandleRaw() { + return (Allay)this.entity; + } + // Folia end - region threading + @Override public Allay getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (Allay) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java index 91573773dba9ca008d209bb4f9c11e82b9d33d26..93d9b4c40aa545d57650a411316210d193a6d3d7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java @@ -10,8 +10,16 @@ public class CraftAmbient extends CraftMob implements Ambient { super(server, entity); } + // Folia start - region threading + @Override + public AmbientCreature getHandleRaw() { + return (AmbientCreature)this.entity; + } + // Folia end - region threading + @Override public AmbientCreature getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (AmbientCreature) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java index 56bc26f227b97e8e935a20c6393d3f2eb806b285..5cf8ea3a7dd4e8ea96ca6061aa1aaefc7ac8fcce 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java @@ -15,8 +15,16 @@ public class CraftAnimals extends CraftAgeable implements Animals { super(server, entity); } + // Folia start - region threading + @Override + public Animal getHandleRaw() { + return (Animal)this.entity; + } + // Folia end - region threading + @Override public Animal getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (Animal) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java index c73a9c930c6fa3a7b85986048dca8dc11aa05238..fb5df44773c478c1418a63429b15b96e2efd5f9a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java @@ -26,8 +26,16 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.AreaEffectCloud getHandleRaw() { + return (net.minecraft.world.entity.AreaEffectCloud)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.AreaEffectCloud getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.AreaEffectCloud) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java index 17d08d2c90047ebfc4098b087be091b83111a40f..f678c151938ddd3e5277a05d6d8884c12b114336 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java @@ -26,8 +26,16 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand { return EntityType.ARMOR_STAND; } + // Folia start - region threading + @Override + public net.minecraft.world.entity.decoration.ArmorStand getHandleRaw() { + return (net.minecraft.world.entity.decoration.ArmorStand)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.decoration.ArmorStand getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.decoration.ArmorStand) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java index 10e2d251ec398245786a0b3bd41f3bc7155a49fe..6050a3209d893dc4b1f65f14f815840390c14eb0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java @@ -143,8 +143,16 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { this.getHandle().setShotFromCrossbow(shotFromCrossbow); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.projectile.AbstractArrow getHandleRaw() { + return (net.minecraft.world.entity.projectile.AbstractArrow)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.projectile.AbstractArrow getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.projectile.AbstractArrow) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java index a82acbbe62bf6aa497e627587e2f3b9be2fbf487..dec03f00091ca781f0eaa4063649883f47040b07 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java @@ -11,8 +11,16 @@ public class CraftAxolotl extends CraftAnimals implements Axolotl, io.papermc.pa super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.axolotl.Axolotl getHandleRaw() { + return (net.minecraft.world.entity.animal.axolotl.Axolotl)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.axolotl.Axolotl getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.axolotl.Axolotl) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java index e405488ba5e0159ff84a72fac1d2da6e9c45238e..631250c15711d0912d2ae34efed02d78d20a0098 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java @@ -9,8 +9,16 @@ public class CraftBat extends CraftAmbient implements Bat { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.ambient.Bat getHandleRaw() { + return (net.minecraft.world.entity.ambient.Bat)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.ambient.Bat getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.ambient.Bat) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java index e222a6ab6afbc43a3d358a79855a818b0e481fdb..1e636646e3baa7a77c008d9109e0dccfbc497d6e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java @@ -14,8 +14,16 @@ public class CraftBee extends CraftAnimals implements Bee { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Bee getHandleRaw() { + return (net.minecraft.world.entity.animal.Bee)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Bee getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Bee) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlaze.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlaze.java index 84cd915955188492696e5948fbb1c4eca0cca039..7dfbf7f7a94eae0c62d6830d459c34784a7e518c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlaze.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlaze.java @@ -9,8 +9,16 @@ public class CraftBlaze extends CraftMonster implements Blaze { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Blaze getHandleRaw() { + return (net.minecraft.world.entity.monster.Blaze)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Blaze getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Blaze) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java index 2592a838b1b1fe4db98b95327dfd4f9774a0390b..29ac4ef7d2ed35e10df539b055db087f741fe4b6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java @@ -13,8 +13,16 @@ public class CraftBlockDisplay extends CraftDisplay implements BlockDisplay { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.Display.BlockDisplay getHandleRaw() { + return (net.minecraft.world.entity.Display.BlockDisplay)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.Display.BlockDisplay getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.Display.BlockDisplay) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java index dd7076938b04d4b36e3360a883bae81ced455fda..6671a86496394a786034cab7defa8126b55e8d5e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java @@ -92,8 +92,16 @@ public class CraftBoat extends CraftVehicle implements Boat { 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; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.vehicle.Boat getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.vehicle.Boat) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java index 509232424f6596d0ac43ba0d59b24e2bbdcbed0f..17dc189187e343db0e91f642a2edc782c6419ab9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java @@ -12,8 +12,16 @@ public class CraftCamel extends CraftAbstractHorse implements Camel { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.camel.Camel getHandleRaw() { + return (net.minecraft.world.entity.animal.camel.Camel)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.camel.Camel getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.camel.Camel) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java index 273a062090f4c6f6ffd5a4238623b32af497f6b6..d2d54ba55b65108c7fdff6e6850982351f6127a6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java @@ -14,8 +14,16 @@ public class CraftCat extends CraftTameableAnimal implements Cat { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Cat getHandleRaw() { + return (net.minecraft.world.entity.animal.Cat)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Cat getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Cat) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java index f7e2b55ac149fa421d5733c2c6a103eb6ef45ef4..86fee0d40a9dc6a18ec19dc3d85978f38b8d1cd0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java @@ -9,8 +9,16 @@ public class CraftCaveSpider extends CraftSpider implements CaveSpider { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.CaveSpider getHandleRaw() { + return (net.minecraft.world.entity.monster.CaveSpider)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.CaveSpider getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.CaveSpider) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java index 06a96f027f90fd5bf05de72c8722ff5a81608b66..0c9400446c2c69e4bd95d167c61ffe22442b4d35 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java @@ -19,8 +19,16 @@ public class CraftChestBoat extends CraftBoat implements org.bukkit.entity.Chest this.inventory = new CraftInventory(entity); } + // Folia start - region threading + @Override + public ChestBoat getHandleRaw() { + return (ChestBoat)this.entity; + } + // Folia end - region threading + @Override public ChestBoat getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (ChestBoat) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java index 40ee96e31dea64ab3a77553dbb6daad001736f2e..1a9986acde12881e32db67b9e7263072871331cb 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java @@ -10,8 +10,16 @@ public abstract class CraftChestedHorse extends CraftAbstractHorse implements Ch super(server, entity); } + // Folia start - region threading + @Override + public AbstractChestedHorse getHandleRaw() { + return (AbstractChestedHorse)this.entity; + } + // Folia end - region threading + @Override public AbstractChestedHorse getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (AbstractChestedHorse) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java index fd87f979ee207dac13e4028d76bdd40911509e56..7066741a251d24c754058aa2553b9430de5b42d3 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java @@ -10,8 +10,16 @@ public class CraftChicken extends CraftAnimals implements Chicken { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Chicken getHandleRaw() { + return (net.minecraft.world.entity.animal.Chicken)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Chicken getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Chicken) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java index 801ed8241cad4ac890a6d99cd19a3dd7490d9339..f3b587295e90f58b0885bc3c7070b62f3cf7805d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java @@ -10,8 +10,16 @@ public class CraftCod extends io.papermc.paper.entity.PaperSchoolableFish implem super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Cod getHandleRaw() { + return (net.minecraft.world.entity.animal.Cod)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Cod getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Cod) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java index cdc000f3fd4d39c1f2ff9dc820eeb019c57bdfa0..54aaee0d0d72c76a02e1ab5d51c47b26b6d08b93 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java @@ -33,8 +33,16 @@ public class CraftComplexPart extends CraftEntity implements ComplexEntityPart { return this.getParent().isValid(); } + // Folia start - region threading + @Override + public EnderDragonPart getHandleRaw() { + return (EnderDragonPart)this.entity; + } + // Folia end - region threading + @Override public EnderDragonPart getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (EnderDragonPart) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java index c7545c8a7272cb28d97e23c15a31e33477a7d96e..a8514a688a6fe4f19000f8f127b0a1277e4f754d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java @@ -10,8 +10,16 @@ public class CraftCow extends CraftAnimals implements Cow { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Cow getHandleRaw() { + return (net.minecraft.world.entity.animal.Cow)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Cow getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Cow) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java index 5bc62af195a7b11182d411296c978b4f6f5f837f..062a625e178ac9bbbb26f3d6548fb663b01d889b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java @@ -9,8 +9,16 @@ public class CraftCreature extends CraftMob implements Creature { super(server, entity); } + // Folia start - region threading + @Override + public PathfinderMob getHandleRaw() { + return (PathfinderMob)this.entity; + } + // Folia end - region threading + @Override public PathfinderMob getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (PathfinderMob) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java index 63a8188010f045d5c17a1ecb63e8081ec86c2960..24c6c26f0930940f88bdd0353d660ff31a0d7c33 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java @@ -80,8 +80,16 @@ public class CraftCreeper extends CraftMonster implements Creeper { this.getHandle().ignite(); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Creeper getHandleRaw() { + return (net.minecraft.world.entity.monster.Creeper)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Creeper getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Creeper) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java index 2f7bf9963c3adfc9d2475a86e53a7dcf9f386bfe..e5ffc16d4d5595a7065119c97293f5b419b5a274 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java @@ -13,8 +13,16 @@ public class CraftDisplay extends CraftEntity implements Display { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.Display getHandleRaw() { + return (net.minecraft.world.entity.Display)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.Display getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.Display) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java index 18623159932df2dd5e43133b4396b43731693780..66f3a67ea0a81d4cfff8365ed055fff6967360b7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java @@ -10,8 +10,16 @@ public class CraftDolphin extends CraftWaterMob implements Dolphin { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Dolphin getHandleRaw() { + return (net.minecraft.world.entity.animal.Dolphin)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Dolphin getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Dolphin) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java index 03e2acd4829da449a471b0fa1a311e74aee114d3..921a36e31f531ab43e9040463f66d8c081469ef4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java @@ -10,8 +10,16 @@ public class CraftDrowned extends CraftZombie implements Drowned, com.destroysto super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Drowned getHandleRaw() { + return (net.minecraft.world.entity.monster.Drowned)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Drowned getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Drowned) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java index 6ac40fab0155f3b54a8ab7f492f42c952ee2377c..c439ab4e1db346d01c5de4ad9f2ce48e8830a081 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java @@ -10,8 +10,16 @@ public class CraftEgg extends CraftThrowableProjectile implements Egg { super(server, entity); } + // Folia start - region threading + @Override + public ThrownEgg getHandleRaw() { + return (ThrownEgg)this.entity; + } + // Folia end - region threading + @Override public ThrownEgg getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (ThrownEgg) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java index 4c7f074a1f7aa43af6fe331bbd5d23929780ab25..d07b70f42c87a92fe662fc27a2eefa474db87bcc 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java @@ -40,8 +40,16 @@ public class CraftEnderCrystal extends CraftEntity implements EnderCrystal { } } + // Folia start - region threading + @Override + public EndCrystal getHandleRaw() { + return (EndCrystal)this.entity; + } + // Folia end - region threading + @Override public EndCrystal getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (EndCrystal) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java index 92bcc01b3b28062aa966a7aaca199d7a3be832f4..10b827cb126d937548cc29a1b052d5acfa244f67 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java @@ -31,8 +31,16 @@ public class CraftEnderDragon extends CraftMob implements EnderDragon, CraftEnem return builder.build(); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.boss.enderdragon.EnderDragon getHandleRaw() { + return (net.minecraft.world.entity.boss.enderdragon.EnderDragon)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.boss.enderdragon.EnderDragon getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.boss.enderdragon.EnderDragon) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java index a407e802164603c74ec1f4ad3c98bc50398954bc..c1f73d89805eca8e13bdee80bcd89ef23cc4b332 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java @@ -15,8 +15,16 @@ public class CraftEnderDragonPart extends CraftComplexPart implements EnderDrago return (EnderDragon) super.getParent(); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.boss.EnderDragonPart getHandleRaw() { + return (net.minecraft.world.entity.boss.EnderDragonPart)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.boss.EnderDragonPart getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.boss.EnderDragonPart) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java index 21d5d8d4becee2709295d45b4b4fd2d1edbd3910..0cc66673866bd20ef74437866765134b0be503d3 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java @@ -10,8 +10,16 @@ public class CraftEnderPearl extends CraftThrowableProjectile implements EnderPe super(server, entity); } + // Folia start - region threading + @Override + public ThrownEnderpearl getHandleRaw() { + return (ThrownEnderpearl)this.entity; + } + // Folia end - region threading + @Override public ThrownEnderpearl getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (ThrownEnderpearl) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java index e3688e941d9b63b5319faf9370b8f75e0e5828ae..631dce2beaa9c8d72d45349a436d72c5417e8de7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java @@ -16,8 +16,16 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal { super(server, entity); } + // Folia start - region threading + @Override + public EyeOfEnder getHandleRaw() { + return (EyeOfEnder)this.entity; + } + // Folia end - region threading + @Override public EyeOfEnder getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (EyeOfEnder) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java index 57704564acc11ea688026aad8be4e612e36803ff..6061d0ea83479611d2c33cf0e001cd43e75c03c4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java @@ -63,8 +63,16 @@ public class CraftEnderman extends CraftMonster implements Enderman { } // Paper end + // Folia start - region threading + @Override + public EnderMan getHandleRaw() { + return (EnderMan)this.entity; + } + // Folia end - region threading + @Override public EnderMan getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (EnderMan) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java index 75c7645fb5732c43d1da15181cf5c7ee4c3ecd6c..6d3325436a77153438bc40aa86819562e65e6a9e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java @@ -10,8 +10,16 @@ public class CraftEndermite extends CraftMonster implements Endermite { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Endermite getHandleRaw() { + return (net.minecraft.world.entity.monster.Endermite)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Endermite getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Endermite) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index dafac02b73326aa04093f16ac2f142004abe26be..19b47478d318edce1242c2a5ddd73da963a24595 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -821,7 +821,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 @@ -836,6 +836,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } public Entity getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java index 7e861636710aa44ed36e7f20c6320dabb809c35d..6d7f99943ae6453edeecaea06f4a906b7b20daaf 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java @@ -12,8 +12,16 @@ public class CraftEvoker extends CraftSpellcaster implements Evoker { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Evoker getHandleRaw() { + return (net.minecraft.world.entity.monster.Evoker)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Evoker getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Evoker) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java index 0d186f37987edfd380dbce96252a45bdc2e8c26b..9fe7028cde18e4936cd2fc62a359feb6386596b3 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java @@ -11,8 +11,16 @@ public class CraftEvokerFangs extends CraftEntity implements EvokerFangs { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.projectile.EvokerFangs getHandleRaw() { + return (net.minecraft.world.entity.projectile.EvokerFangs)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.projectile.EvokerFangs getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.projectile.EvokerFangs) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java index 84899284703baeb04bfc79251941265d52ac07e8..5b8333e342c639f33acf62e5f8eb72d0ba4a68c7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java @@ -31,8 +31,16 @@ public class CraftExperienceOrb extends CraftEntity implements ExperienceOrb { } // Paper end + // Folia start - region threading + @Override + public net.minecraft.world.entity.ExperienceOrb getHandleRaw() { + return (net.minecraft.world.entity.ExperienceOrb)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.ExperienceOrb getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.ExperienceOrb) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java index d17808d132b332d51189067fed245eb6bb904968..fc7d7c0645ff9a8b4d6a0bc78cf6bd64d1a0d858 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java @@ -15,8 +15,16 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock { super(server, entity); } + // Folia start - region threading + @Override + public FallingBlockEntity getHandleRaw() { + return (FallingBlockEntity)this.entity; + } + // Folia end - region threading + @Override public FallingBlockEntity getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (FallingBlockEntity) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java index 1fdf52edc47591bf3d8bbcb9db9d41773aace42f..bd1ed5b1e58cb3ce40036a602acbb0b7a7e6322b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java @@ -47,8 +47,16 @@ public class CraftFireball extends AbstractProjectile implements Fireball { update(); // SPIGOT-6579 } + // Folia start - region threading + @Override + public AbstractHurtingProjectile getHandleRaw() { + return (AbstractHurtingProjectile)this.entity; + } + // Folia end - region threading + @Override public AbstractHurtingProjectile getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (AbstractHurtingProjectile) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java index d1c7ab67cba881d96b7a5e9220130d86d0514304..851cb3216184180667b068f36984bff4a7765c49 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java @@ -38,8 +38,16 @@ public class CraftFirework extends CraftProjectile implements Firework { // Paper End - Expose firework item directly } + // Folia start - region threading + @Override + public FireworkRocketEntity getHandleRaw() { + return (FireworkRocketEntity)this.entity; + } + // Folia end - region threading + @Override public FireworkRocketEntity getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (FireworkRocketEntity) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java index 3c64461119391ec2e987fc936104e21ef0a95ce4..d702e34f65de28df677a9d3616f38b2cf9abfa23 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java @@ -10,8 +10,16 @@ public class CraftFish extends CraftWaterMob implements Fish, io.papermc.paper.e super(server, entity); } + // Folia start - region threading + @Override + public AbstractFish getHandleRaw() { + return (AbstractFish)this.entity; + } + // Folia end - region threading + @Override public AbstractFish getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (AbstractFish) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java index 41e8167766383a6fcb1e9fb78933d74784caddbb..d73d18e10d9a75a43f9352f5eebaa3be485e3572 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java @@ -15,8 +15,16 @@ public class CraftFishHook extends CraftProjectile implements FishHook { super(server, entity); } + // Folia start - region threading + @Override + public FishingHook getHandleRaw() { + return (FishingHook)this.entity; + } + // Folia end - region threading + @Override public FishingHook getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (FishingHook) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java index 8038e1bdac4166bfaf228118e87cb246cb49b9a1..e1e51f050959aa23bd85bb794a7098a549c819c8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java @@ -10,8 +10,16 @@ public class CraftFlying extends CraftMob implements Flying { super(server, entity); } + // Folia start - region threading + @Override + public FlyingMob getHandleRaw() { + return (FlyingMob)this.entity; + } + // Folia end - region threading + @Override public FlyingMob getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (FlyingMob) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java index 9e5c9b1c4299986b2fae7e191d7661549376a331..36997290fa276275bbcf890a7b368f40a9ad8e02 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java @@ -15,8 +15,16 @@ public class CraftFox extends CraftAnimals implements Fox { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Fox getHandleRaw() { + return (net.minecraft.world.entity.animal.Fox)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Fox getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Fox) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java index d67884a83866cdfe14d4f5025e2ff159b6e3ee5d..67e24a4c1daf6c986e34c4a41fb45285809b348f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java @@ -15,8 +15,16 @@ public class CraftFrog extends CraftAnimals implements org.bukkit.entity.Frog { super(server, entity); } + // Folia start - region threading + @Override + public Frog getHandleRaw() { + return (Frog)this.entity; + } + // Folia end - region threading + @Override public Frog getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (Frog) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java index 814cded47a04c25391575af036f53dc409121813..308c39b5721dbf70ad256e5ccacc04831af398d5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java @@ -10,8 +10,16 @@ public class CraftGhast extends CraftFlying implements Ghast, CraftEnemy { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Ghast getHandleRaw() { + return (net.minecraft.world.entity.monster.Ghast)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Ghast getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Ghast) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGiant.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGiant.java index ae6c37627bf6b31b207e65c07c6b3f9def222d1d..f0a04ca56bd58844b40101190772786457239151 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGiant.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGiant.java @@ -10,8 +10,16 @@ public class CraftGiant extends CraftMonster implements Giant { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Giant getHandleRaw() { + return (net.minecraft.world.entity.monster.Giant)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Giant getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Giant) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowItemFrame.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowItemFrame.java index f507b6bd999985c26447810a59a8c73b294159ac..2450dc8a0f1fc526eb0b2ed917a5bbbebeadb7bc 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowItemFrame.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowItemFrame.java @@ -10,8 +10,16 @@ public class CraftGlowItemFrame extends CraftItemFrame implements GlowItemFrame super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.decoration.GlowItemFrame getHandleRaw() { + return (net.minecraft.world.entity.decoration.GlowItemFrame)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.decoration.GlowItemFrame getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.decoration.GlowItemFrame) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java index 8d97c9d0a78c6258dd3dd6a832ee87cad283ee62..b5bac66ad28c0ed2bc41fa3ffe765c61817d6b8a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java @@ -11,8 +11,16 @@ public class CraftGlowSquid extends CraftSquid implements GlowSquid { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.GlowSquid getHandleRaw() { + return (net.minecraft.world.entity.GlowSquid)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.GlowSquid getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.GlowSquid) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java index e4be28b130e35ea263f85b3157898cd3a7e80561..8081d8ef5c2e773f7a716ef33cd842cc4a5458cc 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java @@ -10,8 +10,16 @@ public class CraftGoat extends CraftAnimals implements Goat { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.goat.Goat getHandleRaw() { + return (net.minecraft.world.entity.animal.goat.Goat)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.goat.Goat getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.goat.Goat) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGolem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGolem.java index 79d2395b4a5efb042b80a315cc8e32d9c2521306..1ab70f244ed31eea22cc2614788072dbf3b4bbb5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGolem.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGolem.java @@ -9,8 +9,16 @@ public class CraftGolem extends CraftCreature implements Golem { super(server, entity); } + // Folia start - region threading + @Override + public AbstractGolem getHandleRaw() { + return (AbstractGolem)this.entity; + } + // Folia end - region threading + @Override public AbstractGolem getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (AbstractGolem) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java index 2977939c0e66fbb3976e8526db82af2ecc6ffee9..1280dd6ecc53d681bbb311b6099817b517bc50db 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java @@ -14,8 +14,16 @@ public class CraftGuardian extends CraftMonster implements Guardian { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Guardian getHandleRaw() { + return (net.minecraft.world.entity.monster.Guardian)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Guardian getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Guardian) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java index 62e11bf104b8d39ac73883e2a5d207e5f7393253..1797199729d018d103ccae1773fc0206b8381b8d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java @@ -58,8 +58,16 @@ public class CraftHanging extends CraftEntity implements Hanging { return CraftBlock.notchToBlockFace(direction); } + // Folia start - region threading + @Override + public HangingEntity getHandleRaw() { + return (HangingEntity)this.entity; + } + // Folia end - region threading + @Override public HangingEntity getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (HangingEntity) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java index 5c83b20566cad98c47c8d1aa127a7d2659b952a8..1e312733b266e8350bc1a59113b195881c5a9e17 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java @@ -52,8 +52,16 @@ public class CraftHoglin extends CraftAnimals implements Hoglin, CraftEnemy { return this.getHandle().isConverting(); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.hoglin.Hoglin getHandleRaw() { + return (net.minecraft.world.entity.monster.hoglin.Hoglin)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.hoglin.Hoglin getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.hoglin.Hoglin) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java index 794dc15d5e09d0b73b2d297a2da60d2b6b407f6c..a34608c74daced31ec45a96b643176a4d2ff72dc 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java @@ -14,8 +14,16 @@ public class CraftHorse extends CraftAbstractHorse implements Horse { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.horse.Horse getHandleRaw() { + return (net.minecraft.world.entity.animal.horse.Horse)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.horse.Horse getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.horse.Horse) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 5fe9a0985432ac6cdd28a2a138854a24f10e42ba..16cf9cd20b400cdadac89152bdafd64b4e207a5e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -291,8 +291,16 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { this.mode = mode; } + // Folia start - region threading + @Override + public Player getHandleRaw() { + return (Player)this.entity; + } + // Folia end - region threading + @Override public Player getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (Player) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java index fb3c518f02cb4c428f022523d2f838625841332b..7becaa4d26df7309984b7aa271a0ae6f778acc0a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java @@ -10,8 +10,16 @@ public class CraftIllager extends CraftRaider implements Illager { super(server, entity); } + // Folia start - region threading + @Override + public AbstractIllager getHandleRaw() { + return (AbstractIllager)this.entity; + } + // Folia end - region threading + @Override public AbstractIllager getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (AbstractIllager) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java index bbf7189a0fc9921e7a6007494f91229d9fba0846..3ab7929aa11584ec0f86ff8ad441f2b9660cf9c6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java @@ -10,8 +10,16 @@ public class CraftIllusioner extends CraftSpellcaster implements Illusioner, com super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Illusioner getHandleRaw() { + return (net.minecraft.world.entity.monster.Illusioner)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Illusioner getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Illusioner) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java index cb7183b5d72e505762cfaf5c8694406a5ef2dd3b..7b7074a9418bbcd87c18217ea78efdbc7d01528a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java @@ -13,8 +13,16 @@ public class CraftInteraction extends CraftEntity implements Interaction { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.Interaction getHandleRaw() { + return (net.minecraft.world.entity.Interaction)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.Interaction getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.Interaction) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java index 2966d4d466f44751b2f02afda2273a708c12b251..8c3818e8024ee25c29929368750dc346261db5d6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java @@ -9,8 +9,16 @@ public class CraftIronGolem extends CraftGolem implements IronGolem { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.IronGolem getHandleRaw() { + return (net.minecraft.world.entity.animal.IronGolem)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.IronGolem getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.IronGolem) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java index 9b7b98e21e757ab2caca68de20d0191d0011bc9d..06e2580653db00110b0f0a05cfda9d0e9baecdfa 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java @@ -14,8 +14,16 @@ public class CraftItemDisplay extends CraftDisplay implements ItemDisplay { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.Display.ItemDisplay getHandleRaw() { + return (net.minecraft.world.entity.Display.ItemDisplay)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.Display.ItemDisplay getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.Display.ItemDisplay) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java index 5c05ab52e6ea8ec23ff3778f4074ce21b87238db..9f5825c037d26528740ba02aaf9eb1e36d564f67 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java @@ -156,8 +156,16 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame { this.getHandle().fixed = fixed; } + // Folia start - region threading + @Override + public net.minecraft.world.entity.decoration.ItemFrame getHandleRaw() { + return (net.minecraft.world.entity.decoration.ItemFrame)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.decoration.ItemFrame getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.decoration.ItemFrame) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java index 4bf68ae4c7417d2b97d2da93dffe2e0c3291129f..bbc439dab077bed605179129ae715f9989f2a181 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java @@ -15,8 +15,16 @@ public class CraftLargeFireball extends CraftSizedFireball implements LargeFireb this.getHandle().explosionPower = (int) yield; } + // Folia start - region threading + @Override + public net.minecraft.world.entity.projectile.LargeFireball getHandleRaw() { + return (net.minecraft.world.entity.projectile.LargeFireball)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.projectile.LargeFireball getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.projectile.LargeFireball) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLeash.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLeash.java index 2fc419c0c51c6d88addd98212b198546272b2b13..ffccc8f021cdef6ed00241189aefd8217bc82d1c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLeash.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLeash.java @@ -25,8 +25,16 @@ public class CraftLeash extends CraftHanging implements LeashHitch { return BlockFace.SELF; } + // Folia start - region threading + @Override + public LeashFenceKnotEntity getHandleRaw() { + return (LeashFenceKnotEntity)this.entity; + } + // Folia end - region threading + @Override public LeashFenceKnotEntity getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (LeashFenceKnotEntity) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java index e515e819774bfb31ec03f05a5502921e66f2b0e2..80cac5d7362577e53ef5ca215ab3261898127b2f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java @@ -15,8 +15,16 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike return this.getHandle().visualOnly; } + // Folia start - region threading + @Override + public LightningBolt getHandleRaw() { + return (LightningBolt)this.entity; + } + // Folia end - region threading + @Override public LightningBolt getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (LightningBolt) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 6095d43e08bc1ffc4e9a4796fc7adbd07d69d716..fae85d064bcea3589a69483ec6ac6c4cca73ad9a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -417,6 +417,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { this.getHandle().invulnerableTime = ticks; } + // Folia start - region threading + @Override + public net.minecraft.world.entity.LivingEntity getHandleRaw() { + return (net.minecraft.world.entity.LivingEntity)this.entity; + } + // Folia end - region threading + @Override public int getNoActionTicks() { return this.getHandle().getNoActionTime(); @@ -430,6 +437,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public net.minecraft.world.entity.LivingEntity getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.LivingEntity) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java index 4d7a2c4c1001aefe9fcd4be8dbcb414f721bfff9..bcb06f550033e346923026141dc96b032e9ff765 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java @@ -15,8 +15,16 @@ public class CraftLlama extends CraftChestedHorse implements Llama, com.destroys super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.horse.Llama getHandleRaw() { + return (net.minecraft.world.entity.animal.horse.Llama)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.horse.Llama getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.horse.Llama) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java index 9b92efb9bb6905032cee43299d0fdb226dd0e598..ce153695ce561664fa5e184bad0ca8895f0344f3 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java @@ -11,8 +11,16 @@ public class CraftLlamaSpit extends AbstractProjectile implements LlamaSpit { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.projectile.LlamaSpit getHandleRaw() { + return (net.minecraft.world.entity.projectile.LlamaSpit)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.projectile.LlamaSpit getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.projectile.LlamaSpit) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java index b016d2c621707fe2562c560ef9e005866c087a41..e9fa1f544b7350d7537729768c1a0c3f846c18ac 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java @@ -10,8 +10,16 @@ public class CraftMagmaCube extends CraftSlime implements MagmaCube { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.MagmaCube getHandleRaw() { + return (net.minecraft.world.entity.monster.MagmaCube)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.MagmaCube getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.MagmaCube) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMarker.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMarker.java index 1e794ec9fc4f75c740c4dc263058a130f57e4475..8f28ad0cc3feb4a1a034d916da1ccd892b2149de 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMarker.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMarker.java @@ -10,8 +10,16 @@ public class CraftMarker extends CraftEntity implements Marker { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.Marker getHandleRaw() { + return (net.minecraft.world.entity.Marker)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.Marker getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.Marker) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java index 067fcc1f44d59dd675a9cc5485234c87366ffe10..6cce3d64a4f506fcebbe34eae58163c57d43137c 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 { } // Paper end + // Folia start - region threading + @Override + public AbstractMinecart getHandleRaw() { + return (AbstractMinecart)this.entity; + } + // Folia end - region threading + @Override public AbstractMinecart getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (AbstractMinecart) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java index b709a1d909c189f60d0c3aa97b4b96623e7c1db0..fd3eedcfa056c05761c53bccc62fb4dcd00fcb9b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java @@ -21,8 +21,16 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca super(server, entity); } + // Folia start - region threading + @Override + public MinecartCommandBlock getHandleRaw() { + return (MinecartCommandBlock)this.entity; + } + // Folia end - region threading + @Override public MinecartCommandBlock getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (MinecartCommandBlock) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java index 0dd0ce9a9b3253e87eda12354249ec2fd2a33cf2..b7d0892953f357e58665e87fbcf794a75f1c0980 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java @@ -16,8 +16,16 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo super(server, entity); } + // Folia start - region threading + @Override + public AbstractMinecartContainer getHandleRaw() { + return (AbstractMinecartContainer)this.entity; + } + // Folia end - region threading + @Override public AbstractMinecartContainer getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (AbstractMinecartContainer) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java index b8378d5f3c2a08ab565dcb8cb200822b581c7dba..e7c303a0f8b4e2ca26cf28b4661b7bdf56f2498f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java @@ -12,8 +12,16 @@ public class CraftMinecartFurnace extends CraftMinecart implements PoweredMineca super(server, entity); } + // Folia start - region threading + @Override + public MinecartFurnace getHandleRaw() { + return (MinecartFurnace)this.entity; + } + // Folia end - region threading + @Override public MinecartFurnace getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (MinecartFurnace) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java index 67fe56cc4c2af24f6bd883c6e14851019b0b9523..31665297fc24f6d2e86e206ef1ddf46ded51782f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java @@ -40,8 +40,17 @@ public final class CraftMinecartHopper extends CraftMinecartContainer implements ((MinecartHopper) getHandle()).setEnabled(enabled); } // Paper start + + // Folia start - region threading + @Override + public net.minecraft.world.entity.vehicle.MinecartHopper getHandleRaw() { + return (net.minecraft.world.entity.vehicle.MinecartHopper)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.vehicle.MinecartHopper getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.vehicle.MinecartHopper) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java index e5cad4d149af18104266a6ccff55787891d31f0b..dce230dc9dc44040e925e9ab5ab95529561ba464 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java @@ -43,8 +43,16 @@ public final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMi this.getHandle().explode(power); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.vehicle.MinecartTNT getHandleRaw() { + return (net.minecraft.world.entity.vehicle.MinecartTNT)this.entity; + } + // Folia end - region threading + @Override public MinecartTNT getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (MinecartTNT) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java index 18b9b0dc70f6872a9d71c120bcd2edca531b0ac4..148d0393b093a326f76fc34c035768f4758f3f1b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java @@ -55,8 +55,16 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { return (sound != null) ? CraftSound.getBukkit(sound) : null; } + // Folia start - region threading + @Override + public net.minecraft.world.entity.Mob getHandleRaw() { + return (net.minecraft.world.entity.Mob)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.Mob getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.Mob) entity; } @@ -64,7 +72,7 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { @Override public void setHandle(net.minecraft.world.entity.Entity entity) { super.setHandle(entity); - paperPathfinder.setHandle(getHandle()); + paperPathfinder.setHandle((net.minecraft.world.entity.Mob)entity); // Folia - region threading } // Paper end diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java index 11b23670cd80a643f266c59542a380b42b17dfbd..d3b655ab5adacd60f04f912187662c5717a72962 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java @@ -9,8 +9,16 @@ public class CraftMonster extends CraftCreature implements Monster, CraftEnemy { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Monster getHandleRaw() { + return (net.minecraft.world.entity.monster.Monster)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Monster getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Monster) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java index 4a6aae106de5eeeb80c078c5a167ef0484b13929..f3016d316c1dcee3f5d7c7221668280c7bd9a76e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java @@ -11,8 +11,16 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow, io.paperm super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.MushroomCow getHandleRaw() { + return (net.minecraft.world.entity.animal.MushroomCow)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.MushroomCow getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.MushroomCow) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java index 7609c0e00b9eebcf00e21f6eb19d4175f4717179..e6ba1a905a14ae7113decc72b121175eb85d2b36 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java @@ -10,8 +10,16 @@ public class CraftOcelot extends CraftAnimals implements Ocelot { super(server, ocelot); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Ocelot getHandleRaw() { + return (net.minecraft.world.entity.animal.Ocelot)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Ocelot getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Ocelot) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java index b7610e880e857058b621228583c841b5d9338fc7..2fb654411b042159da97c79e69e8845e2b73c4bb 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java @@ -52,8 +52,16 @@ public class CraftPainting extends CraftHanging implements Painting { return false; } + // Folia start - region threading + @Override + public net.minecraft.world.entity.decoration.Painting getHandleRaw() { + return (net.minecraft.world.entity.decoration.Painting)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.decoration.Painting getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.decoration.Painting) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java index 1f6dcad764240e15083731d017f9bb1c5c84622f..71b307cd7029b8aeb511bfa6eb3f73736f2d0c91 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java @@ -12,8 +12,16 @@ public class CraftPanda extends CraftAnimals implements Panda { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Panda getHandleRaw() { + return (net.minecraft.world.entity.animal.Panda)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Panda getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Panda) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java index d7e9b1d7460c0479ff94a2cb52e6c572a464420a..caee1abf4c057afa08be8495bf742f871b2d1eae 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java @@ -12,8 +12,16 @@ public class CraftParrot extends CraftTameableAnimal implements Parrot { super(server, parrot); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Parrot getHandleRaw() { + return (net.minecraft.world.entity.animal.Parrot)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Parrot getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Parrot) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java index 63e31c237dc3cf37a5e06c1cf3f030c9f1df3d38..8c02dabbfee88ee6c3315c8174da7236eecdd8cc 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java @@ -10,8 +10,16 @@ public class CraftPhantom extends CraftFlying implements Phantom, CraftEnemy { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Phantom getHandleRaw() { + return (net.minecraft.world.entity.monster.Phantom)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Phantom getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Phantom) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java index 61613f38b39dfd4512e2d9caadaa3bb6b37d4e55..f94b45ba171fcbae718b50ab2ff60d38248e622c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java @@ -56,8 +56,16 @@ public class CraftPig extends CraftAnimals implements Pig { return Material.CARROT_ON_A_STICK; } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Pig getHandleRaw() { + return (net.minecraft.world.entity.animal.Pig)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Pig getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Pig) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java index a8a372dc15019ad720994e03f5a7109f31423f56..8e4874f1bf3511e3947c48987caa098712271977 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java @@ -31,8 +31,16 @@ public class CraftPigZombie extends CraftZombie implements PigZombie { return this.getAnger() > 0; } + // Folia start - region threading + @Override + public ZombifiedPiglin getHandleRaw() { + return (ZombifiedPiglin)this.entity; + } + // Folia end - region threading + @Override public ZombifiedPiglin getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (ZombifiedPiglin) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java index 48d0a4e42e1b90d1323784d1284acabfe9497dd6..3da995c2aa9fe947d059e76bb6e6410827f6888d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java @@ -76,8 +76,16 @@ public class CraftPiglin extends CraftPiglinAbstract implements Piglin, com.dest return new CraftInventory(this.getHandle().inventory); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.piglin.Piglin getHandleRaw() { + return (net.minecraft.world.entity.monster.piglin.Piglin)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.piglin.Piglin getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.piglin.Piglin) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java index e7957d6051244ba410f8633f9c16eeb8c5ac3ce0..ce763867f9c6c2d4773d76387afc0ecb479b6259 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java @@ -95,8 +95,16 @@ public class CraftPiglinAbstract extends CraftMonster implements PiglinAbstract public void setBreed(boolean b) { } + // Folia start - region threading + @Override + public AbstractPiglin getHandleRaw() { + return (AbstractPiglin)this.entity; + } + // Folia end - region threading + @Override public AbstractPiglin getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (AbstractPiglin) super.getHandle(); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinBrute.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinBrute.java index 689c4ce62f604d023e2f293db17f423fd10acbaf..18416b48a05a8d564b7715ad00f947e4f4c70d9d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinBrute.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinBrute.java @@ -10,8 +10,16 @@ public class CraftPiglinBrute extends CraftPiglinAbstract implements PiglinBrute super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.piglin.PiglinBrute getHandleRaw() { + return (net.minecraft.world.entity.monster.piglin.PiglinBrute)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.piglin.PiglinBrute getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.piglin.PiglinBrute) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java index beea227855f0b978e655efc298024120df8f4945..e1b7922ed298b6b3068c3f5fbe3b4030cff13484 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java @@ -12,8 +12,16 @@ public class CraftPillager extends CraftIllager implements Pillager, com.destroy super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Pillager getHandleRaw() { + return (net.minecraft.world.entity.monster.Pillager)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Pillager getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Pillager) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 1da2e14d6fa557625835af7a3f003c4e9bb0f40e..36fc7444514a82532731026a0c4402d2ec04e9d2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -602,7 +602,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) { - org.spigotmc.AsyncCatcher.catchOp("player kick"); + //org.spigotmc.AsyncCatcher.catchOp("player kick"); // Folia - region threading - no longer needed final ServerGamePacketListenerImpl connection = this.getHandle().connection; if (connection != null) { connection.disconnect(message == null ? net.kyori.adventure.text.Component.empty() : message, cause); @@ -2086,9 +2086,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return this; } + // Folia start - region threading + @Override + public ServerPlayer getHandleRaw() { + return (ServerPlayer)this.entity; + } + // Folia end - region threading + @Override public ServerPlayer getHandle() { - return (ServerPlayer) entity; + return (ServerPlayer) entity; // Folia - region threading - no checks for players, as it's a total mess } public void setHandle(final ServerPlayer entity) { @@ -3093,7 +3100,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { { if ( CraftPlayer.this.getHealth() <= 0 && CraftPlayer.this.isOnline() ) { - server.getServer().getPlayerList().respawn( CraftPlayer.this.getHandle(), false, org.bukkit.event.player.PlayerRespawnEvent.RespawnReason.PLUGIN ); + CraftPlayer.this.getHandle().respawn(null); // Folia - region threading } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java index 30a0eac179c86b0fe94a2a40b5bfcd3eee01e53b..23364bbd534a147954d72986a96aee836e0aa210 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java @@ -9,8 +9,17 @@ public class CraftPolarBear extends CraftAnimals implements PolarBear { public CraftPolarBear(CraftServer server, net.minecraft.world.entity.animal.PolarBear entity) { super(server, entity); } + + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.PolarBear getHandleRaw() { + return (net.minecraft.world.entity.animal.PolarBear)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.PolarBear getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.PolarBear) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java index fd5beb956f643532e08613366ebd380d7999e79f..1521ad3c160062f22e6e17d2dacde5d8db5ccc00 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java @@ -12,8 +12,16 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj // Paper - moved to AbstractProjectile + // Folia start - region threading + @Override + public net.minecraft.world.entity.projectile.Projectile getHandleRaw() { + return (net.minecraft.world.entity.projectile.Projectile)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.projectile.Projectile getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.projectile.Projectile) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java index bb9722a2cf5f05d1488f7fec2851644ea3e8b975..ed0e5d32a187dd41952b923e4a1734afa7d092b1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java @@ -11,8 +11,16 @@ public class CraftPufferFish extends CraftFish implements PufferFish { super(server, entity); } + // Folia start - region threading + @Override + public Pufferfish getHandleRaw() { + return (Pufferfish)this.entity; + } + // Folia end - region threading + @Override public Pufferfish getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (Pufferfish) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java index 3cd6052ae1e2db15d26157679506ba63a9a59a2f..34a1b2853023006d3ef255651ffa58452ce4cc79 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java @@ -12,8 +12,16 @@ public class CraftRabbit extends CraftAnimals implements Rabbit { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Rabbit getHandleRaw() { + return (net.minecraft.world.entity.animal.Rabbit)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Rabbit getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Rabbit) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java index c3185e189ed06e27e518d29b8577b8f694220b12..cfb231848766414297a13fea16308597546c86ce 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java @@ -16,8 +16,16 @@ public abstract class CraftRaider extends CraftMonster implements Raider { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.raid.Raider getHandleRaw() { + return (net.minecraft.world.entity.raid.Raider)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.raid.Raider getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.raid.Raider) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftRavager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftRavager.java index 84899714b96a7ed31ceee10373a62c37cab2ad2a..0e08b2f7a21a09f61ff4800439346260ef96e2d9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftRavager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRavager.java @@ -10,8 +10,16 @@ public class CraftRavager extends CraftRaider implements Ravager { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Ravager getHandleRaw() { + return (net.minecraft.world.entity.monster.Ravager)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Ravager getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Ravager) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java index c888415f9b4f19db69667525e37279ab8be794f6..3951fa2f21932dc1b4948fab08998afaf928b27d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java @@ -10,8 +10,16 @@ public class CraftSalmon extends io.papermc.paper.entity.PaperSchoolableFish imp super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Salmon getHandleRaw() { + return (net.minecraft.world.entity.animal.Salmon)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Salmon getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Salmon) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java index 81ccb4bde315c42409a0c04883f5cb4551398308..e3c6a74d267ea0a10be375fc83428415ad575fc2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java @@ -30,8 +30,16 @@ public class CraftSheep extends CraftAnimals implements Sheep, io.papermc.paper. this.getHandle().setSheared(flag); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Sheep getHandleRaw() { + return (net.minecraft.world.entity.animal.Sheep)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Sheep getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Sheep) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java index 8113650fda221538d14b53664db2d0cf81f13476..ccf7fd9be8baeda0b47b7abf090f255842bc639c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java @@ -24,8 +24,16 @@ public class CraftShulker extends CraftGolem implements Shulker, CraftEnemy { return EntityType.SHULKER; } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Shulker getHandleRaw() { + return (net.minecraft.world.entity.monster.Shulker)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Shulker getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Shulker) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java index 43f52716c82863382cb0eb08cc0e174a19ffebdf..2435b081eb0587d155d8c4ffb8d67b7529965d85 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java @@ -71,8 +71,16 @@ public class CraftShulkerBullet extends AbstractProjectile implements ShulkerBul return EntityType.SHULKER_BULLET; } + // Folia start - region threading + @Override + public net.minecraft.world.entity.projectile.ShulkerBullet getHandleRaw() { + return (net.minecraft.world.entity.projectile.ShulkerBullet)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.projectile.ShulkerBullet getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.projectile.ShulkerBullet) entity; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSilverfish.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSilverfish.java index 81624189cb533bb9de57dc985095bd497a9a068a..a5a9d0daa0fd5641cbe10b5b269b26a0d589a5d5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSilverfish.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSilverfish.java @@ -9,8 +9,16 @@ public class CraftSilverfish extends CraftMonster implements Silverfish { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Silverfish getHandleRaw() { + return (net.minecraft.world.entity.monster.Silverfish)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Silverfish getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Silverfish) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java index 5d16db88c243279a581092c98d37027aa6731485..c9bfe84cbd2c5835e070251ace2ef06ccb7004cf 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java @@ -27,8 +27,16 @@ public class CraftSizedFireball extends CraftFireball implements SizedFireball { this.getHandle().setItem(CraftItemStack.asNMSCopy(item)); } + // Folia start - region threading + @Override + public Fireball getHandleRaw() { + return (Fireball)this.entity; + } + // Folia end - region threading + @Override public Fireball getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (Fireball) entity; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java index 1737857424c5da885c46f39502cafd2a670d3be7..4aed90c5ed149cc84d91c417b57edec71042d7cc 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java @@ -32,8 +32,16 @@ public class CraftSkeleton extends CraftAbstractSkeleton implements Skeleton { } } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Skeleton getHandleRaw() { + return (net.minecraft.world.entity.monster.Skeleton)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Skeleton getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Skeleton) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java index 78bc77d9cc5797fa8edd189167bb60b75b7f920e..2744d69cc268c809457d730e0061ebfb6c6aee11 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java @@ -26,8 +26,16 @@ public class CraftSkeletonHorse extends CraftAbstractHorse implements SkeletonHo return Variant.SKELETON_HORSE; } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.horse.SkeletonHorse getHandleRaw() { + return (net.minecraft.world.entity.animal.horse.SkeletonHorse)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.horse.SkeletonHorse getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.horse.SkeletonHorse) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java index c580922c64f0e26177494fb87ecd0c1d086c5ef9..307a2b8015c9598083bedccb0c516ea64c4fc514 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java @@ -20,8 +20,16 @@ public class CraftSlime extends CraftMob implements Slime, CraftEnemy { this.getHandle().setSize(size, /* true */ getHandle().isAlive()); // Paper - fix dead slime setSize invincibility } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Slime getHandleRaw() { + return (net.minecraft.world.entity.monster.Slime)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Slime getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Slime) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java index d8b4df1300791aaf310465ec1577b1b8c202901a..17b83eb8563586f1ddf252f438d52d554e946def 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java @@ -9,8 +9,16 @@ public class CraftSmallFireball extends CraftSizedFireball implements SmallFireb super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.projectile.SmallFireball getHandleRaw() { + return (net.minecraft.world.entity.projectile.SmallFireball)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.projectile.SmallFireball getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.projectile.SmallFireball) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java index e9e8ee8c87285705366d54c23a59c136c612aaff..3549d9b0c8ed9d746c38bebedaa7c729717bed92 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java @@ -17,8 +17,16 @@ public class CraftSniffer extends CraftAnimals implements Sniffer { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.sniffer.Sniffer getHandleRaw() { + return (net.minecraft.world.entity.animal.sniffer.Sniffer)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.sniffer.Sniffer getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.sniffer.Sniffer) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java index b747aa0fb5821988ea851273559182997abf9931..117cdf4b1315f2de32aa13844f0f4c46f21cc96d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java @@ -9,8 +9,16 @@ public class CraftSnowball extends CraftThrowableProjectile implements Snowball super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.projectile.Snowball getHandleRaw() { + return (net.minecraft.world.entity.projectile.Snowball)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.projectile.Snowball getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.projectile.Snowball) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java index 42b7058d93fab8cbee49dba130734e1df9910096..00907c925fdb0d709ff421cdc8a1742282ad372f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java @@ -20,8 +20,16 @@ public class CraftSnowman extends CraftGolem implements Snowman, com.destroystok this.getHandle().setPumpkin(!derpMode); } + // Folia start - region threading + @Override + public SnowGolem getHandleRaw() { + return (SnowGolem)this.entity; + } + // Folia end - region threading + @Override public SnowGolem getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (SnowGolem) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java index 8aced77e9a3c1b5c24bfd9d95a651cca90fdf0e1..f4bd0872dc725dc9040a89cbc627d86b786290df 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java @@ -10,8 +10,16 @@ public class CraftSpectralArrow extends CraftArrow implements SpectralArrow { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.projectile.SpectralArrow getHandleRaw() { + return (net.minecraft.world.entity.projectile.SpectralArrow)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.projectile.SpectralArrow getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.projectile.SpectralArrow) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java index 525827f1747631fa108be7e1b7395b47d33aa397..3dbb5f7f88979d616e185980d96cc2c377977000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java @@ -12,8 +12,16 @@ public class CraftSpellcaster extends CraftIllager implements Spellcaster { super(server, entity); } + // Folia start - region threading + @Override + public SpellcasterIllager getHandleRaw() { + return (SpellcasterIllager)this.entity; + } + // Folia end - region threading + @Override public SpellcasterIllager getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (SpellcasterIllager) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java index 994d8d815aa110bd6ac9939a4ce78f1bbad2662f..496fb0ac11cdf32701b0d5fb4761a0ada60a78ac 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java @@ -10,8 +10,16 @@ public class CraftSpider extends CraftMonster implements Spider { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Spider getHandleRaw() { + return (net.minecraft.world.entity.monster.Spider)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Spider getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Spider) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java index 3c0faedaac8cb8d70c0c0767361ebc563a3f0581..10875cdf36b426de512c52ae60ac7e2c8312114b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java @@ -10,8 +10,16 @@ public class CraftSquid extends CraftWaterMob implements Squid { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Squid getHandleRaw() { + return (net.minecraft.world.entity.animal.Squid)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Squid getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Squid) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java index af5344b0edd1f8126d36a79d7497ca52112ce6d1..89cd22b73c38773961d6955d429564e816b8183a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java @@ -66,8 +66,16 @@ public class CraftStrider extends CraftAnimals implements Strider { return Material.WARPED_FUNGUS_ON_A_STICK; } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Strider getHandleRaw() { + return (net.minecraft.world.entity.monster.Strider)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Strider getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Strider) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java index 06540d3771949daff641e518219090559f363959..3be27209a4429c6ab618798418451bd527a2115b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java @@ -43,8 +43,16 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed { this.getHandle().setFuse(fuseTicks); } + // Folia start - region threading + @Override + public PrimedTnt getHandleRaw() { + return (PrimedTnt)this.entity; + } + // Folia end - region threading + @Override public PrimedTnt getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (PrimedTnt) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java index 43c2d820d164d36a28c4920d70aea2fe5096763a..1fab7a34e4fe624d901c0264cda980fd91dbd8e0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java @@ -10,8 +10,16 @@ public class CraftTadpole extends CraftFish implements org.bukkit.entity.Tadpole super(server, entity); } + // Folia start - region threading + @Override + public Tadpole getHandleRaw() { + return (Tadpole)this.entity; + } + // Folia end - region threading + @Override public Tadpole getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (Tadpole) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java index 428437970cac144be53cd0e30af7af0cd1ce603b..dc09e141ba2b12f1955bec521f2170d2fe4ba113 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java @@ -12,8 +12,16 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat super(server, entity); } + // Folia start - region threading + @Override + public TamableAnimal getHandleRaw() { + return (TamableAnimal)this.entity; + } + // Folia end - region threading + @Override public TamableAnimal getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (TamableAnimal) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java index 7bfb83d3ac38c5c270d77d9794a55a363ac6302b..f973d6013eef71025fad3b74d6158561aafe508f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java @@ -14,8 +14,16 @@ public class CraftTextDisplay extends CraftDisplay implements TextDisplay { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.Display.TextDisplay getHandleRaw() { + return (net.minecraft.world.entity.Display.TextDisplay)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.Display.TextDisplay getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.Display.TextDisplay) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java index 989c5c499a52ad0777abecd14a1a9d5803ce1aaf..8e66e9ac17a8a06130d6b039f27868d42554f337 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java @@ -26,8 +26,16 @@ public abstract class CraftThrowableProjectile extends CraftProjectile implement this.getHandle().setItem(CraftItemStack.asNMSCopy(item)); } + // Folia start - region threading + @Override + public ThrowableItemProjectile getHandleRaw() { + return (ThrowableItemProjectile)this.entity; + } + // Folia end - region threading + @Override public ThrowableItemProjectile getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (ThrowableItemProjectile) entity; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java index 00f8e1130620a3a167733ca3297cc90561cce1f0..34de9dcd6fa0e978c65bf48ae78923784bf575fd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java @@ -10,8 +10,16 @@ public class CraftThrownExpBottle extends CraftThrowableProjectile implements Th super(server, entity); } + // Folia start - region threading + @Override + public ThrownExperienceBottle getHandleRaw() { + return (ThrownExperienceBottle)this.entity; + } + // Folia end - region threading + @Override public ThrownExperienceBottle getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (ThrownExperienceBottle) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java index 5c3bc680c4e4e6dc4b2d9edc666d6a8d95c2e7b7..6c15ba92215634a06a1d95fbd7d64bff2bb935dc 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java @@ -61,8 +61,17 @@ public class CraftThrownPotion extends CraftThrowableProjectile implements Throw this.getHandle().splash(null); } // Paper end + + // Folia start - region threading + @Override + public net.minecraft.world.entity.projectile.ThrownPotion getHandleRaw() { + return (net.minecraft.world.entity.projectile.ThrownPotion)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.projectile.ThrownPotion getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.projectile.ThrownPotion) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java index 6dde7fdff3943e5d58d1dd5debadbf7de569f8e2..64058e89a029a75c112569c40d7216a4d349f3e8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java @@ -22,8 +22,16 @@ public class CraftTippedArrow extends CraftArrow implements Arrow { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.projectile.Arrow getHandleRaw() { + return (net.minecraft.world.entity.projectile.Arrow)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.projectile.Arrow getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.projectile.Arrow) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java index 0f07a43896e0f677fb9e4ba5080466d22eddcfcb..124c78fcb7b59d6cb3d4de53609fb64f652c17e4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java @@ -10,8 +10,16 @@ public class CraftTraderLlama extends CraftLlama implements TraderLlama { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.horse.TraderLlama getHandleRaw() { + return (net.minecraft.world.entity.animal.horse.TraderLlama)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.horse.TraderLlama getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.horse.TraderLlama) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java index faf071201b7c1414225a33fe9641eac9477d53c7..4c69a367dfdf7c3b8e82dd44f005ed613e1fe0bf 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java @@ -13,8 +13,16 @@ public class CraftTrident extends CraftArrow implements Trident { super(server, entity); } + // Folia start - region threading + @Override + public ThrownTrident getHandleRaw() { + return (ThrownTrident)this.entity; + } + // Folia end - region threading + @Override public ThrownTrident getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (ThrownTrident) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java index 4352af0a76ce4a4cd4afbea96f4851ef2b64ac7d..f8aa5bc3d846d2fd785c612dd3906b84686e0792 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java @@ -14,8 +14,16 @@ public class CraftTropicalFish extends io.papermc.paper.entity.PaperSchoolableFi super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.TropicalFish getHandleRaw() { + return (net.minecraft.world.entity.animal.TropicalFish)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.TropicalFish getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.TropicalFish) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java index d3546fb082a56b4ce077ded5d25909e15f7eb593..319efb68aebd6d1182dede7b2b6f368b3d7b62c2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java @@ -10,8 +10,16 @@ public class CraftTurtle extends CraftAnimals implements Turtle { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Turtle getHandleRaw() { + return (net.minecraft.world.entity.animal.Turtle)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Turtle getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Turtle) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java index bcfca66c7b99b9d514fe850d6cc6abd7e36ccaf7..90c295ff95bbee4f51fda1be2f58312d281925e5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java @@ -14,8 +14,16 @@ public class CraftVex extends CraftMonster implements Vex { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Vex getHandleRaw() { + return (net.minecraft.world.entity.monster.Vex)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Vex getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Vex) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index f21c715ea109164efa755cddb35ef656a9859759..4b4167edcf9e30d50a103c5b85685e7175842f4b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -30,8 +30,16 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.npc.Villager getHandleRaw() { + return (net.minecraft.world.entity.npc.Villager)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.npc.Villager getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.npc.Villager) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java index 7d63e9b8c92da089886ce9118bea07077f0541cd..6231a4948fd934d2e73f15b364035c64d7e03cc8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java @@ -19,8 +19,16 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.ZombieVillager getHandleRaw() { + return (net.minecraft.world.entity.monster.ZombieVillager)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.ZombieVillager getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.ZombieVillager) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java index bea22e002a9d41b0e364eff1109d5a67c9824a00..fc7a87ed98801914d5cf3e6784f0025db30cf663 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java @@ -10,8 +10,16 @@ public class CraftVindicator extends CraftIllager implements Vindicator { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Vindicator getHandleRaw() { + return (net.minecraft.world.entity.monster.Vindicator)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Vindicator getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Vindicator) super.getHandle(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java index f9a3d060ff4da6047d11f2b024d144572c513399..824e2c7aa9263195cb173da2b5612b3b8bc3a046 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java @@ -10,8 +10,16 @@ public class CraftWanderingTrader extends CraftAbstractVillager implements Wande super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.npc.WanderingTrader getHandleRaw() { + return (net.minecraft.world.entity.npc.WanderingTrader)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.npc.WanderingTrader getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.npc.WanderingTrader) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java index 6ecdc4bf1f6b8f0363e667135ba463433be5c0fb..a4ede0f5973d18ed6b8ae3ee425c4445f39e86c4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java @@ -16,8 +16,16 @@ public class CraftWarden extends CraftMonster implements org.bukkit.entity.Warde super(server, entity); } + // Folia start - region threading + @Override + public Warden getHandleRaw() { + return (Warden)this.entity; + } + // Folia end - region threading + @Override public Warden getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (Warden) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java index 684f983e95459f7065274e0b494e754fd317d42d..c03b8291bac77696daf24caaff3512d6a0ba10db 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java @@ -10,8 +10,16 @@ public class CraftWaterMob extends CraftCreature implements WaterMob { super(server, entity); } + // Folia start - region threading + @Override + public WaterAnimal getHandleRaw() { + return (WaterAnimal)this.entity; + } + // Folia end - region threading + @Override public WaterAnimal getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (WaterAnimal) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java index 9039db1a72009342063d4db08e18e6aee18836e8..c2bceaeabf13d37506eea540cb153d10ba18d817 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java @@ -16,8 +16,16 @@ public class CraftWitch extends CraftRaider implements Witch, com.destroystokyo. super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Witch getHandleRaw() { + return (net.minecraft.world.entity.monster.Witch)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Witch getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Witch) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java index 1477c2c04d8f5c5639ce94808fe2a7029cedaeb2..a6dc41a1eac7aa08a4e13489a7dabb61cd4eadd7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java @@ -22,8 +22,16 @@ public class CraftWither extends CraftMonster implements Wither, com.destroystok } } + // Folia start - region threading + @Override + public WitherBoss getHandleRaw() { + return (WitherBoss)this.entity; + } + // Folia end - region threading + @Override public WitherBoss getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (WitherBoss) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java index 01fb0ca4a0ecc57a1437885f96632644158c4446..d7b5dc3632e22003f80843882652a35d7306b9d9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java @@ -19,8 +19,16 @@ public class CraftWitherSkull extends CraftFireball implements WitherSkull { return this.getHandle().isDangerous(); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.projectile.WitherSkull getHandleRaw() { + return (net.minecraft.world.entity.projectile.WitherSkull)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.projectile.WitherSkull getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.projectile.WitherSkull) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java index e43fd3e59fd8c74828ae65965fade27f56beef65..05372166c2cc7b48184c18a4fdd788a242ec4682 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java @@ -24,8 +24,16 @@ public class CraftWolf extends CraftTameableAnimal implements Wolf { } } + // Folia start - region threading + @Override + public net.minecraft.world.entity.animal.Wolf getHandleRaw() { + return (net.minecraft.world.entity.animal.Wolf)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.animal.Wolf getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.animal.Wolf) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java index 611e794d86ff63d725de9bb843802ec868f4b1fd..8195313de7a047e694c718609505a60b592f3565 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java @@ -20,8 +20,16 @@ public class CraftZoglin extends CraftMonster implements Zoglin { this.getHandle().setBaby(flag); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Zoglin getHandleRaw() { + return (net.minecraft.world.entity.monster.Zoglin)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Zoglin getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Zoglin) entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java index 9f4da46dce54fe4207e24b49402fe0d3fa548e29..631132549f454ffd6dc97e1bce2e994e7ce310d6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java @@ -13,8 +13,16 @@ public class CraftZombie extends CraftMonster implements Zombie { super(server, entity); } + // Folia start - region threading + @Override + public net.minecraft.world.entity.monster.Zombie getHandleRaw() { + return (net.minecraft.world.entity.monster.Zombie)this.entity; + } + // Folia end - region threading + @Override public net.minecraft.world.entity.monster.Zombie getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading return (net.minecraft.world.entity.monster.Zombie) entity; }