2021-06-11 14:02:28 +02:00
|
|
|
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
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/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
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
index 73608abb5a39749c326ce6fe1bf014422941b2d1..1315822ce37e5011880b24afb4fbe18cd1dfe80f 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
2024-01-24 13:07:40 +01:00
|
|
|
@@ -2149,6 +2149,15 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
2022-06-07 21:15:06 +02:00
|
|
|
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
|
2023-12-06 22:59:39 +01:00
|
|
|
entity.inWorld = true; // CraftBukkit - Mark entity as in world
|
2021-06-18 05:37:23 +02:00
|
|
|
entity.valid = true; // CraftBukkit
|
2024-01-24 11:45:17 +01:00
|
|
|
+ // Paper start - Entity origin API
|
2021-06-16 07:36:02 +02:00
|
|
|
+ if (entity.getOriginVector() == null) {
|
|
|
|
+ entity.setOrigin(entity.getBukkitEntity().getLocation());
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
2021-06-22 12:54:49 +02:00
|
|
|
+ // Default to current world if unknown, gross assumption but entities rarely change world
|
|
|
|
+ if (entity.getOriginWorld() == null) {
|
|
|
|
+ entity.setOrigin(entity.getOriginVector().toLocation(getWorld()));
|
|
|
|
+ }
|
2024-01-24 11:45:17 +01:00
|
|
|
+ // Paper end - Entity origin API
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
2021-06-18 05:37:23 +02:00
|
|
|
public void onTrackingEnd(Entity entity) {
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/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
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
index 0ecdc0d671f744d85072ca0d157ef37bb28bab9c..1212943cf64a716ceae187c76ff9be6241595ba2 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
2024-01-14 10:46:04 +01:00
|
|
|
@@ -319,7 +319,27 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
2021-12-03 22:28:15 +01:00
|
|
|
public long activatedTick = Integer.MIN_VALUE;
|
|
|
|
public void inactiveTick() { }
|
|
|
|
// Spigot end
|
2024-01-24 11:45:17 +01:00
|
|
|
+ // Paper start - Entity origin API
|
2021-06-16 07:36:02 +02:00
|
|
|
+ @javax.annotation.Nullable
|
|
|
|
+ private org.bukkit.util.Vector origin;
|
|
|
|
+ @javax.annotation.Nullable
|
|
|
|
+ private UUID originWorld;
|
2024-01-24 11:45:17 +01:00
|
|
|
|
2021-06-16 07:36:02 +02:00
|
|
|
+ public void setOrigin(@javax.annotation.Nonnull Location location) {
|
|
|
|
+ this.origin = location.toVector();
|
|
|
|
+ this.originWorld = location.getWorld().getUID();
|
|
|
|
+ }
|
2024-01-24 11:45:17 +01:00
|
|
|
+
|
2021-06-16 07:36:02 +02:00
|
|
|
+ @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;
|
|
|
|
+ }
|
2024-01-24 11:45:17 +01:00
|
|
|
+ // Paper end - Entity origin API
|
2021-12-03 22:28:15 +01:00
|
|
|
public float getBukkitYaw() {
|
|
|
|
return this.yRot;
|
|
|
|
}
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/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
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
@@ -2042,6 +2062,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
2023-12-05 20:39:26 +01:00
|
|
|
this.bukkitEntity.storeBukkitValues(nbttagcompound);
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2024-01-24 11:45:17 +01:00
|
|
|
+ // Paper start
|
2021-06-11 14:02:28 +02:00
|
|
|
+ if (this.origin != null) {
|
2021-06-22 12:54:49 +02:00
|
|
|
+ UUID originWorld = this.originWorld != null ? this.originWorld : this.level != null ? this.level.getWorld().getUID() : null;
|
|
|
|
+ if (originWorld != null) {
|
2023-12-05 20:39:26 +01:00
|
|
|
+ nbttagcompound.putUUID("Paper.OriginWorld", originWorld);
|
2021-06-22 12:54:49 +02:00
|
|
|
+ }
|
2023-12-05 20:39:26 +01:00
|
|
|
+ nbttagcompound.put("Paper.Origin", this.newDoubleList(origin.getX(), origin.getY(), origin.getZ()));
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2023-12-05 20:39:26 +01:00
|
|
|
return nbttagcompound;
|
2021-06-11 14:02:28 +02:00
|
|
|
} catch (Throwable throwable) {
|
|
|
|
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/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
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
@@ -2169,6 +2198,20 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2024-01-24 11:45:17 +01:00
|
|
|
+ // Paper start
|
2024-01-04 14:38:26 +01:00
|
|
|
+ ListTag originTag = nbt.getList("Paper.Origin", net.minecraft.nbt.Tag.TAG_DOUBLE);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ if (!originTag.isEmpty()) {
|
2021-06-21 11:04:18 +02:00
|
|
|
+ UUID originWorld = null;
|
2021-06-12 00:37:16 +02:00
|
|
|
+ if (nbt.contains("Paper.OriginWorld")) {
|
2021-06-16 07:36:02 +02:00
|
|
|
+ originWorld = nbt.getUUID("Paper.OriginWorld");
|
2021-06-21 11:04:18 +02:00
|
|
|
+ } else if (this.level != null) {
|
|
|
|
+ originWorld = this.level.getWorld().getUID();
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
2021-06-16 07:36:02 +02:00
|
|
|
+ this.originWorld = originWorld;
|
2021-06-17 19:11:00 +02:00
|
|
|
+ origin = new org.bukkit.util.Vector(originTag.getDouble(0), originTag.getDouble(1), originTag.getDouble(2));
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+ // 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/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
2023-12-31 00:45:24 +01:00
|
|
|
index e269812e6193492afc3f25612edafa1a58325fa3..49294a8d580d891f21d8d4cbae14ae477c01ff8d 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
Updated Upstream (Bukkit/CraftBukkit) (#10034)
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:
f29cb801 Separate checkstyle-suppressions file is not required
86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API
d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor
b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack
9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode()
994a6163 Attempt upgrade of resolver libraries
CraftBukkit Changes:
b3b43a6ad Add Checkstyle check for unused imports
13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names
3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API
2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor
1dbdbbed4 PR-1238: Remove unnecessary sign ticking
659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper
e37e29ce0 Increase outdated build delay
c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack
492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode()
e11fbb9d7 Upgrade MySQL driver
9f3a0bd2a Attempt upgrade of resolver libraries
60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion
Spigot Changes:
06d602e7 Rebuild patches
2023-12-17 03:09:28 +01:00
|
|
|
@@ -967,5 +967,20 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
2022-09-01 18:51:59 +02:00
|
|
|
|
|
|
|
return ret;
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Location getOrigin() {
|
2021-06-16 07:36:02 +02:00
|
|
|
+ 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);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
2022-09-01 18:51:59 +02:00
|
|
|
// Paper end
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|