public override void Process(int whoAmI, byte[] readBuffer, int length, int num)
        {
            byte method = ReadByte(readBuffer);
            int x = (int)ReadInt16(readBuffer);
            int y = (int)ReadInt16(readBuffer);
            int type = (int)ReadInt16(readBuffer);

            var player = Main.player[whoAmI];

            var ctx = new HookContext
            {
                Connection = player.Connection,
                Player = player,
                Sender = player,
            };

            var args = new HookArgs.ChestBreakReceived
            {
                X = x,
                Y = y
            };

            HookPoints.ChestBreakReceived.Invoke(ref ctx, ref args);

            if (ctx.CheckForKick())
            {
                return;
            }

            if (ctx.Result == HookResult.IGNORE)
            {
                return;
            }

            if (ctx.Result == HookResult.RECTIFY)
            {
                NewNetMessage.SendTileSquare(whoAmI, x, y, 3);
                return;
            }

            {
                if (method == 0)
                {
                    int num92 = WorldGen.PlaceChest(x, y, 21, false, type);
                    if (num92 == -1)
                    {
                        NewNetMessage.SendData(34, whoAmI, -1, String.Empty, (int)method, (float)x, (float)y, (float)type, num92);
                        Item.NewItem(x * 16, y * 16, 32, 32, Chest.itemSpawn[type], 1, true, 0, false);
                        return;
                    }
                    NewNetMessage.SendData(34, -1, -1, String.Empty, (int)method, (float)x, (float)y, (float)type, num92);
                    return;
                }
                else
                {
                    Tile tile2 = Main.tile[x, y];
                    if (tile2.type != 21)
                    {
                        return;
                    }
                    if (tile2.frameX % 36 != 0)
                    {
                        x--;
                    }
                    if (tile2.frameY % 36 != 0)
                    {
                        y--;
                    }
                    int number = Chest.FindChest(x, y);
                    WorldGen.KillTile(x, y, false, false, false);
                    if (!tile2.active())
                    {
                        NewNetMessage.SendData(34, -1, -1, String.Empty, (int)method, (float)x, (float)y, 0f, number);
                        return;
                    }
                    return;
                }
            }
        }
        private static void ProcessChest(int bufferId)
        {
            var buffer = NetMessage.buffer[bufferId];
            var player = Main.player[bufferId];

            byte b7 = buffer.reader.ReadByte();
            int x = (int)buffer.reader.ReadInt16();
            int y = (int)buffer.reader.ReadInt16();
            int style = (int)buffer.reader.ReadInt16();

            if (Math.Abs(player.position.X / 16 - x) >= 7 || Math.Abs(player.position.Y / 16 - y) >= 7)
            {
                return;
            }

            var ctx = new HookContext
            {
                Connection = player.Connection.Socket,
                Player = player,
                Sender = player
            };

            var args = new HookArgs.ChestBreakReceived
            {
                X = x,
                Y = y
            };

            HookPoints.ChestBreakReceived.Invoke(ref ctx, ref args);

            if (ctx.CheckForKick())
            {
                return;
            }

            if (ctx.Result == HookResult.IGNORE)
            {
                return;
            }

            if (ctx.Result == HookResult.RECTIFY)
            {
                NetMessage.SendTileSquare(bufferId, x, y, 3);
                return;
            }

            if (Main.netMode == 2)
            {
                if (b7 == 0)
                {
                    int num105 = WorldGen.PlaceChest(x, y, 21, false, style);
                    if (num105 == -1)
                    {
                        NetMessage.SendData(34, bufferId, -1, "", (int)b7, (float)x, (float)y, (float)style, num105, 0, 0);
                        Item.NewItem(x * 16, y * 16, 32, 32, Chest.chestItemSpawn[style], 1, true, 0, false);
                        return;
                    }
                    NetMessage.SendData(34, -1, -1, "", (int)b7, (float)x, (float)y, (float)style, num105, 0, 0);
                    return;
                }
                else
                {
                    if (b7 == 2)
                    {
                        int num106 = WorldGen.PlaceChest(x, y, 88, false, style);
                        if (num106 == -1)
                        {
                            NetMessage.SendData(34, bufferId, -1, "", (int)b7, (float)x, (float)y, (float)style, num106, 0, 0);
                            Item.NewItem(x * 16, y * 16, 32, 32, Chest.dresserItemSpawn[style], 1, true, 0, false);
                            return;
                        }
                        NetMessage.SendData(34, -1, -1, "", (int)b7, (float)x, (float)y, (float)style, num106, 0, 0);
                        return;
                    }
                    else
                    {
                        Tile tile2 = Main.tile[x, y];
                        if (tile2.type == 21 && b7 == 1)
                        {
                            if (tile2.frameX % 36 != 0)
                            {
                                x--;
                            }
                            if (tile2.frameY % 36 != 0)
                            {
                                y--;
                            }
                            int number = Chest.FindChest(x, y);
                            WorldGen.KillTile(x, y, false, false, false);
                            if (!tile2.active())
                            {
                                NetMessage.SendData(34, -1, -1, "", (int)b7, (float)x, (float)y, 0, number, 0, 0);
                                return;
                            }
                            return;
                        }
                        else
                        {
                            if (tile2.type != 88 || b7 != 3)
                            {
                                return;
                            }
                            x -= (int)(tile2.frameX % 54 / 18);
                            if (tile2.frameY % 36 != 0)
                            {
                                y--;
                            }
                            int number2 = Chest.FindChest(x, y);
                            WorldGen.KillTile(x, y, false, false, false);
                            if (!tile2.active())
                            {
                                NetMessage.SendData(34, -1, -1, "", (int)b7, (float)x, (float)y, 0, number2, 0, 0);
                                return;
                            }
                            return;
                        }
                    }
                }
            }
            else
            {
                int num107 = (int)buffer.reader.ReadInt16();
                if (b7 == 0)
                {
                    if (num107 == -1)
                    {
                        WorldGen.KillTile(x, y, false, false, false);
                        return;
                    }
                    WorldGen.PlaceChestDirect(x, y, 21, style, num107);
                    return;
                }
                else
                {
                    if (b7 != 2)
                    {
                        Chest.DestroyChestDirect(x, y, num107);
                        WorldGen.KillTile(x, y, false, false, false);
                        return;
                    }
                    if (num107 == -1)
                    {
                        WorldGen.KillTile(x, y, false, false, false);
                        return;
                    }
                    WorldGen.PlaceDresserDirect(x, y, 88, style, num107);
                    return;
                }
            }
        }