本文整理汇总了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));
}
});
}
}
}
}