Yatopia/patches/api/0023-EMC-SpawnEggMeta-setSpawnedEntity-API.patch

66 lines
2.3 KiB
Diff
Raw Normal View History

2020-06-16 16:46:05 +02:00
From 59d0f663adaf25f1e645fd361f76400690129d48 Mon Sep 17 00:00:00 2001
2020-02-26 20:12:29 +01:00
From: Aikar <aikar@aikar.co>
Date: Sat, 18 Aug 2018 21:09:39 -0400
Subject: [PATCH] EMC SpawnEggMeta#setSpawnedEntity API
lets you copy an entities data into a spawn egg.
Partial data is supported through a predicate, letting MC
follow normal spawn behavior in the summon phase.
---
.../bukkit/inventory/meta/SpawnEggMeta.java | 39 +++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java b/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java
2020-06-16 16:46:05 +02:00
index 9ae84de4..f6ee31cd 100644
2020-02-26 20:12:29 +01:00
--- a/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java
@@ -9,6 +9,45 @@ import org.jetbrains.annotations.NotNull;
*/
public interface SpawnEggMeta extends ItemMeta {
+ // Paper start
+
+ /**
+ * Copies the Entity as is into the spawn egg.
+ *
+ * All non positional data properties will be saved
+ * @param entity
+ */
+ default void setSpawnedEntity(org.bukkit.entity.Entity entity) {
+ setSpawnedEntity(entity, null);
+ }
+ /**
+ * Copies the Entity into the spawn egg, giving you
+ * control over which NBT Tags are to be saved.
+ *
+ * Note that while Mojang has made data properties more
+ * of a user facing detail, there is no guarantee that
+ * they will not change names between versions.
+ *
+ * If a key is filtered out, it will assume the default
+ * value upon spawn as a normal spawned entity of this type
+ * might receive. If one key is fitlered that has a strong
+ * relationship to another key, such as Villager Professions
+ * and Careers, you should filter them both/all to avoid buggy
+ * behavior in spawning the entity.
+ *
+ * Filtering by values is not supported.
+ *
+ * Certain keys such as "UUIDLeast", "UUIDMost", "Pos",
+ * "PortalCooldown", "Dimension"
+ *
+ * are default filtered.
+ *
+ * @param entity
+ * @param keyFilter
+ */
+ void setSpawnedEntity(org.bukkit.entity.Entity entity, java.util.function.Predicate<String> keyFilter);
+ // Paper end
+
/**
* Get the type of entity this egg will spawn.
*
--
2.25.1.windows.1