package net.acomputerdog.BlazeLoader.api.entity;

import net.acomputerdog.BlazeLoader.main.BlazeLoader;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;

/**
 * Api for entity-related functions
 */
public class ApiEntity {

    /**
     * Registers a custom entity type.
     *
     * @param entityClass The entity class to register.
     * @param entityName  The name of the entity to register.
     * @param entityId    The entityId that is used to represent the entity over the network and in saves.
     */
    public static void registerEntityType(Class entityClass, String entityName, int entityId) {
        EntityList.addMapping(entityClass, entityName, entityId);
    }

    /**
     * Registers a spawn egg for a given entity type.
     *
     * @param entityId The entityID for this egg.
     * @param eggInfo  The EntityEggInfo to register.
     */
    public static void registerEntityEggInfo(int entityId, EntityList.EntityEggInfo eggInfo) {
        EntityList.entityEggs.put(entityId, eggInfo);
    }

    /**
     * Gets a free entity ID.
     *
     * @return return a free entity ID.
     */
    public static int getFreeEntityId() {
        while (EntityList.getClassFromID(BlazeLoader.currFreeEntityId) == null) {
            BlazeLoader.currFreeEntityId++;
        }
        int currId = BlazeLoader.currFreeEntityId;
        BlazeLoader.currFreeEntityId++;
        return currId;
    }

    /**
     * Gets the entity ID of the passed entity.
     * @param entity The entity to get the ID from
     * @return Return the ID of the entity
     */
    public static int getEntityID(Entity entity) {
        return EntityList.getEntityID(entity);
    }

    /**
     * Gets an entity's class from an entity ID
     * @param id The ID of the entity.
     * @return Return the class of the passed entity.
     */
    public static Class getEntityClassFromID(int id) {
        return EntityList.getClassFromID(id);
    }

    /**
     * Gets the type of an entity
     * @param entity The entity who's type to get
     * @return Return the type of the passed entity.
     */
    public static String getEntityType(Entity entity) {
        return EntityList.getEntityString(entity);
    }

    /**
     * Gets the type of an entity from it's ID
     * @param id The ID of the entity.
     * @return Return the type of the entity.
     */
    public static String getEntityTypeFromID(int id) {
        return EntityList.getStringFromID(id);
    }

    /**
     * Gets an entity ID from a String.
     * @param type The string identifying the entity.
     * @return Return then ID of the entity.
     */
    public static int getEntityIDFromType(String type){
        return EntityList.getIDFromString(type);
    }

    public static Entity createEntityByID(int id, World world) {
        return EntityList.createEntityByID(id, world);
    }

    public static Entity createEntityFromNBT(NBTTagCompound nbt, World world) {
        return EntityList.createEntityFromNBT(nbt, world);
    }

    public static Entity createEntityByName(String name, World world) {
        return EntityList.createEntityByName(name, world);
    }
}

@@ -2831,276 +2831,841 @@
     
-public static Entity createEntityByID(int id, World world) %7B%0A        return EntityList.createEntityByID(id, world);%0A    %7D%0A%0A    public static Entity createEntityFromNBT(NBTTagCompound nbt, World world) %7B%0A        return EntityList.createEntityFromNBT(nbt, world);%0A    %7D%0A
+/**%0A     * Creates an Entity from it's entity ID%0A     * @param id The ID of the entity%0A     * @param world The world to spawn in%0A     * @return Return the spawned entity.%0A     */%0A    public static Entity createEntityByID(int id, World world) %7B%0A        return EntityList.createEntityByID(id, world);%0A    %7D%0A%0A    /**%0A     * Creates an Entity from an NBT structure%0A     * @param nbt The NBT to load from%0A     * @param world The world to spawn in%0A     * @return Return the spawned entity.%0A     */%0A    public static Entity createEntityFromNBT(NBTTagCompound nbt, World world) %7B%0A        return EntityList.createEntityFromNBT(nbt, world);%0A    %7D%0A%0A    /**%0A     * Creates an Entity from the specified type%0A     * @param type The type of entity to spawn%0A     * @param world The world to spawn in%0A     * @return Return the spawned entity.%0A     */
 %0A   
@@ -3700,19 +3700,19 @@
 EntityBy
-Nam
+Typ
 e(String
@@ -3712,19 +3712,19 @@
 (String 
-nam
+typ
 e, World
@@ -3778,19 +3778,19 @@
 yByName(
-nam
+typ
 e, world

Expand ApiEntity