Try even harder to get an origin world and avoid NPEs (Fixes #5931)
This commit is contained in:
parent
aed4433aca
commit
a9394b8c1a
21 changed files with 69 additions and 62 deletions
|
@ -5,10 +5,10 @@ Subject: [PATCH] Entity Origin API
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 5c5cfc31ced6695af7b1dd06cb867274fa38d85f..a127467fdd25b7513c727e1a0634f85087ec542e 100644
|
||||
index 5c5cfc31ced6695af7b1dd06cb867274fa38d85f..fb6e3f0c86c78024203e24d1d7ef51e0ed0283cd 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1894,6 +1894,11 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||||
@@ -1894,6 +1894,15 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||||
}
|
||||
|
||||
entity.valid = true; // CraftBukkit
|
||||
|
@ -16,12 +16,16 @@ index 5c5cfc31ced6695af7b1dd06cb867274fa38d85f..a127467fdd25b7513c727e1a0634f850
|
|||
+ if (entity.getOriginVector() == null) {
|
||||
+ entity.setOrigin(entity.getBukkitEntity().getLocation());
|
||||
+ }
|
||||
+ // Default to current world if unknown, gross assumption but entities rarely change world
|
||||
+ if (entity.getOriginWorld() == null) {
|
||||
+ entity.setOrigin(entity.getOriginVector().toLocation(getWorld()));
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public void onTrackingEnd(Entity entity) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 018792503e5d18470ad17b9f4b4524d5dfba31e9..fcf7113ce8e14ce5e8ae75d8400c6b66e752c4b4 100644
|
||||
index 018792503e5d18470ad17b9f4b4524d5dfba31e9..c8b9381c83d62c8884ec5bbe4aa7ba89d51e5e16 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -280,6 +280,27 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||
|
@ -52,20 +56,23 @@ index 018792503e5d18470ad17b9f4b4524d5dfba31e9..fcf7113ce8e14ce5e8ae75d8400c6b66
|
|||
// Spigot start
|
||||
public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
|
||||
public final boolean defaultActivationState;
|
||||
@@ -1812,6 +1833,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||
@@ -1812,6 +1833,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||
this.bukkitEntity.storeBukkitValues(nbt);
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ // Paper start - Save the entity's origin location
|
||||
+ if (this.origin != null) {
|
||||
+ nbt.putUUID("Paper.OriginWorld", originWorld);
|
||||
+ UUID originWorld = this.originWorld != null ? this.originWorld : this.level != null ? this.level.getWorld().getUID() : null;
|
||||
+ if (originWorld != null) {
|
||||
+ nbt.putUUID("Paper.OriginWorld", originWorld);
|
||||
+ }
|
||||
+ nbt.put("Paper.Origin", this.newDoubleList(origin.getX(), origin.getY(), origin.getZ()));
|
||||
+ }
|
||||
+ // Paper end
|
||||
return nbt;
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
|
||||
@@ -1938,6 +1965,20 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||
@@ -1938,6 +1968,20 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue