mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 8c74d3126 Updated Upstream (Bukkit) (#5359) fd3c66a91 bug #5362 - correctly pass "render type" when registering a new scoreboard objective 39c487b37 Add per-command perms for paper command cdbf2578c Add Item Rarity API (#5352) d80e43647 [CI-SKIP] Removal from the MIT list (#5345) Tuinity Changes: aea6b8347 Merge dev/playerchunkloading 722c7ca8a Use hash table for maintaing changed block set 98ae59d85 Custom table implementation for blockstate state lookups 8b8704fb6 Oprimise map impl for tracked players ea71d6ba4 Optimise snow & ice in chunk ticking 9871d4ce5 Remove chunk lookup & lambda allocation from counting mobs 5a4a35f3e Add patreon 7d93d9618 Refactor data management for region manager c3035219f Change license from MIT to LGPLv3 Airplane Changes: 580f380b6 Updated Upstream (Tuinity) 82253fd36 Early return optimization for target finding 9572643bb Cache entityhuman display name 5df98254f Remove iterators from inventory contains 18d2be193 Merge pull request #14 from violetwtf/patch-1 f716d4c33 Merge pull request #13 from violetwtf/master 128cbe519 Reduce entity chunk ticking checks from 3 to 1 03ac0933b Skip copying unloading tile entities 97dd027b5 Smaller pool size for tracking 9e9f57be4 Only set up Flare if token is available
81 lines
3.4 KiB
Diff
81 lines
3.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Mariell Hoversholm <proximyst@proximyst.com>
|
|
Date: Sat, 9 Jan 2021 21:21:27 +0100
|
|
Subject: [PATCH] Add unsafe Entity serialization API
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
|
index 85f77a58bf6c21da815b6652c7b50d578951a14c..59a91250d80e6f67a32cb4c7a216f1389338ddbf 100644
|
|
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
|
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
|
@@ -152,4 +152,28 @@ public interface UnsafeValues {
|
|
*/
|
|
public io.papermc.paper.inventory.ItemRarity getItemStackRarity(ItemStack itemStack);
|
|
// Paper end
|
|
+
|
|
+ // Purpur start
|
|
+
|
|
+ /**
|
|
+ * Serialize entity to byte array
|
|
+ *
|
|
+ * @param entity entity to serialize
|
|
+ * @return serialized entity
|
|
+ */
|
|
+ byte[] serializeEntity(org.bukkit.entity.Entity entity);
|
|
+
|
|
+ /**
|
|
+ * Deserialize an entity from byte array
|
|
+ * <p>
|
|
+ * The entity is not automatically spawned in the world. You will have to spawn
|
|
+ * the entity yourself with {@link org.bukkit.entity.Entity#spawnAt(Location)} or
|
|
+ * {@link org.bukkit.entity.Entity#spawnAt(Location, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason)}
|
|
+ *
|
|
+ * @param data serialized entity
|
|
+ * @param world world entity belongs in
|
|
+ * @return deserialized entity
|
|
+ */
|
|
+ org.bukkit.entity.Entity deserializeEntity(byte[] data, org.bukkit.World world);
|
|
+ // Purpur end
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
|
index c51d545e137eec2017c9f2ff944db70f2fdffdfc..1e25f387e053b648477a3e9dace1a6c95e7f8cba 100644
|
|
--- a/src/main/java/org/bukkit/entity/Entity.java
|
|
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
|
@@ -751,5 +751,24 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
|
* @return True if ridable in water
|
|
*/
|
|
boolean isRidableInWater();
|
|
+
|
|
+ /**
|
|
+ * Spawn this entity in the world at the given {@link Location} with the default spawn reason.
|
|
+ *
|
|
+ * @param location The location at which to spawn the entity.
|
|
+ * @return Whether the entity was successfully spawned.
|
|
+ */
|
|
+ default boolean spawnAt(@NotNull Location location) {
|
|
+ return spawnAt(location, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Spawn this entity in the world at the given {@link Location} with the reason given.
|
|
+ *
|
|
+ * @param location The location at which to spawn the entity.
|
|
+ * @param spawnReason The reason for which the entity was spawned.
|
|
+ * @return Whether the entity was successfully spawned.
|
|
+ */
|
|
+ boolean spawnAt(@NotNull Location location, @NotNull org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason);
|
|
// Purpur end
|
|
}
|