    001    package net.minecraft.client.multiplayer;
    002
    003    import cpw.mods.fml.common.network.FMLNetworkHandler;
    004    import cpw.mods.fml.relauncher.Side;
    005    import cpw.mods.fml.relauncher.SideOnly;
    006    import java.io.BufferedReader;
    007    import java.io.ByteArrayInputStream;
    008    import java.io.DataInputStream;
    009    import java.io.IOException;
    010    import java.io.InputStreamReader;
    011    import java.math.BigInteger;
    012    import java.net.InetAddress;
    013    import java.net.Socket;
    014    import java.net.URL;
    015    import java.net.URLEncoder;
    016    import java.security.PublicKey;
    017    import java.util.ArrayList;
    018    import java.util.HashMap;
    019    import java.util.List;
    020    import java.util.Map;
    021    import java.util.Random;
    022    import javax.crypto.SecretKey;
    023    import net.minecraft.client.Minecraft;
    024    import net.minecraft.client.entity.EntityClientPlayerMP;
    025    import net.minecraft.client.entity.EntityOtherPlayerMP;
    026    import net.minecraft.client.gui.GuiChat;
    027    import net.minecraft.client.gui.GuiDisconnected;
    028    import net.minecraft.client.gui.GuiDownloadTerrain;
    029    import net.minecraft.client.gui.GuiMerchant;
    030    import net.minecraft.client.gui.GuiPlayerInfo;
    031    import net.minecraft.client.gui.GuiScreen;
    032    import net.minecraft.client.gui.GuiScreenDemo;
    033    import net.minecraft.client.gui.GuiWinGame;
    034    import net.minecraft.client.gui.GuiYesNo;
    035    import net.minecraft.client.gui.inventory.GuiContainerCreative;
    036    import net.minecraft.client.particle.EntityCrit2FX;
    037    import net.minecraft.client.particle.EntityPickupFX;
    038    import net.minecraft.client.settings.GameSettings;
    039    import net.minecraft.creativetab.CreativeTabs;
    040    import net.minecraft.entity.Entity;
    041    import net.minecraft.entity.EntityList;
    042    import net.minecraft.entity.EntityLiving;
    043    import net.minecraft.entity.IMerchant;
    044    import net.minecraft.entity.NpcMerchant;
    045    import net.minecraft.entity.effect.EntityLightningBolt;
    046    import net.minecraft.entity.item.EntityBoat;
    047    import net.minecraft.entity.item.EntityEnderCrystal;
    048    import net.minecraft.entity.item.EntityEnderEye;
    049    import net.minecraft.entity.item.EntityEnderPearl;
    050    import net.minecraft.entity.item.EntityExpBottle;
    051    import net.minecraft.entity.item.EntityFallingSand;
    052    import net.minecraft.entity.item.EntityFireworkRocket;
    053    import net.minecraft.entity.item.EntityItem;
    054    import net.minecraft.entity.item.EntityItemFrame;
    055    import net.minecraft.entity.item.EntityMinecart;
    056    import net.minecraft.entity.item.EntityPainting;
    057    import net.minecraft.entity.item.EntityTNTPrimed;
    058    import net.minecraft.entity.item.EntityXPOrb;
    059    import net.minecraft.entity.player.EntityPlayer;
    060    import net.minecraft.entity.player.InventoryPlayer;
    061    import net.minecraft.entity.projectile.EntityArrow;
    062    import net.minecraft.entity.projectile.EntityEgg;
    063    import net.minecraft.entity.projectile.EntityFishHook;
    064    import net.minecraft.entity.projectile.EntityLargeFireball;
    065    import net.minecraft.entity.projectile.EntityPotion;
    066    import net.minecraft.entity.projectile.EntitySmallFireball;
    067    import net.minecraft.entity.projectile.EntitySnowball;
    068    import net.minecraft.entity.projectile.EntityWitherSkull;
    069    import net.minecraft.inventory.Container;
    070    import net.minecraft.inventory.InventoryBasic;
    071    import net.minecraft.item.Item;
    072    import net.minecraft.item.ItemMap;
    073    import net.minecraft.item.ItemStack;
    074    import net.minecraft.network.INetworkManager;
    075    import net.minecraft.network.MemoryConnection;
    076    import net.minecraft.network.TcpConnection;
    077    import net.minecraft.network.packet.NetHandler;
    078    import net.minecraft.network.packet.Packet;
    079    import net.minecraft.network.packet.Packet0KeepAlive;
    080    import net.minecraft.network.packet.Packet100OpenWindow;
    081    import net.minecraft.network.packet.Packet101CloseWindow;
    082    import net.minecraft.network.packet.Packet103SetSlot;
    083    import net.minecraft.network.packet.Packet104WindowItems;
    084    import net.minecraft.network.packet.Packet105UpdateProgressbar;
    085    import net.minecraft.network.packet.Packet106Transaction;
    086    import net.minecraft.network.packet.Packet10Flying;
    087    import net.minecraft.network.packet.Packet130UpdateSign;
    088    import net.minecraft.network.packet.Packet131MapData;
    089    import net.minecraft.network.packet.Packet132TileEntityData;
    090    import net.minecraft.network.packet.Packet16BlockItemSwitch;
    091    import net.minecraft.network.packet.Packet17Sleep;
    092    import net.minecraft.network.packet.Packet18Animation;
    093    import net.minecraft.network.packet.Packet1Login;
    094    import net.minecraft.network.packet.Packet200Statistic;
    095    import net.minecraft.network.packet.Packet201PlayerInfo;
    096    import net.minecraft.network.packet.Packet202PlayerAbilities;
    097    import net.minecraft.network.packet.Packet203AutoComplete;
    098    import net.minecraft.network.packet.Packet205ClientCommand;
    099    import net.minecraft.network.packet.Packet20NamedEntitySpawn;
    100    import net.minecraft.network.packet.Packet22Collect;
    101    import net.minecraft.network.packet.Packet23VehicleSpawn;
    102    import net.minecraft.network.packet.Packet24MobSpawn;
    103    import net.minecraft.network.packet.Packet250CustomPayload;
    104    import net.minecraft.network.packet.Packet252SharedKey;
    105    import net.minecraft.network.packet.Packet253ServerAuthData;
    106    import net.minecraft.network.packet.Packet255KickDisconnect;
    107    import net.minecraft.network.packet.Packet25EntityPainting;
    108    import net.minecraft.network.packet.Packet26EntityExpOrb;
    109    import net.minecraft.network.packet.Packet28EntityVelocity;
    110    import net.minecraft.network.packet.Packet29DestroyEntity;
    111    import net.minecraft.network.packet.Packet30Entity;
    112    import net.minecraft.network.packet.Packet34EntityTeleport;
    113    import net.minecraft.network.packet.Packet35EntityHeadRotation;
    114    import net.minecraft.network.packet.Packet38EntityStatus;
    115    import net.minecraft.network.packet.Packet39AttachEntity;
    116    import net.minecraft.network.packet.Packet3Chat;
    117    import net.minecraft.network.packet.Packet40EntityMetadata;
    118    import net.minecraft.network.packet.Packet41EntityEffect;
    119    import net.minecraft.network.packet.Packet42RemoveEntityEffect;
    120    import net.minecraft.network.packet.Packet43Experience;
    121    import net.minecraft.network.packet.Packet4UpdateTime;
    122    import net.minecraft.network.packet.Packet51MapChunk;
    123    import net.minecraft.network.packet.Packet52MultiBlockChange;
    124    import net.minecraft.network.packet.Packet53BlockChange;
    125    import net.minecraft.network.packet.Packet54PlayNoteBlock;
    126    import net.minecraft.network.packet.Packet55BlockDestroy;
    127    import net.minecraft.network.packet.Packet56MapChunks;
    128    import net.minecraft.network.packet.Packet5PlayerInventory;
    129    import net.minecraft.network.packet.Packet60Explosion;
    130    import net.minecraft.network.packet.Packet61DoorChange;
    131    import net.minecraft.network.packet.Packet62LevelSound;
    132    import net.minecraft.network.packet.Packet6SpawnPosition;
    133    import net.minecraft.network.packet.Packet70GameEvent;
    134    import net.minecraft.network.packet.Packet71Weather;
    135    import net.minecraft.network.packet.Packet8UpdateHealth;
    136    import net.minecraft.network.packet.Packet9Respawn;
    137    import net.minecraft.potion.PotionEffect;
    138    import net.minecraft.server.integrated.IntegratedServer;
    139    import net.minecraft.stats.StatList;
    140    import net.minecraft.tileentity.TileEntity;
    141    import net.minecraft.tileentity.TileEntityBeacon;
    142    import net.minecraft.tileentity.TileEntityBrewingStand;
    143    import net.minecraft.tileentity.TileEntityCommandBlock;
    144    import net.minecraft.tileentity.TileEntityDispenser;
    145    import net.minecraft.tileentity.TileEntityFurnace;
    146    import net.minecraft.tileentity.TileEntityMobSpawner;
    147    import net.minecraft.tileentity.TileEntitySign;
    148    import net.minecraft.tileentity.TileEntitySkull;
    149    import net.minecraft.util.ChunkCoordinates;
    150    import net.minecraft.util.CryptManager;
    151    import net.minecraft.util.MathHelper;
    152    import net.minecraft.util.StringTranslate;
    153    import net.minecraft.village.MerchantRecipeList;
    154    import net.minecraft.world.EnumGameType;
    155    import net.minecraft.world.Explosion;
    156    import net.minecraft.world.WorldProviderSurface;
    157    import net.minecraft.world.WorldSettings;
    158    import net.minecraft.world.chunk.Chunk;
    159    import net.minecraft.world.storage.ISaveHandler;
    160    import net.minecraft.world.storage.MapStorage;
    161    import org.lwjgl.input.Keyboard;
    162
    163    import net.minecraftforge.client.ForgeHooksClient;
    164    import net.minecraftforge.client.event.ClientChatReceivedEvent;
    165    import net.minecraftforge.common.ForgeHooks;
    166    import net.minecraftforge.common.MinecraftForge;
    167
    168    @SideOnly(Side.CLIENT)
    169    public class NetClientHandler extends NetHandler
    170    {
    171        /** True if kicked or disconnected from the server. */
    172        private boolean disconnected = false;
    173
    174        /** Reference to the NetworkManager object. */
    175        private INetworkManager netManager;
    176        public String field_72560_a;
    177
    178        /** Reference to the Minecraft object. */
    179        private Minecraft mc;
    180        private WorldClient worldClient;
    181
    182        /**
    183         * True if the client has finished downloading terrain and may spawn. Set upon receipt of a player position packet,
    184         * reset upon respawning.
    185         */
    186        private boolean doneLoadingTerrain = false;
    187        public MapStorage mapStorage = new MapStorage((ISaveHandler)null);
    188
    189        /** A HashMap of all player names and their player information objects */
    190        private Map playerInfoMap = new HashMap();
    191
    192        /**
    193         * An ArrayList of GuiPlayerInfo (includes all the players' GuiPlayerInfo on the current server)
    194         */
    195        public List playerInfoList = new ArrayList();
    196        public int currentServerMaxPlayers = 20;
    197
    198        /** RNG. */
    199        Random rand = new Random();
    200
    201        private static byte connectionCompatibilityLevel;
    202
    203        public NetClientHandler(Minecraft par1Minecraft, String par2Str, int par3) throws IOException
    204        {
    205            this.mc = par1Minecraft;
    206            Socket var4 = new Socket(InetAddress.getByName(par2Str), par3);
    207            this.netManager = new TcpConnection(var4, "Client", this);
    208            FMLNetworkHandler.onClientConnectionToRemoteServer(this, par2Str, par3, this.netManager);
    209        }
    210
    211        public NetClientHandler(Minecraft par1Minecraft, IntegratedServer par2IntegratedServer) throws IOException
    212        {
    213            this.mc = par1Minecraft;
    214            this.netManager = new MemoryConnection(this);
    215            par2IntegratedServer.getServerListeningThread().func_71754_a((MemoryConnection)this.netManager, par1Minecraft.session.username);
    216            FMLNetworkHandler.onClientConnectionToIntegratedServer(this, par2IntegratedServer, this.netManager);
    217        }
    218
    219        /**
    220         * sets netManager and worldClient to null
    221         */
    222        public void cleanup()
    223        {
    224            if (this.netManager != null)
    225            {
    226                this.netManager.wakeThreads();
    227            }
    228
    229            this.netManager = null;
    230            this.worldClient = null;
    231        }
    232
    233        /**
    234         * Processes the packets that have been read since the last call to this function.
    235         */
    236        public void processReadPackets()
    237        {
    238            if (!this.disconnected && this.netManager != null)
    239            {
    240                this.netManager.processReadPackets();
    241            }
    242
    243            if (this.netManager != null)
    244            {
    245                this.netManager.wakeThreads();
    246            }
    247        }
    248
    249        public void handleServerAuthData(Packet253ServerAuthData par1Packet253ServerAuthData)
    250        {
    251            String var2 = par1Packet253ServerAuthData.getServerId().trim();
    252            PublicKey var3 = par1Packet253ServerAuthData.getPublicKey();
    253            SecretKey var4 = CryptManager.func_75890_a();
    254
    255            if (!"-".equals(var2))
    256            {
    257                String var5 = (new BigInteger(CryptManager.func_75895_a(var2, var3, var4))).toString(16);
    258                String var6 = this.func_72550_a(this.mc.session.username, this.mc.session.sessionId, var5);
    259
    260                if (!"ok".equalsIgnoreCase(var6))
    261                {
    262                    this.netManager.networkShutdown("disconnect.loginFailedInfo", new Object[] {var6});
    263                    return;
    264                }
    265            }
    266
    267            this.addToSendQueue(new Packet252SharedKey(var4, var3, par1Packet253ServerAuthData.getVerifyToken()));
    268        }
    269
    270        private String func_72550_a(String par1Str, String par2Str, String par3Str)
    271        {
    272            try
    273            {
    274                URL var4 = new URL("http://session.minecraft.net/game/joinserver.jsp?user=" + urlEncode(par1Str) + "&sessionId=" + urlEncode(par2Str) + "&serverId=" + urlEncode(par3Str));
    275                BufferedReader var5 = new BufferedReader(new InputStreamReader(var4.openStream()));
    276                String var6 = var5.readLine();
    277                var5.close();
    278                return var6;
    279            }
    280            catch (IOException var7)
    281            {
    282                return var7.toString();
    283            }
    284        }
    285
    286        /**
    287         * Encode the given string for insertion into a URL
    288         */
    289        private static String urlEncode(String par0Str) throws IOException
    290        {
    291            return URLEncoder.encode(par0Str, "UTF-8");
    292        }
    293
    294        public void handleSharedKey(Packet252SharedKey par1Packet252SharedKey)
    295        {
    296            this.addToSendQueue(FMLNetworkHandler.getFMLFakeLoginPacket());
    297            this.addToSendQueue(new Packet205ClientCommand(0));
    298        }
    299
    300        public void handleLogin(Packet1Login par1Packet1Login)
    301        {
    302            this.mc.playerController = new PlayerControllerMP(this.mc, this);
    303            this.mc.statFileWriter.readStat(StatList.joinMultiplayerStat, 1);
    304            this.worldClient = new WorldClient(this, new WorldSettings(0L, par1Packet1Login.gameType, false, par1Packet1Login.hardcoreMode, par1Packet1Login.terrainType), par1Packet1Login.dimension, par1Packet1Login.difficultySetting, this.mc.mcProfiler);
    305            this.worldClient.isRemote = true;
    306            this.mc.loadWorld(this.worldClient);
    307            this.mc.thePlayer.dimension = par1Packet1Login.dimension;
    308            this.mc.displayGuiScreen(new GuiDownloadTerrain(this));
    309            this.mc.thePlayer.entityId = par1Packet1Login.clientEntityId;
    310            this.currentServerMaxPlayers = par1Packet1Login.maxPlayers;
    311            this.mc.playerController.setGameType(par1Packet1Login.gameType);
    312            FMLNetworkHandler.onConnectionEstablishedToServer(this, netManager, par1Packet1Login);
    313            this.mc.gameSettings.sendSettingsToServer();
    314        }
    315
    316        public void handleVehicleSpawn(Packet23VehicleSpawn par1Packet23VehicleSpawn)
    317        {
    318            double var2 = (double)par1Packet23VehicleSpawn.xPosition / 32.0D;
    319            double var4 = (double)par1Packet23VehicleSpawn.yPosition / 32.0D;
    320            double var6 = (double)par1Packet23VehicleSpawn.zPosition / 32.0D;
    321            Object var8 = null;
    322
    323            if (par1Packet23VehicleSpawn.type == 10)
    324            {
    325                var8 = new EntityMinecart(this.worldClient, var2, var4, var6, 0);
    326            }
    327            else if (par1Packet23VehicleSpawn.type == 11)
    328            {
    329                var8 = new EntityMinecart(this.worldClient, var2, var4, var6, 1);
    330            }
    331            else if (par1Packet23VehicleSpawn.type == 12)
    332            {
    333                var8 = new EntityMinecart(this.worldClient, var2, var4, var6, 2);
    334            }
    335            else if (par1Packet23VehicleSpawn.type == 90)
    336            {
    337                Entity var9 = this.getEntityByID(par1Packet23VehicleSpawn.throwerEntityId);
    338
    339                if (var9 instanceof EntityPlayer)
    340                {
    341                    var8 = new EntityFishHook(this.worldClient, var2, var4, var6, (EntityPlayer)var9);
    342                }
    343
    344                par1Packet23VehicleSpawn.throwerEntityId = 0;
    345            }
    346            else if (par1Packet23VehicleSpawn.type == 60)
    347            {
    348                var8 = new EntityArrow(this.worldClient, var2, var4, var6);
    349            }
    350            else if (par1Packet23VehicleSpawn.type == 61)
    351            {
    352                var8 = new EntitySnowball(this.worldClient, var2, var4, var6);
    353            }
    354            else if (par1Packet23VehicleSpawn.type == 71)
    355            {
    356                var8 = new EntityItemFrame(this.worldClient, (int)var2, (int)var4, (int)var6, par1Packet23VehicleSpawn.throwerEntityId);
    357                par1Packet23VehicleSpawn.throwerEntityId = 0;
    358            }
    359            else if (par1Packet23VehicleSpawn.type == 65)
    360            {
    361                var8 = new EntityEnderPearl(this.worldClient, var2, var4, var6);
    362            }
    363            else if (par1Packet23VehicleSpawn.type == 72)
    364            {
    365                var8 = new EntityEnderEye(this.worldClient, var2, var4, var6);
    366            }
    367            else if (par1Packet23VehicleSpawn.type == 76)
    368            {
    369                var8 = new EntityFireworkRocket(this.worldClient, var2, var4, var6, (ItemStack)null);
    370            }
    371            else if (par1Packet23VehicleSpawn.type == 63)
    372            {
    373                var8 = new EntityLargeFireball(this.worldClient, var2, var4, var6, (double)par1Packet23VehicleSpawn.speedX / 8000.0D, (double)par1Packet23VehicleSpawn.speedY / 8000.0D, (double)par1Packet23VehicleSpawn.speedZ / 8000.0D);
    374                par1Packet23VehicleSpawn.throwerEntityId = 0;
    375            }
    376            else if (par1Packet23VehicleSpawn.type == 64)
    377            {
    378                var8 = new EntitySmallFireball(this.worldClient, var2, var4, var6, (double)par1Packet23VehicleSpawn.speedX / 8000.0D, (double)par1Packet23VehicleSpawn.speedY / 8000.0D, (double)par1Packet23VehicleSpawn.speedZ / 8000.0D);
    379                par1Packet23VehicleSpawn.throwerEntityId = 0;
    380            }
    381            else if (par1Packet23VehicleSpawn.type == 66)
    382            {
    383                var8 = new EntityWitherSkull(this.worldClient, var2, var4, var6, (double)par1Packet23VehicleSpawn.speedX / 8000.0D, (double)par1Packet23VehicleSpawn.speedY / 8000.0D, (double)par1Packet23VehicleSpawn.speedZ / 8000.0D);
    384                par1Packet23VehicleSpawn.throwerEntityId = 0;
    385            }
    386            else if (par1Packet23VehicleSpawn.type == 62)
    387            {
    388                var8 = new EntityEgg(this.worldClient, var2, var4, var6);
    389            }
    390            else if (par1Packet23VehicleSpawn.type == 73)
    391            {
    392                var8 = new EntityPotion(this.worldClient, var2, var4, var6, par1Packet23VehicleSpawn.throwerEntityId);
    393                par1Packet23VehicleSpawn.throwerEntityId = 0;
    394            }
    395            else if (par1Packet23VehicleSpawn.type == 75)
    396            {
    397                var8 = new EntityExpBottle(this.worldClient, var2, var4, var6);
    398                par1Packet23VehicleSpawn.throwerEntityId = 0;
    399            }
    400            else if (par1Packet23VehicleSpawn.type == 1)
    401            {
    402                var8 = new EntityBoat(this.worldClient, var2, var4, var6);
    403            }
    404            else if (par1Packet23VehicleSpawn.type == 50)
    405            {
    406                var8 = new EntityTNTPrimed(this.worldClient, var2, var4, var6);
    407            }
    408            else if (par1Packet23VehicleSpawn.type == 51)
    409            {
    410                var8 = new EntityEnderCrystal(this.worldClient, var2, var4, var6);
    411            }
    412            else if (par1Packet23VehicleSpawn.type == 2)
    413            {
    414                var8 = new EntityItem(this.worldClient, var2, var4, var6);
    415            }
    416            else if (par1Packet23VehicleSpawn.type == 70)
    417            {
    418                var8 = new EntityFallingSand(this.worldClient, var2, var4, var6, par1Packet23VehicleSpawn.throwerEntityId & 65535, par1Packet23VehicleSpawn.throwerEntityId >> 16);
    419                par1Packet23VehicleSpawn.throwerEntityId = 0;
    420            }
    421
    422            if (var8 != null)
    423            {
    424                ((Entity)var8).serverPosX = par1Packet23VehicleSpawn.xPosition;
    425                ((Entity)var8).serverPosY = par1Packet23VehicleSpawn.yPosition;
    426                ((Entity)var8).serverPosZ = par1Packet23VehicleSpawn.zPosition;
    427                ((Entity)var8).rotationPitch = (float)(par1Packet23VehicleSpawn.field_92025_h * 360) / 256.0F;
    428                ((Entity)var8).rotationYaw = (float)(par1Packet23VehicleSpawn.field_92026_i * 360) / 256.0F;
    429                Entity[] var12 = ((Entity)var8).getParts();
    430
    431                if (var12 != null)
    432                {
    433                    int var10 = par1Packet23VehicleSpawn.entityId - ((Entity)var8).entityId;
    434
    435                    for (int var11 = 0; var11 < var12.length; ++var11)
    436                    {
    437                        var12[var11].entityId += var10;
    438                    }
    439                }
    440
    441                ((Entity)var8).entityId = par1Packet23VehicleSpawn.entityId;
    442                this.worldClient.addEntityToWorld(par1Packet23VehicleSpawn.entityId, (Entity)var8);
    443
    444                if (par1Packet23VehicleSpawn.throwerEntityId > 0)
    445                {
    446                    if (par1Packet23VehicleSpawn.type == 60)
    447                    {
    448                        Entity var13 = this.getEntityByID(par1Packet23VehicleSpawn.throwerEntityId);
    449
    450                        if (var13 instanceof EntityLiving)
    451                        {
    452                            EntityArrow var14 = (EntityArrow)var8;
    453                            var14.shootingEntity = var13;
    454                        }
    455                    }
    456
    457                    ((Entity)var8).setVelocity((double)par1Packet23VehicleSpawn.speedX / 8000.0D, (double)par1Packet23VehicleSpawn.speedY / 8000.0D, (double)par1Packet23VehicleSpawn.speedZ / 8000.0D);
    458                }
    459            }
    460        }
    461
    462        /**
    463         * Handle a entity experience orb packet.
    464         */
    465        public void handleEntityExpOrb(Packet26EntityExpOrb par1Packet26EntityExpOrb)
    466        {
    467            EntityXPOrb var2 = new EntityXPOrb(this.worldClient, (double)par1Packet26EntityExpOrb.posX, (double)par1Packet26EntityExpOrb.posY, (double)par1Packet26EntityExpOrb.posZ, par1Packet26EntityExpOrb.xpValue);
    468            var2.serverPosX = par1Packet26EntityExpOrb.posX;
    469            var2.serverPosY = par1Packet26EntityExpOrb.posY;
    470            var2.serverPosZ = par1Packet26EntityExpOrb.posZ;
    471            var2.rotationYaw = 0.0F;
    472            var2.rotationPitch = 0.0F;
    473            var2.entityId = par1Packet26EntityExpOrb.entityId;
    474            this.worldClient.addEntityToWorld(par1Packet26EntityExpOrb.entityId, var2);
    475        }
    476
    477        /**
    478         * Handles weather packet
    479         */
    480        public void handleWeather(Packet71Weather par1Packet71Weather)
    481        {
    482            double var2 = (double)par1Packet71Weather.posX / 32.0D;
    483            double var4 = (double)par1Packet71Weather.posY / 32.0D;
    484            double var6 = (double)par1Packet71Weather.posZ / 32.0D;
    485            EntityLightningBolt var8 = null;
    486
    487            if (par1Packet71Weather.isLightningBolt == 1)
    488            {
    489                var8 = new EntityLightningBolt(this.worldClient, var2, var4, var6);
    490            }
    491
    492            if (var8 != null)
    493            {
    494                var8.serverPosX = par1Packet71Weather.posX;
    495                var8.serverPosY = par1Packet71Weather.posY;
    496                var8.serverPosZ = par1Packet71Weather.posZ;
    497                var8.rotationYaw = 0.0F;
    498                var8.rotationPitch = 0.0F;
    499                var8.entityId = par1Packet71Weather.entityID;
    500                this.worldClient.addWeatherEffect(var8);
    501            }
    502        }
    503
    504        /**
    505         * Packet handler
    506         */
    507        public void handleEntityPainting(Packet25EntityPainting par1Packet25EntityPainting)
    508        {
    509            EntityPainting var2 = new EntityPainting(this.worldClient, par1Packet25EntityPainting.xPosition, par1Packet25EntityPainting.yPosition, par1Packet25EntityPainting.zPosition, par1Packet25EntityPainting.direction, par1Packet25EntityPainting.title);
    510            this.worldClient.addEntityToWorld(par1Packet25EntityPainting.entityId, var2);
    511        }
    512
    513        /**
    514         * Packet handler
    515         */
    516        public void handleEntityVelocity(Packet28EntityVelocity par1Packet28EntityVelocity)
    517        {
    518            Entity var2 = this.getEntityByID(par1Packet28EntityVelocity.entityId);
    519
    520            if (var2 != null)
    521            {
    522                var2.setVelocity((double)par1Packet28EntityVelocity.motionX / 8000.0D, (double)par1Packet28EntityVelocity.motionY / 8000.0D, (double)par1Packet28EntityVelocity.motionZ / 8000.0D);
    523            }
    524        }
    525
    526        /**
    527         * Packet handler
    528         */
    529        public void handleEntityMetadata(Packet40EntityMetadata par1Packet40EntityMetadata)
    530        {
    531            Entity var2 = this.getEntityByID(par1Packet40EntityMetadata.entityId);
    532
    533            if (var2 != null && par1Packet40EntityMetadata.getMetadata() != null)
    534            {
    535                var2.getDataWatcher().updateWatchedObjectsFromList(par1Packet40EntityMetadata.getMetadata());
    536            }
    537        }
    538
    539        public void handleNamedEntitySpawn(Packet20NamedEntitySpawn par1Packet20NamedEntitySpawn)
    540        {
    541            double var2 = (double)par1Packet20NamedEntitySpawn.xPosition / 32.0D;
    542            double var4 = (double)par1Packet20NamedEntitySpawn.yPosition / 32.0D;
    543            double var6 = (double)par1Packet20NamedEntitySpawn.zPosition / 32.0D;
    544            float var8 = (float)(par1Packet20NamedEntitySpawn.rotation * 360) / 256.0F;
    545            float var9 = (float)(par1Packet20NamedEntitySpawn.pitch * 360) / 256.0F;
    546            EntityOtherPlayerMP var10 = new EntityOtherPlayerMP(this.mc.theWorld, par1Packet20NamedEntitySpawn.name);
    547            var10.prevPosX = var10.lastTickPosX = (double)(var10.serverPosX = par1Packet20NamedEntitySpawn.xPosition);
    548            var10.prevPosY = var10.lastTickPosY = (double)(var10.serverPosY = par1Packet20NamedEntitySpawn.yPosition);
    549            var10.prevPosZ = var10.lastTickPosZ = (double)(var10.serverPosZ = par1Packet20NamedEntitySpawn.zPosition);
    550            int var11 = par1Packet20NamedEntitySpawn.currentItem;
    551
    552            if (var11 == 0)
    553            {
    554                var10.inventory.mainInventory[var10.inventory.currentItem] = null;
    555            }
    556            else
    557            {
    558                var10.inventory.mainInventory[var10.inventory.currentItem] = new ItemStack(var11, 1, 0);
    559            }
    560
    561            var10.setPositionAndRotation(var2, var4, var6, var8, var9);
    562            this.worldClient.addEntityToWorld(par1Packet20NamedEntitySpawn.entityId, var10);
    563            List var12 = par1Packet20NamedEntitySpawn.func_73509_c();
    564
    565            if (var12 != null)
    566            {
    567                var10.getDataWatcher().updateWatchedObjectsFromList(var12);
    568            }
    569        }
    570
    571        public void handleEntityTeleport(Packet34EntityTeleport par1Packet34EntityTeleport)
    572        {
    573            Entity var2 = this.getEntityByID(par1Packet34EntityTeleport.entityId);
    574
    575            if (var2 != null)
    576            {
    577                var2.serverPosX = par1Packet34EntityTeleport.xPosition;
    578                var2.serverPosY = par1Packet34EntityTeleport.yPosition;
    579                var2.serverPosZ = par1Packet34EntityTeleport.zPosition;
    580                double var3 = (double)var2.serverPosX / 32.0D;
    581                double var5 = (double)var2.serverPosY / 32.0D + 0.015625D;
    582                double var7 = (double)var2.serverPosZ / 32.0D;
    583                float var9 = (float)(par1Packet34EntityTeleport.yaw * 360) / 256.0F;
    584                float var10 = (float)(par1Packet34EntityTeleport.pitch * 360) / 256.0F;
    585                var2.setPositionAndRotation2(var3, var5, var7, var9, var10, 3);
    586            }
    587        }
    588
    589        public void handleBlockItemSwitch(Packet16BlockItemSwitch par1Packet16BlockItemSwitch)
    590        {
    591            if (par1Packet16BlockItemSwitch.id >= 0 && par1Packet16BlockItemSwitch.id < InventoryPlayer.func_70451_h())
    592            {
    593                this.mc.thePlayer.inventory.currentItem = par1Packet16BlockItemSwitch.id;
    594            }
    595        }
    596
    597        public void handleEntity(Packet30Entity par1Packet30Entity)
    598        {
    599            Entity var2 = this.getEntityByID(par1Packet30Entity.entityId);
    600
    601            if (var2 != null)
    602            {
    603                var2.serverPosX += par1Packet30Entity.xPosition;
    604                var2.serverPosY += par1Packet30Entity.yPosition;
    605                var2.serverPosZ += par1Packet30Entity.zPosition;
    606                double var3 = (double)var2.serverPosX / 32.0D;
    607                double var5 = (double)var2.serverPosY / 32.0D;
    608                double var7 = (double)var2.serverPosZ / 32.0D;
    609                float var9 = par1Packet30Entity.rotating ? (float)(par1Packet30Entity.yaw * 360) / 256.0F : var2.rotationYaw;
    610                float var10 = par1Packet30Entity.rotating ? (float)(par1Packet30Entity.pitch * 360) / 256.0F : var2.rotationPitch;
    611                var2.setPositionAndRotation2(var3, var5, var7, var9, var10, 3);
    612            }
    613        }
    614
    615        public void handleEntityHeadRotation(Packet35EntityHeadRotation par1Packet35EntityHeadRotation)
    616        {
    617            Entity var2 = this.getEntityByID(par1Packet35EntityHeadRotation.entityId);
    618
    619            if (var2 != null)
    620            {
    621                float var3 = (float)(par1Packet35EntityHeadRotation.headRotationYaw * 360) / 256.0F;
    622                var2.setHeadRotationYaw(var3);
    623            }
    624        }
    625
    626        public void handleDestroyEntity(Packet29DestroyEntity par1Packet29DestroyEntity)
    627        {
    628            for (int var2 = 0; var2 < par1Packet29DestroyEntity.entityId.length; ++var2)
    629            {
    630                this.worldClient.removeEntityFromWorld(par1Packet29DestroyEntity.entityId[var2]);
    631            }
    632        }
    633
    634        public void handleFlying(Packet10Flying par1Packet10Flying)
    635        {
    636            EntityClientPlayerMP var2 = this.mc.thePlayer;
    637            double var3 = var2.posX;
    638            double var5 = var2.posY;
    639            double var7 = var2.posZ;
    640            float var9 = var2.rotationYaw;
    641            float var10 = var2.rotationPitch;
    642
    643            if (par1Packet10Flying.moving)
    644            {
    645                var3 = par1Packet10Flying.xPosition;
    646                var5 = par1Packet10Flying.yPosition;
    647                var7 = par1Packet10Flying.zPosition;
    648            }
    649
    650            if (par1Packet10Flying.rotating)
    651            {
    652                var9 = par1Packet10Flying.yaw;
    653                var10 = par1Packet10Flying.pitch;
    654            }
    655
    656            var2.ySize = 0.0F;
    657            var2.motionX = var2.motionY = var2.motionZ = 0.0D;
    658            var2.setPositionAndRotation(var3, var5, var7, var9, var10);
    659            par1Packet10Flying.xPosition = var2.posX;
    660            par1Packet10Flying.yPosition = var2.boundingBox.minY;
    661            par1Packet10Flying.zPosition = var2.posZ;
    662            par1Packet10Flying.stance = var2.posY;
    663            this.netManager.addToSendQueue(par1Packet10Flying);
    664
    665            if (!this.doneLoadingTerrain)
    666            {
    667                this.mc.thePlayer.prevPosX = this.mc.thePlayer.posX;
    668                this.mc.thePlayer.prevPosY = this.mc.thePlayer.posY;
    669                this.mc.thePlayer.prevPosZ = this.mc.thePlayer.posZ;
    670                this.doneLoadingTerrain = true;
    671                this.mc.displayGuiScreen((GuiScreen)null);
    672            }
    673        }
    674
    675        public void handleMultiBlockChange(Packet52MultiBlockChange par1Packet52MultiBlockChange)
    676        {
    677            int var2 = par1Packet52MultiBlockChange.xPosition * 16;
    678            int var3 = par1Packet52MultiBlockChange.zPosition * 16;
    679
    680            if (par1Packet52MultiBlockChange.metadataArray != null)
    681            {
    682                DataInputStream var4 = new DataInputStream(new ByteArrayInputStream(par1Packet52MultiBlockChange.metadataArray));
    683
    684                try
    685                {
    686                    for (int var5 = 0; var5 < par1Packet52MultiBlockChange.size; ++var5)
    687                    {
    688                        short var6 = var4.readShort();
    689                        short var7 = var4.readShort();
    690                        int var8 = var7 >> 4 & 4095;
    691                        int var9 = var7 & 15;
    692                        int var10 = var6 >> 12 & 15;
    693                        int var11 = var6 >> 8 & 15;
    694                        int var12 = var6 & 255;
    695                        this.worldClient.setBlockAndMetadataAndInvalidate(var10 + var2, var12, var11 + var3, var8, var9);
    696                    }
    697                }
    698                catch (IOException var13)
    699                {
    700                    ;
    701                }
    702            }
    703        }
    704
    705        /**
    706         * Handle Packet51MapChunk (full chunk update of blocks, metadata, light levels, and optionally biome data)
    707         */
    708        public void handleMapChunk(Packet51MapChunk par1Packet51MapChunk)
    709        {
    710            if (par1Packet51MapChunk.includeInitialize)
    711            {
    712                if (par1Packet51MapChunk.yChMin == 0)
    713                {
    714                    this.worldClient.doPreChunk(par1Packet51MapChunk.xCh, par1Packet51MapChunk.zCh, false);
    715                    return;
    716                }
    717
    718                this.worldClient.doPreChunk(par1Packet51MapChunk.xCh, par1Packet51MapChunk.zCh, true);
    719            }
    720
    721            this.worldClient.invalidateBlockReceiveRegion(par1Packet51MapChunk.xCh << 4, 0, par1Packet51MapChunk.zCh << 4, (par1Packet51MapChunk.xCh << 4) + 15, 256, (par1Packet51MapChunk.zCh << 4) + 15);
    722            Chunk var2 = this.worldClient.getChunkFromChunkCoords(par1Packet51MapChunk.xCh, par1Packet51MapChunk.zCh);
    723
    724            if (par1Packet51MapChunk.includeInitialize && var2 == null)
    725            {
    726                this.worldClient.doPreChunk(par1Packet51MapChunk.xCh, par1Packet51MapChunk.zCh, true);
    727                var2 = this.worldClient.getChunkFromChunkCoords(par1Packet51MapChunk.xCh, par1Packet51MapChunk.zCh);
    728            }
    729
    730            if (var2 != null)
    731            {
    732                var2.fillChunk(par1Packet51MapChunk.func_73593_d(), par1Packet51MapChunk.yChMin, par1Packet51MapChunk.yChMax, par1Packet51MapChunk.includeInitialize);
    733                this.worldClient.markBlockRangeForRenderUpdate(par1Packet51MapChunk.xCh << 4, 0, par1Packet51MapChunk.zCh << 4, (par1Packet51MapChunk.xCh << 4) + 15, 256, (par1Packet51MapChunk.zCh << 4) + 15);
    734
    735                if (!par1Packet51MapChunk.includeInitialize || !(this.worldClient.provider instanceof WorldProviderSurface))
    736                {
    737                    var2.resetRelightChecks();
    738                }
    739            }
    740        }
    741
    742        public void handleBlockChange(Packet53BlockChange par1Packet53BlockChange)
    743        {
    744            this.worldClient.setBlockAndMetadataAndInvalidate(par1Packet53BlockChange.xPosition, par1Packet53BlockChange.yPosition, par1Packet53BlockChange.zPosition, par1Packet53BlockChange.type, par1Packet53BlockChange.metadata);
    745        }
    746
    747        public void handleKickDisconnect(Packet255KickDisconnect par1Packet255KickDisconnect)
    748        {
    749            this.netManager.networkShutdown("disconnect.kicked", par1Packet255KickDisconnect.reason);
    750            this.disconnected = true;
    751            this.mc.loadWorld((WorldClient)null);
    752            this.mc.displayGuiScreen(new GuiDisconnected("disconnect.disconnected", "disconnect.genericReason", new Object[] {par1Packet255KickDisconnect.reason}));
    753        }
    754
    755        public void handleErrorMessage(String par1Str, Object[] par2ArrayOfObj)
    756        {
    757            if (!this.disconnected)
    758            {
    759                this.disconnected = true;
    760                this.mc.loadWorld((WorldClient)null);
    761                this.mc.displayGuiScreen(new GuiDisconnected("disconnect.lost", par1Str, par2ArrayOfObj));
    762            }
    763        }
    764
    765        public void quitWithPacket(Packet par1Packet)
    766        {
    767            if (!this.disconnected)
    768            {
    769                this.netManager.addToSendQueue(par1Packet);
    770                this.netManager.serverShutdown();
    771                FMLNetworkHandler.onConnectionClosed(this.netManager, this.getPlayer());
    772            }
    773        }
    774
    775        /**
    776         * Adds the packet to the send queue
    777         */
    778        public void addToSendQueue(Packet par1Packet)
    779        {
    780            if (!this.disconnected)
    781            {
    782                this.netManager.addToSendQueue(par1Packet);
    783            }
    784        }
    785
    786        public void handleCollect(Packet22Collect par1Packet22Collect)
    787        {
    788            Entity var2 = this.getEntityByID(par1Packet22Collect.collectedEntityId);
    789            Object var3 = (EntityLiving)this.getEntityByID(par1Packet22Collect.collectorEntityId);
    790
    791            if (var3 == null)
    792            {
    793                var3 = this.mc.thePlayer;
    794            }
    795
    796            if (var2 != null)
    797            {
    798                if (var2 instanceof EntityXPOrb)
    799                {
    800                    this.worldClient.playSoundAtEntity(var2, "random.orb", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
    801                }
    802                else
    803                {
    804                    this.worldClient.playSoundAtEntity(var2, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
    805                }
    806
    807                this.mc.effectRenderer.addEffect(new EntityPickupFX(this.mc.theWorld, var2, (Entity)var3, -0.5F));
    808                this.worldClient.removeEntityFromWorld(par1Packet22Collect.collectedEntityId);
    809            }
    810        }
    811
    812        public void handleChat(Packet3Chat par1Packet3Chat)
    813        {
    814            par1Packet3Chat = FMLNetworkHandler.handleChatMessage(this, par1Packet3Chat);
    815            ClientChatReceivedEvent event = new ClientChatReceivedEvent(par1Packet3Chat.message);
    816            if (!MinecraftForge.EVENT_BUS.post(event) && event.message != null)
    817            {
    818                this.mc.ingameGUI.getChatGUI().printChatMessage(par1Packet3Chat.message);
    819            }
    820        }
    821
    822        public void handleAnimation(Packet18Animation par1Packet18Animation)
    823        {
    824            Entity var2 = this.getEntityByID(par1Packet18Animation.entityId);
    825
    826            if (var2 != null)
    827            {
    828                if (par1Packet18Animation.animate == 1)
    829                {
    830                    EntityLiving var3 = (EntityLiving)var2;
    831                    var3.swingItem();
    832                }
    833                else if (par1Packet18Animation.animate == 2)
    834                {
    835                    var2.performHurtAnimation();
    836                }
    837                else if (par1Packet18Animation.animate == 3)
    838                {
    839                    EntityPlayer var4 = (EntityPlayer)var2;
    840                    var4.wakeUpPlayer(false, false, false);
    841                }
    842                else if (par1Packet18Animation.animate != 4)
    843                {
    844                    if (par1Packet18Animation.animate == 6)
    845                    {
    846                        this.mc.effectRenderer.addEffect(new EntityCrit2FX(this.mc.theWorld, var2));
    847                    }
    848                    else if (par1Packet18Animation.animate == 7)
    849                    {
    850                        EntityCrit2FX var5 = new EntityCrit2FX(this.mc.theWorld, var2, "magicCrit");
    851                        this.mc.effectRenderer.addEffect(var5);
    852                    }
    853                    else if (par1Packet18Animation.animate == 5 && var2 instanceof EntityOtherPlayerMP)
    854                    {
    855                        ;
    856                    }
    857                }
    858            }
    859        }
    860
    861        public void handleSleep(Packet17Sleep par1Packet17Sleep)
    862        {
    863            Entity var2 = this.getEntityByID(par1Packet17Sleep.entityID);
    864
    865            if (var2 != null)
    866            {
    867                if (par1Packet17Sleep.field_73622_e == 0)
    868                {
    869                    EntityPlayer var3 = (EntityPlayer)var2;
    870                    var3.sleepInBedAt(par1Packet17Sleep.bedX, par1Packet17Sleep.bedY, par1Packet17Sleep.bedZ);
    871                }
    872            }
    873        }
    874
    875        /**
    876         * Disconnects the network connection.
    877         */
    878        public void disconnect()
    879        {
    880            this.disconnected = true;
    881            this.netManager.wakeThreads();
    882            this.netManager.networkShutdown("disconnect.closed", new Object[0]);
    883        }
    884
    885        public void handleMobSpawn(Packet24MobSpawn par1Packet24MobSpawn)
    886        {
    887            double var2 = (double)par1Packet24MobSpawn.xPosition / 32.0D;
    888            double var4 = (double)par1Packet24MobSpawn.yPosition / 32.0D;
    889            double var6 = (double)par1Packet24MobSpawn.zPosition / 32.0D;
    890            float var8 = (float)(par1Packet24MobSpawn.yaw * 360) / 256.0F;
    891            float var9 = (float)(par1Packet24MobSpawn.pitch * 360) / 256.0F;
    892            EntityLiving var10 = (EntityLiving)EntityList.createEntityByID(par1Packet24MobSpawn.type, this.mc.theWorld);
    893            var10.serverPosX = par1Packet24MobSpawn.xPosition;
    894            var10.serverPosY = par1Packet24MobSpawn.yPosition;
    895            var10.serverPosZ = par1Packet24MobSpawn.zPosition;
    896            var10.rotationYawHead = (float)(par1Packet24MobSpawn.headYaw * 360) / 256.0F;
    897            Entity[] var11 = var10.getParts();
    898
    899            if (var11 != null)
    900            {
    901                int var12 = par1Packet24MobSpawn.entityId - var10.entityId;
    902
    903                for (int var13 = 0; var13 < var11.length; ++var13)
    904                {
    905                    var11[var13].entityId += var12;
    906                }
    907            }
    908
    909            var10.entityId = par1Packet24MobSpawn.entityId;
    910            var10.setPositionAndRotation(var2, var4, var6, var8, var9);
    911            var10.motionX = (double)((float)par1Packet24MobSpawn.velocityX / 8000.0F);
    912            var10.motionY = (double)((float)par1Packet24MobSpawn.velocityY / 8000.0F);
    913            var10.motionZ = (double)((float)par1Packet24MobSpawn.velocityZ / 8000.0F);
    914            this.worldClient.addEntityToWorld(par1Packet24MobSpawn.entityId, var10);
    915            List var14 = par1Packet24MobSpawn.getMetadata();
    916
    917            if (var14 != null)
    918            {
    919                var10.getDataWatcher().updateWatchedObjectsFromList(var14);
    920            }
    921        }
    922
    923        public void handleUpdateTime(Packet4UpdateTime par1Packet4UpdateTime)
    924        {
    925            this.mc.theWorld.func_82738_a(par1Packet4UpdateTime.field_82562_a);
    926            this.mc.theWorld.setWorldTime(par1Packet4UpdateTime.time);
    927        }
    928
    929        public void handleSpawnPosition(Packet6SpawnPosition par1Packet6SpawnPosition)
    930        {
    931            this.mc.thePlayer.setSpawnChunk(new ChunkCoordinates(par1Packet6SpawnPosition.xPosition, par1Packet6SpawnPosition.yPosition, par1Packet6SpawnPosition.zPosition), true);
    932            this.mc.theWorld.getWorldInfo().setSpawnPosition(par1Packet6SpawnPosition.xPosition, par1Packet6SpawnPosition.yPosition, par1Packet6SpawnPosition.zPosition);
    933        }
    934
    935        /**
    936         * Packet handler
    937         */
    938        public void handleAttachEntity(Packet39AttachEntity par1Packet39AttachEntity)
    939        {
    940            Object var2 = this.getEntityByID(par1Packet39AttachEntity.entityId);
    941            Entity var3 = this.getEntityByID(par1Packet39AttachEntity.vehicleEntityId);
    942
    943            if (par1Packet39AttachEntity.entityId == this.mc.thePlayer.entityId)
    944            {
    945                var2 = this.mc.thePlayer;
    946
    947                if (var3 instanceof EntityBoat)
    948                {
    949                    ((EntityBoat)var3).func_70270_d(false);
    950                }
    951            }
    952            else if (var3 instanceof EntityBoat)
    953            {
    954                ((EntityBoat)var3).func_70270_d(true);
    955            }
    956
    957            if (var2 != null)
    958            {
    959                ((Entity)var2).mountEntity(var3);
    960            }
    961        }
    962
    963        /**
    964         * Packet handler
    965         */
    966        public void handleEntityStatus(Packet38EntityStatus par1Packet38EntityStatus)
    967        {
    968            Entity var2 = this.getEntityByID(par1Packet38EntityStatus.entityId);
    969
    970            if (var2 != null)
    971            {
    972                var2.handleHealthUpdate(par1Packet38EntityStatus.entityStatus);
    973            }
    974        }
    975
    976        private Entity getEntityByID(int par1)
    977        {
    978            return (Entity)(par1 == this.mc.thePlayer.entityId ? this.mc.thePlayer : this.worldClient.getEntityByID(par1));
    979        }
    980
    981        /**
    982         * Recieves player health from the server and then proceeds to set it locally on the client.
    983         */
    984        public void handleUpdateHealth(Packet8UpdateHealth par1Packet8UpdateHealth)
    985        {
    986            this.mc.thePlayer.setHealth(par1Packet8UpdateHealth.healthMP);
    987            this.mc.thePlayer.getFoodStats().setFoodLevel(par1Packet8UpdateHealth.food);
    988            this.mc.thePlayer.getFoodStats().setFoodSaturationLevel(par1Packet8UpdateHealth.foodSaturation);
    989        }
    990
    991        /**
    992         * Handle an experience packet.
    993         */
    994        public void handleExperience(Packet43Experience par1Packet43Experience)
    995        {
    996            this.mc.thePlayer.setXPStats(par1Packet43Experience.experience, par1Packet43Experience.experienceTotal, par1Packet43Experience.experienceLevel);
    997        }
    998
    999        /**
    1000         * respawns the player
    1001         */
    1002        public void handleRespawn(Packet9Respawn par1Packet9Respawn)
    1003        {
    1004            if (par1Packet9Respawn.respawnDimension != this.mc.thePlayer.dimension)
    1005            {
    1006                this.doneLoadingTerrain = false;
    1007                this.worldClient = new WorldClient(this, new WorldSettings(0L, par1Packet9Respawn.gameType, false, this.mc.theWorld.getWorldInfo().isHardcoreModeEnabled(), par1Packet9Respawn.terrainType), par1Packet9Respawn.respawnDimension, par1Packet9Respawn.difficulty, this.mc.mcProfiler);
    1008                this.worldClient.isRemote = true;
    1009                this.mc.loadWorld(this.worldClient);
    1010                this.mc.thePlayer.dimension = par1Packet9Respawn.respawnDimension;
    1011                this.mc.displayGuiScreen(new GuiDownloadTerrain(this));
    1012            }
    1013
    1014            this.mc.setDimensionAndSpawnPlayer(par1Packet9Respawn.respawnDimension);
    1015            this.mc.playerController.setGameType(par1Packet9Respawn.gameType);
    1016        }
    1017
    1018        public void handleExplosion(Packet60Explosion par1Packet60Explosion)
    1019        {
    1020            Explosion var2 = new Explosion(this.mc.theWorld, (Entity)null, par1Packet60Explosion.explosionX, par1Packet60Explosion.explosionY, par1Packet60Explosion.explosionZ, par1Packet60Explosion.explosionSize);
    1021            var2.affectedBlockPositions = par1Packet60Explosion.chunkPositionRecords;
    1022            var2.doExplosionB(true);
    1023            this.mc.thePlayer.motionX += (double)par1Packet60Explosion.func_73607_d();
    1024            this.mc.thePlayer.motionY += (double)par1Packet60Explosion.func_73609_f();
    1025            this.mc.thePlayer.motionZ += (double)par1Packet60Explosion.func_73608_g();
    1026        }
    1027
    1028        public void handleOpenWindow(Packet100OpenWindow par1Packet100OpenWindow)
    1029        {
    1030            EntityClientPlayerMP var2 = this.mc.thePlayer;
    1031
    1032            switch (par1Packet100OpenWindow.inventoryType)
    1033            {
    1034                case 0:
    1035                    var2.displayGUIChest(new InventoryBasic(par1Packet100OpenWindow.windowTitle, par1Packet100OpenWindow.slotsCount));
    1036                    var2.openContainer.windowId = par1Packet100OpenWindow.windowId;
    1037                    break;
    1038                case 1:
    1039                    var2.displayGUIWorkbench(MathHelper.floor_double(var2.posX), MathHelper.floor_double(var2.posY), MathHelper.floor_double(var2.posZ));
    1040                    var2.openContainer.windowId = par1Packet100OpenWindow.windowId;
    1041                    break;
    1042                case 2:
    1043                    var2.displayGUIFurnace(new TileEntityFurnace());
    1044                    var2.openContainer.windowId = par1Packet100OpenWindow.windowId;
    1045                    break;
    1046                case 3:
    1047                    var2.displayGUIDispenser(new TileEntityDispenser());
    1048                    var2.openContainer.windowId = par1Packet100OpenWindow.windowId;
    1049                    break;
    1050                case 4:
    1051                    var2.displayGUIEnchantment(MathHelper.floor_double(var2.posX), MathHelper.floor_double(var2.posY), MathHelper.floor_double(var2.posZ));
    1052                    var2.openContainer.windowId = par1Packet100OpenWindow.windowId;
    1053                    break;
    1054                case 5:
    1055                    var2.displayGUIBrewingStand(new TileEntityBrewingStand());
    1056                    var2.openContainer.windowId = par1Packet100OpenWindow.windowId;
    1057                    break;
    1058                case 6:
    1059                    var2.displayGUIMerchant(new NpcMerchant(var2));
    1060                    var2.openContainer.windowId = par1Packet100OpenWindow.windowId;
    1061                    break;
    1062                case 7:
    1063                    var2.displayGUIBeacon(new TileEntityBeacon());
    1064                    var2.openContainer.windowId = par1Packet100OpenWindow.windowId;
    1065                    break;
    1066                case 8:
    1067                    var2.displayGUIAnvil(MathHelper.floor_double(var2.posX), MathHelper.floor_double(var2.posY), MathHelper.floor_double(var2.posZ));
    1068                    var2.openContainer.windowId = par1Packet100OpenWindow.windowId;
    1069            }
    1070        }
    1071
    1072        public void handleSetSlot(Packet103SetSlot par1Packet103SetSlot)
    1073        {
    1074            EntityClientPlayerMP var2 = this.mc.thePlayer;
    1075
    1076            if (par1Packet103SetSlot.windowId == -1)
    1077            {
    1078                var2.inventory.setItemStack(par1Packet103SetSlot.myItemStack);
    1079            }
    1080            else
    1081            {
    1082                boolean var3 = false;
    1083
    1084                if (this.mc.currentScreen instanceof GuiContainerCreative)
    1085                {
    1086                    GuiContainerCreative var4 = (GuiContainerCreative)this.mc.currentScreen;
    1087                    var3 = var4.func_74230_h() != CreativeTabs.tabInventory.getTabIndex();
    1088                }
    1089
    1090                if (par1Packet103SetSlot.windowId == 0 && par1Packet103SetSlot.itemSlot >= 36 && par1Packet103SetSlot.itemSlot < 45)
    1091                {
    1092                    ItemStack var5 = var2.inventoryContainer.getSlot(par1Packet103SetSlot.itemSlot).getStack();
    1093
    1094                    if (par1Packet103SetSlot.myItemStack != null && (var5 == null || var5.stackSize < par1Packet103SetSlot.myItemStack.stackSize))
    1095                    {
    1096                        par1Packet103SetSlot.myItemStack.animationsToGo = 5;
    1097                    }
    1098
    1099                    var2.inventoryContainer.putStackInSlot(par1Packet103SetSlot.itemSlot, par1Packet103SetSlot.myItemStack);
    1100                }
    1101                else if (par1Packet103SetSlot.windowId == var2.openContainer.windowId && (par1Packet103SetSlot.windowId != 0 || !var3))
    1102                {
    1103                    var2.openContainer.putStackInSlot(par1Packet103SetSlot.itemSlot, par1Packet103SetSlot.myItemStack);
    1104                }
    1105            }
    1106        }
    1107
    1108        public void handleTransaction(Packet106Transaction par1Packet106Transaction)
    1109        {
    1110            Container var2 = null;
    1111            EntityClientPlayerMP var3 = this.mc.thePlayer;
    1112
    1113            if (par1Packet106Transaction.windowId == 0)
    1114            {
    1115                var2 = var3.inventoryContainer;
    1116            }
    1117            else if (par1Packet106Transaction.windowId == var3.openContainer.windowId)
    1118            {
    1119                var2 = var3.openContainer;
    1120            }
    1121
    1122            if (var2 != null && !par1Packet106Transaction.accepted)
    1123            {
    1124                this.addToSendQueue(new Packet106Transaction(par1Packet106Transaction.windowId, par1Packet106Transaction.shortWindowId, true));
    1125            }
    1126        }
    1127
    1128        public void handleWindowItems(Packet104WindowItems par1Packet104WindowItems)
    1129        {
    1130            EntityClientPlayerMP var2 = this.mc.thePlayer;
    1131
    1132            if (par1Packet104WindowItems.windowId == 0)
    1133            {
    1134                var2.inventoryContainer.putStacksInSlots(par1Packet104WindowItems.itemStack);
    1135            }
    1136            else if (par1Packet104WindowItems.windowId == var2.openContainer.windowId)
    1137            {
    1138                var2.openContainer.putStacksInSlots(par1Packet104WindowItems.itemStack);
    1139            }
    1140        }
    1141
    1142        /**
    1143         * Updates Client side signs
    1144         */
    1145        public void handleUpdateSign(Packet130UpdateSign par1Packet130UpdateSign)
    1146        {
    1147            boolean var2 = false;
    1148
    1149            if (this.mc.theWorld.blockExists(par1Packet130UpdateSign.xPosition, par1Packet130UpdateSign.yPosition, par1Packet130UpdateSign.zPosition))
    1150            {
    1151                TileEntity var3 = this.mc.theWorld.getBlockTileEntity(par1Packet130UpdateSign.xPosition, par1Packet130UpdateSign.yPosition, par1Packet130UpdateSign.zPosition);
    1152
    1153                if (var3 instanceof TileEntitySign)
    1154                {
    1155                    TileEntitySign var4 = (TileEntitySign)var3;
    1156
    1157                    if (var4.isEditable())
    1158                    {
    1159                        for (int var5 = 0; var5 < 4; ++var5)
    1160                        {
    1161                            var4.signText[var5] = par1Packet130UpdateSign.signLines[var5];
    1162                        }
    1163
    1164                        var4.onInventoryChanged();
    1165                    }
    1166
    1167                    var2 = true;
    1168                }
    1169            }
    1170
    1171            if (!var2 && this.mc.thePlayer != null)
    1172            {
    1173                this.mc.thePlayer.sendChatToPlayer("Unable to locate sign at " + par1Packet130UpdateSign.xPosition + ", " + par1Packet130UpdateSign.yPosition + ", " + par1Packet130UpdateSign.zPosition);
    1174            }
    1175        }
    1176
    1177        public void handleTileEntityData(Packet132TileEntityData par1Packet132TileEntityData)
    1178        {
    1179            if (this.mc.theWorld.blockExists(par1Packet132TileEntityData.xPosition, par1Packet132TileEntityData.yPosition, par1Packet132TileEntityData.zPosition))
    1180            {
    1181                TileEntity var2 = this.mc.theWorld.getBlockTileEntity(par1Packet132TileEntityData.xPosition, par1Packet132TileEntityData.yPosition, par1Packet132TileEntityData.zPosition);
    1182
    1183                if (var2 != null)
    1184                {
    1185                    if (par1Packet132TileEntityData.actionType == 1 && var2 instanceof TileEntityMobSpawner)
    1186                    {
    1187                        var2.readFromNBT(par1Packet132TileEntityData.customParam1);
    1188                    }
    1189                    else if (par1Packet132TileEntityData.actionType == 2 && var2 instanceof TileEntityCommandBlock)
    1190                    {
    1191                        var2.readFromNBT(par1Packet132TileEntityData.customParam1);
    1192                    }
    1193                    else if (par1Packet132TileEntityData.actionType == 3 && var2 instanceof TileEntityBeacon)
    1194                    {
    1195                        var2.readFromNBT(par1Packet132TileEntityData.customParam1);
    1196                    }
    1197                    else if (par1Packet132TileEntityData.actionType == 4 && var2 instanceof TileEntitySkull)
    1198                    {
    1199                        var2.readFromNBT(par1Packet132TileEntityData.customParam1);
    1200                    }
    1201                    else
    1202                    {
    1203                        var2.onDataPacket(netManager,  par1Packet132TileEntityData);
    1204                    }
    1205                }
    1206            }
    1207        }
    1208
    1209        public void handleUpdateProgressbar(Packet105UpdateProgressbar par1Packet105UpdateProgressbar)
    1210        {
    1211            EntityClientPlayerMP var2 = this.mc.thePlayer;
    1212            this.unexpectedPacket(par1Packet105UpdateProgressbar);
    1213
    1214            if (var2.openContainer != null && var2.openContainer.windowId == par1Packet105UpdateProgressbar.windowId)
    1215            {
    1216                var2.openContainer.updateProgressBar(par1Packet105UpdateProgressbar.progressBar, par1Packet105UpdateProgressbar.progressBarValue);
    1217            }
    1218        }
    1219
    1220        public void handlePlayerInventory(Packet5PlayerInventory par1Packet5PlayerInventory)
    1221        {
    1222            Entity var2 = this.getEntityByID(par1Packet5PlayerInventory.entityID);
    1223
    1224            if (var2 != null)
    1225            {
    1226                var2.setCurrentItemOrArmor(par1Packet5PlayerInventory.slot, par1Packet5PlayerInventory.getItemSlot());
    1227            }
    1228        }
    1229
    1230        public void handleCloseWindow(Packet101CloseWindow par1Packet101CloseWindow)
    1231        {
    1232            this.mc.thePlayer.func_92015_f();
    1233        }
    1234
    1235        public void handleBlockEvent(Packet54PlayNoteBlock par1Packet54PlayNoteBlock)
    1236        {
    1237            this.mc.theWorld.addBlockEvent(par1Packet54PlayNoteBlock.xLocation, par1Packet54PlayNoteBlock.yLocation, par1Packet54PlayNoteBlock.zLocation, par1Packet54PlayNoteBlock.blockId, par1Packet54PlayNoteBlock.instrumentType, par1Packet54PlayNoteBlock.pitch);
    1238        }
    1239
    1240        public void handleBlockDestroy(Packet55BlockDestroy par1Packet55BlockDestroy)
    1241        {
    1242            this.mc.theWorld.destroyBlockInWorldPartially(par1Packet55BlockDestroy.getEntityId(), par1Packet55BlockDestroy.getPosX(), par1Packet55BlockDestroy.getPosY(), par1Packet55BlockDestroy.getPosZ(), par1Packet55BlockDestroy.getDestroyedStage());
    1243        }
    1244
    1245        public void handleMapChunks(Packet56MapChunks par1Packet56MapChunks)
    1246        {
    1247            for (int var2 = 0; var2 < par1Packet56MapChunks.func_73581_d(); ++var2)
    1248            {
    1249                int var3 = par1Packet56MapChunks.func_73582_a(var2);
    1250                int var4 = par1Packet56MapChunks.func_73580_b(var2);
    1251                this.worldClient.doPreChunk(var3, var4, true);
    1252                this.worldClient.invalidateBlockReceiveRegion(var3 << 4, 0, var4 << 4, (var3 << 4) + 15, 256, (var4 << 4) + 15);
    1253                Chunk var5 = this.worldClient.getChunkFromChunkCoords(var3, var4);
    1254
    1255                if (var5 == null)
    1256                {
    1257                    this.worldClient.doPreChunk(var3, var4, true);
    1258                    var5 = this.worldClient.getChunkFromChunkCoords(var3, var4);
    1259                }
    1260
    1261                if (var5 != null)
    1262                {
    1263                    var5.fillChunk(par1Packet56MapChunks.func_73583_c(var2), par1Packet56MapChunks.field_73590_a[var2], par1Packet56MapChunks.field_73588_b[var2], true);
    1264                    this.worldClient.markBlockRangeForRenderUpdate(var3 << 4, 0, var4 << 4, (var3 << 4) + 15, 256, (var4 << 4) + 15);
    1265
    1266                    if (!(this.worldClient.provider instanceof WorldProviderSurface))
    1267                    {
    1268                        var5.resetRelightChecks();
    1269                    }
    1270                }
    1271            }
    1272        }
    1273
    1274        /**
    1275         * packet.processPacket is only called if this returns true
    1276         */
    1277        public boolean canProcessPackets()
    1278        {
    1279            return this.mc != null && this.mc.theWorld != null && this.mc.thePlayer != null && this.worldClient != null;
    1280        }
    1281
    1282        public void handleBed(Packet70GameEvent par1Packet70GameEvent)
    1283        {
    1284            EntityClientPlayerMP var2 = this.mc.thePlayer;
    1285            int var3 = par1Packet70GameEvent.bedState;
    1286            int var4 = par1Packet70GameEvent.gameMode;
    1287
    1288            if (var3 >= 0 && var3 < Packet70GameEvent.bedChat.length && Packet70GameEvent.bedChat[var3] != null)
    1289            {
    1290                var2.addChatMessage(Packet70GameEvent.bedChat[var3]);
    1291            }
    1292
    1293            if (var3 == 1)
    1294            {
    1295                this.worldClient.getWorldInfo().setRaining(true);
    1296                this.worldClient.setRainStrength(0.0F);
    1297            }
    1298            else if (var3 == 2)
    1299            {
    1300                this.worldClient.getWorldInfo().setRaining(false);
    1301                this.worldClient.setRainStrength(1.0F);
    1302            }
    1303            else if (var3 == 3)
    1304            {
    1305                this.mc.playerController.setGameType(EnumGameType.getByID(var4));
    1306            }
    1307            else if (var3 == 4)
    1308            {
    1309                this.mc.displayGuiScreen(new GuiWinGame());
    1310            }
    1311            else if (var3 == 5)
    1312            {
    1313                GameSettings var5 = this.mc.gameSettings;
    1314
    1315                if (var4 == 0)
    1316                {
    1317                    this.mc.displayGuiScreen(new GuiScreenDemo());
    1318                }
    1319                else if (var4 == 101)
    1320                {
    1321                    this.mc.ingameGUI.getChatGUI().addTranslatedMessage("demo.help.movement", new Object[] {Keyboard.getKeyName(var5.keyBindForward.keyCode), Keyboard.getKeyName(var5.keyBindLeft.keyCode), Keyboard.getKeyName(var5.keyBindBack.keyCode), Keyboard.getKeyName(var5.keyBindRight.keyCode)});
    1322                }
    1323                else if (var4 == 102)
    1324                {
    1325                    this.mc.ingameGUI.getChatGUI().addTranslatedMessage("demo.help.jump", new Object[] {Keyboard.getKeyName(var5.keyBindJump.keyCode)});
    1326                }
    1327                else if (var4 == 103)
    1328                {
    1329                    this.mc.ingameGUI.getChatGUI().addTranslatedMessage("demo.help.inventory", new Object[] {Keyboard.getKeyName(var5.keyBindInventory.keyCode)});
    1330                }
    1331            }
    1332            else if (var3 == 6)
    1333            {
    1334                this.worldClient.playSound(var2.posX, var2.posY + (double)var2.getEyeHeight(), var2.posZ, "random.successful_hit", 0.15F, 0.45F, false);
    1335            }
    1336        }
    1337
    1338        /**
    1339         * Contains logic for handling packets containing arbitrary unique item data. Currently this is only for maps.
    1340         */
    1341        public void handleMapData(Packet131MapData par1Packet131MapData)
    1342        {
    1343            FMLNetworkHandler.handlePacket131Packet(this, par1Packet131MapData);
    1344        }
    1345
    1346        public void fmlPacket131Callback(Packet131MapData par1Packet131MapData)
    1347        {
    1348            if (par1Packet131MapData.itemID == Item.map.shiftedIndex)
    1349            {
    1350                ItemMap.getMPMapData(par1Packet131MapData.uniqueID, this.mc.theWorld).updateMPMapData(par1Packet131MapData.itemData);
    1351            }
    1352            else
    1353            {
    1354                System.out.println("Unknown itemid: " + par1Packet131MapData.uniqueID);
    1355            }
    1356        }
    1357
    1358        public void handleDoorChange(Packet61DoorChange par1Packet61DoorChange)
    1359        {
    1360            if (par1Packet61DoorChange.func_82560_d())
    1361            {
    1362                this.mc.theWorld.func_82739_e(par1Packet61DoorChange.sfxID, par1Packet61DoorChange.posX, par1Packet61DoorChange.posY, par1Packet61DoorChange.posZ, par1Packet61DoorChange.auxData);
    1363            }
    1364            else
    1365            {
    1366                this.mc.theWorld.playAuxSFX(par1Packet61DoorChange.sfxID, par1Packet61DoorChange.posX, par1Packet61DoorChange.posY, par1Packet61DoorChange.posZ, par1Packet61DoorChange.auxData);
    1367            }
    1368        }
    1369
    1370        /**
    1371         * Increment player statistics
    1372         */
    1373        public void handleStatistic(Packet200Statistic par1Packet200Statistic)
    1374        {
    1375            this.mc.thePlayer.incrementStat(StatList.getOneShotStat(par1Packet200Statistic.statisticId), par1Packet200Statistic.amount);
    1376        }
    1377
    1378        /**
    1379         * Handle an entity effect packet.
    1380         */
    1381        public void handleEntityEffect(Packet41EntityEffect par1Packet41EntityEffect)
    1382        {
    1383            Entity var2 = this.getEntityByID(par1Packet41EntityEffect.entityId);
    1384
    1385            if (var2 instanceof EntityLiving)
    1386            {
    1387                ((EntityLiving)var2).addPotionEffect(new PotionEffect(par1Packet41EntityEffect.effectId, par1Packet41EntityEffect.duration, par1Packet41EntityEffect.effectAmplifier));
    1388            }
    1389        }
    1390
    1391        /**
    1392         * Handle a remove entity effect packet.
    1393         */
    1394        public void handleRemoveEntityEffect(Packet42RemoveEntityEffect par1Packet42RemoveEntityEffect)
    1395        {
    1396            Entity var2 = this.getEntityByID(par1Packet42RemoveEntityEffect.entityId);
    1397
    1398            if (var2 instanceof EntityLiving)
    1399            {
    1400                ((EntityLiving)var2).removePotionEffectClient(par1Packet42RemoveEntityEffect.effectId);
    1401            }
    1402        }
    1403
    1404        /**
    1405         * determine if it is a server handler
    1406         */
    1407        public boolean isServerHandler()
    1408        {
    1409            return false;
    1410        }
    1411
    1412        /**
    1413         * Handle a player information packet.
    1414         */
    1415        public void handlePlayerInfo(Packet201PlayerInfo par1Packet201PlayerInfo)
    1416        {
    1417            GuiPlayerInfo var2 = (GuiPlayerInfo)this.playerInfoMap.get(par1Packet201PlayerInfo.playerName);
    1418
    1419            if (var2 == null && par1Packet201PlayerInfo.isConnected)
    1420            {
    1421                var2 = new GuiPlayerInfo(par1Packet201PlayerInfo.playerName);
    1422                this.playerInfoMap.put(par1Packet201PlayerInfo.playerName, var2);
    1423                this.playerInfoList.add(var2);
    1424            }
    1425
    1426            if (var2 != null && !par1Packet201PlayerInfo.isConnected)
    1427            {
    1428                this.playerInfoMap.remove(par1Packet201PlayerInfo.playerName);
    1429                this.playerInfoList.remove(var2);
    1430            }
    1431
    1432            if (par1Packet201PlayerInfo.isConnected && var2 != null)
    1433            {
    1434                var2.responseTime = par1Packet201PlayerInfo.ping;
    1435            }
    1436        }
    1437
    1438        /**
    1439         * Handle a keep alive packet.
    1440         */
    1441        public void handleKeepAlive(Packet0KeepAlive par1Packet0KeepAlive)
    1442        {
    1443            this.addToSendQueue(new Packet0KeepAlive(par1Packet0KeepAlive.randomId));
    1444        }
    1445
    1446        /**
    1447         * Handle a player abilities packet.
    1448         */
    1449        public void handlePlayerAbilities(Packet202PlayerAbilities par1Packet202PlayerAbilities)
    1450        {
    1451            EntityClientPlayerMP var2 = this.mc.thePlayer;
    1452            var2.capabilities.isFlying = par1Packet202PlayerAbilities.getFlying();
    1453            var2.capabilities.isCreativeMode = par1Packet202PlayerAbilities.isCreativeMode();
    1454            var2.capabilities.disableDamage = par1Packet202PlayerAbilities.getDisableDamage();
    1455            var2.capabilities.allowFlying = par1Packet202PlayerAbilities.getAllowFlying();
    1456            var2.capabilities.setFlySpeed(par1Packet202PlayerAbilities.getFlySpeed());
    1457            var2.capabilities.func_82877_b(par1Packet202PlayerAbilities.func_82558_j());
    1458        }
    1459
    1460        public void handleAutoComplete(Packet203AutoComplete par1Packet203AutoComplete)
    1461        {
    1462            String[] var2 = par1Packet203AutoComplete.getText().split("\u0000");
    1463
    1464            if (this.mc.currentScreen instanceof GuiChat)
    1465            {
    1466                GuiChat var3 = (GuiChat)this.mc.currentScreen;
    1467                var3.func_73894_a(var2);
    1468            }
    1469        }
    1470
    1471        public void handleLevelSound(Packet62LevelSound par1Packet62LevelSound)
    1472        {
    1473            this.mc.theWorld.playSound(par1Packet62LevelSound.getEffectX(), par1Packet62LevelSound.getEffectY(), par1Packet62LevelSound.getEffectZ(), par1Packet62LevelSound.getSoundName(), par1Packet62LevelSound.getVolume(), par1Packet62LevelSound.getPitch(), false);
    1474        }
    1475
    1476        public void handleCustomPayload(Packet250CustomPayload par1Packet250CustomPayload)
    1477        {
    1478            FMLNetworkHandler.handlePacket250Packet(par1Packet250CustomPayload, netManager, this);
    1479        }
    1480
    1481        public void handleVanilla250Packet(Packet250CustomPayload par1Packet250CustomPayload)
    1482        {
    1483            if ("MC|TPack".equals(par1Packet250CustomPayload.channel))
    1484            {
    1485                String[] var2 = (new String(par1Packet250CustomPayload.data)).split("\u0000");
    1486                String var3 = var2[0];
    1487
    1488                if (var2[1].equals("16"))
    1489                {
    1490                    if (this.mc.texturePackList.getAcceptsTextures())
    1491                    {
    1492                        this.mc.texturePackList.requestDownloadOfTexture(var3);
    1493                    }
    1494                    else if (this.mc.texturePackList.func_77300_f())
    1495                    {
    1496                        this.mc.displayGuiScreen(new GuiYesNo(new NetClientWebTextures(this, var3), StringTranslate.getInstance().translateKey("multiplayer.texturePrompt.line1"), StringTranslate.getInstance().translateKey("multiplayer.texturePrompt.line2"), 0));
    1497                    }
    1498                }
    1499            }
    1500            else if ("MC|TrList".equals(par1Packet250CustomPayload.channel))
    1501            {
    1502                DataInputStream var8 = new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data));
    1503
    1504                try
    1505                {
    1506                    int var9 = var8.readInt();
    1507                    GuiScreen var4 = this.mc.currentScreen;
    1508
    1509                    if (var4 != null && var4 instanceof GuiMerchant && var9 == this.mc.thePlayer.openContainer.windowId)
    1510                    {
    1511                        IMerchant var5 = ((GuiMerchant)var4).getIMerchant();
    1512                        MerchantRecipeList var6 = MerchantRecipeList.readRecipiesFromStream(var8);
    1513                        var5.setRecipes(var6);
    1514                    }
    1515                }
    1516                catch (IOException var7)
    1517                {
    1518                    var7.printStackTrace();
    1519                }
    1520            }
    1521        }
    1522
    1523        /**
    1524         * Return the NetworkManager instance used by this NetClientHandler
    1525         */
    1526        public INetworkManager getNetManager()
    1527        {
    1528            return this.netManager;
    1529        }
    1530
    1531        @Override
    1532        public EntityPlayer getPlayer()
    1533        {
    1534            return mc.thePlayer;
    1535        }
    1536
    1537        public static void setConnectionCompatibilityLevel(byte connectionCompatibilityLevel)
    1538        {
    1539            NetClientHandler.connectionCompatibilityLevel = connectionCompatibilityLevel;
    1540        }
    1541
    1542        public static byte getConnectionCompatibilityLevel()
    1543        {
    1544            return connectionCompatibilityLevel;
    1545        }
    1546    }