/** * Registers a SubTileEntity, a new special flower. Look in the subtile package of the API. * Call this during {@code RegistryEvent.Register<Block>}, and don't forget to register a model in BotaniaAPIClient. */ public static void registerSubTile(String key, Class<? extends SubTileEntity> subtileClass) { subTiles.put(key, subtileClass); subTileMods.put(key, Loader.instance().activeModContainer().getModId()); }
public List<String> getAddedByInfo(Material material) { ImmutableList.Builder<String> builder = ImmutableList.builder(); if(TinkerRegistry.getTrace(material) != null) { String materialInfo = I18n.translateToLocalFormatted("tooltip.part.material_added_by", TinkerRegistry.getTrace(material).getName()); builder.add(""); builder.add(materialInfo); } return builder.build(); }
private ModMeta(ModContainer container) { this.container = container; this.modId = Strings.nullToEmpty(container.getModId()); this.name = Strings.nullToEmpty(container.getName()); this.version = Strings.nullToEmpty(container.getVersion()); this.metadata = container.getMetadata(); }
builder.append( container.getModId() ); builder.append( container.getVersion() );
public static String getDisplayString() { ModContainer metadata = FMLInterface.getModContainer(); return metadata.getName() + " " + metadata.getVersion(); } }
@Override protected @Nonnull Map<String, Configuration> getConfigurations() { Map<String, Configuration> result = new HashMap<>(); for (ModContainer modContainer : Loader.instance().getModList()) { Object mod = modContainer.getMod(); if (mod instanceof IEnderIOAddon) { Configuration configuration = ((IEnderIOAddon) mod).getConfiguration(); if (configuration != null) { result.put(modContainer.getModId(), configuration); } } } return result; }
String apiVersionString = modContainer.getVersion(); if (apiVersionString == null) { apiVersionString = ""; if (modContainer.getModId() != null && modContainer.getModId().startsWith("EnderIOAPI")) { if (!EnderIOAPIProps.VERSION.equals(apiVersionString)) { result.add(" * Another mod is shipping a version of our API that doesn't match our version (" + apiVersionString + " from " + modContainer.getSource().getName() + "). That may not actually work."); } else if (modContainer.getSource().getName() != null && (!modContainer.getSource().getName().startsWith("EnderIO") && !modContainer.getSource().getName().startsWith("enderio") && !modContainer.getSource().getName().equals("bin"))) { result.add(" * Our API got loaded from " + modContainer.getSource().getName() + ". That's unexpected.");
/** * Basic version checker, support having different build number on each side * @param mods the data sent from FML handshake packet * @param remoteParty the side that sent this data * @return true if we allow this to run */ @NetworkCheckHandler public boolean checkRemote(Map<String,String> mods, Side remoteParty){ if(mods.containsKey(MODID)){ String remoteVersion = mods.get(MODID); if(remoteVersion!=null) { String internalVersion = FMLCommonHandler.instance().findContainerFor(this).getVersion(); if(remoteVersion.equals(internalVersion)) return true; else{ internalVersion = internalVersion.substring(0, internalVersion.lastIndexOf(".")); remoteVersion = remoteVersion.substring(0, remoteVersion.lastIndexOf(".")); return remoteVersion.equals(internalVersion); } } } return false; } }
ProgressManager.ProgressBar bar2 = ProgressManager.push("Mod", modList.size()); for (ModContainer modContainer : modList) { bar2.step(modContainer.getName()); Object mod = modContainer.getMod(); if (mod instanceof IEnderIOAddon) { coreFiles.addAll(((IEnderIOAddon) mod).getRecipeFiles()); bar2 = ProgressManager.push("Mod", modList.size()); for (ModContainer modContainer : modList) { bar2.step(modContainer.getName()); Object mod = modContainer.getMod(); if (mod instanceof IEnderIOAddon) { ((IEnderIOAddon) mod).postRecipeRegistration();
public ResourceProxy() { super(Loader.instance().activeModContainer().getSource()); overrides.put("pack.mcmeta", "/proxypack.mcmeta"); }
@Override public void setupBlock(ModContainer container, String id, Class<? extends TileEntity> tileEntity, ItemBlock itemBlock) { this.modInstance = container.getMod(); if (tileEntity != null) { this.teClass = tileEntity; hasTileEntity = true; for (TileEntityCapability capability : TileEntityCapability.values()) if (capability.intf.isAssignableFrom(teClass)) teCapabilities.add(capability); } }
/** @reason Adds a list of mods which may have caused the crash to the report. */ @Inject(method = "populateEnvironment", at = @At("TAIL")) private void afterPopulateEnvironment(CallbackInfo ci) { systemDetailsCategory.addDetail("Suspected Mods", () -> { try { suspectedMods = ModIdentifier.identifyFromStacktrace(cause); String modListString = "Unknown"; List<String> modNames = new ArrayList<>(); for (ModContainer mod : suspectedMods) { modNames.add(mod.getName() + " (" + mod.getModId() + ")"); } if (!modNames.isEmpty()) { modListString = StringUtils.join(modNames, ", "); } return modListString; } catch (Throwable e) { return ExceptionUtils.getStackTrace(e).replace("\t", " "); } }); }
private void collectFilesFromModContainers(ASMDataTable table) { final File dummyEntry = new File("minecraft.jar"); // dummy entry comes from MCP container for (ModContainer c : Loader.instance().getModList()) { File f = c.getSource(); if (f != null && !f.equals(dummyEntry) && !f.isDirectory()) { FileMeta meta = getOrCreateData(f); meta.mods.put(c.getModId(), new ModMeta(c)); } } }
/** * Get's the owning mod instance. If none is set, Bookshelf will attempt to auto-get it * using Forge's loader. * * @return The owning mod's instance. */ public Object getModInstance () { if (this.modInstance == null) { Constants.LOG.error("Registry helper for " + this.modid + " requires a mod instance be set. Attempting to get instance with mod ID. Please ask the mod author to set this themselves."); for (final ModContainer container : Loader.instance().getActiveModList()) { if (this.modid.equalsIgnoreCase(container.getModId())) { this.modInstance = container.getMod(); break; } } } return this.modInstance; }
private void updateModInfo() { this.buttonUpdate.visible = false; this.modInfo = null; if (this.selected == -1) { return; } List<String> textList = new ArrayList<>(); this.buttonUpdate.visible = true; this.buttonUpdate.enabled = true; this.buttonUpdate.displayString = I18n.format("gui.llibrary.update"); UpdateContainer updateContainer = UpdateHandler.INSTANCE.getOutdatedModList().get(this.selected); textList.add(updateContainer.getModContainer().getName()); textList.add(I18n.format("gui.llibrary.currentVersion") + String.format(": %s", updateContainer.getModContainer().getVersion())); textList.add(I18n.format("gui.llibrary.latestVersion") + String.format(": %s", updateContainer.getLatestVersion().getVersionString())); textList.add(null); Collections.addAll(textList, UpdateHandler.INSTANCE.getChangelog(updateContainer, updateContainer.getLatestVersion())); this.modInfo = new ModUpdateEntryGUI(this, this.width - this.modList.getWidth() - 30, textList); }
@Override public boolean init() { List<ModContainer> modList = Loader.instance().getModList(); for (ModContainer mod : modList) { if (mod.getModId().equals("StorageDrawers")) { try { VersionRange validVersions = VersionRange.createFromVersionSpec("[1.7.8,)"); ArtifactVersion version = new DefaultArtifactVersion(mod.getVersion()); return validVersions.containsVersion(version); } catch (InvalidVersionSpecificationException e) { return false; } } } return false; }
public boolean isUpToDate() throws UnknownVersionFormatException { try{ String[] version_split = mc.getVersion().split("\\."); int[] version = new int[version_split.length]; for(int i = 0; i < version.length; i++){ version[i] = Integer.parseInt(version_split[i]); } Release thisVersion = new Release(Release.EnumReleaseType.Normal, null, version, null); return (thisVersion.compareTo(latest) >= 0); } catch(NumberFormatException e){ throw new UnknownVersionFormatException(); } } }
@SuppressWarnings("UnusedDeclaration") @EventHandler public void init(@SuppressWarnings("UnusedParameters") FMLInitializationEvent event) { ModContainer thisMod = Loader.instance().getIndexedModList().get(ModInfo.MODID); if(thisMod != null) { String fileName = thisMod.getSource().getName(); if(fileName.contains("-dev") || !fileName.contains(".jar")) { ModInfo.DEBUG_MODE = true; MinerLogger.debug("Enabling debug mode"); } } }