Java 类net.minecraftforge.fml.common.registry.EntityEntry 实例源码

项目:enderutilities    文件:BlackLists.java   
public static void registerTeleportBlacklist(String[] blacklist)
{
    TELEPORT_BLACKLIST_CLASSES.clear();

    for (String name : blacklist)
    {
        EntityEntry entry = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(name));

        if (entry != null && entry.getEntityClass() != null)
        {
            TELEPORT_BLACKLIST_CLASSES.add(entry.getEntityClass());
        }
        else
        {
            EnderUtilities.logger.warn("Unknown Entity type '{}' on the teleport blacklist", name);
        }
    }
}
项目:ProgressiveDifficulty    文件:Region.java   
private static String[] generateDefaultSpawnCosts(){
    List<String> lines = Lists.newArrayList();
    for(EntityEntry entry : ForgeRegistries.ENTITIES.getValues()){
        if(EntityLiving.class.isAssignableFrom(entry.getEntityClass())) {
            lines.add(entry.getName()+":0");
        }
    }
    return lines.toArray(new String[lines.size()]);
}
项目:ProgressiveDifficulty    文件:ServerCommand.java   
private String[] getMobList(){
    List<String> lines = Lists.newArrayList();
    for(EntityEntry entry : ForgeRegistries.ENTITIES.getValues()){
        if(EntityLiving.class.isAssignableFrom(entry.getEntityClass())) {
            lines.add(entry.getName());
        }
    }
    return lines.toArray(new String[lines.size()]);
}
项目:Waddles    文件:PenguinRegistry.java   
private static EntityEntry createEntity(Class<? extends Entity> entityClass, String name, int eggPrimary, int eggSecondary) {
    ResourceLocation location = new ResourceLocation(Reference.MOD_ID, name);
    EntityEntry entry = new EntityEntry(entityClass, location.toString());
    entry.setRegistryName(location);
    entry.setEgg(new EntityList.EntityEggInfo(location, eggPrimary, eggSecondary));
    entities.add(entry);
    return entry;
}
项目:Waddles    文件:PenguinRegistry.java   
@SubscribeEvent
public static void registerPenguins(RegistryEvent.Register<EntityEntry> event) {
    int id = 0;
    for (EntityEntry entry : entities) {
        event.getRegistry().register(entry);
        id++;
        EntityRegistry.registerModEntity(entry.getRegistryName(), entry.getEntityClass(), entry.getName(), id, Waddles.instance, 64, 1, true, entry.getEgg().primaryColor, entry.getEgg().secondaryColor);
    }
}
项目:Waddles    文件:PenguinRegistry.java   
public static void addPenguinSpawn(Class<? extends EntityAgeable> penguinClass, EntityEntry penguinEntry, int defaultWeight, int defaultMin, int defaultMax, Biome... biomes) {
    String subCategoryNames = ConfigurationHandler.CATEGORY_PENGUIN_SPAWNS + Configuration.CATEGORY_SPLITTER + penguinEntry.getRegistryName().getResourcePath();
    int weight = ConfigurationHandler.config.get(subCategoryNames, "Weight", defaultWeight).getInt();
    int min = ConfigurationHandler.config.get(subCategoryNames, "Min", defaultMin).getInt();
    int max = ConfigurationHandler.config.get(subCategoryNames, "Max", defaultMax).getInt();

    ConfigurationHandler.config.save();

    if (weight != 0) {
        EntityRegistry.addSpawn(penguinClass, weight, min, max, EnumCreatureType.CREATURE, biomes);
    }
}
项目:malmo    文件:TextureHelper.java   
public static void setMobColours(Map<String, Integer> mobColours)
{
    if (mobColours == null || mobColours.isEmpty())
        idealMobColours = null;
    else
    {
        idealMobColours = new HashMap<String, Integer>();
        // Convert the names from our XML entity type into recognisable entity names:
        String id = null;
        for (String oldname : mobColours.keySet())
        {
            for (EntityEntry ent : net.minecraftforge.fml.common.registry.ForgeRegistries.ENTITIES)
            {
               if (ent.getName().equals(oldname))
               {
                   id = ent.getRegistryName().toString();
                   break;
               }
            }
            if (id != null)
            {
                idealMobColours.put(id, mobColours.get(oldname));
            }
        }
    }
    texturesToColours.clear();
}
项目:InfinityLib    文件:EntityRegistryEntry.java   
@SuppressWarnings("unchecked")
public void register(InfinityMod mod, IForgeRegistry<EntityEntry> registry) {
    ResourceLocation registryName = new ResourceLocation(mod.getModId(), this.getName());
    if(hasEgg) {
        this.setEgg(new EntityList.EntityEggInfo(registryName, primaryColor, secondaryColor));
    }
    if(doSpawn && EntityLiving.class.isAssignableFrom(this.getEntityClass())) {
        EntityRegistry.addSpawn((Class<? extends EntityLiving>) this.getEntityClass(), weight, min, max, type, biomes);
    }
    InfinityLib.proxy.register(mod, registry, this, this.getName());
    this.callback.run();
}
项目:InfinityLib    文件:ClientProxy.java   
@Override
public void registerEntities(InfinityMod mod, IForgeRegistry<EntityEntry> registry) {
    ReflectionHelper.forEachIn(mod.getModEntityRegistry(), EntityRegistryEntry.class, (EntityRegistryEntry entry) -> {
        if(entry.isEnabled()) {
            entry.registerClient(mod, registry);
        }
    });
}
项目:InfinityLib    文件:IProxy.java   
default void registerEntities(InfinityMod mod, IForgeRegistry<EntityEntry> registry) {
    ReflectionHelper.forEachIn(mod.getModEntityRegistry(), EntityRegistryEntry.class,
            (EntityRegistryEntry entry) -> {
                if (entry.isEnabled()) {
                    entry.register(mod, registry);
                }
            });
}
项目:Bookshelf    文件:AutoRegistry.java   
@SubscribeEvent
public void registerEntitys (RegistryEvent.Register<EntityEntry> event) {

    for (final EntityEntryBuilder<? extends Entity> entry : this.helper.getEntities()) {

        event.getRegistry().register(entry.build());
    }
}
项目:WearableBackpacks    文件:BackpackRegistry.java   
public Class<? extends EntityLivingBase> getEntityClass() {
    return _entityClassLookupCache.computeIfAbsent(entityID, id ->
        Optional.ofNullable(ForgeRegistries.ENTITIES.getValue(new ResourceLocation(id)))
            .map(EntityEntry::getEntityClass)
            .filter(EntityLivingBase.class::isAssignableFrom)
            .map(c -> c.asSubclass(EntityLivingBase.class))
        ).orElse(null);
}
项目:WearableBackpacks    文件:EntryListEntities.java   
@Override
public void setValue(BackpackEntityEntry value) {
    _value = value;

    Optional<EntityEntry> entry = getEntityEntry(value.entityID);
    _knownEntity      = entry.isPresent();
    Severity severity = Status.getSeverity(getStatus());
    boolean isFine    = (severity == Severity.FINE);

    int numEntries = value.getEntries().size();
    String entriesTextKey = "config." + WearableBackpacks.MOD_ID + ".entity.entry";
    // First we try to translate "[...].entity.entry.<num>".
    String entriesText = I18n.format(entriesTextKey + "." + numEntries);
    if (entriesText.equals(entriesTextKey + "." + numEntries))
        // If not found, use "[...].entity.entry" instead.
        entriesText = I18n.format(entriesTextKey, numEntries);
    // ... I miss C#'s ?? operator :(

    buttonMove.setEnabled(!value.isDefault);
    buttonRemove.setEnabled(!value.isDefault);

    labelName.setText(getEntityEntryName(entry, value.entityID));
    labelName.setColor(value.isDefault ? GuiUtils.getColorCode('8', true)
                     : isFine          ? GuiUtils.getColorCode('7', true)
                                       : severity.foregroundColor);

    buttonEdit.setText(entriesText);
    if (!_knownEntity) buttonEdit.setTextColor(Severity.WARN.foregroundColor);
    else buttonEdit.unsetTextColor();
}
项目:Ores-and-Tools    文件:setEntites.java   
public static void register(IForgeRegistry<EntityEntry> event)
{
    ModelResourceLocation res0 = new ModelResourceLocation(EntityRock.GetRegistryName(), "entity");
    EntityEntry entry0 = EntityEntryBuilder.create().entity(EntityRock.class).id(res0, 0).name(EntityRock.GetRegistryName()).tracker(15, 80, true).build();
    ModelResourceLocation res1 = new ModelResourceLocation(EntityGrenade.GetRegistryName(), "entity");
    EntityEntry entry1 = EntityEntryBuilder.create().entity(EntityGrenade.class).id(res1, 1).name(EntityGrenade.GetRegistryName()).tracker(15, 80, true).build();
    ModelResourceLocation res2 = new ModelResourceLocation(EntityDynamite.GetRegistryName(), "entity");
    EntityEntry entry2 = EntityEntryBuilder.create().entity(EntityDynamite.class).id(res2, 2).name(EntityDynamite.GetRegistryName()).tracker(15, 80, true).build();
    event.registerAll(entry0, entry1, entry2);
}
项目:EnderZoo    文件:RegistryHandler.java   
@SubscribeEvent
public void onEntityRegister(Register<EntityEntry> e) {
    for (MobInfo mob : MobInfo.values()) {
        EntityEntry entry = new EntityEntry(mob.getClz(), mob.getName());
        ResourceLocation name = new ResourceLocation(EnderZoo.MODID, mob.getName());
        entry.setRegistryName(name);
        entry.setEgg(new EntityEggInfo(name, mob.getEggBackgroundColor(), mob.getEggForegroundColor()));
        e.getRegistry().register(entry);
        registerEntity(mob);
      }
}
项目:Etheric    文件:RegistryManager.java   
@SubscribeEvent
public static void registerEntities(RegistryEvent.Register<EntityEntry> event) {
    int id = 0;

    EntityRegistry.registerModEntity(new ResourceLocation(Etheric.MODID, "lesser_celestial"), EntityLesserCelestial.class, "lesser_celestial", id++, Etheric.MODID, 96, 1, true, 16777215, 13158600);
}
项目:malmo    文件:BlockDrawingHelper.java   
/** Spawn a single entity at the specified position.
 * @param e the actual entity to be spawned.
 * @param w the world in which to spawn the entity.
 * @throws Exception
 */
private void DrawPrimitive( DrawEntity e, World w ) throws Exception
{
    String oldEntityName = e.getType().getValue();
    String id = null;
    for (EntityEntry ent : net.minecraftforge.fml.common.registry.ForgeRegistries.ENTITIES)
    {
       if (ent.getName().equals(oldEntityName))
       {
           id = ent.getRegistryName().toString();
           break;
       }
    }
    if (id == null)
        return;

    NBTTagCompound nbttagcompound = new NBTTagCompound();
    nbttagcompound.setString("id", id);
    nbttagcompound.setBoolean("PersistenceRequired", true); // Don't let this entity despawn
    Entity entity;
    try
    {
        entity = EntityList.createEntityFromNBT(nbttagcompound, w);
        if (entity != null)
        {
            positionEntity(entity, e.getX().doubleValue(), e.getY().doubleValue(), e.getZ().doubleValue(), e.getYaw().floatValue(), e.getPitch().floatValue());
            entity.setVelocity(e.getXVel().doubleValue(), e.getYVel().doubleValue(), e.getZVel().doubleValue());
            // Set all the yaw values imaginable:
            if (entity instanceof EntityLivingBase)
            {
                ((EntityLivingBase)entity).rotationYaw = e.getYaw().floatValue();
                ((EntityLivingBase)entity).prevRotationYaw = e.getYaw().floatValue();
                ((EntityLivingBase)entity).prevRotationYawHead = e.getYaw().floatValue();
                ((EntityLivingBase)entity).rotationYawHead = e.getYaw().floatValue();
                ((EntityLivingBase)entity).prevRenderYawOffset = e.getYaw().floatValue();
                ((EntityLivingBase)entity).renderYawOffset = e.getYaw().floatValue();
            }
            w.getBlockState(entity.getPosition());  // Force-load the chunk if necessary, to ensure spawnEntity will work.
            if (!w.spawnEntity(entity))
            {
                System.out.println("WARNING: Failed to spawn entity! Chunk not loaded?");
            }
        }
    }
    catch (RuntimeException runtimeexception)
    {
        // Cannot summon this entity.
        throw new Exception("Couldn't create entity type: " + e.getType().getValue());
    }
}
项目:wolfarmor    文件:RegistrationEventHandler.java   
@Deprecated
@SubscribeEvent
public void registerEntities(RegistryEvent.Register<EntityEntry> event) {
    event.getRegistry().register(EntityEntries.ENTITY_WOLF_ARMORED);
}
项目:InfinityLib    文件:EntityRegistryEntry.java   
@SideOnly(Side.CLIENT)
public void registerClient(InfinityMod mod, IForgeRegistry<EntityEntry> registry) {
    this.register(mod, registry);
    RenderingRegistry.registerEntityRenderingHandler(this.getEntityClass(), renderFactory);
}
项目:InfinityLib    文件:InfinityMod.java   
@SubscribeEvent
public final void registerEntities(RegistryEvent.Register<EntityEntry> event) {
    InfinityLib.proxy.registerEntities(this, event.getRegistry());
}
项目:morecommands    文件:EntityUtils.java   
/**
 * Returns the registered entity entry for a entity class
 */
public static EntityEntry getEntry(Class<? extends Entity> cls) {
    return EntityRegistry.getEntry(cls);
}
项目:morecommands    文件:EntityUtils.java   
/**
 * @return The entity name from its id
 */
public static ResourceLocation getEntityName(int id) {
    EntityEntry entry = ((ForgeRegistry<EntityEntry>) ForgeRegistries.ENTITIES).getValue(id);
    return entry == null ? null : entry.getRegistryName();
}
项目:WearableBackpacks    文件:EntryListEntities.java   
public static Optional<EntityEntry> getEntityEntry(String entityID) {
    return Optional.ofNullable(ForgeRegistries.ENTITIES.getValue(new ResourceLocation(entityID)))
        .filter(entry -> EntityLivingBase.class.isAssignableFrom(entry.getEntityClass()));
}
项目:WearableBackpacks    文件:EntryListEntities.java   
public static String getEntityEntryName(Optional<EntityEntry> entry, String entityID)
{ return entry.map(EntityEntry::getName).map(s -> "[" + s + "]").orElse("\"" + entityID + "\""); }
项目:Ores-and-Tools    文件:Events.java   
@SubscribeEvent
public static void registerEntities(RegistryEvent.Register<EntityEntry> event)
{
    setEntites.register(event.getRegistry());
}
项目:EnderIO    文件:BlockWeatherObelisk.java   
@SubscribeEvent
public void onEntityRegister(RegistryEvent.Register<EntityEntry> event) {
  EntityRegistry.registerModEntity(new ResourceLocation(EnderIO.DOMAIN, "weather_rocket"), EntityWeatherRocket.class, "weather_rocket", 33, EnderIO.MODID, 64,
      3, false);
}
项目:Etheric    文件:RegistryManager.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void registerEntityRenderers(RegistryEvent.Register<EntityEntry> event) {

    RenderingRegistry.registerEntityRenderingHandler(EntityLesserCelestial.class, new RenderLesserCelestial.Factory());

}