net.minecraftforge.fml.common.registry.EntityEntry Java Examples

The following examples show how to use net.minecraftforge.fml.common.registry.EntityEntry. 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: BlackLists.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #2
Source File: TransIconHerobrineButWithBetterPantsSubMod.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void registerEntities(IForgeRegistry<EntityEntry> reg) {
    reg.register(EntityEntryBuilder.create()
            .entity(TransIconHerobrineButWithBetterPantsEntity.class)
            .factory(TransIconHerobrineButWithBetterPantsEntity::new)
            .name(CommunityGlobals.MOD_ID + ".trans_icon_herobrine_but_with_better_pants")
            .id(new ResourceLocation(CommunityGlobals.MOD_ID, "trans_icon_herobrine_but_with_better_pants"), CommunityGlobals.entity_id++)
            .tracker(128, 3, true)
            .spawn(EnumCreatureType.CREATURE, 3, 0, 1, Biome.REGISTRY)
            .egg(0xAA7D66, 0x32394D)
            .build()
    );

    reg.register(EntityEntryBuilder.create()
            .entity(NotchButWithWorsererPantsEntity.class)
            .factory(NotchButWithWorsererPantsEntity::new)
            .name(CommunityGlobals.MOD_ID + ".notch_but_with_worserer_pants")
            .id(new ResourceLocation(CommunityGlobals.MOD_ID, "notch_but_with_worserer_pants"), CommunityGlobals.entity_id++)
            .tracker(80, 3, true)
            .spawn(EnumCreatureType.CREATURE, 3, 2, 3, Biome.REGISTRY)
            .egg(0xAAAAAA, 0xAAAAAA)
            .build()
    );
}
 
Example #3
Source File: RegisterEvents.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
/**
 * This method will be called by Forge when it is time for the mod to register its entity
 * entries.
 */
@SubscribeEvent
public static void onRegisterEntitiesEvent(
    @Nonnull final RegistryEvent.Register<EntityEntry> event) {
    final ResourceLocation physicsWrapperEntity = new ResourceLocation(ValkyrienSkiesMod.MOD_ID,
        "PhysWrapper");
    final ResourceLocation entityMountable = new ResourceLocation(ValkyrienSkiesMod.MOD_ID,
        "entity_mountable");
    final ResourceLocation entityMountableChair = new ResourceLocation(ValkyrienSkiesMod.MOD_ID,
        "entity_mountable_chair");
    // Used to ensure no duplicates of entity network id's
    int entityId = 0;
    event.getRegistry()
        .registerAll(EntityEntryBuilder.create()
                .entity(PhysicsWrapperEntity.class)
                .id(physicsWrapperEntity, entityId++)
                .name(physicsWrapperEntity.getPath())
                .tracker(ValkyrienSkiesMod.VS_ENTITY_LOAD_DISTANCE, 1, false)
                .build(),
            EntityEntryBuilder.create()
                .entity(EntityMountable.class)
                .id(entityMountable, entityId++)
                .name(entityMountable.getPath())
                .tracker(ValkyrienSkiesMod.VS_ENTITY_LOAD_DISTANCE, 1, false)
                .build(),
            EntityEntryBuilder.create()
                .entity(EntityMountableChair.class)
                .id(entityMountableChair, entityId++)
                .name(entityMountableChair.getPath())
                .tracker(ValkyrienSkiesMod.VS_ENTITY_LOAD_DISTANCE, 1, false)
                .build()
        );
}
 
Example #4
Source File: RegistryHandler.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@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);
      }
}
 
Example #5
Source File: EntryListEntities.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@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();
}
 
Example #6
Source File: BackpackRegistry.java    From WearableBackpacks with MIT License 5 votes vote down vote up
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);
}
 
Example #7
Source File: SignalsConfig.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isBlacklisted(EntityMinecart cart, String[] config){
    if(config.length == 0) return false;
    EntityEntry entry = EntityRegistry.getEntry(cart.getClass());
    ResourceLocation cartID = ForgeRegistries.ENTITIES.getKey(entry);
    for(String blacklist : config) {
        if(cartID.equals(new ResourceLocation(blacklist))) {
            return true;
        }
    }
    return false;
}
 
Example #8
Source File: TextureHelper.java    From malmo with MIT License 5 votes vote down vote up
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();
}
 
Example #9
Source File: WillsAssortedThingsSubMod.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerEntities(IForgeRegistry<EntityEntry> reg) {
    reg.registerAll(EntityEntryBuilder.create()
            .entity(EntityChickenArrow.class)
            .factory(EntityChickenArrow::new)
            .id(new ResourceLocation(CommunityGlobals.MOD_ID, "chicken_arrow"), CommunityGlobals.entity_id++)
            .name("chicken_arrow")
            .tracker(64, 3, true)
            .build());
}
 
Example #10
Source File: DabSquirrels.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerEntities(IForgeRegistry<EntityEntry> reg) {
	Set<Biome> biomeset = BiomeDictionary.getBiomes(BiomeDictionary.Type.FOREST);
	Biome[] biomes = biomeset.toArray(new Biome[0]);
	reg.register(EntityEntryBuilder.create()
			.entity(EntityDabSquirrel.class).egg(0x89806f, 0xb2a489)
			.name(CommunityGlobals.MOD_ID + ".dabsquirrel")
			.id(new ResourceLocation(CommunityGlobals.MOD_ID, "dabsquirrel"), CommunityGlobals.entity_id++)
			.tracker(128, 1, true)
			.spawn(EnumCreatureType.CREATURE, 12, 1, 3, biomes)
			.build());
}
 
Example #11
Source File: SubmodGnomes.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerEntities(IForgeRegistry<EntityEntry> reg)
{
	reg.register(EntityEntryBuilder.create()
			.name(CommunityGlobals.MOD_ID + "." + "wood_gnome")
			.entity(EntityGnomeWood.class)
			.id(new ResourceLocation(CommunityGlobals.MOD_ID, "wood_gnome"), CommunityGlobals.entity_id++)
			.tracker(80, 3, false)
			.spawn(EnumCreatureType.CREATURE, 10, 1, 4, BiomeDictionary.getBiomes(BiomeDictionary.Type.FOREST))
			.egg(0xd3753f, 0x774725)
			.build());
}
 
Example #12
Source File: SubmodExplodingChickens.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerEntities(IForgeRegistry<EntityEntry> reg)
{
	reg.register(EntityEntryBuilder.create()
			.name(CommunityGlobals.MOD_ID + "." + "exploding_chicken")
			.entity(EntityExplodingChicken.class)
			.id(new ResourceLocation(CommunityGlobals.MOD_ID, "exploding_chicken"), CommunityGlobals.entity_id++)
			.tracker(80, 3, true)
			.spawn(EnumCreatureType.CREATURE, 3, 1, 4, most_biomes)
			.egg(16711680, 10592673)
			.build());
}
 
Example #13
Source File: Penguins.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerEntities(IForgeRegistry<EntityEntry> reg) {
	List<Biome> penguinBiomes = new LinkedList<Biome>();
	for (Entry<ResourceLocation, Biome> e : ForgeRegistries.BIOMES.getEntries())
		if (e.getValue().getTempCategory() == TempCategory.COLD)
			penguinBiomes.add(e.getValue());
	reg.register(EntityEntryBuilder.create().entity(EntityPenguin.class).egg(0x000000, 0xFFFFFF)
					.tracker(32, 4, true).name("community_mod.penguin")
					.spawn(EnumCreatureType.CREATURE, 7, 7, 9, penguinBiomes)
					.id(new ResourceLocation("community_mod", "penguin"), CommunityGlobals.entity_id++).build());
}
 
Example #14
Source File: BlockDrawingHelper.java    From malmo with MIT License 4 votes vote down vote up
/** 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());
    }
}
 
Example #15
Source File: FatSheep.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void registerEntities(IForgeRegistry<EntityEntry> reg)
{
	reg.register(EntityEntryBuilder.create().name("Overgrown Sheep").entity(EntityOvergrownSheep.class).id(new ResourceLocation(CommunityGlobals.MOD_ID, "overgrown_sheep"), CommunityGlobals.entity_id++).tracker(80, 3, true).build());
}
 
Example #16
Source File: EntryListEntities.java    From WearableBackpacks with MIT License 4 votes vote down vote up
public static Optional<EntityEntry> getEntityEntry(String entityID) {
	return Optional.ofNullable(ForgeRegistries.ENTITIES.getValue(new ResourceLocation(entityID)))
		.filter(entry -> EntityLivingBase.class.isAssignableFrom(entry.getEntityClass()));
}
 
Example #17
Source File: EntryListEntities.java    From WearableBackpacks with MIT License 4 votes vote down vote up
public static String getEntityEntryName(Optional<EntityEntry> entry, String entityID)
{ return entry.map(EntityEntry::getName).map(s -> "[" + s + "]").orElse("\"" + entityID + "\""); }
 
Example #18
Source File: CreativeTabCommunity.java    From CommunityMod with GNU Lesser General Public License v2.1 3 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void displayAllRelevantItems(NonNullList<ItemStack> itemList) {

	super.displayAllRelevantItems(itemList);

	if (entityCache == null) {

		entityCache = new ArrayList<>();

		for (EntityEntry entityEntry : ForgeRegistries.ENTITIES.getValuesCollection()) {

			if (entityEntry.getRegistryName().getNamespace().equalsIgnoreCase(CommunityGlobals.MOD_ID)) {

				entityCache.add(entityEntry.getRegistryName());
			}
		}
	}

	for (final ResourceLocation id : entityCache) {

		final ItemStack spawner = new ItemStack(Items.SPAWN_EGG);
		ItemMonsterPlacer.applyEntityIdToItemStack(spawner, id);
		itemList.add(spawner);
	}

}
 
Example #19
Source File: CommunityMod.java    From CommunityMod with GNU Lesser General Public License v2.1 3 votes vote down vote up
@SubscribeEvent
public void entities (RegistryEvent.Register<EntityEntry> event) {

    IForgeRegistry<EntityEntry> reg = SubModLoader.INSTANCE.trackRegistry(event.getRegistry());

    for (final SubModContainer container : SubModLoader.getLoadedSubMods()) {

        activeSubMod = container;
        container.getSubMod().registerEntities(reg);
    }

    activeSubMod = null;
}
 
Example #20
Source File: ISubMod.java    From CommunityMod with GNU Lesser General Public License v2.1 2 votes vote down vote up
default void registerEntities (IForgeRegistry<EntityEntry> reg) {

    }