public InventoryTweaksModule() { try { this.api = (InvTweaksAPI) Class.forName( "invtweaks.forge.InvTweaksMod", true, Loader.instance().getModClassLoader() ) .getField( "instance" ) .get( null ); } catch( Exception ex ) { } }
public GridSorterInventoryTweaks() { try { api = (InvTweaksAPI) Class.forName("invtweaks.forge.InvTweaksMod", true, Loader.instance().getModClassLoader()).getField("instance").get(null); } catch (Exception e) { // NO OP } }
public void injectConfig(ModContainer mod, ASMDataTable data) { SetMultimap<String, ASMDataTable.ASMData> annotations = data.getAnnotationsFor(mod); if (annotations != null) { Set<ASMDataTable.ASMData> targetList = annotations.get(Config.class.getName()); ClassLoader classLoader = Loader.instance().getModClassLoader(); for (ASMDataTable.ASMData target : targetList) { try { Class<?> targetClass = Class.forName(target.getClassName(), true, classLoader); Field field = targetClass.getDeclaredField(target.getObjectName()); field.setAccessible(true); Class<?> configClass = field.getType(); File configFile = new File(".", "config" + File.separator + mod.getModId() + ".cfg"); field.set(null, this.registerConfig(mod, configFile, configClass.newInstance())); } catch (Exception e) { LLibrary.LOGGER.fatal("Failed to inject config for mod container " + mod, e); } } } }
public void injectNetworkWrapper(ModContainer mod, ASMDataTable data) { SetMultimap<String, ASMDataTable.ASMData> annotations = data.getAnnotationsFor(mod); if (annotations != null) { Set<ASMDataTable.ASMData> targetList = annotations.get(NetworkWrapper.class.getName()); ClassLoader classLoader = Loader.instance().getModClassLoader(); for (ASMDataTable.ASMData target : targetList) { try { Class<?> targetClass = Class.forName(target.getClassName(), true, classLoader); Field field = targetClass.getDeclaredField(target.getObjectName()); field.setAccessible(true); NetworkWrapper annotation = field.getAnnotation(NetworkWrapper.class); SimpleNetworkWrapper networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel(mod.getModId()); field.set(null, networkWrapper); for (Class messageClass : annotation.value()) { this.registerMessage(networkWrapper, messageClass); } } catch (Exception e) { LLibrary.LOGGER.fatal("Failed to inject network wrapper for mod container " + mod, e); } } } } }