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: PaperMC/Paper@f75636b [ci skip] Update my name in author field (#6625) PaperMC/Paper@d2c2b7a Implement Translatable on villager Profession (#6542) PaperMC/Paper@9087993 Mark fish and axolotls from buckets as persistent (#6392) PaperMC/Paper@aad7d37 Fix axolotl/fish persistence PaperMC/Paper@6084ac3 Fix upstream nullability on entity equipment getters (#6519) PaperMC/Paper@655cd8f Fix upstreams fix for composters and variable hoppers (#6563) PaperMC/Paper@7ac51f9 Include slot when constructing the bukkit Attribute Modifiers (#6537) PaperMC/Paper@caa4780 Add more component name methods (#6578) PaperMC/Paper@9460497 Apply furnace cook speed multiplier through event (#6378) PaperMC/Paper@f4f5a76 Fix anvil inventory events (#6157) PaperMC/Paper@1707c10 fixes cancelling PlayerTradeEvent (#5612)
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 ef3011d74ce9acf02d0ee857033816854134ec0e..b2502aaab690b1414a1adffdf64e5a5456feb99c 100644
|
|
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
|
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
|
@@ -194,4 +194,28 @@ public interface UnsafeValues {
|
|
*/
|
|
int getProtocolVersion();
|
|
// 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 6fbfddf950e0db559fc804f27ba4a9761dcaf25c..892fc137c8c35dc111f739e4ebe66be42229c5d8 100644
|
|
--- a/src/main/java/org/bukkit/entity/Entity.java
|
|
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
|
@@ -808,5 +808,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
|
|
}
|