2017-08-03 14:36:06 +00:00
|
|
|
From 0a357cb9c574fa7812c4b90a4b59cc2c8082bdcd 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
|
2017-08-03 14:36:06 +00:00
|
|
|
index 86c946119..acadeae93 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
|
2017-06-11 17:03:07 +00:00
|
|
|
@@ -148,6 +148,7 @@ public abstract class Entity implements ICommandListener {
|
2016-03-25 09:02:35 +00:00
|
|
|
public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only
|
|
|
|
public boolean forceExplosionKnockback; // CraftBukkit - SPIGOT-949
|
2016-04-30 01:23:40 +00:00
|
|
|
public Timing tickTimer = MinecraftTimings.getEntityTimings(this); // Paper
|
2016-03-25 09:02:35 +00:00
|
|
|
+ public Location origin; // Paper
|
|
|
|
// Spigot start
|
|
|
|
public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
|
|
|
|
public final boolean defaultActivationState;
|
2017-05-14 18:05:01 +00:00
|
|
|
@@ -1539,6 +1540,11 @@ public abstract class Entity implements ICommandListener {
|
2016-03-25 09:02:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - Save the entity's origin location
|
|
|
|
+ if (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");
|
2017-05-14 18:05:01 +00:00
|
|
|
@@ -1683,6 +1689,13 @@ public abstract class Entity implements ICommandListener {
|
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()) {
|
2017-05-14 18:05:01 +00:00
|
|
|
+ origin = new 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");
|
2017-05-14 18:05:01 +00:00
|
|
|
@@ -1707,6 +1720,7 @@ public abstract class Entity implements ICommandListener {
|
2016-05-12 02:07:46 +00:00
|
|
|
|
2016-06-09 03:57:14 +00:00
|
|
|
protected abstract void b(NBTTagCompound nbttagcompound);
|
2016-05-12 02:07:46 +00:00
|
|
|
|
2016-06-09 03:57:14 +00:00
|
|
|
+ protected 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
|
2017-08-03 14:36:06 +00:00
|
|
|
index 2ba5d51a5..abdc2dea9 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
|
2017-05-14 18:05:01 +00:00
|
|
|
@@ -267,6 +267,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
|
2017-05-14 18:05:01 +00:00
|
|
|
index 0d70dd1d2..bb0904f86 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
|
2017-05-14 18:05:01 +00:00
|
|
|
@@ -109,6 +109,14 @@ public class EntityTNTPrimed extends Entity {
|
2016-03-25 09:02:35 +00:00
|
|
|
|
|
|
|
protected void a(NBTTagCompound nbttagcompound) {
|
|
|
|
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
|
|
|
|
index bc6383669..ca9eb2f3b 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/NBTTagList.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/NBTTagList.java
|
|
|
|
@@ -153,6 +153,7 @@ public class NBTTagList extends NBTBase {
|
|
|
|
return new int[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public final double getDoubleAt(int i) { return this.f(i); } // Paper - OBFHELPER
|
|
|
|
public double f(int i) {
|
|
|
|
if (i >= 0 && i < this.list.size()) {
|
|
|
|
NBTBase nbtbase = (NBTBase) this.list.get(i);
|
2016-03-25 09:02:35 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2017-08-03 14:36:06 +00:00
|
|
|
index 27f428efa..3298cbe6b 100644
|
2016-03-25 09:02:35 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2017-08-03 14:36:06 +00:00
|
|
|
@@ -1025,6 +1025,12 @@ public abstract class World implements IBlockAccess {
|
2016-03-25 09:02:35 +00:00
|
|
|
int j = MathHelper.floor(entity.locZ / 16.0D);
|
|
|
|
boolean flag = entity.attachedToPlayer;
|
|
|
|
|
|
|
|
+ // 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
|
|
|
|
+
|
|
|
|
if (entity instanceof EntityHuman) {
|
|
|
|
flag = true;
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
2017-08-03 14:36:06 +00:00
|
|
|
index 30641581a..9ee7593b2 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
|
2017-06-13 03:28:09 +00:00
|
|
|
@@ -749,4 +749,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
|
|
|
|
}
|
|
|
|
--
|
2017-08-03 14:36:06 +00:00
|
|
|
2.13.3.windows.1
|
2016-03-25 09:02:35 +00:00
|
|
|
|