diff options
author | Matthew <stteg@hotmail.com> | 2016-12-06 21:12:13 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2016-12-06 21:14:55 +1100 |
commit | 525ea1552b2e01d608cf10cf0b76be662862c188 (patch) | |
tree | caeddb49542ffb49bf071a0cdc8cfa62f458be14 | |
parent | 71d3a3c774a2b53458456c49cf6dd2796934ef2d (diff) | |
download | bukkit-525ea1552b2e01d608cf10cf0b76be662862c188.tar bukkit-525ea1552b2e01d608cf10cf0b76be662862c188.tar.gz bukkit-525ea1552b2e01d608cf10cf0b76be662862c188.tar.lz bukkit-525ea1552b2e01d608cf10cf0b76be662862c188.tar.xz bukkit-525ea1552b2e01d608cf10cf0b76be662862c188.zip |
SPIGOT-1592: Implement ItemMeta for Spawn Eggs
The Minecraft implementation of spawn eggs is able to construct an entity using all data that is present in the save format, however since the Bukkit API has no such way to construct an entity unattached to a world, and it appears creating such a way is a very challenging task, the decision was instead made to add this API now that 1.11 has entities which may not be represented by data values.
In the future it may be possible to implement a more expanded API cognate with this one.
-rw-r--r-- | src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java | 28 | ||||
-rw-r--r-- | src/main/java/org/bukkit/material/SpawnEgg.java | 8 |
2 files changed, 33 insertions, 3 deletions
diff --git a/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java b/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java new file mode 100644 index 00000000..b89802d1 --- /dev/null +++ b/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java @@ -0,0 +1,28 @@ +package org.bukkit.inventory.meta; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; + +/** + * Represents a {@link Material#MONSTER_EGG} and it's spawned type. + */ +public interface SpawnEggMeta extends ItemMeta { + + /** + * Get the type of entity this egg will spawn. + * + * @return The entity type. May be null for implementation specific default. + */ + EntityType getSpawnedType(); + + /** + * Set the type of entity this egg will spawn. + * + * @param type The entity type. May be null for implementation specific + * default. + */ + void setSpawnedType(EntityType type); + + @Override + SpawnEggMeta clone(); +} diff --git a/src/main/java/org/bukkit/material/SpawnEgg.java b/src/main/java/org/bukkit/material/SpawnEgg.java index 596d08ae..40be534a 100644 --- a/src/main/java/org/bukkit/material/SpawnEgg.java +++ b/src/main/java/org/bukkit/material/SpawnEgg.java @@ -2,11 +2,13 @@ package org.bukkit.material; import org.bukkit.Material; import org.bukkit.entity.EntityType; -import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.SpawnEggMeta; /** * Represents a spawn egg that can be used to spawn mobs + * @deprecated use {@link SpawnEggMeta} */ +@Deprecated public class SpawnEgg extends MaterialData { public SpawnEgg() { @@ -41,7 +43,7 @@ public class SpawnEgg extends MaterialData { * Get the type of entity this egg will spawn. * * @return The entity type. - * @deprecated This is now stored in {@link ItemMeta}. See SPIGOT-1592. + * @deprecated This is now stored in {@link SpawnEggMeta}. */ @Deprecated public EntityType getSpawnedType() { @@ -52,7 +54,7 @@ public class SpawnEgg extends MaterialData { * Set the type of entity this egg will spawn. * * @param type The entity type. - * @deprecated This is now stored in {@link ItemMeta}. See SPIGOT-1592. + * @deprecated This is now stored in {@link SpawnEggMeta}. */ @Deprecated public void setSpawnedType(EntityType type) { |