public FanModContainer(final String className, final ModCandidate container, final Map<String, Object> modDescriptor) { try { final Class<?> clazz = Class.forName(className); final Fan fan = clazz.getAnnotation(Fan.class); final Class<? extends FanDefaultModContainer> containerClass = (Class<? extends FanDefaultModContainer>)fan.container(); if (containerClass == FanDefaultModContainer.class) { this.mContainer = (T)new FanDefaultModContainer(this, clazz, fan, container, modDescriptor); } else { this.mContainer = (T)Creator.creator(containerClass).arg(FanModContainer.class, this).arg(Class.class, clazz).arg(Fan.class, fan).arg(ModCandidate.class, container).arg(Map.class, modDescriptor).build(); } ((FanDefaultModContainer)this.mContainer).registerFan(); } catch (Exception e) { throw new IllegalStateException(e); } }
public void sendToTable(ASMDataTable table, ModCandidate candidate) { for (ModAnnotation ma : annotations) { table.addASMData(candidate, ma.asmType.getClassName(), this.asmType.getClassName(), ma.member, ma.values); } }
public void registerContainerType(Type type, Class<? extends ModContainer> container) { try { Constructor<? extends ModContainer> constructor = container.getConstructor(new Class<?>[] { String.class, ModCandidate.class, Map.class }); modTypes.put(type, constructor); } catch (Exception e) { FMLLog.log(Level.ERROR, e, "Critical error : cannot register mod container type %s, it has an invalid constructor"); Throwables.propagate(e); } }
public ModContainer build(ASMModParser modParser, File modSource, ModCandidate container) { String className = modParser.getASMType().getClassName(); if (modParser.isBaseMod(container.getRememberedBaseMods()) && modClass.matcher(className).find()) { FMLLog.severe("Found a BaseMod type mod %s", className); FMLLog.severe("This will not be loaded and will be ignored. ModLoader mechanisms are no longer available."); } else if (modClass.matcher(className).find()) { FMLLog.fine("Identified a class %s following modloader naming convention but not directly a BaseMod or currently seen subclass", className); container.rememberModCandidateType(modParser); } else if (modParser.isBaseMod(container.getRememberedBaseMods())) { FMLLog.fine("Found a basemod %s of non-standard naming format", className); container.rememberBaseModType(className); } for (ModAnnotation ann : modParser.getAnnotations()) { if (modTypes.containsKey(ann.getASMType())) { FMLLog.fine("Identified a mod of type %s (%s) - loading", ann.getASMType(), className); try { return modTypes.get(ann.getASMType()).newInstance(className, container, ann.getValues()); } catch (Exception e) { FMLLog.log(Level.ERROR, e, "Unable to construct %s container", ann.getASMType().getClassName()); return null; } } } return null; }
public FMLModContainer(String className, ModCandidate container, Map<String,Object> modDescriptor) { this.className = className; this.source = container.getModContainer(); this.candidate = container; this.descriptor = modDescriptor; this.eventMethods = ArrayListMultimap.create(); this.modLanguage = (String) modDescriptor.get("modLanguage"); String languageAdapterType = (String)modDescriptor.get("modLanguageAdapter"); if (Strings.isNullOrEmpty(languageAdapterType)) { this.languageAdapter = "scala".equals(modLanguage) ? new ILanguageAdapter.ScalaAdapter() : new ILanguageAdapter.JavaAdapter(); } else { try { this.languageAdapter = (ILanguageAdapter)Class.forName(languageAdapterType, true, Loader.instance().getModClassLoader()).newInstance(); FMLLog.finer("Using custom language adapter %s (type %s) for %s (modid %s)", this.languageAdapter, languageAdapterType, this.className, getModId()); } catch (Exception ex) { FMLLog.log(Level.ERROR, ex, "Error constructing custom mod language adapter %s (referenced by %s) (modid: %s)", languageAdapterType, this.className, getModId()); throw new LoaderException(ex); } } }
public ModContainer build(ASMModParser modParser, File modSource, ModCandidate container) { String className = modParser.getASMType().getClassName(); if (modParser.isBaseMod(container.getRememberedBaseMods()) && modClass.matcher(className).find()) { FMLLog.severe("Found a BaseMod type mod %s", className); FMLLog.severe("This will not be loaded and will be ignored. ModLoader mechanisms are no longer available."); } else if (modClass.matcher(className).find()) { FMLLog.fine("Identified a class %s following modloader naming convention but not directly a BaseMod or currently seen subclass", className); container.rememberModCandidateType(modParser); } else if (modParser.isBaseMod(container.getRememberedBaseMods())) { FMLLog.fine("Found a basemod %s of non-standard naming format", className); container.rememberBaseModType(className); } // We warn if it's not a basemod instance -- compatibility requires it to be in net.minecraft.src *sigh* if (className.startsWith("net.minecraft.src.") && container.isClasspath() && !container.isMinecraftJar()) { FMLLog.severe("FML has detected a mod that is using a package name based on 'net.minecraft.src' : %s. This is generally a severe programming error. " + " There should be no mod code in the minecraft namespace. MOVE YOUR MOD! If you're in eclipse, select your source code and 'refactor' it into " + "a new package. Go on. DO IT NOW!",className); } for (ModAnnotation ann : modParser.getAnnotations()) { if (ann.getASMType().equals(Type.getType(Mod.class))) { FMLLog.fine("Identified an FMLMod type mod %s", className); return new FMLModContainer(className, container, ann.getValues()); } } return null; }
public FMLModContainer(String className, ModCandidate container, Map<String,Object> modDescriptor) { this.className = className; this.source = container.getModContainer(); this.candidate = container; this.descriptor = modDescriptor; this.modLanguage = (String) modDescriptor.get("modLanguage"); this.languageAdapter = "scala".equals(modLanguage) ? new ILanguageAdapter.ScalaAdapter() : new ILanguageAdapter.JavaAdapter(); this.eventMethods = ArrayListMultimap.create(); }
public void parseControllers(FMLPreInitializationEvent event) { if (init) return; init = true; ASMDataTable asmDataTable = event.getAsmData(); Set<ASMData> asmDataSet = asmDataTable.getAll(Controller.class.getName()); // Filters out all controller annotations and places them with their associated mod. for (ASMData data : asmDataSet) { ModCandidate candidate = data.getCandidate(); for (ModContainer modContainer : candidate.getContainedMods()) { String modId = modContainer.getModId(); if (!configMap.containsKey(modId)) configMap.put(modId, new ConfigData(modContainer, candidate.getClassList())); configMap.get(modId).addRoot(data); } } // Process all potential registrars first. for (ConfigData configValue : configMap.values()) if (configValue.isRegistrar) configValue.processIConfigRegistrar(this); processed = true; for (ConfigData configData : configMap.values()) { // Organise all sub-packages. configData.processRoots(); // Process all current classes associated with the ConfigContainer. configData.processConfigContainers(asmDataTable, annotationMap); } postProcessed = true; }
public ModContainer build(ASMModParser modParser, File modSource, ModCandidate container) { String className = modParser.getASMType().getClassName(); if (modParser.isBaseMod(container.getRememberedBaseMods()) && modClass.matcher(className).find()) { FMLLog.fine("Identified a BaseMod type mod %s", className); return new ModLoaderModContainer(className, modSource, modParser.getBaseModProperties()); } else if (modClass.matcher(className).find()) { FMLLog.fine("Identified a class %s following modloader naming convention but not directly a BaseMod or currently seen subclass", className); container.rememberModCandidateType(modParser); } else if (modParser.isBaseMod(container.getRememberedBaseMods())) { FMLLog.fine("Found a basemod %s of non-standard naming format", className); container.rememberBaseModType(className); } // We warn if it's not a basemod instance -- compatibility requires it to be in net.minecraft.src *sigh* if (className.startsWith("net.minecraft.src.") && container.isClasspath() && !container.isMinecraftJar()) { FMLLog.severe("FML has detected a mod that is using a package name based on 'net.minecraft.src' : %s. This is generally a severe programming error. " + " There should be no mod code in the minecraft namespace. MOVE YOUR MOD! If you're in eclipse, select your source code and 'refactor' it into " + "a new package. Go on. DO IT NOW!",className); } for (ModAnnotation ann : modParser.getAnnotations()) { if (ann.getASMType().equals(Type.getType(Mod.class))) { FMLLog.fine("Identified an FMLMod type mod %s", className); return new FMLModContainer(className, container, ann.getValues()); } } return null; }
public void preInit(final FMLPreInitializationEvent event) { LogHelper.info("Hello World", new Object[0]); this.loadTcon(); ExtraUtils.versionHash = event.getModMetadata().version.hashCode(); try { IEnergyHandler.class.getMethod("canConnectEnergy", ForgeDirection.class); for (final ModCandidate t : event.getAsmData().getCandidatesFor("cofh.api.energy")) { final boolean hasProperApi = false; if (t.getClassList().contains("cofh/api/energy/IEnergyHandler") && !t.getClassList().contains("cofh/api/energy/IEnergyConnection")) { for (final ModContainer mod : t.getContainedMods()) { LogHelper.info("" + mod.getModId() + " (" + mod.getName() + ") appears to be missing the updated COFH api", new Object[0]); } } } } catch (NoSuchMethodException e) { e.printStackTrace(); final List<ModContainer> suspects = new ArrayList<ModContainer>(); for (final ModCandidate t2 : event.getAsmData().getCandidatesFor("cofh.api.energy")) { final boolean hasProperApi2 = false; if (t2.getClassList().contains("cofh/api/energy/IEnergyHandler") && !t2.getClassList().contains("cofh/api/energy/IEnergyConnection")) { for (final ModContainer mod2 : t2.getContainedMods()) { LogHelper.info("" + mod2.getModId() + " (" + mod2.getName() + ") appears to be missing the updated COFH api", new Object[0]); } suspects.addAll(t2.getContainedMods()); } } final String[] data = new String[2 + suspects.size()]; data[0] = "Some mod is including a older or incorrect copy of the COFH energy api. This will lead to instability and Extra Utilities will not run properly. Possible candidates that do not include the proper api are..."; data[1] = ""; for (int i = 0; i < suspects.size(); ++i) { data[i + 1] = suspects.get(i).getModId(); } ExtraUtilsMod.proxy.throwLoadingError("COFH API Error", data); } final String networkPath = "com.rwtema.extrautils.network.packets."; for (final ModCandidate t3 : event.getAsmData().getCandidatesFor("com.rwtema.extrautils")) { for (String s : t3.getClassList()) { s = s.replace('/', '.'); if (s.startsWith(networkPath)) { try { Class<?> clazz = Class.forName(s); if (XUPacketBase.class.isAssignableFrom(clazz)) { PacketCodec.addClass(clazz); } else { clazz = clazz; } } catch (ClassNotFoundException e2) { throw new RuntimeException("Presented class missing, FML Bug?", e2); } catch (NoClassDefFoundError e3) { LogHelper.error(s + " can't be created", new Object[0]); throw new RuntimeException(e3); } } } } NetworkHandler.register(); try { World.class.getMethod("getBlock", Integer.TYPE, Integer.TYPE, Integer.TYPE); XUHelper.deObf = true; LogHelper.info("Dev Enviroment detected. Releasing hounds...", new Object[0]); } catch (NoSuchMethodException e4) { XUHelper.deObf = false; } catch (SecurityException e5) { XUHelper.deObf = false; } this.setupConfigs(event.getSuggestedConfigurationFile()); ExtraUtils.creativeTabExtraUtils = new CreativeTabExtraUtils("extraUtil"); this.registerStuff(); this.registerRecipes(); ExtraUtilsMod.proxy.registerClientCommands(); for (final ILoading loader : this.loaders) { loader.preInit(); } }
public FanEventHandler(final ModCandidate candidate, final ModContainer container, final Object mod, final Fan fan) { this.mCandidate = candidate; this.mContainer = container; this.mMod = mod; this.mFan = fan; }