Search in sources :

Example 1 with GuiScreenWorking

use of net.minecraft.client.gui.GuiScreenWorking in project UtilityClient2 by Utility-Client.

the class ResourcePackRepository method downloadResourcePack.

public ListenableFuture<Object> downloadResourcePack(String url, String hash) {
    String s;
    if (hash.matches("^[a-f0-9]{40}$")) {
        s = hash;
    } else {
        s = "legacy";
    }
    final File file1 = new File(this.dirServerResourcepacks, s);
    this.lock.lock();
    try {
        this.func_148529_f();
        if (file1.exists() && hash.length() == 40) {
            try {
                String s1 = Hashing.sha1().hashBytes(Files.toByteArray(file1)).toString();
                if (s1.equals(hash)) {
                    ListenableFuture listenablefuture1 = this.setResourcePackInstance(file1);
                    return listenablefuture1;
                }
                logger.warn("File " + file1 + " had wrong hash (expected " + hash + ", found " + s1 + "). Deleting it.");
                FileUtils.deleteQuietly(file1);
            } catch (IOException ioexception) {
                logger.warn((String) ("File " + file1 + " couldn\'t be hashed. Deleting it."), (Throwable) ioexception);
                FileUtils.deleteQuietly(file1);
            }
        }
        this.func_183028_i();
        final GuiScreenWorking guiscreenworking = new GuiScreenWorking();
        Map<String, String> map = Minecraft.getSessionInfo();
        final Minecraft minecraft = Minecraft.getMinecraft();
        Futures.getUnchecked(minecraft.addScheduledTask(new Runnable() {

            public void run() {
                minecraft.displayGuiScreen(guiscreenworking);
            }
        }));
        final SettableFuture<Object> settablefuture = SettableFuture.<Object>create();
        this.field_177322_i = HttpUtil.downloadResourcePack(file1, url, map, 52428800, guiscreenworking, minecraft.getProxy());
        Futures.addCallback(this.field_177322_i, new FutureCallback<Object>() {

            public void onSuccess(Object p_onSuccess_1_) {
                ResourcePackRepository.this.setResourcePackInstance(file1);
                settablefuture.set((Object) null);
            }

            public void onFailure(Throwable p_onFailure_1_) {
                settablefuture.setException(p_onFailure_1_);
            }
        });
        ListenableFuture listenablefuture = this.field_177322_i;
        return listenablefuture;
    } finally {
        this.lock.unlock();
    }
}
Also used : ListenableFuture(com.google.common.util.concurrent.ListenableFuture) IOException(java.io.IOException) File(java.io.File) Minecraft(net.minecraft.client.Minecraft) GuiScreenWorking(net.minecraft.client.gui.GuiScreenWorking)

Example 2 with GuiScreenWorking

use of net.minecraft.client.gui.GuiScreenWorking in project clientcommands by Earthcomputer.

the class ServerConnectorCVW method connect.

@Override
public void connect() {
    Minecraft mc = Minecraft.getMinecraft();
    mc.loadWorld(null);
    System.gc();
    YggdrasilAuthenticationService authService = new YggdrasilAuthenticationService(mc.getProxy(), UUID.randomUUID().toString());
    MinecraftSessionService sessionService = authService.createMinecraftSessionService();
    GameProfileRepository profileRepo = authService.createProfileRepository();
    PlayerProfileCache profileCache = new PlayerProfileCache(profileRepo, new File(mc.mcDataDir, MinecraftServer.USER_CACHE_FILE.getName()));
    TileEntitySkull.setProfileCache(profileCache);
    TileEntitySkull.setSessionService(sessionService);
    PlayerProfileCache.setOnlineMode(false);
    mc.integratedServer = new ClientVirtualServer(mc, dimensionId, gameType, previousServer, chunks, playerTag, authService, sessionService, profileRepo, profileCache);
    mc.getIntegratedServer().startServerThread();
    mc.integratedServerIsRunning = true;
    mc.loadingScreen.displaySavingString(I18n.format("menu.loadingLevel"));
    while (!mc.getIntegratedServer().serverIsInRunLoop()) {
        if (!StartupQuery.check()) {
            mc.loadWorld(null);
            mc.displayGuiScreen(null);
            return;
        }
        String message = mc.getIntegratedServer().getUserMessage();
        if (message != null) {
            mc.loadingScreen.displayLoadingString(I18n.format(message));
        } else {
            mc.loadingScreen.displayLoadingString("");
        }
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
        // ignore
        }
    }
    mc.displayGuiScreen(new GuiScreenWorking());
    SocketAddress socketAddress = mc.getIntegratedServer().getNetworkSystem().addLocalEndpoint();
    NetworkManager netManager = NetworkManager.provideLocalClient(socketAddress);
    netManager.setNetHandler(new NetHandlerLoginClient(netManager, mc, null));
    netManager.sendPacket(new C00Handshake(socketAddress.toString(), 0, EnumConnectionState.LOGIN, true));
    GameProfile gameProfile = mc.getSession().getProfile();
    if (!mc.getSession().hasCachedProperties()) {
        gameProfile = mc.getSessionService().fillProfileProperties(gameProfile, true);
        mc.getSession().setProperties(gameProfile.getProperties());
    }
    netManager.sendPacket(new CPacketLoginStart(gameProfile));
    mc.myNetworkManager = netManager;
}
Also used : PlayerProfileCache(net.minecraft.server.management.PlayerProfileCache) GameProfileRepository(com.mojang.authlib.GameProfileRepository) MinecraftSessionService(com.mojang.authlib.minecraft.MinecraftSessionService) Minecraft(net.minecraft.client.Minecraft) CPacketLoginStart(net.minecraft.network.login.client.CPacketLoginStart) NetHandlerLoginClient(net.minecraft.client.network.NetHandlerLoginClient) GameProfile(com.mojang.authlib.GameProfile) C00Handshake(net.minecraft.network.handshake.client.C00Handshake) YggdrasilAuthenticationService(com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService) SocketAddress(java.net.SocketAddress) NetworkManager(net.minecraft.network.NetworkManager) File(java.io.File) GuiScreenWorking(net.minecraft.client.gui.GuiScreenWorking)

Aggregations

File (java.io.File)2 Minecraft (net.minecraft.client.Minecraft)2 GuiScreenWorking (net.minecraft.client.gui.GuiScreenWorking)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 GameProfile (com.mojang.authlib.GameProfile)1 GameProfileRepository (com.mojang.authlib.GameProfileRepository)1 MinecraftSessionService (com.mojang.authlib.minecraft.MinecraftSessionService)1 YggdrasilAuthenticationService (com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService)1 IOException (java.io.IOException)1 SocketAddress (java.net.SocketAddress)1 NetHandlerLoginClient (net.minecraft.client.network.NetHandlerLoginClient)1 NetworkManager (net.minecraft.network.NetworkManager)1 C00Handshake (net.minecraft.network.handshake.client.C00Handshake)1 CPacketLoginStart (net.minecraft.network.login.client.CPacketLoginStart)1 PlayerProfileCache (net.minecraft.server.management.PlayerProfileCache)1