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: 2c6b1f048 Revert "Remove itneract event from boat" (Fixes #5677) aae1c54a9 Add command line option to load extra plugin jars not in the plugins folder 322886c86 Avoid NPE due to PlayerBedFailEnterEvent d3c9a195c removed duplicate ProjectileHitEvent for fireball (#5671) 7989028a5 More Enchantment API (#5588) c0cb5c129 Adds methods for checking item repairability (#5651) 22399b07f Actually use extended/ambient in BeaconEffectEvent (#5647) 979135878 Add cause and cancel message to PlayerGameModeChangeEvent (#5638) 51e1e58d2 Fix Adventure support in UnknownCommandEvent (#5664) 45e19ffb0 [Auto] Updated Upstream (CraftBukkit) 151457628 Fix Counter#decrement recursive call (#5665) 21ac7dc98 [Auto] Updated Upstream (CraftBukkit) 18ad2c9dd Add environment variable (PAPER_DISABLE_SERVER_GUI) to disable server gui
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 d3c4da380e46db0cd7664b568781d03455447700..90e8c2d3f2592505d2fe96b038fae9c96d1d7911 100644
|
|
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
|
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
|
@@ -182,4 +182,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 b47e31d2b9b41b39b46892fe10bf36d82c5d8e1b..7fa5242bd44c9b19648d79fa8fecbb7ee125288e 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
|
|
}
|