Search in sources :

Example 1 with EntityEggInfo

use of net.minecraft.entity.EntityList.EntityEggInfo in project PneumaticCraft by MineMaarten.

the class EntityRegistrator method registerEntityEgg.

public static void registerEntityEgg(Class<? extends Entity> entity, int primaryColor, int secondaryColor) {
    int id = getUniqueEntityId();
    EntityList.IDtoClassMapping.put(id, entity);
    EntityList.entityEggs.put(id, new EntityEggInfo(id, primaryColor, secondaryColor));
}
Also used : EntityEggInfo(net.minecraft.entity.EntityList.EntityEggInfo)

Example 2 with EntityEggInfo

use of net.minecraft.entity.EntityList.EntityEggInfo in project ArsMagica2 by Mithion.

the class ItemCrystalPhylactery method getSpawnableEntities.

public void getSpawnableEntities(World world) {
    for (Object clazz : EntityList.classToStringMapping.keySet()) {
        if (EntityCreature.class.isAssignableFrom((Class) clazz)) {
            try {
                EntityCreature temp = (EntityCreature) ((Class) clazz).getConstructor(World.class).newInstance(world);
                if (EntityUtilities.isAIEnabled(temp) && !(temp instanceof IBossDisplayData)) {
                    int color = 0;
                    boolean found = false;
                    //look for entity egg
                    for (Object info : EntityList.entityEggs.values()) {
                        EntityEggInfo eei = (EntityEggInfo) info;
                        Class spawnClass = EntityList.getClassFromID(eei.spawnedID);
                        if (spawnClass == (Class) clazz) {
                            color = eei.primaryColor;
                            found = true;
                            break;
                        }
                    }
                    if (!found) {
                        //no spawn egg...pick random color?
                        color = world.rand.nextInt();
                    }
                    spawnableEntities.put((String) EntityList.classToStringMapping.get(clazz), color);
                }
            } catch (Throwable e) {
            //e.printStackTrace();
            }
        }
    }
}
Also used : EntityEggInfo(net.minecraft.entity.EntityList.EntityEggInfo) IBossDisplayData(net.minecraft.entity.boss.IBossDisplayData) EntityCreature(net.minecraft.entity.EntityCreature)

Example 3 with EntityEggInfo

use of net.minecraft.entity.EntityList.EntityEggInfo in project MinecraftForge by MinecraftForge.

the class EntityRegistry method registerEgg.

/**
     * Registers a spawn egg for the specified entity class.
     * The class must already be registered in the EntityList.classToStringMapping.
     * This can be done either by using the global ID system, or preferably the registerModEntity functions above.
     * Once registered mob eggs can be created by using minecraft:spawn_egg with NBT entry 'entity_name' with
     * value of the name this class is registered in the classToStringMapping with.
     *
     * @param name The entity ResourceLocation
     * @param primary Primary egg color
     * @param secondary Secondary egg color
     *
     */
public static void registerEgg(ResourceLocation name, int primary, int secondary) {
    EntityEntry entry = ForgeRegistries.ENTITIES.getValue(name);
    if (entry == null) {
        FMLLog.bigWarning("Attempted to registry a entity egg for entity (%s) that is not in the Entity Registry", name);
        return;
    }
    entry.setEgg(new EntityEggInfo(name, primary, secondary));
}
Also used : EntityEggInfo(net.minecraft.entity.EntityList.EntityEggInfo)

Aggregations

EntityEggInfo (net.minecraft.entity.EntityList.EntityEggInfo)3 EntityCreature (net.minecraft.entity.EntityCreature)1 IBossDisplayData (net.minecraft.entity.boss.IBossDisplayData)1