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); } } }
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()]); }
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()]); }
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; }
@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); } }
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); } }
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(); }
@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(); }
@Override public void registerEntities(InfinityMod mod, IForgeRegistry<EntityEntry> registry) { ReflectionHelper.forEachIn(mod.getModEntityRegistry(), EntityRegistryEntry.class, (EntityRegistryEntry entry) -> { if(entry.isEnabled()) { entry.registerClient(mod, registry); } }); }
default void registerEntities(InfinityMod mod, IForgeRegistry<EntityEntry> registry) { ReflectionHelper.forEachIn(mod.getModEntityRegistry(), EntityRegistryEntry.class, (EntityRegistryEntry entry) -> { if (entry.isEnabled()) { entry.register(mod, registry); } }); }
@SubscribeEvent public void registerEntitys (RegistryEvent.Register<EntityEntry> event) { for (final EntityEntryBuilder<? extends Entity> entry : this.helper.getEntities()) { event.getRegistry().register(entry.build()); } }
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); }
@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(); }
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); }
@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); } }
@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); }
/** 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()); } }
@Deprecated @SubscribeEvent public void registerEntities(RegistryEvent.Register<EntityEntry> event) { event.getRegistry().register(EntityEntries.ENTITY_WOLF_ARMORED); }
@SideOnly(Side.CLIENT) public void registerClient(InfinityMod mod, IForgeRegistry<EntityEntry> registry) { this.register(mod, registry); RenderingRegistry.registerEntityRenderingHandler(this.getEntityClass(), renderFactory); }
@SubscribeEvent public final void registerEntities(RegistryEvent.Register<EntityEntry> event) { InfinityLib.proxy.registerEntities(this, event.getRegistry()); }
/** * Returns the registered entity entry for a entity class */ public static EntityEntry getEntry(Class<? extends Entity> cls) { return EntityRegistry.getEntry(cls); }
/** * @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(); }
public static Optional<EntityEntry> getEntityEntry(String entityID) { return Optional.ofNullable(ForgeRegistries.ENTITIES.getValue(new ResourceLocation(entityID))) .filter(entry -> EntityLivingBase.class.isAssignableFrom(entry.getEntityClass())); }
public static String getEntityEntryName(Optional<EntityEntry> entry, String entityID) { return entry.map(EntityEntry::getName).map(s -> "[" + s + "]").orElse("\"" + entityID + "\""); }
@SubscribeEvent public static void registerEntities(RegistryEvent.Register<EntityEntry> event) { setEntites.register(event.getRegistry()); }
@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); }
@SideOnly(Side.CLIENT) @SubscribeEvent public static void registerEntityRenderers(RegistryEvent.Register<EntityEntry> event) { RenderingRegistry.registerEntityRenderingHandler(EntityLesserCelestial.class, new RenderLesserCelestial.Factory()); }