geforkt von Mirrors/Paper
6fda3fd0ed
This makes it so entities that are passengers of other entities no longer count in the parents timings, as well as tracks them as a separate timers per their tick status. This lets you see how much time is spent in activated entities vs inactive (as inactive still has to do work) Passengers is also tracked separately so you can identify "Villagers in Minecarts" vs roaming villagers, as the lack of ability to move can impact their performance characteristics. This will likely break any plugin that was naughty and directly messed with our internal timings as this moves the timings to the EntityTypes object, speeding up creation of Entities to no longer store a timing handler object per entity. This will also change the output of the entities in timings to use internal ID's instead of class names. If a plugin is broken by this, shame them for doing bad things. Paper will not fix it, they will have to fix it.
136 Zeilen
7.0 KiB
Diff
136 Zeilen
7.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
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
|
|
index 9bfbbacdf19801aee1f1e566006059181401f676..9f0ae86bbd26c151b371b399db92f527fc4b51d6 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -161,6 +161,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
public boolean valid;
|
|
public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
|
|
public boolean forceExplosionKnockback; // SPIGOT-949
|
|
+ public org.bukkit.Location origin; // Paper
|
|
// Spigot start
|
|
public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
|
|
public final boolean defaultActivationState;
|
|
@@ -1536,6 +1537,11 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
this.bukkitEntity.storeBukkitValues(nbttagcompound);
|
|
}
|
|
// CraftBukkit end
|
|
+ // Paper start - Save the entity's origin location
|
|
+ if (this.origin != null) {
|
|
+ nbttagcompound.set("Paper.Origin", this.createList(origin.getX(), origin.getY(), origin.getZ()));
|
|
+ }
|
|
+ // Paper end
|
|
return nbttagcompound;
|
|
} catch (Throwable throwable) {
|
|
CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT");
|
|
@@ -1653,6 +1659,13 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
this.getBukkitEntity().readBukkitValues(nbttagcompound);
|
|
// CraftBukkit end
|
|
|
|
+ // Paper start - Restore the entity's origin location
|
|
+ NBTTagList originTag = nbttagcompound.getList("Paper.Origin", 6);
|
|
+ if (!originTag.isEmpty()) {
|
|
+ origin = new org.bukkit.Location(world.getWorld(), originTag.getDoubleAt(0), originTag.getDoubleAt(1), originTag.getDoubleAt(2));
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
} catch (Throwable throwable) {
|
|
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
|
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
|
|
@@ -1714,6 +1727,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
|
|
protected abstract void saveData(NBTTagCompound nbttagcompound);
|
|
|
|
+ protected final NBTTagList createList(double... adouble) { return a(adouble); } // Paper - OBFHELPER
|
|
protected NBTTagList a(double... adouble) {
|
|
NBTTagList nbttaglist = new NBTTagList();
|
|
double[] adouble1 = adouble;
|
|
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
index e7efc540a9ec67e67714c9b3cfd2c24c0842e3f5..969b0dca4acc959330c5f10a2c970c896d23ce63 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
@@ -254,6 +254,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 71404a34d27dd7771ea1145085a6a6e4dc7589b0..623db6e3befcc7031e68c71f7eb179fce78291c4 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 {
|
|
@Override
|
|
protected void loadData(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
|
|
}
|
|
|
|
@Nullable
|
|
diff --git a/src/main/java/net/minecraft/server/NBTTagList.java b/src/main/java/net/minecraft/server/NBTTagList.java
|
|
index ad8a506bb430b26fe147a657a2f826daf9bf4d45..ad4807e0bdd6409bd798f995da8f43cec1d0b385 100644
|
|
--- a/src/main/java/net/minecraft/server/NBTTagList.java
|
|
+++ b/src/main/java/net/minecraft/server/NBTTagList.java
|
|
@@ -188,6 +188,7 @@ public class NBTTagList extends NBTList<NBTBase> {
|
|
return new int[0];
|
|
}
|
|
|
|
+ public final double getDoubleAt(int i) { return this.h(i); } // Paper - OBFHELPER
|
|
public double h(int i) {
|
|
if (i >= 0 && i < this.list.size()) {
|
|
NBTBase nbtbase = (NBTBase) this.list.get(i);
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
|
index 3c917e814c05c1a6284d6a0d00ae31aed5d37ff0..dea829c3a568c0f78e8c4413c92f6fcc05297d8b 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -1129,6 +1129,11 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
this.navigators.add(((EntityInsentient) entity).getNavigation());
|
|
}
|
|
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
|
|
}
|
|
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
index 66878c53bfb71392bf07d2c41a2edf1bc8f7af79..10f96056700c88cc8e83477877788e3443cecefd 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
@@ -1022,4 +1022,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|
return spigot;
|
|
}
|
|
// Spigot end
|
|
+
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public Location getOrigin() {
|
|
+ Location origin = getHandle().origin;
|
|
+ return origin == null ? null : origin.clone();
|
|
+ }
|
|
+ // Paper end
|
|
}
|