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 47061546345d0f367aa64c2d562a53509829d499..e1b6673729e71bdc929bc7b76983108a59e55891 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -2872,6 +2872,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()); @@ -2893,6 +2894,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(); @@ -2971,6 +2973,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) { @@ -2998,6 +3001,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 0f7ae4a5c672039828454bf18c770dd99e250212..df182782756f674e2ce5d8c6add5c23cec8be645 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; @@ -38,6 +39,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()); @@ -55,6 +63,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 dc19a0ad99deed9cc71c243322e375b740db7a9b..87f5073b02d5989ee0adde4f22becabb42a90651 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java @@ -16,8 +16,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 2a477dcd9d31a251868e342d1e7f5b9b58ddf66f..4ce13017e17bc327547ce4dd2dba7a5eff9e444f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java @@ -9,8 +9,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 c13d7fd15d8614f1ced30569fd1eae732a31b800..a0979910520442b2cabd9e87b78448e40e753641 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 dc26be80f2c1f058451c0d446165bc78a0ff8c47..774f0f90ad66a0f5f33d1008c036ff515937b18c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java @@ -20,8 +20,16 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand { return "CraftArmorStand"; } + // 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 96a20efc60efef4485eca9ebffed92dc195ed357..4a7ec1c1b479c68d0ec08b78e06b53255d725c08 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java @@ -142,8 +142,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 cbfca242f820d238b112f8ce64e9de8398c48a1c..c5f0cd5e69a20f1fffcd017385bf9fab59630ffc 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java @@ -10,8 +10,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 7592ecac3d0893974d9d22ce40c50f1008ab9695..83d5d7503f1c4988f057743331c6f1eb7c5b57d9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java @@ -8,8 +8,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 17608e0e8cc5288905d2e42ae1429f7d947511fb..b486054e5e9c543cf5e6f2b4356a9f843242cd34 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java @@ -13,8 +13,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 6be071da0637a97123c5100c4e7a2af2c5e83d7e..28edb6913d70c18512fc117735260aa707c2224c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlaze.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlaze.java @@ -8,8 +8,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 dd91de8f24c27b9318c2a898a49991d74c100bff..d7c34f601ce66a6b090ec431a0503462865155a8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java @@ -12,8 +12,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 338e5ec5a518f9542e82ad43efeaa2a8cf04af42..85842cdf946e69398e6f64fa1b6d2315519780e0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java @@ -102,8 +102,16 @@ public class CraftBoat extends CraftVehicle implements Boat { 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 80e571c977db5cdf43bfbfce035f37a3fa325c95..6fafba37dd7128a397ba046be7b33067c9e88f25 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java @@ -11,8 +11,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 6c9531c018be29b5794d047b50007fde1b50b494..cb2f710a48c1e42cf800f657befaac4e2b8a82ff 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java @@ -15,8 +15,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 2d897ded3cb95d988aa3d99d69e904936c7ca8e7..8eaced8d8528d25d3b69816c8ec67e8f44030f6d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java @@ -8,8 +8,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 c332e8504b96a4437325b5a64430c97c5afb6b4b..6f4ee6e3224a25a121a8075929597c5acb691fd2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java @@ -18,8 +18,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 5e0b611db52452c00bf3cd2fc07dd713f238a581..f4858d41c482cc91322cd68cf00a73e2d46cbe18 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java @@ -9,8 +9,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 63e6b07e3b159c74d9ef17be20b5ab43d07f0f5f..7e3a560ff4a3d56e52534eb909eaf60424b84514 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java @@ -9,8 +9,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 c59bd22ba9df070e63e23372e52ba43686a06aa4..3a615a61fedaacb7845fe9c07d4aa3d9e76b2c51 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java @@ -32,8 +32,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 b893974440b2f1e6976f52ca663244bf6e2bbc12..646415cf9da4148a32f4d703f009dbb48393897e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java @@ -9,8 +9,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 6ccb32786b3abe1109dcc2d083cd231b70d8c6b4..c3a489167197ab6392491257d9d11d8077fe4957 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java @@ -79,8 +79,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 48eeb1d9ba0ad6f895bfe507a6fbe4b9c9530e47..4eb5c99862c38cbaf3ba89be3ffc7a78b1a7276a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java @@ -12,8 +12,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 f93f8f6509b12eb9b1e07c829278bb0822dd7988..c693daa86c2e44165ca6a293563670dc82f30eb2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java @@ -9,8 +9,16 @@ public class CraftDolphin extends CraftWaterMob implements Dolphin { 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 14b575254171f66b8792033c93cf5a325a42b467..b7c805ab1b2e4c8abd2728bcd17afab0979efc2d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java @@ -9,8 +9,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 dbc27792bf84c07ca342b95231b4b34e90239da1..822f81ab0c790acde135080c0851dc2e4b408e82 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java @@ -9,8 +9,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 5109fa0e665e484194eb9ccbafec7ff532ebd0fa..acb9be933c33566fe991ea90f7199d1f58262e5a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java @@ -39,8 +39,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 492fdc855fe9735b614b6831aa5baaa6b252cfb6..57ab36ea7e973e8deb47240d2adad63d26ace04d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java @@ -30,8 +30,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 03e2c43cdbd75a6c0127e1c3f708bbad3242d238..55b2d8ad3f1724793ee9631d3872cc9405759990 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java @@ -9,8 +9,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 18712bfd46d3852bc1210c8f0dea7e9af3e55b4d..fb1009a7cd2a8440f9faeed3e12fe9daefea72e6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java @@ -15,8 +15,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 92eb829161079c4a96447698aee58cc6e7cbd29f..7299780db54c9a5acef2e8c0d24885991e80b6e3 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java @@ -62,8 +62,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 d657fd2c507a5b215aeab0a5f3e9c2ee892a27c8..9fc90b162aab15a9cd60b02aba56318130b394c4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java @@ -9,8 +9,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 bdb0198a609028d45501f98d4df62f3a227a25d2..d584c168b5523fda4ebc823f956895178c4b8d13 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -826,7 +826,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 @@ -841,6 +841,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 b66dd5c5c5d98c9285e0d0a4ad4b99a66419f732..3d284b790c869fb30180b92b891b292006c7dad4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java @@ -11,8 +11,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 be52662bcaf7f7d1914ba0db7bd4b3f62974cc70..591e710d5296dddc0bdd7279a3c98c47c9e01239 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java @@ -10,8 +10,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 26c795983515580b30b5ef8c701faa95ab1aea8e..990709bd56a96a60df020947f99b4f30cbe4192e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java @@ -30,8 +30,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 a8bed9c1d129ac31486af8b65e26aa245920d6b5..d2cf436c76d9ed0db0c95aafa1df22386fa09515 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java @@ -14,8 +14,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 22d59ca52229dc566b8dfb460b92ecd6318e6db0..e80426bfcd55e9b2d308eb43b6ec4488668f9dbe 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java @@ -58,8 +58,16 @@ public class CraftFireball extends AbstractProjectile implements Fireball { } // Paper end + // 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 1605ac0e726accdbd7953ffb95a302c2a21d64ce..b5c224998080433dea345b88b238042fb5ccfb72 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java @@ -37,8 +37,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 96b6e537ec4493a0cdd98ccfe7816f7ffb69c7dd..ccb54c8da9f27666ec08347b3c4c738a6a1fe245 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java @@ -14,8 +14,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 6149067a14b950e727d3387055016a19e55c0fc6..929c817b7101973c4cc9f8f5a23f1941d67508cb 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java @@ -14,8 +14,16 @@ public class CraftFox extends CraftAnimals implements Fox { 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 20284ba684d29c619532e076f46e11572b50d367..ad5dcae61a58dd85e01b4dcb915348acc7e74642 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java @@ -16,8 +16,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 3adcf36c7b4beb0f752f91b7333593a610ec118c..d8372cc3ff0f0cbfc5638cb0f4842bfcc54a9565 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java @@ -9,8 +9,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 cf788207c3c81074d54b1ff69fe814a2e0adf55f..d65b641d1bbd325547c16e186f4ec2558bcdc5c4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGiant.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGiant.java @@ -9,8 +9,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 7dd9d670a1436d2bbfcae6c3e597ca6c7b759623..47afda44cb474d9752cf97405b546a534382880a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowItemFrame.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowItemFrame.java @@ -9,8 +9,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 253a0d2f987163cbbb28d261674b47137cbbcbe2..ad0b9025e38926555b47dee1e056c7c8714c91fe 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowSquid.java @@ -10,8 +10,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 2c21de478bff9cdf13ba46cd041831d54c11e924..ab87340df483787d59d8b1e2ce3a69235d39bba5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java @@ -9,8 +9,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 70e75921a20978d730ca02aea47186c79e1632d8..c11304434217a48400ec147f3b4e63d40d3b7280 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java @@ -13,8 +13,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 0ef629a7c76e7f3f24edd76bac3560bf7e55d663..0ea8bcfc368e519d1f4906654ad5c72f80e84a3f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java @@ -57,8 +57,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 e2d95c9b894ccac04fb552d2e934c8ec9efade55..e13f9b88dee6f0e98550dc39bb16373366aa97ce 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java @@ -51,8 +51,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 8b13f6c315675bca8362be16f6511b5b7da34670..584703f2d7d14efd79568663cd833cb31f55c422 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java @@ -13,8 +13,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 017e97c1618b8ee4640b36a0ec1b07026047bfc3..546a7fd563cc0291b5e15e8f67b4c3b8fc4067af 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 5b2af80e584977683cd39e6f440e65a76e929be9..89c0121c40da1596a4bf5db6e1d7d611d5053153 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java @@ -9,8 +9,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 0e6edf0723314693ec904078c8a557a4f18e2db1..ed741f77fbe8f5c40a3923b0a431da768104a1b5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java @@ -12,8 +12,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 75d10b5322eb0a62bce2855c04a5151eb857d7de..a920bfcfa4a977b4107f5f34fe9e625039d3ad39 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java @@ -8,8 +8,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 787f91566fc53c2b4aeba1ec10d8f46ccf15cbe6..eb2b4272b09e5df06e49afc2ccf7063ebc3d42b8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java @@ -13,8 +13,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 58489a6a34e66cd6fc0d0e28141a3ebc32ac0e05..3ee9c2e5f66026375a88bcfcb6b46fbd43770309 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java @@ -157,8 +157,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 16dd5a6fb7d97c8f42700be67de27369bfb0a69c..125e676efc79e582f19a44b68e5faea806f5dda4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java @@ -14,8 +14,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 c8379778adabb513ebac40e9b3308cd2c1623678..9829c809ec385e15bbb1ef48c1bda5ff0adb5774 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLeash.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLeash.java @@ -24,8 +24,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 ef5a5aed9e1b15a29fd3a97ccd502c40b1d865ac..d6e78621601f1553c267f25c527242c813908436 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java @@ -41,8 +41,16 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike this.getHandle().setCause((player != null) ? ((CraftPlayer) player).getHandle() : null); } + // 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 daadfec2d86f7957072a639e1e36d4082448f35f..666742df2f0547922ad40c38821c9fc70b654d24 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 0ad16ee7b33582d214dab41eeee378d52c8e38ed..874c6690ec46d482757093296bbcf1864382e13b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java @@ -14,8 +14,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 47633f05b4fab1dcabc2117e7645fe6d6949622a..f1e78960622b71aa63e172a1d856a757d6926a5a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java @@ -10,8 +10,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 c99cbd36f9bd52cdd1fbcec60ed6981cdfecbeed..b55d9add57561339f86e9c54e1a9e135ee01e8f6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java @@ -9,8 +9,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 e6782a48d22ba1e683e3fe463e970e8a5ed60fbd..9c04388e9d38103b40a154b6f0e13920ede451f5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMarker.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMarker.java @@ -9,8 +9,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 2534abcdce426189ac15e0659ab62840b3d54762..9fe092113bf3db33527670ebc2a2a351960cf458 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java @@ -20,8 +20,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 1027c915c0a2f981703908fdb2eb6beeb548f347..bff74243c147727087f4869d02ab31938afb16e3 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java @@ -11,8 +11,16 @@ public class CraftMinecartFurnace extends CraftMinecart implements PoweredMineca 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 fbabf86510c582e372b0b1ac5585c7287734c985..2e43d3667cc9ba35baf04658c13a8ed35b44e5cd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java @@ -34,8 +34,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 79b608e89d4d1f76a58868c585bb87c82e2689b1..7767a342b3d8bf9c07fbd73ad4ccacd8065c5869 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java @@ -42,8 +42,16 @@ public final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMi 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 153e4c88c168097eb4a78650e7c9c120bec202a3..d03069ef4e2b2b82d399cc5d4d6c093a9a763a88 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.minecraftToBukkit(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 efecddaa165decac6e0958b202ad838405220627..c79bb57c3734fb313ae1a02c2c5185ba35d676f1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java @@ -10,8 +10,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 b6c10507d4d62178cdf82033cc379d66d763aa9b..e0cc8454d7c2e6f3ae1805c686f3ee25dd5f0b9c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java @@ -9,8 +9,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 3d13a79f9add2e45db7f8538ee15e0d4e37a1314..bf06c6250c98ecc10b3585a1a0a4a2385e9a789e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java @@ -50,8 +50,16 @@ public class CraftPainting extends CraftHanging implements Painting { 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 56f9630dbe5d18d5ec33dc85f6531723022d6a3b..2683bcfea4812a0ec57b8c09758eb2b58c02d582 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java @@ -11,8 +11,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 f12b424c7d69b8a64075e1e48c2ac2d4e213d379..8cf5187ac315fdbff0df90fb612f4c9b7d52eccd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java @@ -11,8 +11,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 8338effd39b1709dbe578e247710a8e58d83e3aa..1d998942280db00ba7dab1c9d9a0f818490fe328 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java @@ -9,8 +9,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 2e7410678ffc3d742fb622f4d916df3974b661b1..33aad743e5e55881a1edefcf05d938a6a7301755 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java @@ -55,8 +55,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 fd9a841ed8a0062ece142d0cd2591786104fdda7..45653b31d2b4febe8d14bc6e1b9aa86ab6d7d2be 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java @@ -30,8 +30,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 03e74b29ebf0f9b9a0dbc6ffc872e22a22be20f0..c7411045c4901b6a66c62d68be911a4d7d1f7a9c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java @@ -75,8 +75,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 be874dc973fe632e8ace86041392ca69beaefd16..6889b4599aac0bd03badeefd74c891857f566c30 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinBrute.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinBrute.java @@ -9,8 +9,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 2638c341bc02f201f7ab17fdebcdbdf3a7ec05bf..0f5c2d31a2dea13a46ba81e353393633d097dcc7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java @@ -11,8 +11,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 13fd0b86f5b4b4f97bd0fdec4313a12210ffb38c..44c09217241fae975fa4f734dfc5be4b03094e73 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -611,7 +611,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); @@ -2148,9 +2148,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) { @@ -3164,7 +3171,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 3c4cbde06c768912332edf57768eabe082e47345..fa4bb2533d17d2e97301ba959144df478b195449 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java @@ -8,8 +8,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 35a8219734633529325430810e88755b2dd23125..85ebd34ed143304c603078f2e949179a8e628ed2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java @@ -10,8 +10,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 1a1dfb9e5164f9962059ebf11a9c3334a1987153..38972d1aec6b32aee12972cbca2411caeb823350 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java @@ -11,8 +11,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 763c368e299588f9a0e085a8a5e04e97e1f33428..58de24aeb98f19b2cf3fa9b0ad17e8b14bc1e475 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 09796ce15658e3f7c223a265a547a51ee729ed40..824db5f9f0b5c5f79bc073acaeb4f46aade740af 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftRavager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRavager.java @@ -9,8 +9,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 d4d8ce60098c74508e2de9541bf6534988779764..081d7f454b3556110f5a300602fbe9239d9b77c7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java @@ -9,8 +9,16 @@ public class CraftSalmon extends io.papermc.paper.entity.PaperSchoolableFish imp 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 19e8fc7fa6037b063bc1809c85c703996cd9b5ac..7aa1df10cafdaa778432dc43085b3e4502a2e79a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java @@ -29,8 +29,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 147db69955ad3b8b2f50aae87aa9c8f446ac22d2..6332f85b8b604a2fecba460ceb16380a626ec971 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java @@ -18,8 +18,16 @@ public class CraftShulker extends CraftGolem implements Shulker, CraftEnemy { return "CraftShulker"; } + // 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 807a498c2a80a5bd5eedf5322c699adebf25872f..d46d5c1c6934eb83ec46704573cf29d225429930 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java @@ -65,8 +65,16 @@ public class CraftShulkerBullet extends AbstractProjectile implements ShulkerBul return "CraftShulkerBullet"; } + // 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 598992e13586c38d6526ab496c773d5e5b39a7f2..a1ae5b9ffe97ee7fa55efc8b1cd04e7a682c5ee4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSilverfish.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSilverfish.java @@ -8,8 +8,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 16e6325a944c1eb21dd5a3835aa8a00d238e7b5d..9944be024fc0e0ceb12410d7168f0caf52a0728d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java @@ -31,8 +31,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 bba6dcac6df4841561cf39b9ea0fc116f57a901b..72c43e1ee4f2df751402e4d95a411c1ae110d21a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java @@ -20,8 +20,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 2b1211ee410a0246195053ad041eaa131f859bcd..a61121c6e103fce394e2fd93e60711d6e42c7ad1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java @@ -19,8 +19,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 262e9abf0887c82876d8843504c2dec362e68e6f..74b20c726a0b055180f6385b8020c646939d6690 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java @@ -8,8 +8,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 01328768ef2baba2aa7fea7e10b0eb9783497f4b..737b5ea7f6cbf3db6a8e5ee1bccbcd68191bbf32 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java @@ -16,8 +16,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 1650bd74e37e6963becd9d510d2b640da5c3fede..f72decb7c43337130d3caee6a15ae91cdaf57522 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java @@ -8,8 +8,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 e4a14cdfeb91a3d32e622d27d612605b1bca08e2..b1b87ad34caf0d7888ddf59692c8c766358a6b85 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java @@ -19,8 +19,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 f6ff0e5b16812ae6f577ec30cd6cca337a534ce2..8d89889fafa153d16a8b0a39e8c5ef6b0323ac65 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java @@ -9,8 +9,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 3da93b408a864e1663291ed22aaccfa6beba1280..3d09be063f750ecb79b1fc7f2bc4d65a3688e3c6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java @@ -9,8 +9,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 7f970e1a8d1b6d12cbfc1c6606ab537989655e5a..6f0197156e79fb34d8c54b4317ff6d66a19cb75b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java @@ -9,8 +9,16 @@ public class CraftSquid extends CraftWaterMob implements Squid { 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 09ca1e92b63507554a0801999a917f91375d9d59..796eca2bf20ec7a9de69027418d922473444e588 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java @@ -65,8 +65,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 dc13deb1cea14f0650b292ddb6437fadefc0b8be..c433fda809e9452046ff07aabaa216be3199862b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java @@ -42,8 +42,16 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed { 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 730a25ef2fe934f64f65c21e4e007cf1dbab8bf2..57df8021ce87cb688f84b28156d3f0c41888705d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java @@ -9,8 +9,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 9ef939b76d06874b856e0c850addb364146f5a00..d3975a461778d9815f68f323e616e25c24bf649c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java @@ -13,8 +13,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 6b3c381dbda3686b2644475fef2d373da4c2360a..40fe0132f877e8088b828744823981eb3351f650 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java @@ -9,8 +9,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 04bcb1f26db12556d70e41541a5df0700d20d964..6bbb6f2720ed8fc8b54edc3922d8423274ed8642 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java @@ -60,8 +60,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 182e8e9ecb789d639b2dd7348a68e37096da53ac..3d3ce1392dc9d86965c4baf80e3d92089da5ed2c 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 4b3a764114c8372e1549dadeeced26dc7727f2d1..04cbe165b99d348a864da5d342225fc929b2bfd0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java @@ -9,8 +9,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 c8b65210d2416b5a293cb4bcc1b71f56ed365cd7..0e3045647382111066000fc03925596c1d757e6b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java @@ -12,8 +12,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 d1d932dd27cff00e0ab69443a58715e3cbc1e57c..0deb1cb458d84f9321c4a020cb4bb26163b18fa7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java @@ -13,8 +13,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 d44e6f4bb682d18c1497eee9fb2802f2bda6e840..f2d589721a335d1f92ab04ce70e7678a244314fd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java @@ -9,8 +9,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 6079581ba2eef8ac9272d0bbbf77e31f593edf0f..f89b72a75dc685c08641105c8445f4e14aa9ee35 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java @@ -13,8 +13,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 a67b5d20b956e0bf801c9eeb9330567c21927010..6f353590ff2de58fb147bf65495018045976c1f6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -31,8 +31,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 fd968881eeec6dc5bdf90decc23a2bfc619c410d..96dba371b8fe88f8e15eee5fbc152a0b85bc0511 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java @@ -14,8 +14,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 bcd3370bc48520ea4bb53af25b892131d6ca0b33..c89dfec6f61d4f487bd6292d509a33922127162f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java @@ -9,8 +9,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 fd6ac99dae7e54b90f2b0e01430ac6db9410ccd4..ff3458e986a1063b097b6ae65ba4b2653aca8888 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java @@ -9,8 +9,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 46e3cc146a4b109c4baaf94f42d825646abade68..e41005b7df193d36bf11a12625d1774c8321cfd6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java @@ -15,8 +15,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 0acb96ae2102ab6af4b5610254ab3a1408ed9822..f0cfe156924e036639e5ba368a91be3a382c4780 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java @@ -15,8 +15,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 5a97c92f9b044d8ab7bd3346ceb464455a09046e..c44a349c7dbb5e48f9476fbbda3a8277e8b59aa1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java @@ -21,8 +21,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 cb228731bdefd90776261cba29328d56e9217d04..ad8ac056ef9e6abe1afe21622ba187c2d7f9e3a7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java @@ -18,8 +18,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 e16459c9cfcac790edd6d912750d32c68387cbbc..4100c8beb897b931ac0bf168a934286a4a43732a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java @@ -23,8 +23,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 24165f605708239076f839e4e1accd0560996f88..4af64566b17c39d21acc8f445eb993c9652f9928 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java @@ -19,8 +19,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 ed211b123354ece21dd8beae7192a26727f5124f..323634b642f8af27ba0eb8647c01acab865d300e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java @@ -12,8 +12,16 @@ public class CraftZombie extends CraftMonster implements Zombie { 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; }