2016-04-03 09:02:00 +02:00
|
|
|
From 2b9bf67504d0f896fddad31118b8d6d0e55045f2 Mon Sep 17 00:00:00 2001
|
2016-03-25 10:02:35 +01: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
|
2016-04-02 04:08:40 +02:00
|
|
|
index 9e84616..2d22842 100644
|
2016-03-25 10:02:35 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
@@ -142,6 +142,7 @@ public abstract class Entity implements ICommandListener {
|
|
|
|
public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only
|
|
|
|
public boolean forceExplosionKnockback; // CraftBukkit - SPIGOT-949
|
|
|
|
public Timing tickTimer = SpigotTimings.getEntityTimings(this); // Paper
|
|
|
|
+ public Location origin; // Paper
|
|
|
|
// Spigot start
|
|
|
|
public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
|
|
|
|
public final boolean defaultActivationState;
|
|
|
|
@@ -1347,6 +1348,11 @@ public abstract class Entity implements ICommandListener {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - Save the entity's origin location
|
|
|
|
+ if (origin != null) {
|
|
|
|
+ nbttagcompound.set("Paper.Origin", this.a(origin.getX(), origin.getY(), origin.getZ()));
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
} catch (Throwable throwable) {
|
|
|
|
CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT");
|
|
|
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being saved");
|
2016-03-25 17:32:09 +01:00
|
|
|
@@ -1480,6 +1486,13 @@ public abstract class Entity implements ICommandListener {
|
2016-03-25 10:02:35 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
+ // Paper start - Restore the entity's origin location
|
2016-03-25 17:32:09 +01:00
|
|
|
+ NBTTagList originTag = nbttagcompound.getList("Paper.Origin", 6);
|
|
|
|
+ if (!originTag.isEmpty()) {
|
|
|
|
+ origin = new Location(world.getWorld(), originTag.e(0), originTag.e(1), originTag.e(2));
|
2016-03-25 10:02:35 +01:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
} catch (Throwable throwable) {
|
|
|
|
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
|
|
|
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
|
|
index 6246c05..8f2b253 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
|
|
@@ -242,6 +242,14 @@ public class EntityFallingBlock extends Entity {
|
|
|
|
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
|
|
|
|
index 564ea37..1113b1c 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
|
|
|
@@ -104,6 +104,14 @@ public class EntityTNTPrimed extends Entity {
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
public EntityLiving getSource() {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2016-04-03 09:02:00 +02:00
|
|
|
index 0460dc5..87236e8 100644
|
2016-03-25 10:02:35 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
|
|
@@ -948,6 +948,12 @@ public abstract class World implements IBlockAccess {
|
|
|
|
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
|
2016-04-03 09:02:00 +02:00
|
|
|
index 908dcee..f4168c4 100644
|
2016-03-25 10:02:35 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
2016-04-03 09:02:00 +02:00
|
|
|
@@ -603,4 +603,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
2016-03-25 10:02:35 +01:00
|
|
|
return spigot;
|
|
|
|
}
|
|
|
|
// Spigot end
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public Location getOrigin() {
|
2016-03-25 17:39:37 +01:00
|
|
|
+ Location origin = getHandle().origin;
|
|
|
|
+ return origin == null ? null : origin.clone();
|
2016-03-25 10:02:35 +01:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java
|
|
|
|
index 75eed48..65e1408 100644
|
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java
|
|
|
|
@@ -57,4 +57,11 @@ public class CraftFallingSand extends CraftEntity implements FallingSand {
|
|
|
|
public void setHurtEntities(boolean hurtEntities) {
|
|
|
|
getHandle().hurtEntities = hurtEntities;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public org.bukkit.Location getSourceLoc() {
|
|
|
|
+ return getOrigin();
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
|
|
|
|
index c493c9c..93843aa 100644
|
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
|
|
|
|
@@ -65,4 +65,11 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public org.bukkit.Location getSourceLoc() {
|
|
|
|
+ return getOrigin();
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
--
|
2016-04-02 04:08:40 +02:00
|
|
|
2.8.0
|
2016-03-25 10:02:35 +01:00
|
|
|
|