@Override public void addModAsResource(ModContainer container) { Class<?> resourcePackType = container.getCustomResourcePackClass(); if (resourcePackType != null) { try { ResourcePack pack = (ResourcePack) resourcePackType.getConstructor(ModContainer.class).newInstance(container); resourcePackList.add(pack); resourcePackMap.put(container.getModId(), pack); } catch (NoSuchMethodException e) { FMLLog.log( Level.SEVERE, "The container %s (type %s) returned an invalid class for it's resource pack.", container.getName(), container.getClass().getName()); return; } catch (Exception e) { FMLLog.log( Level.SEVERE, e, "An unexpected exception occurred constructing the custom resource pack for %s", container.getName()); throw Throwables.propagate(e); } } }
private static RegionFile fixNegativeOffset(File regionFileFile) { FMLLog.log( Level.WARNING, "Region file " + regionFileFile + " is corrupted: negative offset. Attempting to fix."); try { Files.copy( regionFileFile, new File(regionFileFile.getParentFile(), regionFileFile.getName() + ".bak")); } catch (IOException e) { FMLLog.log(Level.SEVERE, e, "Failed to back up corrupt region file."); } try { RandomAccessFile dataFile = new RandomAccessFile(regionFileFile, "rw"); try { int length; if (dataFile.length() < 4096L) { for (length = 0; length < 1024; ++length) { dataFile.writeInt(0); } for (length = 0; length < 1024; ++length) { dataFile.writeInt(0); } } if ((dataFile.length() & 4095L) != 0L) { for (length = 0; (long) length < (dataFile.length() & 4095L); ++length) { dataFile.write(0); } } length = (int) dataFile.length() / 4096; dataFile.seek(0L); for (int i = 0; i < 1024; ++i) { int offset = dataFile.readInt(); if (offset != 0 && (offset >> 8) + (offset & 255) <= length) { for (int var5 = 0; var5 < (offset & 255); ++var5) { if ((offset >> 8) + var5 < 0) { dataFile.seek(dataFile.getFilePointer() - 4); dataFile.writeInt(0); break; } } } } } finally { dataFile.close(); } } catch (Throwable t) { FMLLog.log(Level.SEVERE, t, "Failed to fix negative offset index in " + regionFileFile); throw UnsafeUtil.throwIgnoreChecked(t); } return new RegionFile(regionFileFile); }
private int validateAndClaimId(int id) { // workaround for broken ML int realId = id; if (id < Byte.MIN_VALUE) { FMLLog.warning("Compensating for modloader out of range compensation by mod : entityId %d for mod %s is now %d", id, Loader.instance().activeModContainer().getModId(), realId); realId += 3000; } if (realId < 0) { realId += Byte.MAX_VALUE; } try { UnsignedBytes.checkedCast(realId); } catch (IllegalArgumentException e) { FMLLog.log(Level.SEVERE, "The entity ID %d for mod %s is not an unsigned byte and may not work", id, Loader.instance().activeModContainer().getModId()); } if (!availableIndicies.get(realId)) { FMLLog.severe("The mod %s has attempted to register an entity ID %d which is already reserved. This could cause severe problems", Loader.instance().activeModContainer().getModId(), id); } availableIndicies.clear(realId); return realId; }
private void doModEntityRegistration(Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) { ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod); EntityRegistration er = new EntityRegistration(mc, entityClass, entityName, id, trackingRange, updateFrequency, sendsVelocityUpdates); try { entityClassRegistrations.put(entityClass, er); entityNames.put(entityName, mc); if (!EntityList.classToStringMapping.containsKey(entityClass)) { String entityModName = String.format("%s.%s", mc.getModId(), entityName); EntityList.classToStringMapping.put(entityClass, entityModName); EntityList.stringToClassMapping.put(entityModName, entityClass); FMLLog.finest("Automatically registered mod %s entity %s as %s", mc.getModId(), entityName, entityModName); } else { FMLLog.fine("Skipping automatic mod %s entity registration for already registered class %s", mc.getModId(), entityClass.getName()); } } catch (IllegalArgumentException e) { FMLLog.log(Level.WARNING, e, "The mod %s tried to register the entity (name,class) (%s,%s) one or both of which are already registered", mc.getModId(), entityName, entityClass.getName()); return; } entityRegistrations.put(mc, er); }
public void loadLocalization(URL localizationFile, String lang, boolean isXML) { InputStream langStream = null; Properties langPack = new Properties(); try { langStream = localizationFile.openStream(); if (isXML) { langPack.loadFromXML(langStream); } else { langPack.load(new InputStreamReader(langStream, Charsets.UTF_8)); } addStringLocalization(langPack, lang); } catch (IOException e) { FMLLog.log(Level.SEVERE, e, "Unable to load localization from file %s", localizationFile); } finally { try { if (langStream != null) { langStream.close(); } } catch (IOException ex) { // HUSH } } }
/** * Called a bit later on during initialization to finish loading mods Also initializes key * bindings */ @SuppressWarnings("deprecation") public void finishMinecraftLoading() { if (modsMissing != null || wrongMC != null || customError != null || dupesFound != null || modSorting != null) { return; } try { Loader.instance().initializeMods(); } catch (CustomModLoadingErrorDisplayException custom) { FMLLog.log( Level.SEVERE, custom, "A custom exception was thrown by a mod, the game will now halt"); customError = custom; return; } catch (LoaderException le) { haltGame( "There was a severe problem during mod loading that has caused the game to fail", le); return; } LanguageRegistry.reloadLanguageTable(); RenderingRegistry.instance() .loadEntityRenderers( (Map<Class<? extends Entity>, Render>) RenderManager.field_78727_a.field_78729_o); loading = false; KeyBindingRegistry.instance().uploadKeyBindingsToGame(client.field_71474_y); }
/** Creates a new entity and loads its data from the specified NBT. */ public static ItemEntity createAndLoadEntity(NBTTagCompound par0NBTTagCompound) { ItemEntity itementity = null; Class oclass = null; try { oclass = (Class) nameToClassMap.get(par0NBTTagCompound.getString("id")); if (oclass != null) { itementity = (ItemEntity) oclass.newInstance(); } } catch (Exception exception) { exception.printStackTrace(); } if (itementity != null) { try { itementity.readFromNBT(par0NBTTagCompound); } catch (Exception e) { FMLLog.log( Level.ERROR, e, "A ItemEntity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author", par0NBTTagCompound.getString("id"), oclass.getName()); itementity = null; } } else { logger.warn("Skipping ItemEntity with id " + par0NBTTagCompound.getString("id")); } return itementity; }
private void setDefaultValues() { try { ConfigManagerIo.configuration.load(); ConfigManagerIo.idIoEnabled = ConfigManagerIo.configuration .get( Configuration.CATEGORY_GENERAL, "Should Io, Items and Blocks be registered in the game (Big planet on / off switch.)", true) .getBoolean(true); ConfigManagerIo.idDimensionIo = ConfigManagerIo.configuration .get(Configuration.CATEGORY_GENERAL, "Io Dimension", -47) .getInt(-47); ConfigManagerIo.idDayLength = ConfigManagerIo.configuration .get(Configuration.CATEGORY_GENERAL, "Io Day Length Realistic", true) .getBoolean(true); ConfigManagerIo.idBiomeIo = ConfigManagerIo.configuration .get(Configuration.CATEGORY_GENERAL, "Io Biome", 217) .getInt(217); } catch (final Exception e) { FMLLog.log(Level.ERROR, e, "4Space Io Config has a problem loading it's configuration"); } finally { ConfigManagerIo.configuration.save(); ConfigManagerIo.loaded = true; } }
/** {@inheritDoc} */ @Init public void load(final FMLInitializationEvent event) { klaxon = new ItemKlaxon(klaxonId); LanguageRegistry.addName(klaxon, "Klaxon"); GameRegistry.addRecipe( new ItemStack(klaxon), " x ", "xox", " x ", 'x', new ItemStack(Item.stick), 'o', new ItemStack(Item.leather)); if (event.getSide() == Side.CLIENT) { String name = "klaxon" + Minecraft.getMinecraft().session.username; Minecraft.getMinecraft().sndManager.addSound(name + ".ogg", file); FMLLog.log(MOD_ID, Level.INFO, "klaxon name %s", name); } // Adds listeners. if (event.getSide() == Side.CLIENT) { providerListener = new MyProviderListener(); fileListener = new MyFileListener(); IProvider p = P2P.get(P2P.CLIENT_PROVIDER); p.addListener(providerListener); p.getFileProvider().addListener(fileListener); } }
@Override public Entity spawnEntityIntoClientWorld(EntityRegistration er, EntitySpawnPacket packet) { WorldClient wc = client.field_71441_e; Class<? extends Entity> cls = er.getEntityClass(); try { Entity entity; if (er.hasCustomSpawning()) { entity = er.doCustomSpawning(packet); } else { entity = (Entity) (cls.getConstructor(World.class).newInstance(wc)); int offset = packet.entityId - entity.field_70157_k; entity.field_70157_k = packet.entityId; entity.func_70012_b( packet.scaledX, packet.scaledY, packet.scaledZ, packet.scaledYaw, packet.scaledPitch); if (entity instanceof EntityLiving) { ((EntityLiving) entity).field_70759_as = packet.scaledHeadYaw; } Entity parts[] = entity.func_70021_al(); if (parts != null) { for (int j = 0; j < parts.length; j++) { parts[j].field_70157_k += offset; } } } entity.field_70118_ct = packet.rawX; entity.field_70117_cu = packet.rawY; entity.field_70116_cv = packet.rawZ; if (entity instanceof IThrowableEntity) { Entity thrower = client.field_71439_g.field_70157_k == packet.throwerId ? client.field_71439_g : wc.func_73045_a(packet.throwerId); ((IThrowableEntity) entity).setThrower(thrower); } if (packet.metadata != null) { entity.func_70096_w().func_75687_a((List) packet.metadata); } if (packet.throwerId > 0) { entity.func_70016_h(packet.speedScaledX, packet.speedScaledY, packet.speedScaledZ); } if (entity instanceof IEntityAdditionalSpawnData) { ((IEntityAdditionalSpawnData) entity).readSpawnData(packet.dataStream); } wc.func_73027_a(packet.entityId, entity); return entity; } catch (Exception e) { FMLLog.log(Level.SEVERE, e, "A severe problem occurred during the spawning of an entity"); throw Throwables.propagate(e); } }
public static void init(File configFile) { configuration = new Configuration(configFile); try { configuration.load(); /* General configs */ ConfigurationSettings.DISPLAY_VERSION_RESULT = configuration .get( CATEGORY_GENERAL, ConfigurationSettings.DISPLAY_VERSION_RESULT_CONFIGNAME, ConfigurationSettings.DISPLAY_VERSION_RESULT_DEFAULT) .getBoolean(ConfigurationSettings.DISPLAY_VERSION_RESULT_DEFAULT); ConfigurationSettings.LAST_DISCOVERED_VERSION = configuration .get( CATEGORY_GENERAL, ConfigurationSettings.LAST_DISCOVERED_VERSION_CONFIGNAME, ConfigurationSettings.LAST_DISCOVERED_VERSION_DEFAULT) .getString(); ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE = configuration .get( CATEGORY_GENERAL, ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE_CONFIGNAME, ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE_DEFAULT) .getString(); /* Item configs */ ItemIds.HEART_GOLD = configuration .getItem(Strings.HEART_GOLD_NAME, ItemIds.HEART_GOLD_DEFAULT) .getInt(ItemIds.HEART_GOLD_DEFAULT); /* Block config */ BlockIds.CHARGER = configuration .getBlock(Strings.CHARGER_NAME, BlockIds.CHARGER_DEFAULT) .getInt(BlockIds.CHARGER_DEFAULT); /* Item durability configs */ ConfigurationSettings.HEART_GOLD_MAX_DURABILITY = configuration .get( CATEGORY_DURABILITY, ConfigurationSettings.HEART_GOLD_MAX_DURABILITY_CONFIGNAME, ConfigurationSettings.HEART_GOLD_MAX_DURABILITY_DEFAULT) .getInt(ConfigurationSettings.HEART_GOLD_MAX_DURABILITY_DEFAULT); } catch (Exception e) { FMLLog.log( Level.SEVERE, e, Reference.MOD_NAME + " has had a problem loading its configuration"); } finally { configuration.save(); } }
/** * Gets the klaxon with given name only if needed. * * @param name klaxon's name. */ public static synchronized void getKlaxonIfNeeded(String name) { if (running) { if (loadingKlaxons.contains(name) || loadedKlaxons.contains(name)) { FMLLog.log(MOD_ID, Level.INFO, "Must get the klaxon %s if needed, already have it", name); } else { getKlaxon(name); } } }
public static RegionFile newRegionFile(File regionFileFile) { try { return new RegionFile(regionFileFile); } catch (ArrayIndexOutOfBoundsException e) { return fixNegativeOffset(regionFileFile); } catch (Throwable t) { FMLLog.log(Level.SEVERE, t, "Error opening region file: " + regionFileFile); throw UnsafeUtil.throwIgnoreChecked(t); } }
/** {@inheritDoc} */ @Override public void onUploaded(IUpload task) { if (task.getChannel().equals(MOD_ID)) { FMLLog.log(MOD_ID, Level.INFO, "Klaxon has been uploaded, notifying players"); try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); dos.writeInt(PacketType.UploadedKlaxon.ordinal()); dos.writeUTF(task.getName()); Packet250CustomPayload packet = new Packet250CustomPayload(); packet.channel = MOD_ID; packet.data = bos.toByteArray(); packet.length = bos.size(); PacketDispatcher.sendPacketToServer(packet); } catch (IOException e) { FMLLog.log(MOD_ID, Level.SEVERE, e, "Could not notify the players"); } } }
/** * Called when a klaxon has been received. * * @param task the task. */ private static synchronized void gotKlaxon(IDownload task) { String name = task.getName(); File file = task.getFile(); FMLLog.log(MOD_ID, Level.INFO, "Klaxon %s saved to %s", name, file.getAbsolutePath()); // Adds the klaxon to the sound manager. Minecraft.getMinecraft().sndManager.addSound(name + ".ogg", file); // Adds to the list of loaded klaxons. loadedKlaxons.add(name); loadingKlaxons.remove(name); }
public void loadLocalization(String localizationFile, String lang, boolean isXML) { URL urlResource = this.getClass().getResource(localizationFile); if (urlResource != null) { loadLocalization(urlResource, lang, isXML); } else { ModContainer activeModContainer = Loader.instance().activeModContainer(); if (activeModContainer != null) { FMLLog.log( activeModContainer.getModId(), Level.SEVERE, "The language resource %s cannot be located on the classpath. This is a programming error.", localizationFile); } else { FMLLog.log( Level.SEVERE, "The language resource %s cannot be located on the classpath. This is a programming error.", localizationFile); } } }
public static void dumpRegistry(File minecraftDir) { if (customItemStacks == null) { return; } if (Boolean.valueOf(System.getProperty("fml.dumpRegistry", "false")).booleanValue()) { ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder(); for (String modId : customItemStacks.rowKeySet()) { builder.putAll(modId, customItemStacks.row(modId).keySet()); } File f = new File(minecraftDir, "itemStackRegistry.csv"); MapJoiner mapJoiner = Joiner.on("\n").withKeyValueSeparator(","); try { Files.write(mapJoiner.join(builder.build().entries()), f, Charsets.UTF_8); FMLLog.log(Level.INFO, "Dumped item registry data to %s", f.getAbsolutePath()); } catch (IOException e) { FMLLog.log(Level.ERROR, e, "Failed to write registry data to %s", f.getAbsolutePath()); } } }
/** * Called to start the whole game off * * @param minecraft The minecraft instance being launched * @param resourcePackList The resource pack list we will populate with mods * @param resourceManager The resource manager */ public void beginMinecraftLoading( Minecraft minecraft, List resourcePackList, ReloadableResourceManager resourceManager) { client = minecraft; this.resourcePackList = resourcePackList; this.resourceManager = resourceManager; this.resourcePackMap = Maps.newHashMap(); if (minecraft.func_71355_q()) { FMLLog.severe("DEMO MODE DETECTED, FML will not work. Finishing now."); haltGame("FML will not run in demo mode", new RuntimeException()); return; } // TextureFXManager.instance().setClient(client); FMLCommonHandler.instance().beginLoading(this); new ModLoaderClientHelper(client); try { Class<?> optifineConfig = Class.forName("Config", false, Loader.instance().getModClassLoader()); String optifineVersion = (String) optifineConfig.getField("VERSION").get(null); Map<String, Object> dummyOptifineMeta = ImmutableMap.<String, Object>builder() .put("name", "Optifine") .put("version", optifineVersion) .build(); ModMetadata optifineMetadata = MetadataCollection.from(getClass().getResourceAsStream("optifinemod.info"), "optifine") .getMetadataForId("optifine", dummyOptifineMeta); optifineContainer = new DummyModContainer(optifineMetadata); FMLLog.info( "Forge Mod Loader has detected optifine %s, enabling compatibility features", optifineContainer.getVersion()); } catch (Exception e) { optifineContainer = null; } try { Loader.instance().loadMods(); } catch (WrongMinecraftVersionException wrong) { wrongMC = wrong; } catch (DuplicateModsFoundException dupes) { dupesFound = dupes; } catch (MissingModsException missing) { modsMissing = missing; } catch (ModSortingException sorting) { modSorting = sorting; } catch (CustomModLoadingErrorDisplayException custom) { FMLLog.log( Level.SEVERE, custom, "A custom exception was thrown by a mod, the game will now halt"); customError = custom; } catch (LoaderException le) { haltGame( "There was a severe problem during mod loading that has caused the game to fail", le); return; } }
/** * Gets the klaxon with given name. * * @param name klaxon's name. */ public static synchronized void getKlaxon(String name) { if (running) { if (!loadingKlaxons.contains(name)) { FMLLog.log(MOD_ID, Level.INFO, "Must get the klaxon %s", name); loadedKlaxons.remove(name); loadingKlaxons.add(name); File file = new File(klaxons, name + ".ogg"); IFileProvider p = P2P.get(P2P.CLIENT_PROVIDER).getFileProvider(); p.download(MOD_ID, name, file); } } }
/** * Called when the client has been started. * * @param event the event. */ private static synchronized void clientStarted(IProviderEvent event) { running = true; clear(); P2P.get(P2P.CLIENT_PROVIDER).getFileProvider().addListener(fileListener); // Klaxon file exists. if (file.exists() && file.isFile()) { // Uploads the klaxon. String name = "klaxon" + Minecraft.getMinecraft().thePlayer.username + "a"; FMLLog.log(MOD_ID, Level.INFO, "Client started, uploading the klaxon to %s", name); event.getFileProvider().upload(MOD_ID, file, name); } }
public void registerGuiHandler(Object mod, IGuiHandler handler) { ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod); NetworkModHandler nmh = FMLNetworkHandler.instance().findNetworkModHandler(mc); if (nmh == null) { FMLLog.log( Level.FINE, "The mod %s needs to be a @NetworkMod to register a Networked Gui Handler", mc.getModId()); } else { serverGuiHandlers.put(mc, handler); } clientGuiHandlers.put(mc, handler); }
/** {@inheritDoc} */ @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { if (packet.channel.equals(ColoredWool.MOD_ID)) { try { ByteArrayInputStream bis = new ByteArrayInputStream(packet.data); DataInputStream dis = new DataInputStream(bis); Packet p = Packet.values()[dis.readInt()]; p.handle(packet, dis, (EntityPlayer) player); } catch (IOException e) { FMLLog.log(ColoredWool.MOD_ID, Level.SEVERE, e, "Could not handle the packet"); } } }
@Override public void handleServerSide(EntityPlayer player) { TileEntity te = player.worldObj.getTileEntity(xCoord, yCoord, zCoord); if (te instanceof MarketTileEntity) { tile = (MarketTileEntity) te; player.worldObj.playSoundEffect( (double) ((float) xCoord + 0.5F), (double) ((float) yCoord + 0.5F), (double) ((float) zCoord + 0.5F), SimCraft.MODID + ":coins1", 2.0f, 2.0f); if (!MarketManager.sellItems(player, tile)) FMLLog.log(Level.ERROR, "[SimCraft] Player unable to sell items!"); else SimCraft.packetPipeline.sendTo(new PacketMarketItemsSold(), (EntityPlayerMP) player); } }
@EventHandler public void load(FMLInitializationEvent evt) { if (!Loader.isModLoaded("Railcraft")) { return; } try { String id = Block.blockRegistry.getNameForObject(MineFactoryReloadedCore.factoryDecorativeStoneBlock); FMLInterModComms.sendMessage("Railcraft", "balast", String.format("%s@%s", id, 8)); FMLInterModComms.sendMessage("Railcraft", "balast", String.format("%s@%s", id, 9)); // white sand? black sand? Object rockCrusher = Class.forName("mods.railcraft.api.crafting.RailcraftCraftingManager").getField("rockCrusher").get(null); Method createNewRecipe = Class.forName("mods.railcraft.api.crafting.IRockCrusherCraftingManager").getMethod("createNewRecipe", ItemStack.class, boolean.class, boolean.class); Method addOutput = Class.forName("mods.railcraft.api.crafting.IRockCrusherRecipe").getMethod("addOutput", ItemStack.class, float.class); Object recipe = createNewRecipe.invoke(rockCrusher, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 10), true, false); addOutput.invoke(recipe, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 2), 1.0f); // Paved Blackstone -> Cobble recipe = createNewRecipe.invoke(rockCrusher, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 11), true, false); addOutput.invoke(recipe, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 3), 1.0f); // Paved Whitestone -> Cobble recipe = createNewRecipe.invoke(rockCrusher, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 0), true, false); addOutput.invoke(recipe, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 2), 1.0f); // Smooth Blackstone -> Cobble recipe = createNewRecipe.invoke(rockCrusher, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 1), true, false); addOutput.invoke(recipe, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 3), 1.0f); // Smooth Whitestone -> Cobble recipe = createNewRecipe.invoke(rockCrusher, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 2), true, false); addOutput.invoke(recipe, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 8), 1.0f); // Cobble Blackstone -> Gravel + flint addOutput.invoke(recipe, new ItemStack(Items.flint, 1, 0), 0.05f); recipe = createNewRecipe.invoke(rockCrusher, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 3), true, false); addOutput.invoke(recipe, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 9), 1.0f); // Cobble Whitestone -> Gravel + flint addOutput.invoke(recipe, new ItemStack(Items.flint, 1, 0), 0.05f); } catch (Throwable _) { ModContainer This = FMLCommonHandler.instance().findContainerFor(this); FMLLog.log(This.getModId(), Level.WARN, "There was a problem loading %s.", This.getName()); _.printStackTrace(); } }
public static BraceBase createBraceBaseFromNBT(NBTTagCompound nbt, World world, int id) { BraceBase iobj = null; Class oclass = null; try { if (nbt.getString("id") == null) { mitoLogger.info("id is null"); } else { // mitoLogger.info("id is " + nbt.getString("id")); } oclass = (Class) stringToClassMapping.get(nbt.getString("id")); if (oclass == null) { // mitoLogger.info("class is null"); } if (oclass != null) { iobj = (BraceBase) oclass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {world}); if (id != -1) { iobj.BBID = id; } } } catch (Exception exception) { exception.printStackTrace(); } if (iobj != null) { try { iobj.readFromNBT(nbt); } catch (Exception e) { FMLLog.log( Level.ERROR, e, "An Entity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author", nbt.getString("id"), oclass.getName()); iobj = null; } } else { mitoLogger.warn("Skipping Entity with id " + nbt.getString("id")); } return iobj; }
public static void init(File configFile) { config = new Configuration(configFile); try { config.load(); generateEmeralds = config.getBoolean("Generate Emeralds", "World Gen", true, ""); enableCobblestoneBoulders = config.getBoolean("Enable Cobblestone Boulders", "World Gen", true, ""); cobblestoneBoulderChance = config.getInt( "1/x chance that Cobblestone Boulders will generate if given the opportunity to do so during world gen", "World Gen", 1, 1, 100, "1 = Always generate if possible; 2 = 50% chance; 4 = 25% chance"); showDebugInfo = config.getBoolean("Show Debug Info in F3 Screen", "Debugging", false, ""); enableDebugging = config.getBoolean( "Enable Debugging", "Debugging", false, "WARNING: This should only be enabled if you know what you're doing."); biomeSize = config.getInt( "Size of Biomes", "World Gen", 4, 4, 6, "COMING SOON!!! 4 = Default World Type; 6 = Large Biomes World Type"); } catch (Exception e) { FMLLog.log(Level.ERROR, e, "RTG has had a problem loading RTG configuration."); } finally { if (config.hasChanged()) { config.save(); } } }
public void rGenerateEmeralds(World world, Random rand, int chunkX, int chunkZ) { int k = 3 + rand.nextInt(6); int l; int i1; int j1; for (l = 0; l < k; ++l) { i1 = chunkX + rand.nextInt(16); j1 = rand.nextInt(28) + 4; int k1 = chunkZ + rand.nextInt(16); if (world.getBlock(i1, j1, k1).isReplaceableOreGen(world, i1, j1, k1, emeraldStoneBlock)) { world.setBlock(i1, j1, k1, emeraldEmeraldBlock, emeraldEmeraldMeta, 2); if (ConfigRTG.enableDebugging) { FMLLog.log(Level.INFO, "Emerald generated at %d, %d, %d", i1, j1, k1); } } } }
public static void init(File configFile) { configuration = new Configuration(configFile); try { configuration.load(); /* General configs */ ConfigurationSettings.DISPLAY_VERSION_RESULT = configuration .get( CATEGORY_GENERAL, ConfigurationSettings.DISPLAY_VERSION_RESULT_CONFIGNAME, ConfigurationSettings.DISPLAY_VERSION_RESULT_DEFAULT) .getBoolean(ConfigurationSettings.DISPLAY_VERSION_RESULT_DEFAULT); ConfigurationSettings.LAST_DISCOVERED_VERSION = configuration .get( CATEGORY_GENERAL, ConfigurationSettings.LAST_DISCOVERED_VERSION_CONFIGNAME, ConfigurationSettings.LAST_DISCOVERED_VERSION_DEFAULT) .getString(); ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE = configuration .get( CATEGORY_GENERAL, ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE_CONFIGNAME, ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE_DEFAULT) .getString(); // ItemIds.MINIUM_SHARD = configuration.getItem(Strings.MINIUM_SHARD_NAME, // ItemIds.MINIUM_SHARD_DEFAULT).getInt(ItemIds.MINIUM_SHARD_DEFAULT); } catch (Exception e) { FMLLog.log( Level.SEVERE, e, CoreRef.MOD_NAME + " has had a problem loading its configuration"); } finally { configuration.save(); } }
/** {@inheritDoc} */ @PreInit public void preInit(FMLPreInitializationEvent event) { config = new Configuration(event.getSuggestedConfigurationFile()); config.load(); if (event.getSide() == Side.CLIENT) { // Creates the klaxon folder. klaxons = new File(event.getModConfigurationDirectory(), "klaxons"); if (!klaxons.exists()) { klaxons.mkdirs(); } FMLLog.log(MOD_ID, Level.INFO, "Folder %s", klaxons); // Loads client configuration. file = new File(config.get(Configuration.CATEGORY_GENERAL, "Klaxon", "").getString()); // Loading and loaded klaxons. loadingKlaxons = new HashSet<String>(); loadedKlaxons = new HashSet<String>(); } // Loads shared configuration. klaxonId = config.get(Configuration.CATEGORY_ITEM, "Klaxon", klaxonDefaultId).getInt(klaxonDefaultId); config.save(); }
public void postInit(FMLPostInitializationEvent event) { if (Botania.thaumcraftLoaded) { ModBrews.initTC(); ModBrewRecipes.initTC(); } ModBlocks.addDispenserBehaviours(); ModBlocks.registerMultiparts(); ConfigHandler.loadPostInit(); LexiconData.postInit(); registerNEIStuff(); int words = 0; for (LexiconEntry entry : BotaniaAPI.getAllEntries()) for (LexiconPage page : entry.pages) { words += countWords(page.getUnlocalizedName()); if (page instanceof ITwoNamedPage) words += countWords(((ITwoNamedPage) page).getSecondUnlocalizedName()); } FMLLog.log(Level.INFO, "[Botania] The Lexica Botania has %d words.", words); }