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


Java ServerData.getResourceMode方法代码示例

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


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

示例1: handleResourcePack

import net.minecraft.client.multiplayer.ServerData; //导入方法依赖的package包/类
public void handleResourcePack(SPacketResourcePackSend packetIn)
{
    final String s = packetIn.getURL();
    final String s1 = packetIn.getHash();

    if (this.validateResourcePackUrl(s))
    {
        if (s.startsWith("level://"))
        {
            String s2 = s.substring("level://".length());
            File file1 = new File(this.gameController.mcDataDir, "saves");
            File file2 = new File(file1, s2);

            if (file2.isFile())
            {
                this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
                Futures.addCallback(this.gameController.getResourcePackRepository().setResourcePackInstance(file2), this.createDownloadCallback());
            }
            else
            {
                this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
            }
        }
        else
        {
            ServerData serverdata = this.gameController.getCurrentServerData();

            if (serverdata != null && serverdata.getResourceMode() == ServerData.ServerResourceMode.ENABLED)
            {
                this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
                Futures.addCallback(this.gameController.getResourcePackRepository().downloadResourcePack(s, s1), this.createDownloadCallback());
            }
            else if (serverdata != null && serverdata.getResourceMode() != ServerData.ServerResourceMode.PROMPT)
            {
                this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.DECLINED));
            }
            else
            {
                this.gameController.addScheduledTask(new Runnable()
                {
                    public void run()
                    {
                        NetHandlerPlayClient.this.gameController.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback()
                        {
                            public void confirmClicked(boolean result, int id)
                            {
                                NetHandlerPlayClient.this.gameController = Minecraft.getMinecraft();
                                ServerData serverdata1 = NetHandlerPlayClient.this.gameController.getCurrentServerData();

                                if (result)
                                {
                                    if (serverdata1 != null)
                                    {
                                        serverdata1.setResourceMode(ServerData.ServerResourceMode.ENABLED);
                                    }

                                    NetHandlerPlayClient.this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
                                    Futures.addCallback(NetHandlerPlayClient.this.gameController.getResourcePackRepository().downloadResourcePack(s, s1), NetHandlerPlayClient.this.createDownloadCallback());
                                }
                                else
                                {
                                    if (serverdata1 != null)
                                    {
                                        serverdata1.setResourceMode(ServerData.ServerResourceMode.DISABLED);
                                    }

                                    NetHandlerPlayClient.this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.DECLINED));
                                }

                                ServerList.saveSingleServer(serverdata1);
                                NetHandlerPlayClient.this.gameController.displayGuiScreen((GuiScreen)null);
                            }
                        }, I18n.format("multiplayer.texturePrompt.line1", new Object[0]), I18n.format("multiplayer.texturePrompt.line2", new Object[0]), 0));
                    }
                });
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:80,代码来源:NetHandlerPlayClient.java


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