Java Code Examples for org.bukkit.entity.EntityType#fromId()

The following examples show how to use org.bukkit.entity.EntityType#fromId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NMSSpawnEggItemData.java    From SonarPet with GNU General Public License v3.0 5 votes vote down vote up
public static EntityType getSpawnEggEntityType(ItemMeta meta) {
    Preconditions.checkNotNull(meta, "Null meta");
    NBTTagCompound tag = getTagFromMeta(Material.MONSTER_EGG, meta);
    Preconditions.checkState(tag != null, "No nbt tag");
    Preconditions.checkState(tag.hasKeyOfType("EntityTag", 10), "No entity tag");
    NBTTagCompound entityTag = tag.getCompound("EntityTag");
    Preconditions.checkState(entityTag.hasKeyOfType("id", 8), "No internal name");
    String internalName = entityTag.getString("id");
    int id = EntityTypes.a(internalName);
    EntityType type = EntityType.fromId(id);
    if (type == null)
        throw new IllegalStateException("No entity found with internal name " + internalName + " and id " + id);
    return type;
}
 
Example 2
Source File: NMSSpawnEggItemData.java    From SonarPet with GNU General Public License v3.0 5 votes vote down vote up
public static EntityType getSpawnEggEntityType(ItemMeta meta) {
    Preconditions.checkNotNull(meta, "Null meta");
    NBTTagCompound tag = getTagFromMeta(Material.MONSTER_EGG, meta);
    Preconditions.checkState(tag != null, "No nbt tag");
    Preconditions.checkState(tag.hasKeyOfType("EntityTag", 10), "No entity tag");
    NBTTagCompound entityTag = tag.getCompound("EntityTag");
    Preconditions.checkState(entityTag.hasKeyOfType("id", 8), "No internal name");
    String internalName = entityTag.getString("id");
    int id = EntityTypes.a(internalName);
    EntityType type = EntityType.fromId(id);
    if (type == null)
        throw new IllegalStateException("No entity found with internal name " + internalName + " and id " + id);
    return type;
}
 
Example 3
Source File: NMSSpawnEggItemData.java    From SonarPet with GNU General Public License v3.0 5 votes vote down vote up
public static EntityType getSpawnEggEntityType(ItemMeta meta) {
    Preconditions.checkNotNull(meta, "Null meta");
    NBTTagCompound tag = getTagFromMeta(Material.MONSTER_EGG, meta);
    Preconditions.checkState(tag != null, "No nbt tag");
    Preconditions.checkState(tag.hasKeyOfType("EntityTag", 10), "No entity tag");
    NBTTagCompound entityTag = tag.getCompound("EntityTag");
    Preconditions.checkState(entityTag.hasKeyOfType("id", 8), "No internal name");
    String internalName = entityTag.getString("id");
    int id = EntityTypes.a(internalName);
    EntityType type = EntityType.fromId(id);
    if (type == null)
        throw new IllegalStateException("No entity found with internal name " + internalName + " and id " + id);
    return type;
}
 
Example 4
Source File: NMSSpawnEggItemData.java    From SonarPet with GNU General Public License v3.0 5 votes vote down vote up
public static EntityType getSpawnEggEntityType(ItemMeta meta) {
    Preconditions.checkNotNull(meta, "Null meta");
    NBTTagCompound tag = getTagFromMeta(Material.MONSTER_EGG, meta);
    Preconditions.checkState(tag != null, "No nbt tag");
    Preconditions.checkState(tag.hasKeyOfType("EntityTag", 10), "No entity tag");
    NBTTagCompound entityTag = tag.getCompound("EntityTag");
    Preconditions.checkState(entityTag.hasKeyOfType("id", 8), "No internal name");
    String internalName = entityTag.getString("id");
    int id = EntityTypes.b.a(EntityTypes.b.get(new MinecraftKey(internalName)));
    EntityType type = EntityType.fromId(id);
    if (type == null)
        throw new IllegalStateException("No entity found with internal name " + internalName + " and id " + id);
    return type;
}
 
Example 5
Source File: NMSSpawnEggItemData.java    From SonarPet with GNU General Public License v3.0 5 votes vote down vote up
public static EntityType getSpawnEggEntityType(ItemMeta meta) {
    Preconditions.checkNotNull(meta, "Null meta");
    NBTTagCompound tag = getTagFromMeta(Material.MONSTER_EGG, meta);
    Preconditions.checkState(tag != null, "No nbt tag");
    Preconditions.checkState(tag.hasKeyOfType("EntityTag", 10), "No entity tag");
    NBTTagCompound entityTag = tag.getCompound("EntityTag");
    Preconditions.checkState(entityTag.hasKeyOfType("id", 8), "No internal name");
    String internalName = entityTag.getString("id");
    int id = EntityTypes.b.a(EntityTypes.b.get(new MinecraftKey(internalName)));
    EntityType type = EntityType.fromId(id);
    if (type == null)
        throw new IllegalStateException("No entity found with internal name " + internalName + " and id " + id);
    return type;
}
 
Example 6
Source File: Craftbukkit17R4.java    From factions-top with MIT License 4 votes vote down vote up
@Override
public EntityType getSpawnerType(ItemStack item) {
    return EntityType.fromId((int) item.getData().getData());
}
 
Example 7
Source File: LegacyEntityId.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public static NetworkEntityType getTypeByIntId(int intId) {
	EntityType btype = EntityType.fromId(intId);
	return btype != null ? NetworkEntityType.getByBukkitType(btype) : NetworkEntityType.NONE;
}
 
Example 8
Source File: WrapperPlayServerSpawnEntityLiving.java    From HolographicDisplays with GNU General Public License v3.0 4 votes vote down vote up
/**
    * Retrieve the type of mob.
    * @return The current Type
   */
   @SuppressWarnings("deprecation")
public EntityType getType() {
       return EntityType.fromId(handle.getIntegers().read(1));
   }
 
Example 9
Source File: WrapperPlayServerSpawnEntityLiving.java    From PacketWrapper with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
    * Retrieve the type of mob.
    * @return The current Type
   */
   @SuppressWarnings("deprecation")
public EntityType getType() {
       return EntityType.fromId(handle.getIntegers().read(1));
   }
 
Example 10
Source File: SpawnEgg.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get the type of entity this egg will spawn.
 *
 * @return The entity type.
 * @deprecated This is now stored in {@link SpawnEggMeta}.
 */
@Deprecated
public EntityType getSpawnedType() {
    return EntityType.fromId(getData());
}