001    package org.bukkit.material;
002    
003    import org.bukkit.Material;
004    import org.bukkit.entity.EntityType;
005    
006    /**
007     * Represents a spawn egg that can be used to spawn mobs
008     */
009    public class SpawnEgg extends MaterialData {
010    
011        public SpawnEgg() {
012            super(Material.MONSTER_EGG);
013        }
014    
015        /**
016         *
017         * @deprecated Magic value
018         */
019        @Deprecated
020        public SpawnEgg(int type, byte data){
021            super(type, data);
022        }
023    
024        /**
025         *
026         * @deprecated Magic value
027         */
028        @Deprecated
029        public SpawnEgg(byte data) {
030            super(Material.MONSTER_EGG, data);
031        }
032    
033        public SpawnEgg(EntityType type) {
034            this();
035            setSpawnedType(type);
036        }
037    
038        /**
039         * Get the type of entity this egg will spawn.
040         *
041         * @return The entity type.
042         */
043        public EntityType getSpawnedType() {
044            return EntityType.fromId(getData());
045        }
046    
047        /**
048         * Set the type of entity this egg will spawn.
049         *
050         * @param type The entity type.
051         */
052        public void setSpawnedType(EntityType type) {
053            setData((byte) type.getTypeId());
054        }
055    
056        @Override
057        public String toString() {
058            return "SPAWN EGG{" + getSpawnedType() + "}";
059        }
060    
061        @Override
062        public SpawnEgg clone() {
063            return (SpawnEgg) super.clone();
064        }
065    }