Try to prevent an NPE from origin data (Fixes #5905)
This commit is contained in:
@@ -21,7 +21,7 @@ index 5c5cfc31ced6695af7b1dd06cb867274fa38d85f..a127467fdd25b7513c727e1a0634f850
|
||||
|
||||
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..5d4d5628e5c0d82301f988691eac363758af6a4b 100644
|
||||
index 018792503e5d18470ad17b9f4b4524d5dfba31e9..fcf7113ce8e14ce5e8ae75d8400c6b66e752c4b4 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
|
||||
@@ -65,16 +65,18 @@ index 018792503e5d18470ad17b9f4b4524d5dfba31e9..5d4d5628e5c0d82301f988691eac3637
|
||||
return nbt;
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
|
||||
@@ -1938,6 +1965,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||
@@ -1938,6 +1965,20 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
+ // Paper start - Restore the entity's origin location
|
||||
+ ListTag originTag = nbt.getList("Paper.Origin", 6);
|
||||
+ if (!originTag.isEmpty()) {
|
||||
+ UUID originWorld = level.getWorld().getUID();
|
||||
+ UUID originWorld = null;
|
||||
+ if (nbt.contains("Paper.OriginWorld")) {
|
||||
+ originWorld = nbt.getUUID("Paper.OriginWorld");
|
||||
+ } else if (this.level != null) {
|
||||
+ originWorld = this.level.getWorld().getUID();
|
||||
+ }
|
||||
+ this.originWorld = originWorld;
|
||||
+ origin = new org.bukkit.util.Vector(originTag.getDouble(0), originTag.getDouble(1), originTag.getDouble(2));
|
||||
|
||||
Reference in New Issue
Block a user