NetHandlerPlayClient

Client play-state net handler: handle dispatch for every S-packet plus C00/C03/C0F/C17/C19 replies upstream.

net/minecraft/client/network/NetHandlerPlayClient.java

Updated 2026-09-12

Deep Analysis

Client-side PLAY handler applying server state to WorldClient. Dispatches S00-S49 to world, GUI, scoreboard and entities via PacketThreadUtil. Replies with C00 keepalive, C03 pos-look ack, C0F confirm and C17 brand.

Key Methods in Depth (8)

handleJoinGame

Creates WorldClient and player controller.

handleJoinGame processes S01 on the client thread via PacketThreadUtil and builds the initial WorldClient. It installs a new PlayerControllerMP, then constructs WorldClient from gameType, hardcore flag, world type, dimension, difficulty and profiler. It copies difficulty into gameSettings, loads the world, sets thePlayer dimension and shows GuiDownloadTerrain. It assigns the server entityId, stores maxPlayers in currentServerMaxPlayers and applies reducedDebug. It sets the controller gameType, pushes client settings to the server and sends C17 MC|Brand with ClientBrandRetriever mod name. No kick occurs here, the reply packets are C17 brand and settings. Failure to receive later S08 keeps the download screen up.

    public void handleJoinGame(S01PacketJoinGame packetIn)
    {
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
        this.gameController.playerController = new PlayerControllerMP(this.gameController, this);
        this.clientWorldController = new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, packetIn.isHardcoreMode(), packetIn.getWorldType()), packetIn.getDimension(), packetIn.getDifficulty(), this.gameController.mcProfiler);
        this.gameController.gameSettings.difficulty = packetIn.getDifficulty();
        this.gameController.loadWorld(this.clientWorldController);
        this.gameController.thePlayer.dimension = packetIn.getDimension();
        this.gameController.displayGuiScreen(new GuiDownloadTerrain(this));
        this.gameController.thePlayer.setEntityId(packetIn.getEntityId());
        this.currentServerMaxPlayers = packetIn.getMaxPlayers();
        this.gameController.thePlayer.setReducedDebug(packetIn.isReducedDebugInfo());
        this.gameController.playerController.setGameType(packetIn.getGameType());
        this.gameController.gameSettings.sendSettingsToServer();
        this.netManager.sendPacket(new C17PacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName())));
    }

checkThreadAndEnqueue hops S01 onto the main client thread before touching the world. The WorldClient constructor carries gameType, hardcore, world type, dimension and difficulty that define physics and rendering. loadWorld plus GuiDownloadTerrain blocks input until terrain and S08 arrive. setEntityId and currentServerMaxPlayers bind the local player to the server id and tab-list cap. The final C17 MC|Brand reply advertises vanilla or modded client to the server.

handlePlayerPosLook

Applies server teleport and acks it.

handlePlayerPosLook applies S08 server teleports and corrections on the client thread. It reads absolute X Y Z yaw pitch, then adds current player pos or rotation when relative flags X Y Z Y_ROT X_ROT are present. For absolute axes it zeroes motionX, motionY or motionZ to stop rubber-band sliding. It then calls setPositionAndRotation and immediately replies with C06 PacketPlayerPosLook using posX, bounding-box minY, posZ, yaw, pitch and false onGround. On first receipt when doneLoadingTerrain is false it snapshots prevPos, sets the flag true and closes the download screen. Later receipts just correct position without GUI change. No kick occurs, the only response is the C03 C06 ack which lets the server clear hasMoved.

        if (packetIn.func_179834_f().contains(S08PacketPlayerPosLook.EnumFlags.X_ROT))
        {
            f1 += entityplayer.rotationPitch;
        }

        if (packetIn.func_179834_f().contains(S08PacketPlayerPosLook.EnumFlags.Y_ROT))
        {
            f += entityplayer.rotationYaw;
        }

        entityplayer.setPositionAndRotation(d0, d1, d2, f, f1);
        this.netManager.sendPacket(new C03PacketPlayer.C06PacketPlayerPosLook(entityplayer.posX, entityplayer.getEntityBoundingBox().minY, entityplayer.posZ, entityplayer.rotationYaw, entityplayer.rotationPitch, false));

        if (!this.doneLoadingTerrain)
        {
            this.gameController.thePlayer.prevPosX = this.gameController.thePlayer.posX;
            this.gameController.thePlayer.prevPosY = this.gameController.thePlayer.posY;
            this.gameController.thePlayer.prevPosZ = this.gameController.thePlayer.posZ;
            this.doneLoadingTerrain = true;
            this.gameController.displayGuiScreen((GuiScreen)null);
        }
    }

The X_ROT and Y_ROT flag checks add current pitch and yaw for relative look teleports. setPositionAndRotation applies the final merged coordinates and angles to the local player. The C06 reply carries bounding-box minY and false onGround so the server can validate the ack. The doneLoadingTerrain false branch fires once to initialize prevPos and dismiss GuiDownloadTerrain. Repeated S08 packets cause server-side teleport-backs that clients must ack to avoid movement freeze.

handleSpawnObject

Spawns vehicles, projectiles and tiles.

handleSpawnObject spawns S0E vehicles, projectiles and blocks in WorldClient. It scales network X Y Z by dividing by 32.0D to get block coordinates. It switches on type where 10 is minecart with subtype, 60 arrow, 61 snowball, 62 egg, 63 large fireball, 64 small fireball, 65 ender pearl, 66 wither skull, 71 item frame, 72 eye, 73 potion, 75 bottle, 76 firework, 77 leash, 78 armor stand, 1 boat, 2 item, 50 TNT, 51 crystal, 70 falling block and 90 fish hook. Fish hook resolves the thrower entity and resets data to zero, frames and leashes floor coords and reset data. After creation it copies serverPos, converts yaw and pitch with times 360 divided by 256, fixes multipart ids, sets entityId and adds to world. If data is positive it sets velocity divided by 8000.0D and links arrows to shooter living base.

    public void handleSpawnObject(S0EPacketSpawnObject packetIn)
    {
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
        double d0 = (double)packetIn.getX() / 32.0D;
        double d1 = (double)packetIn.getY() / 32.0D;
        double d2 = (double)packetIn.getZ() / 32.0D;
        Entity entity = null;

        if (packetIn.getType() == 10)
        {
            entity = EntityMinecart.getMinecart(this.clientWorldController, d0, d1, d2, EntityMinecart.EnumMinecartType.byNetworkID(packetIn.func_149009_m()));
        }
        else if (packetIn.getType() == 90)
        {
            Entity entity1 = this.clientWorldController.getEntityByID(packetIn.func_149009_m());

            if (entity1 instanceof EntityPlayer)
            {
                entity = new EntityFishHook(this.clientWorldController, d0, d1, d2, (EntityPlayer)entity1);
            }

            packetIn.func_149002_g(0);

checkThreadAndEnqueue ensures spawning happens on the render thread. Dividing by 32.0D converts fixed-point network coords to doubles for accurate placement. The type 10 branch builds minecarts with network subtype for chest, furnace and TNT variants. The type 90 branch looks up the thrower player to attach the fish hook and clears extra data. Later code scales yaw and pitch by 360 over 256 and velocity by 8000, which cheats cannot spoof without server correction.

handleChunkData

Loads or unloads a chunk column.

handleChunkData applies S21 chunk column load or unload on the client thread. If the packet is a full-chunk preChunk signal it checks extracted size, where zero means unload via doPreChunk false and return. Non-zero calls doPreChunk true to allocate the column. It then invalidates the 16 by 256 by 16 receive region, fetches the Chunk object and fills it with extracted bytes, size and full flag. It marks the block range for render update so lighting and meshes rebuild. If not a full chunk or the provider is not surface world, it resets relight checks to avoid stale skylight. Unloads free memory while loads populate blocks and biomes. No reply packet is sent.

    public void handleChunkData(S21PacketChunkData packetIn)
    {
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

        if (packetIn.func_149274_i())
        {
            if (packetIn.getExtractedSize() == 0)
            {
                this.clientWorldController.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), false);
                return;
            }

            this.clientWorldController.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), true);
        }

        this.clientWorldController.invalidateBlockReceiveRegion(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 256, (packetIn.getChunkZ() << 4) + 15);
        Chunk chunk = this.clientWorldController.getChunkFromChunkCoords(packetIn.getChunkX(), packetIn.getChunkZ());
        chunk.fillChunk(packetIn.getExtractedDataBytes(), packetIn.getExtractedSize(), packetIn.func_149274_i());
        this.clientWorldController.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 256, (packetIn.getChunkZ() << 4) + 15);

        if (!packetIn.func_149274_i() || !(this.clientWorldController.provider instanceof WorldProviderSurface))
        {
            chunk.resetRelightChecks();
        }
    }

The func_149274_i gate distinguishes full-column init from delta updates. Zero extracted size with full flag means unload, so doPreChunk false drops the column. Non-zero calls doPreChunk true then fillChunk with the compressed byte payload. invalidateBlockReceiveRegion and markBlockRangeForRenderUpdate bracket the fill to refresh lighting and rendering. The surface-world check skips relight reset for nether and end where skylight differs.

handleConfirmTransaction

Acks server inventory transaction.

handleConfirmTransaction processes S32 server inventory verdicts on the client thread. It resolves the target container by windowId, where zero means inventoryContainer and otherwise the openContainer only if ids match. Null containers from stale windows are ignored. If the packet reports accepted false via func_148888_e it replies with C0F confirm accepted true carrying the same windowId and action number. Accepted true packets need no reply because both sides agree. The C0F reply unlocks the server-side canCraft lock set by processClickWindow mismatch. This single round trip resyncs duped or ghost clicks. No kick or teleport occurs.

    public void handleConfirmTransaction(S32PacketConfirmTransaction packetIn)
    {
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
        Container container = null;
        EntityPlayer entityplayer = this.gameController.thePlayer;

        if (packetIn.getWindowId() == 0)
        {
            container = entityplayer.inventoryContainer;
        }
        else if (packetIn.getWindowId() == entityplayer.openContainer.windowId)
        {
            container = entityplayer.openContainer;
        }

        if (container != null && !packetIn.func_148888_e())
        {
            this.addToSendQueue(new C0FPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), true));
        }
    }

checkThreadAndEnqueue moves the verdict to the main thread. The windowId zero versus openContainer match selects inventory versus chest, furnace or crafting table. Null from closed windows is dropped to avoid acting on stale ids. The not-accepted check via func_148888_e triggers a C0F with accepted true to acknowledge the server correction. That C0F carries windowId and action number so the server can clear field_147372_n and re-enable crafting.

handleRespawn

Rebuilds WorldClient on dimension change.

handleRespawn rebuilds WorldClient on S07 dimension change or difficulty sync. It first compares packet dimension to thePlayer dimension to detect cross-dimension moves. On change it clears doneLoadingTerrain, preserves the old scoreboard, constructs a new WorldClient with gameType, hardcore flag, world type, dimension and difficulty, then loads it and shows GuiDownloadTerrain. It always calls setDimensionAndSpawnPlayer and setGameType from the packet even for same-dimension respawns. The scoreboard carry-over keeps teams and objectives across deaths. No reply packet is sent, the client waits for follow-up S08 position and S21 chunks. This explains respawn flicker and why mods must rebind world references.

    public void handleRespawn(S07PacketRespawn packetIn)
    {
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

        if (packetIn.getDimensionID() != this.gameController.thePlayer.dimension)
        {
            this.doneLoadingTerrain = false;
            Scoreboard scoreboard = this.clientWorldController.getScoreboard();
            this.clientWorldController = new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, this.gameController.theWorld.getWorldInfo().isHardcoreModeEnabled(), packetIn.getWorldType()), packetIn.getDimensionID(), packetIn.getDifficulty(), this.gameController.mcProfiler);
            this.clientWorldController.setWorldScoreboard(scoreboard);
            this.gameController.loadWorld(this.clientWorldController);
            this.gameController.thePlayer.dimension = packetIn.getDimensionID();
            this.gameController.displayGuiScreen(new GuiDownloadTerrain(this));
        }

        this.gameController.setDimensionAndSpawnPlayer(packetIn.getDimensionID());
        this.gameController.playerController.setGameType(packetIn.getGameType());
    }

The dimension mismatch gate separates full world rebuild from same-world respawn. Clearing doneLoadingTerrain forces the next S08 to dismiss the download screen. Saving and restoring the scoreboard preserves teams across dimension travel. The WorldClient constructor with gameType and difficulty reapplies rules for the new dimension. The final setDimensionAndSpawnPlayer plus setGameType sync player controller even when no rebuild occurred.

handleResourcePack

Prompts and downloads server pack.

handleResourcePack implements S48 server pack prompt with C19 status replies. It extracts URL and hash, then branches on level slash slash prefix for local saves versus remote packs. Local files under saves are checked with isFile, replying ACCEPTED then async SUCCESSFULLY_LOADED or FAILED_DOWNLOAD, or immediate FAILED_DOWNLOAD if missing. Remote packs check ServerData resource mode where ENABLED auto-accepts and downloads, DISABLED replies DECLINED, and PROMPT schedules a GuiYesNo dialog. Confirming yes sets mode ENABLED, sends ACCEPTED and downloads, while no sets DISABLED and sends DECLINED. Downloads use the repository with Futures callbacks that send final C19 status. No kick occurs directly, but servers may kick on DECLINED.

    public void handleResourcePack(S48PacketResourcePackSend packetIn)
    {
        final String s = packetIn.getURL();
        final String s1 = packetIn.getHash();

        if (s.startsWith("level://"))
        {
            String s2 = s.substring("level://".length());
            File file1 = new File(this.gameController.mcDataDir, "saves");
            File file2 = new File(file1, s2);

            if (file2.isFile())
            {
                this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.ACCEPTED));
                Futures.addCallback(this.gameController.getResourcePackRepository().setResourcePackInstance(file2), new FutureCallback<Object>()
                {
                    public void onSuccess(Object p_onSuccess_1_)
                    {
                        NetHandlerPlayClient.this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
                    }
                    public void onFailure(Throwable p_onFailure_1_)
                    {
                        NetHandlerPlayClient.this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
                    }
                });
            }
            else
            {
                this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));

getURL and getHash provide the pack location and integrity hash for C19 replies. The startsWith level branch strips the prefix and resolves the file under the saves directory. isFile success sends C19 ACCEPTED immediately before async load. The Futures callbacks send SUCCESSFULLY_LOADED or FAILED_DOWNLOAD after the repository finishes. The missing-file else sends FAILED_DOWNLOAD, while remote ENABLED, DISABLED and PROMPT branches below handle server-hosted packs.

handleCustomPayload

Handles MC|TrList, Brand and BOpen.

handleCustomPayload dispatches S3F plugin channels on the client thread. MC|TrList reads an int windowId, checks the current screen is GuiMerchant and ids match openContainer, then parses MerchantRecipeList and sets villager recipes. MC|Brand reads a string up to 32767 and stores it as clientBrand for server identification. MC|BOpen checks the held item is written_book and opens GuiScreenBook read-only. After TrList the buffer is released in finally to avoid leaks, other branches release via network layer. Unknown channels are ignored. No reply packet is sent, the data only mutates GUI and NBT state. Exploit angle is fake TrList with mismatched windowId which is correctly dropped.

        if ("MC|TrList".equals(packetIn.getChannelName()))
        {
            PacketBuffer packetbuffer = packetIn.getBufferData();

            try
            {
                int i = packetbuffer.readInt();
                GuiScreen guiscreen = this.gameController.currentScreen;

                if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.thePlayer.openContainer.windowId)
                {
                    IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
                    MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
                    imerchant.setRecipes(merchantrecipelist);
                }
            }
            catch (IOException ioexception)
            {
                logger.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
            }
            finally
            {
                packetbuffer.release();
            }
        }
        else if ("MC|Brand".equals(packetIn.getChannelName()))
        {
            this.gameController.thePlayer.setClientBrand(packetIn.getBufferData().readStringFromBuffer(32767));

The MC|TrList equals gate isolates villager trades from brand and book channels. readInt plus GuiMerchant plus windowId match prevents injecting trades into the wrong container. readFromBuf and setRecipes populate the merchant GUI with server offers. The catch logs load failures while finally releases the buffer to prevent netty leaks. The MC|Brand branch stores the server brand string for F3 debug display.

Packet Usage

PacketDirTrigger
S01handledJoin: init world and player
S08handledServer teleport or login position
S21handledChunk column load/unload
S32handledInventory transaction result
S48handledServer resource-pack request
C00sentEcho S00 keepalive key
C03sentAck S08 pos-look
C0FsentConfirm failed transaction
C17sentSend MC|Brand on join
C19sentResource-pack status reply

Internal State

clientWorldControllerActive WorldClient being mutated
playerInfoMapUUID to NetworkPlayerInfo tab-list cache
doneLoadingTerrainGate set by first S08, reset on respawn
gameControllerMinecraft instance for GUI and world
netManagerChannel used for replies and queue

Related Vanilla Internals

Full Source

NetHandlerPlayClient.java2125 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.network;
2
3
import com.google.common.collect.Maps;
4
import com.google.common.util.concurrent.FutureCallback;
5
import com.google.common.util.concurrent.Futures;
6
import com.mojang.authlib.GameProfile;
7
import io.netty.buffer.Unpooled;
8
import java.io.File;
9
import java.io.IOException;
10
import java.util.Collection;
11
import java.util.List;
12
import java.util.Map;
13
import java.util.Random;
14
import java.util.UUID;
15
import java.util.Map.Entry;
16
import net.minecraft.block.Block;
17
import net.minecraft.client.ClientBrandRetriever;
18
import net.minecraft.client.Minecraft;
19
import net.minecraft.client.audio.GuardianSound;
20
import net.minecraft.client.entity.EntityOtherPlayerMP;
21
import net.minecraft.client.entity.EntityPlayerSP;
22
import net.minecraft.client.gui.GuiChat;
23
import net.minecraft.client.gui.GuiDisconnected;
24
import net.minecraft.client.gui.GuiDownloadTerrain;
25
import net.minecraft.client.gui.GuiMainMenu;
26
import net.minecraft.client.gui.GuiMerchant;
27
import net.minecraft.client.gui.GuiMultiplayer;
28
import net.minecraft.client.gui.GuiScreen;
29
import net.minecraft.client.gui.GuiScreenBook;
30
import net.minecraft.client.gui.GuiScreenDemo;
31
import net.minecraft.client.gui.GuiScreenRealmsProxy;
32
import net.minecraft.client.gui.GuiWinGame;
33
import net.minecraft.client.gui.GuiYesNo;
34
import net.minecraft.client.gui.GuiYesNoCallback;
35
import net.minecraft.client.gui.IProgressMeter;
36
import net.minecraft.client.gui.inventory.GuiContainerCreative;
37
import net.minecraft.client.multiplayer.PlayerControllerMP;
38
import net.minecraft.client.multiplayer.ServerData;
39
import net.minecraft.client.multiplayer.ServerList;
40
import net.minecraft.client.multiplayer.WorldClient;
41
import net.minecraft.client.particle.EntityPickupFX;
42
import net.minecraft.client.player.inventory.ContainerLocalMenu;
43
import net.minecraft.client.player.inventory.LocalBlockIntercommunication;
44
import net.minecraft.client.resources.I18n;
45
import net.minecraft.client.settings.GameSettings;
46
import net.minecraft.client.stream.MetadataAchievement;
47
import net.minecraft.client.stream.MetadataCombat;
48
import net.minecraft.client.stream.MetadataPlayerDeath;
49
import net.minecraft.creativetab.CreativeTabs;
50
import net.minecraft.entity.DataWatcher;
51
import net.minecraft.entity.Entity;
52
import net.minecraft.entity.EntityLeashKnot;
53
import net.minecraft.entity.EntityList;
54
import net.minecraft.entity.EntityLiving;
55
import net.minecraft.entity.EntityLivingBase;
56
import net.minecraft.entity.IMerchant;
57
import net.minecraft.entity.NpcMerchant;
58
import net.minecraft.entity.ai.attributes.AttributeModifier;
59
import net.minecraft.entity.ai.attributes.BaseAttributeMap;
60
import net.minecraft.entity.ai.attributes.IAttribute;
61
import net.minecraft.entity.ai.attributes.IAttributeInstance;
62
import net.minecraft.entity.ai.attributes.RangedAttribute;
63
import net.minecraft.entity.effect.EntityLightningBolt;
64
import net.minecraft.entity.item.EntityArmorStand;
65
import net.minecraft.entity.item.EntityBoat;
66
import net.minecraft.entity.item.EntityEnderCrystal;
67
import net.minecraft.entity.item.EntityEnderEye;
68
import net.minecraft.entity.item.EntityEnderPearl;
69
import net.minecraft.entity.item.EntityExpBottle;
70
import net.minecraft.entity.item.EntityFallingBlock;
71
import net.minecraft.entity.item.EntityFireworkRocket;
72
import net.minecraft.entity.item.EntityItem;
73
import net.minecraft.entity.item.EntityItemFrame;
74
import net.minecraft.entity.item.EntityMinecart;
75
import net.minecraft.entity.item.EntityPainting;
76
import net.minecraft.entity.item.EntityTNTPrimed;
77
import net.minecraft.entity.item.EntityXPOrb;
78
import net.minecraft.entity.monster.EntityGuardian;
79
import net.minecraft.entity.passive.EntityHorse;
80
import net.minecraft.entity.player.EntityPlayer;
81
import net.minecraft.entity.player.InventoryPlayer;
82
import net.minecraft.entity.projectile.EntityArrow;
83
import net.minecraft.entity.projectile.EntityEgg;
84
import net.minecraft.entity.projectile.EntityFishHook;
85
import net.minecraft.entity.projectile.EntityLargeFireball;
86
import net.minecraft.entity.projectile.EntityPotion;
87
import net.minecraft.entity.projectile.EntitySmallFireball;
88
import net.minecraft.entity.projectile.EntitySnowball;
89
import net.minecraft.entity.projectile.EntityWitherSkull;
90
import net.minecraft.init.Items;
91
import net.minecraft.inventory.AnimalChest;
92
import net.minecraft.inventory.Container;
93
import net.minecraft.inventory.InventoryBasic;
94
import net.minecraft.item.Item;
95
import net.minecraft.item.ItemMap;
96
import net.minecraft.item.ItemStack;
97
import net.minecraft.network.NetworkManager;
98
import net.minecraft.network.Packet;
99
import net.minecraft.network.PacketBuffer;
100
import net.minecraft.network.PacketThreadUtil;
101
import net.minecraft.network.play.INetHandlerPlayClient;
102
import net.minecraft.network.play.client.C00PacketKeepAlive;
103
import net.minecraft.network.play.client.C03PacketPlayer;
104
import net.minecraft.network.play.client.C0FPacketConfirmTransaction;
105
import net.minecraft.network.play.client.C17PacketCustomPayload;
106
import net.minecraft.network.play.client.C19PacketResourcePackStatus;
107
import net.minecraft.network.play.server.S00PacketKeepAlive;
108
import net.minecraft.network.play.server.S01PacketJoinGame;
109
import net.minecraft.network.play.server.S02PacketChat;
110
import net.minecraft.network.play.server.S03PacketTimeUpdate;
111
import net.minecraft.network.play.server.S04PacketEntityEquipment;
112
import net.minecraft.network.play.server.S05PacketSpawnPosition;
113
import net.minecraft.network.play.server.S06PacketUpdateHealth;
114
import net.minecraft.network.play.server.S07PacketRespawn;
115
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
116
import net.minecraft.network.play.server.S09PacketHeldItemChange;
117
import net.minecraft.network.play.server.S0APacketUseBed;
118
import net.minecraft.network.play.server.S0BPacketAnimation;
119
import net.minecraft.network.play.server.S0CPacketSpawnPlayer;
120
import net.minecraft.network.play.server.S0DPacketCollectItem;
121
import net.minecraft.network.play.server.S0EPacketSpawnObject;
122
import net.minecraft.network.play.server.S0FPacketSpawnMob;
123
import net.minecraft.network.play.server.S10PacketSpawnPainting;
124
import net.minecraft.network.play.server.S11PacketSpawnExperienceOrb;
125
import net.minecraft.network.play.server.S12PacketEntityVelocity;
126
import net.minecraft.network.play.server.S13PacketDestroyEntities;
127
import net.minecraft.network.play.server.S14PacketEntity;
128
import net.minecraft.network.play.server.S18PacketEntityTeleport;
129
import net.minecraft.network.play.server.S19PacketEntityHeadLook;
130
import net.minecraft.network.play.server.S19PacketEntityStatus;
131
import net.minecraft.network.play.server.S1BPacketEntityAttach;
132
import net.minecraft.network.play.server.S1CPacketEntityMetadata;
133
import net.minecraft.network.play.server.S1DPacketEntityEffect;
134
import net.minecraft.network.play.server.S1EPacketRemoveEntityEffect;
135
import net.minecraft.network.play.server.S1FPacketSetExperience;
136
import net.minecraft.network.play.server.S20PacketEntityProperties;
137
import net.minecraft.network.play.server.S21PacketChunkData;
138
import net.minecraft.network.play.server.S22PacketMultiBlockChange;
139
import net.minecraft.network.play.server.S23PacketBlockChange;
140
import net.minecraft.network.play.server.S24PacketBlockAction;
141
import net.minecraft.network.play.server.S25PacketBlockBreakAnim;
142
import net.minecraft.network.play.server.S26PacketMapChunkBulk;
143
import net.minecraft.network.play.server.S27PacketExplosion;
144
import net.minecraft.network.play.server.S28PacketEffect;
145
import net.minecraft.network.play.server.S29PacketSoundEffect;
146
import net.minecraft.network.play.server.S2APacketParticles;
147
import net.minecraft.network.play.server.S2BPacketChangeGameState;
148
import net.minecraft.network.play.server.S2CPacketSpawnGlobalEntity;
149
import net.minecraft.network.play.server.S2DPacketOpenWindow;
150
import net.minecraft.network.play.server.S2EPacketCloseWindow;
151
import net.minecraft.network.play.server.S2FPacketSetSlot;
152
import net.minecraft.network.play.server.S30PacketWindowItems;
153
import net.minecraft.network.play.server.S31PacketWindowProperty;
154
import net.minecraft.network.play.server.S32PacketConfirmTransaction;
155
import net.minecraft.network.play.server.S33PacketUpdateSign;
156
import net.minecraft.network.play.server.S34PacketMaps;
157
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
158
import net.minecraft.network.play.server.S36PacketSignEditorOpen;
159
import net.minecraft.network.play.server.S37PacketStatistics;
160
import net.minecraft.network.play.server.S38PacketPlayerListItem;
161
import net.minecraft.network.play.server.S39PacketPlayerAbilities;
162
import net.minecraft.network.play.server.S3APacketTabComplete;
163
import net.minecraft.network.play.server.S3BPacketScoreboardObjective;
164
import net.minecraft.network.play.server.S3CPacketUpdateScore;
165
import net.minecraft.network.play.server.S3DPacketDisplayScoreboard;
166
import net.minecraft.network.play.server.S3EPacketTeams;
167
import net.minecraft.network.play.server.S3FPacketCustomPayload;
168
import net.minecraft.network.play.server.S40PacketDisconnect;
169
import net.minecraft.network.play.server.S41PacketServerDifficulty;
170
import net.minecraft.network.play.server.S42PacketCombatEvent;
171
import net.minecraft.network.play.server.S43PacketCamera;
172
import net.minecraft.network.play.server.S44PacketWorldBorder;
173
import net.minecraft.network.play.server.S45PacketTitle;
174
import net.minecraft.network.play.server.S46PacketSetCompressionLevel;
175
import net.minecraft.network.play.server.S47PacketPlayerListHeaderFooter;
176
import net.minecraft.network.play.server.S48PacketResourcePackSend;
177
import net.minecraft.network.play.server.S49PacketUpdateEntityNBT;
178
import net.minecraft.potion.PotionEffect;
179
import net.minecraft.realms.DisconnectedRealmsScreen;
180
import net.minecraft.scoreboard.IScoreObjectiveCriteria;
181
import net.minecraft.scoreboard.Score;
182
import net.minecraft.scoreboard.ScoreObjective;
183
import net.minecraft.scoreboard.ScorePlayerTeam;
184
import net.minecraft.scoreboard.Scoreboard;
185
import net.minecraft.scoreboard.Team;
186
import net.minecraft.stats.Achievement;
187
import net.minecraft.stats.AchievementList;
188
import net.minecraft.stats.StatBase;
189
import net.minecraft.tileentity.TileEntity;
190
import net.minecraft.tileentity.TileEntityBanner;
191
import net.minecraft.tileentity.TileEntityBeacon;
192
import net.minecraft.tileentity.TileEntityCommandBlock;
193
import net.minecraft.tileentity.TileEntityFlowerPot;
194
import net.minecraft.tileentity.TileEntityMobSpawner;
195
import net.minecraft.tileentity.TileEntitySign;
196
import net.minecraft.tileentity.TileEntitySkull;
197
import net.minecraft.util.BlockPos;
198
import net.minecraft.util.ChatComponentText;
199
import net.minecraft.util.ChatComponentTranslation;
200
import net.minecraft.util.EnumChatFormatting;
201
import net.minecraft.util.EnumFacing;
202
import net.minecraft.util.EnumParticleTypes;
203
import net.minecraft.util.IChatComponent;
204
import net.minecraft.util.MathHelper;
205
import net.minecraft.util.StringUtils;
206
import net.minecraft.village.MerchantRecipeList;
207
import net.minecraft.world.Explosion;
208
import net.minecraft.world.WorldProviderSurface;
209
import net.minecraft.world.WorldSettings;
210
import net.minecraft.world.chunk.Chunk;
211
import net.minecraft.world.storage.MapData;
212
import org.apache.logging.log4j.LogManager;
213
import org.apache.logging.log4j.Logger;
214
215
public class NetHandlerPlayClient implements INetHandlerPlayClient
216
{
217
    private static final Logger logger = LogManager.getLogger();
218
219
    /**
220
     * The NetworkManager instance used to communicate with the server (used only by handlePlayerPosLook to update
221
     * positioning and handleJoinGame to inform the server of the client distribution/mods)
222
     */
223
    private final NetworkManager netManager;
224
    private final GameProfile profile;
225
226
    /**
227
     * Seems to be either null (integrated server) or an instance of either GuiMultiplayer (when connecting to a server)
228
     * or GuiScreenReamlsTOS (when connecting to MCO server)
229
     */
230
    private final GuiScreen guiScreenServer;
231
232
    /**
233
     * Reference to the Minecraft instance, which many handler methods operate on
234
     */
235
    private Minecraft gameController;
236
237
    /**
238
     * Reference to the current ClientWorld instance, which many handler methods operate on
239
     */
240
    private WorldClient clientWorldController;
241
242
    /**
243
     * True if the client has finished downloading terrain and may spawn. Set upon receipt of S08PacketPlayerPosLook,
244
     * reset upon respawning
245
     */
246
    private boolean doneLoadingTerrain;
247
    private final Map<UUID, NetworkPlayerInfo> playerInfoMap = Maps.<UUID, NetworkPlayerInfo>newHashMap();
248
    public int currentServerMaxPlayers = 20;
249
    private boolean field_147308_k = false;
250
251
    /**
252
     * Just an ordinary random number generator, used to randomize audio pitch of item/orb pickup and randomize both
253
     * particlespawn offset and velocity
254
     */
255
    private final Random avRandomizer = new Random();
256
257
    public NetHandlerPlayClient(Minecraft mcIn, GuiScreen p_i46300_2_, NetworkManager p_i46300_3_, GameProfile p_i46300_4_)
258
    {
259
        this.gameController = mcIn;
260
        this.guiScreenServer = p_i46300_2_;
261
        this.netManager = p_i46300_3_;
262
        this.profile = p_i46300_4_;
263
    }
264
265
    /**
266
     * Clears the WorldClient instance associated with this NetHandlerPlayClient
267
     */
268
    public void cleanup()
269
    {
270
        this.clientWorldController = null;
271
    }
272
273
    /**
274
     * Registers some server properties (gametype,hardcore-mode,terraintype,difficulty,player limit), creates a new
275
     * WorldClient and sets the player initial dimension
276
     */
277
    public void handleJoinGame(S01PacketJoinGame packetIn)
278
    {
279
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
280
        this.gameController.playerController = new PlayerControllerMP(this.gameController, this);
281
        this.clientWorldController = new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, packetIn.isHardcoreMode(), packetIn.getWorldType()), packetIn.getDimension(), packetIn.getDifficulty(), this.gameController.mcProfiler);
282
        this.gameController.gameSettings.difficulty = packetIn.getDifficulty();
283
        this.gameController.loadWorld(this.clientWorldController);
284
        this.gameController.thePlayer.dimension = packetIn.getDimension();
285
        this.gameController.displayGuiScreen(new GuiDownloadTerrain(this));
286
        this.gameController.thePlayer.setEntityId(packetIn.getEntityId());
287
        this.currentServerMaxPlayers = packetIn.getMaxPlayers();
288
        this.gameController.thePlayer.setReducedDebug(packetIn.isReducedDebugInfo());
289
        this.gameController.playerController.setGameType(packetIn.getGameType());
290
        this.gameController.gameSettings.sendSettingsToServer();
291
        this.netManager.sendPacket(new C17PacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName())));
292
    }
293
294
    /**
295
     * Spawns an instance of the objecttype indicated by the packet and sets its position and momentum
296
     */
297
    public void handleSpawnObject(S0EPacketSpawnObject packetIn)
298
    {
299
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
300
        double d0 = (double)packetIn.getX() / 32.0D;
301
        double d1 = (double)packetIn.getY() / 32.0D;
302
        double d2 = (double)packetIn.getZ() / 32.0D;
303
        Entity entity = null;
304
305
        if (packetIn.getType() == 10)
306
        {
307
            entity = EntityMinecart.getMinecart(this.clientWorldController, d0, d1, d2, EntityMinecart.EnumMinecartType.byNetworkID(packetIn.func_149009_m()));
308
        }
309
        else if (packetIn.getType() == 90)
310
        {
311
            Entity entity1 = this.clientWorldController.getEntityByID(packetIn.func_149009_m());
312
313
            if (entity1 instanceof EntityPlayer)
314
            {
315
                entity = new EntityFishHook(this.clientWorldController, d0, d1, d2, (EntityPlayer)entity1);
316
            }
317
318
            packetIn.func_149002_g(0);
319
        }
320
        else if (packetIn.getType() == 60)
321
        {
322
            entity = new EntityArrow(this.clientWorldController, d0, d1, d2);
323
        }
324
        else if (packetIn.getType() == 61)
325
        {
326
            entity = new EntitySnowball(this.clientWorldController, d0, d1, d2);
327
        }
328
        else if (packetIn.getType() == 71)
329
        {
330
            entity = new EntityItemFrame(this.clientWorldController, new BlockPos(MathHelper.floor_double(d0), MathHelper.floor_double(d1), MathHelper.floor_double(d2)), EnumFacing.getHorizontal(packetIn.func_149009_m()));
331
            packetIn.func_149002_g(0);
332
        }
333
        else if (packetIn.getType() == 77)
334
        {
335
            entity = new EntityLeashKnot(this.clientWorldController, new BlockPos(MathHelper.floor_double(d0), MathHelper.floor_double(d1), MathHelper.floor_double(d2)));
336
            packetIn.func_149002_g(0);
337
        }
338
        else if (packetIn.getType() == 65)
339
        {
340
            entity = new EntityEnderPearl(this.clientWorldController, d0, d1, d2);
341
        }
342
        else if (packetIn.getType() == 72)
343
        {
344
            entity = new EntityEnderEye(this.clientWorldController, d0, d1, d2);
345
        }
346
        else if (packetIn.getType() == 76)
347
        {
348
            entity = new EntityFireworkRocket(this.clientWorldController, d0, d1, d2, (ItemStack)null);
349
        }
350
        else if (packetIn.getType() == 63)
351
        {
352
            entity = new EntityLargeFireball(this.clientWorldController, d0, d1, d2, (double)packetIn.getSpeedX() / 8000.0D, (double)packetIn.getSpeedY() / 8000.0D, (double)packetIn.getSpeedZ() / 8000.0D);
353
            packetIn.func_149002_g(0);
354
        }
355
        else if (packetIn.getType() == 64)
356
        {
357
            entity = new EntitySmallFireball(this.clientWorldController, d0, d1, d2, (double)packetIn.getSpeedX() / 8000.0D, (double)packetIn.getSpeedY() / 8000.0D, (double)packetIn.getSpeedZ() / 8000.0D);
358
            packetIn.func_149002_g(0);
359
        }
360
        else if (packetIn.getType() == 66)
361
        {
362
            entity = new EntityWitherSkull(this.clientWorldController, d0, d1, d2, (double)packetIn.getSpeedX() / 8000.0D, (double)packetIn.getSpeedY() / 8000.0D, (double)packetIn.getSpeedZ() / 8000.0D);
363
            packetIn.func_149002_g(0);
364
        }
365
        else if (packetIn.getType() == 62)
366
        {
367
            entity = new EntityEgg(this.clientWorldController, d0, d1, d2);
368
        }
369
        else if (packetIn.getType() == 73)
370
        {
371
            entity = new EntityPotion(this.clientWorldController, d0, d1, d2, packetIn.func_149009_m());
372
            packetIn.func_149002_g(0);
373
        }
374
        else if (packetIn.getType() == 75)
375
        {
376
            entity = new EntityExpBottle(this.clientWorldController, d0, d1, d2);
377
            packetIn.func_149002_g(0);
378
        }
379
        else if (packetIn.getType() == 1)
380
        {
381
            entity = new EntityBoat(this.clientWorldController, d0, d1, d2);
382
        }
383
        else if (packetIn.getType() == 50)
384
        {
385
            entity = new EntityTNTPrimed(this.clientWorldController, d0, d1, d2, (EntityLivingBase)null);
386
        }
387
        else if (packetIn.getType() == 78)
388
        {
389
            entity = new EntityArmorStand(this.clientWorldController, d0, d1, d2);
390
        }
391
        else if (packetIn.getType() == 51)
392
        {
393
            entity = new EntityEnderCrystal(this.clientWorldController, d0, d1, d2);
394
        }
395
        else if (packetIn.getType() == 2)
396
        {
397
            entity = new EntityItem(this.clientWorldController, d0, d1, d2);
398
        }
399
        else if (packetIn.getType() == 70)
400
        {
401
            entity = new EntityFallingBlock(this.clientWorldController, d0, d1, d2, Block.getStateById(packetIn.func_149009_m() & 65535));
402
            packetIn.func_149002_g(0);
403
        }
404
405
        if (entity != null)
406
        {
407
            entity.serverPosX = packetIn.getX();
408
            entity.serverPosY = packetIn.getY();
409
            entity.serverPosZ = packetIn.getZ();
410
            entity.rotationPitch = (float)(packetIn.getPitch() * 360) / 256.0F;
411
            entity.rotationYaw = (float)(packetIn.getYaw() * 360) / 256.0F;
412
            Entity[] aentity = entity.getParts();
413
414
            if (aentity != null)
415
            {
416
                int i = packetIn.getEntityID() - entity.getEntityId();
417
418
                for (int j = 0; j < aentity.length; ++j)
419
                {
420
                    aentity[j].setEntityId(aentity[j].getEntityId() + i);
421
                }
422
            }
423
424
            entity.setEntityId(packetIn.getEntityID());
425
            this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entity);
426
427
            if (packetIn.func_149009_m() > 0)
428
            {
429
                if (packetIn.getType() == 60)
430
                {
431
                    Entity entity2 = this.clientWorldController.getEntityByID(packetIn.func_149009_m());
432
433
                    if (entity2 instanceof EntityLivingBase && entity instanceof EntityArrow)
434
                    {
435
                        ((EntityArrow)entity).shootingEntity = entity2;
436
                    }
437
                }
438
439
                entity.setVelocity((double)packetIn.getSpeedX() / 8000.0D, (double)packetIn.getSpeedY() / 8000.0D, (double)packetIn.getSpeedZ() / 8000.0D);
440
            }
441
        }
442
    }
443
444
    /**
445
     * Spawns an experience orb and sets its value (amount of XP)
446
     */
447
    public void handleSpawnExperienceOrb(S11PacketSpawnExperienceOrb packetIn)
448
    {
449
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
450
        Entity entity = new EntityXPOrb(this.clientWorldController, (double)packetIn.getX() / 32.0D, (double)packetIn.getY() / 32.0D, (double)packetIn.getZ() / 32.0D, packetIn.getXPValue());
451
        entity.serverPosX = packetIn.getX();
452
        entity.serverPosY = packetIn.getY();
453
        entity.serverPosZ = packetIn.getZ();
454
        entity.rotationYaw = 0.0F;
455
        entity.rotationPitch = 0.0F;
456
        entity.setEntityId(packetIn.getEntityID());
457
        this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entity);
458
    }
459
460
    /**
461
     * Handles globally visible entities. Used in vanilla for lightning bolts
462
     */
463
    public void handleSpawnGlobalEntity(S2CPacketSpawnGlobalEntity packetIn)
464
    {
465
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
466
        double d0 = (double)packetIn.func_149051_d() / 32.0D;
467
        double d1 = (double)packetIn.func_149050_e() / 32.0D;
468
        double d2 = (double)packetIn.func_149049_f() / 32.0D;
469
        Entity entity = null;
470
471
        if (packetIn.func_149053_g() == 1)
472
        {
473
            entity = new EntityLightningBolt(this.clientWorldController, d0, d1, d2);
474
        }
475
476
        if (entity != null)
477
        {
478
            entity.serverPosX = packetIn.func_149051_d();
479
            entity.serverPosY = packetIn.func_149050_e();
480
            entity.serverPosZ = packetIn.func_149049_f();
481
            entity.rotationYaw = 0.0F;
482
            entity.rotationPitch = 0.0F;
483
            entity.setEntityId(packetIn.func_149052_c());
484
            this.clientWorldController.addWeatherEffect(entity);
485
        }
486
    }
487
488
    /**
489
     * Handles the spawning of a painting object
490
     */
491
    public void handleSpawnPainting(S10PacketSpawnPainting packetIn)
492
    {
493
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
494
        EntityPainting entitypainting = new EntityPainting(this.clientWorldController, packetIn.getPosition(), packetIn.getFacing(), packetIn.getTitle());
495
        this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entitypainting);
496
    }
497
498
    /**
499
     * Sets the velocity of the specified entity to the specified value
500
     */
501
    public void handleEntityVelocity(S12PacketEntityVelocity packetIn)
502
    {
503
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
504
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID());
505
506
        if (entity != null)
507
        {
508
            entity.setVelocity((double)packetIn.getMotionX() / 8000.0D, (double)packetIn.getMotionY() / 8000.0D, (double)packetIn.getMotionZ() / 8000.0D);
509
        }
510
    }
511
512
    /**
513
     * Invoked when the server registers new proximate objects in your watchlist or when objects in your watchlist have
514
     * changed -> Registers any changes locally
515
     */
516
    public void handleEntityMetadata(S1CPacketEntityMetadata packetIn)
517
    {
518
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
519
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
520
521
        if (entity != null && packetIn.func_149376_c() != null)
522
        {
523
            entity.getDataWatcher().updateWatchedObjectsFromList(packetIn.func_149376_c());
524
        }
525
    }
526
527
    /**
528
     * Handles the creation of a nearby player entity, sets the position and held item
529
     */
530
    public void handleSpawnPlayer(S0CPacketSpawnPlayer packetIn)
531
    {
532
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
533
        double d0 = (double)packetIn.getX() / 32.0D;
534
        double d1 = (double)packetIn.getY() / 32.0D;
535
        double d2 = (double)packetIn.getZ() / 32.0D;
536
        float f = (float)(packetIn.getYaw() * 360) / 256.0F;
537
        float f1 = (float)(packetIn.getPitch() * 360) / 256.0F;
538
        EntityOtherPlayerMP entityotherplayermp = new EntityOtherPlayerMP(this.gameController.theWorld, this.getPlayerInfo(packetIn.getPlayer()).getGameProfile());
539
        entityotherplayermp.prevPosX = entityotherplayermp.lastTickPosX = (double)(entityotherplayermp.serverPosX = packetIn.getX());
540
        entityotherplayermp.prevPosY = entityotherplayermp.lastTickPosY = (double)(entityotherplayermp.serverPosY = packetIn.getY());
541
        entityotherplayermp.prevPosZ = entityotherplayermp.lastTickPosZ = (double)(entityotherplayermp.serverPosZ = packetIn.getZ());
542
        int i = packetIn.getCurrentItemID();
543
544
        if (i == 0)
545
        {
546
            entityotherplayermp.inventory.mainInventory[entityotherplayermp.inventory.currentItem] = null;
547
        }
548
        else
549
        {
550
            entityotherplayermp.inventory.mainInventory[entityotherplayermp.inventory.currentItem] = new ItemStack(Item.getItemById(i), 1, 0);
551
        }
552
553
        entityotherplayermp.setPositionAndRotation(d0, d1, d2, f, f1);
554
        this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entityotherplayermp);
555
        List<DataWatcher.WatchableObject> list = packetIn.func_148944_c();
556
557
        if (list != null)
558
        {
559
            entityotherplayermp.getDataWatcher().updateWatchedObjectsFromList(list);
560
        }
561
    }
562
563
    /**
564
     * Updates an entity's position and rotation as specified by the packet
565
     */
566
    public void handleEntityTeleport(S18PacketEntityTeleport packetIn)
567
    {
568
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
569
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
570
571
        if (entity != null)
572
        {
573
            entity.serverPosX = packetIn.getX();
574
            entity.serverPosY = packetIn.getY();
575
            entity.serverPosZ = packetIn.getZ();
576
            double d0 = (double)entity.serverPosX / 32.0D;
577
            double d1 = (double)entity.serverPosY / 32.0D;
578
            double d2 = (double)entity.serverPosZ / 32.0D;
579
            float f = (float)(packetIn.getYaw() * 360) / 256.0F;
580
            float f1 = (float)(packetIn.getPitch() * 360) / 256.0F;
581
582
            if (Math.abs(entity.posX - d0) < 0.03125D && Math.abs(entity.posY - d1) < 0.015625D && Math.abs(entity.posZ - d2) < 0.03125D)
583
            {
584
                entity.setPositionAndRotation2(entity.posX, entity.posY, entity.posZ, f, f1, 3, true);
585
            }
586
            else
587
            {
588
                entity.setPositionAndRotation2(d0, d1, d2, f, f1, 3, true);
589
            }
590
591
            entity.onGround = packetIn.getOnGround();
592
        }
593
    }
594
595
    /**
596
     * Updates which hotbar slot of the player is currently selected
597
     */
598
    public void handleHeldItemChange(S09PacketHeldItemChange packetIn)
599
    {
600
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
601
602
        if (packetIn.getHeldItemHotbarIndex() >= 0 && packetIn.getHeldItemHotbarIndex() < InventoryPlayer.getHotbarSize())
603
        {
604
            this.gameController.thePlayer.inventory.currentItem = packetIn.getHeldItemHotbarIndex();
605
        }
606
    }
607
608
    /**
609
     * Updates the specified entity's position by the specified relative moment and absolute rotation. Note that
610
     * subclassing of the packet allows for the specification of a subset of this data (e.g. only rel. position, abs.
611
     * rotation or both).
612
     */
613
    public void handleEntityMovement(S14PacketEntity packetIn)
614
    {
615
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
616
        Entity entity = packetIn.getEntity(this.clientWorldController);
617
618
        if (entity != null)
619
        {
620
            entity.serverPosX += packetIn.func_149062_c();
621
            entity.serverPosY += packetIn.func_149061_d();
622
            entity.serverPosZ += packetIn.func_149064_e();
623
            double d0 = (double)entity.serverPosX / 32.0D;
624
            double d1 = (double)entity.serverPosY / 32.0D;
625
            double d2 = (double)entity.serverPosZ / 32.0D;
626
            float f = packetIn.func_149060_h() ? (float)(packetIn.func_149066_f() * 360) / 256.0F : entity.rotationYaw;
627
            float f1 = packetIn.func_149060_h() ? (float)(packetIn.func_149063_g() * 360) / 256.0F : entity.rotationPitch;
628
            entity.setPositionAndRotation2(d0, d1, d2, f, f1, 3, false);
629
            entity.onGround = packetIn.getOnGround();
630
        }
631
    }
632
633
    /**
634
     * Updates the direction in which the specified entity is looking, normally this head rotation is independent of the
635
     * rotation of the entity itself
636
     */
637
    public void handleEntityHeadLook(S19PacketEntityHeadLook packetIn)
638
    {
639
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
640
        Entity entity = packetIn.getEntity(this.clientWorldController);
641
642
        if (entity != null)
643
        {
644
            float f = (float)(packetIn.getYaw() * 360) / 256.0F;
645
            entity.setRotationYawHead(f);
646
        }
647
    }
648
649
    /**
650
     * Locally eliminates the entities. Invoked by the server when the items are in fact destroyed, or the player is no
651
     * longer registered as required to monitor them. The latter  happens when distance between the player and item
652
     * increases beyond a certain treshold (typically the viewing distance)
653
     */
654
    public void handleDestroyEntities(S13PacketDestroyEntities packetIn)
655
    {
656
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
657
658
        for (int i = 0; i < packetIn.getEntityIDs().length; ++i)
659
        {
660
            this.clientWorldController.removeEntityFromWorld(packetIn.getEntityIDs()[i]);
661
        }
662
    }
663
664
    /**
665
     * Handles changes in player positioning and rotation such as when travelling to a new dimension, (re)spawning,
666
     * mounting horses etc. Seems to immediately reply to the server with the clients post-processing perspective on the
667
     * player positioning
668
     */
669
    public void handlePlayerPosLook(S08PacketPlayerPosLook packetIn)
670
    {
671
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
672
        EntityPlayer entityplayer = this.gameController.thePlayer;
673
        double d0 = packetIn.getX();
674
        double d1 = packetIn.getY();
675
        double d2 = packetIn.getZ();
676
        float f = packetIn.getYaw();
677
        float f1 = packetIn.getPitch();
678
679
        if (packetIn.func_179834_f().contains(S08PacketPlayerPosLook.EnumFlags.X))
680
        {
681
            d0 += entityplayer.posX;
682
        }
683
        else
684
        {
685
            entityplayer.motionX = 0.0D;
686
        }
687
688
        if (packetIn.func_179834_f().contains(S08PacketPlayerPosLook.EnumFlags.Y))
689
        {
690
            d1 += entityplayer.posY;
691
        }
692
        else
693
        {
694
            entityplayer.motionY = 0.0D;
695
        }
696
697
        if (packetIn.func_179834_f().contains(S08PacketPlayerPosLook.EnumFlags.Z))
698
        {
699
            d2 += entityplayer.posZ;
700
        }
701
        else
702
        {
703
            entityplayer.motionZ = 0.0D;
704
        }
705
706
        if (packetIn.func_179834_f().contains(S08PacketPlayerPosLook.EnumFlags.X_ROT))
707
        {
708
            f1 += entityplayer.rotationPitch;
709
        }
710
711
        if (packetIn.func_179834_f().contains(S08PacketPlayerPosLook.EnumFlags.Y_ROT))
712
        {
713
            f += entityplayer.rotationYaw;
714
        }
715
716
        entityplayer.setPositionAndRotation(d0, d1, d2, f, f1);
717
        this.netManager.sendPacket(new C03PacketPlayer.C06PacketPlayerPosLook(entityplayer.posX, entityplayer.getEntityBoundingBox().minY, entityplayer.posZ, entityplayer.rotationYaw, entityplayer.rotationPitch, false));
718
719
        if (!this.doneLoadingTerrain)
720
        {
721
            this.gameController.thePlayer.prevPosX = this.gameController.thePlayer.posX;
722
            this.gameController.thePlayer.prevPosY = this.gameController.thePlayer.posY;
723
            this.gameController.thePlayer.prevPosZ = this.gameController.thePlayer.posZ;
724
            this.doneLoadingTerrain = true;
725
            this.gameController.displayGuiScreen((GuiScreen)null);
726
        }
727
    }
728
729
    /**
730
     * Received from the servers PlayerManager if between 1 and 64 blocks in a chunk are changed. If only one block
731
     * requires an update, the server sends S23PacketBlockChange and if 64 or more blocks are changed, the server sends
732
     * S21PacketChunkData
733
     */
734
    public void handleMultiBlockChange(S22PacketMultiBlockChange packetIn)
735
    {
736
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
737
738
        for (S22PacketMultiBlockChange.BlockUpdateData s22packetmultiblockchange$blockupdatedata : packetIn.getChangedBlocks())
739
        {
740
            this.clientWorldController.invalidateRegionAndSetBlock(s22packetmultiblockchange$blockupdatedata.getPos(), s22packetmultiblockchange$blockupdatedata.getBlockState());
741
        }
742
    }
743
744
    /**
745
     * Updates the specified chunk with the supplied data, marks it for re-rendering and lighting recalculation
746
     */
747
    public void handleChunkData(S21PacketChunkData packetIn)
748
    {
749
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
750
751
        if (packetIn.func_149274_i())
752
        {
753
            if (packetIn.getExtractedSize() == 0)
754
            {
755
                this.clientWorldController.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), false);
756
                return;
757
            }
758
759
            this.clientWorldController.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), true);
760
        }
761
762
        this.clientWorldController.invalidateBlockReceiveRegion(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 256, (packetIn.getChunkZ() << 4) + 15);
763
        Chunk chunk = this.clientWorldController.getChunkFromChunkCoords(packetIn.getChunkX(), packetIn.getChunkZ());
764
        chunk.fillChunk(packetIn.getExtractedDataBytes(), packetIn.getExtractedSize(), packetIn.func_149274_i());
765
        this.clientWorldController.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 256, (packetIn.getChunkZ() << 4) + 15);
766
767
        if (!packetIn.func_149274_i() || !(this.clientWorldController.provider instanceof WorldProviderSurface))
768
        {
769
            chunk.resetRelightChecks();
770
        }
771
    }
772
773
    /**
774
     * Updates the block and metadata and generates a blockupdate (and notify the clients)
775
     */
776
    public void handleBlockChange(S23PacketBlockChange packetIn)
777
    {
778
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
779
        this.clientWorldController.invalidateRegionAndSetBlock(packetIn.getBlockPosition(), packetIn.getBlockState());
780
    }
781
782
    /**
783
     * Closes the network channel
784
     */
785
    public void handleDisconnect(S40PacketDisconnect packetIn)
786
    {
787
        this.netManager.closeChannel(packetIn.getReason());
788
    }
789
790
    /**
791
     * Invoked when disconnecting, the parameter is a ChatComponent describing the reason for termination
792
     */
793
    public void onDisconnect(IChatComponent reason)
794
    {
795
        this.gameController.loadWorld((WorldClient)null);
796
797
        if (this.guiScreenServer != null)
798
        {
799
            if (this.guiScreenServer instanceof GuiScreenRealmsProxy)
800
            {
801
                this.gameController.displayGuiScreen((new DisconnectedRealmsScreen(((GuiScreenRealmsProxy)this.guiScreenServer).func_154321_a(), "disconnect.lost", reason)).getProxy());
802
            }
803
            else
804
            {
805
                this.gameController.displayGuiScreen(new GuiDisconnected(this.guiScreenServer, "disconnect.lost", reason));
806
            }
807
        }
808
        else
809
        {
810
            this.gameController.displayGuiScreen(new GuiDisconnected(new GuiMultiplayer(new GuiMainMenu()), "disconnect.lost", reason));
811
        }
812
    }
813
814
    public void addToSendQueue(Packet p_147297_1_)
815
    {
816
        this.netManager.sendPacket(p_147297_1_);
817
    }
818
819
    public void handleCollectItem(S0DPacketCollectItem packetIn)
820
    {
821
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
822
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getCollectedItemEntityID());
823
        EntityLivingBase entitylivingbase = (EntityLivingBase)this.clientWorldController.getEntityByID(packetIn.getEntityID());
824
825
        if (entitylivingbase == null)
826
        {
827
            entitylivingbase = this.gameController.thePlayer;
828
        }
829
830
        if (entity != null)
831
        {
832
            if (entity instanceof EntityXPOrb)
833
            {
834
                this.clientWorldController.playSoundAtEntity(entity, "random.orb", 0.2F, ((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F);
835
            }
836
            else
837
            {
838
                this.clientWorldController.playSoundAtEntity(entity, "random.pop", 0.2F, ((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F);
839
            }
840
841
            this.gameController.effectRenderer.addEffect(new EntityPickupFX(this.clientWorldController, entity, entitylivingbase, 0.5F));
842
            this.clientWorldController.removeEntityFromWorld(packetIn.getCollectedItemEntityID());
843
        }
844
    }
845
846
    /**
847
     * Prints a chatmessage in the chat GUI
848
     */
849
    public void handleChat(S02PacketChat packetIn)
850
    {
851
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
852
853
        if (packetIn.getType() == 2)
854
        {
855
            this.gameController.ingameGUI.setRecordPlaying(packetIn.getChatComponent(), false);
856
        }
857
        else
858
        {
859
            this.gameController.ingameGUI.getChatGUI().printChatMessage(packetIn.getChatComponent());
860
        }
861
    }
862
863
    /**
864
     * Renders a specified animation: Waking up a player, a living entity swinging its currently held item, being hurt
865
     * or receiving a critical hit by normal or magical means
866
     */
867
    public void handleAnimation(S0BPacketAnimation packetIn)
868
    {
869
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
870
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID());
871
872
        if (entity != null)
873
        {
874
            if (packetIn.getAnimationType() == 0)
875
            {
876
                EntityLivingBase entitylivingbase = (EntityLivingBase)entity;
877
                entitylivingbase.swingItem();
878
            }
879
            else if (packetIn.getAnimationType() == 1)
880
            {
881
                entity.performHurtAnimation();
882
            }
883
            else if (packetIn.getAnimationType() == 2)
884
            {
885
                EntityPlayer entityplayer = (EntityPlayer)entity;
886
                entityplayer.wakeUpPlayer(false, false, false);
887
            }
888
            else if (packetIn.getAnimationType() == 4)
889
            {
890
                this.gameController.effectRenderer.emitParticleAtEntity(entity, EnumParticleTypes.CRIT);
891
            }
892
            else if (packetIn.getAnimationType() == 5)
893
            {
894
                this.gameController.effectRenderer.emitParticleAtEntity(entity, EnumParticleTypes.CRIT_MAGIC);
895
            }
896
        }
897
    }
898
899
    /**
900
     * Retrieves the player identified by the packet, puts him to sleep if possible (and flags whether all players are
901
     * asleep)
902
     */
903
    public void handleUseBed(S0APacketUseBed packetIn)
904
    {
905
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
906
        packetIn.getPlayer(this.clientWorldController).trySleep(packetIn.getBedPosition());
907
    }
908
909
    /**
910
     * Spawns the mob entity at the specified location, with the specified rotation, momentum and type. Updates the
911
     * entities Datawatchers with the entity metadata specified in the packet
912
     */
913
    public void handleSpawnMob(S0FPacketSpawnMob packetIn)
914
    {
915
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
916
        double d0 = (double)packetIn.getX() / 32.0D;
917
        double d1 = (double)packetIn.getY() / 32.0D;
918
        double d2 = (double)packetIn.getZ() / 32.0D;
919
        float f = (float)(packetIn.getYaw() * 360) / 256.0F;
920
        float f1 = (float)(packetIn.getPitch() * 360) / 256.0F;
921
        EntityLivingBase entitylivingbase = (EntityLivingBase)EntityList.createEntityByID(packetIn.getEntityType(), this.gameController.theWorld);
922
        entitylivingbase.serverPosX = packetIn.getX();
923
        entitylivingbase.serverPosY = packetIn.getY();
924
        entitylivingbase.serverPosZ = packetIn.getZ();
925
        entitylivingbase.renderYawOffset = entitylivingbase.rotationYawHead = (float)(packetIn.getHeadPitch() * 360) / 256.0F;
926
        Entity[] aentity = entitylivingbase.getParts();
927
928
        if (aentity != null)
929
        {
930
            int i = packetIn.getEntityID() - entitylivingbase.getEntityId();
931
932
            for (int j = 0; j < aentity.length; ++j)
933
            {
934
                aentity[j].setEntityId(aentity[j].getEntityId() + i);
935
            }
936
        }
937
938
        entitylivingbase.setEntityId(packetIn.getEntityID());
939
        entitylivingbase.setPositionAndRotation(d0, d1, d2, f, f1);
940
        entitylivingbase.motionX = (double)((float)packetIn.getVelocityX() / 8000.0F);
941
        entitylivingbase.motionY = (double)((float)packetIn.getVelocityY() / 8000.0F);
942
        entitylivingbase.motionZ = (double)((float)packetIn.getVelocityZ() / 8000.0F);
943
        this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entitylivingbase);
944
        List<DataWatcher.WatchableObject> list = packetIn.func_149027_c();
945
946
        if (list != null)
947
        {
948
            entitylivingbase.getDataWatcher().updateWatchedObjectsFromList(list);
949
        }
950
    }
951
952
    public void handleTimeUpdate(S03PacketTimeUpdate packetIn)
953
    {
954
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
955
        this.gameController.theWorld.setTotalWorldTime(packetIn.getTotalWorldTime());
956
        this.gameController.theWorld.setWorldTime(packetIn.getWorldTime());
957
    }
958
959
    public void handleSpawnPosition(S05PacketSpawnPosition packetIn)
960
    {
961
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
962
        this.gameController.thePlayer.setSpawnPoint(packetIn.getSpawnPos(), true);
963
        this.gameController.theWorld.getWorldInfo().setSpawn(packetIn.getSpawnPos());
964
    }
965
966
    public void handleEntityAttach(S1BPacketEntityAttach packetIn)
967
    {
968
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
969
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
970
        Entity entity1 = this.clientWorldController.getEntityByID(packetIn.getVehicleEntityId());
971
972
        if (packetIn.getLeash() == 0)
973
        {
974
            boolean flag = false;
975
976
            if (packetIn.getEntityId() == this.gameController.thePlayer.getEntityId())
977
            {
978
                entity = this.gameController.thePlayer;
979
980
                if (entity1 instanceof EntityBoat)
981
                {
982
                    ((EntityBoat)entity1).setIsBoatEmpty(false);
983
                }
984
985
                flag = entity.ridingEntity == null && entity1 != null;
986
            }
987
            else if (entity1 instanceof EntityBoat)
988
            {
989
                ((EntityBoat)entity1).setIsBoatEmpty(true);
990
            }
991
992
            if (entity == null)
993
            {
994
                return;
995
            }
996
997
            entity.mountEntity(entity1);
998
999
            if (flag)
1000
            {
1001
                GameSettings gamesettings = this.gameController.gameSettings;
1002
                this.gameController.ingameGUI.setRecordPlaying(I18n.format("mount.onboard", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindSneak.getKeyCode())}), false);
1003
            }
1004
        }
1005
        else if (packetIn.getLeash() == 1 && entity instanceof EntityLiving)
1006
        {
1007
            if (entity1 != null)
1008
            {
1009
                ((EntityLiving)entity).setLeashedToEntity(entity1, false);
1010
            }
1011
            else
1012
            {
1013
                ((EntityLiving)entity).clearLeashed(false, false);
1014
            }
1015
        }
1016
    }
1017
1018
    /**
1019
     * Invokes the entities' handleUpdateHealth method which is implemented in LivingBase (hurt/death),
1020
     * MinecartMobSpawner (spawn delay), FireworkRocket & MinecartTNT (explosion), IronGolem (throwing,...), Witch
1021
     * (spawn particles), Zombie (villager transformation), Animal (breeding mode particles), Horse (breeding/smoke
1022
     * particles), Sheep (...), Tameable (...), Villager (particles for breeding mode, angry and happy), Wolf (...)
1023
     */
1024
    public void handleEntityStatus(S19PacketEntityStatus packetIn)
1025
    {
1026
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1027
        Entity entity = packetIn.getEntity(this.clientWorldController);
1028
1029
        if (entity != null)
1030
        {
1031
            if (packetIn.getOpCode() == 21)
1032
            {
1033
                this.gameController.getSoundHandler().playSound(new GuardianSound((EntityGuardian)entity));
1034
            }
1035
            else
1036
            {
1037
                entity.handleStatusUpdate(packetIn.getOpCode());
1038
            }
1039
        }
1040
    }
1041
1042
    public void handleUpdateHealth(S06PacketUpdateHealth packetIn)
1043
    {
1044
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1045
        this.gameController.thePlayer.setPlayerSPHealth(packetIn.getHealth());
1046
        this.gameController.thePlayer.getFoodStats().setFoodLevel(packetIn.getFoodLevel());
1047
        this.gameController.thePlayer.getFoodStats().setFoodSaturationLevel(packetIn.getSaturationLevel());
1048
    }
1049
1050
    public void handleSetExperience(S1FPacketSetExperience packetIn)
1051
    {
1052
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1053
        this.gameController.thePlayer.setXPStats(packetIn.func_149397_c(), packetIn.getTotalExperience(), packetIn.getLevel());
1054
    }
1055
1056
    public void handleRespawn(S07PacketRespawn packetIn)
1057
    {
1058
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1059
1060
        if (packetIn.getDimensionID() != this.gameController.thePlayer.dimension)
1061
        {
1062
            this.doneLoadingTerrain = false;
1063
            Scoreboard scoreboard = this.clientWorldController.getScoreboard();
1064
            this.clientWorldController = new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, this.gameController.theWorld.getWorldInfo().isHardcoreModeEnabled(), packetIn.getWorldType()), packetIn.getDimensionID(), packetIn.getDifficulty(), this.gameController.mcProfiler);
1065
            this.clientWorldController.setWorldScoreboard(scoreboard);
1066
            this.gameController.loadWorld(this.clientWorldController);
1067
            this.gameController.thePlayer.dimension = packetIn.getDimensionID();
1068
            this.gameController.displayGuiScreen(new GuiDownloadTerrain(this));
1069
        }
1070
1071
        this.gameController.setDimensionAndSpawnPlayer(packetIn.getDimensionID());
1072
        this.gameController.playerController.setGameType(packetIn.getGameType());
1073
    }
1074
1075
    /**
1076
     * Initiates a new explosion (sound, particles, drop spawn) for the affected blocks indicated by the packet.
1077
     */
1078
    public void handleExplosion(S27PacketExplosion packetIn)
1079
    {
1080
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1081
        Explosion explosion = new Explosion(this.gameController.theWorld, (Entity)null, packetIn.getX(), packetIn.getY(), packetIn.getZ(), packetIn.getStrength(), packetIn.getAffectedBlockPositions());
1082
        explosion.doExplosionB(true);
1083
        this.gameController.thePlayer.motionX += (double)packetIn.func_149149_c();
1084
        this.gameController.thePlayer.motionY += (double)packetIn.func_149144_d();
1085
        this.gameController.thePlayer.motionZ += (double)packetIn.func_149147_e();
1086
    }
1087
1088
    /**
1089
     * Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table,
1090
     * Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse
1091
     */
1092
    public void handleOpenWindow(S2DPacketOpenWindow packetIn)
1093
    {
1094
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1095
        EntityPlayerSP entityplayersp = this.gameController.thePlayer;
1096
1097
        if ("minecraft:container".equals(packetIn.getGuiId()))
1098
        {
1099
            entityplayersp.displayGUIChest(new InventoryBasic(packetIn.getWindowTitle(), packetIn.getSlotCount()));
1100
            entityplayersp.openContainer.windowId = packetIn.getWindowId();
1101
        }
1102
        else if ("minecraft:villager".equals(packetIn.getGuiId()))
1103
        {
1104
            entityplayersp.displayVillagerTradeGui(new NpcMerchant(entityplayersp, packetIn.getWindowTitle()));
1105
            entityplayersp.openContainer.windowId = packetIn.getWindowId();
1106
        }
1107
        else if ("EntityHorse".equals(packetIn.getGuiId()))
1108
        {
1109
            Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
1110
1111
            if (entity instanceof EntityHorse)
1112
            {
1113
                entityplayersp.displayGUIHorse((EntityHorse)entity, new AnimalChest(packetIn.getWindowTitle(), packetIn.getSlotCount()));
1114
                entityplayersp.openContainer.windowId = packetIn.getWindowId();
1115
            }
1116
        }
1117
        else if (!packetIn.hasSlots())
1118
        {
1119
            entityplayersp.displayGui(new LocalBlockIntercommunication(packetIn.getGuiId(), packetIn.getWindowTitle()));
1120
            entityplayersp.openContainer.windowId = packetIn.getWindowId();
1121
        }
1122
        else
1123
        {
1124
            ContainerLocalMenu containerlocalmenu = new ContainerLocalMenu(packetIn.getGuiId(), packetIn.getWindowTitle(), packetIn.getSlotCount());
1125
            entityplayersp.displayGUIChest(containerlocalmenu);
1126
            entityplayersp.openContainer.windowId = packetIn.getWindowId();
1127
        }
1128
    }
1129
1130
    /**
1131
     * Handles pickin up an ItemStack or dropping one in your inventory or an open (non-creative) container
1132
     */
1133
    public void handleSetSlot(S2FPacketSetSlot packetIn)
1134
    {
1135
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1136
        EntityPlayer entityplayer = this.gameController.thePlayer;
1137
1138
        if (packetIn.func_149175_c() == -1)
1139
        {
1140
            entityplayer.inventory.setItemStack(packetIn.func_149174_e());
1141
        }
1142
        else
1143
        {
1144
            boolean flag = false;
1145
1146
            if (this.gameController.currentScreen instanceof GuiContainerCreative)
1147
            {
1148
                GuiContainerCreative guicontainercreative = (GuiContainerCreative)this.gameController.currentScreen;
1149
                flag = guicontainercreative.getSelectedTabIndex() != CreativeTabs.tabInventory.getTabIndex();
1150
            }
1151
1152
            if (packetIn.func_149175_c() == 0 && packetIn.func_149173_d() >= 36 && packetIn.func_149173_d() < 45)
1153
            {
1154
                ItemStack itemstack = entityplayer.inventoryContainer.getSlot(packetIn.func_149173_d()).getStack();
1155
1156
                if (packetIn.func_149174_e() != null && (itemstack == null || itemstack.stackSize < packetIn.func_149174_e().stackSize))
1157
                {
1158
                    packetIn.func_149174_e().animationsToGo = 5;
1159
                }
1160
1161
                entityplayer.inventoryContainer.putStackInSlot(packetIn.func_149173_d(), packetIn.func_149174_e());
1162
            }
1163
            else if (packetIn.func_149175_c() == entityplayer.openContainer.windowId && (packetIn.func_149175_c() != 0 || !flag))
1164
            {
1165
                entityplayer.openContainer.putStackInSlot(packetIn.func_149173_d(), packetIn.func_149174_e());
1166
            }
1167
        }
1168
    }
1169
1170
    /**
1171
     * Verifies that the server and client are synchronized with respect to the inventory/container opened by the player
1172
     * and confirms if it is the case.
1173
     */
1174
    public void handleConfirmTransaction(S32PacketConfirmTransaction packetIn)
1175
    {
1176
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1177
        Container container = null;
1178
        EntityPlayer entityplayer = this.gameController.thePlayer;
1179
1180
        if (packetIn.getWindowId() == 0)
1181
        {
1182
            container = entityplayer.inventoryContainer;
1183
        }
1184
        else if (packetIn.getWindowId() == entityplayer.openContainer.windowId)
1185
        {
1186
            container = entityplayer.openContainer;
1187
        }
1188
1189
        if (container != null && !packetIn.func_148888_e())
1190
        {
1191
            this.addToSendQueue(new C0FPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), true));
1192
        }
1193
    }
1194
1195
    /**
1196
     * Handles the placement of a specified ItemStack in a specified container/inventory slot
1197
     */
1198
    public void handleWindowItems(S30PacketWindowItems packetIn)
1199
    {
1200
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1201
        EntityPlayer entityplayer = this.gameController.thePlayer;
1202
1203
        if (packetIn.func_148911_c() == 0)
1204
        {
1205
            entityplayer.inventoryContainer.putStacksInSlots(packetIn.getItemStacks());
1206
        }
1207
        else if (packetIn.func_148911_c() == entityplayer.openContainer.windowId)
1208
        {
1209
            entityplayer.openContainer.putStacksInSlots(packetIn.getItemStacks());
1210
        }
1211
    }
1212
1213
    /**
1214
     * Creates a sign in the specified location if it didn't exist and opens the GUI to edit its text
1215
     */
1216
    public void handleSignEditorOpen(S36PacketSignEditorOpen packetIn)
1217
    {
1218
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1219
        TileEntity tileentity = this.clientWorldController.getTileEntity(packetIn.getSignPosition());
1220
1221
        if (!(tileentity instanceof TileEntitySign))
1222
        {
1223
            tileentity = new TileEntitySign();
1224
            tileentity.setWorldObj(this.clientWorldController);
1225
            tileentity.setPos(packetIn.getSignPosition());
1226
        }
1227
1228
        this.gameController.thePlayer.openEditSign((TileEntitySign)tileentity);
1229
    }
1230
1231
    /**
1232
     * Updates a specified sign with the specified text lines
1233
     */
1234
    public void handleUpdateSign(S33PacketUpdateSign packetIn)
1235
    {
1236
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1237
        boolean flag = false;
1238
1239
        if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos()))
1240
        {
1241
            TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos());
1242
1243
            if (tileentity instanceof TileEntitySign)
1244
            {
1245
                TileEntitySign tileentitysign = (TileEntitySign)tileentity;
1246
1247
                if (tileentitysign.getIsEditable())
1248
                {
1249
                    System.arraycopy(packetIn.getLines(), 0, tileentitysign.signText, 0, 4);
1250
                    tileentitysign.markDirty();
1251
                }
1252
1253
                flag = true;
1254
            }
1255
        }
1256
1257
        if (!flag && this.gameController.thePlayer != null)
1258
        {
1259
            this.gameController.thePlayer.addChatMessage(new ChatComponentText("Unable to locate sign at " + packetIn.getPos().getX() + ", " + packetIn.getPos().getY() + ", " + packetIn.getPos().getZ()));
1260
        }
1261
    }
1262
1263
    /**
1264
     * Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks,
1265
     * beacons, skulls, flowerpot
1266
     */
1267
    public void handleUpdateTileEntity(S35PacketUpdateTileEntity packetIn)
1268
    {
1269
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1270
1271
        if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos()))
1272
        {
1273
            TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos());
1274
            int i = packetIn.getTileEntityType();
1275
1276
            if (i == 1 && tileentity instanceof TileEntityMobSpawner || i == 2 && tileentity instanceof TileEntityCommandBlock || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner)
1277
            {
1278
                tileentity.readFromNBT(packetIn.getNbtCompound());
1279
            }
1280
        }
1281
    }
1282
1283
    /**
1284
     * Sets the progressbar of the opened window to the specified value
1285
     */
1286
    public void handleWindowProperty(S31PacketWindowProperty packetIn)
1287
    {
1288
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1289
        EntityPlayer entityplayer = this.gameController.thePlayer;
1290
1291
        if (entityplayer.openContainer != null && entityplayer.openContainer.windowId == packetIn.getWindowId())
1292
        {
1293
            entityplayer.openContainer.updateProgressBar(packetIn.getVarIndex(), packetIn.getVarValue());
1294
        }
1295
    }
1296
1297
    public void handleEntityEquipment(S04PacketEntityEquipment packetIn)
1298
    {
1299
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1300
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID());
1301
1302
        if (entity != null)
1303
        {
1304
            entity.setCurrentItemOrArmor(packetIn.getEquipmentSlot(), packetIn.getItemStack());
1305
        }
1306
    }
1307
1308
    /**
1309
     * Resets the ItemStack held in hand and closes the window that is opened
1310
     */
1311
    public void handleCloseWindow(S2EPacketCloseWindow packetIn)
1312
    {
1313
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1314
        this.gameController.thePlayer.closeScreenAndDropStack();
1315
    }
1316
1317
    /**
1318
     * Triggers Block.onBlockEventReceived, which is implemented in BlockPistonBase for extension/retraction, BlockNote
1319
     * for setting the instrument (including audiovisual feedback) and in BlockContainer to set the number of players
1320
     * accessing a (Ender)Chest
1321
     */
1322
    public void handleBlockAction(S24PacketBlockAction packetIn)
1323
    {
1324
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1325
        this.gameController.theWorld.addBlockEvent(packetIn.getBlockPosition(), packetIn.getBlockType(), packetIn.getData1(), packetIn.getData2());
1326
    }
1327
1328
    /**
1329
     * Updates all registered IWorldAccess instances with destroyBlockInWorldPartially
1330
     */
1331
    public void handleBlockBreakAnim(S25PacketBlockBreakAnim packetIn)
1332
    {
1333
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1334
        this.gameController.theWorld.sendBlockBreakProgress(packetIn.getBreakerId(), packetIn.getPosition(), packetIn.getProgress());
1335
    }
1336
1337
    public void handleMapChunkBulk(S26PacketMapChunkBulk packetIn)
1338
    {
1339
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1340
1341
        for (int i = 0; i < packetIn.getChunkCount(); ++i)
1342
        {
1343
            int j = packetIn.getChunkX(i);
1344
            int k = packetIn.getChunkZ(i);
1345
            this.clientWorldController.doPreChunk(j, k, true);
1346
            this.clientWorldController.invalidateBlockReceiveRegion(j << 4, 0, k << 4, (j << 4) + 15, 256, (k << 4) + 15);
1347
            Chunk chunk = this.clientWorldController.getChunkFromChunkCoords(j, k);
1348
            chunk.fillChunk(packetIn.getChunkBytes(i), packetIn.getChunkSize(i), true);
1349
            this.clientWorldController.markBlockRangeForRenderUpdate(j << 4, 0, k << 4, (j << 4) + 15, 256, (k << 4) + 15);
1350
1351
            if (!(this.clientWorldController.provider instanceof WorldProviderSurface))
1352
            {
1353
                chunk.resetRelightChecks();
1354
            }
1355
        }
1356
    }
1357
1358
    public void handleChangeGameState(S2BPacketChangeGameState packetIn)
1359
    {
1360
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1361
        EntityPlayer entityplayer = this.gameController.thePlayer;
1362
        int i = packetIn.getGameState();
1363
        float f = packetIn.func_149137_d();
1364
        int j = MathHelper.floor_float(f + 0.5F);
1365
1366
        if (i >= 0 && i < S2BPacketChangeGameState.MESSAGE_NAMES.length && S2BPacketChangeGameState.MESSAGE_NAMES[i] != null)
1367
        {
1368
            entityplayer.addChatComponentMessage(new ChatComponentTranslation(S2BPacketChangeGameState.MESSAGE_NAMES[i], new Object[0]));
1369
        }
1370
1371
        if (i == 1)
1372
        {
1373
            this.clientWorldController.getWorldInfo().setRaining(true);
1374
            this.clientWorldController.setRainStrength(0.0F);
1375
        }
1376
        else if (i == 2)
1377
        {
1378
            this.clientWorldController.getWorldInfo().setRaining(false);
1379
            this.clientWorldController.setRainStrength(1.0F);
1380
        }
1381
        else if (i == 3)
1382
        {
1383
            this.gameController.playerController.setGameType(WorldSettings.GameType.getByID(j));
1384
        }
1385
        else if (i == 4)
1386
        {
1387
            this.gameController.displayGuiScreen(new GuiWinGame());
1388
        }
1389
        else if (i == 5)
1390
        {
1391
            GameSettings gamesettings = this.gameController.gameSettings;
1392
1393
            if (f == 0.0F)
1394
            {
1395
                this.gameController.displayGuiScreen(new GuiScreenDemo());
1396
            }
1397
            else if (f == 101.0F)
1398
            {
1399
                this.gameController.ingameGUI.getChatGUI().printChatMessage(new ChatComponentTranslation("demo.help.movement", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindForward.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindLeft.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindBack.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindRight.getKeyCode())}));
1400
            }
1401
            else if (f == 102.0F)
1402
            {
1403
                this.gameController.ingameGUI.getChatGUI().printChatMessage(new ChatComponentTranslation("demo.help.jump", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindJump.getKeyCode())}));
1404
            }
1405
            else if (f == 103.0F)
1406
            {
1407
                this.gameController.ingameGUI.getChatGUI().printChatMessage(new ChatComponentTranslation("demo.help.inventory", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindInventory.getKeyCode())}));
1408
            }
1409
        }
1410
        else if (i == 6)
1411
        {
1412
            this.clientWorldController.playSound(entityplayer.posX, entityplayer.posY + (double)entityplayer.getEyeHeight(), entityplayer.posZ, "random.successful_hit", 0.18F, 0.45F, false);
1413
        }
1414
        else if (i == 7)
1415
        {
1416
            this.clientWorldController.setRainStrength(f);
1417
        }
1418
        else if (i == 8)
1419
        {
1420
            this.clientWorldController.setThunderStrength(f);
1421
        }
1422
        else if (i == 10)
1423
        {
1424
            this.clientWorldController.spawnParticle(EnumParticleTypes.MOB_APPEARANCE, entityplayer.posX, entityplayer.posY, entityplayer.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
1425
            this.clientWorldController.playSound(entityplayer.posX, entityplayer.posY, entityplayer.posZ, "mob.guardian.curse", 1.0F, 1.0F, false);
1426
        }
1427
    }
1428
1429
    /**
1430
     * Updates the worlds MapStorage with the specified MapData for the specified map-identifier and invokes a
1431
     * MapItemRenderer for it
1432
     */
1433
    public void handleMaps(S34PacketMaps packetIn)
1434
    {
1435
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1436
        MapData mapdata = ItemMap.loadMapData(packetIn.getMapId(), this.gameController.theWorld);
1437
        packetIn.setMapdataTo(mapdata);
1438
        this.gameController.entityRenderer.getMapItemRenderer().updateMapTexture(mapdata);
1439
    }
1440
1441
    public void handleEffect(S28PacketEffect packetIn)
1442
    {
1443
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1444
1445
        if (packetIn.isSoundServerwide())
1446
        {
1447
            this.gameController.theWorld.playBroadcastSound(packetIn.getSoundType(), packetIn.getSoundPos(), packetIn.getSoundData());
1448
        }
1449
        else
1450
        {
1451
            this.gameController.theWorld.playAuxSFX(packetIn.getSoundType(), packetIn.getSoundPos(), packetIn.getSoundData());
1452
        }
1453
    }
1454
1455
    /**
1456
     * Updates the players statistics or achievements
1457
     */
1458
    public void handleStatistics(S37PacketStatistics packetIn)
1459
    {
1460
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1461
        boolean flag = false;
1462
1463
        for (Entry<StatBase, Integer> entry : packetIn.func_148974_c().entrySet())
1464
        {
1465
            StatBase statbase = (StatBase)entry.getKey();
1466
            int i = ((Integer)entry.getValue()).intValue();
1467
1468
            if (statbase.isAchievement() && i > 0)
1469
            {
1470
                if (this.field_147308_k && this.gameController.thePlayer.getStatFileWriter().readStat(statbase) == 0)
1471
                {
1472
                    Achievement achievement = (Achievement)statbase;
1473
                    this.gameController.guiAchievement.displayAchievement(achievement);
1474
                    this.gameController.getTwitchStream().func_152911_a(new MetadataAchievement(achievement), 0L);
1475
1476
                    if (statbase == AchievementList.openInventory)
1477
                    {
1478
                        this.gameController.gameSettings.showInventoryAchievementHint = false;
1479
                        this.gameController.gameSettings.saveOptions();
1480
                    }
1481
                }
1482
1483
                flag = true;
1484
            }
1485
1486
            this.gameController.thePlayer.getStatFileWriter().unlockAchievement(this.gameController.thePlayer, statbase, i);
1487
        }
1488
1489
        if (!this.field_147308_k && !flag && this.gameController.gameSettings.showInventoryAchievementHint)
1490
        {
1491
            this.gameController.guiAchievement.displayUnformattedAchievement(AchievementList.openInventory);
1492
        }
1493
1494
        this.field_147308_k = true;
1495
1496
        if (this.gameController.currentScreen instanceof IProgressMeter)
1497
        {
1498
            ((IProgressMeter)this.gameController.currentScreen).doneLoading();
1499
        }
1500
    }
1501
1502
    public void handleEntityEffect(S1DPacketEntityEffect packetIn)
1503
    {
1504
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1505
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
1506
1507
        if (entity instanceof EntityLivingBase)
1508
        {
1509
            PotionEffect potioneffect = new PotionEffect(packetIn.getEffectId(), packetIn.getDuration(), packetIn.getAmplifier(), false, packetIn.func_179707_f());
1510
            potioneffect.setPotionDurationMax(packetIn.func_149429_c());
1511
            ((EntityLivingBase)entity).addPotionEffect(potioneffect);
1512
        }
1513
    }
1514
1515
    public void handleCombatEvent(S42PacketCombatEvent packetIn)
1516
    {
1517
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1518
        Entity entity = this.clientWorldController.getEntityByID(packetIn.field_179775_c);
1519
        EntityLivingBase entitylivingbase = entity instanceof EntityLivingBase ? (EntityLivingBase)entity : null;
1520
1521
        if (packetIn.eventType == S42PacketCombatEvent.Event.END_COMBAT)
1522
        {
1523
            long i = (long)(1000 * packetIn.field_179772_d / 20);
1524
            MetadataCombat metadatacombat = new MetadataCombat(this.gameController.thePlayer, entitylivingbase);
1525
            this.gameController.getTwitchStream().func_176026_a(metadatacombat, 0L - i, 0L);
1526
        }
1527
        else if (packetIn.eventType == S42PacketCombatEvent.Event.ENTITY_DIED)
1528
        {
1529
            Entity entity1 = this.clientWorldController.getEntityByID(packetIn.field_179774_b);
1530
1531
            if (entity1 instanceof EntityPlayer)
1532
            {
1533
                MetadataPlayerDeath metadataplayerdeath = new MetadataPlayerDeath((EntityPlayer)entity1, entitylivingbase);
1534
                metadataplayerdeath.func_152807_a(packetIn.deathMessage);
1535
                this.gameController.getTwitchStream().func_152911_a(metadataplayerdeath, 0L);
1536
            }
1537
        }
1538
    }
1539
1540
    public void handleServerDifficulty(S41PacketServerDifficulty packetIn)
1541
    {
1542
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1543
        this.gameController.theWorld.getWorldInfo().setDifficulty(packetIn.getDifficulty());
1544
        this.gameController.theWorld.getWorldInfo().setDifficultyLocked(packetIn.isDifficultyLocked());
1545
    }
1546
1547
    public void handleCamera(S43PacketCamera packetIn)
1548
    {
1549
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1550
        Entity entity = packetIn.getEntity(this.clientWorldController);
1551
1552
        if (entity != null)
1553
        {
1554
            this.gameController.setRenderViewEntity(entity);
1555
        }
1556
    }
1557
1558
    public void handleWorldBorder(S44PacketWorldBorder packetIn)
1559
    {
1560
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1561
        packetIn.func_179788_a(this.clientWorldController.getWorldBorder());
1562
    }
1563
1564
    @SuppressWarnings("incomplete-switch")
1565
    public void handleTitle(S45PacketTitle packetIn)
1566
    {
1567
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1568
        S45PacketTitle.Type s45packettitle$type = packetIn.getType();
1569
        String s = null;
1570
        String s1 = null;
1571
        String s2 = packetIn.getMessage() != null ? packetIn.getMessage().getFormattedText() : "";
1572
1573
        switch (s45packettitle$type)
1574
        {
1575
            case TITLE:
1576
                s = s2;
1577
                break;
1578
1579
            case SUBTITLE:
1580
                s1 = s2;
1581
                break;
1582
1583
            case RESET:
1584
                this.gameController.ingameGUI.displayTitle("", "", -1, -1, -1);
1585
                this.gameController.ingameGUI.setDefaultTitlesTimes();
1586
                return;
1587
        }
1588
1589
        this.gameController.ingameGUI.displayTitle(s, s1, packetIn.getFadeInTime(), packetIn.getDisplayTime(), packetIn.getFadeOutTime());
1590
    }
1591
1592
    public void handleSetCompressionLevel(S46PacketSetCompressionLevel packetIn)
1593
    {
1594
        if (!this.netManager.isLocalChannel())
1595
        {
1596
            this.netManager.setCompressionTreshold(packetIn.getThreshold());
1597
        }
1598
    }
1599
1600
    public void handlePlayerListHeaderFooter(S47PacketPlayerListHeaderFooter packetIn)
1601
    {
1602
        this.gameController.ingameGUI.getTabList().setHeader(packetIn.getHeader().getFormattedText().length() == 0 ? null : packetIn.getHeader());
1603
        this.gameController.ingameGUI.getTabList().setFooter(packetIn.getFooter().getFormattedText().length() == 0 ? null : packetIn.getFooter());
1604
    }
1605
1606
    public void handleRemoveEntityEffect(S1EPacketRemoveEntityEffect packetIn)
1607
    {
1608
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1609
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
1610
1611
        if (entity instanceof EntityLivingBase)
1612
        {
1613
            ((EntityLivingBase)entity).removePotionEffectClient(packetIn.getEffectId());
1614
        }
1615
    }
1616
1617
    @SuppressWarnings("incomplete-switch")
1618
    public void handlePlayerListItem(S38PacketPlayerListItem packetIn)
1619
    {
1620
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1621
1622
        for (S38PacketPlayerListItem.AddPlayerData s38packetplayerlistitem$addplayerdata : packetIn.getEntries())
1623
        {
1624
            if (packetIn.getAction() == S38PacketPlayerListItem.Action.REMOVE_PLAYER)
1625
            {
1626
                this.playerInfoMap.remove(s38packetplayerlistitem$addplayerdata.getProfile().getId());
1627
            }
1628
            else
1629
            {
1630
                NetworkPlayerInfo networkplayerinfo = (NetworkPlayerInfo)this.playerInfoMap.get(s38packetplayerlistitem$addplayerdata.getProfile().getId());
1631
1632
                if (packetIn.getAction() == S38PacketPlayerListItem.Action.ADD_PLAYER)
1633
                {
1634
                    networkplayerinfo = new NetworkPlayerInfo(s38packetplayerlistitem$addplayerdata);
1635
                    this.playerInfoMap.put(networkplayerinfo.getGameProfile().getId(), networkplayerinfo);
1636
                }
1637
1638
                if (networkplayerinfo != null)
1639
                {
1640
                    switch (packetIn.getAction())
1641
                    {
1642
                        case ADD_PLAYER:
1643
                            networkplayerinfo.setGameType(s38packetplayerlistitem$addplayerdata.getGameMode());
1644
                            networkplayerinfo.setResponseTime(s38packetplayerlistitem$addplayerdata.getPing());
1645
                            break;
1646
1647
                        case UPDATE_GAME_MODE:
1648
                            networkplayerinfo.setGameType(s38packetplayerlistitem$addplayerdata.getGameMode());
1649
                            break;
1650
1651
                        case UPDATE_LATENCY:
1652
                            networkplayerinfo.setResponseTime(s38packetplayerlistitem$addplayerdata.getPing());
1653
                            break;
1654
1655
                        case UPDATE_DISPLAY_NAME:
1656
                            networkplayerinfo.setDisplayName(s38packetplayerlistitem$addplayerdata.getDisplayName());
1657
                    }
1658
                }
1659
            }
1660
        }
1661
    }
1662
1663
    public void handleKeepAlive(S00PacketKeepAlive packetIn)
1664
    {
1665
        this.addToSendQueue(new C00PacketKeepAlive(packetIn.func_149134_c()));
1666
    }
1667
1668
    public void handlePlayerAbilities(S39PacketPlayerAbilities packetIn)
1669
    {
1670
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1671
        EntityPlayer entityplayer = this.gameController.thePlayer;
1672
        entityplayer.capabilities.isFlying = packetIn.isFlying();
1673
        entityplayer.capabilities.isCreativeMode = packetIn.isCreativeMode();
1674
        entityplayer.capabilities.disableDamage = packetIn.isInvulnerable();
1675
        entityplayer.capabilities.allowFlying = packetIn.isAllowFlying();
1676
        entityplayer.capabilities.setFlySpeed(packetIn.getFlySpeed());
1677
        entityplayer.capabilities.setPlayerWalkSpeed(packetIn.getWalkSpeed());
1678
    }
1679
1680
    /**
1681
     * Displays the available command-completion options the server knows of
1682
     */
1683
    public void handleTabComplete(S3APacketTabComplete packetIn)
1684
    {
1685
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1686
        String[] astring = packetIn.func_149630_c();
1687
1688
        if (this.gameController.currentScreen instanceof GuiChat)
1689
        {
1690
            GuiChat guichat = (GuiChat)this.gameController.currentScreen;
1691
            guichat.onAutocompleteResponse(astring);
1692
        }
1693
    }
1694
1695
    public void handleSoundEffect(S29PacketSoundEffect packetIn)
1696
    {
1697
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1698
        this.gameController.theWorld.playSound(packetIn.getX(), packetIn.getY(), packetIn.getZ(), packetIn.getSoundName(), packetIn.getVolume(), packetIn.getPitch(), false);
1699
    }
1700
1701
    public void handleResourcePack(S48PacketResourcePackSend packetIn)
1702
    {
1703
        final String s = packetIn.getURL();
1704
        final String s1 = packetIn.getHash();
1705
1706
        if (s.startsWith("level://"))
1707
        {
1708
            String s2 = s.substring("level://".length());
1709
            File file1 = new File(this.gameController.mcDataDir, "saves");
1710
            File file2 = new File(file1, s2);
1711
1712
            if (file2.isFile())
1713
            {
1714
                this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.ACCEPTED));
1715
                Futures.addCallback(this.gameController.getResourcePackRepository().setResourcePackInstance(file2), new FutureCallback<Object>()
1716
                {
1717
                    public void onSuccess(Object p_onSuccess_1_)
1718
                    {
1719
                        NetHandlerPlayClient.this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
1720
                    }
1721
                    public void onFailure(Throwable p_onFailure_1_)
1722
                    {
1723
                        NetHandlerPlayClient.this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
1724
                    }
1725
                });
1726
            }
1727
            else
1728
            {
1729
                this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
1730
            }
1731
        }
1732
        else
1733
        {
1734
            if (this.gameController.getCurrentServerData() != null && this.gameController.getCurrentServerData().getResourceMode() == ServerData.ServerResourceMode.ENABLED)
1735
            {
1736
                this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.ACCEPTED));
1737
                Futures.addCallback(this.gameController.getResourcePackRepository().downloadResourcePack(s, s1), new FutureCallback<Object>()
1738
                {
1739
                    public void onSuccess(Object p_onSuccess_1_)
1740
                    {
1741
                        NetHandlerPlayClient.this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
1742
                    }
1743
                    public void onFailure(Throwable p_onFailure_1_)
1744
                    {
1745
                        NetHandlerPlayClient.this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
1746
                    }
1747
                });
1748
            }
1749
            else if (this.gameController.getCurrentServerData() != null && this.gameController.getCurrentServerData().getResourceMode() != ServerData.ServerResourceMode.PROMPT)
1750
            {
1751
                this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.DECLINED));
1752
            }
1753
            else
1754
            {
1755
                this.gameController.addScheduledTask(new Runnable()
1756
                {
1757
                    public void run()
1758
                    {
1759
                        NetHandlerPlayClient.this.gameController.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback()
1760
                        {
1761
                            public void confirmClicked(boolean result, int id)
1762
                            {
1763
                                NetHandlerPlayClient.this.gameController = Minecraft.getMinecraft();
1764
1765
                                if (result)
1766
                                {
1767
                                    if (NetHandlerPlayClient.this.gameController.getCurrentServerData() != null)
1768
                                    {
1769
                                        NetHandlerPlayClient.this.gameController.getCurrentServerData().setResourceMode(ServerData.ServerResourceMode.ENABLED);
1770
                                    }
1771
1772
                                    NetHandlerPlayClient.this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.ACCEPTED));
1773
                                    Futures.addCallback(NetHandlerPlayClient.this.gameController.getResourcePackRepository().downloadResourcePack(s, s1), new FutureCallback<Object>()
1774
                                    {
1775
                                        public void onSuccess(Object p_onSuccess_1_)
1776
                                        {
1777
                                            NetHandlerPlayClient.this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
1778
                                        }
1779
                                        public void onFailure(Throwable p_onFailure_1_)
1780
                                        {
1781
                                            NetHandlerPlayClient.this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
1782
                                        }
1783
                                    });
1784
                                }
1785
                                else
1786
                                {
1787
                                    if (NetHandlerPlayClient.this.gameController.getCurrentServerData() != null)
1788
                                    {
1789
                                        NetHandlerPlayClient.this.gameController.getCurrentServerData().setResourceMode(ServerData.ServerResourceMode.DISABLED);
1790
                                    }
1791
1792
                                    NetHandlerPlayClient.this.netManager.sendPacket(new C19PacketResourcePackStatus(s1, C19PacketResourcePackStatus.Action.DECLINED));
1793
                                }
1794
1795
                                ServerList.func_147414_b(NetHandlerPlayClient.this.gameController.getCurrentServerData());
1796
                                NetHandlerPlayClient.this.gameController.displayGuiScreen((GuiScreen)null);
1797
                            }
1798
                        }, I18n.format("multiplayer.texturePrompt.line1", new Object[0]), I18n.format("multiplayer.texturePrompt.line2", new Object[0]), 0));
1799
                    }
1800
                });
1801
            }
1802
        }
1803
    }
1804
1805
    public void handleEntityNBT(S49PacketUpdateEntityNBT packetIn)
1806
    {
1807
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1808
        Entity entity = packetIn.getEntity(this.clientWorldController);
1809
1810
        if (entity != null)
1811
        {
1812
            entity.clientUpdateEntityNBT(packetIn.getTagCompound());
1813
        }
1814
    }
1815
1816
    /**
1817
     * Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
1818
     * acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
1819
     * player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
1820
     * resourcepack for the client to load.
1821
     */
1822
    public void handleCustomPayload(S3FPacketCustomPayload packetIn)
1823
    {
1824
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1825
1826
        if ("MC|TrList".equals(packetIn.getChannelName()))
1827
        {
1828
            PacketBuffer packetbuffer = packetIn.getBufferData();
1829
1830
            try
1831
            {
1832
                int i = packetbuffer.readInt();
1833
                GuiScreen guiscreen = this.gameController.currentScreen;
1834
1835
                if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.thePlayer.openContainer.windowId)
1836
                {
1837
                    IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
1838
                    MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
1839
                    imerchant.setRecipes(merchantrecipelist);
1840
                }
1841
            }
1842
            catch (IOException ioexception)
1843
            {
1844
                logger.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
1845
            }
1846
            finally
1847
            {
1848
                packetbuffer.release();
1849
            }
1850
        }
1851
        else if ("MC|Brand".equals(packetIn.getChannelName()))
1852
        {
1853
            this.gameController.thePlayer.setClientBrand(packetIn.getBufferData().readStringFromBuffer(32767));
1854
        }
1855
        else if ("MC|BOpen".equals(packetIn.getChannelName()))
1856
        {
1857
            ItemStack itemstack = this.gameController.thePlayer.getCurrentEquippedItem();
1858
1859
            if (itemstack != null && itemstack.getItem() == Items.written_book)
1860
            {
1861
                this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.thePlayer, itemstack, false));
1862
            }
1863
        }
1864
    }
1865
1866
    /**
1867
     * May create a scoreboard objective, remove an objective from the scoreboard or update an objectives' displayname
1868
     */
1869
    public void handleScoreboardObjective(S3BPacketScoreboardObjective packetIn)
1870
    {
1871
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1872
        Scoreboard scoreboard = this.clientWorldController.getScoreboard();
1873
1874
        if (packetIn.func_149338_e() == 0)
1875
        {
1876
            ScoreObjective scoreobjective = scoreboard.addScoreObjective(packetIn.func_149339_c(), IScoreObjectiveCriteria.DUMMY);
1877
            scoreobjective.setDisplayName(packetIn.func_149337_d());
1878
            scoreobjective.setRenderType(packetIn.func_179817_d());
1879
        }
1880
        else
1881
        {
1882
            ScoreObjective scoreobjective1 = scoreboard.getObjective(packetIn.func_149339_c());
1883
1884
            if (packetIn.func_149338_e() == 1)
1885
            {
1886
                scoreboard.removeObjective(scoreobjective1);
1887
            }
1888
            else if (packetIn.func_149338_e() == 2)
1889
            {
1890
                scoreobjective1.setDisplayName(packetIn.func_149337_d());
1891
                scoreobjective1.setRenderType(packetIn.func_179817_d());
1892
            }
1893
        }
1894
    }
1895
1896
    /**
1897
     * Either updates the score with a specified value or removes the score for an objective
1898
     */
1899
    public void handleUpdateScore(S3CPacketUpdateScore packetIn)
1900
    {
1901
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1902
        Scoreboard scoreboard = this.clientWorldController.getScoreboard();
1903
        ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());
1904
1905
        if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.CHANGE)
1906
        {
1907
            Score score = scoreboard.getValueFromObjective(packetIn.getPlayerName(), scoreobjective);
1908
            score.setScorePoints(packetIn.getScoreValue());
1909
        }
1910
        else if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.REMOVE)
1911
        {
1912
            if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName()))
1913
            {
1914
                scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective)null);
1915
            }
1916
            else if (scoreobjective != null)
1917
            {
1918
                scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
1919
            }
1920
        }
1921
    }
1922
1923
    /**
1924
     * Removes or sets the ScoreObjective to be displayed at a particular scoreboard position (list, sidebar, below
1925
     * name)
1926
     */
1927
    public void handleDisplayScoreboard(S3DPacketDisplayScoreboard packetIn)
1928
    {
1929
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1930
        Scoreboard scoreboard = this.clientWorldController.getScoreboard();
1931
1932
        if (packetIn.func_149370_d().length() == 0)
1933
        {
1934
            scoreboard.setObjectiveInDisplaySlot(packetIn.func_149371_c(), (ScoreObjective)null);
1935
        }
1936
        else
1937
        {
1938
            ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.func_149370_d());
1939
            scoreboard.setObjectiveInDisplaySlot(packetIn.func_149371_c(), scoreobjective);
1940
        }
1941
    }
1942
1943
    /**
1944
     * Updates a team managed by the scoreboard: Create/Remove the team registration, Register/Remove the player-team-
1945
     * memberships, Set team displayname/prefix/suffix and/or whether friendly fire is enabled
1946
     */
1947
    public void handleTeams(S3EPacketTeams packetIn)
1948
    {
1949
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
1950
        Scoreboard scoreboard = this.clientWorldController.getScoreboard();
1951
        ScorePlayerTeam scoreplayerteam;
1952
1953
        if (packetIn.getAction() == 0)
1954
        {
1955
            scoreplayerteam = scoreboard.createTeam(packetIn.getName());
1956
        }
1957
        else
1958
        {
1959
            scoreplayerteam = scoreboard.getTeam(packetIn.getName());
1960
        }
1961
1962
        if (packetIn.getAction() == 0 || packetIn.getAction() == 2)
1963
        {
1964
            scoreplayerteam.setTeamName(packetIn.getDisplayName());
1965
            scoreplayerteam.setNamePrefix(packetIn.getPrefix());
1966
            scoreplayerteam.setNameSuffix(packetIn.getSuffix());
1967
            scoreplayerteam.setChatFormat(EnumChatFormatting.func_175744_a(packetIn.getColor()));
1968
            scoreplayerteam.func_98298_a(packetIn.getFriendlyFlags());
1969
            Team.EnumVisible team$enumvisible = Team.EnumVisible.func_178824_a(packetIn.getNameTagVisibility());
1970
1971
            if (team$enumvisible != null)
1972
            {
1973
                scoreplayerteam.setNameTagVisibility(team$enumvisible);
1974
            }
1975
        }
1976
1977
        if (packetIn.getAction() == 0 || packetIn.getAction() == 3)
1978
        {
1979
            for (String s : packetIn.getPlayers())
1980
            {
1981
                scoreboard.addPlayerToTeam(s, packetIn.getName());
1982
            }
1983
        }
1984
1985
        if (packetIn.getAction() == 4)
1986
        {
1987
            for (String s1 : packetIn.getPlayers())
1988
            {
1989
                scoreboard.removePlayerFromTeam(s1, scoreplayerteam);
1990
            }
1991
        }
1992
1993
        if (packetIn.getAction() == 1)
1994
        {
1995
            scoreboard.removeTeam(scoreplayerteam);
1996
        }
1997
    }
1998
1999
    /**
2000
     * Spawns a specified number of particles at the specified location with a randomized displacement according to
2001
     * specified bounds
2002
     */
2003
    public void handleParticles(S2APacketParticles packetIn)
2004
    {
2005
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
2006
2007
        if (packetIn.getParticleCount() == 0)
2008
        {
2009
            double d0 = (double)(packetIn.getParticleSpeed() * packetIn.getXOffset());
2010
            double d2 = (double)(packetIn.getParticleSpeed() * packetIn.getYOffset());
2011
            double d4 = (double)(packetIn.getParticleSpeed() * packetIn.getZOffset());
2012
2013
            try
2014
            {
2015
                this.clientWorldController.spawnParticle(packetIn.getParticleType(), packetIn.isLongDistance(), packetIn.getXCoordinate(), packetIn.getYCoordinate(), packetIn.getZCoordinate(), d0, d2, d4, packetIn.getParticleArgs());
2016
            }
2017
            catch (Throwable var17)
2018
            {
2019
                logger.warn("Could not spawn particle effect " + packetIn.getParticleType());
2020
            }
2021
        }
2022
        else
2023
        {
2024
            for (int i = 0; i < packetIn.getParticleCount(); ++i)
2025
            {
2026
                double d1 = this.avRandomizer.nextGaussian() * (double)packetIn.getXOffset();
2027
                double d3 = this.avRandomizer.nextGaussian() * (double)packetIn.getYOffset();
2028
                double d5 = this.avRandomizer.nextGaussian() * (double)packetIn.getZOffset();
2029
                double d6 = this.avRandomizer.nextGaussian() * (double)packetIn.getParticleSpeed();
2030
                double d7 = this.avRandomizer.nextGaussian() * (double)packetIn.getParticleSpeed();
2031
                double d8 = this.avRandomizer.nextGaussian() * (double)packetIn.getParticleSpeed();
2032
2033
                try
2034
                {
2035
                    this.clientWorldController.spawnParticle(packetIn.getParticleType(), packetIn.isLongDistance(), packetIn.getXCoordinate() + d1, packetIn.getYCoordinate() + d3, packetIn.getZCoordinate() + d5, d6, d7, d8, packetIn.getParticleArgs());
2036
                }
2037
                catch (Throwable var16)
2038
                {
2039
                    logger.warn("Could not spawn particle effect " + packetIn.getParticleType());
2040
                    return;
2041
                }
2042
            }
2043
        }
2044
    }
2045
2046
    /**
2047
     * Updates en entity's attributes and their respective modifiers, which are used for speed bonusses (player
2048
     * sprinting, animals fleeing, baby speed), weapon/tool attackDamage, hostiles followRange randomization, zombie
2049
     * maxHealth and knockback resistance as well as reinforcement spawning chance.
2050
     */
2051
    public void handleEntityProperties(S20PacketEntityProperties packetIn)
2052
    {
2053
        PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
2054
        Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
2055
2056
        if (entity != null)
2057
        {
2058
            if (!(entity instanceof EntityLivingBase))
2059
            {
2060
                throw new IllegalStateException("Server tried to update attributes of a non-living entity (actually: " + entity + ")");
2061
            }
2062
            else
2063
            {
2064
                BaseAttributeMap baseattributemap = ((EntityLivingBase)entity).getAttributeMap();
2065
2066
                for (S20PacketEntityProperties.Snapshot s20packetentityproperties$snapshot : packetIn.func_149441_d())
2067
                {
2068
                    IAttributeInstance iattributeinstance = baseattributemap.getAttributeInstanceByName(s20packetentityproperties$snapshot.func_151409_a());
2069
2070
                    if (iattributeinstance == null)
2071
                    {
2072
                        iattributeinstance = baseattributemap.registerAttribute(new RangedAttribute((IAttribute)null, s20packetentityproperties$snapshot.func_151409_a(), 0.0D, 2.2250738585072014E-308D, Double.MAX_VALUE));
2073
                    }
2074
2075
                    iattributeinstance.setBaseValue(s20packetentityproperties$snapshot.func_151410_b());
2076
                    iattributeinstance.removeAllModifiers();
2077
2078
                    for (AttributeModifier attributemodifier : s20packetentityproperties$snapshot.func_151408_c())
2079
                    {
2080
                        iattributeinstance.applyModifier(attributemodifier);
2081
                    }
2082
                }
2083
            }
2084
        }
2085
    }
2086
2087
    /**
2088
     * Returns this the NetworkManager instance registered with this NetworkHandlerPlayClient
2089
     */
2090
    public NetworkManager getNetworkManager()
2091
    {
2092
        return this.netManager;
2093
    }
2094
2095
    public Collection<NetworkPlayerInfo> getPlayerInfoMap()
2096
    {
2097
        return this.playerInfoMap.values();
2098
    }
2099
2100
    public NetworkPlayerInfo getPlayerInfo(UUID p_175102_1_)
2101
    {
2102
        return (NetworkPlayerInfo)this.playerInfoMap.get(p_175102_1_);
2103
    }
2104
2105
    /**
2106
     * Gets the client's description information about another player on the server.
2107
     */
2108
    public NetworkPlayerInfo getPlayerInfo(String p_175104_1_)
2109
    {
2110
        for (NetworkPlayerInfo networkplayerinfo : this.playerInfoMap.values())
2111
        {
2112
            if (networkplayerinfo.getGameProfile().getName().equals(p_175104_1_))
2113
            {
2114
                return networkplayerinfo;
2115
            }
2116
        }
2117
2118
        return null;
2119
    }
2120
2121
    public GameProfile getGameProfile()
2122
    {
2123
        return this.profile;
2124
    }
2125
}

Deobfuscated MCP 1.8.9 source of NetHandlerPlayClient from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/network/NetHandlerPlayClient.java), stored verbatim.