2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2016-03-25 09:02:35 +00:00
|
|
|
From: Byteflux <byte@byteflux.net>
|
|
|
|
Date: Tue, 1 Mar 2016 23:45:08 -0600
|
|
|
|
Subject: [PATCH] Entity Origin API
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
2020-12-21 07:56:22 +00:00
|
|
|
index 3e37374eba5d806a8e776924e034d26b06f26766..f20c6f1d2118a5f3feaace82f1c472c8ebbd26c0 100644
|
2016-03-25 09:02:35 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2020-09-19 11:29:53 +00:00
|
|
|
@@ -162,6 +162,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
2017-11-08 16:13:57 +00:00
|
|
|
public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
|
|
|
|
public boolean forceExplosionKnockback; // SPIGOT-949
|
2020-09-19 11:29:53 +00:00
|
|
|
public boolean persistentInvisibility = false;
|
2020-06-26 06:29:44 +00:00
|
|
|
+ public org.bukkit.Location origin; // Paper
|
2016-03-25 09:02:35 +00:00
|
|
|
// Spigot start
|
2019-05-30 23:54:25 +00:00
|
|
|
public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
|
2016-03-25 09:02:35 +00:00
|
|
|
public final boolean defaultActivationState;
|
2020-09-19 11:29:53 +00:00
|
|
|
@@ -1540,6 +1541,11 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
2019-05-06 02:58:04 +00:00
|
|
|
this.bukkitEntity.storeBukkitValues(nbttagcompound);
|
2016-03-25 09:02:35 +00:00
|
|
|
}
|
2019-05-06 02:58:04 +00:00
|
|
|
// CraftBukkit end
|
2016-03-25 09:02:35 +00:00
|
|
|
+ // Paper start - Save the entity's origin location
|
2019-05-06 02:58:04 +00:00
|
|
|
+ if (this.origin != null) {
|
2016-05-12 02:07:46 +00:00
|
|
|
+ nbttagcompound.set("Paper.Origin", this.createList(origin.getX(), origin.getY(), origin.getZ()));
|
2016-03-25 09:02:35 +00:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2016-05-12 02:07:46 +00:00
|
|
|
return nbttagcompound;
|
2016-03-25 09:02:35 +00:00
|
|
|
} catch (Throwable throwable) {
|
|
|
|
CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT");
|
2020-09-19 11:29:53 +00:00
|
|
|
@@ -1662,6 +1668,13 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
|
|
}
|
2016-03-25 09:02:35 +00:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
+ // Paper start - Restore the entity's origin location
|
2016-03-25 16:32:09 +00:00
|
|
|
+ NBTTagList originTag = nbttagcompound.getList("Paper.Origin", 6);
|
|
|
|
+ if (!originTag.isEmpty()) {
|
2020-06-26 06:29:44 +00:00
|
|
|
+ origin = new org.bukkit.Location(world.getWorld(), originTag.getDoubleAt(0), originTag.getDoubleAt(1), originTag.getDoubleAt(2));
|
2016-03-25 09:02:35 +00:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
} catch (Throwable throwable) {
|
|
|
|
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
|
|
|
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
|
2020-09-19 11:29:53 +00:00
|
|
|
@@ -1723,6 +1736,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
2016-05-12 02:07:46 +00:00
|
|
|
|
2020-06-25 09:27:25 +00:00
|
|
|
protected abstract void saveData(NBTTagCompound nbttagcompound);
|
2016-05-12 02:07:46 +00:00
|
|
|
|
2020-08-02 05:39:36 +00:00
|
|
|
+ protected final NBTTagList createList(double... adouble) { return a(adouble); } // Paper - OBFHELPER
|
2016-05-12 02:07:46 +00:00
|
|
|
protected NBTTagList a(double... adouble) {
|
|
|
|
NBTTagList nbttaglist = new NBTTagList();
|
|
|
|
double[] adouble1 = adouble;
|
2016-03-25 09:02:35 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
2020-11-03 02:22:15 +00:00
|
|
|
index 6b226c04d40adff8b0f1d28c0cc79439df002b3d..bdeabfaeb17778a12ab4ad72689a72b043efcff4 100644
|
2016-03-25 09:02:35 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
2020-04-08 07:49:15 +00:00
|
|
|
@@ -254,6 +254,14 @@ public class EntityFallingBlock extends Entity {
|
2016-03-25 09:02:35 +00:00
|
|
|
this.block = Blocks.SAND.getBlockData();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - Try and load origin location from the old NBT tags for backwards compatibility
|
|
|
|
+ if (nbttagcompound.hasKey("SourceLoc_x")) {
|
|
|
|
+ int srcX = nbttagcompound.getInt("SourceLoc_x");
|
|
|
|
+ int srcY = nbttagcompound.getInt("SourceLoc_y");
|
|
|
|
+ int srcZ = nbttagcompound.getInt("SourceLoc_z");
|
|
|
|
+ origin = new org.bukkit.Location(world.getWorld(), srcX, srcY, srcZ);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(boolean flag) {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
2020-11-03 02:22:15 +00:00
|
|
|
index 2b8ed9d14bd6dd9330712741859eb77ba0194153..e25404fd89ad6317c2656c68c2e32aa05e5f0e73 100644
|
2016-03-25 09:02:35 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
2020-04-08 07:49:15 +00:00
|
|
|
@@ -104,6 +104,14 @@ public class EntityTNTPrimed extends Entity {
|
2019-04-24 02:34:11 +00:00
|
|
|
@Override
|
2020-06-25 09:27:25 +00:00
|
|
|
protected void loadData(NBTTagCompound nbttagcompound) {
|
2016-03-25 09:02:35 +00:00
|
|
|
this.setFuseTicks(nbttagcompound.getShort("Fuse"));
|
|
|
|
+ // Paper start - Try and load origin location from the old NBT tags for backwards compatibility
|
|
|
|
+ if (nbttagcompound.hasKey("SourceLoc_x")) {
|
|
|
|
+ int srcX = nbttagcompound.getInt("SourceLoc_x");
|
|
|
|
+ int srcY = nbttagcompound.getInt("SourceLoc_y");
|
|
|
|
+ int srcZ = nbttagcompound.getInt("SourceLoc_z");
|
|
|
|
+ origin = new org.bukkit.Location(world.getWorld(), srcX, srcY, srcZ);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
2016-11-17 02:23:38 +00:00
|
|
|
@Nullable
|
2017-05-14 18:05:01 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/NBTTagList.java b/src/main/java/net/minecraft/server/NBTTagList.java
|
2020-06-25 09:27:25 +00:00
|
|
|
index ad8a506bb430b26fe147a657a2f826daf9bf4d45..ad4807e0bdd6409bd798f995da8f43cec1d0b385 100644
|
2017-05-14 18:05:01 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/NBTTagList.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/NBTTagList.java
|
2019-12-11 00:56:03 +00:00
|
|
|
@@ -188,6 +188,7 @@ public class NBTTagList extends NBTList<NBTBase> {
|
2017-05-14 18:05:01 +00:00
|
|
|
return new int[0];
|
|
|
|
}
|
|
|
|
|
2019-04-24 02:34:11 +00:00
|
|
|
+ public final double getDoubleAt(int i) { return this.h(i); } // Paper - OBFHELPER
|
|
|
|
public double h(int i) {
|
2017-05-14 18:05:01 +00:00
|
|
|
if (i >= 0 && i < this.list.size()) {
|
2019-01-01 03:15:55 +00:00
|
|
|
NBTBase nbtbase = (NBTBase) this.list.get(i);
|
2019-05-05 21:39:51 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
2020-11-18 03:45:18 +00:00
|
|
|
index da01aac42b32af6831a69f49e43d77fd6d5704ca..5c5229a815f098411450f6affb883c40c170fb2e 100644
|
2019-05-05 21:39:51 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
2020-11-18 03:45:18 +00:00
|
|
|
@@ -1135,6 +1135,11 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2019-12-11 00:56:03 +00:00
|
|
|
this.navigators.add(((EntityInsentient) entity).getNavigation());
|
2019-05-05 21:39:51 +00:00
|
|
|
}
|
|
|
|
entity.valid = true; // CraftBukkit
|
|
|
|
+ // Paper start - Set origin location when the entity is being added to the world
|
|
|
|
+ if (entity.origin == null) {
|
|
|
|
+ entity.origin = entity.getBukkitEntity().getLocation();
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2016-03-25 09:02:35 +00:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
2020-12-21 07:56:22 +00:00
|
|
|
index db7c4011c8b90b6daca2b48a6d9ec447d31f7197..b9a789b161d20aefd93142cb7549f3023d402e8c 100644
|
2016-03-25 09:02:35 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
2020-12-21 07:56:22 +00:00
|
|
|
@@ -1049,4 +1049,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
2016-03-25 09:02:35 +00:00
|
|
|
return spigot;
|
|
|
|
}
|
|
|
|
// Spigot end
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public Location getOrigin() {
|
2016-03-25 16:39:37 +00:00
|
|
|
+ Location origin = getHandle().origin;
|
|
|
|
+ return origin == null ? null : origin.clone();
|
2016-03-25 09:02:35 +00:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|