geforkt von Mirrors/Paper
54dd19b818
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 18cda936 Fix variant of unloadChunkRequest that was incorrectly never deprecated 00763e1b Deprecate some methods 35a83d54 SPIGOT-4572: Make default no permission message clearer 6163343d Fix some misplaced material enum entries 8736469c Fix typo in TechnicalPiston documentation CraftBukkit Changes:0c715b32
SPIGOT-4579: Shulker boxes not dropping in creative50fbc3f1
SPIGOT-4576: Fix attributes in itemstack internal data being lost8059a937
SPIGOT-4577: Fix loss of int/double custom tags when serialized to yaml07e504c3
Clarify exception thrown when setting drop chance for player inventory98b862ad
Fix duplicate iron golem add843cee65
Fix a bunch of duplicate EntityCombustEvent calls43855624
SPIGOT-4571: EntityCombustEvent not firing for phantoms
140 Zeilen
6.5 KiB
Diff
140 Zeilen
6.5 KiB
Diff
From 1342f7d2b36a0aa22b7ae6eee34015b790d16f5e 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 2b4a784e4d..22f757756c 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -160,6 +160,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
|
|
public boolean forceExplosionKnockback; // SPIGOT-949
|
|
public Timing tickTimer = MinecraftTimings.getEntityTimings(this); // Paper
|
|
+ public Location origin; // Paper
|
|
// Spigot start
|
|
public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
|
|
public final boolean defaultActivationState;
|
|
@@ -1620,6 +1621,11 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
}
|
|
}
|
|
|
|
+ // Paper start - Save the entity's origin location
|
|
+ if (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");
|
|
@@ -1761,6 +1767,13 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
}
|
|
// CraftBukkit end
|
|
|
|
+ // Paper start - Restore the entity's origin location
|
|
+ NBTTagList originTag = nbttagcompound.getList("Paper.Origin", 6);
|
|
+ if (!originTag.isEmpty()) {
|
|
+ origin = new 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");
|
|
@@ -1836,6 +1849,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
|
|
protected abstract void b(NBTTagCompound nbttagcompound);
|
|
|
|
+ protected 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 a6eae266de..489dd861d2 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
@@ -249,6 +249,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 5dc52b6b89..2c28633c42 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
|
@@ -109,6 +109,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
|
|
}
|
|
|
|
@Nullable
|
|
diff --git a/src/main/java/net/minecraft/server/NBTTagList.java b/src/main/java/net/minecraft/server/NBTTagList.java
|
|
index 27debcfca9..22027321bd 100644
|
|
--- a/src/main/java/net/minecraft/server/NBTTagList.java
|
|
+++ b/src/main/java/net/minecraft/server/NBTTagList.java
|
|
@@ -182,6 +182,7 @@ public class NBTTagList extends NBTList<NBTBase> {
|
|
return new int[0];
|
|
}
|
|
|
|
+ public final double getDoubleAt(int i) { return this.k(i); } // Paper - OBFHELPER
|
|
public double k(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/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index dab1be9b61..59b1f90433 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -913,6 +913,12 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
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
|
|
index 8fb0ecf525..9a5bb02226 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
@@ -800,4 +800,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
|
|
}
|
|
--
|
|
2.20.1
|
|
|