本文整理汇总了Java中net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData.getClassName方法的典型用法代码示例。如果您正苦于以下问题:Java ASMData.getClassName方法的具体用法?Java ASMData.getClassName怎么用?Java ASMData.getClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData
的用法示例。
在下文中一共展示了ASMData.getClassName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInjectClass
import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData; //导入方法依赖的package包/类
private static String getInjectClass(String test, ASMData data, ClassLoader classLoader) throws Exception {
String className;
String methodName;
if (!test.equals("")) {
int index = test.lastIndexOf('.');
className = test.substring(0, index);
methodName = test.substring(index + 1);
} else {
className = data.getClassName();
methodName = "proxyCallback";
}
Class<?> clazz = Class.forName(className, true, classLoader);
for (Method method : clazz.getMethods()) {
if (method.getName().equals(methodName) && method.getReturnType().equals(String.class) && ReflectionManager.isStatic(method)) {
method.setAccessible(true);
return (String) method.invoke(null);
}
}
throw new RuntimeException(String.format("Unable to find static method with string return type! Method: %s.%s", className, methodName));
}
示例2: findSubscribers
import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData; //导入方法依赖的package包/类
@Nonnull
@Override
public Set<Pair<Object, Map<Class, Set<Method>>>> findSubscribers() {
SetMultimap<String, ASMData> allAnnotationsInContainer = asmTable.getAnnotationsFor(
Loader.instance().activeModContainer());
if (!allAnnotationsInContainer.containsKey(ForgepathHandler.class.getCanonicalName())) return NO_SUBSCRIBERS;
Set<ASMData> asmDataSet = allAnnotationsInContainer.get(ForgepathHandler.class.getName());
// Goddamnit Java and your stupidly long types
ImmutableSet.Builder<Pair<Object, Map<Class, Set<Method>>>> mapBuilder =
new ImmutableSet.Builder<Pair<Object, Map<Class, Set<Method>>>>();
for (ASMData asmData : asmDataSet) {
String cname = asmData.getClassName();
Object obj;
try {
obj = Class.forName(cname).newInstance();
} catch (Exception ex) {
continue; // SKIP!
}
Map<Class, Set<Method>> subscribers = innerLocator.findSubscribers(obj);
mapBuilder.add(new Pair<Object, Map<Class, Set<Method>>>(obj, subscribers));
}
return mapBuilder.build();
}
示例3: findTargets
import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData; //导入方法依赖的package包/类
private static void findTargets(ASMData target, Map<Field, Class<?>> classTargetToSource, Map<Field, Class<?>> fieldTargetToSource) {
final String targetClassName = target.getClassName();
final String targetObject = target.getObjectName();
final Type sourceClassName = (Type)target.getAnnotationInfo().get("value");
try {
final Class<?> targetClass = Class.forName(targetClassName);
final Class<?> sourceClass;
if (sourceClassName == null || sourceClassName.equals(USE_DECLARING_TYPE_MARKER))
sourceClass = targetClass;
else
sourceClass = Class.forName(sourceClassName.getClassName());
if (targetClassName.equals(targetObject))
addClassFields(classTargetToSource, targetClass, sourceClass);
else
addField(fieldTargetToSource, targetClass, targetObject, sourceClass);
} catch (Exception e) {
Log.warn(e, "Failed to fill type variable holder at %s:%s", targetClassName, targetObject);
}
}
示例4: fillTargetField
import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData; //导入方法依赖的package包/类
private static <A> void fillTargetField(ClassInfoCache clsCache, ApiProviderRegistry<A> registry, ASMData data, Class<A> interfaceMarker) {
final String targetClassName = data.getClassName();
final String targetObjectName = data.getObjectName();
final ClassInfo targetCls = clsCache.getOrCreate(targetClassName);
final Setter setter = targetCls.get(targetObjectName);
Preconditions.checkArgument(setter != null, "Entry '%s' in class '%s' is not valid target for API annotation", targetObjectName, targetClassName);
final Class<?> acceptedType = setter.getType();
Preconditions.checkState(interfaceMarker.isAssignableFrom(acceptedType), "Failed to set API object on %s:%s - invalid type, expected %s",
targetClassName, targetObjectName, interfaceMarker);
final Class<? extends A> castAcceptedType = acceptedType.asSubclass(interfaceMarker);
final A api = registry.getApi(castAcceptedType);
if (api != null) {
try {
setter.set(api);
} catch (Throwable t) {
throw new RuntimeException(String.format("Failed to set entry '%s' in class '%s'", targetObjectName, targetClassName), t);
}
Log.trace("Injecting instance of %s from mod %s to field %s:%s from file %s",
castAcceptedType,
Loader.instance().activeModContainer().getModId(),
targetClassName,
targetObjectName,
data.getCandidate().getModContainer());
} else {
Log.info("Can't set API field %s:%s - no API for type %s",
targetClassName, targetObjectName, castAcceptedType);
}
}
示例5: inject
import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData; //导入方法依赖的package包/类
public static void inject(ModContainer mod, ASMDataTable data, Side side, ILanguageAdapter languageAdapter)
{
FMLLog.fine("Attempting to inject @SidedProxy classes into %s", mod.getModId());
Set<ASMData> targets = data.getAnnotationsFor(mod).get(SidedProxy.class.getName());
ClassLoader mcl = Loader.instance().getModClassLoader();
for (ASMData targ : targets)
{
try
{
Class<?> proxyTarget = Class.forName(targ.getClassName(), true, mcl);
Field target = proxyTarget.getDeclaredField(targ.getObjectName());
if (target == null)
{
// Impossible?
FMLLog.severe("Attempted to load a proxy type into %s.%s but the field was not found", targ.getClassName(), targ.getObjectName());
throw new LoaderException(String.format("Attempted to load a proxy type into %s.%s but the field was not found", targ.getClassName(), targ.getObjectName()));
}
target.setAccessible(true);
SidedProxy annotation = target.getAnnotation(SidedProxy.class);
if (!Strings.isNullOrEmpty(annotation.modId()) && !annotation.modId().equals(mod.getModId()))
{
FMLLog.fine("Skipping proxy injection for %s.%s since it is not for mod %s", targ.getClassName(), targ.getObjectName(), mod.getModId());
continue;
}
String targetType = side.isClient() ? annotation.clientSide() : annotation.serverSide();
if(targetType.equals(""))
{
targetType = targ.getClassName() + (side.isClient() ? "$ClientProxy" : "$ServerProxy");
}
Object proxy=Class.forName(targetType, true, mcl).newInstance();
if (languageAdapter.supportsStatics() && (target.getModifiers() & Modifier.STATIC) == 0 )
{
FMLLog.severe("Attempted to load a proxy type %s into %s.%s, but the field is not static", targetType, targ.getClassName(), targ.getObjectName());
throw new LoaderException(String.format("Attempted to load a proxy type %s into %s.%s, but the field is not static", targetType, targ.getClassName(), targ.getObjectName()));
}
if (!target.getType().isAssignableFrom(proxy.getClass()))
{
FMLLog.severe("Attempted to load a proxy type %s into %s.%s, but the types don't match", targetType, targ.getClassName(), targ.getObjectName());
throw new LoaderException(String.format("Attempted to load a proxy type %s into %s.%s, but the types don't match", targetType, targ.getClassName(), targ.getObjectName()));
}
languageAdapter.setProxy(target, proxyTarget, proxy);
}
catch (Exception e)
{
FMLLog.log(Level.ERROR, e, "An error occurred trying to load a proxy into %s.%s", targ.getAnnotationInfo(), targ.getClassName(), targ.getObjectName());
throw new LoaderException(e);
}
}
// Allow language specific proxy injection.
languageAdapter.setInternalProxies(mod, side, mcl);
}