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