当前位置: 首页>>代码示例>>Java>>正文


Java Side.isClient方法代码示例

本文整理汇总了Java中net.minecraftforge.fml.relauncher.Side.isClient方法的典型用法代码示例。如果您正苦于以下问题:Java Side.isClient方法的具体用法?Java Side.isClient怎么用?Java Side.isClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.fml.relauncher.Side的用法示例。


在下文中一共展示了Side.isClient方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNetworkManager

import net.minecraftforge.fml.relauncher.Side; //导入方法依赖的package包/类
/**
 * This will return the NetworkManager for the given side.
 * @param side the side to get the NetworkManager for.
 * @return The NetworkManager for the given side.
 */
public static INetworkManager getNetworkManager(Side side) {
	if (side.isClient()) {
		return clientInstance;
	}
	else {
		return serverInstance;
	}
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:14,代码来源:NetworkHelper.java

示例2: drawRAM

import net.minecraftforge.fml.relauncher.Side; //导入方法依赖的package包/类
private void drawRAM(ArrayList<String> list, Side side)
{
    int max;
    int total;
    int free;
    if (side.isClient())
    {
        list.add("Client");
        max = (int) (Runtime.getRuntime().maxMemory() / 1024 / 1024);
        total = (int) (Runtime.getRuntime().totalMemory() / 1024 / 1024);
        free = (int) (Runtime.getRuntime().freeMemory() / 1024 / 1024);
    }
    else
    {
        max = this.max;
        total = this.total;
        free = this.free;
        if (dims == null)
        {
            list.add("No server RAM data :(");
            return;
        }
        list.add("Server");
    }

    int diff = total - free;
    list.add(String.format("Mem: % 2d%% %03d/%03dMB", diff * 100 / max, diff, max));
    list.add(String.format("Allocated: % 2d%% %03dMB", total * 100 / max, total));
}
 
开发者ID:dries007,项目名称:DebugServerInfo,代码行数:30,代码来源:ClientProxy.java

示例3: setInternalProxies

import net.minecraftforge.fml.relauncher.Side; //导入方法依赖的package包/类
@Override
public void setInternalProxies(ModContainer mod, Side side, ClassLoader loader)
{
    // For Scala mods, we want to enable authors to write them like so:
    // object ModName {
    //   @SidedProxy(...)
    //   var proxy: ModProxy = null
    // }
    // For this to work, we have to search inside the inner class Scala
    // generates for singletons, which is in called ModName$. These are
    // not automatically handled, because the mod discovery code ignores
    // internal classes.
    // Note that it is alternatively possible to write this like so:
    // class ModName {
    //   @SidedProxy(...)
    //   var proxy: ModProxy = null
    // }
    // object ModName extends ModName { ... }
    // which will fall back to the normal injection code which calls
    // setProxy in turn.

    // Get the actual mod implementation, which will be the inner class
    // if we have a singleton.
    Class<?> proxyTarget = mod.getMod().getClass();
    if (proxyTarget.getName().endsWith("$"))
    {
        // So we have a singleton class, check if there are targets.
        for (Field target : proxyTarget.getDeclaredFields())
        {
            // This will not turn up anything if the alternative
            // approach was taken (manually declaring the class).
            // So we don't initialize the field twice.
            if (target.getAnnotation(SidedProxy.class) != null)
            {
                String targetType = side.isClient() ? target.getAnnotation(SidedProxy.class).clientSide() : target.getAnnotation(SidedProxy.class).serverSide();
                try
                {
                    Object proxy = Class.forName(targetType, true, loader).newInstance();

                    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, proxyTarget.getSimpleName(), target.getName());
                        throw new LoaderException(String.format("Attempted to load a proxy type %s into %s.%s, but the types don't match", targetType, proxyTarget.getSimpleName(), target.getName()));
                    }

                    setProxy(target, proxyTarget, proxy);
                }
                catch (Exception e) {
                    FMLLog.log(Level.ERROR, e, "An error occurred trying to load a proxy into %s.%s", proxyTarget.getSimpleName(), target.getName());
                    throw new LoaderException(e);
                }
            }
        }
    }
    else
    {
        FMLLog.finer("Mod does not appear to be a singleton.");
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:60,代码来源:ILanguageAdapter.java

示例4: inject

import net.minecraftforge.fml.relauncher.Side; //导入方法依赖的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);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:56,代码来源:ProxyInjector.java


注:本文中的net.minecraftforge.fml.relauncher.Side.isClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。