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