Paper/patches/api/0338-Add-Raw-Byte-Entity-Serialization.patch
Nassim Jahnke 928bcc8d3a
Updated Upstream (Bukkit/CraftBukkit) (#8430)
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:
09943450 Update SnakeYAML version
5515734f SPIGOT-7162: Incorrect description for Entity#getVehicle javadoc
6f82b381 PR-788: Add getHand() to all relevant events

CraftBukkit Changes:
aaf484f6f SPIGOT-7163: CraftMerchantRecipe doesn't copy demand and specialPrice from BukkitMerchantRecipe
5329dd6fd PR-1107: Add getHand() to all relevant events
93061706e SPIGOT-7045: Ocelots never spawn with babies with spawn reason OCELOT_BABY
2022-10-02 09:56:36 +02:00

63 lines
2.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mariell Hoversholm <proximyst@proximyst.com>
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 be8d5c172b0a300648f21e2163ccf0a9cd7915ee..4fcafddf3792b66c618f91e04d102f374de565a8 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -112,6 +112,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);
+
/**
* Return the translation key for the Material, so the client can translate it into the active
* locale when using a {@link net.kyori.adventure.text.TranslatableComponent}.
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
index 2eb98be7095495f0e99d46b92ccc16d19bbc411b..c15235b93f43746836eb4b7e136615fbc9308369 100644
--- a/src/main/java/org/bukkit/entity/Entity.java
+++ b/src/main/java/org/bukkit/entity/Entity.java
@@ -802,5 +802,32 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
* @return players in tracking range
*/
@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
}