Search in sources :

Example 1 with EntityRegistration

use of cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration in project MineFactoryReloaded by powercrystals.

the class TwilightForestEggHandler method getEgg.

@SuppressWarnings("unchecked")
@Override
public EntityEggInfo getEgg(ItemStack safariNet) {
    Class<? extends Entity> entityClass = (Class<? extends Entity>) EntityList.stringToClassMapping.get(safariNet.getTagCompound().getString("id"));
    if (entityClass == null) {
        return null;
    }
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(entityClass, true);
    if (er != null && er.getContainer() == TwilightForest.twilightForestContainer) {
        return (EntityEggInfo) TwilightForest.entityEggs.get(er.getModEntityId());
    }
    return null;
}
Also used : Entity(net.minecraft.entity.Entity) EntityEggInfo(net.minecraft.entity.EntityEggInfo) EntityRegistration(cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration)

Example 2 with EntityRegistration

use of cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration in project ArsMagica2 by Mithion.

the class CompendiumUnlockHandler method onEntityDeath.

/**
	 * This should handle all mobs and the Astral Barrier
	 *
	 * @param event
	 */
@SubscribeEvent
public void onEntityDeath(LivingDeathEvent event) {
    if (event.entityLiving.worldObj.isRemote && event.source.getSourceOfDamage() instanceof EntityPlayer) {
        if (event.entity instanceof EntityEnderman) {
            ArcaneCompendium.instance.unlockEntry("blockastralbarrier");
        } else {
            EntityRegistration reg = EntityRegistry.instance().lookupModSpawn(event.entityLiving.getClass(), true);
            if (reg != null && reg.getContainer().matches(AMCore.instance)) {
                String id = reg.getEntityName();
                ArcaneCompendium.instance.unlockEntry(id);
            }
        }
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityEnderman(net.minecraft.entity.monster.EntityEnderman) EntityRegistration(cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

EntityRegistration (cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Entity (net.minecraft.entity.Entity)1 EntityEggInfo (net.minecraft.entity.EntityEggInfo)1 EntityEnderman (net.minecraft.entity.monster.EntityEnderman)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1