Minecraft .java

net.minecraft.client.Minecraft (class): members: addGraphicsAndWorldToCrashReport, standardGalacticFontRenderer, getBlockRendererDispatcher, timer, debug.

net.minecraft.clientclass3,324 linesclient127.8 KB

Implements

API Surface (96)

void run()
String formatString(String str)
Framebuffer getFramebuffer()
String getVersion()
void run()
void crashed(CrashReport crash)
void displayCrashReport(CrashReport crashReportIn)
boolean isUnicode()
void refreshResources()
void draw(int posX, int posY, int texU, int texV, int width, int height, int red, int green, int blue, int alpha)
ISaveFormat getSaveLoader()
void displayGuiScreen(GuiScreen guiScreenIn)
void shutdownMinecraftApplet()
void updateDisplay()
void checkWindowResize()
int getLimitFramerate()
boolean isFramerateLimitBelowMax()
void freeMemory()
void shutdown()
void setIngameFocus()
void setIngameNotInFocus()
void displayInGameMenu()
void toggleFullscreen()
MusicTicker getMusicTicker()
void runTick()
String call()
String call()
void launchIntegratedServer(String folderName, String worldName, WorldSettings worldSettingsIn)
void loadWorld(WorldClient worldClientIn)
void loadWorld(WorldClient worldClientIn, String loadingMessage)
void setDimensionAndSpawnPlayer(int dimension)
boolean isDemo()
NetHandlerPlayClient getNetHandler()
boolean isGuiEnabled()
boolean isFancyGraphicsEnabled()
boolean isAmbientOcclusionEnabled()
CrashReport addGraphicsAndWorldToCrashReport(CrashReport theCrash)
String call()
String call()
String call()
String call()
String call()
String call()
String call()
String call()
String call()
String call()
String call()
Minecraft getMinecraft()
ListenableFuture<Object> scheduleResourcesRefresh()
void run()
void addServerStatsToSnooper(PlayerUsageSnooper playerSnooper)
void addServerTypeToSnooper(PlayerUsageSnooper playerSnooper)
int getGLMaximumTextureSize()
boolean isSnooperEnabled()
void setServerData(ServerData serverDataIn)
ServerData getCurrentServerData()
boolean isIntegratedServerRunning()
boolean isSingleplayer()
IntegratedServer getIntegratedServer()
void stopIntegratedServer()
PlayerUsageSnooper getPlayerUsageSnooper()
long getSystemTime()
boolean isFullScreen()
Session getSession()
PropertyMap getTwitchDetails()
PropertyMap getProfileProperties()
Proxy getProxy()
TextureManager getTextureManager()
IResourceManager getResourceManager()
ResourcePackRepository getResourcePackRepository()
LanguageManager getLanguageManager()
TextureMap getTextureMapBlocks()
boolean isJava64bit()
boolean isGamePaused()
SoundHandler getSoundHandler()
MusicTicker.MusicType getAmbientMusicType()
IStream getTwitchStream()
void dispatchKeypresses()
void confirmClicked(boolean result, int id)
MinecraftSessionService getSessionService()
SkinManager getSkinManager()
Entity getRenderViewEntity()
void setRenderViewEntity(Entity viewingEntity)
<V> ListenableFuture<V> addScheduledTask(Callable<V> callableToSchedule)
ListenableFuture<Object> addScheduledTask(Runnable runnableToSchedule)
boolean isCallingFromMinecraftThread()
BlockRendererDispatcher getBlockRendererDispatcher()
RenderManager getRenderManager()
RenderItem getRenderItem()
ItemRenderer getItemRenderer()
int getDebugFPS()
FrameTimer getFrameTimer()
Map<String, String> getSessionInfo()
boolean isConnectedToRealms()
void setConnectedToRealms(boolean isConnected)

Fields & Constants (96)

logger
locationMojangPng
isRunningOnMac
macDisplayModes
memoryReserve
fileResourcepacks
twitchDetails
profileProperties
currentServerData
renderEngine
theMinecraft
playerController
fullscreen
enableGLErrorChecking
hasCrashed
crashReporter
displayWidth
displayHeight
connectedToRealms
timer
usageSnooper
theWorld
renderGlobal
renderManager
renderItem
itemRenderer
thePlayer
renderViewEntity

…and 68 more (see full source).

String literals (224)

"textures/gui/title/mojang.png"
"client"
"root"
"Setting user: "
"(Session ID is "
"Initializing game"
"Initialization"
"Reported exception thrown!"
"Unexpected error"
"Unreported exception thrown!"
"LWJGL Version: "
"server-resource-packs"
"skins"
"saves"
"textures/font/ascii.png"
"textures/font/ascii_sga.png"
"Error: "
"Pre startup"
"Startup"
"textures"
"Post startup"
"twitch_access_token"
"Couldn\'t initialize twitch stream"
"Minecraft 1.8.9"

Code Graph: Dependencies (80)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

Minecraft.java3324 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client;
2
3
import com.google.common.collect.Iterables;
4
import com.google.common.collect.Lists;
5
import com.google.common.collect.Maps;
6
import com.google.common.collect.Queues;
7
import com.google.common.collect.Sets;
8
import com.google.common.util.concurrent.Futures;
9
import com.google.common.util.concurrent.ListenableFuture;
10
import com.google.common.util.concurrent.ListenableFutureTask;
11
import com.mojang.authlib.GameProfile;
12
import com.mojang.authlib.minecraft.MinecraftSessionService;
13
import com.mojang.authlib.properties.Property;
14
import com.mojang.authlib.properties.PropertyMap;
15
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
16
import java.awt.image.BufferedImage;
17
import java.io.File;
18
import java.io.IOException;
19
import java.io.InputStream;
20
import java.net.Proxy;
21
import java.net.SocketAddress;
22
import java.nio.ByteBuffer;
23
import java.nio.ByteOrder;
24
import java.text.DecimalFormat;
25
import java.text.SimpleDateFormat;
26
import java.util.Collections;
27
import java.util.Date;
28
import java.util.Iterator;
29
import java.util.List;
30
import java.util.Map;
31
import java.util.Queue;
32
import java.util.Set;
33
import java.util.UUID;
34
import java.util.concurrent.Callable;
35
import java.util.concurrent.Executors;
36
import java.util.concurrent.FutureTask;
37
import javax.imageio.ImageIO;
38
import net.minecraft.block.Block;
39
import net.minecraft.block.material.Material;
40
import net.minecraft.client.audio.MusicTicker;
41
import net.minecraft.client.audio.SoundHandler;
42
import net.minecraft.client.entity.EntityPlayerSP;
43
import net.minecraft.client.gui.FontRenderer;
44
import net.minecraft.client.gui.GuiChat;
45
import net.minecraft.client.gui.GuiControls;
46
import net.minecraft.client.gui.GuiGameOver;
47
import net.minecraft.client.gui.GuiIngame;
48
import net.minecraft.client.gui.GuiIngameMenu;
49
import net.minecraft.client.gui.GuiMainMenu;
50
import net.minecraft.client.gui.GuiMemoryErrorScreen;
51
import net.minecraft.client.gui.GuiScreen;
52
import net.minecraft.client.gui.GuiSleepMP;
53
import net.minecraft.client.gui.GuiYesNo;
54
import net.minecraft.client.gui.GuiYesNoCallback;
55
import net.minecraft.client.gui.ScaledResolution;
56
import net.minecraft.client.gui.achievement.GuiAchievement;
57
import net.minecraft.client.gui.inventory.GuiInventory;
58
import net.minecraft.client.gui.stream.GuiStreamUnavailable;
59
import net.minecraft.client.main.GameConfiguration;
60
import net.minecraft.client.multiplayer.GuiConnecting;
61
import net.minecraft.client.multiplayer.PlayerControllerMP;
62
import net.minecraft.client.multiplayer.ServerData;
63
import net.minecraft.client.multiplayer.WorldClient;
64
import net.minecraft.client.network.NetHandlerLoginClient;
65
import net.minecraft.client.network.NetHandlerPlayClient;
66
import net.minecraft.client.particle.EffectRenderer;
67
import net.minecraft.client.renderer.BlockRendererDispatcher;
68
import net.minecraft.client.renderer.EntityRenderer;
69
import net.minecraft.client.renderer.GlStateManager;
70
import net.minecraft.client.renderer.ItemRenderer;
71
import net.minecraft.client.renderer.OpenGlHelper;
72
import net.minecraft.client.renderer.RenderGlobal;
73
import net.minecraft.client.renderer.Tessellator;
74
import net.minecraft.client.renderer.WorldRenderer;
75
import net.minecraft.client.renderer.chunk.RenderChunk;
76
import net.minecraft.client.renderer.entity.RenderItem;
77
import net.minecraft.client.renderer.entity.RenderManager;
78
import net.minecraft.client.renderer.texture.DynamicTexture;
79
import net.minecraft.client.renderer.texture.TextureManager;
80
import net.minecraft.client.renderer.texture.TextureMap;
81
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
82
import net.minecraft.client.resources.DefaultResourcePack;
83
import net.minecraft.client.resources.FoliageColorReloadListener;
84
import net.minecraft.client.resources.GrassColorReloadListener;
85
import net.minecraft.client.resources.I18n;
86
import net.minecraft.client.resources.IReloadableResourceManager;
87
import net.minecraft.client.resources.IResourceManager;
88
import net.minecraft.client.resources.IResourcePack;
89
import net.minecraft.client.resources.LanguageManager;
90
import net.minecraft.client.resources.ResourceIndex;
91
import net.minecraft.client.resources.ResourcePackRepository;
92
import net.minecraft.client.resources.SimpleReloadableResourceManager;
93
import net.minecraft.client.resources.SkinManager;
94
import net.minecraft.client.resources.data.AnimationMetadataSection;
95
import net.minecraft.client.resources.data.AnimationMetadataSectionSerializer;
96
import net.minecraft.client.resources.data.FontMetadataSection;
97
import net.minecraft.client.resources.data.FontMetadataSectionSerializer;
98
import net.minecraft.client.resources.data.IMetadataSerializer;
99
import net.minecraft.client.resources.data.LanguageMetadataSection;
100
import net.minecraft.client.resources.data.LanguageMetadataSectionSerializer;
101
import net.minecraft.client.resources.data.PackMetadataSection;
102
import net.minecraft.client.resources.data.PackMetadataSectionSerializer;
103
import net.minecraft.client.resources.data.TextureMetadataSection;
104
import net.minecraft.client.resources.data.TextureMetadataSectionSerializer;
105
import net.minecraft.client.resources.model.ModelManager;
106
import net.minecraft.client.settings.GameSettings;
107
import net.minecraft.client.settings.KeyBinding;
108
import net.minecraft.client.shader.Framebuffer;
109
import net.minecraft.client.stream.IStream;
110
import net.minecraft.client.stream.NullStream;
111
import net.minecraft.client.stream.TwitchStream;
112
import net.minecraft.crash.CrashReport;
113
import net.minecraft.crash.CrashReportCategory;
114
import net.minecraft.entity.Entity;
115
import net.minecraft.entity.EntityLeashKnot;
116
import net.minecraft.entity.EntityList;
117
import net.minecraft.entity.boss.BossStatus;
118
import net.minecraft.entity.item.EntityArmorStand;
119
import net.minecraft.entity.item.EntityBoat;
120
import net.minecraft.entity.item.EntityItemFrame;
121
import net.minecraft.entity.item.EntityMinecart;
122
import net.minecraft.entity.item.EntityPainting;
123
import net.minecraft.entity.player.EntityPlayer;
124
import net.minecraft.entity.player.InventoryPlayer;
125
import net.minecraft.init.Bootstrap;
126
import net.minecraft.init.Items;
127
import net.minecraft.item.Item;
128
import net.minecraft.item.ItemBlock;
129
import net.minecraft.item.ItemStack;
130
import net.minecraft.nbt.NBTTagCompound;
131
import net.minecraft.nbt.NBTTagList;
132
import net.minecraft.nbt.NBTTagString;
133
import net.minecraft.network.EnumConnectionState;
134
import net.minecraft.network.NetworkManager;
135
import net.minecraft.network.handshake.client.C00Handshake;
136
import net.minecraft.network.login.client.C00PacketLoginStart;
137
import net.minecraft.network.play.client.C16PacketClientStatus;
138
import net.minecraft.profiler.IPlayerUsage;
139
import net.minecraft.profiler.PlayerUsageSnooper;
140
import net.minecraft.profiler.Profiler;
141
import net.minecraft.server.MinecraftServer;
142
import net.minecraft.server.integrated.IntegratedServer;
143
import net.minecraft.stats.AchievementList;
144
import net.minecraft.stats.IStatStringFormat;
145
import net.minecraft.stats.StatFileWriter;
146
import net.minecraft.tileentity.TileEntity;
147
import net.minecraft.util.BlockPos;
148
import net.minecraft.util.ChatComponentText;
149
import net.minecraft.util.FrameTimer;
150
import net.minecraft.util.IThreadListener;
151
import net.minecraft.util.MathHelper;
152
import net.minecraft.util.MinecraftError;
153
import net.minecraft.util.MouseHelper;
154
import net.minecraft.util.MovementInputFromOptions;
155
import net.minecraft.util.MovingObjectPosition;
156
import net.minecraft.util.ReportedException;
157
import net.minecraft.util.ResourceLocation;
158
import net.minecraft.util.ScreenShotHelper;
159
import net.minecraft.util.Session;
160
import net.minecraft.util.Timer;
161
import net.minecraft.util.Util;
162
import net.minecraft.world.EnumDifficulty;
163
import net.minecraft.world.WorldProviderEnd;
164
import net.minecraft.world.WorldProviderHell;
165
import net.minecraft.world.WorldSettings;
166
import net.minecraft.world.chunk.storage.AnvilSaveConverter;
167
import net.minecraft.world.storage.ISaveFormat;
168
import net.minecraft.world.storage.ISaveHandler;
169
import net.minecraft.world.storage.WorldInfo;
170
import org.apache.commons.io.IOUtils;
171
import org.apache.commons.lang3.Validate;
172
import org.apache.logging.log4j.LogManager;
173
import org.apache.logging.log4j.Logger;
174
import org.lwjgl.LWJGLException;
175
import org.lwjgl.Sys;
176
import org.lwjgl.input.Keyboard;
177
import org.lwjgl.input.Mouse;
178
import org.lwjgl.opengl.ContextCapabilities;
179
import org.lwjgl.opengl.Display;
180
import org.lwjgl.opengl.DisplayMode;
181
import org.lwjgl.opengl.GL11;
182
import org.lwjgl.opengl.GL20;
183
import org.lwjgl.opengl.GLContext;
184
import org.lwjgl.opengl.OpenGLException;
185
import org.lwjgl.opengl.PixelFormat;
186
import org.lwjgl.util.glu.GLU;
187
188
public class Minecraft implements IThreadListener, IPlayerUsage
189
{
190
    private static final Logger logger = LogManager.getLogger();
191
    private static final ResourceLocation locationMojangPng = new ResourceLocation("textures/gui/title/mojang.png");
192
    public static final boolean isRunningOnMac = Util.getOSType() == Util.EnumOS.OSX;
193
194
    /** A 10MiB preallocation to ensure the heap is reasonably sized. */
195
    public static byte[] memoryReserve = new byte[10485760];
196
    private static final List<DisplayMode> macDisplayModes = Lists.newArrayList(new DisplayMode[] {new DisplayMode(2560, 1600), new DisplayMode(2880, 1800)});
197
    private final File fileResourcepacks;
198
    private final PropertyMap twitchDetails;
199
200
    /** The player's GameProfile properties */
201
    private final PropertyMap profileProperties;
202
    private ServerData currentServerData;
203
204
    /** The RenderEngine instance used by Minecraft */
205
    private TextureManager renderEngine;
206
207
    /**
208
     * Set to 'this' in Minecraft constructor; used by some settings get methods
209
     */
210
    private static Minecraft theMinecraft;
211
    public PlayerControllerMP playerController;
212
    private boolean fullscreen;
213
    private boolean enableGLErrorChecking = true;
214
    private boolean hasCrashed;
215
216
    /** Instance of CrashReport. */
217
    private CrashReport crashReporter;
218
    public int displayWidth;
219
    public int displayHeight;
220
221
    /** True if the player is connected to a realms server */
222
    private boolean connectedToRealms = false;
223
    private Timer timer = new Timer(20.0F);
224
225
    /** Instance of PlayerUsageSnooper. */
226
    private PlayerUsageSnooper usageSnooper = new PlayerUsageSnooper("client", this, MinecraftServer.getCurrentTimeMillis());
227
    public WorldClient theWorld;
228
    public RenderGlobal renderGlobal;
229
    private RenderManager renderManager;
230
    private RenderItem renderItem;
231
    private ItemRenderer itemRenderer;
232
    public EntityPlayerSP thePlayer;
233
    private Entity renderViewEntity;
234
    public Entity pointedEntity;
235
    public EffectRenderer effectRenderer;
236
    private final Session session;
237
    private boolean isGamePaused;
238
239
    /** The font renderer used for displaying and measuring text */
240
    public FontRenderer fontRendererObj;
241
    public FontRenderer standardGalacticFontRenderer;
242
243
    /** The GuiScreen that's being displayed at the moment. */
244
    public GuiScreen currentScreen;
245
    public LoadingScreenRenderer loadingScreen;
246
    public EntityRenderer entityRenderer;
247
248
    /** Mouse left click counter */
249
    private int leftClickCounter;
250
251
    /** Display width */
252
    private int tempDisplayWidth;
253
254
    /** Display height */
255
    private int tempDisplayHeight;
256
257
    /** Instance of IntegratedServer. */
258
    private IntegratedServer theIntegratedServer;
259
260
    /** Gui achievement */
261
    public GuiAchievement guiAchievement;
262
    public GuiIngame ingameGUI;
263
264
    /** Skip render world */
265
    public boolean skipRenderWorld;
266
267
    /** The ray trace hit that the mouse is over. */
268
    public MovingObjectPosition objectMouseOver;
269
270
    /** The game settings that currently hold effect. */
271
    public GameSettings gameSettings;
272
273
    /** Mouse helper instance. */
274
    public MouseHelper mouseHelper;
275
    public final File mcDataDir;
276
    private final File fileAssets;
277
    private final String launchedVersion;
278
    private final Proxy proxy;
279
    private ISaveFormat saveLoader;
280
281
    /**
282
     * This is set to fpsCounter every debug screen update, and is shown on the debug screen. It's also sent as part of
283
     * the usage snooping.
284
     */
285
    private static int debugFPS;
286
287
    /**
288
     * When you place a block, it's set to 6, decremented once per tick, when it's 0, you can place another block.
289
     */
290
    private int rightClickDelayTimer;
291
    private String serverName;
292
    private int serverPort;
293
294
    /**
295
     * Does the actual gameplay have focus. If so then mouse and keys will effect the player instead of menus.
296
     */
297
    public boolean inGameHasFocus;
298
    long systemTime = getSystemTime();
299
300
    /** Join player counter */
301
    private int joinPlayerCounter;
302
303
    /** The FrameTimer's instance */
304
    public final FrameTimer frameTimer = new FrameTimer();
305
306
    /** Time in nanoseconds of when the class is loaded */
307
    long startNanoTime = System.nanoTime();
308
    private final boolean jvm64bit;
309
    private final boolean isDemo;
310
    private NetworkManager myNetworkManager;
311
    private boolean integratedServerIsRunning;
312
313
    /** The profiler instance */
314
    public final Profiler mcProfiler = new Profiler();
315
316
    /**
317
     * Keeps track of how long the debug crash keycombo (F3+C) has been pressed for, in order to crash after 10 seconds.
318
     */
319
    private long debugCrashKeyPressTime = -1L;
320
    private IReloadableResourceManager mcResourceManager;
321
    private final IMetadataSerializer metadataSerializer_ = new IMetadataSerializer();
322
    private final List<IResourcePack> defaultResourcePacks = Lists.<IResourcePack>newArrayList();
323
    private final DefaultResourcePack mcDefaultResourcePack;
324
    private ResourcePackRepository mcResourcePackRepository;
325
    private LanguageManager mcLanguageManager;
326
    private IStream stream;
327
    private Framebuffer framebufferMc;
328
    private TextureMap textureMapBlocks;
329
    private SoundHandler mcSoundHandler;
330
    private MusicTicker mcMusicTicker;
331
    private ResourceLocation mojangLogo;
332
    private final MinecraftSessionService sessionService;
333
    private SkinManager skinManager;
334
    private final Queue < FutureTask<? >> scheduledTasks = Queues. < FutureTask<? >> newArrayDeque();
335
    private long field_175615_aJ = 0L;
336
    private final Thread mcThread = Thread.currentThread();
337
    private ModelManager modelManager;
338
339
    /**
340
     * The BlockRenderDispatcher instance that will be used based off gamesettings
341
     */
342
    private BlockRendererDispatcher blockRenderDispatcher;
343
344
    /**
345
     * Set to true to keep the game loop running. Set to false by shutdown() to allow the game loop to exit cleanly.
346
     */
347
    volatile boolean running = true;
348
349
    /** String that shows the debug information */
350
    public String debug = "";
351
    public boolean field_175613_B = false;
352
    public boolean field_175614_C = false;
353
    public boolean field_175611_D = false;
354
    public boolean renderChunksMany = true;
355
356
    /** Approximate time (in ms) of last update to debug string */
357
    long debugUpdateTime = getSystemTime();
358
359
    /** holds the current fps */
360
    int fpsCounter;
361
    long prevFrameTime = -1L;
362
363
    /** Profiler currently displayed in the debug screen pie chart */
364
    private String debugProfilerName = "root";
365
366
    public Minecraft(GameConfiguration gameConfig)
367
    {
368
        theMinecraft = this;
369
        this.mcDataDir = gameConfig.folderInfo.mcDataDir;
370
        this.fileAssets = gameConfig.folderInfo.assetsDir;
371
        this.fileResourcepacks = gameConfig.folderInfo.resourcePacksDir;
372
        this.launchedVersion = gameConfig.gameInfo.version;
373
        this.twitchDetails = gameConfig.userInfo.userProperties;
374
        this.profileProperties = gameConfig.userInfo.profileProperties;
375
        this.mcDefaultResourcePack = new DefaultResourcePack((new ResourceIndex(gameConfig.folderInfo.assetsDir, gameConfig.folderInfo.assetIndex)).getResourceMap());
376
        this.proxy = gameConfig.userInfo.proxy == null ? Proxy.NO_PROXY : gameConfig.userInfo.proxy;
377
        this.sessionService = (new YggdrasilAuthenticationService(gameConfig.userInfo.proxy, UUID.randomUUID().toString())).createMinecraftSessionService();
378
        this.session = gameConfig.userInfo.session;
379
        logger.info("Setting user: " + this.session.getUsername());
380
        logger.info("(Session ID is " + this.session.getSessionID() + ")");
381
        this.isDemo = gameConfig.gameInfo.isDemo;
382
        this.displayWidth = gameConfig.displayInfo.width > 0 ? gameConfig.displayInfo.width : 1;
383
        this.displayHeight = gameConfig.displayInfo.height > 0 ? gameConfig.displayInfo.height : 1;
384
        this.tempDisplayWidth = gameConfig.displayInfo.width;
385
        this.tempDisplayHeight = gameConfig.displayInfo.height;
386
        this.fullscreen = gameConfig.displayInfo.fullscreen;
387
        this.jvm64bit = isJvm64bit();
388
        this.theIntegratedServer = new IntegratedServer(this);
389
390
        if (gameConfig.serverInfo.serverName != null)
391
        {
392
            this.serverName = gameConfig.serverInfo.serverName;
393
            this.serverPort = gameConfig.serverInfo.serverPort;
394
        }
395
396
        ImageIO.setUseCache(false);
397
        Bootstrap.register();
398
    }
399
400
    public void run()
401
    {
402
        this.running = true;
403
404
        try
405
        {
406
            this.startGame();
407
        }
408
        catch (Throwable throwable)
409
        {
410
            CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Initializing game");
411
            crashreport.makeCategory("Initialization");
412
            this.displayCrashReport(this.addGraphicsAndWorldToCrashReport(crashreport));
413
            return;
414
        }
415
416
        while (true)
417
        {
418
            try
419
            {
420
                while (this.running)
421
                {
422
                    if (!this.hasCrashed || this.crashReporter == null)
423
                    {
424
                        try
425
                        {
426
                            this.runGameLoop();
427
                        }
428
                        catch (OutOfMemoryError var10)
429
                        {
430
                            this.freeMemory();
431
                            this.displayGuiScreen(new GuiMemoryErrorScreen());
432
                            System.gc();
433
                        }
434
                    }
435
                    else
436
                    {
437
                        this.displayCrashReport(this.crashReporter);
438
                    }
439
                }
440
            }
441
            catch (MinecraftError var12)
442
            {
443
                break;
444
            }
445
            catch (ReportedException reportedexception)
446
            {
447
                this.addGraphicsAndWorldToCrashReport(reportedexception.getCrashReport());
448
                this.freeMemory();
449
                logger.fatal((String)"Reported exception thrown!", (Throwable)reportedexception);
450
                this.displayCrashReport(reportedexception.getCrashReport());
451
                break;
452
            }
453
            catch (Throwable throwable1)
454
            {
455
                CrashReport crashreport1 = this.addGraphicsAndWorldToCrashReport(new CrashReport("Unexpected error", throwable1));
456
                this.freeMemory();
457
                logger.fatal("Unreported exception thrown!", throwable1);
458
                this.displayCrashReport(crashreport1);
459
                break;
460
            }
461
            finally
462
            {
463
                this.shutdownMinecraftApplet();
464
            }
465
466
            return;
467
        }
468
    }
469
470
    /**
471
     * Starts the game: initializes the canvas, the title, the settings, etcetera.
472
     */
473
    private void startGame() throws LWJGLException, IOException
474
    {
475
        this.gameSettings = new GameSettings(this, this.mcDataDir);
476
        this.defaultResourcePacks.add(this.mcDefaultResourcePack);
477
        this.startTimerHackThread();
478
479
        if (this.gameSettings.overrideHeight > 0 && this.gameSettings.overrideWidth > 0)
480
        {
481
            this.displayWidth = this.gameSettings.overrideWidth;
482
            this.displayHeight = this.gameSettings.overrideHeight;
483
        }
484
485
        logger.info("LWJGL Version: " + Sys.getVersion());
486
        this.setWindowIcon();
487
        this.setInitialDisplayMode();
488
        this.createDisplay();
489
        OpenGlHelper.initializeTextures();
490
        this.framebufferMc = new Framebuffer(this.displayWidth, this.displayHeight, true);
491
        this.framebufferMc.setFramebufferColor(0.0F, 0.0F, 0.0F, 0.0F);
492
        this.registerMetadataSerializers();
493
        this.mcResourcePackRepository = new ResourcePackRepository(this.fileResourcepacks, new File(this.mcDataDir, "server-resource-packs"), this.mcDefaultResourcePack, this.metadataSerializer_, this.gameSettings);
494
        this.mcResourceManager = new SimpleReloadableResourceManager(this.metadataSerializer_);
495
        this.mcLanguageManager = new LanguageManager(this.metadataSerializer_, this.gameSettings.language);
496
        this.mcResourceManager.registerReloadListener(this.mcLanguageManager);
497
        this.refreshResources();
498
        this.renderEngine = new TextureManager(this.mcResourceManager);
499
        this.mcResourceManager.registerReloadListener(this.renderEngine);
500
        this.drawSplashScreen(this.renderEngine);
501
        this.initStream();
502
        this.skinManager = new SkinManager(this.renderEngine, new File(this.fileAssets, "skins"), this.sessionService);
503
        this.saveLoader = new AnvilSaveConverter(new File(this.mcDataDir, "saves"));
504
        this.mcSoundHandler = new SoundHandler(this.mcResourceManager, this.gameSettings);
505
        this.mcResourceManager.registerReloadListener(this.mcSoundHandler);
506
        this.mcMusicTicker = new MusicTicker(this);
507
        this.fontRendererObj = new FontRenderer(this.gameSettings, new ResourceLocation("textures/font/ascii.png"), this.renderEngine, false);
508
509
        if (this.gameSettings.language != null)
510
        {
511
            this.fontRendererObj.setUnicodeFlag(this.isUnicode());
512
            this.fontRendererObj.setBidiFlag(this.mcLanguageManager.isCurrentLanguageBidirectional());
513
        }
514
515
        this.standardGalacticFontRenderer = new FontRenderer(this.gameSettings, new ResourceLocation("textures/font/ascii_sga.png"), this.renderEngine, false);
516
        this.mcResourceManager.registerReloadListener(this.fontRendererObj);
517
        this.mcResourceManager.registerReloadListener(this.standardGalacticFontRenderer);
518
        this.mcResourceManager.registerReloadListener(new GrassColorReloadListener());
519
        this.mcResourceManager.registerReloadListener(new FoliageColorReloadListener());
520
        AchievementList.openInventory.setStatStringFormatter(new IStatStringFormat()
521
        {
522
            public String formatString(String str)
523
            {
524
                try
525
                {
526
                    return String.format(str, new Object[] {GameSettings.getKeyDisplayString(Minecraft.this.gameSettings.keyBindInventory.getKeyCode())});
527
                }
528
                catch (Exception exception)
529
                {
530
                    return "Error: " + exception.getLocalizedMessage();
531
                }
532
            }
533
        });
534
        this.mouseHelper = new MouseHelper();
535
        this.checkGLError("Pre startup");
536
        GlStateManager.enableTexture2D();
537
        GlStateManager.shadeModel(7425);
538
        GlStateManager.clearDepth(1.0D);
539
        GlStateManager.enableDepth();
540
        GlStateManager.depthFunc(515);
541
        GlStateManager.enableAlpha();
542
        GlStateManager.alphaFunc(516, 0.1F);
543
        GlStateManager.cullFace(1029);
544
        GlStateManager.matrixMode(5889);
545
        GlStateManager.loadIdentity();
546
        GlStateManager.matrixMode(5888);
547
        this.checkGLError("Startup");
548
        this.textureMapBlocks = new TextureMap("textures");
549
        this.textureMapBlocks.setMipmapLevels(this.gameSettings.mipmapLevels);
550
        this.renderEngine.loadTickableTexture(TextureMap.locationBlocksTexture, this.textureMapBlocks);
551
        this.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
552
        this.textureMapBlocks.setBlurMipmapDirect(false, this.gameSettings.mipmapLevels > 0);
553
        this.modelManager = new ModelManager(this.textureMapBlocks);
554
        this.mcResourceManager.registerReloadListener(this.modelManager);
555
        this.renderItem = new RenderItem(this.renderEngine, this.modelManager);
556
        this.renderManager = new RenderManager(this.renderEngine, this.renderItem);
557
        this.itemRenderer = new ItemRenderer(this);
558
        this.mcResourceManager.registerReloadListener(this.renderItem);
559
        this.entityRenderer = new EntityRenderer(this, this.mcResourceManager);
560
        this.mcResourceManager.registerReloadListener(this.entityRenderer);
561
        this.blockRenderDispatcher = new BlockRendererDispatcher(this.modelManager.getBlockModelShapes(), this.gameSettings);
562
        this.mcResourceManager.registerReloadListener(this.blockRenderDispatcher);
563
        this.renderGlobal = new RenderGlobal(this);
564
        this.mcResourceManager.registerReloadListener(this.renderGlobal);
565
        this.guiAchievement = new GuiAchievement(this);
566
        GlStateManager.viewport(0, 0, this.displayWidth, this.displayHeight);
567
        this.effectRenderer = new EffectRenderer(this.theWorld, this.renderEngine);
568
        this.checkGLError("Post startup");
569
        this.ingameGUI = new GuiIngame(this);
570
571
        if (this.serverName != null)
572
        {
573
            this.displayGuiScreen(new GuiConnecting(new GuiMainMenu(), this, this.serverName, this.serverPort));
574
        }
575
        else
576
        {
577
            this.displayGuiScreen(new GuiMainMenu());
578
        }
579
580
        this.renderEngine.deleteTexture(this.mojangLogo);
581
        this.mojangLogo = null;
582
        this.loadingScreen = new LoadingScreenRenderer(this);
583
584
        if (this.gameSettings.fullScreen && !this.fullscreen)
585
        {
586
            this.toggleFullscreen();
587
        }
588
589
        try
590
        {
591
            Display.setVSyncEnabled(this.gameSettings.enableVsync);
592
        }
593
        catch (OpenGLException var2)
594
        {
595
            this.gameSettings.enableVsync = false;
596
            this.gameSettings.saveOptions();
597
        }
598
599
        this.renderGlobal.makeEntityOutlineShader();
600
    }
601
602
    private void registerMetadataSerializers()
603
    {
604
        this.metadataSerializer_.registerMetadataSectionType(new TextureMetadataSectionSerializer(), TextureMetadataSection.class);
605
        this.metadataSerializer_.registerMetadataSectionType(new FontMetadataSectionSerializer(), FontMetadataSection.class);
606
        this.metadataSerializer_.registerMetadataSectionType(new AnimationMetadataSectionSerializer(), AnimationMetadataSection.class);
607
        this.metadataSerializer_.registerMetadataSectionType(new PackMetadataSectionSerializer(), PackMetadataSection.class);
608
        this.metadataSerializer_.registerMetadataSectionType(new LanguageMetadataSectionSerializer(), LanguageMetadataSection.class);
609
    }
610
611
    private void initStream()
612
    {
613
        try
614
        {
615
            this.stream = new TwitchStream(this, (Property)Iterables.getFirst(this.twitchDetails.get("twitch_access_token"), null));
616
        }
617
        catch (Throwable throwable)
618
        {
619
            this.stream = new NullStream(throwable);
620
            logger.error("Couldn\'t initialize twitch stream");
621
        }
622
    }
623
624
    private void createDisplay() throws LWJGLException
625
    {
626
        Display.setResizable(true);
627
        Display.setTitle("Minecraft 1.8.9");
628
629
        try
630
        {
631
            Display.create((new PixelFormat()).withDepthBits(24));
632
        }
633
        catch (LWJGLException lwjglexception)
634
        {
635
            logger.error((String)"Couldn\'t set pixel format", (Throwable)lwjglexception);
636
637
            try
638
            {
639
                Thread.sleep(1000L);
640
            }
641
            catch (InterruptedException var3)
642
            {
643
                ;
644
            }
645
646
            if (this.fullscreen)
647
            {
648
                this.updateDisplayMode();
649
            }
650
651
            Display.create();
652
        }
653
    }
654
655
    private void setInitialDisplayMode() throws LWJGLException
656
    {
657
        if (this.fullscreen)
658
        {
659
            Display.setFullscreen(true);
660
            DisplayMode displaymode = Display.getDisplayMode();
661
            this.displayWidth = Math.max(1, displaymode.getWidth());
662
            this.displayHeight = Math.max(1, displaymode.getHeight());
663
        }
664
        else
665
        {
666
            Display.setDisplayMode(new DisplayMode(this.displayWidth, this.displayHeight));
667
        }
668
    }
669
670
    private void setWindowIcon()
671
    {
672
        Util.EnumOS util$enumos = Util.getOSType();
673
674
        if (util$enumos != Util.EnumOS.OSX)
675
        {
676
            InputStream inputstream = null;
677
            InputStream inputstream1 = null;
678
679
            try
680
            {
681
                inputstream = this.mcDefaultResourcePack.getInputStreamAssets(new ResourceLocation("icons/icon_16x16.png"));
682
                inputstream1 = this.mcDefaultResourcePack.getInputStreamAssets(new ResourceLocation("icons/icon_32x32.png"));
683
684
                if (inputstream != null && inputstream1 != null)
685
                {
686
                    Display.setIcon(new ByteBuffer[] {this.readImageToBuffer(inputstream), this.readImageToBuffer(inputstream1)});
687
                }
688
            }
689
            catch (IOException ioexception)
690
            {
691
                logger.error((String)"Couldn\'t set icon", (Throwable)ioexception);
692
            }
693
            finally
694
            {
695
                IOUtils.closeQuietly(inputstream);
696
                IOUtils.closeQuietly(inputstream1);
697
            }
698
        }
699
    }
700
701
    private static boolean isJvm64bit()
702
    {
703
        String[] astring = new String[] {"sun.arch.data.model", "com.ibm.vm.bitmode", "os.arch"};
704
705
        for (String s : astring)
706
        {
707
            String s1 = System.getProperty(s);
708
709
            if (s1 != null && s1.contains("64"))
710
            {
711
                return true;
712
            }
713
        }
714
715
        return false;
716
    }
717
718
    public Framebuffer getFramebuffer()
719
    {
720
        return this.framebufferMc;
721
    }
722
723
    public String getVersion()
724
    {
725
        return this.launchedVersion;
726
    }
727
728
    private void startTimerHackThread()
729
    {
730
        Thread thread = new Thread("Timer hack thread")
731
        {
732
            public void run()
733
            {
734
                while (Minecraft.this.running)
735
                {
736
                    try
737
                    {
738
                        Thread.sleep(2147483647L);
739
                    }
740
                    catch (InterruptedException var2)
741
                    {
742
                        ;
743
                    }
744
                }
745
            }
746
        };
747
        thread.setDaemon(true);
748
        thread.start();
749
    }
750
751
    public void crashed(CrashReport crash)
752
    {
753
        this.hasCrashed = true;
754
        this.crashReporter = crash;
755
    }
756
757
    /**
758
     * Wrapper around displayCrashReportInternal
759
     */
760
    public void displayCrashReport(CrashReport crashReportIn)
761
    {
762
        File file1 = new File(getMinecraft().mcDataDir, "crash-reports");
763
        File file2 = new File(file1, "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-client.txt");
764
        Bootstrap.printToSYSOUT(crashReportIn.getCompleteReport());
765
766
        if (crashReportIn.getFile() != null)
767
        {
768
            Bootstrap.printToSYSOUT("#@!@# Game crashed! Crash report saved to: #@!@# " + crashReportIn.getFile());
769
            System.exit(-1);
770
        }
771
        else if (crashReportIn.saveToFile(file2))
772
        {
773
            Bootstrap.printToSYSOUT("#@!@# Game crashed! Crash report saved to: #@!@# " + file2.getAbsolutePath());
774
            System.exit(-1);
775
        }
776
        else
777
        {
778
            Bootstrap.printToSYSOUT("#@?@# Game crashed! Crash report could not be saved. #@?@#");
779
            System.exit(-2);
780
        }
781
    }
782
783
    public boolean isUnicode()
784
    {
785
        return this.mcLanguageManager.isCurrentLocaleUnicode() || this.gameSettings.forceUnicodeFont;
786
    }
787
788
    public void refreshResources()
789
    {
790
        List<IResourcePack> list = Lists.newArrayList(this.defaultResourcePacks);
791
792
        for (ResourcePackRepository.Entry resourcepackrepository$entry : this.mcResourcePackRepository.getRepositoryEntries())
793
        {
794
            list.add(resourcepackrepository$entry.getResourcePack());
795
        }
796
797
        if (this.mcResourcePackRepository.getResourcePackInstance() != null)
798
        {
799
            list.add(this.mcResourcePackRepository.getResourcePackInstance());
800
        }
801
802
        try
803
        {
804
            this.mcResourceManager.reloadResources(list);
805
        }
806
        catch (RuntimeException runtimeexception)
807
        {
808
            logger.info((String)"Caught error stitching, removing all assigned resourcepacks", (Throwable)runtimeexception);
809
            list.clear();
810
            list.addAll(this.defaultResourcePacks);
811
            this.mcResourcePackRepository.setRepositories(Collections.<ResourcePackRepository.Entry>emptyList());
812
            this.mcResourceManager.reloadResources(list);
813
            this.gameSettings.resourcePacks.clear();
814
            this.gameSettings.incompatibleResourcePacks.clear();
815
            this.gameSettings.saveOptions();
816
        }
817
818
        this.mcLanguageManager.parseLanguageMetadata(list);
819
820
        if (this.renderGlobal != null)
821
        {
822
            this.renderGlobal.loadRenderers();
823
        }
824
    }
825
826
    private ByteBuffer readImageToBuffer(InputStream imageStream) throws IOException
827
    {
828
        BufferedImage bufferedimage = ImageIO.read(imageStream);
829
        int[] aint = bufferedimage.getRGB(0, 0, bufferedimage.getWidth(), bufferedimage.getHeight(), (int[])null, 0, bufferedimage.getWidth());
830
        ByteBuffer bytebuffer = ByteBuffer.allocate(4 * aint.length);
831
832
        for (int i : aint)
833
        {
834
            bytebuffer.putInt(i << 8 | i >> 24 & 255);
835
        }
836
837
        bytebuffer.flip();
838
        return bytebuffer;
839
    }
840
841
    private void updateDisplayMode() throws LWJGLException
842
    {
843
        Set<DisplayMode> set = Sets.<DisplayMode>newHashSet();
844
        Collections.addAll(set, Display.getAvailableDisplayModes());
845
        DisplayMode displaymode = Display.getDesktopDisplayMode();
846
847
        if (!set.contains(displaymode) && Util.getOSType() == Util.EnumOS.OSX)
848
        {
849
            label53:
850
851
            for (DisplayMode displaymode1 : macDisplayModes)
852
            {
853
                boolean flag = true;
854
855
                for (DisplayMode displaymode2 : set)
856
                {
857
                    if (displaymode2.getBitsPerPixel() == 32 && displaymode2.getWidth() == displaymode1.getWidth() && displaymode2.getHeight() == displaymode1.getHeight())
858
                    {
859
                        flag = false;
860
                        break;
861
                    }
862
                }
863
864
                if (!flag)
865
                {
866
                    Iterator iterator = set.iterator();
867
                    DisplayMode displaymode3;
868
869
                    while (true)
870
                    {
871
                        if (!iterator.hasNext())
872
                        {
873
                            continue label53;
874
                        }
875
876
                        displaymode3 = (DisplayMode)iterator.next();
877
878
                        if (displaymode3.getBitsPerPixel() == 32 && displaymode3.getWidth() == displaymode1.getWidth() / 2 && displaymode3.getHeight() == displaymode1.getHeight() / 2)
879
                        {
880
                            break;
881
                        }
882
                    }
883
884
                    displaymode = displaymode3;
885
                }
886
            }
887
        }
888
889
        Display.setDisplayMode(displaymode);
890
        this.displayWidth = displaymode.getWidth();
891
        this.displayHeight = displaymode.getHeight();
892
    }
893
894
    private void drawSplashScreen(TextureManager textureManagerInstance) throws LWJGLException
895
    {
896
        ScaledResolution scaledresolution = new ScaledResolution(this);
897
        int i = scaledresolution.getScaleFactor();
898
        Framebuffer framebuffer = new Framebuffer(scaledresolution.getScaledWidth() * i, scaledresolution.getScaledHeight() * i, true);
899
        framebuffer.bindFramebuffer(false);
900
        GlStateManager.matrixMode(5889);
901
        GlStateManager.loadIdentity();
902
        GlStateManager.ortho(0.0D, (double)scaledresolution.getScaledWidth(), (double)scaledresolution.getScaledHeight(), 0.0D, 1000.0D, 3000.0D);
903
        GlStateManager.matrixMode(5888);
904
        GlStateManager.loadIdentity();
905
        GlStateManager.translate(0.0F, 0.0F, -2000.0F);
906
        GlStateManager.disableLighting();
907
        GlStateManager.disableFog();
908
        GlStateManager.disableDepth();
909
        GlStateManager.enableTexture2D();
910
        InputStream inputstream = null;
911
912
        try
913
        {
914
            inputstream = this.mcDefaultResourcePack.getInputStream(locationMojangPng);
915
            this.mojangLogo = textureManagerInstance.getDynamicTextureLocation("logo", new DynamicTexture(ImageIO.read(inputstream)));
916
            textureManagerInstance.bindTexture(this.mojangLogo);
917
        }
918
        catch (IOException ioexception)
919
        {
920
            logger.error((String)("Unable to load logo: " + locationMojangPng), (Throwable)ioexception);
921
        }
922
        finally
923
        {
924
            IOUtils.closeQuietly(inputstream);
925
        }
926
927
        Tessellator tessellator = Tessellator.getInstance();
928
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
929
        worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
930
        worldrenderer.pos(0.0D, (double)this.displayHeight, 0.0D).tex(0.0D, 0.0D).color(255, 255, 255, 255).endVertex();
931
        worldrenderer.pos((double)this.displayWidth, (double)this.displayHeight, 0.0D).tex(0.0D, 0.0D).color(255, 255, 255, 255).endVertex();
932
        worldrenderer.pos((double)this.displayWidth, 0.0D, 0.0D).tex(0.0D, 0.0D).color(255, 255, 255, 255).endVertex();
933
        worldrenderer.pos(0.0D, 0.0D, 0.0D).tex(0.0D, 0.0D).color(255, 255, 255, 255).endVertex();
934
        tessellator.draw();
935
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
936
        int j = 256;
937
        int k = 256;
938
        this.draw((scaledresolution.getScaledWidth() - j) / 2, (scaledresolution.getScaledHeight() - k) / 2, 0, 0, j, k, 255, 255, 255, 255);
939
        GlStateManager.disableLighting();
940
        GlStateManager.disableFog();
941
        framebuffer.unbindFramebuffer();
942
        framebuffer.framebufferRender(scaledresolution.getScaledWidth() * i, scaledresolution.getScaledHeight() * i);
943
        GlStateManager.enableAlpha();
944
        GlStateManager.alphaFunc(516, 0.1F);
945
        this.updateDisplay();
946
    }
947
948
    /**
949
     * Draw with the WorldRenderer
950
     *  
951
     * @param posX X position for the render
952
     * @param posY Y position for the render
953
     * @param texU X position for the texture
954
     * @param texV Y position for the texture
955
     * @param width Width of the render
956
     * @param height Height of the render
957
     * @param red The red component of the render's color
958
     * @param green The green component of the render's color
959
     * @param blue The blue component of the render's color
960
     * @param alpha The alpha component of the render's color
961
     */
962
    public void draw(int posX, int posY, int texU, int texV, int width, int height, int red, int green, int blue, int alpha)
963
    {
964
        float f = 0.00390625F;
965
        float f1 = 0.00390625F;
966
        WorldRenderer worldrenderer = Tessellator.getInstance().getWorldRenderer();
967
        worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
968
        worldrenderer.pos((double)posX, (double)(posY + height), 0.0D).tex((double)((float)texU * f), (double)((float)(texV + height) * f1)).color(red, green, blue, alpha).endVertex();
969
        worldrenderer.pos((double)(posX + width), (double)(posY + height), 0.0D).tex((double)((float)(texU + width) * f), (double)((float)(texV + height) * f1)).color(red, green, blue, alpha).endVertex();
970
        worldrenderer.pos((double)(posX + width), (double)posY, 0.0D).tex((double)((float)(texU + width) * f), (double)((float)texV * f1)).color(red, green, blue, alpha).endVertex();
971
        worldrenderer.pos((double)posX, (double)posY, 0.0D).tex((double)((float)texU * f), (double)((float)texV * f1)).color(red, green, blue, alpha).endVertex();
972
        Tessellator.getInstance().draw();
973
    }
974
975
    /**
976
     * Returns the save loader that is currently being used
977
     */
978
    public ISaveFormat getSaveLoader()
979
    {
980
        return this.saveLoader;
981
    }
982
983
    /**
984
     * Sets the argument GuiScreen as the main (topmost visible) screen.
985
     */
986
    public void displayGuiScreen(GuiScreen guiScreenIn)
987
    {
988
        if (this.currentScreen != null)
989
        {
990
            this.currentScreen.onGuiClosed();
991
        }
992
993
        if (guiScreenIn == null && this.theWorld == null)
994
        {
995
            guiScreenIn = new GuiMainMenu();
996
        }
997
        else if (guiScreenIn == null && this.thePlayer.getHealth() <= 0.0F)
998
        {
999
            guiScreenIn = new GuiGameOver();
1000
        }
1001
1002
        if (guiScreenIn instanceof GuiMainMenu)
1003
        {
1004
            this.gameSettings.showDebugInfo = false;
1005
            this.ingameGUI.getChatGUI().clearChatMessages();
1006
        }
1007
1008
        this.currentScreen = (GuiScreen)guiScreenIn;
1009
1010
        if (guiScreenIn != null)
1011
        {
1012
            this.setIngameNotInFocus();
1013
            ScaledResolution scaledresolution = new ScaledResolution(this);
1014
            int i = scaledresolution.getScaledWidth();
1015
            int j = scaledresolution.getScaledHeight();
1016
            ((GuiScreen)guiScreenIn).setWorldAndResolution(this, i, j);
1017
            this.skipRenderWorld = false;
1018
        }
1019
        else
1020
        {
1021
            this.mcSoundHandler.resumeSounds();
1022
            this.setIngameFocus();
1023
        }
1024
    }
1025
1026
    /**
1027
     * Checks for an OpenGL error. If there is one, prints the error ID and error string.
1028
     */
1029
    private void checkGLError(String message)
1030
    {
1031
        if (this.enableGLErrorChecking)
1032
        {
1033
            int i = GL11.glGetError();
1034
1035
            if (i != 0)
1036
            {
1037
                String s = GLU.gluErrorString(i);
1038
                logger.error("########## GL ERROR ##########");
1039
                logger.error("@ " + message);
1040
                logger.error(i + ": " + s);
1041
            }
1042
        }
1043
    }
1044
1045
    /**
1046
     * Shuts down the minecraft applet by stopping the resource downloads, and clearing up GL stuff; called when the
1047
     * application (or web page) is exited.
1048
     */
1049
    public void shutdownMinecraftApplet()
1050
    {
1051
        try
1052
        {
1053
            this.stream.shutdownStream();
1054
            logger.info("Stopping!");
1055
1056
            try
1057
            {
1058
                this.loadWorld((WorldClient)null);
1059
            }
1060
            catch (Throwable var5)
1061
            {
1062
                ;
1063
            }
1064
1065
            this.mcSoundHandler.unloadSounds();
1066
        }
1067
        finally
1068
        {
1069
            Display.destroy();
1070
1071
            if (!this.hasCrashed)
1072
            {
1073
                System.exit(0);
1074
            }
1075
        }
1076
1077
        System.gc();
1078
    }
1079
1080
    /**
1081
     * Called repeatedly from run()
1082
     */
1083
    private void runGameLoop() throws IOException
1084
    {
1085
        long i = System.nanoTime();
1086
        this.mcProfiler.startSection("root");
1087
1088
        if (Display.isCreated() && Display.isCloseRequested())
1089
        {
1090
            this.shutdown();
1091
        }
1092
1093
        if (this.isGamePaused && this.theWorld != null)
1094
        {
1095
            float f = this.timer.renderPartialTicks;
1096
            this.timer.updateTimer();
1097
            this.timer.renderPartialTicks = f;
1098
        }
1099
        else
1100
        {
1101
            this.timer.updateTimer();
1102
        }
1103
1104
        this.mcProfiler.startSection("scheduledExecutables");
1105
1106
        synchronized (this.scheduledTasks)
1107
        {
1108
            while (!this.scheduledTasks.isEmpty())
1109
            {
1110
                Util.runTask((FutureTask)this.scheduledTasks.poll(), logger);
1111
            }
1112
        }
1113
1114
        this.mcProfiler.endSection();
1115
        long l = System.nanoTime();
1116
        this.mcProfiler.startSection("tick");
1117
1118
        for (int j = 0; j < this.timer.elapsedTicks; ++j)
1119
        {
1120
            this.runTick();
1121
        }
1122
1123
        this.mcProfiler.endStartSection("preRenderErrors");
1124
        long i1 = System.nanoTime() - l;
1125
        this.checkGLError("Pre render");
1126
        this.mcProfiler.endStartSection("sound");
1127
        this.mcSoundHandler.setListener(this.thePlayer, this.timer.renderPartialTicks);
1128
        this.mcProfiler.endSection();
1129
        this.mcProfiler.startSection("render");
1130
        GlStateManager.pushMatrix();
1131
        GlStateManager.clear(16640);
1132
        this.framebufferMc.bindFramebuffer(true);
1133
        this.mcProfiler.startSection("display");
1134
        GlStateManager.enableTexture2D();
1135
1136
        if (this.thePlayer != null && this.thePlayer.isEntityInsideOpaqueBlock())
1137
        {
1138
            this.gameSettings.thirdPersonView = 0;
1139
        }
1140
1141
        this.mcProfiler.endSection();
1142
1143
        if (!this.skipRenderWorld)
1144
        {
1145
            this.mcProfiler.endStartSection("gameRenderer");
1146
            this.entityRenderer.updateCameraAndRender(this.timer.renderPartialTicks, i);
1147
            this.mcProfiler.endSection();
1148
        }
1149
1150
        this.mcProfiler.endSection();
1151
1152
        if (this.gameSettings.showDebugInfo && this.gameSettings.showDebugProfilerChart && !this.gameSettings.hideGUI)
1153
        {
1154
            if (!this.mcProfiler.profilingEnabled)
1155
            {
1156
                this.mcProfiler.clearProfiling();
1157
            }
1158
1159
            this.mcProfiler.profilingEnabled = true;
1160
            this.displayDebugInfo(i1);
1161
        }
1162
        else
1163
        {
1164
            this.mcProfiler.profilingEnabled = false;
1165
            this.prevFrameTime = System.nanoTime();
1166
        }
1167
1168
        this.guiAchievement.updateAchievementWindow();
1169
        this.framebufferMc.unbindFramebuffer();
1170
        GlStateManager.popMatrix();
1171
        GlStateManager.pushMatrix();
1172
        this.framebufferMc.framebufferRender(this.displayWidth, this.displayHeight);
1173
        GlStateManager.popMatrix();
1174
        GlStateManager.pushMatrix();
1175
        this.entityRenderer.renderStreamIndicator(this.timer.renderPartialTicks);
1176
        GlStateManager.popMatrix();
1177
        this.mcProfiler.startSection("root");
1178
        this.updateDisplay();
1179
        Thread.yield();
1180
        this.mcProfiler.startSection("stream");
1181
        this.mcProfiler.startSection("update");
1182
        this.stream.func_152935_j();
1183
        this.mcProfiler.endStartSection("submit");
1184
        this.stream.func_152922_k();
1185
        this.mcProfiler.endSection();
1186
        this.mcProfiler.endSection();
1187
        this.checkGLError("Post render");
1188
        ++this.fpsCounter;
1189
        this.isGamePaused = this.isSingleplayer() && this.currentScreen != null && this.currentScreen.doesGuiPauseGame() && !this.theIntegratedServer.getPublic();
1190
        long k = System.nanoTime();
1191
        this.frameTimer.addFrame(k - this.startNanoTime);
1192
        this.startNanoTime = k;
1193
1194
        while (getSystemTime() >= this.debugUpdateTime + 1000L)
1195
        {
1196
            debugFPS = this.fpsCounter;
1197
            this.debug = String.format("%d fps (%d chunk update%s) T: %s%s%s%s%s", new Object[] {Integer.valueOf(debugFPS), Integer.valueOf(RenderChunk.renderChunksUpdated), RenderChunk.renderChunksUpdated != 1 ? "s" : "", (float)this.gameSettings.limitFramerate == GameSettings.Options.FRAMERATE_LIMIT.getValueMax() ? "inf" : Integer.valueOf(this.gameSettings.limitFramerate), this.gameSettings.enableVsync ? " vsync" : "", this.gameSettings.fancyGraphics ? "" : " fast", this.gameSettings.clouds == 0 ? "" : (this.gameSettings.clouds == 1 ? " fast-clouds" : " fancy-clouds"), OpenGlHelper.useVbo() ? " vbo" : ""});
1198
            RenderChunk.renderChunksUpdated = 0;
1199
            this.debugUpdateTime += 1000L;
1200
            this.fpsCounter = 0;
1201
            this.usageSnooper.addMemoryStatsToSnooper();
1202
1203
            if (!this.usageSnooper.isSnooperRunning())
1204
            {
1205
                this.usageSnooper.startSnooper();
1206
            }
1207
        }
1208
1209
        if (this.isFramerateLimitBelowMax())
1210
        {
1211
            this.mcProfiler.startSection("fpslimit_wait");
1212
            Display.sync(this.getLimitFramerate());
1213
            this.mcProfiler.endSection();
1214
        }
1215
1216
        this.mcProfiler.endSection();
1217
    }
1218
1219
    public void updateDisplay()
1220
    {
1221
        this.mcProfiler.startSection("display_update");
1222
        Display.update();
1223
        this.mcProfiler.endSection();
1224
        this.checkWindowResize();
1225
    }
1226
1227
    protected void checkWindowResize()
1228
    {
1229
        if (!this.fullscreen && Display.wasResized())
1230
        {
1231
            int i = this.displayWidth;
1232
            int j = this.displayHeight;
1233
            this.displayWidth = Display.getWidth();
1234
            this.displayHeight = Display.getHeight();
1235
1236
            if (this.displayWidth != i || this.displayHeight != j)
1237
            {
1238
                if (this.displayWidth <= 0)
1239
                {
1240
                    this.displayWidth = 1;
1241
                }
1242
1243
                if (this.displayHeight <= 0)
1244
                {
1245
                    this.displayHeight = 1;
1246
                }
1247
1248
                this.resize(this.displayWidth, this.displayHeight);
1249
            }
1250
        }
1251
    }
1252
1253
    public int getLimitFramerate()
1254
    {
1255
        return this.theWorld == null && this.currentScreen != null ? 30 : this.gameSettings.limitFramerate;
1256
    }
1257
1258
    public boolean isFramerateLimitBelowMax()
1259
    {
1260
        return (float)this.getLimitFramerate() < GameSettings.Options.FRAMERATE_LIMIT.getValueMax();
1261
    }
1262
1263
    public void freeMemory()
1264
    {
1265
        try
1266
        {
1267
            memoryReserve = new byte[0];
1268
            this.renderGlobal.deleteAllDisplayLists();
1269
        }
1270
        catch (Throwable var3)
1271
        {
1272
            ;
1273
        }
1274
1275
        try
1276
        {
1277
            System.gc();
1278
            this.loadWorld((WorldClient)null);
1279
        }
1280
        catch (Throwable var2)
1281
        {
1282
            ;
1283
        }
1284
1285
        System.gc();
1286
    }
1287
1288
    /**
1289
     * Update debugProfilerName in response to number keys in debug screen
1290
     */
1291
    private void updateDebugProfilerName(int keyCount)
1292
    {
1293
        List<Profiler.Result> list = this.mcProfiler.getProfilingData(this.debugProfilerName);
1294
1295
        if (list != null && !list.isEmpty())
1296
        {
1297
            Profiler.Result profiler$result = (Profiler.Result)list.remove(0);
1298
1299
            if (keyCount == 0)
1300
            {
1301
                if (profiler$result.field_76331_c.length() > 0)
1302
                {
1303
                    int i = this.debugProfilerName.lastIndexOf(".");
1304
1305
                    if (i >= 0)
1306
                    {
1307
                        this.debugProfilerName = this.debugProfilerName.substring(0, i);
1308
                    }
1309
                }
1310
            }
1311
            else
1312
            {
1313
                --keyCount;
1314
1315
                if (keyCount < list.size() && !((Profiler.Result)list.get(keyCount)).field_76331_c.equals("unspecified"))
1316
                {
1317
                    if (this.debugProfilerName.length() > 0)
1318
                    {
1319
                        this.debugProfilerName = this.debugProfilerName + ".";
1320
                    }
1321
1322
                    this.debugProfilerName = this.debugProfilerName + ((Profiler.Result)list.get(keyCount)).field_76331_c;
1323
                }
1324
            }
1325
        }
1326
    }
1327
1328
    /**
1329
     * Parameter appears to be unused
1330
     */
1331
    private void displayDebugInfo(long elapsedTicksTime)
1332
    {
1333
        if (this.mcProfiler.profilingEnabled)
1334
        {
1335
            List<Profiler.Result> list = this.mcProfiler.getProfilingData(this.debugProfilerName);
1336
            Profiler.Result profiler$result = (Profiler.Result)list.remove(0);
1337
            GlStateManager.clear(256);
1338
            GlStateManager.matrixMode(5889);
1339
            GlStateManager.enableColorMaterial();
1340
            GlStateManager.loadIdentity();
1341
            GlStateManager.ortho(0.0D, (double)this.displayWidth, (double)this.displayHeight, 0.0D, 1000.0D, 3000.0D);
1342
            GlStateManager.matrixMode(5888);
1343
            GlStateManager.loadIdentity();
1344
            GlStateManager.translate(0.0F, 0.0F, -2000.0F);
1345
            GL11.glLineWidth(1.0F);
1346
            GlStateManager.disableTexture2D();
1347
            Tessellator tessellator = Tessellator.getInstance();
1348
            WorldRenderer worldrenderer = tessellator.getWorldRenderer();
1349
            int i = 160;
1350
            int j = this.displayWidth - i - 10;
1351
            int k = this.displayHeight - i * 2;
1352
            GlStateManager.enableBlend();
1353
            worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
1354
            worldrenderer.pos((double)((float)j - (float)i * 1.1F), (double)((float)k - (float)i * 0.6F - 16.0F), 0.0D).color(200, 0, 0, 0).endVertex();
1355
            worldrenderer.pos((double)((float)j - (float)i * 1.1F), (double)(k + i * 2), 0.0D).color(200, 0, 0, 0).endVertex();
1356
            worldrenderer.pos((double)((float)j + (float)i * 1.1F), (double)(k + i * 2), 0.0D).color(200, 0, 0, 0).endVertex();
1357
            worldrenderer.pos((double)((float)j + (float)i * 1.1F), (double)((float)k - (float)i * 0.6F - 16.0F), 0.0D).color(200, 0, 0, 0).endVertex();
1358
            tessellator.draw();
1359
            GlStateManager.disableBlend();
1360
            double d0 = 0.0D;
1361
1362
            for (int l = 0; l < list.size(); ++l)
1363
            {
1364
                Profiler.Result profiler$result1 = (Profiler.Result)list.get(l);
1365
                int i1 = MathHelper.floor_double(profiler$result1.field_76332_a / 4.0D) + 1;
1366
                worldrenderer.begin(6, DefaultVertexFormats.POSITION_COLOR);
1367
                int j1 = profiler$result1.getColor();
1368
                int k1 = j1 >> 16 & 255;
1369
                int l1 = j1 >> 8 & 255;
1370
                int i2 = j1 & 255;
1371
                worldrenderer.pos((double)j, (double)k, 0.0D).color(k1, l1, i2, 255).endVertex();
1372
1373
                for (int j2 = i1; j2 >= 0; --j2)
1374
                {
1375
                    float f = (float)((d0 + profiler$result1.field_76332_a * (double)j2 / (double)i1) * Math.PI * 2.0D / 100.0D);
1376
                    float f1 = MathHelper.sin(f) * (float)i;
1377
                    float f2 = MathHelper.cos(f) * (float)i * 0.5F;
1378
                    worldrenderer.pos((double)((float)j + f1), (double)((float)k - f2), 0.0D).color(k1, l1, i2, 255).endVertex();
1379
                }
1380
1381
                tessellator.draw();
1382
                worldrenderer.begin(5, DefaultVertexFormats.POSITION_COLOR);
1383
1384
                for (int i3 = i1; i3 >= 0; --i3)
1385
                {
1386
                    float f3 = (float)((d0 + profiler$result1.field_76332_a * (double)i3 / (double)i1) * Math.PI * 2.0D / 100.0D);
1387
                    float f4 = MathHelper.sin(f3) * (float)i;
1388
                    float f5 = MathHelper.cos(f3) * (float)i * 0.5F;
1389
                    worldrenderer.pos((double)((float)j + f4), (double)((float)k - f5), 0.0D).color(k1 >> 1, l1 >> 1, i2 >> 1, 255).endVertex();
1390
                    worldrenderer.pos((double)((float)j + f4), (double)((float)k - f5 + 10.0F), 0.0D).color(k1 >> 1, l1 >> 1, i2 >> 1, 255).endVertex();
1391
                }
1392
1393
                tessellator.draw();
1394
                d0 += profiler$result1.field_76332_a;
1395
            }
1396
1397
            DecimalFormat decimalformat = new DecimalFormat("##0.00");
1398
            GlStateManager.enableTexture2D();
1399
            String s = "";
1400
1401
            if (!profiler$result.field_76331_c.equals("unspecified"))
1402
            {
1403
                s = s + "[0] ";
1404
            }
1405
1406
            if (profiler$result.field_76331_c.length() == 0)
1407
            {
1408
                s = s + "ROOT ";
1409
            }
1410
            else
1411
            {
1412
                s = s + profiler$result.field_76331_c + " ";
1413
            }
1414
1415
            int l2 = 16777215;
1416
            this.fontRendererObj.drawStringWithShadow(s, (float)(j - i), (float)(k - i / 2 - 16), l2);
1417
            this.fontRendererObj.drawStringWithShadow(s = decimalformat.format(profiler$result.field_76330_b) + "%", (float)(j + i - this.fontRendererObj.getStringWidth(s)), (float)(k - i / 2 - 16), l2);
1418
1419
            for (int k2 = 0; k2 < list.size(); ++k2)
1420
            {
1421
                Profiler.Result profiler$result2 = (Profiler.Result)list.get(k2);
1422
                String s1 = "";
1423
1424
                if (profiler$result2.field_76331_c.equals("unspecified"))
1425
                {
1426
                    s1 = s1 + "[?] ";
1427
                }
1428
                else
1429
                {
1430
                    s1 = s1 + "[" + (k2 + 1) + "] ";
1431
                }
1432
1433
                s1 = s1 + profiler$result2.field_76331_c;
1434
                this.fontRendererObj.drawStringWithShadow(s1, (float)(j - i), (float)(k + i / 2 + k2 * 8 + 20), profiler$result2.getColor());
1435
                this.fontRendererObj.drawStringWithShadow(s1 = decimalformat.format(profiler$result2.field_76332_a) + "%", (float)(j + i - 50 - this.fontRendererObj.getStringWidth(s1)), (float)(k + i / 2 + k2 * 8 + 20), profiler$result2.getColor());
1436
                this.fontRendererObj.drawStringWithShadow(s1 = decimalformat.format(profiler$result2.field_76330_b) + "%", (float)(j + i - this.fontRendererObj.getStringWidth(s1)), (float)(k + i / 2 + k2 * 8 + 20), profiler$result2.getColor());
1437
            }
1438
        }
1439
    }
1440
1441
    /**
1442
     * Called when the window is closing. Sets 'running' to false which allows the game loop to exit cleanly.
1443
     */
1444
    public void shutdown()
1445
    {
1446
        this.running = false;
1447
    }
1448
1449
    /**
1450
     * Will set the focus to ingame if the Minecraft window is the active with focus. Also clears any GUI screen
1451
     * currently displayed
1452
     */
1453
    public void setIngameFocus()
1454
    {
1455
        if (Display.isActive())
1456
        {
1457
            if (!this.inGameHasFocus)
1458
            {
1459
                this.inGameHasFocus = true;
1460
                this.mouseHelper.grabMouseCursor();
1461
                this.displayGuiScreen((GuiScreen)null);
1462
                this.leftClickCounter = 10000;
1463
            }
1464
        }
1465
    }
1466
1467
    /**
1468
     * Resets the player keystate, disables the ingame focus, and ungrabs the mouse cursor.
1469
     */
1470
    public void setIngameNotInFocus()
1471
    {
1472
        if (this.inGameHasFocus)
1473
        {
1474
            KeyBinding.unPressAllKeys();
1475
            this.inGameHasFocus = false;
1476
            this.mouseHelper.ungrabMouseCursor();
1477
        }
1478
    }
1479
1480
    /**
1481
     * Displays the ingame menu
1482
     */
1483
    public void displayInGameMenu()
1484
    {
1485
        if (this.currentScreen == null)
1486
        {
1487
            this.displayGuiScreen(new GuiIngameMenu());
1488
1489
            if (this.isSingleplayer() && !this.theIntegratedServer.getPublic())
1490
            {
1491
                this.mcSoundHandler.pauseSounds();
1492
            }
1493
        }
1494
    }
1495
1496
    private void sendClickBlockToController(boolean leftClick)
1497
    {
1498
        if (!leftClick)
1499
        {
1500
            this.leftClickCounter = 0;
1501
        }
1502
1503
        if (this.leftClickCounter <= 0 && !this.thePlayer.isUsingItem())
1504
        {
1505
            if (leftClick && this.objectMouseOver != null && this.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
1506
            {
1507
                BlockPos blockpos = this.objectMouseOver.getBlockPos();
1508
1509
                if (this.theWorld.getBlockState(blockpos).getBlock().getMaterial() != Material.air && this.playerController.onPlayerDamageBlock(blockpos, this.objectMouseOver.sideHit))
1510
                {
1511
                    this.effectRenderer.addBlockHitEffects(blockpos, this.objectMouseOver.sideHit);
1512
                    this.thePlayer.swingItem();
1513
                }
1514
            }
1515
            else
1516
            {
1517
                this.playerController.resetBlockRemoving();
1518
            }
1519
        }
1520
    }
1521
1522
    private void clickMouse()
1523
    {
1524
        if (this.leftClickCounter <= 0)
1525
        {
1526
            this.thePlayer.swingItem();
1527
1528
            if (this.objectMouseOver == null)
1529
            {
1530
                logger.error("Null returned as \'hitResult\', this shouldn\'t happen!");
1531
1532
                if (this.playerController.isNotCreative())
1533
                {
1534
                    this.leftClickCounter = 10;
1535
                }
1536
            }
1537
            else
1538
            {
1539
                switch (this.objectMouseOver.typeOfHit)
1540
                {
1541
                    case ENTITY:
1542
                        this.playerController.attackEntity(this.thePlayer, this.objectMouseOver.entityHit);
1543
                        break;
1544
1545
                    case BLOCK:
1546
                        BlockPos blockpos = this.objectMouseOver.getBlockPos();
1547
1548
                        if (this.theWorld.getBlockState(blockpos).getBlock().getMaterial() != Material.air)
1549
                        {
1550
                            this.playerController.clickBlock(blockpos, this.objectMouseOver.sideHit);
1551
                            break;
1552
                        }
1553
1554
                    case MISS:
1555
                    default:
1556
                        if (this.playerController.isNotCreative())
1557
                        {
1558
                            this.leftClickCounter = 10;
1559
                        }
1560
                }
1561
            }
1562
        }
1563
    }
1564
1565
    @SuppressWarnings("incomplete-switch")
1566
1567
    /**
1568
     * Called when user clicked he's mouse right button (place)
1569
     */
1570
    private void rightClickMouse()
1571
    {
1572
        if (!this.playerController.getIsHittingBlock())
1573
        {
1574
            this.rightClickDelayTimer = 4;
1575
            boolean flag = true;
1576
            ItemStack itemstack = this.thePlayer.inventory.getCurrentItem();
1577
1578
            if (this.objectMouseOver == null)
1579
            {
1580
                logger.warn("Null returned as \'hitResult\', this shouldn\'t happen!");
1581
            }
1582
            else
1583
            {
1584
                switch (this.objectMouseOver.typeOfHit)
1585
                {
1586
                    case ENTITY:
1587
                        if (this.playerController.isPlayerRightClickingOnEntity(this.thePlayer, this.objectMouseOver.entityHit, this.objectMouseOver))
1588
                        {
1589
                            flag = false;
1590
                        }
1591
                        else if (this.playerController.interactWithEntitySendPacket(this.thePlayer, this.objectMouseOver.entityHit))
1592
                        {
1593
                            flag = false;
1594
                        }
1595
1596
                        break;
1597
1598
                    case BLOCK:
1599
                        BlockPos blockpos = this.objectMouseOver.getBlockPos();
1600
1601
                        if (this.theWorld.getBlockState(blockpos).getBlock().getMaterial() != Material.air)
1602
                        {
1603
                            int i = itemstack != null ? itemstack.stackSize : 0;
1604
1605
                            if (this.playerController.onPlayerRightClick(this.thePlayer, this.theWorld, itemstack, blockpos, this.objectMouseOver.sideHit, this.objectMouseOver.hitVec))
1606
                            {
1607
                                flag = false;
1608
                                this.thePlayer.swingItem();
1609
                            }
1610
1611
                            if (itemstack == null)
1612
                            {
1613
                                return;
1614
                            }
1615
1616
                            if (itemstack.stackSize == 0)
1617
                            {
1618
                                this.thePlayer.inventory.mainInventory[this.thePlayer.inventory.currentItem] = null;
1619
                            }
1620
                            else if (itemstack.stackSize != i || this.playerController.isInCreativeMode())
1621
                            {
1622
                                this.entityRenderer.itemRenderer.resetEquippedProgress();
1623
                            }
1624
                        }
1625
                }
1626
            }
1627
1628
            if (flag)
1629
            {
1630
                ItemStack itemstack1 = this.thePlayer.inventory.getCurrentItem();
1631
1632
                if (itemstack1 != null && this.playerController.sendUseItem(this.thePlayer, this.theWorld, itemstack1))
1633
                {
1634
                    this.entityRenderer.itemRenderer.resetEquippedProgress2();
1635
                }
1636
            }
1637
        }
1638
    }
1639
1640
    /**
1641
     * Toggles fullscreen mode.
1642
     */
1643
    public void toggleFullscreen()
1644
    {
1645
        try
1646
        {
1647
            this.fullscreen = !this.fullscreen;
1648
            this.gameSettings.fullScreen = this.fullscreen;
1649
1650
            if (this.fullscreen)
1651
            {
1652
                this.updateDisplayMode();
1653
                this.displayWidth = Display.getDisplayMode().getWidth();
1654
                this.displayHeight = Display.getDisplayMode().getHeight();
1655
1656
                if (this.displayWidth <= 0)
1657
                {
1658
                    this.displayWidth = 1;
1659
                }
1660
1661
                if (this.displayHeight <= 0)
1662
                {
1663
                    this.displayHeight = 1;
1664
                }
1665
            }
1666
            else
1667
            {
1668
                Display.setDisplayMode(new DisplayMode(this.tempDisplayWidth, this.tempDisplayHeight));
1669
                this.displayWidth = this.tempDisplayWidth;
1670
                this.displayHeight = this.tempDisplayHeight;
1671
1672
                if (this.displayWidth <= 0)
1673
                {
1674
                    this.displayWidth = 1;
1675
                }
1676
1677
                if (this.displayHeight <= 0)
1678
                {
1679
                    this.displayHeight = 1;
1680
                }
1681
            }
1682
1683
            if (this.currentScreen != null)
1684
            {
1685
                this.resize(this.displayWidth, this.displayHeight);
1686
            }
1687
            else
1688
            {
1689
                this.updateFramebufferSize();
1690
            }
1691
1692
            Display.setFullscreen(this.fullscreen);
1693
            Display.setVSyncEnabled(this.gameSettings.enableVsync);
1694
            this.updateDisplay();
1695
        }
1696
        catch (Exception exception)
1697
        {
1698
            logger.error((String)"Couldn\'t toggle fullscreen", (Throwable)exception);
1699
        }
1700
    }
1701
1702
    /**
1703
     * Called to resize the current screen.
1704
     */
1705
    private void resize(int width, int height)
1706
    {
1707
        this.displayWidth = Math.max(1, width);
1708
        this.displayHeight = Math.max(1, height);
1709
1710
        if (this.currentScreen != null)
1711
        {
1712
            ScaledResolution scaledresolution = new ScaledResolution(this);
1713
            this.currentScreen.onResize(this, scaledresolution.getScaledWidth(), scaledresolution.getScaledHeight());
1714
        }
1715
1716
        this.loadingScreen = new LoadingScreenRenderer(this);
1717
        this.updateFramebufferSize();
1718
    }
1719
1720
    private void updateFramebufferSize()
1721
    {
1722
        this.framebufferMc.createBindFramebuffer(this.displayWidth, this.displayHeight);
1723
1724
        if (this.entityRenderer != null)
1725
        {
1726
            this.entityRenderer.updateShaderGroupSize(this.displayWidth, this.displayHeight);
1727
        }
1728
    }
1729
1730
    /**
1731
     * Return the musicTicker's instance
1732
     */
1733
    public MusicTicker getMusicTicker()
1734
    {
1735
        return this.mcMusicTicker;
1736
    }
1737
1738
    /**
1739
     * Runs the current tick.
1740
     */
1741
    public void runTick() throws IOException
1742
    {
1743
        if (this.rightClickDelayTimer > 0)
1744
        {
1745
            --this.rightClickDelayTimer;
1746
        }
1747
1748
        this.mcProfiler.startSection("gui");
1749
1750
        if (!this.isGamePaused)
1751
        {
1752
            this.ingameGUI.updateTick();
1753
        }
1754
1755
        this.mcProfiler.endSection();
1756
        this.entityRenderer.getMouseOver(1.0F);
1757
        this.mcProfiler.startSection("gameMode");
1758
1759
        if (!this.isGamePaused && this.theWorld != null)
1760
        {
1761
            this.playerController.updateController();
1762
        }
1763
1764
        this.mcProfiler.endStartSection("textures");
1765
1766
        if (!this.isGamePaused)
1767
        {
1768
            this.renderEngine.tick();
1769
        }
1770
1771
        if (this.currentScreen == null && this.thePlayer != null)
1772
        {
1773
            if (this.thePlayer.getHealth() <= 0.0F)
1774
            {
1775
                this.displayGuiScreen((GuiScreen)null);
1776
            }
1777
            else if (this.thePlayer.isPlayerSleeping() && this.theWorld != null)
1778
            {
1779
                this.displayGuiScreen(new GuiSleepMP());
1780
            }
1781
        }
1782
        else if (this.currentScreen != null && this.currentScreen instanceof GuiSleepMP && !this.thePlayer.isPlayerSleeping())
1783
        {
1784
            this.displayGuiScreen((GuiScreen)null);
1785
        }
1786
1787
        if (this.currentScreen != null)
1788
        {
1789
            this.leftClickCounter = 10000;
1790
        }
1791
1792
        if (this.currentScreen != null)
1793
        {
1794
            try
1795
            {
1796
                this.currentScreen.handleInput();
1797
            }
1798
            catch (Throwable throwable1)
1799
            {
1800
                CrashReport crashreport = CrashReport.makeCrashReport(throwable1, "Updating screen events");
1801
                CrashReportCategory crashreportcategory = crashreport.makeCategory("Affected screen");
1802
                crashreportcategory.addCrashSectionCallable("Screen name", new Callable<String>()
1803
                {
1804
                    public String call() throws Exception
1805
                    {
1806
                        return Minecraft.this.currentScreen.getClass().getCanonicalName();
1807
                    }
1808
                });
1809
                throw new ReportedException(crashreport);
1810
            }
1811
1812
            if (this.currentScreen != null)
1813
            {
1814
                try
1815
                {
1816
                    this.currentScreen.updateScreen();
1817
                }
1818
                catch (Throwable throwable)
1819
                {
1820
                    CrashReport crashreport1 = CrashReport.makeCrashReport(throwable, "Ticking screen");
1821
                    CrashReportCategory crashreportcategory1 = crashreport1.makeCategory("Affected screen");
1822
                    crashreportcategory1.addCrashSectionCallable("Screen name", new Callable<String>()
1823
                    {
1824
                        public String call() throws Exception
1825
                        {
1826
                            return Minecraft.this.currentScreen.getClass().getCanonicalName();
1827
                        }
1828
                    });
1829
                    throw new ReportedException(crashreport1);
1830
                }
1831
            }
1832
        }
1833
1834
        if (this.currentScreen == null || this.currentScreen.allowUserInput)
1835
        {
1836
            this.mcProfiler.endStartSection("mouse");
1837
1838
            while (Mouse.next())
1839
            {
1840
                int i = Mouse.getEventButton();
1841
                KeyBinding.setKeyBindState(i - 100, Mouse.getEventButtonState());
1842
1843
                if (Mouse.getEventButtonState())
1844
                {
1845
                    if (this.thePlayer.isSpectator() && i == 2)
1846
                    {
1847
                        this.ingameGUI.getSpectatorGui().func_175261_b();
1848
                    }
1849
                    else
1850
                    {
1851
                        KeyBinding.onTick(i - 100);
1852
                    }
1853
                }
1854
1855
                long i1 = getSystemTime() - this.systemTime;
1856
1857
                if (i1 <= 200L)
1858
                {
1859
                    int j = Mouse.getEventDWheel();
1860
1861
                    if (j != 0)
1862
                    {
1863
                        if (this.thePlayer.isSpectator())
1864
                        {
1865
                            j = j < 0 ? -1 : 1;
1866
1867
                            if (this.ingameGUI.getSpectatorGui().func_175262_a())
1868
                            {
1869
                                this.ingameGUI.getSpectatorGui().func_175259_b(-j);
1870
                            }
1871
                            else
1872
                            {
1873
                                float f = MathHelper.clamp_float(this.thePlayer.capabilities.getFlySpeed() + (float)j * 0.005F, 0.0F, 0.2F);
1874
                                this.thePlayer.capabilities.setFlySpeed(f);
1875
                            }
1876
                        }
1877
                        else
1878
                        {
1879
                            this.thePlayer.inventory.changeCurrentItem(j);
1880
                        }
1881
                    }
1882
1883
                    if (this.currentScreen == null)
1884
                    {
1885
                        if (!this.inGameHasFocus && Mouse.getEventButtonState())
1886
                        {
1887
                            this.setIngameFocus();
1888
                        }
1889
                    }
1890
                    else if (this.currentScreen != null)
1891
                    {
1892
                        this.currentScreen.handleMouseInput();
1893
                    }
1894
                }
1895
            }
1896
1897
            if (this.leftClickCounter > 0)
1898
            {
1899
                --this.leftClickCounter;
1900
            }
1901
1902
            this.mcProfiler.endStartSection("keyboard");
1903
1904
            while (Keyboard.next())
1905
            {
1906
                int k = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
1907
                KeyBinding.setKeyBindState(k, Keyboard.getEventKeyState());
1908
1909
                if (Keyboard.getEventKeyState())
1910
                {
1911
                    KeyBinding.onTick(k);
1912
                }
1913
1914
                if (this.debugCrashKeyPressTime > 0L)
1915
                {
1916
                    if (getSystemTime() - this.debugCrashKeyPressTime >= 6000L)
1917
                    {
1918
                        throw new ReportedException(new CrashReport("Manually triggered debug crash", new Throwable()));
1919
                    }
1920
1921
                    if (!Keyboard.isKeyDown(46) || !Keyboard.isKeyDown(61))
1922
                    {
1923
                        this.debugCrashKeyPressTime = -1L;
1924
                    }
1925
                }
1926
                else if (Keyboard.isKeyDown(46) && Keyboard.isKeyDown(61))
1927
                {
1928
                    this.debugCrashKeyPressTime = getSystemTime();
1929
                }
1930
1931
                this.dispatchKeypresses();
1932
1933
                if (Keyboard.getEventKeyState())
1934
                {
1935
                    if (k == 62 && this.entityRenderer != null)
1936
                    {
1937
                        this.entityRenderer.switchUseShader();
1938
                    }
1939
1940
                    if (this.currentScreen != null)
1941
                    {
1942
                        this.currentScreen.handleKeyboardInput();
1943
                    }
1944
                    else
1945
                    {
1946
                        if (k == 1)
1947
                        {
1948
                            this.displayInGameMenu();
1949
                        }
1950
1951
                        if (k == 32 && Keyboard.isKeyDown(61) && this.ingameGUI != null)
1952
                        {
1953
                            this.ingameGUI.getChatGUI().clearChatMessages();
1954
                        }
1955
1956
                        if (k == 31 && Keyboard.isKeyDown(61))
1957
                        {
1958
                            this.refreshResources();
1959
                        }
1960
1961
                        if (k == 17 && Keyboard.isKeyDown(61))
1962
                        {
1963
                            ;
1964
                        }
1965
1966
                        if (k == 18 && Keyboard.isKeyDown(61))
1967
                        {
1968
                            ;
1969
                        }
1970
1971
                        if (k == 47 && Keyboard.isKeyDown(61))
1972
                        {
1973
                            ;
1974
                        }
1975
1976
                        if (k == 38 && Keyboard.isKeyDown(61))
1977
                        {
1978
                            ;
1979
                        }
1980
1981
                        if (k == 22 && Keyboard.isKeyDown(61))
1982
                        {
1983
                            ;
1984
                        }
1985
1986
                        if (k == 20 && Keyboard.isKeyDown(61))
1987
                        {
1988
                            this.refreshResources();
1989
                        }
1990
1991
                        if (k == 33 && Keyboard.isKeyDown(61))
1992
                        {
1993
                            this.gameSettings.setOptionValue(GameSettings.Options.RENDER_DISTANCE, GuiScreen.isShiftKeyDown() ? -1 : 1);
1994
                        }
1995
1996
                        if (k == 30 && Keyboard.isKeyDown(61))
1997
                        {
1998
                            this.renderGlobal.loadRenderers();
1999
                        }
2000
2001
                        if (k == 35 && Keyboard.isKeyDown(61))
2002
                        {
2003
                            this.gameSettings.advancedItemTooltips = !this.gameSettings.advancedItemTooltips;
2004
                            this.gameSettings.saveOptions();
2005
                        }
2006
2007
                        if (k == 48 && Keyboard.isKeyDown(61))
2008
                        {
2009
                            this.renderManager.setDebugBoundingBox(!this.renderManager.isDebugBoundingBox());
2010
                        }
2011
2012
                        if (k == 25 && Keyboard.isKeyDown(61))
2013
                        {
2014
                            this.gameSettings.pauseOnLostFocus = !this.gameSettings.pauseOnLostFocus;
2015
                            this.gameSettings.saveOptions();
2016
                        }
2017
2018
                        if (k == 59)
2019
                        {
2020
                            this.gameSettings.hideGUI = !this.gameSettings.hideGUI;
2021
                        }
2022
2023
                        if (k == 61)
2024
                        {
2025
                            this.gameSettings.showDebugInfo = !this.gameSettings.showDebugInfo;
2026
                            this.gameSettings.showDebugProfilerChart = GuiScreen.isShiftKeyDown();
2027
                            this.gameSettings.showLagometer = GuiScreen.isAltKeyDown();
2028
                        }
2029
2030
                        if (this.gameSettings.keyBindTogglePerspective.isPressed())
2031
                        {
2032
                            ++this.gameSettings.thirdPersonView;
2033
2034
                            if (this.gameSettings.thirdPersonView > 2)
2035
                            {
2036
                                this.gameSettings.thirdPersonView = 0;
2037
                            }
2038
2039
                            if (this.gameSettings.thirdPersonView == 0)
2040
                            {
2041
                                this.entityRenderer.loadEntityShader(this.getRenderViewEntity());
2042
                            }
2043
                            else if (this.gameSettings.thirdPersonView == 1)
2044
                            {
2045
                                this.entityRenderer.loadEntityShader((Entity)null);
2046
                            }
2047
2048
                            this.renderGlobal.setDisplayListEntitiesDirty();
2049
                        }
2050
2051
                        if (this.gameSettings.keyBindSmoothCamera.isPressed())
2052
                        {
2053
                            this.gameSettings.smoothCamera = !this.gameSettings.smoothCamera;
2054
                        }
2055
                    }
2056
2057
                    if (this.gameSettings.showDebugInfo && this.gameSettings.showDebugProfilerChart)
2058
                    {
2059
                        if (k == 11)
2060
                        {
2061
                            this.updateDebugProfilerName(0);
2062
                        }
2063
2064
                        for (int j1 = 0; j1 < 9; ++j1)
2065
                        {
2066
                            if (k == 2 + j1)
2067
                            {
2068
                                this.updateDebugProfilerName(j1 + 1);
2069
                            }
2070
                        }
2071
                    }
2072
                }
2073
            }
2074
2075
            for (int l = 0; l < 9; ++l)
2076
            {
2077
                if (this.gameSettings.keyBindsHotbar[l].isPressed())
2078
                {
2079
                    if (this.thePlayer.isSpectator())
2080
                    {
2081
                        this.ingameGUI.getSpectatorGui().func_175260_a(l);
2082
                    }
2083
                    else
2084
                    {
2085
                        this.thePlayer.inventory.currentItem = l;
2086
                    }
2087
                }
2088
            }
2089
2090
            boolean flag = this.gameSettings.chatVisibility != EntityPlayer.EnumChatVisibility.HIDDEN;
2091
2092
            while (this.gameSettings.keyBindInventory.isPressed())
2093
            {
2094
                if (this.playerController.isRidingHorse())
2095
                {
2096
                    this.thePlayer.sendHorseInventory();
2097
                }
2098
                else
2099
                {
2100
                    this.getNetHandler().addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.OPEN_INVENTORY_ACHIEVEMENT));
2101
                    this.displayGuiScreen(new GuiInventory(this.thePlayer));
2102
                }
2103
            }
2104
2105
            while (this.gameSettings.keyBindDrop.isPressed())
2106
            {
2107
                if (!this.thePlayer.isSpectator())
2108
                {
2109
                    this.thePlayer.dropOneItem(GuiScreen.isCtrlKeyDown());
2110
                }
2111
            }
2112
2113
            while (this.gameSettings.keyBindChat.isPressed() && flag)
2114
            {
2115
                this.displayGuiScreen(new GuiChat());
2116
            }
2117
2118
            if (this.currentScreen == null && this.gameSettings.keyBindCommand.isPressed() && flag)
2119
            {
2120
                this.displayGuiScreen(new GuiChat("/"));
2121
            }
2122
2123
            if (this.thePlayer.isUsingItem())
2124
            {
2125
                if (!this.gameSettings.keyBindUseItem.isKeyDown())
2126
                {
2127
                    this.playerController.onStoppedUsingItem(this.thePlayer);
2128
                }
2129
2130
                while (this.gameSettings.keyBindAttack.isPressed())
2131
                {
2132
                    ;
2133
                }
2134
2135
                while (this.gameSettings.keyBindUseItem.isPressed())
2136
                {
2137
                    ;
2138
                }
2139
2140
                while (this.gameSettings.keyBindPickBlock.isPressed())
2141
                {
2142
                    ;
2143
                }
2144
            }
2145
            else
2146
            {
2147
                while (this.gameSettings.keyBindAttack.isPressed())
2148
                {
2149
                    this.clickMouse();
2150
                }
2151
2152
                while (this.gameSettings.keyBindUseItem.isPressed())
2153
                {
2154
                    this.rightClickMouse();
2155
                }
2156
2157
                while (this.gameSettings.keyBindPickBlock.isPressed())
2158
                {
2159
                    this.middleClickMouse();
2160
                }
2161
            }
2162
2163
            if (this.gameSettings.keyBindUseItem.isKeyDown() && this.rightClickDelayTimer == 0 && !this.thePlayer.isUsingItem())
2164
            {
2165
                this.rightClickMouse();
2166
            }
2167
2168
            this.sendClickBlockToController(this.currentScreen == null && this.gameSettings.keyBindAttack.isKeyDown() && this.inGameHasFocus);
2169
        }
2170
2171
        if (this.theWorld != null)
2172
        {
2173
            if (this.thePlayer != null)
2174
            {
2175
                ++this.joinPlayerCounter;
2176
2177
                if (this.joinPlayerCounter == 30)
2178
                {
2179
                    this.joinPlayerCounter = 0;
2180
                    this.theWorld.joinEntityInSurroundings(this.thePlayer);
2181
                }
2182
            }
2183
2184
            this.mcProfiler.endStartSection("gameRenderer");
2185
2186
            if (!this.isGamePaused)
2187
            {
2188
                this.entityRenderer.updateRenderer();
2189
            }
2190
2191
            this.mcProfiler.endStartSection("levelRenderer");
2192
2193
            if (!this.isGamePaused)
2194
            {
2195
                this.renderGlobal.updateClouds();
2196
            }
2197
2198
            this.mcProfiler.endStartSection("level");
2199
2200
            if (!this.isGamePaused)
2201
            {
2202
                if (this.theWorld.getLastLightningBolt() > 0)
2203
                {
2204
                    this.theWorld.setLastLightningBolt(this.theWorld.getLastLightningBolt() - 1);
2205
                }
2206
2207
                this.theWorld.updateEntities();
2208
            }
2209
        }
2210
        else if (this.entityRenderer.isShaderActive())
2211
        {
2212
            this.entityRenderer.stopUseShader();
2213
        }
2214
2215
        if (!this.isGamePaused)
2216
        {
2217
            this.mcMusicTicker.update();
2218
            this.mcSoundHandler.update();
2219
        }
2220
2221
        if (this.theWorld != null)
2222
        {
2223
            if (!this.isGamePaused)
2224
            {
2225
                this.theWorld.setAllowedSpawnTypes(this.theWorld.getDifficulty() != EnumDifficulty.PEACEFUL, true);
2226
2227
                try
2228
                {
2229
                    this.theWorld.tick();
2230
                }
2231
                catch (Throwable throwable2)
2232
                {
2233
                    CrashReport crashreport2 = CrashReport.makeCrashReport(throwable2, "Exception in world tick");
2234
2235
                    if (this.theWorld == null)
2236
                    {
2237
                        CrashReportCategory crashreportcategory2 = crashreport2.makeCategory("Affected level");
2238
                        crashreportcategory2.addCrashSection("Problem", "Level is null!");
2239
                    }
2240
                    else
2241
                    {
2242
                        this.theWorld.addWorldInfoToCrashReport(crashreport2);
2243
                    }
2244
2245
                    throw new ReportedException(crashreport2);
2246
                }
2247
            }
2248
2249
            this.mcProfiler.endStartSection("animateTick");
2250
2251
            if (!this.isGamePaused && this.theWorld != null)
2252
            {
2253
                this.theWorld.doVoidFogParticles(MathHelper.floor_double(this.thePlayer.posX), MathHelper.floor_double(this.thePlayer.posY), MathHelper.floor_double(this.thePlayer.posZ));
2254
            }
2255
2256
            this.mcProfiler.endStartSection("particles");
2257
2258
            if (!this.isGamePaused)
2259
            {
2260
                this.effectRenderer.updateEffects();
2261
            }
2262
        }
2263
        else if (this.myNetworkManager != null)
2264
        {
2265
            this.mcProfiler.endStartSection("pendingConnection");
2266
            this.myNetworkManager.processReceivedPackets();
2267
        }
2268
2269
        this.mcProfiler.endSection();
2270
        this.systemTime = getSystemTime();
2271
    }
2272
2273
    /**
2274
     * Arguments: World foldername,  World ingame name, WorldSettings
2275
     */
2276
    public void launchIntegratedServer(String folderName, String worldName, WorldSettings worldSettingsIn)
2277
    {
2278
        this.loadWorld((WorldClient)null);
2279
        System.gc();
2280
        ISaveHandler isavehandler = this.saveLoader.getSaveLoader(folderName, false);
2281
        WorldInfo worldinfo = isavehandler.loadWorldInfo();
2282
2283
        if (worldinfo == null && worldSettingsIn != null)
2284
        {
2285
            worldinfo = new WorldInfo(worldSettingsIn, folderName);
2286
            isavehandler.saveWorldInfo(worldinfo);
2287
        }
2288
2289
        if (worldSettingsIn == null)
2290
        {
2291
            worldSettingsIn = new WorldSettings(worldinfo);
2292
        }
2293
2294
        try
2295
        {
2296
            this.theIntegratedServer = new IntegratedServer(this, folderName, worldName, worldSettingsIn);
2297
            this.theIntegratedServer.startServerThread();
2298
            this.integratedServerIsRunning = true;
2299
        }
2300
        catch (Throwable throwable)
2301
        {
2302
            CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Starting integrated server");
2303
            CrashReportCategory crashreportcategory = crashreport.makeCategory("Starting integrated server");
2304
            crashreportcategory.addCrashSection("Level ID", folderName);
2305
            crashreportcategory.addCrashSection("Level Name", worldName);
2306
            throw new ReportedException(crashreport);
2307
        }
2308
2309
        this.loadingScreen.displaySavingString(I18n.format("menu.loadingLevel", new Object[0]));
2310
2311
        while (!this.theIntegratedServer.serverIsInRunLoop())
2312
        {
2313
            String s = this.theIntegratedServer.getUserMessage();
2314
2315
            if (s != null)
2316
            {
2317
                this.loadingScreen.displayLoadingString(I18n.format(s, new Object[0]));
2318
            }
2319
            else
2320
            {
2321
                this.loadingScreen.displayLoadingString("");
2322
            }
2323
2324
            try
2325
            {
2326
                Thread.sleep(200L);
2327
            }
2328
            catch (InterruptedException var9)
2329
            {
2330
                ;
2331
            }
2332
        }
2333
2334
        this.displayGuiScreen((GuiScreen)null);
2335
        SocketAddress socketaddress = this.theIntegratedServer.getNetworkSystem().addLocalEndpoint();
2336
        NetworkManager networkmanager = NetworkManager.provideLocalClient(socketaddress);
2337
        networkmanager.setNetHandler(new NetHandlerLoginClient(networkmanager, this, (GuiScreen)null));
2338
        networkmanager.sendPacket(new C00Handshake(47, socketaddress.toString(), 0, EnumConnectionState.LOGIN));
2339
        networkmanager.sendPacket(new C00PacketLoginStart(this.getSession().getProfile()));
2340
        this.myNetworkManager = networkmanager;
2341
    }
2342
2343
    /**
2344
     * unloads the current world first
2345
     */
2346
    public void loadWorld(WorldClient worldClientIn)
2347
    {
2348
        this.loadWorld(worldClientIn, "");
2349
    }
2350
2351
    /**
2352
     * par2Str is displayed on the loading screen to the user unloads the current world first
2353
     */
2354
    public void loadWorld(WorldClient worldClientIn, String loadingMessage)
2355
    {
2356
        if (worldClientIn == null)
2357
        {
2358
            NetHandlerPlayClient nethandlerplayclient = this.getNetHandler();
2359
2360
            if (nethandlerplayclient != null)
2361
            {
2362
                nethandlerplayclient.cleanup();
2363
            }
2364
2365
            if (this.theIntegratedServer != null && this.theIntegratedServer.isAnvilFileSet())
2366
            {
2367
                this.theIntegratedServer.initiateShutdown();
2368
                this.theIntegratedServer.setStaticInstance();
2369
            }
2370
2371
            this.theIntegratedServer = null;
2372
            this.guiAchievement.clearAchievements();
2373
            this.entityRenderer.getMapItemRenderer().clearLoadedMaps();
2374
        }
2375
2376
        this.renderViewEntity = null;
2377
        this.myNetworkManager = null;
2378
2379
        if (this.loadingScreen != null)
2380
        {
2381
            this.loadingScreen.resetProgressAndMessage(loadingMessage);
2382
            this.loadingScreen.displayLoadingString("");
2383
        }
2384
2385
        if (worldClientIn == null && this.theWorld != null)
2386
        {
2387
            this.mcResourcePackRepository.clearResourcePack();
2388
            this.ingameGUI.resetPlayersOverlayFooterHeader();
2389
            this.setServerData((ServerData)null);
2390
            this.integratedServerIsRunning = false;
2391
        }
2392
2393
        this.mcSoundHandler.stopSounds();
2394
        this.theWorld = worldClientIn;
2395
2396
        if (worldClientIn != null)
2397
        {
2398
            if (this.renderGlobal != null)
2399
            {
2400
                this.renderGlobal.setWorldAndLoadRenderers(worldClientIn);
2401
            }
2402
2403
            if (this.effectRenderer != null)
2404
            {
2405
                this.effectRenderer.clearEffects(worldClientIn);
2406
            }
2407
2408
            if (this.thePlayer == null)
2409
            {
2410
                this.thePlayer = this.playerController.func_178892_a(worldClientIn, new StatFileWriter());
2411
                this.playerController.flipPlayer(this.thePlayer);
2412
            }
2413
2414
            this.thePlayer.preparePlayerToSpawn();
2415
            worldClientIn.spawnEntityInWorld(this.thePlayer);
2416
            this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings);
2417
            this.playerController.setPlayerCapabilities(this.thePlayer);
2418
            this.renderViewEntity = this.thePlayer;
2419
        }
2420
        else
2421
        {
2422
            this.saveLoader.flushCache();
2423
            this.thePlayer = null;
2424
        }
2425
2426
        System.gc();
2427
        this.systemTime = 0L;
2428
    }
2429
2430
    public void setDimensionAndSpawnPlayer(int dimension)
2431
    {
2432
        this.theWorld.setInitialSpawnLocation();
2433
        this.theWorld.removeAllEntities();
2434
        int i = 0;
2435
        String s = null;
2436
2437
        if (this.thePlayer != null)
2438
        {
2439
            i = this.thePlayer.getEntityId();
2440
            this.theWorld.removeEntity(this.thePlayer);
2441
            s = this.thePlayer.getClientBrand();
2442
        }
2443
2444
        this.renderViewEntity = null;
2445
        EntityPlayerSP entityplayersp = this.thePlayer;
2446
        this.thePlayer = this.playerController.func_178892_a(this.theWorld, this.thePlayer == null ? new StatFileWriter() : this.thePlayer.getStatFileWriter());
2447
        this.thePlayer.getDataWatcher().updateWatchedObjectsFromList(entityplayersp.getDataWatcher().getAllWatched());
2448
        this.thePlayer.dimension = dimension;
2449
        this.renderViewEntity = this.thePlayer;
2450
        this.thePlayer.preparePlayerToSpawn();
2451
        this.thePlayer.setClientBrand(s);
2452
        this.theWorld.spawnEntityInWorld(this.thePlayer);
2453
        this.playerController.flipPlayer(this.thePlayer);
2454
        this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings);
2455
        this.thePlayer.setEntityId(i);
2456
        this.playerController.setPlayerCapabilities(this.thePlayer);
2457
        this.thePlayer.setReducedDebug(entityplayersp.hasReducedDebug());
2458
2459
        if (this.currentScreen instanceof GuiGameOver)
2460
        {
2461
            this.displayGuiScreen((GuiScreen)null);
2462
        }
2463
    }
2464
2465
    /**
2466
     * Gets whether this is a demo or not.
2467
     */
2468
    public final boolean isDemo()
2469
    {
2470
        return this.isDemo;
2471
    }
2472
2473
    public NetHandlerPlayClient getNetHandler()
2474
    {
2475
        return this.thePlayer != null ? this.thePlayer.sendQueue : null;
2476
    }
2477
2478
    public static boolean isGuiEnabled()
2479
    {
2480
        return theMinecraft == null || !theMinecraft.gameSettings.hideGUI;
2481
    }
2482
2483
    public static boolean isFancyGraphicsEnabled()
2484
    {
2485
        return theMinecraft != null && theMinecraft.gameSettings.fancyGraphics;
2486
    }
2487
2488
    /**
2489
     * Returns if ambient occlusion is enabled
2490
     */
2491
    public static boolean isAmbientOcclusionEnabled()
2492
    {
2493
        return theMinecraft != null && theMinecraft.gameSettings.ambientOcclusion != 0;
2494
    }
2495
2496
    /**
2497
     * Called when user clicked he's mouse middle button (pick block)
2498
     */
2499
    private void middleClickMouse()
2500
    {
2501
        if (this.objectMouseOver != null)
2502
        {
2503
            boolean flag = this.thePlayer.capabilities.isCreativeMode;
2504
            int i = 0;
2505
            boolean flag1 = false;
2506
            TileEntity tileentity = null;
2507
            Item item;
2508
2509
            if (this.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
2510
            {
2511
                BlockPos blockpos = this.objectMouseOver.getBlockPos();
2512
                Block block = this.theWorld.getBlockState(blockpos).getBlock();
2513
2514
                if (block.getMaterial() == Material.air)
2515
                {
2516
                    return;
2517
                }
2518
2519
                item = block.getItem(this.theWorld, blockpos);
2520
2521
                if (item == null)
2522
                {
2523
                    return;
2524
                }
2525
2526
                if (flag && GuiScreen.isCtrlKeyDown())
2527
                {
2528
                    tileentity = this.theWorld.getTileEntity(blockpos);
2529
                }
2530
2531
                Block block1 = item instanceof ItemBlock && !block.isFlowerPot() ? Block.getBlockFromItem(item) : block;
2532
                i = block1.getDamageValue(this.theWorld, blockpos);
2533
                flag1 = item.getHasSubtypes();
2534
            }
2535
            else
2536
            {
2537
                if (this.objectMouseOver.typeOfHit != MovingObjectPosition.MovingObjectType.ENTITY || this.objectMouseOver.entityHit == null || !flag)
2538
                {
2539
                    return;
2540
                }
2541
2542
                if (this.objectMouseOver.entityHit instanceof EntityPainting)
2543
                {
2544
                    item = Items.painting;
2545
                }
2546
                else if (this.objectMouseOver.entityHit instanceof EntityLeashKnot)
2547
                {
2548
                    item = Items.lead;
2549
                }
2550
                else if (this.objectMouseOver.entityHit instanceof EntityItemFrame)
2551
                {
2552
                    EntityItemFrame entityitemframe = (EntityItemFrame)this.objectMouseOver.entityHit;
2553
                    ItemStack itemstack = entityitemframe.getDisplayedItem();
2554
2555
                    if (itemstack == null)
2556
                    {
2557
                        item = Items.item_frame;
2558
                    }
2559
                    else
2560
                    {
2561
                        item = itemstack.getItem();
2562
                        i = itemstack.getMetadata();
2563
                        flag1 = true;
2564
                    }
2565
                }
2566
                else if (this.objectMouseOver.entityHit instanceof EntityMinecart)
2567
                {
2568
                    EntityMinecart entityminecart = (EntityMinecart)this.objectMouseOver.entityHit;
2569
2570
                    switch (entityminecart.getMinecartType())
2571
                    {
2572
                        case FURNACE:
2573
                            item = Items.furnace_minecart;
2574
                            break;
2575
2576
                        case CHEST:
2577
                            item = Items.chest_minecart;
2578
                            break;
2579
2580
                        case TNT:
2581
                            item = Items.tnt_minecart;
2582
                            break;
2583
2584
                        case HOPPER:
2585
                            item = Items.hopper_minecart;
2586
                            break;
2587
2588
                        case COMMAND_BLOCK:
2589
                            item = Items.command_block_minecart;
2590
                            break;
2591
2592
                        default:
2593
                            item = Items.minecart;
2594
                    }
2595
                }
2596
                else if (this.objectMouseOver.entityHit instanceof EntityBoat)
2597
                {
2598
                    item = Items.boat;
2599
                }
2600
                else if (this.objectMouseOver.entityHit instanceof EntityArmorStand)
2601
                {
2602
                    item = Items.armor_stand;
2603
                }
2604
                else
2605
                {
2606
                    item = Items.spawn_egg;
2607
                    i = EntityList.getEntityID(this.objectMouseOver.entityHit);
2608
                    flag1 = true;
2609
2610
                    if (!EntityList.entityEggs.containsKey(Integer.valueOf(i)))
2611
                    {
2612
                        return;
2613
                    }
2614
                }
2615
            }
2616
2617
            InventoryPlayer inventoryplayer = this.thePlayer.inventory;
2618
2619
            if (tileentity == null)
2620
            {
2621
                inventoryplayer.setCurrentItem(item, i, flag1, flag);
2622
            }
2623
            else
2624
            {
2625
                ItemStack itemstack1 = this.pickBlockWithNBT(item, i, tileentity);
2626
                inventoryplayer.setInventorySlotContents(inventoryplayer.currentItem, itemstack1);
2627
            }
2628
2629
            if (flag)
2630
            {
2631
                int j = this.thePlayer.inventoryContainer.inventorySlots.size() - 9 + inventoryplayer.currentItem;
2632
                this.playerController.sendSlotPacket(inventoryplayer.getStackInSlot(inventoryplayer.currentItem), j);
2633
            }
2634
        }
2635
    }
2636
2637
    /**
2638
     * Return an ItemStack with the NBTTag of the TileEntity ("Owner" if the block is a skull)
2639
     *  
2640
     * @param itemIn The item from the block picked
2641
     * @param meta Metadata of the item
2642
     * @param tileEntityIn TileEntity of the block picked
2643
     */
2644
    private ItemStack pickBlockWithNBT(Item itemIn, int meta, TileEntity tileEntityIn)
2645
    {
2646
        ItemStack itemstack = new ItemStack(itemIn, 1, meta);
2647
        NBTTagCompound nbttagcompound = new NBTTagCompound();
2648
        tileEntityIn.writeToNBT(nbttagcompound);
2649
2650
        if (itemIn == Items.skull && nbttagcompound.hasKey("Owner"))
2651
        {
2652
            NBTTagCompound nbttagcompound2 = nbttagcompound.getCompoundTag("Owner");
2653
            NBTTagCompound nbttagcompound3 = new NBTTagCompound();
2654
            nbttagcompound3.setTag("SkullOwner", nbttagcompound2);
2655
            itemstack.setTagCompound(nbttagcompound3);
2656
            return itemstack;
2657
        }
2658
        else
2659
        {
2660
            itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
2661
            NBTTagCompound nbttagcompound1 = new NBTTagCompound();
2662
            NBTTagList nbttaglist = new NBTTagList();
2663
            nbttaglist.appendTag(new NBTTagString("(+NBT)"));
2664
            nbttagcompound1.setTag("Lore", nbttaglist);
2665
            itemstack.setTagInfo("display", nbttagcompound1);
2666
            return itemstack;
2667
        }
2668
    }
2669
2670
    /**
2671
     * adds core server Info (GL version , Texture pack, isModded, type), and the worldInfo to the crash report
2672
     */
2673
    public CrashReport addGraphicsAndWorldToCrashReport(CrashReport theCrash)
2674
    {
2675
        theCrash.getCategory().addCrashSectionCallable("Launched Version", new Callable<String>()
2676
        {
2677
            public String call() throws Exception
2678
            {
2679
                return Minecraft.this.launchedVersion;
2680
            }
2681
        });
2682
        theCrash.getCategory().addCrashSectionCallable("LWJGL", new Callable<String>()
2683
        {
2684
            public String call()
2685
            {
2686
                return Sys.getVersion();
2687
            }
2688
        });
2689
        theCrash.getCategory().addCrashSectionCallable("OpenGL", new Callable<String>()
2690
        {
2691
            public String call()
2692
            {
2693
                return GL11.glGetString(GL11.GL_RENDERER) + " GL version " + GL11.glGetString(GL11.GL_VERSION) + ", " + GL11.glGetString(GL11.GL_VENDOR);
2694
            }
2695
        });
2696
        theCrash.getCategory().addCrashSectionCallable("GL Caps", new Callable<String>()
2697
        {
2698
            public String call()
2699
            {
2700
                return OpenGlHelper.getLogText();
2701
            }
2702
        });
2703
        theCrash.getCategory().addCrashSectionCallable("Using VBOs", new Callable<String>()
2704
        {
2705
            public String call()
2706
            {
2707
                return Minecraft.this.gameSettings.useVbo ? "Yes" : "No";
2708
            }
2709
        });
2710
        theCrash.getCategory().addCrashSectionCallable("Is Modded", new Callable<String>()
2711
        {
2712
            public String call() throws Exception
2713
            {
2714
                String s = ClientBrandRetriever.getClientModName();
2715
                return !s.equals("vanilla") ? "Definitely; Client brand changed to \'" + s + "\'" : (Minecraft.class.getSigners() == null ? "Very likely; Jar signature invalidated" : "Probably not. Jar signature remains and client brand is untouched.");
2716
            }
2717
        });
2718
        theCrash.getCategory().addCrashSectionCallable("Type", new Callable<String>()
2719
        {
2720
            public String call() throws Exception
2721
            {
2722
                return "Client (map_client.txt)";
2723
            }
2724
        });
2725
        theCrash.getCategory().addCrashSectionCallable("Resource Packs", new Callable<String>()
2726
        {
2727
            public String call() throws Exception
2728
            {
2729
                StringBuilder stringbuilder = new StringBuilder();
2730
2731
                for (String s : Minecraft.this.gameSettings.resourcePacks)
2732
                {
2733
                    if (stringbuilder.length() > 0)
2734
                    {
2735
                        stringbuilder.append(", ");
2736
                    }
2737
2738
                    stringbuilder.append(s);
2739
2740
                    if (Minecraft.this.gameSettings.incompatibleResourcePacks.contains(s))
2741
                    {
2742
                        stringbuilder.append(" (incompatible)");
2743
                    }
2744
                }
2745
2746
                return stringbuilder.toString();
2747
            }
2748
        });
2749
        theCrash.getCategory().addCrashSectionCallable("Current Language", new Callable<String>()
2750
        {
2751
            public String call() throws Exception
2752
            {
2753
                return Minecraft.this.mcLanguageManager.getCurrentLanguage().toString();
2754
            }
2755
        });
2756
        theCrash.getCategory().addCrashSectionCallable("Profiler Position", new Callable<String>()
2757
        {
2758
            public String call() throws Exception
2759
            {
2760
                return Minecraft.this.mcProfiler.profilingEnabled ? Minecraft.this.mcProfiler.getNameOfLastSection() : "N/A (disabled)";
2761
            }
2762
        });
2763
        theCrash.getCategory().addCrashSectionCallable("CPU", new Callable<String>()
2764
        {
2765
            public String call()
2766
            {
2767
                return OpenGlHelper.getCpu();
2768
            }
2769
        });
2770
2771
        if (this.theWorld != null)
2772
        {
2773
            this.theWorld.addWorldInfoToCrashReport(theCrash);
2774
        }
2775
2776
        return theCrash;
2777
    }
2778
2779
    /**
2780
     * Return the singleton Minecraft instance for the game
2781
     */
2782
    public static Minecraft getMinecraft()
2783
    {
2784
        return theMinecraft;
2785
    }
2786
2787
    public ListenableFuture<Object> scheduleResourcesRefresh()
2788
    {
2789
        return this.addScheduledTask(new Runnable()
2790
        {
2791
            public void run()
2792
            {
2793
                Minecraft.this.refreshResources();
2794
            }
2795
        });
2796
    }
2797
2798
    public void addServerStatsToSnooper(PlayerUsageSnooper playerSnooper)
2799
    {
2800
        playerSnooper.addClientStat("fps", Integer.valueOf(debugFPS));
2801
        playerSnooper.addClientStat("vsync_enabled", Boolean.valueOf(this.gameSettings.enableVsync));
2802
        playerSnooper.addClientStat("display_frequency", Integer.valueOf(Display.getDisplayMode().getFrequency()));
2803
        playerSnooper.addClientStat("display_type", this.fullscreen ? "fullscreen" : "windowed");
2804
        playerSnooper.addClientStat("run_time", Long.valueOf((MinecraftServer.getCurrentTimeMillis() - playerSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L));
2805
        playerSnooper.addClientStat("current_action", this.getCurrentAction());
2806
        String s = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN ? "little" : "big";
2807
        playerSnooper.addClientStat("endianness", s);
2808
        playerSnooper.addClientStat("resource_packs", Integer.valueOf(this.mcResourcePackRepository.getRepositoryEntries().size()));
2809
        int i = 0;
2810
2811
        for (ResourcePackRepository.Entry resourcepackrepository$entry : this.mcResourcePackRepository.getRepositoryEntries())
2812
        {
2813
            playerSnooper.addClientStat("resource_pack[" + i++ + "]", resourcepackrepository$entry.getResourcePackName());
2814
        }
2815
2816
        if (this.theIntegratedServer != null && this.theIntegratedServer.getPlayerUsageSnooper() != null)
2817
        {
2818
            playerSnooper.addClientStat("snooper_partner", this.theIntegratedServer.getPlayerUsageSnooper().getUniqueID());
2819
        }
2820
    }
2821
2822
    /**
2823
     * Return the current action's name
2824
     */
2825
    private String getCurrentAction()
2826
    {
2827
        return this.theIntegratedServer != null ? (this.theIntegratedServer.getPublic() ? "hosting_lan" : "singleplayer") : (this.currentServerData != null ? (this.currentServerData.isOnLAN() ? "playing_lan" : "multiplayer") : "out_of_game");
2828
    }
2829
2830
    public void addServerTypeToSnooper(PlayerUsageSnooper playerSnooper)
2831
    {
2832
        playerSnooper.addStatToSnooper("opengl_version", GL11.glGetString(GL11.GL_VERSION));
2833
        playerSnooper.addStatToSnooper("opengl_vendor", GL11.glGetString(GL11.GL_VENDOR));
2834
        playerSnooper.addStatToSnooper("client_brand", ClientBrandRetriever.getClientModName());
2835
        playerSnooper.addStatToSnooper("launched_version", this.launchedVersion);
2836
        ContextCapabilities contextcapabilities = GLContext.getCapabilities();
2837
        playerSnooper.addStatToSnooper("gl_caps[ARB_arrays_of_arrays]", Boolean.valueOf(contextcapabilities.GL_ARB_arrays_of_arrays));
2838
        playerSnooper.addStatToSnooper("gl_caps[ARB_base_instance]", Boolean.valueOf(contextcapabilities.GL_ARB_base_instance));
2839
        playerSnooper.addStatToSnooper("gl_caps[ARB_blend_func_extended]", Boolean.valueOf(contextcapabilities.GL_ARB_blend_func_extended));
2840
        playerSnooper.addStatToSnooper("gl_caps[ARB_clear_buffer_object]", Boolean.valueOf(contextcapabilities.GL_ARB_clear_buffer_object));
2841
        playerSnooper.addStatToSnooper("gl_caps[ARB_color_buffer_float]", Boolean.valueOf(contextcapabilities.GL_ARB_color_buffer_float));
2842
        playerSnooper.addStatToSnooper("gl_caps[ARB_compatibility]", Boolean.valueOf(contextcapabilities.GL_ARB_compatibility));
2843
        playerSnooper.addStatToSnooper("gl_caps[ARB_compressed_texture_pixel_storage]", Boolean.valueOf(contextcapabilities.GL_ARB_compressed_texture_pixel_storage));
2844
        playerSnooper.addStatToSnooper("gl_caps[ARB_compute_shader]", Boolean.valueOf(contextcapabilities.GL_ARB_compute_shader));
2845
        playerSnooper.addStatToSnooper("gl_caps[ARB_copy_buffer]", Boolean.valueOf(contextcapabilities.GL_ARB_copy_buffer));
2846
        playerSnooper.addStatToSnooper("gl_caps[ARB_copy_image]", Boolean.valueOf(contextcapabilities.GL_ARB_copy_image));
2847
        playerSnooper.addStatToSnooper("gl_caps[ARB_depth_buffer_float]", Boolean.valueOf(contextcapabilities.GL_ARB_depth_buffer_float));
2848
        playerSnooper.addStatToSnooper("gl_caps[ARB_compute_shader]", Boolean.valueOf(contextcapabilities.GL_ARB_compute_shader));
2849
        playerSnooper.addStatToSnooper("gl_caps[ARB_copy_buffer]", Boolean.valueOf(contextcapabilities.GL_ARB_copy_buffer));
2850
        playerSnooper.addStatToSnooper("gl_caps[ARB_copy_image]", Boolean.valueOf(contextcapabilities.GL_ARB_copy_image));
2851
        playerSnooper.addStatToSnooper("gl_caps[ARB_depth_buffer_float]", Boolean.valueOf(contextcapabilities.GL_ARB_depth_buffer_float));
2852
        playerSnooper.addStatToSnooper("gl_caps[ARB_depth_clamp]", Boolean.valueOf(contextcapabilities.GL_ARB_depth_clamp));
2853
        playerSnooper.addStatToSnooper("gl_caps[ARB_depth_texture]", Boolean.valueOf(contextcapabilities.GL_ARB_depth_texture));
2854
        playerSnooper.addStatToSnooper("gl_caps[ARB_draw_buffers]", Boolean.valueOf(contextcapabilities.GL_ARB_draw_buffers));
2855
        playerSnooper.addStatToSnooper("gl_caps[ARB_draw_buffers_blend]", Boolean.valueOf(contextcapabilities.GL_ARB_draw_buffers_blend));
2856
        playerSnooper.addStatToSnooper("gl_caps[ARB_draw_elements_base_vertex]", Boolean.valueOf(contextcapabilities.GL_ARB_draw_elements_base_vertex));
2857
        playerSnooper.addStatToSnooper("gl_caps[ARB_draw_indirect]", Boolean.valueOf(contextcapabilities.GL_ARB_draw_indirect));
2858
        playerSnooper.addStatToSnooper("gl_caps[ARB_draw_instanced]", Boolean.valueOf(contextcapabilities.GL_ARB_draw_instanced));
2859
        playerSnooper.addStatToSnooper("gl_caps[ARB_explicit_attrib_location]", Boolean.valueOf(contextcapabilities.GL_ARB_explicit_attrib_location));
2860
        playerSnooper.addStatToSnooper("gl_caps[ARB_explicit_uniform_location]", Boolean.valueOf(contextcapabilities.GL_ARB_explicit_uniform_location));
2861
        playerSnooper.addStatToSnooper("gl_caps[ARB_fragment_layer_viewport]", Boolean.valueOf(contextcapabilities.GL_ARB_fragment_layer_viewport));
2862
        playerSnooper.addStatToSnooper("gl_caps[ARB_fragment_program]", Boolean.valueOf(contextcapabilities.GL_ARB_fragment_program));
2863
        playerSnooper.addStatToSnooper("gl_caps[ARB_fragment_shader]", Boolean.valueOf(contextcapabilities.GL_ARB_fragment_shader));
2864
        playerSnooper.addStatToSnooper("gl_caps[ARB_fragment_program_shadow]", Boolean.valueOf(contextcapabilities.GL_ARB_fragment_program_shadow));
2865
        playerSnooper.addStatToSnooper("gl_caps[ARB_framebuffer_object]", Boolean.valueOf(contextcapabilities.GL_ARB_framebuffer_object));
2866
        playerSnooper.addStatToSnooper("gl_caps[ARB_framebuffer_sRGB]", Boolean.valueOf(contextcapabilities.GL_ARB_framebuffer_sRGB));
2867
        playerSnooper.addStatToSnooper("gl_caps[ARB_geometry_shader4]", Boolean.valueOf(contextcapabilities.GL_ARB_geometry_shader4));
2868
        playerSnooper.addStatToSnooper("gl_caps[ARB_gpu_shader5]", Boolean.valueOf(contextcapabilities.GL_ARB_gpu_shader5));
2869
        playerSnooper.addStatToSnooper("gl_caps[ARB_half_float_pixel]", Boolean.valueOf(contextcapabilities.GL_ARB_half_float_pixel));
2870
        playerSnooper.addStatToSnooper("gl_caps[ARB_half_float_vertex]", Boolean.valueOf(contextcapabilities.GL_ARB_half_float_vertex));
2871
        playerSnooper.addStatToSnooper("gl_caps[ARB_instanced_arrays]", Boolean.valueOf(contextcapabilities.GL_ARB_instanced_arrays));
2872
        playerSnooper.addStatToSnooper("gl_caps[ARB_map_buffer_alignment]", Boolean.valueOf(contextcapabilities.GL_ARB_map_buffer_alignment));
2873
        playerSnooper.addStatToSnooper("gl_caps[ARB_map_buffer_range]", Boolean.valueOf(contextcapabilities.GL_ARB_map_buffer_range));
2874
        playerSnooper.addStatToSnooper("gl_caps[ARB_multisample]", Boolean.valueOf(contextcapabilities.GL_ARB_multisample));
2875
        playerSnooper.addStatToSnooper("gl_caps[ARB_multitexture]", Boolean.valueOf(contextcapabilities.GL_ARB_multitexture));
2876
        playerSnooper.addStatToSnooper("gl_caps[ARB_occlusion_query2]", Boolean.valueOf(contextcapabilities.GL_ARB_occlusion_query2));
2877
        playerSnooper.addStatToSnooper("gl_caps[ARB_pixel_buffer_object]", Boolean.valueOf(contextcapabilities.GL_ARB_pixel_buffer_object));
2878
        playerSnooper.addStatToSnooper("gl_caps[ARB_seamless_cube_map]", Boolean.valueOf(contextcapabilities.GL_ARB_seamless_cube_map));
2879
        playerSnooper.addStatToSnooper("gl_caps[ARB_shader_objects]", Boolean.valueOf(contextcapabilities.GL_ARB_shader_objects));
2880
        playerSnooper.addStatToSnooper("gl_caps[ARB_shader_stencil_export]", Boolean.valueOf(contextcapabilities.GL_ARB_shader_stencil_export));
2881
        playerSnooper.addStatToSnooper("gl_caps[ARB_shader_texture_lod]", Boolean.valueOf(contextcapabilities.GL_ARB_shader_texture_lod));
2882
        playerSnooper.addStatToSnooper("gl_caps[ARB_shadow]", Boolean.valueOf(contextcapabilities.GL_ARB_shadow));
2883
        playerSnooper.addStatToSnooper("gl_caps[ARB_shadow_ambient]", Boolean.valueOf(contextcapabilities.GL_ARB_shadow_ambient));
2884
        playerSnooper.addStatToSnooper("gl_caps[ARB_stencil_texturing]", Boolean.valueOf(contextcapabilities.GL_ARB_stencil_texturing));
2885
        playerSnooper.addStatToSnooper("gl_caps[ARB_sync]", Boolean.valueOf(contextcapabilities.GL_ARB_sync));
2886
        playerSnooper.addStatToSnooper("gl_caps[ARB_tessellation_shader]", Boolean.valueOf(contextcapabilities.GL_ARB_tessellation_shader));
2887
        playerSnooper.addStatToSnooper("gl_caps[ARB_texture_border_clamp]", Boolean.valueOf(contextcapabilities.GL_ARB_texture_border_clamp));
2888
        playerSnooper.addStatToSnooper("gl_caps[ARB_texture_buffer_object]", Boolean.valueOf(contextcapabilities.GL_ARB_texture_buffer_object));
2889
        playerSnooper.addStatToSnooper("gl_caps[ARB_texture_cube_map]", Boolean.valueOf(contextcapabilities.GL_ARB_texture_cube_map));
2890
        playerSnooper.addStatToSnooper("gl_caps[ARB_texture_cube_map_array]", Boolean.valueOf(contextcapabilities.GL_ARB_texture_cube_map_array));
2891
        playerSnooper.addStatToSnooper("gl_caps[ARB_texture_non_power_of_two]", Boolean.valueOf(contextcapabilities.GL_ARB_texture_non_power_of_two));
2892
        playerSnooper.addStatToSnooper("gl_caps[ARB_uniform_buffer_object]", Boolean.valueOf(contextcapabilities.GL_ARB_uniform_buffer_object));
2893
        playerSnooper.addStatToSnooper("gl_caps[ARB_vertex_blend]", Boolean.valueOf(contextcapabilities.GL_ARB_vertex_blend));
2894
        playerSnooper.addStatToSnooper("gl_caps[ARB_vertex_buffer_object]", Boolean.valueOf(contextcapabilities.GL_ARB_vertex_buffer_object));
2895
        playerSnooper.addStatToSnooper("gl_caps[ARB_vertex_program]", Boolean.valueOf(contextcapabilities.GL_ARB_vertex_program));
2896
        playerSnooper.addStatToSnooper("gl_caps[ARB_vertex_shader]", Boolean.valueOf(contextcapabilities.GL_ARB_vertex_shader));
2897
        playerSnooper.addStatToSnooper("gl_caps[EXT_bindable_uniform]", Boolean.valueOf(contextcapabilities.GL_EXT_bindable_uniform));
2898
        playerSnooper.addStatToSnooper("gl_caps[EXT_blend_equation_separate]", Boolean.valueOf(contextcapabilities.GL_EXT_blend_equation_separate));
2899
        playerSnooper.addStatToSnooper("gl_caps[EXT_blend_func_separate]", Boolean.valueOf(contextcapabilities.GL_EXT_blend_func_separate));
2900
        playerSnooper.addStatToSnooper("gl_caps[EXT_blend_minmax]", Boolean.valueOf(contextcapabilities.GL_EXT_blend_minmax));
2901
        playerSnooper.addStatToSnooper("gl_caps[EXT_blend_subtract]", Boolean.valueOf(contextcapabilities.GL_EXT_blend_subtract));
2902
        playerSnooper.addStatToSnooper("gl_caps[EXT_draw_instanced]", Boolean.valueOf(contextcapabilities.GL_EXT_draw_instanced));
2903
        playerSnooper.addStatToSnooper("gl_caps[EXT_framebuffer_multisample]", Boolean.valueOf(contextcapabilities.GL_EXT_framebuffer_multisample));
2904
        playerSnooper.addStatToSnooper("gl_caps[EXT_framebuffer_object]", Boolean.valueOf(contextcapabilities.GL_EXT_framebuffer_object));
2905
        playerSnooper.addStatToSnooper("gl_caps[EXT_framebuffer_sRGB]", Boolean.valueOf(contextcapabilities.GL_EXT_framebuffer_sRGB));
2906
        playerSnooper.addStatToSnooper("gl_caps[EXT_geometry_shader4]", Boolean.valueOf(contextcapabilities.GL_EXT_geometry_shader4));
2907
        playerSnooper.addStatToSnooper("gl_caps[EXT_gpu_program_parameters]", Boolean.valueOf(contextcapabilities.GL_EXT_gpu_program_parameters));
2908
        playerSnooper.addStatToSnooper("gl_caps[EXT_gpu_shader4]", Boolean.valueOf(contextcapabilities.GL_EXT_gpu_shader4));
2909
        playerSnooper.addStatToSnooper("gl_caps[EXT_multi_draw_arrays]", Boolean.valueOf(contextcapabilities.GL_EXT_multi_draw_arrays));
2910
        playerSnooper.addStatToSnooper("gl_caps[EXT_packed_depth_stencil]", Boolean.valueOf(contextcapabilities.GL_EXT_packed_depth_stencil));
2911
        playerSnooper.addStatToSnooper("gl_caps[EXT_paletted_texture]", Boolean.valueOf(contextcapabilities.GL_EXT_paletted_texture));
2912
        playerSnooper.addStatToSnooper("gl_caps[EXT_rescale_normal]", Boolean.valueOf(contextcapabilities.GL_EXT_rescale_normal));
2913
        playerSnooper.addStatToSnooper("gl_caps[EXT_separate_shader_objects]", Boolean.valueOf(contextcapabilities.GL_EXT_separate_shader_objects));
2914
        playerSnooper.addStatToSnooper("gl_caps[EXT_shader_image_load_store]", Boolean.valueOf(contextcapabilities.GL_EXT_shader_image_load_store));
2915
        playerSnooper.addStatToSnooper("gl_caps[EXT_shadow_funcs]", Boolean.valueOf(contextcapabilities.GL_EXT_shadow_funcs));
2916
        playerSnooper.addStatToSnooper("gl_caps[EXT_shared_texture_palette]", Boolean.valueOf(contextcapabilities.GL_EXT_shared_texture_palette));
2917
        playerSnooper.addStatToSnooper("gl_caps[EXT_stencil_clear_tag]", Boolean.valueOf(contextcapabilities.GL_EXT_stencil_clear_tag));
2918
        playerSnooper.addStatToSnooper("gl_caps[EXT_stencil_two_side]", Boolean.valueOf(contextcapabilities.GL_EXT_stencil_two_side));
2919
        playerSnooper.addStatToSnooper("gl_caps[EXT_stencil_wrap]", Boolean.valueOf(contextcapabilities.GL_EXT_stencil_wrap));
2920
        playerSnooper.addStatToSnooper("gl_caps[EXT_texture_3d]", Boolean.valueOf(contextcapabilities.GL_EXT_texture_3d));
2921
        playerSnooper.addStatToSnooper("gl_caps[EXT_texture_array]", Boolean.valueOf(contextcapabilities.GL_EXT_texture_array));
2922
        playerSnooper.addStatToSnooper("gl_caps[EXT_texture_buffer_object]", Boolean.valueOf(contextcapabilities.GL_EXT_texture_buffer_object));
2923
        playerSnooper.addStatToSnooper("gl_caps[EXT_texture_integer]", Boolean.valueOf(contextcapabilities.GL_EXT_texture_integer));
2924
        playerSnooper.addStatToSnooper("gl_caps[EXT_texture_lod_bias]", Boolean.valueOf(contextcapabilities.GL_EXT_texture_lod_bias));
2925
        playerSnooper.addStatToSnooper("gl_caps[EXT_texture_sRGB]", Boolean.valueOf(contextcapabilities.GL_EXT_texture_sRGB));
2926
        playerSnooper.addStatToSnooper("gl_caps[EXT_vertex_shader]", Boolean.valueOf(contextcapabilities.GL_EXT_vertex_shader));
2927
        playerSnooper.addStatToSnooper("gl_caps[EXT_vertex_weighting]", Boolean.valueOf(contextcapabilities.GL_EXT_vertex_weighting));
2928
        playerSnooper.addStatToSnooper("gl_caps[gl_max_vertex_uniforms]", Integer.valueOf(GL11.glGetInteger(GL20.GL_MAX_VERTEX_UNIFORM_COMPONENTS)));
2929
        GL11.glGetError();
2930
        playerSnooper.addStatToSnooper("gl_caps[gl_max_fragment_uniforms]", Integer.valueOf(GL11.glGetInteger(GL20.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS)));
2931
        GL11.glGetError();
2932
        playerSnooper.addStatToSnooper("gl_caps[gl_max_vertex_attribs]", Integer.valueOf(GL11.glGetInteger(GL20.GL_MAX_VERTEX_ATTRIBS)));
2933
        GL11.glGetError();
2934
        playerSnooper.addStatToSnooper("gl_caps[gl_max_vertex_texture_image_units]", Integer.valueOf(GL11.glGetInteger(GL20.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS)));
2935
        GL11.glGetError();
2936
        playerSnooper.addStatToSnooper("gl_caps[gl_max_texture_image_units]", Integer.valueOf(GL11.glGetInteger(GL20.GL_MAX_TEXTURE_IMAGE_UNITS)));
2937
        GL11.glGetError();
2938
        playerSnooper.addStatToSnooper("gl_caps[gl_max_texture_image_units]", Integer.valueOf(GL11.glGetInteger(35071)));
2939
        GL11.glGetError();
2940
        playerSnooper.addStatToSnooper("gl_max_texture_size", Integer.valueOf(getGLMaximumTextureSize()));
2941
    }
2942
2943
    /**
2944
     * Used in the usage snooper.
2945
     */
2946
    public static int getGLMaximumTextureSize()
2947
    {
2948
        for (int i = 16384; i > 0; i >>= 1)
2949
        {
2950
            GL11.glTexImage2D(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_RGBA, i, i, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)((ByteBuffer)null));
2951
            int j = GL11.glGetTexLevelParameteri(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH);
2952
2953
            if (j != 0)
2954
            {
2955
                return i;
2956
            }
2957
        }
2958
2959
        return -1;
2960
    }
2961
2962
    /**
2963
     * Returns whether snooping is enabled or not.
2964
     */
2965
    public boolean isSnooperEnabled()
2966
    {
2967
        return this.gameSettings.snooperEnabled;
2968
    }
2969
2970
    /**
2971
     * Set the current ServerData instance.
2972
     */
2973
    public void setServerData(ServerData serverDataIn)
2974
    {
2975
        this.currentServerData = serverDataIn;
2976
    }
2977
2978
    public ServerData getCurrentServerData()
2979
    {
2980
        return this.currentServerData;
2981
    }
2982
2983
    public boolean isIntegratedServerRunning()
2984
    {
2985
        return this.integratedServerIsRunning;
2986
    }
2987
2988
    /**
2989
     * Returns true if there is only one player playing, and the current server is the integrated one.
2990
     */
2991
    public boolean isSingleplayer()
2992
    {
2993
        return this.integratedServerIsRunning && this.theIntegratedServer != null;
2994
    }
2995
2996
    /**
2997
     * Returns the currently running integrated server
2998
     */
2999
    public IntegratedServer getIntegratedServer()
3000
    {
3001
        return this.theIntegratedServer;
3002
    }
3003
3004
    public static void stopIntegratedServer()
3005
    {
3006
        if (theMinecraft != null)
3007
        {
3008
            IntegratedServer integratedserver = theMinecraft.getIntegratedServer();
3009
3010
            if (integratedserver != null)
3011
            {
3012
                integratedserver.stopServer();
3013
            }
3014
        }
3015
    }
3016
3017
    /**
3018
     * Returns the PlayerUsageSnooper instance.
3019
     */
3020
    public PlayerUsageSnooper getPlayerUsageSnooper()
3021
    {
3022
        return this.usageSnooper;
3023
    }
3024
3025
    /**
3026
     * Gets the system time in milliseconds.
3027
     */
3028
    public static long getSystemTime()
3029
    {
3030
        return Sys.getTime() * 1000L / Sys.getTimerResolution();
3031
    }
3032
3033
    /**
3034
     * Returns whether we're in full screen or not.
3035
     */
3036
    public boolean isFullScreen()
3037
    {
3038
        return this.fullscreen;
3039
    }
3040
3041
    public Session getSession()
3042
    {
3043
        return this.session;
3044
    }
3045
3046
    public PropertyMap getTwitchDetails()
3047
    {
3048
        return this.twitchDetails;
3049
    }
3050
3051
    /**
3052
     * Return the player's GameProfile properties
3053
     */
3054
    public PropertyMap getProfileProperties()
3055
    {
3056
        if (this.profileProperties.isEmpty())
3057
        {
3058
            GameProfile gameprofile = this.getSessionService().fillProfileProperties(this.session.getProfile(), false);
3059
            this.profileProperties.putAll(gameprofile.getProperties());
3060
        }
3061
3062
        return this.profileProperties;
3063
    }
3064
3065
    public Proxy getProxy()
3066
    {
3067
        return this.proxy;
3068
    }
3069
3070
    public TextureManager getTextureManager()
3071
    {
3072
        return this.renderEngine;
3073
    }
3074
3075
    public IResourceManager getResourceManager()
3076
    {
3077
        return this.mcResourceManager;
3078
    }
3079
3080
    public ResourcePackRepository getResourcePackRepository()
3081
    {
3082
        return this.mcResourcePackRepository;
3083
    }
3084
3085
    public LanguageManager getLanguageManager()
3086
    {
3087
        return this.mcLanguageManager;
3088
    }
3089
3090
    public TextureMap getTextureMapBlocks()
3091
    {
3092
        return this.textureMapBlocks;
3093
    }
3094
3095
    public boolean isJava64bit()
3096
    {
3097
        return this.jvm64bit;
3098
    }
3099
3100
    public boolean isGamePaused()
3101
    {
3102
        return this.isGamePaused;
3103
    }
3104
3105
    public SoundHandler getSoundHandler()
3106
    {
3107
        return this.mcSoundHandler;
3108
    }
3109
3110
    public MusicTicker.MusicType getAmbientMusicType()
3111
    {
3112
        return this.thePlayer != null ? (this.thePlayer.worldObj.provider instanceof WorldProviderHell ? MusicTicker.MusicType.NETHER : (this.thePlayer.worldObj.provider instanceof WorldProviderEnd ? (BossStatus.bossName != null && BossStatus.statusBarTime > 0 ? MusicTicker.MusicType.END_BOSS : MusicTicker.MusicType.END) : (this.thePlayer.capabilities.isCreativeMode && this.thePlayer.capabilities.allowFlying ? MusicTicker.MusicType.CREATIVE : MusicTicker.MusicType.GAME))) : MusicTicker.MusicType.MENU;
3113
    }
3114
3115
    public IStream getTwitchStream()
3116
    {
3117
        return this.stream;
3118
    }
3119
3120
    public void dispatchKeypresses()
3121
    {
3122
        int i = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() : Keyboard.getEventKey();
3123
3124
        if (i != 0 && !Keyboard.isRepeatEvent())
3125
        {
3126
            if (!(this.currentScreen instanceof GuiControls) || ((GuiControls)this.currentScreen).time <= getSystemTime() - 20L)
3127
            {
3128
                if (Keyboard.getEventKeyState())
3129
                {
3130
                    if (i == this.gameSettings.keyBindStreamStartStop.getKeyCode())
3131
                    {
3132
                        if (this.getTwitchStream().isBroadcasting())
3133
                        {
3134
                            this.getTwitchStream().stopBroadcasting();
3135
                        }
3136
                        else if (this.getTwitchStream().isReadyToBroadcast())
3137
                        {
3138
                            this.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback()
3139
                            {
3140
                                public void confirmClicked(boolean result, int id)
3141
                                {
3142
                                    if (result)
3143
                                    {
3144
                                        Minecraft.this.getTwitchStream().func_152930_t();
3145
                                    }
3146
3147
                                    Minecraft.this.displayGuiScreen((GuiScreen)null);
3148
                                }
3149
                            }, I18n.format("stream.confirm_start", new Object[0]), "", 0));
3150
                        }
3151
                        else if (this.getTwitchStream().func_152928_D() && this.getTwitchStream().func_152936_l())
3152
                        {
3153
                            if (this.theWorld != null)
3154
                            {
3155
                                this.ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("Not ready to start streaming yet!"));
3156
                            }
3157
                        }
3158
                        else
3159
                        {
3160
                            GuiStreamUnavailable.func_152321_a(this.currentScreen);
3161
                        }
3162
                    }
3163
                    else if (i == this.gameSettings.keyBindStreamPauseUnpause.getKeyCode())
3164
                    {
3165
                        if (this.getTwitchStream().isBroadcasting())
3166
                        {
3167
                            if (this.getTwitchStream().isPaused())
3168
                            {
3169
                                this.getTwitchStream().unpause();
3170
                            }
3171
                            else
3172
                            {
3173
                                this.getTwitchStream().pause();
3174
                            }
3175
                        }
3176
                    }
3177
                    else if (i == this.gameSettings.keyBindStreamCommercials.getKeyCode())
3178
                    {
3179
                        if (this.getTwitchStream().isBroadcasting())
3180
                        {
3181
                            this.getTwitchStream().requestCommercial();
3182
                        }
3183
                    }
3184
                    else if (i == this.gameSettings.keyBindStreamToggleMic.getKeyCode())
3185
                    {
3186
                        this.stream.muteMicrophone(true);
3187
                    }
3188
                    else if (i == this.gameSettings.keyBindFullscreen.getKeyCode())
3189
                    {
3190
                        this.toggleFullscreen();
3191
                    }
3192
                    else if (i == this.gameSettings.keyBindScreenshot.getKeyCode())
3193
                    {
3194
                        this.ingameGUI.getChatGUI().printChatMessage(ScreenShotHelper.saveScreenshot(this.mcDataDir, this.displayWidth, this.displayHeight, this.framebufferMc));
3195
                    }
3196
                }
3197
                else if (i == this.gameSettings.keyBindStreamToggleMic.getKeyCode())
3198
                {
3199
                    this.stream.muteMicrophone(false);
3200
                }
3201
            }
3202
        }
3203
    }
3204
3205
    public MinecraftSessionService getSessionService()
3206
    {
3207
        return this.sessionService;
3208
    }
3209
3210
    public SkinManager getSkinManager()
3211
    {
3212
        return this.skinManager;
3213
    }
3214
3215
    public Entity getRenderViewEntity()
3216
    {
3217
        return this.renderViewEntity;
3218
    }
3219
3220
    public void setRenderViewEntity(Entity viewingEntity)
3221
    {
3222
        this.renderViewEntity = viewingEntity;
3223
        this.entityRenderer.loadEntityShader(viewingEntity);
3224
    }
3225
3226
    public <V> ListenableFuture<V> addScheduledTask(Callable<V> callableToSchedule)
3227
    {
3228
        Validate.notNull(callableToSchedule);
3229
3230
        if (!this.isCallingFromMinecraftThread())
3231
        {
3232
            ListenableFutureTask<V> listenablefuturetask = ListenableFutureTask.<V>create(callableToSchedule);
3233
3234
            synchronized (this.scheduledTasks)
3235
            {
3236
                this.scheduledTasks.add(listenablefuturetask);
3237
                return listenablefuturetask;
3238
            }
3239
        }
3240
        else
3241
        {
3242
            try
3243
            {
3244
                return Futures.<V>immediateFuture(callableToSchedule.call());
3245
            }
3246
            catch (Exception exception)
3247
            {
3248
                return Futures.immediateFailedCheckedFuture(exception);
3249
            }
3250
        }
3251
    }
3252
3253
    public ListenableFuture<Object> addScheduledTask(Runnable runnableToSchedule)
3254
    {
3255
        Validate.notNull(runnableToSchedule);
3256
        return this.<Object>addScheduledTask(Executors.callable(runnableToSchedule));
3257
    }
3258
3259
    public boolean isCallingFromMinecraftThread()
3260
    {
3261
        return Thread.currentThread() == this.mcThread;
3262
    }
3263
3264
    public BlockRendererDispatcher getBlockRendererDispatcher()
3265
    {
3266
        return this.blockRenderDispatcher;
3267
    }
3268
3269
    public RenderManager getRenderManager()
3270
    {
3271
        return this.renderManager;
3272
    }
3273
3274
    public RenderItem getRenderItem()
3275
    {
3276
        return this.renderItem;
3277
    }
3278
3279
    public ItemRenderer getItemRenderer()
3280
    {
3281
        return this.itemRenderer;
3282
    }
3283
3284
    public static int getDebugFPS()
3285
    {
3286
        return debugFPS;
3287
    }
3288
3289
    /**
3290
     * Return the FrameTimer's instance
3291
     */
3292
    public FrameTimer getFrameTimer()
3293
    {
3294
        return this.frameTimer;
3295
    }
3296
3297
    public static Map<String, String> getSessionInfo()
3298
    {
3299
        Map<String, String> map = Maps.<String, String>newHashMap();
3300
        map.put("X-Minecraft-Username", getMinecraft().getSession().getUsername());
3301
        map.put("X-Minecraft-UUID", getMinecraft().getSession().getPlayerID());
3302
        map.put("X-Minecraft-Version", "1.8.9");
3303
        return map;
3304
    }
3305
3306
    /**
3307
     * Return true if the player is connected to a realms server
3308
     */
3309
    public boolean isConnectedToRealms()
3310
    {
3311
        return this.connectedToRealms;
3312
    }
3313
3314
    /**
3315
     * Set if the player is connected to a realms server
3316
     *  
3317
     * @param isConnected The value that set if the player is connected to a realms server or not
3318
     */
3319
    public void setConnectedToRealms(boolean isConnected)
3320
    {
3321
        this.connectedToRealms = isConnected;
3322
    }
3323
}
3324

Deobfuscated MCP 1.8.9 source of Minecraft from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/Minecraft.java), stored verbatim.