Java Code Examples for cpw.mods.fml.common.registry.EntityRegistry#addSpawn()

The following examples show how to use cpw.mods.fml.common.registry.EntityRegistry#addSpawn() . 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: CommonProxy.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
public void registerEntities() {
	if (EtFuturum.enableBanners)
		GameRegistry.registerTileEntity(TileEntityBanner.class, Utils.getUnlocalisedName("banner"));
	if (EtFuturum.enableArmourStand)
		ModEntityList.registerEntity(EntityArmourStand.class, "wooden_armorstand", 0, EtFuturum.instance, 64, 1, true);
	if (EtFuturum.enableEndermite)
		ModEntityList.registerEntity(EntityEndermite.class, "endermite", 1, EtFuturum.instance, 64, 1, true, 1447446, 7237230);
	if (EtFuturum.enableChorusFruit)
		GameRegistry.registerTileEntity(TileEntityEndRod.class, Utils.getUnlocalisedName("end_rod"));
	if (EtFuturum.enableTippedArrows)
		ModEntityList.registerEntity(EntityTippedArrow.class, "tipped_arrow", 2, EtFuturum.instance, 64, 20, true);
	if (EtFuturum.enableBrewingStands)
		GameRegistry.registerTileEntity(TileEntityNewBrewingStand.class, Utils.getUnlocalisedName("brewing_stand"));
	if (EtFuturum.enableColourfulBeacons)
		GameRegistry.registerTileEntity(TileEntityNewBeacon.class, Utils.getUnlocalisedName("beacon"));

	if (EtFuturum.enableRabbit) {
		ModEntityList.registerEntity(EntityRabbit.class, "rabbit", 3, EtFuturum.instance, 80, 3, true, 10051392, 7555121);

		List<BiomeGenBase> biomes = new LinkedList<BiomeGenBase>();
		label: for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray())
			if (biome != null)
				// Check if pigs can spawn on this biome
				for (Object obj : biome.getSpawnableList(EnumCreatureType.creature))
					if (obj instanceof SpawnListEntry) {
						SpawnListEntry entry = (SpawnListEntry) obj;
						if (entry.entityClass == EntityPig.class) {
							biomes.add(biome);
							continue label;
						}
					}
		EntityRegistry.addSpawn(EntityRabbit.class, 10, 3, 3, EnumCreatureType.creature, biomes.toArray(new BiomeGenBase[biomes.size()]));
	}

	if (EtFuturum.enableLingeringPotions) {
		ModEntityList.registerEntity(EntityLingeringPotion.class, "lingering_potion", 4, EtFuturum.instance, 64, 10, true);
		ModEntityList.registerEntity(EntityLingeringEffect.class, "lingering_effect", 5, EtFuturum.instance, 64, 1, true);
	}

	if (EtFuturum.enableVillagerZombies)
		ModEntityList.registerEntity(EntityZombieVillager.class, "villager_zombie", 6, EtFuturum.instance, 80, 3, true, 44975, 7969893);

	if (EtFuturum.enableDragonRespawn) {
		ModEntityList.registerEntity(EntityPlacedEndCrystal.class, "end_crystal", 7, EtFuturum.instance, 256, Integer.MAX_VALUE, false);
		ModEntityList.registerEntity(EntityRespawnedDragon.class, "ender_dragon", 8, EtFuturum.instance, 160, 3, true);
	}

	if (EtFuturum.enableShearableGolems)
		ModEntityList.registerEntity(EntityNewSnowGolem.class, "snow_golem", 9, EtFuturum.instance, 80, 3, true);
}
 
Example 2
Source File: MoCreatures.java    From mocreaturesdev with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Populates spawn lists with MoCreatures or MoCreatures plus vanilla and other custom mobs (if modifyVanillaSpawns is true)
 * if useCustomSpawner is false, it will populate the Forge/MC spawn lists
 */
public static void populateSpawns()
{
    if (proxy.debugLogging) log.info("Populating spawns...");

    MoCConfigCategory entities = proxy.MoCconfig.getCategory(proxy.CATEGORY_ENTITY_BIOME_SETTINGS);
    Map<String, MoCEntityData> entityList = proxy.mocEntityMap; // add mocreatures only
    if (proxy.modifyVanillaSpawns) // if we are modifying the vanilla spawns then use the complete entity list containing all entities
    {
        entityList = proxy.entityMap;
    }
    if (proxy.debugLogging) log.info("Scanning MoCProperties.cfg for entities...");
    for (Entry<String, MoCProperty> entityEntry : entities.entrySet())
    {
        if (proxy.debugLogging) log.info("Found entity " + entityEntry.getKey());
        if (proxy.entityMap.containsKey(entityEntry.getKey()));
        {
            if (proxy.debugLogging) log.info("Entity " + entityEntry.getKey() + " exists in entityMap, proceeding...");
            MoCProperty biomeGroups = entityEntry.getValue();
            if (proxy.debugLogging) log.info("Detected " + biomeGroups.valueList.size() + " Biome Groups for entity, verifying list...");

            for (int i = 0; i < biomeGroups.valueList.size(); i++)
            {
                if (proxy.debugLogging) log.info("Found Biome Group " + biomeGroups.valueList.get(i));
                if (proxy.biomeGroupMap.containsKey(biomeGroups.valueList.get(i))) // if valid biome group from MoCBiomeGroups.cfg continue
                {
                    if (proxy.debugLogging) log.info("Group is valid, scanning biomes...");
                    List biomeGroup = proxy.biomeGroupMap.get(biomeGroups.valueList.get(i)).getBiomeList();
                    List<BiomeGenBase> entitySpawnBiomes = new ArrayList<BiomeGenBase>();
                    MoCEntityData entityData = entityList.get(entityEntry.getKey());//entityClass.getValue();
                    for (int j = 0; j < biomeGroup.size(); j++)
                    {
                        if (proxy.debugLogging) log.info("Found biome " + biomeGroup.get(j));
                        if (proxy.biomeMap.get(biomeGroup.get(j)) != null)
                        {
                            entitySpawnBiomes.add(proxy.biomeMap.get(biomeGroup.get(j)).getBiome());
                            if (proxy.debugLogging) log.info("Added biome " + biomeGroup.get(j) + " for entity " + entityEntry.getKey());
                        }else
                        {
                            if (proxy.debugLogging) log.info("Skipping biome " + biomeGroup.get(j) + " for entity " + entityEntry.getKey() + " as that biome is not loaded");
                        }
                    }
                    if (entitySpawnBiomes.size() > 0 && entityData != null)
                    {
                        if (proxy.debugLogging) log.info("entitySpawnBiomes size = " + entitySpawnBiomes.size());
                        BiomeGenBase[] biomesToSpawn = new BiomeGenBase[entitySpawnBiomes.size()];
                        biomesToSpawn = entitySpawnBiomes.toArray(biomesToSpawn);
                        if (proxy.useCustomSpawner)
                        {
                        	if (entityData.frequency > 0 && entityData.minGroup > 0 && entityData.maxGroup > 0)
                        	{
                        		myCustomSpawner.AddCustomSpawn(entityData.getEntityClass(), entityData.frequency, entityData.minGroup, entityData.maxGroup, entityData.getType(), biomesToSpawn);
                                if (proxy.debugLogging) log.info("Added " + entityData.getEntityClass() + " to CustomSpawner spawn lists");
                        	}else
                        	{
                        		//myCustomSpawner.RemoveCustomSpawn(entityData.getEntityClass(), entityData.getType(), biomesToSpawn);
                        	}
                            
                            //otherwise the Forge spawnlist remains pouplated with duplicated entries on CMS
                            EntityRegistry.removeSpawn(entityData.getEntityClass(), entityData.getType(), biomesToSpawn); 
                            if (proxy.debugLogging) log.info("Removed " + entityData.getEntityClass() + " from Vanilla spawn lists");
                        }
                        else //use Forge Spawn method instead
                        {
                        	if (entityData.frequency > 0 && entityData.minGroup > 0 && entityData.maxGroup > 0)
                        	{
                        		EntityRegistry.addSpawn(entityData.getEntityClass(), entityData.frequency, entityData.minGroup, entityData.maxGroup, entityData.getType(), biomesToSpawn);
                                if (proxy.debugLogging) log.info("Added " + entityData.getEntityClass() + " to Vanilla spawn lists");
                        	}else
                        	{
                        	    if (proxy.debugLogging) log.info("Removed " + entityData.getEntityClass() + " from Vanilla spawn lists");
                        		EntityRegistry.removeSpawn(entityData.getEntityClass(), entityData.getType(), biomesToSpawn); 
                        	}
                            
                        }
                    }
                    
                }
            }
        }
    }
}