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.

By: Matthew <stteg@hotmail.com>
This commit is contained in:
Bukkit/Spigot 2016-12-06 21:12:13 +11:00
parent 8c5665d841
commit ef84e6b90f
2 changed files with 33 additions and 3 deletions

View File

@ -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();
}

View File

@ -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) {