diff --git a/patches/server/Entity-AddTo-RemoveFrom-World-Events.patch b/patches/server/Entity-AddTo-RemoveFrom-World-Events.patch index fd5b13ecf4..a88e1cd3d6 100644 --- a/patches/server/Entity-AddTo-RemoveFrom-World-Events.patch +++ b/patches/server/Entity-AddTo-RemoveFrom-World-Events.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl - entity.origin = entity.getBukkitEntity().getLocation(); + entity.setOrigin(entity.getBukkitEntity().getLocation()); } // Paper end + new com.destroystokyo.paper.event.entity.EntityAddToWorldEvent(entity.getBukkitEntity()).callEvent(); // Paper - fire while valid diff --git a/patches/server/Entity-Origin-API.patch b/patches/server/Entity-Origin-API.patch index fa708c4b72..d4c04b9725 100644 --- a/patches/server/Entity-Origin-API.patch +++ b/patches/server/Entity-Origin-API.patch @@ -25,8 +25,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } + // Paper start - Set origin location when the entity is being added to the world -+ if (entity.origin == null) { -+ entity.origin = entity.getBukkitEntity().getLocation(); ++ if (entity.getOriginVector() == null) { ++ entity.setOrigin(entity.getBukkitEntity().getLocation()); + } + // Paper end } @@ -40,7 +40,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only public boolean forceExplosionKnockback; // SPIGOT-949 public boolean persistentInvisibility = false; -+ public org.bukkit.Location origin; // Paper ++ // Paper start ++ @javax.annotation.Nullable ++ private org.bukkit.util.Vector origin; ++ @javax.annotation.Nullable ++ private UUID originWorld; ++ ++ public void setOrigin(@javax.annotation.Nonnull Location location) { ++ this.origin = location.toVector(); ++ this.originWorld = location.getWorld().getUID(); ++ } ++ ++ @javax.annotation.Nullable ++ public org.bukkit.util.Vector getOriginVector() { ++ return this.origin != null ? this.origin.clone() : null; ++ } ++ ++ @javax.annotation.Nullable ++ public UUID getOriginWorld() { ++ return this.originWorld; ++ } ++ // Paper // Spigot start public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this); public final boolean defaultActivationState; @@ -50,7 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit end + // Paper start - Save the entity's origin location + if (this.origin != null) { -+ nbt.setUUID("Paper.OriginWorld", origin.getWorld().getUID()); ++ nbt.setUUID("Paper.OriginWorld", originWorld); + nbt.put("Paper.Origin", this.newDoubleList(origin.getX(), origin.getY(), origin.getZ())); + } + // Paper end @@ -64,11 +84,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - Restore the entity's origin location + ListTag originTag = nbt.getList("Paper.Origin", 6); + if (!originTag.isEmpty()) { -+ org.bukkit.World originWorld = level.getWorld(); ++ UUID originWorld = level.getWorld().getUID(); + if (nbt.contains("Paper.OriginWorld")) { -+ originWorld = Bukkit.getWorld(nbt.getUUID("Paper.OriginWorld")); ++ originWorld = nbt.getUUID("Paper.OriginWorld"); + } -+ origin = new org.bukkit.Location(originWorld, originTag.getDoubleAt(0), originTag.getDoubleAt(1), originTag.getDoubleAt(2)); ++ this.originWorld = originWorld; ++ origin = new org.bukkit.util.Vector(originTag.getDoubleAt(0), originTag.getDoubleAt(1), originTag.getDoubleAt(2)); + } + // Paper end + @@ -88,7 +109,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + int srcX = nbt.getInt("SourceLoc_x"); + int srcY = nbt.getInt("SourceLoc_y"); + int srcZ = nbt.getInt("SourceLoc_z"); -+ origin = new org.bukkit.Location(level.getWorld(), srcX, srcY, srcZ); ++ this.setOrigin(new org.bukkit.Location(level.getWorld(), srcX, srcY, srcZ)); + } + // Paper end } @@ -107,7 +128,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + int srcX = nbt.getInt("SourceLoc_x"); + int srcY = nbt.getInt("SourceLoc_y"); + int srcZ = nbt.getInt("SourceLoc_z"); -+ origin = new org.bukkit.Location(level.getWorld(), srcX, srcY, srcZ); ++ this.setOrigin(new org.bukkit.Location(level.getWorld(), srcX, srcY, srcZ)); + } + // Paper end } @@ -125,8 +146,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + @Override + public Location getOrigin() { -+ Location origin = getHandle().origin; -+ return origin == null ? null : origin.clone(); ++ Vector originVector = this.getHandle().getOriginVector(); ++ if (originVector == null) { ++ return null; ++ } ++ World world = this.getWorld(); ++ if (this.getHandle().getOriginWorld() != null) { ++ world = org.bukkit.Bukkit.getWorld(this.getHandle().getOriginWorld()); ++ } ++ ++ //noinspection ConstantConditions ++ return originVector.toLocation(world); + } + // Paper end } diff --git a/patches/server/Entity-fromMobSpawner.patch b/patches/server/Entity-fromMobSpawner.patch index b281276867..ed801b9908 100644 --- a/patches/server/Entity-fromMobSpawner.patch +++ b/patches/server/Entity-fromMobSpawner.patch @@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void inactiveTick() { } // Spigot end @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n - nbt.setUUID("Paper.OriginWorld", origin.getWorld().getUID()); + nbt.setUUID("Paper.OriginWorld", originWorld); nbt.put("Paper.Origin", this.newDoubleList(origin.getX(), origin.getY(), origin.getZ())); } + // Save entity's from mob spawner status @@ -28,8 +28,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return nbt; } catch (Throwable throwable) { @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n - } - origin = new org.bukkit.Location(originWorld, originTag.getDoubleAt(0), originTag.getDoubleAt(1), originTag.getDoubleAt(2)); + this.originWorld = originWorld; + origin = new org.bukkit.util.Vector(originTag.getDoubleAt(0), originTag.getDoubleAt(1), originTag.getDoubleAt(2)); } + + spawnedViaMobSpawner = nbt.getBoolean("Paper.FromMobSpawner"); // Restore entity's from mob spawner status @@ -53,8 +53,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - Location origin = getHandle().origin; - return origin == null ? null : origin.clone(); + //noinspection ConstantConditions + return originVector.toLocation(world); } + + @Override diff --git a/patches/server/Entity-getEntitySpawnReason.patch b/patches/server/Entity-getEntitySpawnReason.patch index 5d15f6a1c1..6cf19eceb8 100644 --- a/patches/server/Entity-getEntitySpawnReason.patch +++ b/patches/server/Entity-getEntitySpawnReason.patch @@ -56,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n - nbt.setUUID("Paper.OriginWorld", origin.getWorld().getUID()); + nbt.setUUID("Paper.OriginWorld", originWorld); nbt.put("Paper.Origin", this.newDoubleList(origin.getX(), origin.getY(), origin.getZ())); } + if (spawnReason != null) { diff --git a/patches/server/Fix-invulnerable-end-crystals.patch b/patches/server/Fix-invulnerable-end-crystals.patch index 7e4f09bc32..5deaf9cda9 100644 --- a/patches/server/Fix-invulnerable-end-crystals.patch +++ b/patches/server/Fix-invulnerable-end-crystals.patch @@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + // Paper start - Fix invulnerable end crystals + if (this.level.paperConfig.fixInvulnerableEndCrystalExploit && this.generatedByDragonFight && this.isInvulnerable()) { -+ if ((this.origin.getWorld() != null && !((ServerLevel) this.level).uuid.equals(this.origin.getWorld().getUID())) ++ if (!java.util.Objects.equals(((ServerLevel) this.level).uuid, this.getOriginWorld()) + || ((ServerLevel) this.level).dragonFight() == null + || ((ServerLevel) this.level).dragonFight().respawnStage == null + || ((ServerLevel) this.level).dragonFight().respawnStage.ordinal() > net.minecraft.world.level.dimension.end.DragonRespawnAnimation.SUMMONING_DRAGON.ordinal()) {