001 package net.minecraft.client; 002 003 import cpw.mods.fml.common.Side; 004 import cpw.mods.fml.common.asm.SideOnly; 005 import java.awt.BorderLayout; 006 import java.awt.Canvas; 007 import java.awt.Color; 008 import java.awt.Component; 009 import java.awt.Dimension; 010 import java.awt.Frame; 011 import java.awt.Graphics; 012 import java.io.File; 013 import java.io.IOException; 014 import java.nio.ByteBuffer; 015 import java.text.DecimalFormat; 016 import java.util.HashMap; 017 import java.util.List; 018 019 import javax.swing.JPanel; 020 021 import net.minecraft.src.AchievementList; 022 import net.minecraft.src.AnvilSaveConverter; 023 import net.minecraft.src.AxisAlignedBB; 024 import net.minecraft.src.Block; 025 import net.minecraft.src.CallableClientMemoryStats; 026 import net.minecraft.src.CallableClientProfiler; 027 import net.minecraft.src.CallableGLInfo; 028 import net.minecraft.src.CallableLWJGLVersion; 029 import net.minecraft.src.CallableModded; 030 import net.minecraft.src.CallableParticleScreenName; 031 import net.minecraft.src.CallableTexturePack; 032 import net.minecraft.src.CallableTickingScreenName; 033 import net.minecraft.src.CallableType2; 034 import net.minecraft.src.CallableUpdatingScreenName; 035 import net.minecraft.src.ColorizerFoliage; 036 import net.minecraft.src.ColorizerGrass; 037 import net.minecraft.src.ColorizerWater; 038 import net.minecraft.src.CrashReport; 039 import net.minecraft.src.CrashReportCategory; 040 import net.minecraft.src.EffectRenderer; 041 import net.minecraft.src.EntityBoat; 042 import net.minecraft.src.EntityClientPlayerMP; 043 import net.minecraft.src.EntityItemFrame; 044 import net.minecraft.src.EntityList; 045 import net.minecraft.src.EntityLiving; 046 import net.minecraft.src.EntityMinecart; 047 import net.minecraft.src.EntityPainting; 048 import net.minecraft.src.EntityRenderer; 049 import net.minecraft.src.EnumMovingObjectType; 050 import net.minecraft.src.EnumOS; 051 import net.minecraft.src.EnumOSHelper; 052 import net.minecraft.src.EnumOptions; 053 import net.minecraft.src.FontRenderer; 054 import net.minecraft.src.GLAllocation; 055 import net.minecraft.src.GameSettings; 056 import net.minecraft.src.GameWindowListener; 057 import net.minecraft.src.GuiAchievement; 058 import net.minecraft.src.GuiChat; 059 import net.minecraft.src.GuiConnecting; 060 import net.minecraft.src.GuiErrorScreen; 061 import net.minecraft.src.GuiGameOver; 062 import net.minecraft.src.GuiIngame; 063 import net.minecraft.src.GuiIngameMenu; 064 import net.minecraft.src.GuiInventory; 065 import net.minecraft.src.GuiMainMenu; 066 import net.minecraft.src.GuiMemoryErrorScreen; 067 import net.minecraft.src.GuiScreen; 068 import net.minecraft.src.GuiSleepMP; 069 import net.minecraft.src.HttpUtil; 070 import net.minecraft.src.INetworkManager; 071 import net.minecraft.src.IPlayerUsage; 072 import net.minecraft.src.ISaveFormat; 073 import net.minecraft.src.ISaveHandler; 074 import net.minecraft.src.IntegratedServer; 075 import net.minecraft.src.Item; 076 import net.minecraft.src.ItemRenderer; 077 import net.minecraft.src.ItemStack; 078 import net.minecraft.src.KeyBinding; 079 import net.minecraft.src.LoadingScreenRenderer; 080 import net.minecraft.src.MathHelper; 081 import net.minecraft.src.MemoryConnection; 082 import net.minecraft.src.MinecraftError; 083 import net.minecraft.src.MinecraftFakeLauncher; 084 import net.minecraft.src.MouseHelper; 085 import net.minecraft.src.MovementInputFromOptions; 086 import net.minecraft.src.MovingObjectPosition; 087 import net.minecraft.src.NetClientHandler; 088 import net.minecraft.src.OpenGlHelper; 089 import net.minecraft.src.Packet3Chat; 090 import net.minecraft.src.PlayerControllerMP; 091 import net.minecraft.src.PlayerUsageSnooper; 092 import net.minecraft.src.Profiler; 093 import net.minecraft.src.ProfilerResult; 094 import net.minecraft.src.RenderBlocks; 095 import net.minecraft.src.RenderEngine; 096 import net.minecraft.src.RenderGlobal; 097 import net.minecraft.src.RenderManager; 098 import net.minecraft.src.ReportedException; 099 import net.minecraft.src.ScaledResolution; 100 import net.minecraft.src.ScreenShotHelper; 101 import net.minecraft.src.ServerData; 102 import net.minecraft.src.Session; 103 import net.minecraft.src.SoundManager; 104 import net.minecraft.src.StatCollector; 105 import net.minecraft.src.StatFileWriter; 106 import net.minecraft.src.StatList; 107 import net.minecraft.src.StatStringFormatKeyInv; 108 import net.minecraft.src.StringTranslate; 109 import net.minecraft.src.Tessellator; 110 import net.minecraft.src.TextureCompassFX; 111 import net.minecraft.src.TextureFlamesFX; 112 import net.minecraft.src.TextureLavaFX; 113 import net.minecraft.src.TextureLavaFlowFX; 114 import net.minecraft.src.TexturePackList; 115 import net.minecraft.src.TexturePortalFX; 116 import net.minecraft.src.TextureWatchFX; 117 import net.minecraft.src.TextureWaterFX; 118 import net.minecraft.src.TextureWaterFlowFX; 119 import net.minecraft.src.ThreadClientSleep; 120 import net.minecraft.src.ThreadDownloadResources; 121 import net.minecraft.src.ThreadShutdown; 122 import net.minecraft.src.Timer; 123 import net.minecraft.src.WorldClient; 124 import net.minecraft.src.WorldInfo; 125 import net.minecraft.src.WorldRenderer; 126 import net.minecraft.src.WorldSettings; 127 import net.minecraftforge.common.ForgeHooks; 128 import net.minecraftforge.event.ForgeEventFactory; 129 import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; 130 131 import org.lwjgl.LWJGLException; 132 import org.lwjgl.Sys; 133 import org.lwjgl.input.Keyboard; 134 import org.lwjgl.input.Mouse; 135 import org.lwjgl.opengl.ContextCapabilities; 136 import org.lwjgl.opengl.Display; 137 import org.lwjgl.opengl.DisplayMode; 138 import org.lwjgl.opengl.GL11; 139 import org.lwjgl.opengl.GL20; 140 import org.lwjgl.opengl.GLContext; 141 import org.lwjgl.opengl.PixelFormat; 142 import org.lwjgl.util.glu.GLU; 143 144 import cpw.mods.fml.client.FMLClientHandler; 145 import cpw.mods.fml.common.FMLCommonHandler; 146 import cpw.mods.fml.common.Side; 147 import cpw.mods.fml.relauncher.ArgsWrapper; 148 import cpw.mods.fml.relauncher.FMLRelauncher; 149 150 @SideOnly(Side.CLIENT) 151 public abstract class Minecraft implements Runnable, IPlayerUsage 152 { 153 /** A 10MiB preallocation to ensure the heap is reasonably sized. */ 154 public static byte[] memoryReserve = new byte[10485760]; 155 private ServerData currentServerData; 156 157 /** 158 * Set to 'this' in Minecraft constructor; used by some settings get methods 159 */ 160 private static Minecraft theMinecraft; 161 public PlayerControllerMP playerController; 162 private boolean fullscreen = false; 163 private boolean hasCrashed = false; 164 165 /** Instance of CrashReport. */ 166 private CrashReport crashReporter; 167 public int displayWidth; 168 public int displayHeight; 169 private Timer timer = new Timer(20.0F); 170 171 /** Instance of PlayerUsageSnooper. */ 172 private PlayerUsageSnooper usageSnooper = new PlayerUsageSnooper("client", this); 173 public WorldClient theWorld; 174 public RenderGlobal renderGlobal; 175 public EntityClientPlayerMP thePlayer; 176 177 /** 178 * The Entity from which the renderer determines the render viewpoint. Currently is always the parent Minecraft 179 * class's 'thePlayer' instance. Modification of its location, rotation, or other settings at render time will 180 * modify the camera likewise, with the caveat of triggering chunk rebuilds as it moves, making it unsuitable for 181 * changing the viewpoint mid-render. 182 */ 183 public EntityLiving renderViewEntity; 184 public EffectRenderer effectRenderer; 185 public Session session = null; 186 public String minecraftUri; 187 public Canvas mcCanvas; 188 189 /** a boolean to hide a Quit button from the main menu */ 190 public boolean hideQuitButton = false; 191 public volatile boolean isGamePaused = false; 192 193 /** The RenderEngine instance used by Minecraft */ 194 public RenderEngine renderEngine; 195 196 /** The font renderer used for displaying and measuring text. */ 197 public FontRenderer fontRenderer; 198 public FontRenderer standardGalacticFontRenderer; 199 200 /** The GuiScreen that's being displayed at the moment. */ 201 public GuiScreen currentScreen = null; 202 public LoadingScreenRenderer loadingScreen; 203 public EntityRenderer entityRenderer; 204 205 /** Reference to the download resources thread. */ 206 private ThreadDownloadResources downloadResourcesThread; 207 208 /** Mouse left click counter */ 209 private int leftClickCounter = 0; 210 211 /** Display width */ 212 private int tempDisplayWidth; 213 214 /** Display height */ 215 private int tempDisplayHeight; 216 217 /** Instance of IntegratedServer. */ 218 private IntegratedServer theIntegratedServer; 219 220 /** Gui achievement */ 221 public GuiAchievement guiAchievement = new GuiAchievement(this); 222 public GuiIngame ingameGUI; 223 224 /** Skip render world */ 225 public boolean skipRenderWorld = false; 226 227 /** The ray trace hit that the mouse is over. */ 228 public MovingObjectPosition objectMouseOver = null; 229 230 /** The game settings that currently hold effect. */ 231 public GameSettings gameSettings; 232 protected MinecraftApplet mcApplet; 233 public SoundManager sndManager = new SoundManager(); 234 235 /** Mouse helper instance. */ 236 public MouseHelper mouseHelper; 237 238 /** The TexturePackLister used by this instance of Minecraft... */ 239 public TexturePackList texturePackList; 240 public File mcDataDir; 241 private ISaveFormat saveLoader; 242 243 /** 244 * This is set to fpsCounter every debug screen update, and is shown on the debug screen. It's also sent as part of 245 * the usage snooping. 246 */ 247 private static int debugFPS; 248 249 /** 250 * When you place a block, it's set to 6, decremented once per tick, when it's 0, you can place another block. 251 */ 252 private int rightClickDelayTimer = 0; 253 254 /** 255 * Checked in Minecraft's while(running) loop, if true it's set to false and the textures refreshed. 256 */ 257 private boolean refreshTexturePacksScheduled; 258 259 /** Stat file writer */ 260 public StatFileWriter statFileWriter; 261 private String serverName; 262 private int serverPort; 263 private TextureWaterFX textureWaterFX = new TextureWaterFX(); 264 private TextureLavaFX textureLavaFX = new TextureLavaFX(); 265 266 /** 267 * Makes sure it doesn't keep taking screenshots when both buttons are down. 268 */ 269 boolean isTakingScreenshot = false; 270 271 /** 272 * Does the actual gameplay have focus. If so then mouse and keys will effect the player instead of menus. 273 */ 274 public boolean inGameHasFocus = false; 275 long systemTime = getSystemTime(); 276 277 /** Join player counter */ 278 private int joinPlayerCounter = 0; 279 private boolean isDemo; 280 private INetworkManager myNetworkManager; 281 private boolean integratedServerIsRunning; 282 283 /** The profiler instance */ 284 public final Profiler mcProfiler = new Profiler(); 285 private long field_83002_am = -1L; 286 287 /** The working dir (OS specific) for minecraft */ 288 private static File minecraftDir = null; 289 290 /** 291 * Set to true to keep the game loop running. Set to false by shutdown() to allow the game loop to exit cleanly. 292 */ 293 public volatile boolean running = true; 294 295 /** String that shows the debug information */ 296 public String debug = ""; 297 298 /** Approximate time (in ms) of last update to debug string */ 299 long debugUpdateTime = getSystemTime(); 300 301 /** holds the current fps */ 302 int fpsCounter = 0; 303 long prevFrameTime = -1L; 304 305 /** Profiler currently displayed in the debug screen pie chart */ 306 private String debugProfilerName = "root"; 307 308 public Minecraft(Canvas par1Canvas, MinecraftApplet par2MinecraftApplet, int par3, int par4, boolean par5) 309 { 310 StatList.func_75919_a(); 311 this.tempDisplayHeight = par4; 312 this.fullscreen = par5; 313 this.mcApplet = par2MinecraftApplet; 314 Packet3Chat.maxChatLength = 32767; 315 this.startTimerHackThread(); 316 this.mcCanvas = par1Canvas; 317 this.displayWidth = par3; 318 this.displayHeight = par4; 319 this.fullscreen = par5; 320 theMinecraft = this; 321 } 322 323 private void startTimerHackThread() 324 { 325 ThreadClientSleep var1 = new ThreadClientSleep(this, "Timer hack thread"); 326 var1.setDaemon(true); 327 var1.start(); 328 } 329 330 public void crashed(CrashReport par1CrashReport) 331 { 332 this.hasCrashed = true; 333 this.crashReporter = par1CrashReport; 334 } 335 336 /** 337 * Wrapper around displayCrashReportInternal 338 */ 339 public void displayCrashReport(CrashReport par1CrashReport) 340 { 341 this.hasCrashed = true; 342 this.displayCrashReportInternal(par1CrashReport); 343 } 344 345 public abstract void displayCrashReportInternal(CrashReport var1); 346 347 public void setServer(String par1Str, int par2) 348 { 349 this.serverName = par1Str; 350 this.serverPort = par2; 351 } 352 353 /** 354 * Starts the game: initializes the canvas, the title, the settings, etcetera. 355 */ 356 public void startGame() throws LWJGLException 357 { 358 if (this.mcCanvas != null) 359 { 360 Graphics var1 = this.mcCanvas.getGraphics(); 361 362 if (var1 != null) 363 { 364 var1.setColor(Color.BLACK); 365 var1.fillRect(0, 0, this.displayWidth, this.displayHeight); 366 var1.dispose(); 367 } 368 369 Display.setParent(this.mcCanvas); 370 } 371 else if (this.fullscreen) 372 { 373 Display.setFullscreen(true); 374 this.displayWidth = Display.getDisplayMode().getWidth(); 375 this.displayHeight = Display.getDisplayMode().getHeight(); 376 377 if (this.displayWidth <= 0) 378 { 379 this.displayWidth = 1; 380 } 381 382 if (this.displayHeight <= 0) 383 { 384 this.displayHeight = 1; 385 } 386 } 387 else 388 { 389 Display.setDisplayMode(new DisplayMode(this.displayWidth, this.displayHeight)); 390 } 391 392 Display.setTitle("Minecraft Minecraft 1.4.4"); 393 System.out.println("LWJGL Version: " + Sys.getVersion()); 394 395 try 396 { 397 Display.create((new PixelFormat()).withDepthBits(24)); 398 } 399 catch (LWJGLException var5) 400 { 401 var5.printStackTrace(); 402 403 try 404 { 405 Thread.sleep(1000L); 406 } 407 catch (InterruptedException var4) 408 { 409 ; 410 } 411 412 Display.create(); 413 } 414 415 OpenGlHelper.initializeTextures(); 416 this.mcDataDir = getMinecraftDir(); 417 this.saveLoader = new AnvilSaveConverter(new File(this.mcDataDir, "saves")); 418 this.gameSettings = new GameSettings(this, this.mcDataDir); 419 this.texturePackList = new TexturePackList(this.mcDataDir, this); 420 this.renderEngine = new RenderEngine(this.texturePackList, this.gameSettings); 421 this.loadScreen(); 422 this.fontRenderer = new FontRenderer(this.gameSettings, "/font/default.png", this.renderEngine, false); 423 this.standardGalacticFontRenderer = new FontRenderer(this.gameSettings, "/font/alternate.png", this.renderEngine, false); 424 FMLClientHandler.instance().beginMinecraftLoading(this); 425 if (this.gameSettings.language != null) 426 { 427 StringTranslate.getInstance().setLanguage(this.gameSettings.language); 428 this.fontRenderer.setUnicodeFlag(StringTranslate.getInstance().isUnicode()); 429 this.fontRenderer.setBidiFlag(StringTranslate.isBidirectional(this.gameSettings.language)); 430 } 431 432 ColorizerWater.setWaterBiomeColorizer(this.renderEngine.getTextureContents("/misc/watercolor.png")); 433 ColorizerGrass.setGrassBiomeColorizer(this.renderEngine.getTextureContents("/misc/grasscolor.png")); 434 ColorizerFoliage.getFoilageBiomeColorizer(this.renderEngine.getTextureContents("/misc/foliagecolor.png")); 435 this.entityRenderer = new EntityRenderer(this); 436 RenderManager.instance.itemRenderer = new ItemRenderer(this); 437 this.statFileWriter = new StatFileWriter(this.session, this.mcDataDir); 438 AchievementList.openInventory.setStatStringFormatter(new StatStringFormatKeyInv(this)); 439 this.loadScreen(); 440 Mouse.create(); 441 this.mouseHelper = new MouseHelper(this.mcCanvas, this.gameSettings); 442 this.checkGLError("Pre startup"); 443 GL11.glEnable(GL11.GL_TEXTURE_2D); 444 GL11.glShadeModel(GL11.GL_SMOOTH); 445 GL11.glClearDepth(1.0D); 446 GL11.glEnable(GL11.GL_DEPTH_TEST); 447 GL11.glDepthFunc(GL11.GL_LEQUAL); 448 GL11.glEnable(GL11.GL_ALPHA_TEST); 449 GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); 450 GL11.glCullFace(GL11.GL_BACK); 451 GL11.glMatrixMode(GL11.GL_PROJECTION); 452 GL11.glLoadIdentity(); 453 GL11.glMatrixMode(GL11.GL_MODELVIEW); 454 this.checkGLError("Startup"); 455 this.sndManager.loadSoundSettings(this.gameSettings); 456 this.renderEngine.registerTextureFX(this.textureLavaFX); 457 this.renderEngine.registerTextureFX(this.textureWaterFX); 458 this.renderEngine.registerTextureFX(new TexturePortalFX()); 459 this.renderEngine.registerTextureFX(new TextureCompassFX(this)); 460 this.renderEngine.registerTextureFX(new TextureWatchFX(this)); 461 this.renderEngine.registerTextureFX(new TextureWaterFlowFX()); 462 this.renderEngine.registerTextureFX(new TextureLavaFlowFX()); 463 this.renderEngine.registerTextureFX(new TextureFlamesFX(0)); 464 this.renderEngine.registerTextureFX(new TextureFlamesFX(1)); 465 this.renderGlobal = new RenderGlobal(this, this.renderEngine); 466 GL11.glViewport(0, 0, this.displayWidth, this.displayHeight); 467 this.effectRenderer = new EffectRenderer(this.theWorld, this.renderEngine); 468 469 FMLClientHandler.instance().finishMinecraftLoading(); 470 471 try 472 { 473 this.downloadResourcesThread = new ThreadDownloadResources(this.mcDataDir, this); 474 this.downloadResourcesThread.start(); 475 } 476 catch (Exception var3) 477 { 478 ; 479 } 480 481 this.checkGLError("Post startup"); 482 this.ingameGUI = new GuiIngame(this); 483 484 if (this.serverName != null) 485 { 486 this.displayGuiScreen(new GuiConnecting(this, this.serverName, this.serverPort)); 487 } 488 else 489 { 490 this.displayGuiScreen(new GuiMainMenu()); 491 } 492 493 this.loadingScreen = new LoadingScreenRenderer(this); 494 495 if (this.gameSettings.fullScreen && !this.fullscreen) 496 { 497 this.toggleFullscreen(); 498 } 499 FMLClientHandler.instance().onInitializationComplete(); 500 } 501 502 /** 503 * Displays a new screen. 504 */ 505 private void loadScreen() throws LWJGLException 506 { 507 ScaledResolution var1 = new ScaledResolution(this.gameSettings, this.displayWidth, this.displayHeight); 508 GL11.glClear(16640); 509 GL11.glMatrixMode(GL11.GL_PROJECTION); 510 GL11.glLoadIdentity(); 511 GL11.glOrtho(0.0D, var1.getScaledWidth_double(), var1.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D); 512 GL11.glMatrixMode(GL11.GL_MODELVIEW); 513 GL11.glLoadIdentity(); 514 GL11.glTranslatef(0.0F, 0.0F, -2000.0F); 515 GL11.glViewport(0, 0, this.displayWidth, this.displayHeight); 516 GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F); 517 GL11.glDisable(GL11.GL_LIGHTING); 518 GL11.glEnable(GL11.GL_TEXTURE_2D); 519 GL11.glDisable(GL11.GL_FOG); 520 Tessellator var2 = Tessellator.instance; 521 GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/title/mojang.png")); 522 var2.startDrawingQuads(); 523 var2.setColorOpaque_I(16777215); 524 var2.addVertexWithUV(0.0D, (double)this.displayHeight, 0.0D, 0.0D, 0.0D); 525 var2.addVertexWithUV((double)this.displayWidth, (double)this.displayHeight, 0.0D, 0.0D, 0.0D); 526 var2.addVertexWithUV((double)this.displayWidth, 0.0D, 0.0D, 0.0D, 0.0D); 527 var2.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0.0D); 528 var2.draw(); 529 GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 530 var2.setColorOpaque_I(16777215); 531 short var3 = 256; 532 short var4 = 256; 533 this.scaledTessellator((var1.getScaledWidth() - var3) / 2, (var1.getScaledHeight() - var4) / 2, 0, 0, var3, var4); 534 GL11.glDisable(GL11.GL_LIGHTING); 535 GL11.glDisable(GL11.GL_FOG); 536 GL11.glEnable(GL11.GL_ALPHA_TEST); 537 GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); 538 Display.swapBuffers(); 539 } 540 541 /** 542 * Loads Tessellator with a scaled resolution 543 */ 544 public void scaledTessellator(int par1, int par2, int par3, int par4, int par5, int par6) 545 { 546 float var7 = 0.00390625F; 547 float var8 = 0.00390625F; 548 Tessellator var9 = Tessellator.instance; 549 var9.startDrawingQuads(); 550 var9.addVertexWithUV((double)(par1 + 0), (double)(par2 + par6), 0.0D, (double)((float)(par3 + 0) * var7), (double)((float)(par4 + par6) * var8)); 551 var9.addVertexWithUV((double)(par1 + par5), (double)(par2 + par6), 0.0D, (double)((float)(par3 + par5) * var7), (double)((float)(par4 + par6) * var8)); 552 var9.addVertexWithUV((double)(par1 + par5), (double)(par2 + 0), 0.0D, (double)((float)(par3 + par5) * var7), (double)((float)(par4 + 0) * var8)); 553 var9.addVertexWithUV((double)(par1 + 0), (double)(par2 + 0), 0.0D, (double)((float)(par3 + 0) * var7), (double)((float)(par4 + 0) * var8)); 554 var9.draw(); 555 } 556 557 /** 558 * gets the working dir (OS specific) for minecraft 559 */ 560 public static File getMinecraftDir() 561 { 562 if (minecraftDir == null) 563 { 564 minecraftDir = getAppDir("minecraft"); 565 } 566 567 return minecraftDir; 568 } 569 570 /** 571 * gets the working dir (OS specific) for the specific application (which is always minecraft) 572 */ 573 public static File getAppDir(String par0Str) 574 { 575 String var1 = System.getProperty("user.home", "."); 576 File var2; 577 578 switch (EnumOSHelper.field_90049_a[getOs().ordinal()]) 579 { 580 case 1: 581 case 2: 582 var2 = new File(var1, '.' + par0Str + '/'); 583 break; 584 case 3: 585 String var3 = System.getenv("APPDATA"); 586 587 if (var3 != null) 588 { 589 var2 = new File(var3, "." + par0Str + '/'); 590 } 591 else 592 { 593 var2 = new File(var1, '.' + par0Str + '/'); 594 } 595 596 break; 597 case 4: 598 var2 = new File(var1, "Library/Application Support/" + par0Str); 599 break; 600 default: 601 var2 = new File(var1, par0Str + '/'); 602 } 603 604 if (!var2.exists() && !var2.mkdirs()) 605 { 606 throw new RuntimeException("The working directory could not be created: " + var2); 607 } 608 else 609 { 610 return var2; 611 } 612 } 613 614 public static EnumOS getOs() 615 { 616 String var0 = System.getProperty("os.name").toLowerCase(); 617 return var0.contains("win") ? EnumOS.WINDOWS : (var0.contains("mac") ? EnumOS.MACOS : (var0.contains("solaris") ? EnumOS.SOLARIS : (var0.contains("sunos") ? EnumOS.SOLARIS : (var0.contains("linux") ? EnumOS.LINUX : (var0.contains("unix") ? EnumOS.LINUX : EnumOS.UNKNOWN))))); 618 } 619 620 /** 621 * Returns the save loader that is currently being used 622 */ 623 public ISaveFormat getSaveLoader() 624 { 625 return this.saveLoader; 626 } 627 628 /** 629 * Sets the argument GuiScreen as the main (topmost visible) screen. 630 */ 631 public void displayGuiScreen(GuiScreen par1GuiScreen) 632 { 633 if (!(this.currentScreen instanceof GuiErrorScreen)) 634 { 635 if (this.currentScreen != null) 636 { 637 this.currentScreen.onGuiClosed(); 638 } 639 640 this.statFileWriter.syncStats(); 641 642 if (par1GuiScreen == null && this.theWorld == null) 643 { 644 par1GuiScreen = new GuiMainMenu(); 645 } 646 else if (par1GuiScreen == null && this.thePlayer.getHealth() <= 0) 647 { 648 par1GuiScreen = new GuiGameOver(); 649 } 650 651 if (par1GuiScreen instanceof GuiMainMenu) 652 { 653 this.gameSettings.showDebugInfo = false; 654 this.ingameGUI.getChatGUI().func_73761_a(); 655 } 656 657 this.currentScreen = (GuiScreen)par1GuiScreen; 658 659 if (par1GuiScreen != null) 660 { 661 this.setIngameNotInFocus(); 662 ScaledResolution var2 = new ScaledResolution(this.gameSettings, this.displayWidth, this.displayHeight); 663 int var3 = var2.getScaledWidth(); 664 int var4 = var2.getScaledHeight(); 665 ((GuiScreen)par1GuiScreen).setWorldAndResolution(this, var3, var4); 666 this.skipRenderWorld = false; 667 } 668 else 669 { 670 this.setIngameFocus(); 671 } 672 } 673 } 674 675 /** 676 * Checks for an OpenGL error. If there is one, prints the error ID and error string. 677 */ 678 private void checkGLError(String par1Str) 679 { 680 int var2 = GL11.glGetError(); 681 682 if (var2 != 0) 683 { 684 String var3 = GLU.gluErrorString(var2); 685 System.out.println("########## GL ERROR ##########"); 686 System.out.println("@ " + par1Str); 687 System.out.println(var2 + ": " + var3); 688 } 689 } 690 691 /** 692 * Shuts down the minecraft applet by stopping the resource downloads, and clearing up GL stuff; called when the 693 * application (or web page) is exited. 694 */ 695 public void shutdownMinecraftApplet() 696 { 697 try 698 { 699 this.statFileWriter.syncStats(); 700 701 try 702 { 703 if (this.downloadResourcesThread != null) 704 { 705 this.downloadResourcesThread.closeMinecraft(); 706 } 707 } 708 catch (Exception var9) 709 { 710 ; 711 } 712 713 System.out.println("Stopping!"); 714 715 try 716 { 717 this.loadWorld((WorldClient)null); 718 } 719 catch (Throwable var8) 720 { 721 ; 722 } 723 724 try 725 { 726 GLAllocation.deleteTexturesAndDisplayLists(); 727 } 728 catch (Throwable var7) 729 { 730 ; 731 } 732 733 this.sndManager.closeMinecraft(); 734 Mouse.destroy(); 735 Keyboard.destroy(); 736 } 737 finally 738 { 739 Display.destroy(); 740 741 if (!this.hasCrashed) 742 { 743 System.exit(0); 744 } 745 } 746 747 System.gc(); 748 } 749 750 public void run() 751 { 752 this.running = true; 753 754 try 755 { 756 this.startGame(); 757 } 758 catch (Exception var11) 759 { 760 var11.printStackTrace(); 761 this.displayCrashReport(this.addGraphicsAndWorldToCrashReport(new CrashReport("Failed to start game", var11))); 762 return; 763 } 764 765 try 766 { 767 while (this.running) 768 { 769 if (this.hasCrashed && this.crashReporter != null) 770 { 771 this.displayCrashReport(this.crashReporter); 772 return; 773 } 774 775 if (this.refreshTexturePacksScheduled) 776 { 777 this.refreshTexturePacksScheduled = false; 778 this.renderEngine.refreshTextures(); 779 } 780 781 try 782 { 783 this.runGameLoop(); 784 } 785 catch (OutOfMemoryError var10) 786 { 787 this.freeMemory(); 788 this.displayGuiScreen(new GuiMemoryErrorScreen()); 789 System.gc(); 790 } 791 } 792 } 793 catch (MinecraftError var12) 794 { 795 ; 796 } 797 catch (ReportedException var13) 798 { 799 this.addGraphicsAndWorldToCrashReport(var13.getTheReportedExceptionCrashReport()); 800 this.freeMemory(); 801 var13.printStackTrace(); 802 this.displayCrashReport(var13.getTheReportedExceptionCrashReport()); 803 } 804 catch (Throwable var14) 805 { 806 CrashReport var2 = this.addGraphicsAndWorldToCrashReport(new CrashReport("Unexpected error", var14)); 807 this.freeMemory(); 808 var14.printStackTrace(); 809 this.displayCrashReport(var2); 810 } 811 finally 812 { 813 this.shutdownMinecraftApplet(); 814 } 815 } 816 817 /** 818 * Called repeatedly from run() 819 */ 820 private void runGameLoop() 821 { 822 if (this.mcApplet != null && !this.mcApplet.isActive()) 823 { 824 this.running = false; 825 } 826 else 827 { 828 AxisAlignedBB.getAABBPool().cleanPool(); 829 830 if (this.theWorld != null) 831 { 832 this.theWorld.getWorldVec3Pool().clear(); 833 } 834 835 this.mcProfiler.startSection("root"); 836 837 if (this.mcCanvas == null && Display.isCloseRequested()) 838 { 839 this.shutdown(); 840 } 841 842 if (this.isGamePaused && this.theWorld != null) 843 { 844 float var1 = this.timer.renderPartialTicks; 845 this.timer.updateTimer(); 846 this.timer.renderPartialTicks = var1; 847 } 848 else 849 { 850 this.timer.updateTimer(); 851 } 852 853 long var6 = System.nanoTime(); 854 this.mcProfiler.startSection("tick"); 855 856 for (int var3 = 0; var3 < this.timer.elapsedTicks; ++var3) 857 { 858 this.runTick(); 859 } 860 861 this.mcProfiler.endStartSection("preRenderErrors"); 862 long var7 = System.nanoTime() - var6; 863 this.checkGLError("Pre render"); 864 RenderBlocks.fancyGrass = this.gameSettings.fancyGraphics; 865 this.mcProfiler.endStartSection("sound"); 866 this.sndManager.setListener(this.thePlayer, this.timer.renderPartialTicks); 867 this.mcProfiler.endSection(); 868 this.mcProfiler.startSection("render"); 869 this.mcProfiler.startSection("display"); 870 GL11.glEnable(GL11.GL_TEXTURE_2D); 871 872 if (!Keyboard.isKeyDown(65)) 873 { 874 Display.update(); 875 } 876 877 if (this.thePlayer != null && this.thePlayer.isEntityInsideOpaqueBlock()) 878 { 879 this.gameSettings.thirdPersonView = 0; 880 } 881 882 this.mcProfiler.endSection(); 883 884 if (!this.skipRenderWorld) 885 { 886 FMLCommonHandler.instance().onRenderTickStart(this.timer.renderPartialTicks); 887 this.mcProfiler.endStartSection("gameRenderer"); 888 this.entityRenderer.updateCameraAndRender(this.timer.renderPartialTicks); 889 this.mcProfiler.endSection(); 890 FMLCommonHandler.instance().onRenderTickEnd(this.timer.renderPartialTicks); 891 } 892 893 GL11.glFlush(); 894 this.mcProfiler.endSection(); 895 896 if (!Display.isActive() && this.fullscreen) 897 { 898 this.toggleFullscreen(); 899 } 900 901 if (this.gameSettings.showDebugInfo && this.gameSettings.showDebugProfilerChart) 902 { 903 if (!this.mcProfiler.profilingEnabled) 904 { 905 this.mcProfiler.clearProfiling(); 906 } 907 908 this.mcProfiler.profilingEnabled = true; 909 this.displayDebugInfo(var7); 910 } 911 else 912 { 913 this.mcProfiler.profilingEnabled = false; 914 this.prevFrameTime = System.nanoTime(); 915 } 916 917 this.guiAchievement.updateAchievementWindow(); 918 this.mcProfiler.startSection("root"); 919 Thread.yield(); 920 921 if (Keyboard.isKeyDown(65)) 922 { 923 Display.update(); 924 } 925 926 this.screenshotListener(); 927 928 if (this.mcCanvas != null && !this.fullscreen && (this.mcCanvas.getWidth() != this.displayWidth || this.mcCanvas.getHeight() != this.displayHeight)) 929 { 930 this.displayWidth = this.mcCanvas.getWidth(); 931 this.displayHeight = this.mcCanvas.getHeight(); 932 933 if (this.displayWidth <= 0) 934 { 935 this.displayWidth = 1; 936 } 937 938 if (this.displayHeight <= 0) 939 { 940 this.displayHeight = 1; 941 } 942 943 this.resize(this.displayWidth, this.displayHeight); 944 } 945 946 this.checkGLError("Post render"); 947 ++this.fpsCounter; 948 boolean var5 = this.isGamePaused; 949 this.isGamePaused = this.isSingleplayer() && this.currentScreen != null && this.currentScreen.doesGuiPauseGame() && !this.theIntegratedServer.getPublic(); 950 951 if (this.isIntegratedServerRunning() && this.thePlayer != null && this.thePlayer.sendQueue != null && this.isGamePaused != var5) 952 { 953 ((MemoryConnection)this.thePlayer.sendQueue.getNetManager()).setGamePaused(this.isGamePaused); 954 } 955 956 while (getSystemTime() >= this.debugUpdateTime + 1000L) 957 { 958 debugFPS = this.fpsCounter; 959 this.debug = debugFPS + " fps, " + WorldRenderer.chunksUpdated + " chunk updates"; 960 WorldRenderer.chunksUpdated = 0; 961 this.debugUpdateTime += 1000L; 962 this.fpsCounter = 0; 963 this.usageSnooper.addMemoryStatsToSnooper(); 964 965 if (!this.usageSnooper.isSnooperRunning()) 966 { 967 this.usageSnooper.startSnooper(); 968 } 969 } 970 971 this.mcProfiler.endSection(); 972 973 if (this.func_90020_K() > 0) 974 { 975 Display.sync(EntityRenderer.func_78465_a(this.func_90020_K())); 976 } 977 } 978 } 979 980 private int func_90020_K() 981 { 982 return this.currentScreen != null && this.currentScreen instanceof GuiMainMenu ? 2 : this.gameSettings.limitFramerate; 983 } 984 985 public void freeMemory() 986 { 987 try 988 { 989 memoryReserve = new byte[0]; 990 this.renderGlobal.func_72728_f(); 991 } 992 catch (Throwable var4) 993 { 994 ; 995 } 996 997 try 998 { 999 System.gc(); 1000 AxisAlignedBB.getAABBPool().clearPool(); 1001 this.theWorld.getWorldVec3Pool().clearAndFreeCache(); 1002 } 1003 catch (Throwable var3) 1004 { 1005 ; 1006 } 1007 1008 try 1009 { 1010 System.gc(); 1011 this.loadWorld((WorldClient)null); 1012 } 1013 catch (Throwable var2) 1014 { 1015 ; 1016 } 1017 1018 System.gc(); 1019 } 1020 1021 /** 1022 * checks if keys are down 1023 */ 1024 private void screenshotListener() 1025 { 1026 if (Keyboard.isKeyDown(60)) 1027 { 1028 if (!this.isTakingScreenshot) 1029 { 1030 this.isTakingScreenshot = true; 1031 this.ingameGUI.getChatGUI().printChatMessage(ScreenShotHelper.saveScreenshot(minecraftDir, this.displayWidth, this.displayHeight)); 1032 } 1033 } 1034 else 1035 { 1036 this.isTakingScreenshot = false; 1037 } 1038 } 1039 1040 /** 1041 * Update debugProfilerName in response to number keys in debug screen 1042 */ 1043 private void updateDebugProfilerName(int par1) 1044 { 1045 List var2 = this.mcProfiler.getProfilingData(this.debugProfilerName); 1046 1047 if (var2 != null && !var2.isEmpty()) 1048 { 1049 ProfilerResult var3 = (ProfilerResult)var2.remove(0); 1050 1051 if (par1 == 0) 1052 { 1053 if (var3.field_76331_c.length() > 0) 1054 { 1055 int var4 = this.debugProfilerName.lastIndexOf("."); 1056 1057 if (var4 >= 0) 1058 { 1059 this.debugProfilerName = this.debugProfilerName.substring(0, var4); 1060 } 1061 } 1062 } 1063 else 1064 { 1065 --par1; 1066 1067 if (par1 < var2.size() && !((ProfilerResult)var2.get(par1)).field_76331_c.equals("unspecified")) 1068 { 1069 if (this.debugProfilerName.length() > 0) 1070 { 1071 this.debugProfilerName = this.debugProfilerName + "."; 1072 } 1073 1074 this.debugProfilerName = this.debugProfilerName + ((ProfilerResult)var2.get(par1)).field_76331_c; 1075 } 1076 } 1077 } 1078 } 1079 1080 private void displayDebugInfo(long par1) 1081 { 1082 if (this.mcProfiler.profilingEnabled) 1083 { 1084 List var3 = this.mcProfiler.getProfilingData(this.debugProfilerName); 1085 ProfilerResult var4 = (ProfilerResult)var3.remove(0); 1086 GL11.glClear(256); 1087 GL11.glMatrixMode(GL11.GL_PROJECTION); 1088 GL11.glEnable(GL11.GL_COLOR_MATERIAL); 1089 GL11.glLoadIdentity(); 1090 GL11.glOrtho(0.0D, (double)this.displayWidth, (double)this.displayHeight, 0.0D, 1000.0D, 3000.0D); 1091 GL11.glMatrixMode(GL11.GL_MODELVIEW); 1092 GL11.glLoadIdentity(); 1093 GL11.glTranslatef(0.0F, 0.0F, -2000.0F); 1094 GL11.glLineWidth(1.0F); 1095 GL11.glDisable(GL11.GL_TEXTURE_2D); 1096 Tessellator var5 = Tessellator.instance; 1097 short var6 = 160; 1098 int var7 = this.displayWidth - var6 - 10; 1099 int var8 = this.displayHeight - var6 * 2; 1100 GL11.glEnable(GL11.GL_BLEND); 1101 var5.startDrawingQuads(); 1102 var5.setColorRGBA_I(0, 200); 1103 var5.addVertex((double)((float)var7 - (float)var6 * 1.1F), (double)((float)var8 - (float)var6 * 0.6F - 16.0F), 0.0D); 1104 var5.addVertex((double)((float)var7 - (float)var6 * 1.1F), (double)(var8 + var6 * 2), 0.0D); 1105 var5.addVertex((double)((float)var7 + (float)var6 * 1.1F), (double)(var8 + var6 * 2), 0.0D); 1106 var5.addVertex((double)((float)var7 + (float)var6 * 1.1F), (double)((float)var8 - (float)var6 * 0.6F - 16.0F), 0.0D); 1107 var5.draw(); 1108 GL11.glDisable(GL11.GL_BLEND); 1109 double var9 = 0.0D; 1110 int var13; 1111 1112 for (int var11 = 0; var11 < var3.size(); ++var11) 1113 { 1114 ProfilerResult var12 = (ProfilerResult)var3.get(var11); 1115 var13 = MathHelper.floor_double(var12.field_76332_a / 4.0D) + 1; 1116 var5.startDrawing(6); 1117 var5.setColorOpaque_I(var12.func_76329_a()); 1118 var5.addVertex((double)var7, (double)var8, 0.0D); 1119 int var14; 1120 float var15; 1121 float var17; 1122 float var16; 1123 1124 for (var14 = var13; var14 >= 0; --var14) 1125 { 1126 var15 = (float)((var9 + var12.field_76332_a * (double)var14 / (double)var13) * Math.PI * 2.0D / 100.0D); 1127 var16 = MathHelper.sin(var15) * (float)var6; 1128 var17 = MathHelper.cos(var15) * (float)var6 * 0.5F; 1129 var5.addVertex((double)((float)var7 + var16), (double)((float)var8 - var17), 0.0D); 1130 } 1131 1132 var5.draw(); 1133 var5.startDrawing(5); 1134 var5.setColorOpaque_I((var12.func_76329_a() & 16711422) >> 1); 1135 1136 for (var14 = var13; var14 >= 0; --var14) 1137 { 1138 var15 = (float)((var9 + var12.field_76332_a * (double)var14 / (double)var13) * Math.PI * 2.0D / 100.0D); 1139 var16 = MathHelper.sin(var15) * (float)var6; 1140 var17 = MathHelper.cos(var15) * (float)var6 * 0.5F; 1141 var5.addVertex((double)((float)var7 + var16), (double)((float)var8 - var17), 0.0D); 1142 var5.addVertex((double)((float)var7 + var16), (double)((float)var8 - var17 + 10.0F), 0.0D); 1143 } 1144 1145 var5.draw(); 1146 var9 += var12.field_76332_a; 1147 } 1148 1149 DecimalFormat var19 = new DecimalFormat("##0.00"); 1150 GL11.glEnable(GL11.GL_TEXTURE_2D); 1151 String var18 = ""; 1152 1153 if (!var4.field_76331_c.equals("unspecified")) 1154 { 1155 var18 = var18 + "[0] "; 1156 } 1157 1158 if (var4.field_76331_c.length() == 0) 1159 { 1160 var18 = var18 + "ROOT "; 1161 } 1162 else 1163 { 1164 var18 = var18 + var4.field_76331_c + " "; 1165 } 1166 1167 var13 = 16777215; 1168 this.fontRenderer.drawStringWithShadow(var18, var7 - var6, var8 - var6 / 2 - 16, var13); 1169 this.fontRenderer.drawStringWithShadow(var18 = var19.format(var4.field_76330_b) + "%", var7 + var6 - this.fontRenderer.getStringWidth(var18), var8 - var6 / 2 - 16, var13); 1170 1171 for (int var21 = 0; var21 < var3.size(); ++var21) 1172 { 1173 ProfilerResult var20 = (ProfilerResult)var3.get(var21); 1174 String var22 = ""; 1175 1176 if (var20.field_76331_c.equals("unspecified")) 1177 { 1178 var22 = var22 + "[?] "; 1179 } 1180 else 1181 { 1182 var22 = var22 + "[" + (var21 + 1) + "] "; 1183 } 1184 1185 var22 = var22 + var20.field_76331_c; 1186 this.fontRenderer.drawStringWithShadow(var22, var7 - var6, var8 + var6 / 2 + var21 * 8 + 20, var20.func_76329_a()); 1187 this.fontRenderer.drawStringWithShadow(var22 = var19.format(var20.field_76332_a) + "%", var7 + var6 - 50 - this.fontRenderer.getStringWidth(var22), var8 + var6 / 2 + var21 * 8 + 20, var20.func_76329_a()); 1188 this.fontRenderer.drawStringWithShadow(var22 = var19.format(var20.field_76330_b) + "%", var7 + var6 - this.fontRenderer.getStringWidth(var22), var8 + var6 / 2 + var21 * 8 + 20, var20.func_76329_a()); 1189 } 1190 } 1191 } 1192 1193 /** 1194 * Called when the window is closing. Sets 'running' to false which allows the game loop to exit cleanly. 1195 */ 1196 public void shutdown() 1197 { 1198 this.running = false; 1199 } 1200 1201 /** 1202 * Will set the focus to ingame if the Minecraft window is the active with focus. Also clears any GUI screen 1203 * currently displayed 1204 */ 1205 public void setIngameFocus() 1206 { 1207 if (Display.isActive()) 1208 { 1209 if (!this.inGameHasFocus) 1210 { 1211 this.inGameHasFocus = true; 1212 this.mouseHelper.grabMouseCursor(); 1213 this.displayGuiScreen((GuiScreen)null); 1214 this.leftClickCounter = 10000; 1215 } 1216 } 1217 } 1218 1219 /** 1220 * Resets the player keystate, disables the ingame focus, and ungrabs the mouse cursor. 1221 */ 1222 public void setIngameNotInFocus() 1223 { 1224 if (this.inGameHasFocus) 1225 { 1226 KeyBinding.unPressAllKeys(); 1227 this.inGameHasFocus = false; 1228 this.mouseHelper.ungrabMouseCursor(); 1229 } 1230 } 1231 1232 /** 1233 * Displays the ingame menu 1234 */ 1235 public void displayInGameMenu() 1236 { 1237 if (this.currentScreen == null) 1238 { 1239 this.displayGuiScreen(new GuiIngameMenu()); 1240 1241 if (this.isSingleplayer() && !this.theIntegratedServer.getPublic()) 1242 { 1243 this.sndManager.pauseAllSounds(); 1244 } 1245 } 1246 } 1247 1248 private void sendClickBlockToController(int par1, boolean par2) 1249 { 1250 if (!par2) 1251 { 1252 this.leftClickCounter = 0; 1253 } 1254 1255 if (par1 != 0 || this.leftClickCounter <= 0) 1256 { 1257 if (par2 && this.objectMouseOver != null && this.objectMouseOver.typeOfHit == EnumMovingObjectType.TILE && par1 == 0) 1258 { 1259 int var3 = this.objectMouseOver.blockX; 1260 int var4 = this.objectMouseOver.blockY; 1261 int var5 = this.objectMouseOver.blockZ; 1262 this.playerController.onPlayerDamageBlock(var3, var4, var5, this.objectMouseOver.sideHit); 1263 1264 if (this.thePlayer.canCurrentToolHarvestBlock(var3, var4, var5)) 1265 { 1266 this.effectRenderer.addBlockHitEffects(var3, var4, var5, this.objectMouseOver); 1267 this.thePlayer.swingItem(); 1268 } 1269 } 1270 else 1271 { 1272 this.playerController.resetBlockRemoving(); 1273 } 1274 } 1275 } 1276 1277 /** 1278 * Called whenever the mouse is clicked. Button clicked is 0 for left clicking and 1 for right clicking. Args: 1279 * buttonClicked 1280 */ 1281 private void clickMouse(int par1) 1282 { 1283 if (par1 != 0 || this.leftClickCounter <= 0) 1284 { 1285 if (par1 == 0) 1286 { 1287 this.thePlayer.swingItem(); 1288 } 1289 1290 if (par1 == 1) 1291 { 1292 this.rightClickDelayTimer = 4; 1293 } 1294 1295 boolean var2 = true; 1296 ItemStack var3 = this.thePlayer.inventory.getCurrentItem(); 1297 1298 if (this.objectMouseOver == null) 1299 { 1300 if (par1 == 0 && this.playerController.isNotCreative()) 1301 { 1302 this.leftClickCounter = 10; 1303 } 1304 } 1305 else if (this.objectMouseOver.typeOfHit == EnumMovingObjectType.ENTITY) 1306 { 1307 if (par1 == 0) 1308 { 1309 this.playerController.attackEntity(this.thePlayer, this.objectMouseOver.entityHit); 1310 } 1311 1312 if (par1 == 1 && this.playerController.func_78768_b(this.thePlayer, this.objectMouseOver.entityHit)) 1313 { 1314 var2 = false; 1315 } 1316 } 1317 else if (this.objectMouseOver.typeOfHit == EnumMovingObjectType.TILE) 1318 { 1319 int var4 = this.objectMouseOver.blockX; 1320 int var5 = this.objectMouseOver.blockY; 1321 int var6 = this.objectMouseOver.blockZ; 1322 int var7 = this.objectMouseOver.sideHit; 1323 1324 if (par1 == 0) 1325 { 1326 this.playerController.clickBlock(var4, var5, var6, this.objectMouseOver.sideHit); 1327 } 1328 else 1329 { 1330 int var8 = var3 != null ? var3.stackSize : 0; 1331 1332 boolean result = !ForgeEventFactory.onPlayerInteract(thePlayer, Action.RIGHT_CLICK_BLOCK, var4, var5, var6, var7).isCanceled(); 1333 if (result && this.playerController.onPlayerRightClick(this.thePlayer, this.theWorld, var3, var4, var5, var6, var7, this.objectMouseOver.hitVec)) 1334 { 1335 var2 = false; 1336 this.thePlayer.swingItem(); 1337 } 1338 1339 if (var3 == null) 1340 { 1341 return; 1342 } 1343 1344 if (var3.stackSize == 0) 1345 { 1346 this.thePlayer.inventory.mainInventory[this.thePlayer.inventory.currentItem] = null; 1347 } 1348 else if (var3.stackSize != var8 || this.playerController.isInCreativeMode()) 1349 { 1350 this.entityRenderer.itemRenderer.func_78444_b(); 1351 } 1352 } 1353 } 1354 1355 if (var2 && par1 == 1) 1356 { 1357 ItemStack var9 = this.thePlayer.inventory.getCurrentItem(); 1358 1359 boolean result = !ForgeEventFactory.onPlayerInteract(thePlayer, Action.RIGHT_CLICK_AIR, 0, 0, 0, -1).isCanceled(); 1360 if (result && var9 != null && this.playerController.sendUseItem(this.thePlayer, this.theWorld, var9)) 1361 { 1362 this.entityRenderer.itemRenderer.func_78445_c(); 1363 } 1364 } 1365 } 1366 } 1367 1368 /** 1369 * Toggles fullscreen mode. 1370 */ 1371 public void toggleFullscreen() 1372 { 1373 try 1374 { 1375 this.fullscreen = !this.fullscreen; 1376 1377 if (this.fullscreen) 1378 { 1379 Display.setDisplayMode(Display.getDesktopDisplayMode()); 1380 this.displayWidth = Display.getDisplayMode().getWidth(); 1381 this.displayHeight = Display.getDisplayMode().getHeight(); 1382 1383 if (this.displayWidth <= 0) 1384 { 1385 this.displayWidth = 1; 1386 } 1387 1388 if (this.displayHeight <= 0) 1389 { 1390 this.displayHeight = 1; 1391 } 1392 } 1393 else 1394 { 1395 if (this.mcCanvas != null) 1396 { 1397 this.displayWidth = this.mcCanvas.getWidth(); 1398 this.displayHeight = this.mcCanvas.getHeight(); 1399 } 1400 else 1401 { 1402 this.displayWidth = this.tempDisplayWidth; 1403 this.displayHeight = this.tempDisplayHeight; 1404 } 1405 1406 if (this.displayWidth <= 0) 1407 { 1408 this.displayWidth = 1; 1409 } 1410 1411 if (this.displayHeight <= 0) 1412 { 1413 this.displayHeight = 1; 1414 } 1415 } 1416 1417 if (this.currentScreen != null) 1418 { 1419 this.resize(this.displayWidth, this.displayHeight); 1420 } 1421 1422 Display.setFullscreen(this.fullscreen); 1423 Display.setVSyncEnabled(this.gameSettings.enableVsync); 1424 Display.update(); 1425 } 1426 catch (Exception var2) 1427 { 1428 var2.printStackTrace(); 1429 } 1430 } 1431 1432 /** 1433 * Called to resize the current screen. 1434 */ 1435 private void resize(int par1, int par2) 1436 { 1437 this.displayWidth = par1 <= 0 ? 1 : par1; 1438 this.displayHeight = par2 <= 0 ? 1 : par2; 1439 1440 if (this.currentScreen != null) 1441 { 1442 ScaledResolution var3 = new ScaledResolution(this.gameSettings, par1, par2); 1443 int var4 = var3.getScaledWidth(); 1444 int var5 = var3.getScaledHeight(); 1445 this.currentScreen.setWorldAndResolution(this, var4, var5); 1446 } 1447 } 1448 1449 /** 1450 * Runs the current tick. 1451 */ 1452 public void runTick() 1453 { 1454 FMLCommonHandler.instance().rescheduleTicks(Side.CLIENT); 1455 if (this.rightClickDelayTimer > 0) 1456 { 1457 --this.rightClickDelayTimer; 1458 } 1459 1460 FMLCommonHandler.instance().onPreClientTick(); 1461 this.mcProfiler.startSection("stats"); 1462 this.statFileWriter.func_77449_e(); 1463 this.mcProfiler.endStartSection("gui"); 1464 1465 if (!this.isGamePaused) 1466 { 1467 this.ingameGUI.updateTick(); 1468 } 1469 1470 this.mcProfiler.endStartSection("pick"); 1471 this.entityRenderer.getMouseOver(1.0F); 1472 this.mcProfiler.endStartSection("gameMode"); 1473 1474 if (!this.isGamePaused && this.theWorld != null) 1475 { 1476 this.playerController.updateController(); 1477 } 1478 1479 GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/terrain.png")); 1480 this.mcProfiler.endStartSection("textures"); 1481 1482 if (!this.isGamePaused) 1483 { 1484 this.renderEngine.updateDynamicTextures(); 1485 } 1486 1487 if (this.currentScreen == null && this.thePlayer != null) 1488 { 1489 if (this.thePlayer.getHealth() <= 0) 1490 { 1491 this.displayGuiScreen((GuiScreen)null); 1492 } 1493 else if (this.thePlayer.isPlayerSleeping() && this.theWorld != null) 1494 { 1495 this.displayGuiScreen(new GuiSleepMP()); 1496 } 1497 } 1498 else if (this.currentScreen != null && this.currentScreen instanceof GuiSleepMP && !this.thePlayer.isPlayerSleeping()) 1499 { 1500 this.displayGuiScreen((GuiScreen)null); 1501 } 1502 1503 if (this.currentScreen != null) 1504 { 1505 this.leftClickCounter = 10000; 1506 } 1507 1508 CrashReport var2; 1509 CrashReportCategory var3; 1510 1511 if (this.currentScreen != null) 1512 { 1513 try 1514 { 1515 this.currentScreen.handleInput(); 1516 } 1517 catch (Throwable var6) 1518 { 1519 var2 = CrashReport.func_85055_a(var6, "Updating screen events"); 1520 var3 = var2.func_85058_a("Affected screen"); 1521 var3.addCrashSectionCallable("Screen name", new CallableUpdatingScreenName(this)); 1522 throw new ReportedException(var2); 1523 } 1524 1525 if (this.currentScreen != null) 1526 { 1527 try 1528 { 1529 this.currentScreen.guiParticles.update(); 1530 } 1531 catch (Throwable var5) 1532 { 1533 var2 = CrashReport.func_85055_a(var5, "Ticking screen particles"); 1534 var3 = var2.func_85058_a("Affected screen"); 1535 var3.addCrashSectionCallable("Screen name", new CallableParticleScreenName(this)); 1536 throw new ReportedException(var2); 1537 } 1538 1539 try 1540 { 1541 this.currentScreen.updateScreen(); 1542 } 1543 catch (Throwable var4) 1544 { 1545 var2 = CrashReport.func_85055_a(var4, "Ticking screen"); 1546 var3 = var2.func_85058_a("Affected screen"); 1547 var3.addCrashSectionCallable("Screen name", new CallableTickingScreenName(this)); 1548 throw new ReportedException(var2); 1549 } 1550 } 1551 } 1552 1553 if (this.currentScreen == null || this.currentScreen.allowUserInput) 1554 { 1555 this.mcProfiler.endStartSection("mouse"); 1556 1557 while (Mouse.next()) 1558 { 1559 KeyBinding.setKeyBindState(Mouse.getEventButton() - 100, Mouse.getEventButtonState()); 1560 1561 if (Mouse.getEventButtonState()) 1562 { 1563 KeyBinding.onTick(Mouse.getEventButton() - 100); 1564 } 1565 1566 long var1 = getSystemTime() - this.systemTime; 1567 1568 if (var1 <= 200L) 1569 { 1570 int var10 = Mouse.getEventDWheel(); 1571 1572 if (var10 != 0) 1573 { 1574 this.thePlayer.inventory.changeCurrentItem(var10); 1575 1576 if (this.gameSettings.noclip) 1577 { 1578 if (var10 > 0) 1579 { 1580 var10 = 1; 1581 } 1582 1583 if (var10 < 0) 1584 { 1585 var10 = -1; 1586 } 1587 1588 this.gameSettings.noclipRate += (float)var10 * 0.25F; 1589 } 1590 } 1591 1592 if (this.currentScreen == null) 1593 { 1594 if (!this.inGameHasFocus && Mouse.getEventButtonState()) 1595 { 1596 this.setIngameFocus(); 1597 } 1598 } 1599 else if (this.currentScreen != null) 1600 { 1601 this.currentScreen.handleMouseInput(); 1602 } 1603 } 1604 } 1605 1606 if (this.leftClickCounter > 0) 1607 { 1608 --this.leftClickCounter; 1609 } 1610 1611 this.mcProfiler.endStartSection("keyboard"); 1612 boolean var8; 1613 1614 while (Keyboard.next()) 1615 { 1616 KeyBinding.setKeyBindState(Keyboard.getEventKey(), Keyboard.getEventKeyState()); 1617 1618 if (Keyboard.getEventKeyState()) 1619 { 1620 KeyBinding.onTick(Keyboard.getEventKey()); 1621 } 1622 1623 if (this.field_83002_am > 0L) 1624 { 1625 if (getSystemTime() - this.field_83002_am >= 6000L) 1626 { 1627 throw new ReportedException(new CrashReport("Manually triggered debug crash", new Throwable())); 1628 } 1629 1630 if (!Keyboard.isKeyDown(46) || !Keyboard.isKeyDown(61)) 1631 { 1632 this.field_83002_am = -1L; 1633 } 1634 } 1635 else if (Keyboard.isKeyDown(46) && Keyboard.isKeyDown(61)) 1636 { 1637 this.field_83002_am = getSystemTime(); 1638 } 1639 1640 if (Keyboard.getEventKeyState()) 1641 { 1642 if (Keyboard.getEventKey() == 87) 1643 { 1644 this.toggleFullscreen(); 1645 } 1646 else 1647 { 1648 if (this.currentScreen != null) 1649 { 1650 this.currentScreen.handleKeyboardInput(); 1651 } 1652 else 1653 { 1654 if (Keyboard.getEventKey() == 1) 1655 { 1656 this.displayInGameMenu(); 1657 } 1658 1659 if (Keyboard.getEventKey() == 31 && Keyboard.isKeyDown(61)) 1660 { 1661 this.forceReload(); 1662 } 1663 1664 if (Keyboard.getEventKey() == 20 && Keyboard.isKeyDown(61)) 1665 { 1666 this.renderEngine.refreshTextures(); 1667 } 1668 1669 if (Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(61)) 1670 { 1671 var8 = Keyboard.isKeyDown(42) | Keyboard.isKeyDown(54); 1672 this.gameSettings.setOptionValue(EnumOptions.RENDER_DISTANCE, var8 ? -1 : 1); 1673 } 1674 1675 if (Keyboard.getEventKey() == 30 && Keyboard.isKeyDown(61)) 1676 { 1677 this.renderGlobal.loadRenderers(); 1678 } 1679 1680 if (Keyboard.getEventKey() == 35 && Keyboard.isKeyDown(61)) 1681 { 1682 this.gameSettings.advancedItemTooltips = !this.gameSettings.advancedItemTooltips; 1683 this.gameSettings.saveOptions(); 1684 } 1685 1686 if (Keyboard.getEventKey() == 48 && Keyboard.isKeyDown(61)) 1687 { 1688 RenderManager.field_85095_o = !RenderManager.field_85095_o; 1689 } 1690 1691 if (Keyboard.getEventKey() == 25 && Keyboard.isKeyDown(61)) 1692 { 1693 this.gameSettings.pauseOnLostFocus = !this.gameSettings.pauseOnLostFocus; 1694 this.gameSettings.saveOptions(); 1695 } 1696 1697 if (Keyboard.getEventKey() == 59) 1698 { 1699 this.gameSettings.hideGUI = !this.gameSettings.hideGUI; 1700 } 1701 1702 if (Keyboard.getEventKey() == 61) 1703 { 1704 this.gameSettings.showDebugInfo = !this.gameSettings.showDebugInfo; 1705 this.gameSettings.showDebugProfilerChart = GuiScreen.isShiftKeyDown(); 1706 } 1707 1708 if (Keyboard.getEventKey() == 63) 1709 { 1710 ++this.gameSettings.thirdPersonView; 1711 1712 if (this.gameSettings.thirdPersonView > 2) 1713 { 1714 this.gameSettings.thirdPersonView = 0; 1715 } 1716 } 1717 1718 if (Keyboard.getEventKey() == 66) 1719 { 1720 this.gameSettings.smoothCamera = !this.gameSettings.smoothCamera; 1721 } 1722 } 1723 1724 int var9; 1725 1726 for (var9 = 0; var9 < 9; ++var9) 1727 { 1728 if (Keyboard.getEventKey() == 2 + var9) 1729 { 1730 this.thePlayer.inventory.currentItem = var9; 1731 } 1732 } 1733 1734 if (this.gameSettings.showDebugInfo && this.gameSettings.showDebugProfilerChart) 1735 { 1736 if (Keyboard.getEventKey() == 11) 1737 { 1738 this.updateDebugProfilerName(0); 1739 } 1740 1741 for (var9 = 0; var9 < 9; ++var9) 1742 { 1743 if (Keyboard.getEventKey() == 2 + var9) 1744 { 1745 this.updateDebugProfilerName(var9 + 1); 1746 } 1747 } 1748 } 1749 } 1750 } 1751 } 1752 1753 var8 = this.gameSettings.chatVisibility != 2; 1754 1755 while (this.gameSettings.keyBindInventory.isPressed()) 1756 { 1757 this.displayGuiScreen(new GuiInventory(this.thePlayer)); 1758 } 1759 1760 while (this.gameSettings.keyBindDrop.isPressed()) 1761 { 1762 this.thePlayer.dropOneItem(); 1763 } 1764 1765 while (this.gameSettings.keyBindChat.isPressed() && var8) 1766 { 1767 this.displayGuiScreen(new GuiChat()); 1768 } 1769 1770 if (this.currentScreen == null && this.gameSettings.keyBindCommand.isPressed() && var8) 1771 { 1772 this.displayGuiScreen(new GuiChat("/")); 1773 } 1774 1775 if (this.thePlayer.isUsingItem()) 1776 { 1777 if (!this.gameSettings.keyBindUseItem.pressed) 1778 { 1779 this.playerController.onStoppedUsingItem(this.thePlayer); 1780 } 1781 1782 label379: 1783 1784 while (true) 1785 { 1786 if (!this.gameSettings.keyBindAttack.isPressed()) 1787 { 1788 while (this.gameSettings.keyBindUseItem.isPressed()) 1789 { 1790 ; 1791 } 1792 1793 while (true) 1794 { 1795 if (this.gameSettings.keyBindPickBlock.isPressed()) 1796 { 1797 continue; 1798 } 1799 1800 break label379; 1801 } 1802 } 1803 } 1804 } 1805 else 1806 { 1807 while (this.gameSettings.keyBindAttack.isPressed()) 1808 { 1809 this.clickMouse(0); 1810 } 1811 1812 while (this.gameSettings.keyBindUseItem.isPressed()) 1813 { 1814 this.clickMouse(1); 1815 } 1816 1817 while (this.gameSettings.keyBindPickBlock.isPressed()) 1818 { 1819 this.clickMiddleMouseButton(); 1820 } 1821 } 1822 1823 if (this.gameSettings.keyBindUseItem.pressed && this.rightClickDelayTimer == 0 && !this.thePlayer.isUsingItem()) 1824 { 1825 this.clickMouse(1); 1826 } 1827 1828 this.sendClickBlockToController(0, this.currentScreen == null && this.gameSettings.keyBindAttack.pressed && this.inGameHasFocus); 1829 } 1830 1831 if (this.theWorld != null) 1832 { 1833 if (this.thePlayer != null) 1834 { 1835 ++this.joinPlayerCounter; 1836 1837 if (this.joinPlayerCounter == 30) 1838 { 1839 this.joinPlayerCounter = 0; 1840 this.theWorld.joinEntityInSurroundings(this.thePlayer); 1841 } 1842 } 1843 1844 this.mcProfiler.endStartSection("gameRenderer"); 1845 1846 if (!this.isGamePaused) 1847 { 1848 this.entityRenderer.updateRenderer(); 1849 } 1850 1851 this.mcProfiler.endStartSection("levelRenderer"); 1852 1853 if (!this.isGamePaused) 1854 { 1855 this.renderGlobal.updateClouds(); 1856 } 1857 1858 this.mcProfiler.endStartSection("level"); 1859 1860 if (!this.isGamePaused) 1861 { 1862 if (this.theWorld.lightningFlash > 0) 1863 { 1864 --this.theWorld.lightningFlash; 1865 } 1866 1867 this.theWorld.updateEntities(); 1868 } 1869 1870 if (!this.isGamePaused) 1871 { 1872 this.theWorld.setAllowedSpawnTypes(this.theWorld.difficultySetting > 0, true); 1873 1874 try 1875 { 1876 this.theWorld.tick(); 1877 } 1878 catch (Throwable var7) 1879 { 1880 var2 = CrashReport.func_85055_a(var7, "Exception in world tick"); 1881 1882 if (this.theWorld == null) 1883 { 1884 var3 = var2.func_85058_a("Affected level"); 1885 var3.addCrashSection("Problem", "Level is null!"); 1886 } 1887 else 1888 { 1889 this.theWorld.addWorldInfoToCrashReport(var2); 1890 } 1891 1892 throw new ReportedException(var2); 1893 } 1894 } 1895 1896 this.mcProfiler.endStartSection("animateTick"); 1897 1898 if (!this.isGamePaused && this.theWorld != null) 1899 { 1900 this.theWorld.func_73029_E(MathHelper.floor_double(this.thePlayer.posX), MathHelper.floor_double(this.thePlayer.posY), MathHelper.floor_double(this.thePlayer.posZ)); 1901 } 1902 1903 this.mcProfiler.endStartSection("particles"); 1904 1905 if (!this.isGamePaused) 1906 { 1907 this.effectRenderer.updateEffects(); 1908 } 1909 } 1910 else if (this.myNetworkManager != null) 1911 { 1912 this.mcProfiler.endStartSection("pendingConnection"); 1913 this.myNetworkManager.processReadPackets(); 1914 } 1915 1916 FMLCommonHandler.instance().onPostClientTick(); 1917 this.mcProfiler.endSection(); 1918 this.systemTime = getSystemTime(); 1919 } 1920 1921 /** 1922 * Forces a reload of the sound manager and all the resources. Called in game by holding 'F3' and pressing 'S'. 1923 */ 1924 private void forceReload() 1925 { 1926 System.out.println("FORCING RELOAD!"); 1927 1928 if (this.sndManager != null) 1929 { 1930 this.sndManager.stopAllSounds(); 1931 } 1932 1933 this.sndManager = new SoundManager(); 1934 this.sndManager.loadSoundSettings(this.gameSettings); 1935 this.downloadResourcesThread.reloadResources(); 1936 } 1937 1938 /** 1939 * Arguments: World foldername, World ingame name, WorldSettings 1940 */ 1941 public void launchIntegratedServer(String par1Str, String par2Str, WorldSettings par3WorldSettings) 1942 { 1943 this.loadWorld((WorldClient)null); 1944 System.gc(); 1945 ISaveHandler var4 = this.saveLoader.getSaveLoader(par1Str, false); 1946 WorldInfo var5 = var4.loadWorldInfo(); 1947 1948 if (var5 == null && par3WorldSettings != null) 1949 { 1950 this.statFileWriter.readStat(StatList.createWorldStat, 1); 1951 var5 = new WorldInfo(par3WorldSettings, par1Str); 1952 var4.saveWorldInfo(var5); 1953 } 1954 1955 if (par3WorldSettings == null) 1956 { 1957 par3WorldSettings = new WorldSettings(var5); 1958 } 1959 1960 this.statFileWriter.readStat(StatList.startGameStat, 1); 1961 this.theIntegratedServer = new IntegratedServer(this, par1Str, par2Str, par3WorldSettings); 1962 this.theIntegratedServer.startServerThread(); 1963 this.integratedServerIsRunning = true; 1964 this.loadingScreen.displayProgressMessage(StatCollector.translateToLocal("menu.loadingLevel")); 1965 1966 while (!this.theIntegratedServer.serverIsInRunLoop()) 1967 { 1968 String var6 = this.theIntegratedServer.getUserMessage(); 1969 1970 if (var6 != null) 1971 { 1972 this.loadingScreen.resetProgresAndWorkingMessage(StatCollector.translateToLocal(var6)); 1973 } 1974 else 1975 { 1976 this.loadingScreen.resetProgresAndWorkingMessage(""); 1977 } 1978 1979 try 1980 { 1981 Thread.sleep(200L); 1982 } 1983 catch (InterruptedException var9) 1984 { 1985 ; 1986 } 1987 } 1988 1989 this.displayGuiScreen((GuiScreen)null); 1990 1991 try 1992 { 1993 NetClientHandler var10 = new NetClientHandler(this, this.theIntegratedServer); 1994 this.myNetworkManager = var10.getNetManager(); 1995 } 1996 catch (IOException var8) 1997 { 1998 this.displayCrashReport(this.addGraphicsAndWorldToCrashReport(new CrashReport("Connecting to integrated server", var8))); 1999 } 2000 } 2001 2002 /** 2003 * unloads the current world first 2004 */ 2005 public void loadWorld(WorldClient par1WorldClient) 2006 { 2007 this.loadWorld(par1WorldClient, ""); 2008 } 2009 2010 /** 2011 * par2Str is displayed on the loading screen to the user unloads the current world first 2012 */ 2013 public void loadWorld(WorldClient par1WorldClient, String par2Str) 2014 { 2015 this.statFileWriter.syncStats(); 2016 2017 if (par1WorldClient == null) 2018 { 2019 NetClientHandler var3 = this.getSendQueue(); 2020 2021 if (var3 != null) 2022 { 2023 var3.cleanup(); 2024 } 2025 2026 if (this.myNetworkManager != null) 2027 { 2028 this.myNetworkManager.closeConnections(); 2029 } 2030 2031 if (this.theIntegratedServer != null) 2032 { 2033 this.theIntegratedServer.initiateShutdown(); 2034 if (loadingScreen!=null) 2035 { 2036 this.loadingScreen.resetProgresAndWorkingMessage("Shutting down internal server..."); 2037 } 2038 while (!theIntegratedServer.isServerStopped()) 2039 { 2040 try 2041 { 2042 Thread.sleep(10); 2043 } 2044 catch (InterruptedException ie) {} 2045 } 2046 } 2047 2048 this.theIntegratedServer = null; 2049 } 2050 2051 this.renderViewEntity = null; 2052 this.myNetworkManager = null; 2053 2054 if (this.loadingScreen != null) 2055 { 2056 this.loadingScreen.resetProgressAndMessage(par2Str); 2057 this.loadingScreen.resetProgresAndWorkingMessage(""); 2058 } 2059 2060 if (par1WorldClient == null && this.theWorld != null) 2061 { 2062 if (this.texturePackList.getIsDownloading()) 2063 { 2064 this.texturePackList.onDownloadFinished(); 2065 } 2066 2067 this.setServerData((ServerData)null); 2068 this.integratedServerIsRunning = false; 2069 } 2070 2071 this.sndManager.playStreaming((String)null, 0.0F, 0.0F, 0.0F); 2072 this.sndManager.stopAllSounds(); 2073 this.theWorld = par1WorldClient; 2074 2075 if (par1WorldClient != null) 2076 { 2077 if (this.renderGlobal != null) 2078 { 2079 this.renderGlobal.setWorldAndLoadRenderers(par1WorldClient); 2080 } 2081 2082 if (this.effectRenderer != null) 2083 { 2084 this.effectRenderer.clearEffects(par1WorldClient); 2085 } 2086 2087 if (this.thePlayer == null) 2088 { 2089 this.thePlayer = this.playerController.func_78754_a(par1WorldClient); 2090 this.playerController.flipPlayer(this.thePlayer); 2091 } 2092 2093 this.thePlayer.preparePlayerToSpawn(); 2094 par1WorldClient.spawnEntityInWorld(this.thePlayer); 2095 this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings); 2096 this.playerController.setPlayerCapabilities(this.thePlayer); 2097 this.renderViewEntity = this.thePlayer; 2098 } 2099 else 2100 { 2101 this.saveLoader.flushCache(); 2102 this.thePlayer = null; 2103 } 2104 2105 System.gc(); 2106 this.systemTime = 0L; 2107 } 2108 2109 /** 2110 * Installs a resource. Currently only sounds are download so this method just adds them to the SoundManager. 2111 */ 2112 public void installResource(String par1Str, File par2File) 2113 { 2114 int var3 = par1Str.indexOf("/"); 2115 String var4 = par1Str.substring(0, var3); 2116 par1Str = par1Str.substring(var3 + 1); 2117 2118 if (var4.equalsIgnoreCase("sound3")) 2119 { 2120 this.sndManager.addSound(par1Str, par2File); 2121 } 2122 else if (var4.equalsIgnoreCase("streaming")) 2123 { 2124 this.sndManager.addStreaming(par1Str, par2File); 2125 } 2126 else if (var4.equalsIgnoreCase("music") || var4.equalsIgnoreCase("newmusic")) 2127 { 2128 this.sndManager.addMusic(par1Str, par2File); 2129 } 2130 } 2131 2132 /** 2133 * A String of renderGlobal.getDebugInfoRenders 2134 */ 2135 public String debugInfoRenders() 2136 { 2137 return this.renderGlobal.getDebugInfoRenders(); 2138 } 2139 2140 /** 2141 * Gets the information in the F3 menu about how many entities are infront/around you 2142 */ 2143 public String getEntityDebug() 2144 { 2145 return this.renderGlobal.getDebugInfoEntities(); 2146 } 2147 2148 /** 2149 * Gets the name of the world's current chunk provider 2150 */ 2151 public String getWorldProviderName() 2152 { 2153 return this.theWorld.getProviderName(); 2154 } 2155 2156 /** 2157 * A String of how many entities are in the world 2158 */ 2159 public String debugInfoEntities() 2160 { 2161 return "P: " + this.effectRenderer.getStatistics() + ". T: " + this.theWorld.getDebugLoadedEntities(); 2162 } 2163 2164 public void setDimensionAndSpawnPlayer(int par1) 2165 { 2166 this.theWorld.setSpawnLocation(); 2167 this.theWorld.removeAllEntities(); 2168 int var2 = 0; 2169 2170 if (this.thePlayer != null) 2171 { 2172 var2 = this.thePlayer.entityId; 2173 this.theWorld.setEntityDead(this.thePlayer); 2174 } 2175 2176 this.renderViewEntity = null; 2177 this.thePlayer = this.playerController.func_78754_a(this.theWorld); 2178 this.thePlayer.dimension = par1; 2179 this.renderViewEntity = this.thePlayer; 2180 this.thePlayer.preparePlayerToSpawn(); 2181 this.theWorld.spawnEntityInWorld(this.thePlayer); 2182 this.playerController.flipPlayer(this.thePlayer); 2183 this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings); 2184 this.thePlayer.entityId = var2; 2185 this.playerController.setPlayerCapabilities(this.thePlayer); 2186 2187 if (this.currentScreen instanceof GuiGameOver) 2188 { 2189 this.displayGuiScreen((GuiScreen)null); 2190 } 2191 } 2192 2193 /** 2194 * Sets whether this is a demo or not. 2195 */ 2196 void setDemo(boolean par1) 2197 { 2198 this.isDemo = par1; 2199 } 2200 2201 /** 2202 * Gets whether this is a demo or not. 2203 */ 2204 public final boolean isDemo() 2205 { 2206 return this.isDemo; 2207 } 2208 2209 /** 2210 * get the client packet send queue 2211 */ 2212 public NetClientHandler getSendQueue() 2213 { 2214 return this.thePlayer != null ? this.thePlayer.sendQueue : null; 2215 } 2216 2217 public static void main(String[] par0ArrayOfStr) 2218 { 2219 FMLRelauncher.handleClientRelaunch(new ArgsWrapper(par0ArrayOfStr)); 2220 } 2221 2222 public static void fmlReentry(ArgsWrapper wrapper) 2223 { 2224 String[] par0ArrayOfStr = wrapper.args; 2225 HashMap var1 = new HashMap(); 2226 boolean var2 = false; 2227 boolean var3 = true; 2228 boolean var4 = false; 2229 String var5 = "Player" + getSystemTime() % 1000L; 2230 2231 if (par0ArrayOfStr.length > 0) 2232 { 2233 var5 = par0ArrayOfStr[0]; 2234 } 2235 2236 String var6 = "-"; 2237 2238 if (par0ArrayOfStr.length > 1) 2239 { 2240 var6 = par0ArrayOfStr[1]; 2241 } 2242 2243 for (int var7 = 2; var7 < par0ArrayOfStr.length; ++var7) 2244 { 2245 String var8 = par0ArrayOfStr[var7]; 2246 String var9 = var7 == par0ArrayOfStr.length - 1 ? null : par0ArrayOfStr[var7 + 1]; 2247 boolean var10 = false; 2248 2249 if (!var8.equals("-demo") && !var8.equals("--demo")) 2250 { 2251 if (var8.equals("--applet")) 2252 { 2253 var3 = false; 2254 } 2255 else if (var8.equals("--password") && var9 != null) 2256 { 2257 String[] var11 = HttpUtil.func_82718_a(var5, var9); 2258 2259 if (var11 != null) 2260 { 2261 var5 = var11[0]; 2262 var6 = var11[1]; 2263 System.out.println("Logged in insecurely as " + var5 + " - sessionId is " + var6); 2264 } 2265 else 2266 { 2267 System.out.println("Could not log in as " + var5 + " with given password"); 2268 } 2269 2270 var10 = true; 2271 } 2272 } 2273 else 2274 { 2275 var2 = true; 2276 } 2277 2278 if (var10) 2279 { 2280 ++var7; 2281 } 2282 } 2283 2284 var1.put("demo", "" + var2); 2285 var1.put("stand-alone", "" + var3); 2286 var1.put("username", var5); 2287 var1.put("fullscreen", "" + var4); 2288 var1.put("sessionid", var6); 2289 Frame var13 = new Frame(); 2290 var13.setTitle("Minecraft"); 2291 var13.setBackground(Color.BLACK); 2292 JPanel var12 = new JPanel(); 2293 var13.setLayout(new BorderLayout()); 2294 var12.setPreferredSize(new Dimension(854, 480)); 2295 var13.add(var12, "Center"); 2296 var13.pack(); 2297 var13.setLocationRelativeTo((Component)null); 2298 var13.setVisible(true); 2299 var13.addWindowListener(new GameWindowListener()); 2300 MinecraftFakeLauncher var14 = new MinecraftFakeLauncher(var1); 2301 MinecraftApplet var15 = new MinecraftApplet(); 2302 var15.setStub(var14); 2303 var14.setLayout(new BorderLayout()); 2304 var14.add(var15, "Center"); 2305 var14.validate(); 2306 var13.removeAll(); 2307 var13.setLayout(new BorderLayout()); 2308 var13.add(var14, "Center"); 2309 var13.validate(); 2310 var15.init(); 2311 var15.start(); 2312 Runtime.getRuntime().addShutdownHook(new ThreadShutdown()); 2313 } 2314 2315 public static boolean isGuiEnabled() 2316 { 2317 return theMinecraft == null || !theMinecraft.gameSettings.hideGUI; 2318 } 2319 2320 public static boolean isFancyGraphicsEnabled() 2321 { 2322 return theMinecraft != null && theMinecraft.gameSettings.fancyGraphics; 2323 } 2324 2325 /** 2326 * Returns if ambient occlusion is enabled 2327 */ 2328 public static boolean isAmbientOcclusionEnabled() 2329 { 2330 return theMinecraft != null && theMinecraft.gameSettings.ambientOcclusion; 2331 } 2332 2333 public static boolean isDebugInfoEnabled() 2334 { 2335 return theMinecraft != null && theMinecraft.gameSettings.showDebugInfo; 2336 } 2337 2338 /** 2339 * Returns true if the message is a client command and should not be sent to the server. However there are no such 2340 * commands at this point in time. 2341 */ 2342 public boolean handleClientCommand(String par1Str) 2343 { 2344 return !par1Str.startsWith("/") ? false : false; 2345 } 2346 2347 /** 2348 * Called when the middle mouse button gets clicked 2349 */ 2350 private void clickMiddleMouseButton() 2351 { 2352 if (this.objectMouseOver != null) 2353 { 2354 boolean var1 = this.thePlayer.capabilities.isCreativeMode; 2355 int var5; 2356 2357 if (!ForgeHooks.onPickBlock(this.objectMouseOver, this.thePlayer, this.theWorld)) 2358 { 2359 return; 2360 } 2361 2362 if (var1) 2363 { 2364 var5 = this.thePlayer.inventorySlots.inventorySlots.size() - 9 + this.thePlayer.inventory.currentItem; 2365 this.playerController.sendSlotPacket(this.thePlayer.inventory.getStackInSlot(this.thePlayer.inventory.currentItem), var5); 2366 } 2367 } 2368 } 2369 2370 /** 2371 * adds core server Info (GL version , Texture pack, isModded, type), and the worldInfo to the crash report 2372 */ 2373 public CrashReport addGraphicsAndWorldToCrashReport(CrashReport par1CrashReport) 2374 { 2375 par1CrashReport.func_85056_g().addCrashSectionCallable("LWJGL", new CallableLWJGLVersion(this)); 2376 par1CrashReport.func_85056_g().addCrashSectionCallable("OpenGL", new CallableGLInfo(this)); 2377 par1CrashReport.func_85056_g().addCrashSectionCallable("Is Modded", new CallableModded(this)); 2378 par1CrashReport.func_85056_g().addCrashSectionCallable("Type", new CallableType2(this)); 2379 par1CrashReport.func_85056_g().addCrashSectionCallable("Texture Pack", new CallableTexturePack(this)); 2380 par1CrashReport.func_85056_g().addCrashSectionCallable("Profiler Position", new CallableClientProfiler(this)); 2381 par1CrashReport.func_85056_g().addCrashSectionCallable("Vec3 Pool Size", new CallableClientMemoryStats(this)); 2382 2383 if (this.theWorld != null) 2384 { 2385 this.theWorld.addWorldInfoToCrashReport(par1CrashReport); 2386 } 2387 2388 return par1CrashReport; 2389 } 2390 2391 /** 2392 * Return the singleton Minecraft instance for the game 2393 */ 2394 public static Minecraft getMinecraft() 2395 { 2396 return theMinecraft; 2397 } 2398 2399 /** 2400 * Sets refreshTexturePacksScheduled to true, triggering a texture pack refresh next time the while(running) loop is 2401 * run 2402 */ 2403 public void scheduleTexturePackRefresh() 2404 { 2405 this.refreshTexturePacksScheduled = true; 2406 } 2407 2408 public void addServerStatsToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper) 2409 { 2410 par1PlayerUsageSnooper.addData("fps", Integer.valueOf(debugFPS)); 2411 par1PlayerUsageSnooper.addData("texpack_name", this.texturePackList.getSelectedTexturePack().getTexturePackFileName()); 2412 par1PlayerUsageSnooper.addData("texpack_resolution", Integer.valueOf(this.texturePackList.getSelectedTexturePack().getTexturePackResolution())); 2413 par1PlayerUsageSnooper.addData("vsync_enabled", Boolean.valueOf(this.gameSettings.enableVsync)); 2414 par1PlayerUsageSnooper.addData("display_frequency", Integer.valueOf(Display.getDisplayMode().getFrequency())); 2415 par1PlayerUsageSnooper.addData("display_type", this.fullscreen ? "fullscreen" : "windowed"); 2416 2417 if (this.theIntegratedServer != null && this.theIntegratedServer.getPlayerUsageSnooper() != null) 2418 { 2419 par1PlayerUsageSnooper.addData("snooper_partner", this.theIntegratedServer.getPlayerUsageSnooper().getUniqueID()); 2420 } 2421 } 2422 2423 public void addServerTypeToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper) 2424 { 2425 par1PlayerUsageSnooper.addData("opengl_version", GL11.glGetString(GL11.GL_VERSION)); 2426 par1PlayerUsageSnooper.addData("opengl_vendor", GL11.glGetString(GL11.GL_VENDOR)); 2427 par1PlayerUsageSnooper.addData("client_brand", ClientBrandRetriever.getClientModName()); 2428 par1PlayerUsageSnooper.addData("applet", Boolean.valueOf(this.hideQuitButton)); 2429 ContextCapabilities var2 = GLContext.getCapabilities(); 2430 par1PlayerUsageSnooper.addData("gl_caps[ARB_multitexture]", Boolean.valueOf(var2.GL_ARB_multitexture)); 2431 par1PlayerUsageSnooper.addData("gl_caps[ARB_multisample]", Boolean.valueOf(var2.GL_ARB_multisample)); 2432 par1PlayerUsageSnooper.addData("gl_caps[ARB_texture_cube_map]", Boolean.valueOf(var2.GL_ARB_texture_cube_map)); 2433 par1PlayerUsageSnooper.addData("gl_caps[ARB_vertex_blend]", Boolean.valueOf(var2.GL_ARB_vertex_blend)); 2434 par1PlayerUsageSnooper.addData("gl_caps[ARB_matrix_palette]", Boolean.valueOf(var2.GL_ARB_matrix_palette)); 2435 par1PlayerUsageSnooper.addData("gl_caps[ARB_vertex_program]", Boolean.valueOf(var2.GL_ARB_vertex_program)); 2436 par1PlayerUsageSnooper.addData("gl_caps[ARB_vertex_shader]", Boolean.valueOf(var2.GL_ARB_vertex_shader)); 2437 par1PlayerUsageSnooper.addData("gl_caps[ARB_fragment_program]", Boolean.valueOf(var2.GL_ARB_fragment_program)); 2438 par1PlayerUsageSnooper.addData("gl_caps[ARB_fragment_shader]", Boolean.valueOf(var2.GL_ARB_fragment_shader)); 2439 par1PlayerUsageSnooper.addData("gl_caps[ARB_shader_objects]", Boolean.valueOf(var2.GL_ARB_shader_objects)); 2440 par1PlayerUsageSnooper.addData("gl_caps[ARB_vertex_buffer_object]", Boolean.valueOf(var2.GL_ARB_vertex_buffer_object)); 2441 par1PlayerUsageSnooper.addData("gl_caps[ARB_framebuffer_object]", Boolean.valueOf(var2.GL_ARB_framebuffer_object)); 2442 par1PlayerUsageSnooper.addData("gl_caps[ARB_pixel_buffer_object]", Boolean.valueOf(var2.GL_ARB_pixel_buffer_object)); 2443 par1PlayerUsageSnooper.addData("gl_caps[ARB_uniform_buffer_object]", Boolean.valueOf(var2.GL_ARB_uniform_buffer_object)); 2444 par1PlayerUsageSnooper.addData("gl_caps[ARB_texture_non_power_of_two]", Boolean.valueOf(var2.GL_ARB_texture_non_power_of_two)); 2445 par1PlayerUsageSnooper.addData("gl_caps[gl_max_vertex_uniforms]", Integer.valueOf(GL11.glGetInteger(GL20.GL_MAX_VERTEX_UNIFORM_COMPONENTS))); 2446 par1PlayerUsageSnooper.addData("gl_caps[gl_max_fragment_uniforms]", Integer.valueOf(GL11.glGetInteger(GL20.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS))); 2447 par1PlayerUsageSnooper.addData("gl_max_texture_size", Integer.valueOf(getGLMaximumTextureSize())); 2448 } 2449 2450 /** 2451 * Used in the usage snooper. 2452 */ 2453 private static int getGLMaximumTextureSize() 2454 { 2455 for (int var0 = 16384; var0 > 0; var0 >>= 1) 2456 { 2457 GL11.glTexImage2D(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_RGBA, var0, var0, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null); 2458 int var1 = GL11.glGetTexLevelParameteri(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH); 2459 2460 if (var1 != 0) 2461 { 2462 return var0; 2463 } 2464 } 2465 2466 return -1; 2467 } 2468 2469 /** 2470 * Returns whether snooping is enabled or not. 2471 */ 2472 public boolean isSnooperEnabled() 2473 { 2474 return this.gameSettings.snooperEnabled; 2475 } 2476 2477 /** 2478 * Set the current ServerData instance. 2479 */ 2480 public void setServerData(ServerData par1ServerData) 2481 { 2482 this.currentServerData = par1ServerData; 2483 } 2484 2485 /** 2486 * Get the current ServerData instance. 2487 */ 2488 public ServerData getServerData() 2489 { 2490 return this.currentServerData; 2491 } 2492 2493 public boolean isIntegratedServerRunning() 2494 { 2495 return this.integratedServerIsRunning; 2496 } 2497 2498 /** 2499 * Returns true if there is only one player playing, and the current server is the integrated one. 2500 */ 2501 public boolean isSingleplayer() 2502 { 2503 return this.integratedServerIsRunning && this.theIntegratedServer != null; 2504 } 2505 2506 /** 2507 * Returns the currently running integrated server 2508 */ 2509 public IntegratedServer getIntegratedServer() 2510 { 2511 return this.theIntegratedServer; 2512 } 2513 2514 public static void stopIntegratedServer() 2515 { 2516 if (theMinecraft != null) 2517 { 2518 IntegratedServer var0 = theMinecraft.getIntegratedServer(); 2519 2520 if (var0 != null) 2521 { 2522 var0.stopServer(); 2523 } 2524 } 2525 } 2526 2527 /** 2528 * Returns the PlayerUsageSnooper instance. 2529 */ 2530 public PlayerUsageSnooper getPlayerUsageSnooper() 2531 { 2532 return this.usageSnooper; 2533 } 2534 2535 /** 2536 * Gets the system time in milliseconds. 2537 */ 2538 public static long getSystemTime() 2539 { 2540 return Sys.getTime() * 1000L / Sys.getTimerResolution(); 2541 } 2542 2543 /** 2544 * Returns whether we're in full screen or not. 2545 */ 2546 public boolean isFullScreen() 2547 { 2548 return this.fullscreen; 2549 } 2550 }