Spicy FastPlace module 2 files, 3344 lines

Spicy FastPlace: Full Source Analysis

Spicy's FastPlace is a two-line timer kill.

info/spicyclient/modules/world/FastPlace.java · GitHub source ↗

Published 2026-08-13 · Updated 2026-10-14

Packets This Module Uses

Analysis

Overview

Spicy's FastPlace is a two-line timer kill. Its entire logic runs in the EventUpdate pre phase of every tick: it writes 0 into mc.rightClickDelayTimer, the field that Minecraft's right-click handler re-arms to 4 after every processed right click and that the main loop decrements once per tick. Vanilla uses the timer to enforce a minimum four-tick gap between right-click actions, so blocks place at most once every five ticks; with the timer pinned at 0, every click is processed immediately and the placement rate rises to the click-processing ceiling of one C08PacketPlayerBlockPlacement per tick, roughly 20 per second against vanilla's 4 per second. The module touches nothing else: no rotation rewrite, no packet injection, no reach change. Every placement it produces is an ordinary C08, which is what makes the module's only observable the rate of its own C08 stream.

The timer kill

Three sites in Minecraft.java give the timer its lifecycle. The main loop decrements rightClickDelayTimer once per tick while it is above zero (line 1743). The use-item handler is only entered while the timer reads exactly 0 (line 2166: keyBindUseItem down, rightClickDelayTimer == 0, not already using an item), and rightClickMouse() ends by resetting the timer to 4 (line 1577). The module's pre-tick write of 0 therefore collapses the cooldown to zero for every tick the mouse button is held, and because the click handler runs at most once per game tick, the module's ceiling is one placement per tick (20 per second) against vanilla's one per five ticks.

Wire effect and limits

Each placement is a stock C08PacketPlayerBlockPlacement carrying the vanilla payload: the targeted position, face, held item and the four float offsets. Nothing about the packet's geometry changes, so geometry-based checks see nothing. The gain is purely rate: a sustained 20/s C08 stream instead of 4/s. The same delay gate also throttles right-click item use, so the timer kill accelerates item interactions as well, but the module's purpose and its name are block placement. The C08 rate is the entire detectable surface.

source FastPlace.java (module)

FastPlace.java38 lines · JavaOriginal ↗
1
package info.spicyclient.modules.world;
2
3
import org.lwjgl.input.Keyboard;
4
5
import info.spicyclient.events.Event;
6
import info.spicyclient.events.listeners.EventUpdate;
7
import info.spicyclient.modules.Module;
8
import net.minecraft.network.play.client.C03PacketPlayer;
9
10
public class FastPlace extends Module {
11
12
	public FastPlace() {
13
		super("Fast Place", Keyboard.KEY_NONE, Category.WORLD);
14
	}
15
	
16
	public void onEnable() {
17
		
18
	}
19
	
20
	public void onDisable() {
21
		
22
	}
23
	
24
	public void onEvent(Event e) {
25
		
26
		if (e instanceof EventUpdate) {
27
			
28
			if (e.isPre()) {
29
				
30
				mc.rightClickDelayTimer = 0;
31
				
32
			}
33
			
34
		}
35
		
36
	}
37
	
38
}

What this file does

The whole module is the single EventUpdate pre branch; onEnable and onDisable are empty stubs. The one statement, mc.rightClickDelayTimer = 0, is the full exploit: the field is public on Minecraft, the main loop decrements it once per tick, and the use-item handler at Minecraft.java line 2166 only proceeds while it is exactly 0. Writing 0 from a pre-tick event therefore removes the four-tick cooldown before every click check.

The pre-tick placement is deliberate: Spicy's onUpdateWalkingPlayer dispatches EventUpdate with EventType.PRE at the very start of the movement tick, before any input processing, so the zeroed timer is in place before the game loop's click handling reads it.

source Minecraft.java (timer lifecycle)

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

What this file does

The timer is born and consumed in three spots. Line 292 declares the public int rightClickDelayTimer. The main loop decrements it once per tick while positive (line 1743), and the use-item branch (line 2166) is gated on rightClickDelayTimer == 0, with rightClickMouse() re-arming the timer to 4 (line 1577) at the end of every processed click.

Zeroing the field from an event hook defeats the gate without touching the rest of the click path, so every subsequent right click in the same tick passes. Because the click handler itself runs once per tick, the module cannot exceed one C08 per tick no matter how fast the mouse is clicked. The 20/s ceiling is structural, not configurable.

anticheat Countering Checks

The anticheat code that detects or counters the techniques this module uses. Full source, with the detection mechanism explained below each box.

anticheat FastPlace (placement-rate ledger)

FastPlace.java103 lines · Java
1
/*
2
 * This program is free software: you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation, either version 3 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 */
15
package fr.neatmonster.nocheatplus.checks.blockplace;
16
17
import org.bukkit.block.Block;
18
import org.bukkit.entity.Player;
19
20
import fr.neatmonster.nocheatplus.checks.Check;
21
import fr.neatmonster.nocheatplus.checks.CheckType;
22
import fr.neatmonster.nocheatplus.players.IPlayerData;
23
import fr.neatmonster.nocheatplus.utilities.TickTask;
24
25
/**
26
 * A check used to verify if the player isn't placing blocks too quickly.
27
 */
28
public class FastPlace extends Check {
29
30
    /**
31
     * Instantiates a new fast place check.
32
     */
33
    public FastPlace() {
34
        super(CheckType.BLOCKPLACE_FASTPLACE);
35
    }
36
37
    /**
38
     * Checks a player.
39
     * 
40
     * @param player
41
     *            the player
42
     * @param block
43
     *            the block
44
     * @param tick
45
     * @param data
46
     * @param cc
47
     * @param pData
48
     * @return true, if successful
49
     */
50
    public boolean check(final Player player, final Block block, final int tick, final BlockPlaceData data, 
51
                         final BlockPlaceConfig cc, final IPlayerData pData) {
52
53
        data.fastPlaceBuckets.add(System.currentTimeMillis(), 1f);
54
        final boolean lag = pData.getCurrentWorldData().shouldAdjustToLag(type);
55
        // Full period frequency.
56
        final float fullScore = data.fastPlaceBuckets.score(1f);
57
58
        // Short term limit.
59
        if (tick < data.fastPlaceShortTermTick) {
60
            // TickTask got reset.
61
            data.fastPlaceShortTermTick = tick;
62
            data.fastPlaceShortTermCount = 1;
63
        }
64
        else if (tick - data.fastPlaceShortTermTick < cc.fastPlaceShortTermTicks) {
65
            // Account for server side lag.
66
            if (!lag || TickTask.getLag(50L * (tick - data.fastPlaceShortTermTick), true) < 1.2f) {
67
                // Within range, add.
68
                data.fastPlaceShortTermCount ++;
69
            }
70
            else {
71
                // Too much lag, reset.
72
                data.fastPlaceShortTermTick = tick;
73
                data.fastPlaceShortTermCount = 1;
74
            }
75
        }
76
        else { 
77
            data.fastPlaceShortTermTick = tick;
78
            data.fastPlaceShortTermCount = 1;
79
        }
80
81
        // Find out if one of both are violations:
82
        final float fullViolation;
83
        if (fullScore > cc.fastPlaceLimit) {
84
            // Account for server side lag.
85
            fullViolation = lag ? fullScore / TickTask.getLag(data.fastPlaceBuckets.bucketDuration() * data.fastPlaceBuckets.numberOfBuckets(), true) - cc.fastPlaceLimit
86
                                : fullScore - cc.fastPlaceLimit;
87
        }
88
        else fullViolation = 0;
89
        final float shortTermViolation = data.fastPlaceShortTermCount - cc.fastPlaceShortTermLimit; 
90
        final float violation = Math.max(fullViolation, shortTermViolation);
91
        boolean cancel = false;
92
93
        if (violation > 0.0) {
94
            final double change = (double) violation;
95
            data.fastPlaceVL += change;
96
            cancel = executeActions(player, data.fastPlaceVL, change, cc.fastPlaceActions).willCancel();
97
        }
98
        else if (data.fastPlaceVL > 0D && fullScore < cc.fastPlaceLimit * .75) {
99
            data.fastPlaceVL *= 0.95;
100
        }
101
        return cancel;
102
    }
103
}

How it counteracts this module

NCP's FastPlace check scores every processed block placement into data.fastPlaceBuckets, an ActionFrequency with 2 buckets of 1000ms each (BlockPlaceData line 53), giving a two-second window. check() computes a full-window score against cc.fastPlaceLimit and, in parallel, a short-term counter (fastPlaceShortTermCount within cc.fastPlaceShortTermTicks) against cc.fastPlaceShortTermLimit; the violation is the larger of the two, lag-adjusted through TickTask, and executeActions decides cancellation. A vanilla click-spammer reaches about 8 places per two-second window (4/s); the module's zeroed timer sustains 20/s, roughly five times that rate, so the full-window score crosses the default limit and the short-term counter trips within the first second of sustained placing.

The check is content-blind (it reads no geometry, no rotation, no item), which is exactly right for this module: the timer kill leaves every other C08 field vanilla, so the rate ledger is the only check in the blockplace battery that actually fires on it.

anticheat Direction (placement line-of-sight)

Direction.java52 lines · Java
1
/*
2
 * This program is free software: you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation, either version 3 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 */
15
package fr.neatmonster.nocheatplus.checks.blockplace;
16
17
import org.bukkit.entity.Player;
18
19
import fr.neatmonster.nocheatplus.actions.ActionList;
20
import fr.neatmonster.nocheatplus.checks.CheckType;
21
import fr.neatmonster.nocheatplus.checks.generic.block.AbstractBlockDirectionCheck;
22
23
/**
24
 * The Direction check will find out if a player tried to interact with
25
 * something that's not in their field of view.
26
 */
27
public class Direction extends AbstractBlockDirectionCheck<BlockPlaceData, BlockPlaceConfig> {
28
29
    /**
30
     * Instantiates a new direction check.
31
     */
32
    public Direction() {
33
        super(CheckType.BLOCKPLACE_DIRECTION);
34
    }
35
36
    @Override
37
    protected double addVL(Player player, double distance, BlockPlaceData data, BlockPlaceConfig cc) {
38
        data.directionVL += distance;
39
        return data.directionVL;
40
    }
41
42
    @Override
43
    protected ActionList getActions(BlockPlaceConfig cc) {
44
        return cc.directionActions;
45
    }
46
47
    @Override
48
    protected void cooldown(Player player, BlockPlaceData data, BlockPlaceConfig cc) {
49
        data.directionVL *= 0.9D;
50
    }
51
52
}

How it counteracts this module

Direction extends AbstractBlockDirectionCheck, which validates the geometry of every placement. check() casts a ray from the eye position along the player's yaw and pitch (checkBoulder against a CollideRayVsAABB) and requires it to intersect the placed block's AABB; isInteractable then verifies the clicked face is a face the player can actually reach from their position, using the block-relative coordinates and the block flags (getInteractableFaces, isDirectionBlocked). The violation distance feeds directionVL with a 0.9 cooldown decay.

FastPlace never touches rotations, so an honest player's placements stay on the look ray and pass. The check is the companion in the battery that catches clients whose placement rate outpaces their aim (edge-of-view placements, look-ahead placement streams), which is precisely the behavior a pure timer kill does not produce. As a counter to this module it is the geometry half of the battery, present to keep the rate ledger honest rather than to fire on it.

anticheat Reach (placement distance)

Reach.java85 lines · Java
1
/*
2
 * This program is free software: you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation, either version 3 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 */
15
package fr.neatmonster.nocheatplus.checks.blockplace;
16
17
import org.bukkit.GameMode;
18
import org.bukkit.Location;
19
import org.bukkit.block.Block;
20
import org.bukkit.entity.Player;
21
22
import fr.neatmonster.nocheatplus.actions.ParameterName;
23
import fr.neatmonster.nocheatplus.checks.Check;
24
import fr.neatmonster.nocheatplus.checks.CheckType;
25
import fr.neatmonster.nocheatplus.checks.ViolationData;
26
import fr.neatmonster.nocheatplus.utilities.StringUtil;
27
import fr.neatmonster.nocheatplus.utilities.math.TrigUtil;
28
29
/**
30
 * The Reach check will find out if a player places a block too far away.
31
 */
32
public class Reach extends Check {
33
34
    /** The maximum distance allowed to interact with a block in creative mode. */
35
    public static final double CREATIVE_DISTANCE = 5.6D;
36
37
    /** The maximum distance allowed to interact with a block in survival mode. */
38
    public static final double SURVIVAL_DISTANCE = 5.2D;
39
40
    /** For temporary use: LocUtil.clone before passing deeply, call setWorld(null) after use. */
41
    private final Location useLoc = new Location(null, 0, 0, 0);
42
43
    /**
44
     * Instantiates a new reach check.
45
     */
46
    public Reach() {
47
        super(CheckType.BLOCKPLACE_REACH);
48
    }
49
50
    /**
51
     * Checks a player.
52
     * 
53
     * @param player
54
     *            the player
55
     * @param eyeHeight 
56
     * @param block 
57
     * @param data
58
     * @param cc
59
     * @return true, if successful
60
     */
61
    public boolean check(final Player player, final double eyeHeight, final Block block, final BlockPlaceData data, final BlockPlaceConfig cc) {
62
    	// TODO: Ray tracing-based?
63
        boolean cancel = false;
64
        final double distanceLimit = player.getGameMode() == GameMode.CREATIVE ? CREATIVE_DISTANCE : SURVIVAL_DISTANCE;
65
        // Distance is calculated from eye location to center of targeted block.
66
        final Location eyeLoc = player.getLocation(useLoc);
67
        eyeLoc.setY(eyeLoc.getY() + eyeHeight);
68
        final double distance = TrigUtil.distance(eyeLoc, block) - distanceLimit;
69
70
        if (distance > distanceLimit) {
71
            // They failed, increment violation level.
72
            data.reachVL += distance - distanceLimit;
73
            // Execute whatever actions are associated with this check and the violation level and find out if we should
74
            // cancel the event.
75
            final ViolationData vd = new ViolationData(this, player, data.reachVL, distance, cc.reachActions);
76
            vd.setParameter(ParameterName.REACH_DISTANCE, StringUtil.fdec3.format(distance));
77
            cancel = executeActions(vd).willCancel();
78
        } 
79
        // Player passed the check, reward them
80
        else data.reachVL *= 0.9D;
81
        // Cleanup.
82
        useLoc.setWorld(null);
83
        return cancel;
84
    }
85
}

How it counteracts this module

Reach measures the eye-to-block-center distance of every placement against SURVIVAL_DISTANCE = 5.2 or CREATIVE_DISTANCE = 5.6 depending on the player's game mode; a distance above the limit accumulates reachVL and cancels through cc.reachActions, otherwise the VL decays by 0.9.

The module does not extend reach in any way: the timer kill leaves the click target exactly where the crosshair points, so every placement stays inside the survival envelope and the check passes. It rounds out the blockplace battery and only becomes relevant if a FastPlace user pairs the timer kill with a reach extension, in which case the same C08s that trip the rate ledger also trip this distance check.

anticheat BlockInteractSpeed (same-tick double-place)

BlockInteractSpeed.java55 lines · Java
1
/*
2
 * This file is part of Hawk Anticheat.
3
 * Copyright (C) 2018 Hawk Development Team
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
package me.islandscout.hawk.check.interaction.terrain;
20
21
import me.islandscout.hawk.HawkPlayer;
22
import me.islandscout.hawk.check.BlockInteractionCheck;
23
import me.islandscout.hawk.event.InteractWorldEvent;
24
import org.bukkit.entity.Player;
25
26
import java.util.HashMap;
27
import java.util.Map;
28
import java.util.UUID;
29
30
public class BlockInteractSpeed extends BlockInteractionCheck {
31
32
    private final Map<UUID, Long> lastPlaceTick;
33
34
    public BlockInteractSpeed() {
35
        super("blockplacespeed", "%player% failed block place speed. VL: %vl%");
36
        lastPlaceTick = new HashMap<>();
37
    }
38
39
    @Override
40
    protected void check(InteractWorldEvent e) {
41
        Player p = e.getPlayer();
42
        HawkPlayer pp = e.getHawkPlayer();
43
        if (pp.getCurrentTick() == lastPlaceTick.getOrDefault(p.getUniqueId(), 0L))
44
            punishAndTryCancelAndBlockRespawn(pp, 1, e);
45
        else
46
            reward(pp);
47
48
        lastPlaceTick.put(p.getUniqueId(), pp.getCurrentTick());
49
    }
50
51
    @Override
52
    public void removeData(Player p) {
53
        lastPlaceTick.remove(p.getUniqueId());
54
    }
55
}

How it counteracts this module

Hawk's BlockInteractSpeed is the tightest placement-rate check in the corpus. check() compares the current server tick against the per-player lastPlaceTick: if two block interactions land in the same tick, punishAndTryCancelAndBlockRespawn fires with VL 1; any other outcome rewards, and the tick is recorded for the next comparison.

For this module it is a documented boundary: the timer kill's ceiling is one C08 per tick because the client's click handler itself runs once per tick, so the module can never produce two placements in one tick and the check never fires on it. Its purpose is the class of clients that emit multiple C08s per tick by bypassing the click path entirely. A single-tick timer kill cannot reach that rate, which is exactly why it is the right boundary check to pair with NCP's windowed ledger.

← Back to Analysis Hub