private void tick() {
		if(this.soundPlayer != null) {
			SoundPlayer var1 = this.soundPlayer;
			SoundManager var2 = this.sound;
			if(System.currentTimeMillis() > var2.lastMusic && var2.playMusic(var1, "calm")) {
				var2.lastMusic = System.currentTimeMillis() + (long)var2.random.nextInt(900000) + 300000L;
			}
		}

		this.gamemode.spawnMob();
		HUDScreen var17 = this.hud;
		++this.hud.ticks;

		int var16;
		for(var16 = 0; var16 < var17.chat.size(); ++var16) {
			++((ChatLine)var17.chat.get(var16)).time;
		}

		GL11.glBindTexture(3553, this.textureManager.load("/terrain.png"));
		TextureManager var19 = this.textureManager;

		for(var16 = 0; var16 < var19.animations.size(); ++var16) {
			TextureFX var3;
			(var3 = var19.animations.get(var16)).anaglyph = var19.settings.anaglyph;
			var3.animate();
			var19.textureBuffer.clear();
			var19.textureBuffer.put(var3.textureData);
			var19.textureBuffer.position(0).limit(var3.textureData.length);
			GL11.glTexSubImage2D(3553, 0, var3.textureId % 16 << 4, var3.textureId / 16 << 4, 16, 16, 6408, 5121, var19.textureBuffer);
		}

		int var4;
		int var8;
		int var40;
		int var46;
		int var45;
		if(this.networkManager != null && !(this.currentScreen instanceof ErrorScreen)) {
			if(!this.networkManager.isConnected()) {
				this.progressBar.setTitle("Connecting..");
				this.progressBar.setProgress(0);
			} else {
				NetworkManager var20 = this.networkManager;
				if(this.networkManager.successful) {
					NetworkHandler var18 = var20.netHandler;
					if(var20.netHandler.connected) {
						try {
							NetworkHandler var22 = var20.netHandler;
							var20.netHandler.channel.read(var22.in);
							var4 = 0;

							while(var22.in.position() > 0 && var4++ != 100) {
								var22.in.flip();
								byte var5 = var22.in.get(0);
								PacketType var6;
								if((var6 = PacketType.packets[var5]) == null) {
									throw new IOException("Bad command: " + var5);
								}

								if(var22.in.remaining() < var6.length + 1) {
									var22.in.compact();
									break;
								}

								var22.in.get();
								Object[] var7 = new Object[var6.params.length];

								for(var8 = 0; var8 < var7.length; ++var8) {
									var7[var8] = var22.readObject(var6.params[var8]);
								}

								NetworkManager var42 = var22.netManager;
								if(var22.netManager.successful) {
									if(var6 == PacketType.IDENTIFICATION) {
										var42.minecraft.progressBar.setTitle(var7[1].toString());
										var42.minecraft.progressBar.setText(var7[2].toString());
										var42.minecraft.player.userType = ((Byte)var7[3]).byteValue();
									} else if(var6 == PacketType.LEVEL_INIT) {
										var42.minecraft.setLevel((Level)null);
										var42.levelData = new ByteArrayOutputStream();
									} else if(var6 == PacketType.LEVEL_DATA) {
										short var11 = ((Short)var7[0]).shortValue();
										byte[] var12 = (byte[])((byte[])var7[1]);
										byte var13 = ((Byte)var7[2]).byteValue();
										var42.minecraft.progressBar.setProgress(var13);
										var42.levelData.write(var12, 0, var11);
									} else if(var6 == PacketType.LEVEL_FINALIZE) {
										try {
											var42.levelData.close();
										} catch (IOException var14) {
											var14.printStackTrace();
										}

										byte[] var51 = LevelIO.decompress(new ByteArrayInputStream(var42.levelData.toByteArray()));
										var42.levelData = null;
										short var55 = ((Short)var7[0]).shortValue();
										short var63 = ((Short)var7[1]).shortValue();
										short var21 = ((Short)var7[2]).shortValue();
										Level var30;
										(var30 = new Level()).setNetworkMode(true);
										var30.setData(var55, var63, var21, var51);
										var42.minecraft.setLevel(var30);
										var42.minecraft.online = false;
										var42.levelLoaded = true;
									} else if(var6 == PacketType.BLOCK_CHANGE) {
										if(var42.minecraft.level != null) {
											var42.minecraft.level.netSetTile(((Short)var7[0]).shortValue(), ((Short)var7[1]).shortValue(), ((Short)var7[2]).shortValue(), ((Byte)var7[3]).byteValue());
										}
									} else {
										byte var9;
										String var34;
										NetworkPlayer var33;
										short var36;
										short var10004;
										byte var10001;
										short var47;
										short var10003;
										if(var6 == PacketType.SPAWN_PLAYER) {
											var10001 = ((Byte)var7[0]).byteValue();
											String var10002 = (String)var7[1];
											var10003 = ((Short)var7[2]).shortValue();
											var10004 = ((Short)var7[3]).shortValue();
											short var10005 = ((Short)var7[4]).shortValue();
											byte var10006 = ((Byte)var7[5]).byteValue();
											byte var58 = ((Byte)var7[6]).byteValue();
											var9 = var10006;
											short var10 = var10005;
											var47 = var10004;
											var36 = var10003;
											var34 = var10002;
											var5 = var10001;
											if(var5 >= 0) {
												var9 = (byte)(var9 + 128);
												var47 = (short)(var47 - 22);
												var33 = new NetworkPlayer(var42.minecraft, var5, var34, var36, var47, var10, (float)(var9 * 360) / 256.0F, (float)(var58 * 360) / 256.0F);
												var42.players.put(Byte.valueOf(var5), var33);
												var42.minecraft.level.addEntity(var33);
											} else {
												var42.minecraft.level.setSpawnPos(var36 / 32, var47 / 32, var10 / 32, (float)(var9 * 320 / 256));
												var42.minecraft.player.moveTo((float)var36 / 32.0F, (float)var47 / 32.0F, (float)var10 / 32.0F, (float)(var9 * 360) / 256.0F, (float)(var58 * 360) / 256.0F);
											}
										} else {
											byte var53;
											NetworkPlayer var61;
											byte var69;
											if(var6 == PacketType.POSITION_ROTATION) {
												var10001 = ((Byte)var7[0]).byteValue();
												short var66 = ((Short)var7[1]).shortValue();
												var10003 = ((Short)var7[2]).shortValue();
												var10004 = ((Short)var7[3]).shortValue();
												var69 = ((Byte)var7[4]).byteValue();
												var9 = ((Byte)var7[5]).byteValue();
												var53 = var69;
												var47 = var10004;
												var36 = var10003;
												short var38 = var66;
												var5 = var10001;
												if(var5 < 0) {
													var42.minecraft.player.moveTo((float)var38 / 32.0F, (float)var36 / 32.0F, (float)var47 / 32.0F, (float)(var53 * 360) / 256.0F, (float)(var9 * 360) / 256.0F);
												} else {
													var53 = (byte)(var53 + 128);
													var36 = (short)(var36 - 22);
													if((var61 = (NetworkPlayer)var42.players.get(Byte.valueOf(var5))) != null) {
														var61.teleport(var38, var36, var47, (float)(var53 * 360) / 256.0F, (float)(var9 * 360) / 256.0F);
													}
												}
											} else {
												byte var37;
												byte var44;
												byte var49;
												byte var65;
												byte var67;
												if(var6 == PacketType.POSITION_ROTATION_UPDATE) {
													var10001 = ((Byte)var7[0]).byteValue();
													var67 = ((Byte)var7[1]).byteValue();
													var65 = ((Byte)var7[2]).byteValue();
													byte var64 = ((Byte)var7[3]).byteValue();
													var69 = ((Byte)var7[4]).byteValue();
													var9 = ((Byte)var7[5]).byteValue();
													var53 = var69;
													var49 = var64;
													var44 = var65;
													var37 = var67;
													var5 = var10001;
													if(var5 >= 0) {
														var53 = (byte)(var53 + 128);
														if((var61 = (NetworkPlayer)var42.players.get(Byte.valueOf(var5))) != null) {
															var61.queue(var37, var44, var49, (float)(var53 * 360) / 256.0F, (float)(var9 * 360) / 256.0F);
														}
													}
												} else if(var6 == PacketType.ROTATION_UPDATE) {
													var10001 = ((Byte)var7[0]).byteValue();
													var67 = ((Byte)var7[1]).byteValue();
													var44 = ((Byte)var7[2]).byteValue();
													var37 = var67;
													var5 = var10001;
													if(var5 >= 0) {
														var37 = (byte)(var37 + 128);
														NetworkPlayer var54;
														if((var54 = (NetworkPlayer)var42.players.get(Byte.valueOf(var5))) != null) {
															var54.queue((float)(var37 * 360) / 256.0F, (float)(var44 * 360) / 256.0F);
														}
													}
												} else if(var6 == PacketType.POSITION_UPDATE) {
													var10001 = ((Byte)var7[0]).byteValue();
													var67 = ((Byte)var7[1]).byteValue();
													var65 = ((Byte)var7[2]).byteValue();
													var49 = ((Byte)var7[3]).byteValue();
													var44 = var65;
													var37 = var67;
													var5 = var10001;
													NetworkPlayer var59;
													if(var5 >= 0 && (var59 = (NetworkPlayer)var42.players.get(Byte.valueOf(var5))) != null) {
														var59.queue(var37, var44, var49);
													}
												} else if(var6 == PacketType.DESPAWN_PLAYER) {
													var5 = ((Byte)var7[0]).byteValue();
													if(var5 >= 0 && (var33 = (NetworkPlayer)var42.players.remove(Byte.valueOf(var5))) != null) {
														var33.clear();
														var42.minecraft.level.removeEntity(var33);
													}
												} else if(var6 == PacketType.CHAT_MESSAGE) {
													var10001 = ((Byte)var7[0]).byteValue();
													var34 = (String)var7[1];
													var5 = var10001;
													if(var5 < 0) {
														var42.minecraft.hud.addChat("&e" + var34);
													} else {
														var42.players.get(Byte.valueOf(var5));
														var42.minecraft.hud.addChat(var34);
													}
												} else if(var6 == PacketType.DISCONNECT) {
													var42.netHandler.close();
													var42.minecraft.setCurrentScreen(new ErrorScreen("Connection lost", (String)var7[0]));
												} else if(var6 == PacketType.UPDATE_PLAYER_TYPE) {
													var42.minecraft.player.userType = ((Byte)var7[0]).byteValue();
												}
											}
										}
									}
								}

								if(!var22.connected) {
									break;
								}

								var22.in.compact();
							}

							if(var22.out.position() > 0) {
								var22.out.flip();
								var22.channel.write(var22.out);
								var22.out.compact();
							}
						} catch (Exception var15) {
							var20.minecraft.setCurrentScreen(new ErrorScreen("Disconnected!", "You\'ve lost connection to the server"));
							var20.minecraft.online = false;
							var15.printStackTrace();
							var20.netHandler.close();
							var20.minecraft.networkManager = null;
						}
					}
				}

				Player var28 = this.player;
				var20 = this.networkManager;
				if(this.networkManager.levelLoaded) {
					int var24 = (int)(var28.x * 32.0F);
					var4 = (int)(var28.y * 32.0F);
					var40 = (int)(var28.z * 32.0F);
					var46 = (int)(var28.yRot * 256.0F / 360.0F) & 255;
					var45 = (int)(var28.xRot * 256.0F / 360.0F) & 255;
					var20.netHandler.send(PacketType.POSITION_ROTATION, new Object[]{Integer.valueOf(-1), Integer.valueOf(var24), Integer.valueOf(var4), Integer.valueOf(var40), Integer.valueOf(var46), Integer.valueOf(var45)});
				}
			}
		}

		if(this.currentScreen == null && this.player != null && this.player.health <= 0) {
			this.setCurrentScreen((GuiScreen)null);
		}

		if(this.currentScreen == null || this.currentScreen.grabsMouse) {
			int var25;
			while(Mouse.next()) {
				if((var25 = Mouse.getEventDWheel()) != 0) {
					this.player.inventory.swapPaint(var25);
				}

				if(this.currentScreen == null) {
					if(!this.hasMouse && Mouse.getEventButtonState()) {
						this.grabMouse();
					} else {
						if(Mouse.getEventButton() == 0 && Mouse.getEventButtonState()) {
							this.onMouseClick(0);
							this.lastClick = this.ticks;
						}

						if(Mouse.getEventButton() == 1 && Mouse.getEventButtonState()) {
							this.onMouseClick(1);
							this.lastClick = this.ticks;
						}

						if(Mouse.getEventButton() == 2 && Mouse.getEventButtonState() && this.selected != null) {
							if((var16 = this.level.getTile(this.selected.x, this.selected.y, this.selected.z)) == Block.GRASS.id) {
								var16 = Block.DIRT.id;
							}

							if(var16 == Block.DOUBLE_SLAB.id) {
								var16 = Block.SLAB.id;
							}

							if(var16 == Block.BEDROCK.id) {
								var16 = Block.STONE.id;
							}

							this.player.inventory.grabTexture(var16, this.gamemode instanceof CreativeGameMode);
						}
					}
				}

				if(this.currentScreen != null) {
					this.currentScreen.mouseEvent();
				}
			}

			if(this.blockHitTime > 0) {
				--this.blockHitTime;
			}

			while(Keyboard.next()) {
				this.player.setKey(Keyboard.getEventKey(), Keyboard.getEventKeyState());
				if(Keyboard.getEventKeyState()) {
					if(this.currentScreen != null) {
						this.currentScreen.keyboardEvent();
					}

					if(this.currentScreen == null) {
						if(Keyboard.getEventKey() == 1) {
							this.pause();
						}

						if(this.gamemode instanceof CreativeGameMode) {
							if(Keyboard.getEventKey() == this.settings.loadLocationKey.key) {
								this.player.resetPos();
							}

							if(Keyboard.getEventKey() == this.settings.saveLocationKey.key) {
								this.level.setSpawnPos((int)this.player.x, (int)this.player.y, (int)this.player.z, this.player.yRot);
								this.player.resetPos();
							}
						}

						Keyboard.getEventKey();
						if(Keyboard.getEventKey() == 63) {
							this.raining = !this.raining;
						}

						if(Keyboard.getEventKey() == 15 && this.gamemode instanceof SurvivalGameMode && this.player.arrows > 0) {
							this.level.addEntity(new Arrow(this.level, this.player, this.player.x, this.player.y, this.player.z, this.player.yRot, this.player.xRot, 1.2F));
							--this.player.arrows;
						}

						if(Keyboard.getEventKey() == this.settings.inventoryKey.key) {
							this.gamemode.openInventory();
						}

						if(Keyboard.getEventKey() == this.settings.chatKey.key && this.networkManager != null && this.networkManager.isConnected()) {
							this.player.releaseAllKeys();
							this.setCurrentScreen(new ChatInputScreen());
						}
					}

					for(var25 = 0; var25 < 9; ++var25) {
						if(Keyboard.getEventKey() == var25 + 2) {
							this.player.inventory.selected = var25;
						}
					}

					if(Keyboard.getEventKey() == this.settings.toggleFogKey.key) {
						this.settings.toggleSetting(4, !Keyboard.isKeyDown(42) && !Keyboard.isKeyDown(54)?1:-1);
					}
				}
			}

			if(this.currentScreen == null) {
				if(Mouse.isButtonDown(0) && (float)(this.ticks - this.lastClick) >= this.timer.tps / 4.0F && this.hasMouse) {
					this.onMouseClick(0);
					this.lastClick = this.ticks;
				}

				if(Mouse.isButtonDown(1) && (float)(this.ticks - this.lastClick) >= this.timer.tps / 4.0F && this.hasMouse) {
					this.onMouseClick(1);
					this.lastClick = this.ticks;
				}
			}

			boolean var26 = this.currentScreen == null && Mouse.isButtonDown(0) && this.hasMouse;
			boolean var35 = false;
			if(!this.gamemode.instantBreak && this.blockHitTime <= 0) {
				if(var26 && this.selected != null && this.selected.entityPos == 0) {
					var4 = this.selected.x;
					var40 = this.selected.y;
					var46 = this.selected.z;
					this.gamemode.hitBlock(var4, var40, var46, this.selected.face);
				} else {
					this.gamemode.resetHits();
				}
			}
		}

		if(this.currentScreen != null) {
			this.lastClick = this.ticks + 10000;
		}

		if(this.currentScreen != null) {
			this.currentScreen.doInput();
			if(this.currentScreen != null) {
				this.currentScreen.tick();
			}
		}

		if(this.level != null) {
			com.mojang.minecraft.render.Renderer var29 = this.renderer;
			++this.renderer.levelTicks;
			HeldBlock var41 = var29.heldBlock;
			var29.heldBlock.lastPos = var41.pos;
			if(var41.moving) {
				++var41.offset;
				if(var41.offset == 7) {
					var41.offset = 0;
					var41.moving = false;
				}
			}

			Player var27 = var41.minecraft.player;
			var4 = var41.minecraft.player.inventory.getSelected();
			Block var43 = null;
			if(var4 > 0) {
				var43 = Block.blocks[var4];
			}

			float var48 = 0.4F;
			float var50;
			if((var50 = (var43 == var41.block?1.0F:0.0F) - var41.pos) < -var48) {
				var50 = -var48;
			}

			if(var50 > var48) {
				var50 = var48;
			}

			var41.pos += var50;
			if(var41.pos < 0.1F) {
				var41.block = var43;
			}

			if(var29.minecraft.raining) {
				com.mojang.minecraft.render.Renderer var39 = var29;
				var27 = var29.minecraft.player;
				Level var32 = var29.minecraft.level;
				var40 = (int)var27.x;
				var46 = (int)var27.y;
				var45 = (int)var27.z;

				for(var8 = 0; var8 < 50; ++var8) {
					int var60 = var40 + var39.random.nextInt(9) - 4;
					int var52 = var45 + var39.random.nextInt(9) - 4;
					int var57;
					if((var57 = var32.getHighestTile(var60, var52)) <= var46 + 4 && var57 >= var46 - 4) {
						float var56 = var39.random.nextFloat();
						float var62 = var39.random.nextFloat();
						var39.minecraft.particleManager.spawnParticle(new WaterDropParticle(var32, (float)var60 + var56, (float)var57 + 0.1F, (float)var52 + var62));
					}
				}
			}

			LevelRenderer var31 = this.levelRenderer;
			++this.levelRenderer.ticks;
			this.level.tickEntities();
			if(!this.isOnline()) {
				this.level.tick();
			}

			this.particleManager.tick();
		}

	}