Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 20:40:07 +01:00
2f34301581
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: 7361a62e SPIGOT-5641: Add Block.getDrops(ItemStack, Entity) 1dc91b15 Add specific notes about what is not API 2b05ef88 #484: Allow statistics to be accessed for offline players CraftBukkit Changes:f7d6ad53
SPIGOT-5603: Use LootContext#lootingModifier in CraftLootTable5838285d
SPIGOT-5657: BlockPlaceEvent not cancelling for tripwire hooksf325b9be
SPIGOT-5641: Add Block.getDrops(ItemStack, Entity)e25a2272
Fix some formatting in CraftHumanEntity498540e0
Add Merchant slot delegateb2de47d5
SPIGOT-5621: Add missing container types for opening InventoryViewaa3a2f27
#645: Allow statistics to be accessed for offline players2122c0b1
#649: CraftBell should implement Bell
139 Zeilen
6.6 KiB
Diff
139 Zeilen
6.6 KiB
Diff
From 9267e410b3666e372fb8f2a5bb534e903b401c89 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 7d4badd974..18236504e4 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -167,6 +167,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 org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
|
|
public final boolean defaultActivationState;
|
|
@@ -1580,6 +1581,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");
|
|
@@ -1694,6 +1700,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 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");
|
|
@@ -1775,6 +1788,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 2097ec535e..e64722f63b 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 d9fd4448c7..7f8b8f5a36 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 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 5406f4c40f..d778eac45d 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 6810d49b17..450b414298 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -1180,6 +1180,11 @@ public class WorldServer extends World {
|
|
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 c82c213260..a296936748 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
@@ -1007,4 +1007,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.25.1
|
|
|