本文整理了Java中net.minecraftforge.fml.common.Loader.getModClassLoader()
方法的一些代码示例,展示了Loader.getModClassLoader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Loader.getModClassLoader()
方法的具体详情如下:
包路径:net.minecraftforge.fml.common.Loader
类名称:Loader
方法名:getModClassLoader
暂无
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
public InventoryTweaksModule()
{
try
{
this.api = (InvTweaksAPI) Class.forName( "invtweaks.forge.InvTweaksMod", true, Loader.instance().getModClassLoader() )
.getField( "instance" )
.get( null );
}
catch( Exception ex )
{
}
}
代码示例来源:origin: raoulvdberge/refinedstorage
public GridSorterInventoryTweaks() {
try {
api = (InvTweaksAPI) Class.forName("invtweaks.forge.InvTweaksMod", true, Loader.instance().getModClassLoader()).getField("instance").get(null);
} catch (Exception e) {
// NO OP
}
}
代码示例来源:origin: iLexiconn/LLibrary
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);
}
}
}
}
代码示例来源:origin: iLexiconn/LLibrary
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);
}
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!