QuickPlay.java
net.minecraft.client.quickplay.QuickPlay
信息
- 全限定名:net.minecraft.client.quickplay.QuickPlay
- 类型:public class
- 包:net.minecraft.client.quickplay
- 源码路径:src/main/java/net/minecraft/client/quickplay/QuickPlay.java
- 起始行号:L35
- 职责:
TODO
字段/常量
-
LOGGER- 类型:
Logger - 修饰符:
private static final - 源码定位:
L36 - 说明:
TODO
- 类型:
-
ERROR_TITLE- 类型:
Component - 修饰符:
public static final - 源码定位:
L37 - 说明:
TODO
- 类型:
-
INVALID_IDENTIFIER- 类型:
Component - 修饰符:
private static final - 源码定位:
L38 - 说明:
TODO
- 类型:
-
REALM_CONNECT- 类型:
Component - 修饰符:
private static final - 源码定位:
L39 - 说明:
TODO
- 类型:
-
REALM_PERMISSION- 类型:
Component - 修饰符:
private static final - 源码定位:
L40 - 说明:
TODO
- 类型:
-
TO_TITLE- 类型:
Component - 修饰符:
private static final - 源码定位:
L41 - 说明:
TODO
- 类型:
-
TO_WORLD_LIST- 类型:
Component - 修饰符:
private static final - 源码定位:
L42 - 说明:
TODO
- 类型:
-
TO_REALMS_LIST- 类型:
Component - 修饰符:
private static final - 源码定位:
L43 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static void connect(Minecraft minecraft, GameConfig.QuickPlayVariant quickPlayVariant, RealmsClient realmsClient) @ L45
- 方法名:connect
- 源码定位:L45
- 返回类型:void
- 修饰符:public static
参数:
- minecraft: Minecraft
- quickPlayVariant: GameConfig.QuickPlayVariant
- realmsClient: RealmsClient
说明:
TODO
private static String getLatestSingleplayerWorld(LevelStorageSource levelSource) @ L75
- 方法名:getLatestSingleplayerWorld
- 源码定位:L75
- 返回类型:String
- 修饰符:private static
参数:
- levelSource: LevelStorageSource
说明:
TODO
private static void joinSingleplayerWorld(Minecraft minecraft, String identifier) @ L90
- 方法名:joinSingleplayerWorld
- 源码定位:L90
- 返回类型:void
- 修饰符:private static
参数:
- minecraft: Minecraft
- identifier: String
说明:
TODO
private static void joinMultiplayerWorld(Minecraft minecraft, String serverAddressString) @ L99
- 方法名:joinMultiplayerWorld
- 源码定位:L99
- 返回类型:void
- 修饰符:private static
参数:
- minecraft: Minecraft
- serverAddressString: String
说明:
TODO
private static void joinRealmsWorld(Minecraft minecraft, RealmsClient realmsClient, String identifier) @ L113
- 方法名:joinRealmsWorld
- 源码定位:L113
- 返回类型:void
- 修饰符:private static
参数:
- minecraft: Minecraft
- realmsClient: RealmsClient
- identifier: String
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class QuickPlay {
private static final Logger LOGGER = LogUtils.getLogger();
public static final Component ERROR_TITLE = Component.translatable("quickplay.error.title");
private static final Component INVALID_IDENTIFIER = Component.translatable("quickplay.error.invalid_identifier");
private static final Component REALM_CONNECT = Component.translatable("quickplay.error.realm_connect");
private static final Component REALM_PERMISSION = Component.translatable("quickplay.error.realm_permission");
private static final Component TO_TITLE = Component.translatable("gui.toTitle");
private static final Component TO_WORLD_LIST = Component.translatable("gui.toWorld");
private static final Component TO_REALMS_LIST = Component.translatable("gui.toRealms");
public static void connect(Minecraft minecraft, GameConfig.QuickPlayVariant quickPlayVariant, RealmsClient realmsClient) {
if (!quickPlayVariant.isEnabled()) {
LOGGER.error("Quick play disabled");
minecraft.setScreen(new TitleScreen());
} else {
switch (quickPlayVariant) {
case GameConfig.QuickPlayMultiplayerData multiplayerData:
joinMultiplayerWorld(minecraft, multiplayerData.serverAddress());
break;
case GameConfig.QuickPlayRealmsData realmsData:
joinRealmsWorld(minecraft, realmsClient, realmsData.realmId());
break;
case GameConfig.QuickPlaySinglePlayerData singlePlayerData:
String worldId = singlePlayerData.worldId();
if (StringUtil.isBlank(worldId)) {
worldId = getLatestSingleplayerWorld(minecraft.getLevelSource());
}
joinSingleplayerWorld(minecraft, worldId);
break;
case GameConfig.QuickPlayDisabled disabled:
LOGGER.error("Quick play disabled");
minecraft.setScreen(new TitleScreen());
break;
default:
throw new MatchException(null, null);
}
}
}
private static @Nullable String getLatestSingleplayerWorld(LevelStorageSource levelSource) {
try {
List<LevelSummary> levels = levelSource.loadLevelSummaries(levelSource.findLevelCandidates()).get();
if (levels.isEmpty()) {
LOGGER.warn("no latest singleplayer world found");
return null;
} else {
return levels.getFirst().getLevelId();
}
} catch (ExecutionException | InterruptedException var2) {
LOGGER.error("failed to load singleplayer world summaries", (Throwable)var2);
return null;
}
}
private static void joinSingleplayerWorld(Minecraft minecraft, @Nullable String identifier) {
if (!StringUtil.isBlank(identifier) && minecraft.getLevelSource().levelExists(identifier)) {
minecraft.createWorldOpenFlows().openWorld(identifier, () -> minecraft.setScreen(new TitleScreen()));
} else {
Screen parent = new SelectWorldScreen(new TitleScreen());
minecraft.setScreen(new DisconnectedScreen(parent, ERROR_TITLE, INVALID_IDENTIFIER, TO_WORLD_LIST));
}
}
private static void joinMultiplayerWorld(Minecraft minecraft, String serverAddressString) {
ServerList servers = new ServerList(minecraft);
servers.load();
ServerData serverData = servers.get(serverAddressString);
if (serverData == null) {
serverData = new ServerData(I18n.get("selectServer.defaultName"), serverAddressString, ServerData.Type.OTHER);
servers.add(serverData, true);
servers.save();
}
ServerAddress serverAddress = ServerAddress.parseString(serverAddressString);
ConnectScreen.startConnecting(new JoinMultiplayerScreen(new TitleScreen()), minecraft, serverAddress, serverData, true, null);
}
private static void joinRealmsWorld(Minecraft minecraft, RealmsClient realmsClient, String identifier) {
long realmId;
RealmsServerList realmsServerList;
try {
realmId = Long.parseLong(identifier);
realmsServerList = realmsClient.listRealms();
} catch (NumberFormatException var8) {
Screen parent = new RealmsMainScreen(new TitleScreen());
minecraft.setScreen(new DisconnectedScreen(parent, ERROR_TITLE, INVALID_IDENTIFIER, TO_REALMS_LIST));
return;
} catch (RealmsServiceException var9) {
Screen parentx = new TitleScreen();
minecraft.setScreen(new DisconnectedScreen(parentx, ERROR_TITLE, REALM_CONNECT, TO_TITLE));
return;
}
RealmsServer server = realmsServerList.servers().stream().filter(realmsServer -> realmsServer.id == realmId).findFirst().orElse(null);
if (server == null) {
Screen parent = new RealmsMainScreen(new TitleScreen());
minecraft.setScreen(new DisconnectedScreen(parent, ERROR_TITLE, REALM_PERMISSION, TO_REALMS_LIST));
} else {
TitleScreen titleScreen = new TitleScreen();
minecraft.setScreen(new RealmsLongRunningMcoTaskScreen(titleScreen, new GetServerDetailsTask(titleScreen, server)));
}
}
}引用的其他类
-
- 引用位置:
构造调用 - 关联成员:
RealmsMainScreen()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
RealmsLongRunningMcoTaskScreen
- 引用位置:
构造调用 - 关联成员:
RealmsLongRunningMcoTaskScreen()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
GetServerDetailsTask()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ConnectScreen.startConnecting()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
DisconnectedScreen()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
TitleScreen()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
JoinMultiplayerScreen()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
SelectWorldScreen()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
ServerData()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
ServerList()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ServerAddress.parseString()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
I18n.get()
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Component.translatable()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
StringUtil.isBlank()
- 引用位置:
-
- 引用位置:
参数
- 引用位置: