private void CalculateButton_OnClick(UIMouseEvent evt, UIElement listeningElement) { Point point = Main.LocalPlayer.Center.ToTileCoordinates(); byte[] writeBuffer = new byte[131070]; int sectionX = point.X / 200; int sectionY = point.Y / 150; int x = sectionX * 200; int y = sectionY * 150; // This doesn't return the correct number technically. int chunkDataSize = NetMessage.CompressTileBlock(x, y, 200, 150, writeBuffer, 0); if (chunkDataSize > 65535) // 65535 131070 { Main.NewText($"[c/FF0000:Bad]: {chunkDataSize} > 65535"); } else { Main.NewText($"[c/00FF00:OK]: {chunkDataSize} < 65535"); } Dust.QuickBox(new Vector2(x, y) * 16, new Vector2(x + 200, y + 150) * 16, 80, Color.White, null); //Dust.QuickBox(new Vector2(x, y) * 16 + new Vector2(3, 3) * 16, new Vector2(x + 200, y + 150) * 16 - new Vector2(3, 3) * 16, 38, Color.LightSkyBlue, null); //Dust.QuickBox(new Vector2(x, y) * 16 + new Vector2(6, 6) * 16, new Vector2(x + 200, y + 150) * 16 - new Vector2(6, 6) * 16, 36, Color.LightSteelBlue, null); using (MemoryStream memoryStream = new MemoryStream()) { using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream)) { long position = memoryStream.Position; foreach (var item in TileEntity.ByPosition) { Point16 pos = item.Key; if (pos.X >= x && pos.X < x + 200 && pos.Y >= y && pos.Y < y + 150) { if (item.Value.type > 2) { short id = (short)item.Value.ID; TileEntity.Write(binaryWriter, TileEntity.ByID[id], false); long length = memoryStream.Position - position; position = memoryStream.Position; Main.NewText($"TE@{pos.X},{pos.Y}: {length}"); } } } } } }