aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0323-Add-Raw-Byte-Entity-Serialization.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/api/0323-Add-Raw-Byte-Entity-Serialization.patch')
-rw-r--r--patches/api/0323-Add-Raw-Byte-Entity-Serialization.patch62
1 files changed, 62 insertions, 0 deletions
diff --git a/patches/api/0323-Add-Raw-Byte-Entity-Serialization.patch b/patches/api/0323-Add-Raw-Byte-Entity-Serialization.patch
new file mode 100644
index 0000000000..6c33be9317
--- /dev/null
+++ b/patches/api/0323-Add-Raw-Byte-Entity-Serialization.patch
@@ -0,0 +1,62 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Mariell Hoversholm <[email protected]>
+Date: Sun, 24 Oct 2021 16:19:26 -0400
+Subject: [PATCH] Add Raw Byte Entity Serialization
+
+
+diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
+index 434fde52986ba07d7209ff47483f74fe31e8ebe7..0c7204e390f44b649fc26cd46152abeb2ad2d670 100644
+--- a/src/main/java/org/bukkit/UnsafeValues.java
++++ b/src/main/java/org/bukkit/UnsafeValues.java
+@@ -156,6 +156,14 @@ public interface UnsafeValues {
+
+ ItemStack deserializeItem(byte[] data);
+
++ byte[] serializeEntity(org.bukkit.entity.Entity entity);
++
++ default org.bukkit.entity.Entity deserializeEntity(byte[] data, World world) {
++ return deserializeEntity(data, world, false);
++ }
++
++ org.bukkit.entity.Entity deserializeEntity(byte[] data, World world, boolean preserveUUID);
++
+ /**
+ * Creates and returns the next EntityId available.
+ * <p>
+diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
+index d68ccecaadcf7a906058e66a750f4cfce5dd7b3f..2e2c8d7d2e2c27e2f1264a267d589b2c790f366b 100644
+--- a/src/main/java/org/bukkit/entity/Entity.java
++++ b/src/main/java/org/bukkit/entity/Entity.java
+@@ -891,5 +891,32 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
+ */
+ @Deprecated
+ @NotNull Set<Player> getTrackedPlayers();
++
++ /**
++ * Spawns the entity in the world at the given {@link Location} with the default spawn reason.
++ * <p>
++ * This will not spawn the entity if the entity is already spawned or has previously been despawned.
++ * <p>
++ * Also, this method will fire the same events as a normal entity spawn.
++ *
++ * @param location The location to spawn the entity at.
++ * @return Whether the entity was successfully spawned.
++ */
++ public default boolean spawnAt(@NotNull Location location) {
++ return spawnAt(location, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
++ }
++
++ /**
++ * Spawns the entity in the world at the given {@link Location} with the reason given.
++ * <p>
++ * This will not spawn the entity if the entity is already spawned or has previously been despawned.
++ * <p>
++ * Also, this method will fire the same events as a normal entity spawn.
++ *
++ * @param location The location to spawn the entity at.
++ * @param reason The reason for the entity being spawned.
++ * @return Whether the entity was successfully spawned.
++ */
++ public boolean spawnAt(@NotNull Location location, @NotNull org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason);
+ // Paper end
+ }