Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 20:40:07 +01:00
26734e83b0
* Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appear 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: 8085edde SPIGOT-6918: Add SpawnCategory API and configurations for Axolotls 04c7e13c PR-719: Add Player Profile API 71564210 SPIGOT-6910: Add BlockDamageAbortEvent CraftBukkit Changes: febaa1c6 SPIGOT-6918: Add SpawnCategory API and configurations for Axolotls 9dafd109 Don't send updates over large distances bdac46b0 SPIGOT-6782: EntityPortalEvent should not destroy entity when setTo() uses same world as getFrom() 8f361ece PR-1002: Add Player Profile API 911875d4 Increase outdated build delay e5f8a767 SPIGOT-6917: Use main scoreboard for /trigger a672a531 Clean up callBlockDamageEvent 8e1bdeef SPIGOT-6910: Add BlockDamageAbortEvent Spigot Changes: 6edb62f3 Rebuild patches 7fbc6a1e Rebuild patches * Updated Upstream (CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing CraftBukkit Changes: de951355 SPIGOT-6927: Fix default value of spawn-limits in Worlds
160 Zeilen
7.4 KiB
Diff
160 Zeilen
7.4 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/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index c7fe4b6aa8d68bd5dc394752a5ae635eb46c5f31..a38fe84e9f8060640eb0c485957e8ceaef55c29b 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -2016,6 +2016,15 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
}
|
|
|
|
entity.valid = true; // CraftBukkit
|
|
+ // Paper start - Set origin location when the entity is being added to the world
|
|
+ if (entity.getOriginVector() == null) {
|
|
+ entity.setOrigin(entity.getBukkitEntity().getLocation());
|
|
+ }
|
|
+ // Default to current world if unknown, gross assumption but entities rarely change world
|
|
+ if (entity.getOriginWorld() == null) {
|
|
+ entity.setOrigin(entity.getOriginVector().toLocation(getWorld()));
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
public void onTrackingEnd(Entity entity) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index b883558c101ad1e5d051cc8d14e1905aa3af6aad..a0c9493c7067dabbc5c9f118d01eb9c8bdd6a8a1 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -297,7 +297,27 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
|
public long activatedTick = Integer.MIN_VALUE;
|
|
public void inactiveTick() { }
|
|
// Spigot end
|
|
+ // Paper start
|
|
+ @javax.annotation.Nullable
|
|
+ private org.bukkit.util.Vector origin;
|
|
+ @javax.annotation.Nullable
|
|
+ private UUID originWorld;
|
|
+
|
|
+ public void setOrigin(@javax.annotation.Nonnull Location location) {
|
|
+ this.origin = location.toVector();
|
|
+ this.originWorld = location.getWorld().getUID();
|
|
+ }
|
|
|
|
+ @javax.annotation.Nullable
|
|
+ public org.bukkit.util.Vector getOriginVector() {
|
|
+ return this.origin != null ? this.origin.clone() : null;
|
|
+ }
|
|
+
|
|
+ @javax.annotation.Nullable
|
|
+ public UUID getOriginWorld() {
|
|
+ return this.originWorld;
|
|
+ }
|
|
+ // Paper end
|
|
public float getBukkitYaw() {
|
|
return this.yRot;
|
|
}
|
|
@@ -1817,6 +1837,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
|
this.bukkitEntity.storeBukkitValues(nbt);
|
|
}
|
|
// CraftBukkit end
|
|
+ // Paper start - Save the entity's origin location
|
|
+ if (this.origin != null) {
|
|
+ UUID originWorld = this.originWorld != null ? this.originWorld : this.level != null ? this.level.getWorld().getUID() : null;
|
|
+ if (originWorld != null) {
|
|
+ nbt.putUUID("Paper.OriginWorld", originWorld);
|
|
+ }
|
|
+ nbt.put("Paper.Origin", this.newDoubleList(origin.getX(), origin.getY(), origin.getZ()));
|
|
+ }
|
|
+ // Paper end
|
|
return nbt;
|
|
} catch (Throwable throwable) {
|
|
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
|
|
@@ -1947,6 +1976,20 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
|
}
|
|
// CraftBukkit end
|
|
|
|
+ // Paper start - Restore the entity's origin location
|
|
+ ListTag originTag = nbt.getList("Paper.Origin", 6);
|
|
+ if (!originTag.isEmpty()) {
|
|
+ UUID originWorld = null;
|
|
+ if (nbt.contains("Paper.OriginWorld")) {
|
|
+ originWorld = nbt.getUUID("Paper.OriginWorld");
|
|
+ } else if (this.level != null) {
|
|
+ originWorld = this.level.getWorld().getUID();
|
|
+ }
|
|
+ this.originWorld = originWorld;
|
|
+ origin = new org.bukkit.util.Vector(originTag.getDouble(0), originTag.getDouble(1), originTag.getDouble(2));
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
} catch (Throwable throwable) {
|
|
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
|
|
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
|
|
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
index 1cc849fadd1e1cf4ef1d1009c8e42febe92a6e28..0366303a986ae6da8e95ed3051610c432a790194 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
@@ -345,6 +345,14 @@ public class FallingBlockEntity extends Entity {
|
|
this.blockState = Blocks.SAND.defaultBlockState();
|
|
}
|
|
|
|
+ // Paper start - Try and load origin location from the old NBT tags for backwards compatibility
|
|
+ if (nbt.contains("SourceLoc_x")) {
|
|
+ int srcX = nbt.getInt("SourceLoc_x");
|
|
+ int srcY = nbt.getInt("SourceLoc_y");
|
|
+ int srcZ = nbt.getInt("SourceLoc_z");
|
|
+ this.setOrigin(new org.bukkit.Location(level.getWorld(), srcX, srcY, srcZ));
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
public void setHurtsEntities(float fallHurtAmount, int fallHurtMax) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
index 1f61dcc3d6f33f69fbebaaaee0554403c3e13adf..7135e22a2ee274eaef52804d60f15002176ff1db 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
@@ -120,6 +120,14 @@ public class PrimedTnt extends Entity {
|
|
@Override
|
|
protected void readAdditionalSaveData(CompoundTag nbt) {
|
|
this.setFuse(nbt.getShort("Fuse"));
|
|
+ // Paper start - Try and load origin location from the old NBT tags for backwards compatibility
|
|
+ if (nbt.contains("SourceLoc_x")) {
|
|
+ int srcX = nbt.getInt("SourceLoc_x");
|
|
+ int srcY = nbt.getInt("SourceLoc_y");
|
|
+ int srcZ = nbt.getInt("SourceLoc_z");
|
|
+ this.setOrigin(new org.bukkit.Location(level.getWorld(), srcX, srcY, srcZ));
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
@Nullable
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
index 4b7ed15279bbdd116d993f190094f80c888aed69..fdbcf4989f72e1604a2841f565adfeebf8d45622 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
@@ -1154,4 +1154,21 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|
return this.spigot;
|
|
}
|
|
// Spigot end
|
|
+
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public Location getOrigin() {
|
|
+ Vector originVector = this.getHandle().getOriginVector();
|
|
+ if (originVector == null) {
|
|
+ return null;
|
|
+ }
|
|
+ World world = this.getWorld();
|
|
+ if (this.getHandle().getOriginWorld() != null) {
|
|
+ world = org.bukkit.Bukkit.getWorld(this.getHandle().getOriginWorld());
|
|
+ }
|
|
+
|
|
+ //noinspection ConstantConditions
|
|
+ return originVector.toLocation(world);
|
|
+ }
|
|
+ // Paper end
|
|
}
|