resonant-induction/archive/java/resonantinduction/old/core/misc/EnumBird.java
2014-01-11 17:44:07 +08:00

106 lines
2.3 KiB
Java

package resonantinduction.old.core.misc;
import java.awt.Color;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import resonantinduction.old.transport.ResonantInductionTransport;
import cpw.mods.fml.common.registry.EntityRegistry;
/**
* Enum of different birds that can be spawned by an egg or in the world threw normal spawning
*
* @author DarkGuardsman
*/
public enum EnumBird
{
VANILLA_CHICKEN("", new SpawnEntity()
{
@Override
public void register()
{
// Vanilla chicken is already registered
}
@Override
public Entity getNew(World world)
{
return new EntityChicken(world);
}
}), TURKEY("Turkey", new SpawnEntity()
{
@Override
public void register()
{
EntityRegistry.registerGlobalEntityID(EntityTurkey.class, "FTTurkey", EntityRegistry.findGlobalUniqueEntityId(), 5651507, Color.red.getRGB());
EntityRegistry.registerModEntity(EntityTurkey.class, "FTTurkey", ResonantInductionTransport.entitiesIds++, ResonantInductionTransport.instance, 64, 1, true);
EntityRegistry.addSpawn(EntityTurkey.class, 3, 1, 10, EnumCreatureType.creature, BiomeGenBase.forest, BiomeGenBase.river);
}
@Override
public Entity getNew(World world)
{
return new EntityTurkey(world);
}
});
private SpawnEntity entity;
private String name;
private EnumBird(String name, SpawnEntity entity)
{
this.entity = entity;
this.name = name;
}
public Entity getNewEntity(World world)
{
return this.entity.getNew(world);
}
public void register()
{
this.entity.register();
}
public static Entity getNewEntity(World world, int id)
{
if (get(id) != null)
{
return get(id).getNewEntity(world);
}
return null;
}
public static EnumBird get(int id)
{
if (id >= 0 && id < EnumBird.values().length)
{
return EnumBird.values()[id];
}
return null;
}
public String getName()
{
return this.name;
}
/**
* Quick interface to allow each enum to define how the entity is created without using
* reflection
*/
public static interface SpawnEntity
{
/** Anything that needs registered including spawning and event calls */
public void register();
/** Return a new entity for this enum instance */
public Entity getNew(World world);
}
}