public static int AfterPlacement_Hook(int x, int y, int type = 21, int style = 0, int direction = 1) { Point16 point16 = new Point16(x, y); TileObjectData.OriginToTopLeft(type, style, ref point16); int num = Chest.FindEmptyChest(point16.X, point16.Y, 21, 0, 1); if (num == -1) { return -1; } if (Main.netMode != 1) { Chest chest = new Chest(false) { x = point16.X, y = point16.Y }; for (int i = 0; i < 40; i++) { chest.item[i] = new Item(); } Main.chest[num] = chest; } else if (type != 21) { NetMessage.SendData((int)PacketTypes.TileKill, -1, -1, "", 2, (float)x, (float)y, (float)style, 0, 0, 0); } else { NetMessage.SendData((int)PacketTypes.TileKill, -1, -1, "", 0, (float)x, (float)y, (float)style, 0, 0, 0); } return num; }
private void ExportChests(CommandArgs args) { var player = args.Player; player.SendWarningMessage("Exporting chests. This may take a while..."); foreach (var chest in _database.GetAll()) { var chestId = Main.chest.TakeWhile(c => c != null).Count(); if (chestId >= Main.maxChests) { player.SendWarningMessage("The chest limit was reached."); break; } var terrariaChest = new Terraria.Chest { x = chest.X, y = chest.Y, name = chest.Name }; for (var i = 0; i < Terraria.Chest.maxItems; ++i) { var item = new Item(); item.SetDefaults(chest.Items[i].NetId); item.stack = chest.Items[i].Stack; item.prefix = chest.Items[i].PrefixId; terrariaChest.item[i] = item; } Main.chest[chestId] = terrariaChest; } player.SendSuccessMessage("Exported chests."); }
public void OnChestSetupShop(Chest chest, int type) { if (type == 1) { var player = Main.player[Main.myPlayer]; if (player.statLifeMax >= 200 && player.statLifeMax <= 299) { chest.item[7].SetDefaults("Healing Potion"); } else if (player.statLifeMax >= 300 && player.statLifeMax <= 499) { chest.item[7].SetDefaults("Greater Healing Potion"); } else if (player.statLifeMax >= 500) { chest.item[7].SetDefaults("Super Healing Potion"); } if (player.statManaMax >= 160 && player.statManaMax <= 200) { chest.item[8].SetDefaults("Mana Potion"); } else if (player.statManaMax >= 201 && player.statManaMax <= 399) { chest.item[8].SetDefaults("Greater Mana Potion"); } else if (player.statManaMax >= 400) { chest.item[8].SetDefaults("Super Mana Potion"); } } }
public static void OnChestSetupShop(Chest chest, int type) { foreach (var plugin in loadedPlugins.OfType<IPluginChestSetupShop>()) { plugin.OnChestSetupShop(chest, type); } }
public override void SetupShop(Chest shop, ref int nextSlot) { shop.item[nextSlot].SetDefaults(ItemID.MolotovCocktail); nextSlot++; shop.item[nextSlot].SetDefaults(ItemID.FlamingArrow); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("FireGrenade")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("FirestormBottle")); }
public static void ConvertToAutoRefill(int s, int e) { var items = new StringBuilder(); for (int i = s; i < s + e; i++) { Terraria.Chest c = Main.chest[i]; if (c != null) { for (int j = 0; j < 40; j++) { items.Append(c.item[j].netID).Append(",").Append(c.item[j].stack).Append(",").Append(c.item[j].prefix).Append(","); } main.Database.Query("INSERT INTO Chests (X, Y, Account, Items, Flags, WorldID) VALUES (@0, @1, '', @2, @3, @4)", c.x, c.y, items.ToString(0, items.Length - 1), 5, Main.worldID); items.Clear(); Main.chest[i] = null; } } }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { var chestId = (int)ReadInt16(readBuffer); var x = (int)ReadInt16(readBuffer); var y = (int)ReadInt16(readBuffer); if (Main.netMode == 1) { if (chestId < 0 || chestId >= 1000) return; var chest = Main.chest[chestId]; if (chest == null) { chest = new Chest(false); chest.x = x; chest.y = y; Main.chest[chestId] = chest; } else if (chest.x != x || chest.y != y) return; chest.name = ReadString(readBuffer); } else { if (chestId < -1 || chestId >= 1000) return; if (chestId == -1) { chestId = Chest.FindChest(x, y); if (chestId == -1) return; } var chest = Main.chest[chestId]; if (chest.x != x || chest.y != y) return; NewNetMessage.SendData(Packet.CHEST_NAME_UPDATE, whoAmI, -1, chest.name, chestId, (float)x, (float)y, 0f, 0); } }
public static void WriteChest(this BinaryWriter writer, Chest chest) { writer.Write(chest.x); writer.Write(chest.y); //writer.Write(chest.name); for (int l = 0; l < 40; l++) { Item item = chest.item[l]; if (item != null && item.stack > 0) { writer.Write((short)item.stack); writer.Write(item.netID); writer.Write(item.prefix); } else { writer.Write((short)0); } } }
public override void SetupShop(int type, Chest shop, ref int nextSlot) { if (type == NPCID.Dryad) { shop.item[nextSlot].SetDefaults(mod.ItemType<Items.CarKey>()); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType<Items.CarKey>()); shop.item[nextSlot].shopCustomPrice = new int?(2); shop.item[nextSlot].shopSpecialCurrency = CustomCurrencyID.DefenderMedals; nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType<Items.CarKey>()); shop.item[nextSlot].shopCustomPrice = new int?(3); shop.item[nextSlot].shopSpecialCurrency = ExampleMod.FaceCustomCurrencyID; nextSlot++; } }
private static void LoadChests(BinaryReader reader) { short num; int i; int j; int num1; int num2; Chest chest = null; int num3 = reader.ReadInt16(); int num4 = reader.ReadInt16(); if (num4 >= 40) { num1 = 40; num2 = num4 - 40; } else { num1 = num4; num2 = 0; } for (i = 0; i < num3; i++) { chest = new Chest(false) { x = reader.ReadInt32(), y = reader.ReadInt32(), name = reader.ReadString() }; for (j = 0; j < num1; j++) { num = reader.ReadInt16(); Item item = new Item(); if (num > 0) { item.netDefaults(reader.ReadInt32()); item.stack = num; item.Prefix((int)reader.ReadByte()); } else if (num < 0) { item.netDefaults(reader.ReadInt32()); item.Prefix((int)reader.ReadByte()); item.stack = 1; } chest.item[j] = item; } for (j = 0; j < num2; j++) { num = reader.ReadInt16(); if (num > 0) { reader.ReadInt32(); reader.ReadByte(); } } Main.chest[i] = chest; } while (i < 1000) { Main.chest[i] = null; i++; } if (WorldFile.versionNumber < 115) { WorldFile.FixDresserChests(); } }
//in Terraria.Chest.SetupShop before discount call NPCLoader.SetupShop(type, this, ref num); internal static void SetupShop(int type, Chest shop, ref int nextSlot) { if (type < shopToNPC.Length) { type = shopToNPC[type]; } else if (type >= NPCID.Count) { GetNPC(type).SetupShop(shop, ref nextSlot); } foreach (GlobalNPC globalNPC in globalNPCs) { globalNPC.SetupShop(type, shop, ref nextSlot); } }
private static void LoadChests(BinaryReader reader) { int num = (int)reader.ReadInt16(); int num2 = (int)reader.ReadInt16(); int num3; int num4; if (num2 < Chest.maxItems) { num3 = num2; num4 = 0; } else { num3 = Chest.maxItems; num4 = num2 - Chest.maxItems; } int i; for (i = 0; i < num; i++) { Chest chest = new Chest(false); chest.x = reader.ReadInt32(); chest.y = reader.ReadInt32(); chest.name = reader.ReadString(); for (int j = 0; j < num3; j++) { short num5 = reader.ReadInt16(); Item item = new Item(); if (num5 > 0) { item.netDefaults(reader.ReadInt32()); item.stack = (int)num5; item.Prefix((int)reader.ReadByte()); } else if (num5 < 0) { item.netDefaults(reader.ReadInt32()); item.Prefix((int)reader.ReadByte()); item.stack = 1; } chest.item[j] = item; } for (int j = 0; j < num4; j++) { short num5 = reader.ReadInt16(); if (num5 > 0) { reader.ReadInt32(); reader.ReadByte(); } } Main.chest[i] = chest; } while (i < 1000) { Main.chest[i] = null; i++; } }
public static int AfterPlacement_Hook(int x, int y, int type = 21, int style = 0, int direction = 1) { for (int i = 0; i < 100; i++) Main.NewText(x + " : " + y + " : " + type + " : " + style + " : " + direction); Point16 point = new Point16(x, y); TileObjectData.OriginToTopLeft(type, style, ref point); int num = Chest.FindEmptyChest((int)point.X, (int)point.Y, type, 0, 1);// if (num == -1) { return -1; } if (Main.netMode != 1) { Chest chest = new Chest(false); chest.x = (int)point.X; chest.y = (int)point.Y; for (int i = 0; i < 40; i++) { chest.item[i] = new Item(); } Main.chest[num] = chest; } else if (type == 21 || type == 431) { NetMessage.SendData(34, -1, -1, "", 0, (float)x, (float)y, (float)style, 0, 0, 0); } else { NetMessage.SendData(34, -1, -1, "", 2, (float)x, (float)y, (float)style, 0, 0, 0); } return num; }
public World(string path) { if (genRand == null) { genRand = new Random((int) DateTime.Now.Ticks); } using (FileStream stream = new FileStream(path, FileMode.Open)) { using (BinaryReader reader = new BinaryReader(stream)) { worldVersion = reader.ReadInt32(); Name = reader.ReadString(); ID = reader.ReadInt32(); leftWorld = reader.ReadInt32(); rightWorld = reader.ReadInt32(); topWorld = reader.ReadInt32(); bottomWorld = reader.ReadInt32(); int tilesY = reader.ReadInt32(); int tilesX = reader.ReadInt32(); Size = new Size(tilesX, tilesY); Spawn = new Point(reader.ReadInt32(), reader.ReadInt32()); worldSurface = reader.ReadDouble(); rockLayer = reader.ReadDouble(); double tempTime = reader.ReadDouble(); bool tempDayTime= reader.ReadBoolean(); int tempMoonPhase = reader.ReadInt32(); bool tempBloodMoon= reader.ReadBoolean(); Dungeon = new Point(reader.ReadInt32(), reader.ReadInt32()); downedBoss1 = reader.ReadBoolean(); downedBoss2 = reader.ReadBoolean(); downedBoss3 = reader.ReadBoolean(); shadowOrbSmashed = reader.ReadBoolean(); spawnMeteor = reader.ReadBoolean(); shadowOrbCount = reader.ReadByte(); invasionDelay = reader.ReadInt32(); invasionSize = reader.ReadInt32(); invasionType = reader.ReadInt32(); invasionX = reader.ReadDouble(); for (int num4 = 0; num4 < MaxTilesX; num4++) { for (int num6 = 0; num6 < MaxTilesY; num6++) { tile[num4, num6] = new Tile(); } } for (int i = 0; i < tilesX; i++) { float num3 = ((float) i) / ((float) tilesX); for (int n = 0; n < tilesY; n++) { tile[i, n].Active = reader.ReadBoolean(); if (tile[i, n].Active) { tile[i, n].Type = reader.ReadByte(); if (tileFrameImportant[tile[i, n].Type]) { tile[i, n].FrameX = reader.ReadInt16(); tile[i, n].FrameY = reader.ReadInt16(); } else { tile[i, n].FrameX = -1; tile[i, n].FrameY = -1; } } tile[i, n].Lighted = reader.ReadBoolean(); if (reader.ReadBoolean()) { tile[i, n].Wall = reader.ReadByte(); } if (reader.ReadBoolean()) { tile[i, n].Liquid = reader.ReadByte(); tile[i, n].Lava = reader.ReadBoolean(); } } } for (int j = 0; j < 0x3e8; j++) { if (reader.ReadBoolean()) { chest[j] = new Chest(); chest[j].Position = new Microsoft.Xna.Framework.Vector2(reader.ReadInt32(), reader.ReadInt32()); for (int num6 = 0; num6 < Chest.MaxItems; num6++) { byte num7 = reader.ReadByte(); if (num7 > 0) { chest[j].Items[num6] = new Item(); string itemName = reader.ReadString(); chest[j].Items[num6].Name = itemName; chest[j].Items[num6].Count = num7; } } } } for (int k = 0; k < 0x3e8; k++) { if (reader.ReadBoolean()) { string str2 = reader.ReadString(); int num9 = reader.ReadInt32(); int num10 = reader.ReadInt32(); if (tile[num9, num10].Active && (tile[num9, num10].Type == 0x37)) { sign[k] = new Sign(); sign[k].Position = new Microsoft.Xna.Framework.Vector2(num9, num10); sign[k].Text = str2; } } } bool flag = reader.ReadBoolean(); for (int m = 0; flag; m++) { npc[m] = new Npc(); npc[m].Name = reader.ReadString(); npc[m].Position.X = reader.ReadSingle(); npc[m].Position.Y = reader.ReadSingle(); npc[m].IsHomeless = reader.ReadBoolean(); npc[m].HomePosition = new Microsoft.Xna.Framework.Vector2(reader.ReadInt32(), reader.ReadInt32()); flag = reader.ReadBoolean(); } reader.Close(); waterLine = tilesY; } } FrameTiles(); }
public void GetData(int start, int length) { List<Point> points; List<Point> points1; int num; TileEntity tileEntity; if (this.whoAmI >= 256) { Netplay.Connection.TimeOutTimer = 0; } else { Netplay.Clients[this.whoAmI].TimeOutTimer = 0; } byte num1 = 0; int num2 = 0; num2 = start + 1; num1 = this.readBuffer[start]; if (ServerApi.Hooks.InvokeNetGetData(ref num1, this, ref num2, ref length)) { return; } Main.rxMsg = Main.rxMsg + 1; Main.rxData = Main.rxData + length; if (Main.netMode == 1 && Netplay.Connection.StatusMax > 0) { RemoteServer connection = Netplay.Connection; connection.StatusCount = connection.StatusCount + 1; } if (Main.verboseNetplay) { int num3 = start; while (num3 < start + length) { num3++; } for (int i = start; i < start + length; i++) { byte num4 = this.readBuffer[i]; } } if (Main.netMode == 2 && num1 != 38 && Netplay.Clients[this.whoAmI].State == -1) { NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[1], 0, 0f, 0f, 0f, 0, 0, 0); return; } if (Main.netMode == 2 && Netplay.Clients[this.whoAmI].State < 10 && num1 > 12 && num1 != 93 && num1 != 16 && num1 != 42 && num1 != 50 && num1 != 38 && num1 != 68) { NetMessage.BootPlayer(this.whoAmI, Lang.mp[2]); } if (this.reader == null) { this.ResetReader(); } this.reader.BaseStream.Position = (long)num2; byte num5 = num1; // Console.WriteLine("Received: {0}", num5); switch (num5) { case 1: { if (Main.netMode != 2) { return; } if (Main.dedServ && Netplay.IsBanned(Netplay.Clients[this.whoAmI].Socket.GetRemoteAddress())) { NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[3], 0, 0f, 0f, 0f, 0, 0, 0); return; } if (Netplay.Clients[this.whoAmI].State != 0) { return; } if (this.reader.ReadString() != string.Concat("Terraria", Main.curRelease)) { NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[4], 0, 0f, 0f, 0f, 0, 0, 0); return; } if (string.IsNullOrEmpty(Netplay.ServerPassword)) { Netplay.Clients[this.whoAmI].State = 1; NetMessage.SendData(3, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); return; } Netplay.Clients[this.whoAmI].State = -1; NetMessage.SendData(37, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); return; } case 2: { if (Main.netMode != 1) { return; } Netplay.disconnect = true; Main.statusText = this.reader.ReadString(); return; } case 3: { if (Main.netMode != 1) { return; } if (Netplay.Connection.State == 1) { Netplay.Connection.State = 2; } int num6 = this.reader.ReadByte(); if (num6 != Main.myPlayer) { Main.player[num6] = Main.ActivePlayerFileData.Player; Main.player[Main.myPlayer] = new Player(); } Main.player[num6].whoAmI = num6; Main.myPlayer = num6; Player player = Main.player[num6]; NetMessage.SendData(4, -1, -1, player.name, num6, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(68, -1, -1, "", num6, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(16, -1, -1, "", num6, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(42, -1, -1, "", num6, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(50, -1, -1, "", num6, 0f, 0f, 0f, 0, 0, 0); for (int j = 0; j < 59; j++) { NetMessage.SendData(5, -1, -1, player.inventory[j].name, num6, (float)j, (float)player.inventory[j].prefix, 0f, 0, 0, 0); } for (int k = 0; k < (int)player.armor.Length; k++) { NetMessage.SendData(5, -1, -1, player.armor[k].name, num6, (float)(59 + k), (float)player.armor[k].prefix, 0f, 0, 0, 0); } for (int l = 0; l < (int)player.dye.Length; l++) { NetMessage.SendData(5, -1, -1, player.dye[l].name, num6, (float)(58 + (int)player.armor.Length + 1 + l), (float)player.dye[l].prefix, 0f, 0, 0, 0); } for (int m = 0; m < (int)player.miscEquips.Length; m++) { NetMessage.SendData(5, -1, -1, "", num6, (float)(58 + (int)player.armor.Length + (int)player.dye.Length + 1 + m), (float)player.miscEquips[m].prefix, 0f, 0, 0, 0); } for (int n = 0; n < (int)player.miscDyes.Length; n++) { NetMessage.SendData(5, -1, -1, "", num6, (float)(58 + (int)player.armor.Length + (int)player.dye.Length + (int)player.miscEquips.Length + 1 + n), (float)player.miscDyes[n].prefix, 0f, 0, 0, 0); } for (int o = 0; o < (int)player.bank.item.Length; o++) { NetMessage.SendData(5, -1, -1, "", num6, (float)(58 + (int)player.armor.Length + (int)player.dye.Length + (int)player.miscEquips.Length + (int)player.miscDyes.Length + 1 + o), (float)player.bank.item[o].prefix, 0f, 0, 0, 0); } for (int p = 0; p < (int)player.bank2.item.Length; p++) { NetMessage.SendData(5, -1, -1, "", num6, (float)(58 + (int)player.armor.Length + (int)player.dye.Length + (int)player.miscEquips.Length + (int)player.miscDyes.Length + (int)player.bank.item.Length + 1 + p), (float)player.bank2.item[p].prefix, 0f, 0, 0, 0); } NetMessage.SendData(6, -1, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); if (Netplay.Connection.State != 2) { return; } Netplay.Connection.State = 3; return; } case 4: { int num7 = this.reader.ReadByte(); if (Main.netMode == 2) { num7 = this.whoAmI; } if (num7 == Main.myPlayer && !Main.ServerSideCharacter) { return; } Player item1 = Main.player[num7]; item1.whoAmI = num7; item1.skinVariant = this.reader.ReadByte(); item1.skinVariant = (int)MathHelper.Clamp((float)item1.skinVariant, 0f, 7f); item1.hair = this.reader.ReadByte(); if (item1.hair >= 134) { item1.hair = 0; } item1.name = this.reader.ReadString().Trim().Trim(); item1.hairDye = this.reader.ReadByte(); BitsByte bitsByte = this.reader.ReadByte(); for (int q = 0; q < 8; q++) { item1.hideVisual[q] = bitsByte[q]; } bitsByte = this.reader.ReadByte(); for (int r = 0; r < 2; r++) { item1.hideVisual[r + 8] = bitsByte[r]; } item1.hideMisc = this.reader.ReadByte(); item1.hairColor = this.reader.ReadRGB(); item1.skinColor = this.reader.ReadRGB(); item1.eyeColor = this.reader.ReadRGB(); item1.shirtColor = this.reader.ReadRGB(); item1.underShirtColor = this.reader.ReadRGB(); item1.pantsColor = this.reader.ReadRGB(); item1.shoeColor = this.reader.ReadRGB(); BitsByte bitsByte1 = this.reader.ReadByte(); item1.difficulty = 0; if (bitsByte1[0]) { Player player1 = item1; player1.difficulty = (byte)(player1.difficulty + 1); } if (bitsByte1[1]) { Player player2 = item1; player2.difficulty = (byte)(player2.difficulty + 2); } item1.extraAccessory = bitsByte1[2]; if (Main.netMode != 2) { return; } bool flag = false; if (Netplay.Clients[this.whoAmI].State < 10) { for (int s = 0; s < 255; s++) { if (s != num7 && item1.name == Main.player[s].name && Netplay.Clients[s].IsActive) { flag = true; } } } if (flag) { if (!ServerApi.Hooks.InvokeNetNameCollision(num7, item1.name)) { NetMessage.SendData(2, this.whoAmI, -1, string.Concat(item1.name, " ", Lang.mp[5]), 0, 0f, 0f, 0f, 0, 0, 0); return; } return; } if (item1.name.Length > Player.nameLen) { NetMessage.SendData(2, this.whoAmI, -1, "Name is too long.", 0, 0f, 0f, 0f, 0, 0, 0); return; } if (item1.name == "") { NetMessage.SendData(2, this.whoAmI, -1, "Empty name.", 0, 0f, 0f, 0f, 0, 0, 0); return; } Netplay.Clients[this.whoAmI].Name = item1.name; Netplay.Clients[this.whoAmI].Name = item1.name; NetMessage.SendData(4, -1, this.whoAmI, item1.name, num7, 0f, 0f, 0f, 0, 0, 0); return; } case 5: { int num8 = this.reader.ReadByte(); if (Main.netMode == 2) { num8 = this.whoAmI; } if (num8 == Main.myPlayer && !Main.ServerSideCharacter && !Main.player[num8].IsStackingItems()) { return; } Player item1 = Main.player[num8]; lock (item1) { int num9 = this.reader.ReadByte(); int num10 = this.reader.ReadInt16(); int num11 = this.reader.ReadByte(); int num12 = this.reader.ReadInt16(); Item[] itemArray = null; int num13 = 0; bool flag1 = false; if (num9 > 58 + (int)item1.armor.Length + (int)item1.dye.Length + (int)item1.miscEquips.Length + (int)item1.miscDyes.Length + (int)item1.bank.item.Length + (int)item1.bank2.item.Length) { flag1 = true; } else if (num9 > 58 + (int)item1.armor.Length + (int)item1.dye.Length + (int)item1.miscEquips.Length + (int)item1.miscDyes.Length + (int)item1.bank.item.Length) { num13 = num9 - 58 - ((int)item1.armor.Length + (int)item1.dye.Length + (int)item1.miscEquips.Length + (int)item1.miscDyes.Length + (int)item1.bank.item.Length) - 1; itemArray = item1.bank2.item; } else if (num9 > 58 + (int)item1.armor.Length + (int)item1.dye.Length + (int)item1.miscEquips.Length + (int)item1.miscDyes.Length) { num13 = num9 - 58 - ((int)item1.armor.Length + (int)item1.dye.Length + (int)item1.miscEquips.Length + (int)item1.miscDyes.Length) - 1; itemArray = item1.bank.item; } else if (num9 > 58 + (int)item1.armor.Length + (int)item1.dye.Length + (int)item1.miscEquips.Length) { num13 = num9 - 58 - ((int)item1.armor.Length + (int)item1.dye.Length + (int)item1.miscEquips.Length) - 1; itemArray = item1.miscDyes; } else if (num9 > 58 + (int)item1.armor.Length + (int)item1.dye.Length) { num13 = num9 - 58 - ((int)item1.armor.Length + (int)item1.dye.Length) - 1; itemArray = item1.miscEquips; } else if (num9 > 58 + (int)item1.armor.Length) { num13 = num9 - 58 - (int)item1.armor.Length - 1; itemArray = item1.dye; } else if (num9 <= 58) { num13 = num9; itemArray = item1.inventory; } else { num13 = num9 - 58 - 1; itemArray = item1.armor; } if (flag1) { item1.trashItem = new Item(); item1.trashItem.netDefaults(num12); item1.trashItem.stack = num10; item1.trashItem.Prefix(num11); } else if (num9 > 58) { itemArray[num13] = new Item(); itemArray[num13].netDefaults(num12); itemArray[num13].stack = num10; itemArray[num13].Prefix(num11); } else { int num14 = itemArray[num13].type; int num15 = itemArray[num13].stack; itemArray[num13] = new Item(); itemArray[num13].netDefaults(num12); itemArray[num13].stack = num10; itemArray[num13].Prefix(num11); if (num8 == Main.myPlayer && num13 == 58) { Main.mouseItem = itemArray[num13].Clone(); } if (num8 == Main.myPlayer && Main.netMode == 1) { Main.player[num8].inventoryChestStack[num9] = false; } } if (Main.netMode == 2 && num8 == this.whoAmI) { NetMessage.SendData(5, -1, this.whoAmI, "", num8, (float)num9, (float)num11, 0f, 0, 0, 0); } return; } } case 6: { if (Main.netMode != 2) { return; } if (Netplay.Clients[this.whoAmI].State == 1) { Netplay.Clients[this.whoAmI].State = 2; Netplay.Clients[this.whoAmI].ResetSections(); } NetMessage.SendData(7, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); Main.SyncAnInvasion(this.whoAmI); return; } case 7: { if (Main.netMode != 1) { return; } Main.time = (double)this.reader.ReadInt32(); BitsByte bitsByte2 = this.reader.ReadByte(); Main.dayTime = bitsByte2[0]; Main.bloodMoon = bitsByte2[1]; Main.eclipse = bitsByte2[2]; Main.moonPhase = this.reader.ReadByte(); Main.maxTilesX = this.reader.ReadInt16(); Main.maxTilesY = this.reader.ReadInt16(); Main.spawnTileX = this.reader.ReadInt16(); Main.spawnTileY = this.reader.ReadInt16(); Main.worldSurface = (double)this.reader.ReadInt16(); Main.rockLayer = (double)this.reader.ReadInt16(); Main.worldID = this.reader.ReadInt32(); Main.worldName = this.reader.ReadString(); Main.moonType = this.reader.ReadByte(); WorldGen.setBG(0, (int)this.reader.ReadByte()); WorldGen.setBG(1, (int)this.reader.ReadByte()); WorldGen.setBG(2, (int)this.reader.ReadByte()); WorldGen.setBG(3, (int)this.reader.ReadByte()); WorldGen.setBG(4, (int)this.reader.ReadByte()); WorldGen.setBG(5, (int)this.reader.ReadByte()); WorldGen.setBG(6, (int)this.reader.ReadByte()); WorldGen.setBG(7, (int)this.reader.ReadByte()); Main.iceBackStyle = this.reader.ReadByte(); Main.jungleBackStyle = this.reader.ReadByte(); Main.hellBackStyle = this.reader.ReadByte(); Main.windSpeedSet = this.reader.ReadSingle(); Main.numClouds = this.reader.ReadByte(); for (int t = 0; t < 3; t++) { Main.treeX[t] = this.reader.ReadInt32(); } for (int u = 0; u < 4; u++) { Main.treeStyle[u] = this.reader.ReadByte(); } for (int v = 0; v < 3; v++) { Main.caveBackX[v] = this.reader.ReadInt32(); } for (int w = 0; w < 4; w++) { Main.caveBackStyle[w] = this.reader.ReadByte(); } Main.maxRaining = this.reader.ReadSingle(); Main.raining = Main.maxRaining > 0f; BitsByte bitsByte3 = this.reader.ReadByte(); WorldGen.shadowOrbSmashed = bitsByte3[0]; NPC.downedBoss1 = bitsByte3[1]; NPC.downedBoss2 = bitsByte3[2]; NPC.downedBoss3 = bitsByte3[3]; Main.hardMode = bitsByte3[4]; NPC.downedClown = bitsByte3[5]; Main.ServerSideCharacter = bitsByte3[6]; NPC.downedPlantBoss = bitsByte3[7]; BitsByte bitsByte4 = this.reader.ReadByte(); NPC.downedMechBoss1 = bitsByte4[0]; NPC.downedMechBoss2 = bitsByte4[1]; NPC.downedMechBoss3 = bitsByte4[2]; NPC.downedMechBossAny = bitsByte4[3]; float cloudbg = 0; if (bitsByte4[4]) { cloudbg = 1; } Main.cloudBGActive = (float)cloudbg; WorldGen.crimson = bitsByte4[5]; Main.pumpkinMoon = bitsByte4[6]; Main.snowMoon = bitsByte4[7]; BitsByte bitsByte5 = this.reader.ReadByte(); Main.expertMode = bitsByte5[0]; Main.fastForwardTime = bitsByte5[1]; Main.UpdateSundial(); bool flag1 = bitsByte5[2]; NPC.downedSlimeKing = bitsByte5[3]; NPC.downedQueenBee = bitsByte5[4]; NPC.downedFishron = bitsByte5[5]; NPC.downedMartians = bitsByte5[6]; NPC.downedAncientCultist = bitsByte5[7]; BitsByte bitsByte6 = this.reader.ReadByte(); NPC.downedMoonlord = bitsByte6[0]; NPC.downedHalloweenKing = bitsByte6[1]; NPC.downedHalloweenTree = bitsByte6[2]; NPC.downedChristmasIceQueen = bitsByte6[3]; NPC.downedChristmasSantank = bitsByte6[4]; NPC.downedChristmasTree = bitsByte6[5]; if (!flag1) { Main.StopSlimeRain(true); } else { Main.StartSlimeRain(true); } Main.invasionType = this.reader.ReadSByte(); Main.LobbyId = this.reader.ReadUInt64(); if (Netplay.Connection.State != 3) return; Netplay.Connection.State = 4; return; } case 8: { if (Main.netMode != 2) { return; } int sectionX = this.reader.ReadInt32(); int sectionY = this.reader.ReadInt32(); bool flag2 = true; if (sectionX == -1 || sectionY == -1) { flag2 = false; } else if (sectionX < 10 || sectionX > Main.maxTilesX - 10) { flag2 = false; } else if (sectionY < 10 || sectionY > Main.maxTilesY - 10) { flag2 = false; } int sectionX1 = Netplay.GetSectionX(Main.spawnTileX) - 2; int sectionY1 = Netplay.GetSectionY(Main.spawnTileY) - 1; int num16 = sectionX1 + 5; int num17 = sectionY1 + 3; if (sectionX1 < 0) { sectionX1 = 0; } if (num16 >= Main.maxSectionsX) { num16 = Main.maxSectionsX - 1; } if (sectionY1 < 0) { sectionY1 = 0; } if (num17 >= Main.maxSectionsY) { num17 = Main.maxSectionsY - 1; } int count = (num16 - sectionX1) * (num17 - sectionY1); List<Point> points2 = new List<Point>(); for (int x = sectionX1; x < num16; x++) { for (int y = sectionY1; y < num17; y++) { points2.Add(new Point(x, y)); } } int num18 = -1; int num19 = -1; if (flag2) { sectionX = Netplay.GetSectionX(sectionX) - 2; sectionY = Netplay.GetSectionY(sectionY) - 1; num18 = sectionX + 5; num19 = sectionY + 3; if (sectionX < 0) { sectionX = 0; } if (num18 >= Main.maxSectionsX) { num18 = Main.maxSectionsX - 1; } if (sectionY < 0) { sectionY = 0; } if (num19 >= Main.maxSectionsY) { num19 = Main.maxSectionsY - 1; } for (int a = sectionX; a < num18; a++) { for (int b = sectionY; b < num19; b++) { if (a < sectionX1 || a >= num16 || b < sectionY1 || b >= num17) { points2.Add(new Point(a, b)); count++; } } } } int num20 = 1; PortalHelper.SyncPortalsOnPlayerJoin(this.whoAmI, 1, points2, out points, out points1); count = count + points.Count; if (Netplay.Clients[this.whoAmI].State == 2) { Netplay.Clients[this.whoAmI].State = 3; } NetMessage.SendData(9, this.whoAmI, -1, Lang.inter[44], count, 0f, 0f, 0f, 0, 0, 0); Netplay.Clients[this.whoAmI].StatusText2 = "is receiving tile data"; RemoteClient clients = Netplay.Clients[this.whoAmI]; clients.StatusMax = clients.StatusMax + count; for (int c = sectionX1; c < num16; c++) { for (int d = sectionY1; d < num17; d++) { NetMessage.SendSection(this.whoAmI, c, d, false); } } NetMessage.SendData(11, this.whoAmI, -1, "", sectionX1, (float)sectionY1, (float)(num16 - 1), (float)(num17 - 1), 0, 0, 0); if (flag2) { for (int e = sectionX; e < num18; e++) { for (int f = sectionY; f < num19; f++) { NetMessage.SendSection(this.whoAmI, e, f, true); } } NetMessage.SendData(11, this.whoAmI, -1, "", sectionX, (float)sectionY, (float)(num18 - 1), (float)(num19 - 1), 0, 0, 0); } for (int g = 0; g < points.Count; g++) { NetMessage.SendSection(this.whoAmI, points[g].X, points[g].Y, true); } for (int h = 0; h < points1.Count; h++) { NetMessage.SendData(11, this.whoAmI, -1, "", points1[h].X - num20, (float)(points1[h].Y - num20), (float)(points1[h].X + num20 + 1), (float)(points1[h].Y + num20 + 1), 0, 0, 0); } for (int i1 = 0; i1 < 400; i1++) { if (Main.item[i1].active) { NetMessage.SendData(21, this.whoAmI, -1, "", i1, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(22, this.whoAmI, -1, "", i1, 0f, 0f, 0f, 0, 0, 0); } } for (int j1 = 0; j1 < 200; j1++) { if (Main.npc[j1].active) { NetMessage.SendData(23, this.whoAmI, -1, "", j1, 0f, 0f, 0f, 0, 0, 0); } } for (int k1 = 0; k1 < 1000; k1++) { if (Main.projectile[k1].active && (Main.projPet[Main.projectile[k1].type] || Main.projectile[k1].netImportant)) { NetMessage.SendData(27, this.whoAmI, -1, "", k1, 0f, 0f, 0f, 0, 0, 0); } } for (int l1 = 0; l1 < 251; l1++) { NetMessage.SendData(83, this.whoAmI, -1, "", l1, 0f, 0f, 0f, 0, 0, 0); } NetMessage.SendData(49, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(57, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(7, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(103, -1, -1, "", NPC.MoonLordCountdown, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(101, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); return; } case 9: { if (Main.netMode != 1) { return; } RemoteServer statusMax = Netplay.Connection; statusMax.StatusMax = statusMax.StatusMax + this.reader.ReadInt32(); Netplay.Connection.StatusText = this.reader.ReadString(); return; } case 10: { if (Main.netMode != 1) { return; } NetMessage.DecompressTileBlock(this.readBuffer, num2, length); return; } case 11: { if (Main.netMode != 1) { return; } WorldGen.SectionTileFrame(this.reader.ReadInt16(), this.reader.ReadInt16(), this.reader.ReadInt16(), this.reader.ReadInt16()); return; } case 12: { int num21 = this.reader.ReadByte(); if (Main.netMode == 2) { num21 = this.whoAmI; } Player player4 = Main.player[num21]; player4.SpawnX = this.reader.ReadInt16(); player4.SpawnY = this.reader.ReadInt16(); player4.Spawn(); if (num21 == Main.myPlayer && Main.netMode != 2) { Main.ActivePlayerFileData.StartPlayTimer(); Player.EnterWorld(Main.player[Main.myPlayer]); } if (Main.netMode != 2 || Netplay.Clients[this.whoAmI].State < 3) { return; } if (Netplay.Clients[this.whoAmI].State != 3) { NetMessage.SendData(12, -1, this.whoAmI, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0); return; } Netplay.Clients[this.whoAmI].State = 10; NetMessage.greetPlayer(this.whoAmI); NetMessage.buffer[this.whoAmI].broadcast = true; NetMessage.syncPlayers(); NetMessage.SendData(12, -1, this.whoAmI, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(74, this.whoAmI, -1, Main.player[this.whoAmI].name, Main.anglerQuest, 0f, 0f, 0f, 0, 0, 0); return; } case 13: { int num22 = this.reader.ReadByte(); if (num22 == Main.myPlayer && !Main.ServerSideCharacter) { return; } if (Main.netMode == 2) { num22 = this.whoAmI; } Player item2 = Main.player[num22]; BitsByte bitsByte7 = this.reader.ReadByte(); item2.controlUp = bitsByte7[0]; item2.controlDown = bitsByte7[1]; item2.controlLeft = bitsByte7[2]; item2.controlRight = bitsByte7[3]; item2.controlJump = bitsByte7[4]; item2.controlUseItem = bitsByte7[5]; item2.direction = (bitsByte7[6] ? 1 : -1); BitsByte bitsByte8 = this.reader.ReadByte(); if (!bitsByte8[0]) { item2.pulley = false; } else { item2.pulley = true; item2.pulleyDir = (byte)((bitsByte8[1] ? 2 : 1)); } item2.selectedItem = this.reader.ReadByte(); item2.position = this.reader.ReadVector2(); if (bitsByte8[2]) { item2.velocity = this.reader.ReadVector2(); } else { item2.velocity = Vector2.Zero; } item2.vortexStealthActive = bitsByte8[3]; item2.gravDir = (float)((bitsByte8[4] ? 1 : -1)); if (Main.netMode != 2 || Netplay.Clients[this.whoAmI].State != 10) { return; } NetMessage.SendData(13, -1, this.whoAmI, "", num22, 0f, 0f, 0f, 0, 0, 0); return; } case 14: { if (Main.netMode != 1) { return; } int num23 = this.reader.ReadByte(); if (this.reader.ReadByte() != 1) { Main.player[num23].active = false; return; } if (!Main.player[num23].active) { Main.player[num23] = new Player(); } Main.player[num23].active = true; return; } case 15: case 67: case 93: case 94: case 98: { return; } case 16: { int num24 = this.reader.ReadByte(); if (num24 == Main.myPlayer && !Main.ServerSideCharacter) { return; } if (Main.netMode == 2) { num24 = this.whoAmI; } Player player5 = Main.player[num24]; player5.statLife = this.reader.ReadInt16(); player5.statLifeMax = this.reader.ReadInt16(); if (player5.statLifeMax < 100) { player5.statLifeMax = 100; } player5.dead = player5.statLife <= 0; if (Main.netMode != 2) { return; } NetMessage.SendData(16, -1, this.whoAmI, "", num24, 0f, 0f, 0f, 0, 0, 0); return; } case 17: { byte num25 = this.reader.ReadByte(); int num26 = this.reader.ReadInt16(); int num27 = this.reader.ReadInt16(); short num28 = this.reader.ReadInt16(); int num29 = this.reader.ReadByte(); bool flag3 = num28 == 1; if (!WorldGen.InWorld(num26, num27, 3)) { return; } if (Main.tile[num26, num27] == null) { Main.tile[num26, num27] = new Tile(); } if (Main.netMode == 2) { if (!flag3) { if (num25 == 0 || num25 == 2 || num25 == 4) { RemoteClient spamDeleteBlock = Netplay.Clients[this.whoAmI]; spamDeleteBlock.SpamDeleteBlock = spamDeleteBlock.SpamDeleteBlock + 1f; } if (num25 == 1 || num25 == 3) { RemoteClient spamAddBlock = Netplay.Clients[this.whoAmI]; spamAddBlock.SpamAddBlock = spamAddBlock.SpamAddBlock + 1f; } } if (!Netplay.Clients[this.whoAmI].TileSections[Netplay.GetSectionX(num26), Netplay.GetSectionY(num27)]) { flag3 = true; } } if (num25 == 0) { WorldGen.KillTile(num26, num27, flag3, false, false); } if (num25 == 1) { WorldGen.PlaceTile(num26, num27, num28, false, true, -1, num29); } if (num25 == 2) { WorldGen.KillWall(num26, num27, flag3); } if (num25 == 3) { WorldGen.PlaceWall(num26, num27, num28, false); } if (num25 == 4) { WorldGen.KillTile(num26, num27, flag3, false, true); } if (num25 == 5) { WorldGen.PlaceWire(num26, num27); } if (num25 == 6) { WorldGen.KillWire(num26, num27); } if (num25 == 7) { WorldGen.PoundTile(num26, num27); } if (num25 == 8) { WorldGen.PlaceActuator(num26, num27); } if (num25 == 9) { WorldGen.KillActuator(num26, num27); } if (num25 == 10) { WorldGen.PlaceWire2(num26, num27); } if (num25 == 11) { WorldGen.KillWire2(num26, num27); } if (num25 == 12) { WorldGen.PlaceWire3(num26, num27); } if (num25 == 13) { WorldGen.KillWire3(num26, num27); } if (num25 == 14) { WorldGen.SlopeTile(num26, num27, num28); } if (num25 == 15) { Minecart.FrameTrack(num26, num27, true, false); } if (Main.netMode != 2) { return; } NetMessage.SendData(17, -1, this.whoAmI, "", (int)num25, (float)num26, (float)num27, (float)num28, num29, 0, 0); if (num25 != 1 || num28 != 53) { return; } NetMessage.SendTileSquare(-1, num26, num27, 1); return; } case 18: { if (Main.netMode != 1) { return; } Main.dayTime = this.reader.ReadByte() == 1; Main.time = (double)this.reader.ReadInt32(); Main.sunModY = this.reader.ReadInt16(); Main.moonModY = this.reader.ReadInt16(); return; } case 19: { byte num30 = this.reader.ReadByte(); int num31 = this.reader.ReadInt16(); int num32 = this.reader.ReadInt16(); int num33 = (this.reader.ReadByte() == 0 ? -1 : 1); if (num30 == 0) { WorldGen.OpenDoor(num31, num32, num33); } else if (num30 == 1) { WorldGen.CloseDoor(num31, num32, true); } else if (num30 == 2) { WorldGen.ShiftTrapdoor(num31, num32, num33 == 1, 1); } else if (num30 == 3) { WorldGen.ShiftTrapdoor(num31, num32, num33 == 1, 0); } else if (num30 == 4) { WorldGen.ShiftTallGate(num31, num32, false); } else if (num30 == 5) { WorldGen.ShiftTallGate(num31, num32, true); } if (Main.netMode != 2) { return; } int num34 = this.whoAmI; byte num35 = num30; float single = (float)num31; float single1 = (float)num32; //not sure what this does float variable = 0; if (num33 == 1) { variable = 1; } NetMessage.SendData(19, -1, num34, "", (int)num35, single, single1, (float)variable, 0, 0, 0); return; } case 20: { short num36 = this.reader.ReadInt16(); int num37 = this.reader.ReadInt16(); int num38 = this.reader.ReadInt16(); if (!WorldGen.InWorld(num37, num38, 3)) { return; } BitsByte bitsByte9 = 0; BitsByte bitsByte10 = 0; Tile tile = null; for (int l1 = num37; l1 < num37 + num36; l1++) { for (int m1 = num38; m1 < num38 + num36; m1++) { if (Main.tile[l1, m1] == null) { Main.tile[l1, m1] = new Tile(); } tile = Main.tile[l1, m1]; bool flag4 = tile.active(); bitsByte9 = this.reader.ReadByte(); bitsByte10 = this.reader.ReadByte(); tile.active(bitsByte9[0]); Tile tile1 = tile; byte wall = 0; if (bitsByte9[2]) { wall = 1; } tile1.wall = wall; bool item3 = bitsByte9[3]; if (Main.netMode != 2) { Tile tile2 = tile; byte liquid = 0; if (item3) { liquid = 1; } tile2.liquid = liquid; } tile.wire(bitsByte9[4]); tile.halfBrick(bitsByte9[5]); tile.actuator(bitsByte9[6]); tile.inActive(bitsByte9[7]); tile.wire2(bitsByte10[0]); tile.wire3(bitsByte10[1]); if (bitsByte10[2]) { tile.color(this.reader.ReadByte()); } if (bitsByte10[3]) { tile.wallColor(this.reader.ReadByte()); } if (tile.active()) { int num39 = tile.type; tile.type = this.reader.ReadUInt16(); if (Main.tileFrameImportant[tile.type]) { tile.frameX = this.reader.ReadInt16(); tile.frameY = this.reader.ReadInt16(); } else if (!flag4 || tile.type != num39) { tile.frameX = -1; tile.frameY = -1; } byte num40 = 0; if (bitsByte10[4]) { num40 = (byte)(num40 + 1); } if (bitsByte10[5]) { num40 = (byte)(num40 + 2); } if (bitsByte10[6]) { num40 = (byte)(num40 + 4); } tile.slope(num40); } if (tile.wall > 0) { tile.wall = this.reader.ReadByte(); } if (item3) { tile.liquid = this.reader.ReadByte(); tile.liquidType((int)this.reader.ReadByte()); } } } WorldGen.RangeFrame(num37, num38, num37 + num36, num38 + num36); if (Main.netMode != 2) { return; } NetMessage.SendData((int)num1, -1, this.whoAmI, "", num36, (float)num37, (float)num38, 0f, 0, 0, 0); return; } case 21: case 90: { int num41 = this.reader.ReadInt16(); Vector2 vector2 = this.reader.ReadVector2(); Vector2 vector21 = this.reader.ReadVector2(); int num42 = this.reader.ReadInt16(); int num43 = this.reader.ReadByte(); int num44 = this.reader.ReadByte(); int num45 = this.reader.ReadInt16(); if (Main.netMode == 1) { if (num45 == 0) { Main.item[num41].active = false; return; } Item item4 = Main.item[num41]; item4.netDefaults(num45); item4.Prefix(num43); item4.stack = num42; item4.position = vector2; item4.velocity = vector21; item4.active = true; if (num1 == 90) { item4.instanced = true; item4.owner = Main.myPlayer; item4.keepTime = 600; } item4.wet = Collision.WetCollision(item4.position, item4.width, item4.height); return; } if (Main.itemLockoutTime[num41] > 0) { return; } if (num45 != 0) { bool flag5 = false; if (num41 == 400) { flag5 = true; } if (flag5) { Item item5 = new Item(); item5.netDefaults(num45); num41 = Item.NewItem((int)vector2.X, (int)vector2.Y, item5.width, item5.height, item5.type, num42, true, 0, false); } Item item6 = Main.item[num41]; item6.netDefaults(num45); item6.Prefix(num43); item6.stack = num42; item6.position = vector2; item6.velocity = vector21; item6.active = true; item6.owner = Main.myPlayer; if (!flag5) { NetMessage.SendData(21, -1, this.whoAmI, "", num41, 0f, 0f, 0f, 0, 0, 0); return; } NetMessage.SendData(21, -1, -1, "", num41, 0f, 0f, 0f, 0, 0, 0); if (num44 == 0) { Main.item[num41].ownIgnore = this.whoAmI; Main.item[num41].ownTime = 100; } Main.item[num41].FindOwner(num41); return; } if (num41 >= 400) { return; } Main.item[num41].active = false; NetMessage.SendData(21, -1, -1, "", num41, 0f, 0f, 0f, 0, 0, 0); return; } case 22: { int num46 = this.reader.ReadInt16(); int num47 = this.reader.ReadByte(); if (Main.netMode == 2 && Main.item[num46].owner != this.whoAmI) { return; } Main.item[num46].owner = num47; if (num47 != Main.myPlayer) { Main.item[num46].keepTime = 0; } else { Main.item[num46].keepTime = 15; } if (Main.netMode != 2) { return; } Main.item[num46].owner = 255; Main.item[num46].keepTime = 15; NetMessage.SendData(22, -1, -1, "", num46, 0f, 0f, 0f, 0, 0, 0); return; } case 23: { if (Main.netMode != 1) { return; } int num48 = this.reader.ReadInt16(); Vector2 vector22 = this.reader.ReadVector2(); Vector2 vector23 = this.reader.ReadVector2(); int num49 = this.reader.ReadByte(); BitsByte bitsByte11 = this.reader.ReadByte(); float[] singleArray = new float[NPC.maxAI]; for (int n1 = 0; n1 < NPC.maxAI; n1++) { if (!bitsByte11[n1 + 2]) { singleArray[n1] = 0f; } else { singleArray[n1] = this.reader.ReadSingle(); } } int num50 = this.reader.ReadInt16(); int num51 = 0; if (!bitsByte11[7]) { if (Main.npcLifeBytes[num50] == 2) { num51 = this.reader.ReadInt16(); } else if (Main.npcLifeBytes[num50] != 4) { num51 = this.reader.ReadSByte(); } else { num51 = this.reader.ReadInt32(); } } int num52 = -1; NPC nPC = Main.npc[num48]; if (!nPC.active || nPC.netID != num50) { if (nPC.active) { num52 = nPC.type; } nPC.active = true; nPC.netDefaults(num50); } nPC.position = vector22; nPC.velocity = vector23; nPC.target = num49; nPC.direction = (bitsByte11[0] ? 1 : -1); nPC.directionY = (bitsByte11[1] ? 1 : -1); nPC.spriteDirection = (bitsByte11[6] ? 1 : -1); if (!bitsByte11[7]) { nPC.life = num51; } else { int num53 = nPC.lifeMax; int num54 = num53; nPC.life = num53; num51 = num54; } if (num51 <= 0) { nPC.active = false; } for (int o1 = 0; o1 < NPC.maxAI; o1++) { nPC.ai[o1] = singleArray[o1]; } if (num50 == 262) { NPC.plantBoss = num48; } if (num50 == 245) { NPC.golemBoss = num48; } if (!Main.npcCatchable[nPC.type]) { return; } nPC.releaseOwner = this.reader.ReadByte(); return; } case 24: { int num55 = this.reader.ReadInt16(); int num56 = this.reader.ReadByte(); if (Main.netMode == 2) { num56 = this.whoAmI; } Player player6 = Main.player[num56]; Main.npc[num55].StrikeNPC(player6.inventory[player6.selectedItem].damage, player6.inventory[player6.selectedItem].knockBack, player6.direction, false, false, false); if (Main.netMode != 2) { return; } NetMessage.SendData(24, -1, this.whoAmI, "", num55, (float)num56, 0f, 0f, 0, 0, 0); //NetMessage.SendData(23, -1, -1, "", num55, 0f, 0f, 0f, 0, 0, 0); return; } case 25: { int num57 = this.reader.ReadByte(); if (Main.netMode == 2) { num57 = this.whoAmI; } Color color = this.reader.ReadRGB(); if (Main.netMode == 2) { color = new Color(255, 255, 255); } string str = this.reader.ReadString(); if (Main.netMode != 2) { return; } string lower = str.ToLower(); if (lower == Lang.mp[6] || lower == Lang.mp[21]) { string str2 = ""; for (int p1 = 0; p1 < 255; p1++) { if (Main.player[p1].active) { str2 = (str2 != "" ? string.Concat(str2, ", ", Main.player[p1].name) : Main.player[p1].name); } } NetMessage.SendData(25, this.whoAmI, -1, string.Concat(Lang.mp[7], " ", str2, "."), 255, 255f, 240f, 20f, 0, 0, 0); return; } if (lower.StartsWith("/me ")) { NetMessage.SendData(25, -1, -1, string.Concat("*", Main.player[this.whoAmI].name, " ", str.Substring(4)), 255, 200f, 100f, 0f, 0, 0, 0); return; } if (lower == Lang.mp[8]) { object[] objArray = new object[] { "*", Main.player[this.whoAmI].name, " ", Lang.mp[9], " ", Main.rand.Next(1, 101) }; NetMessage.SendData(25, -1, -1, string.Concat(objArray), 255, 255f, 240f, 20f, 0, 0, 0); return; } if (lower.StartsWith("/p ")) { int num58 = Main.player[this.whoAmI].team; color = Main.teamColor[num58]; if (num58 == 0) { NetMessage.SendData(25, this.whoAmI, -1, Lang.mp[10], 255, 255f, 240f, 20f, 0, 0, 0); return; } for (int q1 = 0; q1 < 255; q1++) { if (Main.player[q1].team == num58) { NetMessage.SendData(25, q1, -1, str.Substring(3), num57, (float)color.R, (float)color.G, (float)color.B, 0, 0, 0); } } return; } if (Main.player[this.whoAmI].difficulty == 2) { color = Main.hcColor; } else if (Main.player[this.whoAmI].difficulty == 1) { color = Main.mcColor; } NetMessage.SendData(25, -1, -1, str, num57, (float)color.R, (float)color.G, (float)color.B, 0, 0, 0); if (!Main.dedServ) { return; } Console.WriteLine(string.Concat("<", Main.player[this.whoAmI].name, "> ", str)); return; } case 26: { int num59 = this.reader.ReadByte(); if (Main.netMode == 2 && this.whoAmI != num59 && (!Main.player[num59].hostile || !Main.player[this.whoAmI].hostile)) { return; } int num60 = this.reader.ReadByte() - 1; int num61 = this.reader.ReadInt16(); string str3 = this.reader.ReadString(); BitsByte bitsByte12 = this.reader.ReadByte(); bool flag6 = bitsByte12[0]; bool item7 = bitsByte12[1]; Main.player[num59].Hurt(num61, num60, flag6, true, str3, item7); if (Main.netMode != 2) { return; } int num62 = this.whoAmI; string str4 = str3; int num63 = num59; float single2 = (float)num60; float single3 = (float)num61; float crit = 0; if (flag6) { crit = 1; } NetMessage.SendData(26, -1, num62, str4, num63, single2, single3, crit, (item7 ? 1 : 0), 0, 0); return; } case 27: { int num67 = this.reader.ReadInt16(); Vector2 vector24 = this.reader.ReadVector2(); Vector2 vector25 = this.reader.ReadVector2(); float single4 = this.reader.ReadSingle(); int num68 = this.reader.ReadInt16(); int num69 = this.reader.ReadByte(); int num70 = this.reader.ReadInt16(); BitsByte bitsByte13 = this.reader.ReadByte(); float[] singleArray1 = new float[Projectile.maxAI]; if (num70 < 0 || num70 >= Main.maxProjectileTypes) return; for (int s1 = 0; s1 < Projectile.maxAI; s1++) { if (!bitsByte13[s1]) { singleArray1[s1] = 0f; } else { singleArray1[s1] = this.reader.ReadSingle(); } } if (Main.netMode == 2) { num69 = this.whoAmI; if (Main.projHostile[num70]) { return; } } int num71 = 1000; int num72 = 0; while (num72 < 1000) { if (Main.projectile[num72].owner != num69 || Main.projectile[num72].identity != num67 || !Main.projectile[num72].active) { num72++; } else { num71 = num72; break; } } if (num71 == 1000) { int num73 = 0; while (num73 < 1000) { if (Main.projectile[num73].active) { num73++; } else { num71 = num73; break; } } } Projectile projectile = Main.projectile[num71]; if (!projectile.active || projectile.type != num70) { projectile.SetDefaults(num70); if (Main.netMode == 2) { RemoteClient spamProjectile = Netplay.Clients[this.whoAmI]; spamProjectile.SpamProjectile = spamProjectile.SpamProjectile + 1f; } } projectile.identity = num67; projectile.position = vector24; projectile.velocity = vector25; projectile.type = num70; projectile.damage = num68; projectile.knockBack = single4; projectile.owner = num69; for (int t1 = 0; t1 < Projectile.maxAI; t1++) { projectile.ai[t1] = singleArray1[t1]; } Main.projectileIdentity[num69, num67] = num71; if (Main.netMode != 2) { projectile.ProjectileFixDesperation(num69); } if (Main.netMode != 2) { return; } NetMessage.SendData(27, -1, this.whoAmI, "", num71, 0f, 0f, 0f, 0, 0, 0); return; } case 28: { int num71 = this.reader.ReadInt16(); int num72 = this.reader.ReadInt16(); float single5 = this.reader.ReadSingle(); int num73 = this.reader.ReadByte() - 1; byte num74 = this.reader.ReadByte(); if (Main.netMode == 2) { Main.npc[num71].PlayerInteraction(this.whoAmI); } if (num72 < 0) { Main.npc[num71].life = 0; Main.npc[num71].HitEffect(0, 10); Main.npc[num71].active = false; } else { Main.npc[num71].StrikeNPC(num72, single5, num73, num74 == 1, false, true); } if (Main.netMode != 2) { return; } NetMessage.SendData(28, -1, this.whoAmI, "", num71, (float)num72, single5, (float)num73, (int)num74, 0, 0); if (Main.npc[num71].life > 0) { Main.npc[num71].netUpdate = true; return; } //NetMessage.SendData(23, -1, -1, "", num71, 0f, 0f, 0f, 0, 0, 0); return; } case 29: { int num75 = this.reader.ReadInt16(); int num76 = this.reader.ReadByte(); if (Main.netMode == 2) { num76 = this.whoAmI; } int num77 = 0; while (num77 < 1000) { if (Main.projectile[num77].owner != num76 || Main.projectile[num77].identity != num75 || !Main.projectile[num77].active) { num77++; } else { Main.projectile[num77].Kill(); break; } } if (Main.netMode != 2) { return; } NetMessage.SendData(29, -1, this.whoAmI, "", num75, (float)num76, 0f, 0f, 0, 0, 0); return; } case 30: { int num78 = this.reader.ReadByte(); if (Main.netMode == 2) { num78 = this.whoAmI; } bool flag7 = this.reader.ReadBoolean(); Main.player[num78].hostile = flag7; if (Main.netMode != 2) { return; } NetMessage.SendData(30, -1, this.whoAmI, "", num78, 0f, 0f, 0f, 0, 0, 0); string str5 = string.Concat(" ", Lang.mp[(flag7 ? 11 : 12)]); Color color1 = Main.teamColor[Main.player[num78].team]; NetMessage.SendData(25, -1, -1, string.Concat(Main.player[num78].name, str5), 255, (float)color1.R, (float)color1.G, (float)color1.B, 0, 0, 0); return; } case 31: { if (Main.netMode != 2) { return; } int num79 = this.reader.ReadInt16(); int num80 = this.reader.ReadInt16(); int num81 = Chest.FindChest(num79, num80); if (num81 <= -1 || Chest.UsingChest(num81) != -1) { return; } for (int t1 = 0; t1 < 40; t1++) { NetMessage.SendData(32, this.whoAmI, -1, "", num81, (float)t1, 0f, 0f, 0, 0, 0); } NetMessage.SendData(33, this.whoAmI, -1, "", num81, 0f, 0f, 0f, 0, 0, 0); Main.player[this.whoAmI].chest = num81; if (Main.myPlayer == this.whoAmI) { Main.recBigList = false; } Recipe.FindRecipes(); NetMessage.SendData(80, -1, this.whoAmI, "", this.whoAmI, (float)num81, 0f, 0f, 0, 0, 0); if (Main.tile[num79, num80].frameX < 36 || Main.tile[num79, num80].frameX >= 72) { return; } AchievementsHelper.HandleSpecialEvent(Main.player[this.whoAmI], 16); return; } case 32: { int num82 = this.reader.ReadInt16(); int num83 = this.reader.ReadByte(); int num84 = this.reader.ReadInt16(); int num85 = this.reader.ReadByte(); int num86 = this.reader.ReadInt16(); if (Main.chest[num82] == null) { Main.chest[num82] = new Chest(false); } if (Main.chest[num82].item[num83] == null) { Main.chest[num82].item[num83] = new Item(); } Main.chest[num82].item[num83].netDefaults(num86); Main.chest[num82].item[num83].Prefix(num85); Main.chest[num82].item[num83].stack = num84; Recipe.FindRecipes(); return; } case 33: { int num87 = this.reader.ReadInt16(); int num88 = this.reader.ReadInt16(); int num89 = this.reader.ReadInt16(); int num90 = this.reader.ReadByte(); string empty = string.Empty; if (num90 != 0) { if (num90 <= 20) { empty = this.reader.ReadString(); } else if (num90 != 255) { num90 = 0; } } if (Main.netMode != 1) { if (num90 != 0) { int num91 = Main.player[this.whoAmI].chest; Chest chest = Main.chest[num91]; chest.name = empty; NetMessage.SendData(69, -1, this.whoAmI, empty, num91, (float)chest.x, (float)chest.y, 0f, 0, 0, 0); } Main.player[this.whoAmI].chest = num87; Recipe.FindRecipes(); NetMessage.SendData(80, -1, this.whoAmI, "", this.whoAmI, (float)num87, 0f, 0f, 0, 0, 0); return; } Player player7 = Main.player[Main.myPlayer]; if (player7.chest == -1) { Main.playerInventory = true; } else if (player7.chest != num87 && num87 != -1) { Main.playerInventory = true; Main.recBigList = false; } else if (player7.chest != -1 && num87 == -1) { Main.recBigList = false; } player7.chest = num87; player7.chestX = num88; player7.chestY = num89; Recipe.FindRecipes(); return; } case 34: { byte num92 = this.reader.ReadByte(); int num93 = this.reader.ReadInt16(); int num94 = this.reader.ReadInt16(); int num95 = this.reader.ReadInt16(); if (num93 > Main.maxTilesX || num94 > Main.maxTilesY) { return; } if (Main.netMode != 2) { int num96 = this.reader.ReadInt16(); if (num92 == 0) { if (num96 == -1) { WorldGen.KillTile(num93, num94, false, false, false); return; } WorldGen.PlaceChestDirect(num93, num94, 21, num95, num96); return; } if (num92 != 2) { Chest.DestroyChestDirect(num93, num94, num96); WorldGen.KillTile(num93, num94, false, false, false); return; } if (num96 == -1) { WorldGen.KillTile(num93, num94, false, false, false); return; } WorldGen.PlaceDresserDirect(num93, num94, 88, num95, num96); return; } if (num92 == 0) { int num97 = WorldGen.PlaceChest(num93, num94, 21, false, num95); if (num97 != -1) { NetMessage.SendData(34, -1, -1, "", (int)num92, (float)num93, (float)num94, (float)num95, num97, 0, 0); return; } NetMessage.SendData(34, this.whoAmI, -1, "", (int)num92, (float)num93, (float)num94, (float)num95, num97, 0, 0); Item.NewItem(num93 * 16, num94 * 16, 32, 32, Chest.chestItemSpawn[num95], 1, true, 0, false); return; } if (num92 == 2) { int num98 = WorldGen.PlaceChest(num93, num94, 88, false, num95); if (num98 != -1) { NetMessage.SendData(34, -1, -1, "", (int)num92, (float)num93, (float)num94, (float)num95, num98, 0, 0); return; } NetMessage.SendData(34, this.whoAmI, -1, "", (int)num92, (float)num93, (float)num94, (float)num95, num98, 0, 0); Item.NewItem(num93 * 16, num94 * 16, 32, 32, Chest.dresserItemSpawn[num95], 1, true, 0, false); return; } Tile tile3 = Main.tile[num93, num94]; if (tile3.type != 21 || num92 != 1) { if (tile3.type != 88 || num92 != 3) { return; } num93 = num93 - tile3.frameX % 54 / 18; if (tile3.frameY % 36 != 0) { num94--; } int num99 = Chest.FindChest(num93, num94); WorldGen.KillTile(num93, num94, false, false, false); if (tile3.active()) { return; } NetMessage.SendData(34, -1, -1, "", (int)num92, (float)num93, (float)num94, 0f, num99, 0, 0); return; } else { if (tile3.frameX % 36 != 0) { num93--; } if (tile3.frameY % 36 != 0) { num94--; } int num100 = Chest.FindChest(num93, num94); WorldGen.KillTile(num93, num94, false, false, false); if (tile3.active()) { return; } NetMessage.SendData(34, -1, -1, "", (int)num92, (float)num93, (float)num94, 0f, num100, 0, 0); return; } } case 35: { int num101 = this.reader.ReadByte(); if (Main.netMode == 2) { num101 = this.whoAmI; } int num102 = this.reader.ReadInt16(); if (num101 != Main.myPlayer || Main.ServerSideCharacter) { Main.player[num101].HealEffect(num102, true); } if (Main.netMode != 2) { return; } NetMessage.SendData(35, -1, this.whoAmI, "", num101, (float)num102, 0f, 0f, 0, 0, 0); return; } case 36: { int num103 = this.reader.ReadByte(); if (Main.netMode == 2) { num103 = this.whoAmI; } Player player8 = Main.player[num103]; player8.zone1 = this.reader.ReadByte(); player8.zone2 = this.reader.ReadByte(); if (Main.netMode != 2) { return; } NetMessage.SendData(36, -1, this.whoAmI, "", num103, 0f, 0f, 0f, 0, 0, 0); return; } case 37: { if (Main.netMode != 1) { return; } if (!Main.autoPass) { Netplay.ServerPassword = ""; Main.menuMode = 31; return; } NetMessage.SendData(38, -1, -1, Netplay.ServerPassword, 0, 0f, 0f, 0f, 0, 0, 0); Main.autoPass = false; return; } case 38: { if (Main.netMode != 2) { return; } if (this.reader.ReadString() != Netplay.ServerPassword) { NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[1], 0, 0f, 0f, 0f, 0, 0, 0); return; } Netplay.Clients[this.whoAmI].State = 1; NetMessage.SendData(3, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); return; } case 39: { if (Main.netMode != 1) { return; } int num104 = this.reader.ReadInt16(); Main.item[num104].owner = 255; NetMessage.SendData(22, -1, -1, "", num104, 0f, 0f, 0f, 0, 0, 0); return; } case 40: { int num105 = this.reader.ReadByte(); if (Main.netMode == 2) { num105 = this.whoAmI; } int num106 = this.reader.ReadInt16(); Main.player[num105].talkNPC = num106; if (Main.netMode != 2) { return; } NetMessage.SendData(40, -1, this.whoAmI, "", num105, 0f, 0f, 0f, 0, 0, 0); return; } case 41: { int num107 = this.reader.ReadByte(); if (Main.netMode == 2) { num107 = this.whoAmI; } Player player9 = Main.player[num107]; float single6 = this.reader.ReadSingle(); int num108 = this.reader.ReadInt16(); player9.itemRotation = single6; player9.itemAnimation = num108; player9.channel = player9.inventory[player9.selectedItem].channel; if (Main.netMode != 2) { return; } NetMessage.SendData(41, -1, this.whoAmI, "", num107, 0f, 0f, 0f, 0, 0, 0); return; } case 42: { int num109 = this.reader.ReadByte(); if (Main.netMode == 2) { num109 = this.whoAmI; } else if (Main.myPlayer == num109 && !Main.ServerSideCharacter) { return; } int num110 = this.reader.ReadInt16(); int num111 = this.reader.ReadInt16(); Main.player[num109].statMana = num110; Main.player[num109].statManaMax = num111; return; } case 43: { int num112 = this.reader.ReadByte(); if (Main.netMode == 2) { num112 = this.whoAmI; } int num113 = this.reader.ReadInt16(); if (num112 != Main.myPlayer) { Main.player[num112].ManaEffect(num113); } if (Main.netMode != 2) { return; } NetMessage.SendData(43, -1, this.whoAmI, "", num112, (float)num113, 0f, 0f, 0, 0, 0); return; } case 44: { int num114 = this.reader.ReadByte(); if (Main.netMode == 2) { num114 = this.whoAmI; } int num115 = this.reader.ReadByte() - 1; int num116 = this.reader.ReadInt16(); byte num117 = this.reader.ReadByte(); string str6 = this.reader.ReadString(); Main.player[num114].KillMe((double)num116, num115, num117 == 1, str6); if (Main.netMode != 2) { return; } NetMessage.SendData(44, -1, this.whoAmI, str6, num114, (float)num115, (float)num116, (float)num117, 0, 0, 0); return; } case 45: { int num118 = this.reader.ReadByte(); if (Main.netMode == 2) { num118 = this.whoAmI; } int num119 = this.reader.ReadByte(); Player player10 = Main.player[num118]; int num120 = player10.team; player10.team = num119; Color color2 = Main.teamColor[num119]; if (Main.netMode != 2) { return; } NetMessage.SendData(45, -1, this.whoAmI, "", num118, 0f, 0f, 0f, 0, 0, 0); string str7 = string.Concat(" ", Lang.mp[13 + num119]); if (num119 == 5) { str7 = string.Concat(" ", Lang.mp[22]); } for (int u1 = 0; u1 < 255; u1++) { if (u1 == this.whoAmI || num120 > 0 && Main.player[u1].team == num120 || num119 > 0 && Main.player[u1].team == num119) { NetMessage.SendData(25, u1, -1, string.Concat(player10.name, str7), 255, (float)color2.R, (float)color2.G, (float)color2.B, 0, 0, 0); } } return; } case 46: { if (Main.netMode != 2) { return; } int num121 = this.reader.ReadInt16(); int num122 = this.reader.ReadInt16(); int num123 = Sign.ReadSign(num121, num122, true); if (num123 < 0) { return; } NetMessage.SendData(47, this.whoAmI, -1, "", num123, (float)this.whoAmI, 0f, 0f, 0, 0, 0); return; } case 47: { int num124 = this.reader.ReadInt16(); int num125 = this.reader.ReadInt16(); int num126 = this.reader.ReadInt16(); string str8 = this.reader.ReadString(); string str9 = ""; if (Main.sign[num124] != null) { str9 = Main.sign[num124].text; } Main.sign[num124] = new Sign(); Main.sign[num124].x = num125; Main.sign[num124].y = num126; Sign.TextSign(num124, str8); int num127 = this.reader.ReadByte(); if (Main.netMode == 2 && str9 != str8) { num127 = this.whoAmI; NetMessage.SendData(47, -1, this.whoAmI, "", num124, (float)num127, 0f, 0f, 0, 0, 0); } if (Main.netMode != 1 || num127 != Main.myPlayer || Main.sign[num124] == null) { return; } Main.playerInventory = false; Main.player[Main.myPlayer].talkNPC = -1; Main.npcChatCornerItem = 0; Main.editSign = false; Main.player[Main.myPlayer].sign = num124; Main.npcChatText = Main.sign[num124].text; return; } case 48: { int num128 = this.reader.ReadInt16(); int num129 = this.reader.ReadInt16(); byte num130 = this.reader.ReadByte(); byte num131 = this.reader.ReadByte(); if (Main.netMode == 2 && Netplay.spamCheck) { int num132 = this.whoAmI; int x1 = (int)(Main.player[num132].position.X + (float)(Main.player[num132].width / 2)); int y1 = (int)(Main.player[num132].position.Y + (float)(Main.player[num132].height / 2)); int num133 = 10; int num134 = x1 - num133; int num135 = x1 + num133; int num136 = y1 - num133; int num137 = y1 + num133; if (num128 < num134 || num128 > num135 || num129 < num136 || num129 > num137) { NetMessage.BootPlayer(this.whoAmI, "Cheating attempt detected: Liquid spam"); return; } } if (Main.tile[num128, num129] == null) { Main.tile[num128, num129] = new Tile(); } lock (Main.tile[num128, num129]) { Main.tile[num128, num129].liquid = num130; Main.tile[num128, num129].liquidType((int)num131); if (Main.netMode == 2) { WorldGen.SquareTileFrame(num128, num129, true); } return; } } case 49: { if (Netplay.Connection.State != 6) { return; } Netplay.Connection.State = 10; Main.ActivePlayerFileData.StartPlayTimer(); Player.EnterWorld(Main.player[Main.myPlayer]); Main.player[Main.myPlayer].Spawn(); return; } case 50: { int num138 = this.reader.ReadByte(); if (Main.netMode == 2) { num138 = this.whoAmI; } else if (num138 == Main.myPlayer && !Main.ServerSideCharacter) { return; } Player player11 = Main.player[num138]; for (int v1 = 0; v1 < 22; v1++) { player11.buffType[v1] = this.reader.ReadByte(); if (player11.buffType[v1] <= 0) { player11.buffTime[v1] = 0; } else { player11.buffTime[v1] = 60; } } if (Main.netMode != 2) { return; } NetMessage.SendData(50, -1, this.whoAmI, "", num138, 0f, 0f, 0f, 0, 0, 0); return; } case 51: { byte num139 = this.reader.ReadByte(); byte num140 = this.reader.ReadByte(); if (num140 == 1) { NPC.SpawnSkeletron(); return; } if (num140 == 2) { if (Main.netMode == 2) { NetMessage.SendData(51, -1, this.whoAmI, "", (int)num139, (float)num140, 0f, 0f, 0, 0, 0); return; } return; } if (num140 != 3) { if (num140 != 4) { return; } Main.npc[num139].BigMimicSpawnSmoke(); return; } else { if (Main.netMode != 2) { return; } Main.Sundialing(); return; } } case 52: { int ldap = (int)this.reader.ReadByte(); int ad = (int)this.reader.ReadInt16(); int winfs = (int)this.reader.ReadInt16(); if (ldap == 1) { Chest.Unlock(ad, winfs); if (Main.netMode == 2) { NetMessage.SendData(52, -1, this.whoAmI, "", 0, (float)ldap, (float)ad, (float)winfs, 0, 0, 0); NetMessage.SendTileSquare(-1, ad, winfs, 2); } } if (ldap != 2) { return; } WorldGen.UnlockDoor(ad, winfs); if (Main.netMode == 2) { NetMessage.SendData(52, -1, this.whoAmI, "", 0, (float)ldap, (float)ad, (float)winfs, 0, 0, 0); NetMessage.SendTileSquare(-1, ad, winfs, 2); return; } return; } case 53: { int num145 = this.reader.ReadInt16(); int num146 = this.reader.ReadByte(); int num147 = this.reader.ReadInt16(); Main.npc[num145].AddBuff(num146, num147, false); if (Main.netMode != 2) { return; } //NetMessage.SendData(54, -1, -1, "", num145, 0f, 0f, 0f, 0, 0, 0); return; } case 54: { if (Main.netMode != 1) { return; } int num148 = this.reader.ReadInt16(); NPC nPC1 = Main.npc[num148]; for (int w1 = 0; w1 < 5; w1++) { nPC1.buffType[w1] = this.reader.ReadByte(); nPC1.buffTime[w1] = this.reader.ReadInt16(); } return; } case 55: { int num149 = this.reader.ReadByte(); int num150 = this.reader.ReadByte(); int num151 = this.reader.ReadInt16(); if (Main.netMode == 2 && num149 != this.whoAmI && !Main.pvpBuff[num150]) { return; } if (Main.netMode == 1 && num149 == Main.myPlayer) { Main.player[num149].AddBuff(num150, num151, true); return; } if (Main.netMode != 2) { return; } NetMessage.SendData(55, num149, -1, "", num149, (float)num150, (float)num151, 0f, 0, 0, 0); return; } case 56: { int num152 = this.reader.ReadInt16(); if (num152 < 0 || num152 >= 200) { return; } if (Main.netMode == 1) { Main.npc[num152].displayName = this.reader.ReadString(); return; } if (Main.netMode != 2) { return; } NetMessage.SendData(56, this.whoAmI, -1, Main.npc[num152].displayName, num152, 0f, 0f, 0f, 0, 0, 0); return; } case 57: { if (Main.netMode != 1) { return; } WorldGen.tGood = this.reader.ReadByte(); WorldGen.tEvil = this.reader.ReadByte(); WorldGen.tBlood = this.reader.ReadByte(); return; } case 58: { int num153 = this.reader.ReadByte(); if (Main.netMode == 2) { num153 = this.whoAmI; } float single7 = this.reader.ReadSingle(); if (Main.netMode == 2) { NetMessage.SendData(58, -1, this.whoAmI, "", this.whoAmI, single7, 0f, 0f, 0, 0, 0); return; } Player player12 = Main.player[num153]; Main.harpNote = single7; int num154 = 26; if (player12.inventory[player12.selectedItem].type == 507) { num154 = 35; } return; } case 59: { int num155 = this.reader.ReadInt16(); int num156 = this.reader.ReadInt16(); Wiring.HitSwitch(num155, num156); if (Main.netMode != 2) { return; } NetMessage.SendData(59, -1, this.whoAmI, "", num155, (float)num156, 0f, 0f, 0, 0, 0); return; } case 60: { int num157 = this.reader.ReadInt16(); int num158 = this.reader.ReadInt16(); int num159 = this.reader.ReadInt16(); byte num160 = this.reader.ReadByte(); if (num157 >= 200) { NetMessage.BootPlayer(this.whoAmI, "cheating attempt detected: Invalid kick-out"); return; } if (Main.netMode != 1) { if (num160 == 0) { WorldGen.kickOut(num157); return; } WorldGen.moveRoom(num158, num159, num157); return; } Main.npc[num157].homeless = num160 == 1; Main.npc[num157].homeTileX = num158; Main.npc[num157].homeTileY = num159; return; } case 61: { int num161 = this.reader.ReadInt16(); int num162 = this.reader.ReadInt16(); if (Main.netMode != 2) { return; } if (num162 >= 0 && num162 < 540 && NPCID.Sets.MPAllowedEnemies[num162]) { if (num162 == 75) { for (int x11 = 0; x11 < 200; x11++) { if (!Main.npc[x11].townNPC) { Main.npc[x11].active = false; } } } if (NPC.AnyNPCs(num162)) { return; } NPC.SpawnOnPlayer(num161, num162); return; } else if (num162 == -4) { if (Main.dayTime) { return; } NetMessage.SendData(25, -1, -1, Lang.misc[31], 255, 50f, 255f, 130f, 0, 0, 0); Main.startPumpkinMoon(); NetMessage.SendData(7, -1, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(78, -1, -1, "", 0, 1f, 2f, 1f, 0, 0, 0); return; } else if (num162 == -5) { if (Main.dayTime) { return; } NetMessage.SendData(25, -1, -1, Lang.misc[34], 255, 50f, 255f, 130f, 0, 0, 0); Main.startSnowMoon(); NetMessage.SendData(7, -1, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(78, -1, -1, "", 0, 1f, 1f, 1f, 0, 0, 0); return; } else if (num162 != -6) { if (num162 == -7) { NetMessage.SendData(25, -1, -1, "martian moon toggled", 255, 50f, 255f, 130f, 0, 0, 0); Main.invasionDelay = 0; Main.StartInvasion(4); NetMessage.SendData(7, -1, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(78, -1, -1, "", 0, 1f, (float)(Main.invasionType + 2), 0f, 0, 0, 0); return; } if (num162 >= 0) { return; } int num163 = 1; if (num162 > -5) { num163 = -num162; } if (num163 > 0 && Main.invasionType == 0) { Main.invasionDelay = 0; Main.StartInvasion(num163); } NetMessage.SendData(78, -1, -1, "", 0, 1f, (float)(Main.invasionType + 2), 0f, 0, 0, 0); return; } else { if (!Main.dayTime) { return; } NetMessage.SendData(25, -1, -1, Lang.misc[20], 255, 50f, 255f, 130f, 0, 0, 0); Main.eclipse = true; NetMessage.SendData(7, -1, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); return; } } case 62: { int num164 = this.reader.ReadByte(); int num165 = this.reader.ReadByte(); if (Main.netMode == 2) { num164 = this.whoAmI; } if (num165 == 1) { Main.player[num164].NinjaDodge(); } if (num165 == 2) { Main.player[num164].ShadowDodge(); } if (Main.netMode != 2) { return; } NetMessage.SendData(62, -1, this.whoAmI, "", num164, (float)num165, 0f, 0f, 0, 0, 0); return; } case 63: { int num166 = this.reader.ReadInt16(); int num167 = this.reader.ReadInt16(); byte num168 = this.reader.ReadByte(); WorldGen.paintTile(num166, num167, num168, false); if (Main.netMode != 2) { return; } NetMessage.SendData(63, -1, this.whoAmI, "", num166, (float)num167, (float)num168, 0f, 0, 0, 0); return; } case 64: { int num169 = this.reader.ReadInt16(); int num170 = this.reader.ReadInt16(); byte num171 = this.reader.ReadByte(); WorldGen.paintWall(num169, num170, num171, false); if (Main.netMode != 2) { return; } NetMessage.SendData(64, -1, this.whoAmI, "", num169, (float)num170, (float)num171, 0f, 0, 0, 0); return; } case 65: { BitsByte bitsByte14 = this.reader.ReadByte(); int num172 = this.reader.ReadInt16(); if (Main.netMode == 2) { num172 = this.whoAmI; } Vector2 vector26 = this.reader.ReadVector2(); int num173 = 0; int num174 = 0; if (bitsByte14[0]) { num173++; } if (bitsByte14[1]) { num173 = num173 + 2; } if (bitsByte14[2]) { num174++; } if (bitsByte14[3]) { num174 = num174 + 2; } if (num173 == 0) { Main.player[num172].Teleport(vector26, num174, 0); } else if (num173 == 1) { Main.npc[num172].Teleport(vector26, num174, 0); } else if (num173 == 2) { Main.player[num172].Teleport(vector26, num174, 0); if (Main.netMode == 2) { RemoteClient.CheckSection(this.whoAmI, vector26, 1); NetMessage.SendData(65, -1, -1, "", 0, (float)num172, vector26.X, vector26.Y, num174, 0, 0); int num175 = -1; float single8 = 9999f; for (int y11 = 0; y11 < 255; y11++) { if (Main.player[y11].active && y11 != this.whoAmI) { Vector2 vector27 = Main.player[y11].position - Main.player[this.whoAmI].position; if (vector27.Length() < single8) { single8 = vector27.Length(); num175 = y11; } } } if (num175 >= 0) { NetMessage.SendData(25, -1, -1, string.Concat(Main.player[this.whoAmI].name, " has teleported to ", Main.player[num175].name), 255, 250f, 250f, 0f, 0, 0, 0); } } } if (Main.netMode != 2 || num173 != 0) { return; } NetMessage.SendData(65, -1, this.whoAmI, "", 0, (float)num172, vector26.X, vector26.Y, num174, 0, 0); return; } case 66: { int num176 = this.reader.ReadByte(); int num177 = this.reader.ReadInt16(); if (num177 <= 0) { return; } Player player13 = Main.player[num176]; Player player14 = player13; player14.statLife = player14.statLife + num177; if (player13.statLife > player13.statLifeMax2) { player13.statLife = player13.statLifeMax2; } player13.HealEffect(num177, false); if (Main.netMode != 2) { return; } NetMessage.SendData(66, -1, this.whoAmI, "", num176, (float)num177, 0f, 0f, 0, 0, 0); return; } case 68: { this.reader.ReadString(); return; } case 69: { int num178 = this.reader.ReadInt16(); int num179 = this.reader.ReadInt16(); int num180 = this.reader.ReadInt16(); if (Main.netMode == 1) { if (num178 < 0 || num178 >= 1000) { return; } Chest chest1 = Main.chest[num178]; if (chest1 == null) { chest1 = new Chest(false) { x = num179, y = num180 }; Main.chest[num178] = chest1; } else if (chest1.x != num179 || chest1.y != num180) { return; } chest1.name = this.reader.ReadString(); return; } if (num178 < -1 || num178 >= 1000) { return; } if (num178 == -1) { num178 = Chest.FindChest(num179, num180); if (num178 == -1) { return; } } Chest chest2 = Main.chest[num178]; if (chest2.x != num179 || chest2.y != num180) { return; } NetMessage.SendData(69, this.whoAmI, -1, chest2.name, num178, (float)num179, (float)num180, 0f, 0, 0, 0); return; } case 70: { if (Main.netMode != 2) { return; } int num181 = this.reader.ReadInt16(); int num182 = this.reader.ReadByte(); if (Main.netMode == 2) { num182 = this.whoAmI; } if (num181 < 200 && num181 >= 0) { NPC.CatchNPC(num181, num182); return; } return; } case 71: { if (Main.netMode != 2) { return; } int num183 = this.reader.ReadInt32(); int num184 = this.reader.ReadInt32(); int num185 = this.reader.ReadInt16(); byte num186 = this.reader.ReadByte(); NPC.ReleaseNPC(num183, num184, num185, (int)num186, this.whoAmI); return; } case 72: { if (Main.netMode != 1) { return; } for (int a1 = 0; a1 < 40; a1++) { Main.travelShop[a1] = this.reader.ReadInt16(); } return; } case 73: { Main.player[this.whoAmI].TeleportationPotion(); return; } case 74: { if (Main.netMode != 1) { return; } Main.anglerQuest = this.reader.ReadByte(); Main.anglerQuestFinished = this.reader.ReadBoolean(); return; } case 75: { if (Main.netMode != 2) { return; } string str10 = Main.player[this.whoAmI].name; if (Main.anglerWhoFinishedToday.Contains(str10)) { return; } Main.anglerWhoFinishedToday.Add(str10); return; } case 76: { int num187 = this.reader.ReadByte(); if (num187 == Main.myPlayer && !Main.ServerSideCharacter) { return; } if (Main.netMode == 2) { num187 = this.whoAmI; } Main.player[num187].anglerQuestsFinished = this.reader.ReadInt32(); if (Main.netMode != 2) { return; } NetMessage.SendData(76, -1, this.whoAmI, "", num187, 0f, 0f, 0f, 0, 0, 0); return; } case 77: { short num188 = this.reader.ReadInt16(); ushort num189 = this.reader.ReadUInt16(); short num190 = this.reader.ReadInt16(); Animation.NewTemporaryAnimation(num188, num189, num190, this.reader.ReadInt16()); return; } case 78: { if (Main.netMode != 1) { return; } Main.ReportInvasionProgress(this.reader.ReadInt32(), this.reader.ReadInt32(), this.reader.ReadSByte(), this.reader.ReadSByte()); return; } case 79: { int num191 = this.reader.ReadInt16(); int num192 = this.reader.ReadInt16(); short num193 = this.reader.ReadInt16(); int num194 = this.reader.ReadInt16(); int num195 = this.reader.ReadByte(); int num196 = this.reader.ReadSByte(); num = (!this.reader.ReadBoolean() ? -1 : 1); if (Main.netMode == 2) { RemoteClient remoteClient = Netplay.Clients[this.whoAmI]; remoteClient.SpamAddBlock = remoteClient.SpamAddBlock + 1f; if (!Netplay.Clients[this.whoAmI].TileSections[Netplay.GetSectionX(num191), Netplay.GetSectionY(num192)]) { return; } } WorldGen.PlaceObject(num191, num192, num193, false, num194, num195, num196, num); if (Main.netMode != 2) { return; } NetMessage.SendObjectPlacment(this.whoAmI, num191, num192, num193, num194, num195, num196, num); return; } case 80: { if (Main.netMode != 1) { return; } int num197 = this.reader.ReadByte(); int num198 = this.reader.ReadInt16(); Main.player[num197].chest = num198; Recipe.FindRecipes(); return; } case 81: { if (Main.netMode != 1) { return; } int num199 = (int)this.reader.ReadSingle(); int num200 = (int)this.reader.ReadSingle(); Color color3 = this.reader.ReadRGB(); string str11 = this.reader.ReadString(); CombatText.NewText(new Rectangle(num199, num200, 0, 0), color3, str11, false, false); return; } case 82: { NetManager.Instance.Read(this.reader, this.whoAmI); return; } case 83: { if (Main.netMode != 1) { return; } int num201 = this.reader.ReadInt16(); int num202 = this.reader.ReadInt32(); if (num201 < 0 || num201 >= 251) { return; } NPC.killCount[num201] = num202; return; } case 84: { byte num203 = this.reader.ReadByte(); float single9 = this.reader.ReadSingle(); Main.player[num203].stealth = single9; if (Main.netMode != 2) { return; } NetMessage.SendData(84, -1, this.whoAmI, "", (int)num203, 0f, 0f, 0f, 0, 0, 0); return; } case 85: { int num204 = this.whoAmI; byte num205 = this.reader.ReadByte(); if (Main.netMode != 2 || num204 >= 255 || num205 >= 58) { return; } Chest.ServerPlaceItem(this.whoAmI, (int)num205); return; } case 86: { if (Main.netMode != 1) { return; } int num206 = this.reader.ReadInt32(); if (this.reader.ReadBoolean()) { TileEntity tileEntity1 = TileEntity.Read(this.reader); TileEntity.ByID[tileEntity1.ID] = tileEntity1; TileEntity.ByPosition[tileEntity1.Position] = tileEntity1; return; } if (!TileEntity.ByID.TryGetValue(num206, out tileEntity) || !(tileEntity is TETrainingDummy) && !(tileEntity is TEItemFrame)) { return; } TileEntity.ByID.Remove(num206); TileEntity.ByPosition.Remove(tileEntity.Position); return; } case 87: { if (Main.netMode != 2) { return; } int num207 = this.reader.ReadInt16(); int num208 = this.reader.ReadInt16(); int num209 = this.reader.ReadByte(); if (num207 < 0 || num207 >= Main.maxTilesX) { return; } if (num208 < 0 || num208 >= Main.maxTilesY) { return; } if (TileEntity.ByPosition.ContainsKey(new Point16(num207, num208))) { return; } switch (num209) { case 0: { if (!TETrainingDummy.ValidTile(num207, num208)) { return; } TETrainingDummy.Place(num207, num208); return; } case 1: { if (!TEItemFrame.ValidTile(num207, num208)) { return; } int num210 = TEItemFrame.Place(num207, num208); NetMessage.SendData(86, -1, -1, "", num210, (float)num207, (float)num208, 0f, 0, 0, 0); return; } default: { return; } } } case 88: { if (Main.netMode != 1) { return; } int num211 = this.reader.ReadInt16(); if (num211 < 0 || num211 > 400) { return; } Item item8 = Main.item[num211]; if (this.reader.ReadByte() == 0) { return; } item8.color.PackedValue = this.reader.ReadUInt32(); return; } case 89: { if (Main.netMode != 2) { return; } int num212 = this.reader.ReadInt16(); int num213 = this.reader.ReadInt16(); int num214 = this.reader.ReadInt16(); int num215 = this.reader.ReadByte(); int num216 = this.reader.ReadInt16(); TEItemFrame.TryPlacing(num212, num213, num214, num215, num216); return; } case 91: { if (Main.netMode != 1) { return; } int emoteBubble = this.reader.ReadInt32(); int num217 = this.reader.ReadByte(); if (num217 != 255) { int num218 = this.reader.ReadUInt16(); int num219 = this.reader.ReadByte(); int num220 = this.reader.ReadByte(); int num221 = 0; if (num220 < 0) { num221 = this.reader.ReadInt16(); } /*WorldUIAnchor worldUIAnchor = EmoteBubble.DeserializeNetAnchor(num217, num218); lock (EmoteBubble.byID) { if (EmoteBubble.byID.ContainsKey(emoteBubble)) { EmoteBubble.byID[emoteBubble].lifeTime = num219; EmoteBubble.byID[emoteBubble].lifeTimeStart = num219; EmoteBubble.byID[emoteBubble].emote = num220; EmoteBubble.byID[emoteBubble].anchor = worldUIAnchor; } else { EmoteBubble.byID[emoteBubble] = new EmoteBubble(num220, worldUIAnchor, num219); } EmoteBubble.byID[emoteBubble].ID = emoteBubble; EmoteBubble.byID[emoteBubble].metadata = num221; return; }*/ } /*else { if (!EmoteBubble.byID.ContainsKey(emoteBubble)) { return; } EmoteBubble.byID.Remove(emoteBubble); return; }*/ return; } case 92: { int num222 = this.reader.ReadInt16(); float single10 = this.reader.ReadSingle(); float single11 = this.reader.ReadSingle(); float single12 = this.reader.ReadSingle(); if (Main.netMode == 1) { Main.npc[num222].extraValue = single10; return; } NPC nPC2 = Main.npc[num222]; nPC2.extraValue = nPC2.extraValue + single10; NetMessage.SendData(92, -1, -1, "", num222, Main.npc[num222].extraValue, single11, single12, 0, 0, 0); return; } case 95: { if (Main.netMode != 2) { return; } ushort num223 = this.reader.ReadUInt16(); if (num223 < 0 || num223 >= 1000) { return; } Projectile projectile1 = Main.projectile[num223]; if (projectile1.type != 602) { return; } projectile1.Kill(); if (Main.netMode == 0) { return; } NetMessage.SendData(29, -1, -1, "", projectile1.whoAmI, (float)projectile1.owner, 0f, 0f, 0, 0, 0); return; } case 96: { int num224 = this.reader.ReadByte(); Player player15 = Main.player[num224]; int num225 = this.reader.ReadInt16(); Vector2 vector28 = this.reader.ReadVector2(); Vector2 vector29 = this.reader.ReadVector2(); player15.lastPortalColorIndex = num225 + (num225 % 2 == 0 ? 1 : -1); player15.Teleport(vector28, 4, num225); player15.velocity = vector29; return; } case 97: { if (Main.netMode != 1) { return; } AchievementsHelper.NotifyNPCKilledDirect(Main.player[Main.myPlayer], this.reader.ReadInt16()); return; } case 99: { int num226 = this.reader.ReadByte(); if (Main.netMode == 2) { num226 = this.whoAmI; } Player player16 = Main.player[num226]; player16.MinionTargetPoint = this.reader.ReadVector2(); if (Main.netMode != 2) { return; } NetMessage.SendData(99, -1, this.whoAmI, "", num226, 0f, 0f, 0f, 0, 0, 0); return; } case 100: { int num227 = this.reader.ReadUInt16(); NPC nPC3 = Main.npc[num227]; int num228 = this.reader.ReadInt16(); Vector2 vector210 = this.reader.ReadVector2(); Vector2 vector211 = this.reader.ReadVector2(); nPC3.lastPortalColorIndex = num228 + (num228 % 2 == 0 ? 1 : -1); nPC3.Teleport(vector210, 4, num228); nPC3.velocity = vector211; return; } case 101: { if (Main.netMode == 2) { return; } NPC.ShieldStrengthTowerSolar = this.reader.ReadUInt16(); NPC.ShieldStrengthTowerVortex = this.reader.ReadUInt16(); NPC.ShieldStrengthTowerNebula = this.reader.ReadUInt16(); NPC.ShieldStrengthTowerStardust = this.reader.ReadUInt16(); return; } case 102: { int num229 = this.reader.ReadByte(); byte num230 = this.reader.ReadByte(); Vector2 vector212 = this.reader.ReadVector2(); if (Main.netMode == 2) { num229 = this.whoAmI; NetMessage.SendData(102, -1, -1, "", num229, (float)num230, vector212.X, vector212.Y, 0, 0, 0); return; } Player player17 = Main.player[num229]; for (int b1 = 0; b1 < 255; b1++) { Player player18 = Main.player[b1]; if (player18.active && !player18.dead && (player17.team == 0 || player17.team == player18.team) && player18.Distance(vector212) < 700f) { Vector2 center = player17.Center - player18.Center; Vector2 vector213 = Vector2.Normalize(center); if (!vector213.HasNaNs()) { int num231 = 90; float single13 = 0f; float single14 = 0.209439516f; Vector2 vector214 = new Vector2(0f, -8f); Vector2 vector215 = new Vector2(-3f); float single15 = 0f; float single16 = 0.005f; num5 = num230; if (num5 == 173) { num231 = 90; } else if (num5 == 176) { num231 = 88; } else if (num5 == 179) { num231 = 86; } } player18.NebulaLevelup((int)num230); } } return; } case 103: { if (Main.netMode != 1) { return; } NPC.MoonLordCountdown = this.reader.ReadInt32(); return; } case 104: { if (Main.netMode != 1 || Main.npcShop <= 0) { return; } Item[] itemArray = Main.instance.shop[Main.npcShop].item; int num234 = this.reader.ReadByte(); int num235 = this.reader.ReadInt16(); int num236 = this.reader.ReadInt16(); int num237 = this.reader.ReadByte(); int num238 = this.reader.ReadInt32(); BitsByte bitsByte15 = this.reader.ReadByte(); if (num234 >= (int)itemArray.Length) { return; } itemArray[num234] = new Item(); itemArray[num234].netDefaults(num235); itemArray[num234].stack = num236; itemArray[num234].Prefix(num237); itemArray[num234].value = num238; itemArray[num234].buyOnce = bitsByte15[0]; return; } default: { return; } } }
public override void SetupShop(Chest shop, ref int nextSlot) { shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleItem")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("EquipMaterial")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("BossItem")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleWorkbench")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleChair")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleDoor")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleBed")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleChest")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExamplePickaxe")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleHamaxe")); nextSlot++; if(Main.moonPhase < 2) { shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleSword")); nextSlot++; } else if(Main.moonPhase < 4) { shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleGun")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleBullet")); nextSlot++; } else if(Main.moonPhase < 6) { shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleStaff")); nextSlot++; } else { } }
private void DoChests(CommandArgs args) { if (args.Parameters.Count == 0 || args.Parameters.Count > 2) { args.Player.SendInfoMessage("Usage: /genchests <amount> [gen mode: default/easy/all]"); } int empty = 0; int tmpEmpty = 0; int chests = 0; int maxChests = 1000; string setting = "default"; if (args.Parameters.Count > 1) { setting = args.Parameters[1]; } const int maxtries = 100000; Int32.TryParse(args.Parameters[0], out chests); const int threshold = 100; if (!config.UseInfiniteChests) { for (int x = 0; x < maxChests; x++) { if (Main.chest[x] != null) { tmpEmpty++; bool found = false; foreach (Item itm in Main.chest[x].item) { if (itm.netID != 0) { found = true; } } if (found == false) { empty++; // TShock.Utils.Broadcast(string.Format("Found chest {0} empty at x {1} y {2}", x, Main.chest[x].x, // Main.chest[x].y)); // destroying WorldGen.KillTile(Main.chest[x].x, Main.chest[x].y, false, false, false); Main.chest[x] = null; } } } args.Player.SendSuccessMessage("Uprooted {0} empty out of {1} chests.", empty, tmpEmpty); } else { try { switch (TShock.Config.StorageType.ToLowerInvariant()) { case "mysql": string[] host = TShock.Config.MySqlHost.Split(':'); ChestDB = new MySqlConnection() { ConnectionString = string.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};", host[0], host.Length == 1 ? "3306" : host[1], TShock.Config.MySqlDbName, TShock.Config.MySqlUsername, TShock.Config.MySqlPassword) }; break; case "sqlite": string sql = Path.Combine(TShock.SavePath, "chests.sqlite"); ChestDB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql)); break; } } catch (Exception ex) { TShock.Log.ConsoleError(ex.ToString()); } } if (chests + tmpEmpty + threshold > maxChests) { chests = maxChests - tmpEmpty - threshold; } if (chests > 0) { int chestcount = 0; chestcount = tmpEmpty; int tries = 0; int newcount = 0; while (newcount < chests) { int contain; if (setting == "default") { // Moved item list into a separate .txt file int[] itemID = config.DefaultChestIDs; contain = itemID[WorldGen.genRand.Next(0, itemID.Length)]; } else if (setting == "all") { // Updated item list to 1.2.4.1 contain = WorldGen.genRand.Next(ItemList[0], ItemList.Last() + 1); } else if (setting == "easy") { contain = WorldGen.genRand.Next(-24, 364); } else { args.Player.SendWarningMessage("Warning! Typo in second argument: {0}", args.Parameters[1]); return; } int tryX = WorldGen.genRand.Next(20, Main.maxTilesX - 20); int tryY = WorldGen.genRand.Next((int)Main.worldSurface, Main.maxTilesY - 200); if (!config.GenInsideProtectedRegions && IsProtected(tryX, tryY)) { continue; } while (!Main.tile[tryX, tryY].active()) { tryY++; } tryY--; WorldGen.KillTile(tryX, tryY, false, false, false); WorldGen.KillTile(tryX + 1, tryY, false, false, false); WorldGen.KillTile(tryX, tryY + 1, false, false, false); WorldGen.KillTile(tryX + 1, tryY, false, false, false); if (WorldGen.AddBuriedChest(tryX, tryY, contain, true, 1)) { chestcount++; newcount++; if (config.UseInfiniteChests) { StringBuilder items = new StringBuilder(); Terraria.Chest c = Main.chest[0]; if (c != null) { for (int j = 0; j < 40; j++) { items.Append(c.item[j].netID + "," + c.item[j].stack + "," + c.item[j].prefix); if (j != 39) { items.Append(","); } } try { ChestDB.Query("INSERT INTO Chests (X, Y, Account, Items, WorldID) VALUES (@0, @1, '', @2, @3)", c.x, c.y, items.ToString(), Main.worldID); } catch (Exception ex) { TShock.Log.ConsoleError(ex.ToString()); } items.Clear(); Main.chest[0] = null; } } } if (tries + 1 >= maxtries) { break; } tries++; } if (config.UseInfiniteChests) { ChestDB.Dispose(); } args.Player.SendSuccessMessage("Generated {0} new chests - {1} total", newcount, chestcount); InformPlayers(); } }
public virtual void SetupShop(int type, Chest shop, ref int nextSlot) { }
private static Chest Adapt(TerrariaChest terrariaChest) => new Chest(new Vector(terrariaChest.x, terrariaChest.y), terrariaChest.name, terrariaChest.item.Select(Adapt));
public override void SetupShop(Chest shop, ref int nextSlot) { shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleItem")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("EquipMaterial")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("BossItem")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleWorkbench")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleChair")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleDoor")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleBed")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleChest")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExamplePickaxe")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleHamaxe")); nextSlot++; if (Main.LocalPlayer.GetModPlayer<ExamplePlayer>(mod).ZoneExample) { shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleWings")); nextSlot++; } if (Main.moonPhase < 2) { shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleSword")); nextSlot++; } else if (Main.moonPhase < 4) { shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleGun")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleBullet")); nextSlot++; } else if (Main.moonPhase < 6) { shop.item[nextSlot].SetDefaults(mod.ItemType("ExampleStaff")); nextSlot++; } else { } // Here is an example of how your npc can sell items from other mods. if (ModLoader.GetLoadedMods().Contains("SummonersAssociation")) { shop.item[nextSlot].SetDefaults(ModLoader.GetMod("SummonersAssociation").ItemType("BloodTalisman")); nextSlot++; } }
public override void SetupShop(Chest shop, ref int nextSlot) { { shop.item[nextSlot].SetDefaults(mod.ItemType("CopperShuriken")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("TinShuriken")); nextSlot++; } if (NPC.downedBoss1 == true) { shop.item[nextSlot].SetDefaults(mod.ItemType("IronShuriken")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("LeadShuriken")); nextSlot++; } if (NPC.downedBoss2 == true) { shop.item[nextSlot].SetDefaults(mod.ItemType("SilverShuriken")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("TungstenShuriken")); nextSlot++; } if (NPC.downedBoss3 == true) { shop.item[nextSlot].SetDefaults(mod.ItemType("GoldShuriken")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("PlatinumShuriken")); nextSlot++; } if (NPC.downedMechBossAny == true) { shop.item[nextSlot].SetDefaults(mod.ItemType("TwilightBlades")); } { nextSlot = 10; shop.item[nextSlot].SetDefaults(mod.ItemType("ShurikenLauncher")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("SwiftRune")); nextSlot++; } }
public static Chest ReadChest(this BinaryReader reader) { Chest chest = new Chest(false); chest.x = reader.ReadInt32(); chest.y = reader.ReadInt32(); chest.name = "World Chest"; for (int l = 0; l < 40; l++) { Item item = new Item(); int stack = reader.ReadInt16(); if (stack > 0) { int netID = reader.ReadInt32(); byte prefix = reader.ReadByte(); item.netDefaults(netID); item.stack = stack; item.Prefix(prefix); } chest.item[l] = item; } return chest; }
public static int AfterPlacement_Hook(int x, int y, int type = 21, int style = 0, int direction = 1) { Point16 baseCoords = new Point16(x, y); TileObjectData.OriginToTopLeft(type, style, ref baseCoords); int emptyChest = FindEmptyChest(baseCoords.X, baseCoords.Y, 21, 0, 1); if (emptyChest == -1) return -1; if (Main.netMode != 1) { Chest chest = new Chest(false); chest.x = baseCoords.X; chest.y = baseCoords.Y; for (int index = 0; index < 40; ++index) chest.item[index] = new Item(); Main.chest[emptyChest] = chest; } else if (type == 21) NetMessage.SendData(34, -1, -1, "", 0, (float)x, (float)y, (float)style, 0, 0, 0); else NetMessage.SendData(34, -1, -1, "", 2, (float)x, (float)y, (float)style, 0, 0, 0); return emptyChest; }
public void GetData(int start, int length) { if (this.whoAmI < 256) { Netplay.serverSock[this.whoAmI].timeOut = 0; } else { Netplay.clientSock.timeOut = 0; } int num = start + 1; byte b = this.readBuffer[start]; Main.rxMsg++; Main.rxData += length; Main.rxMsgType[(int)b]++; Main.rxDataType[(int)b] += length; if (Main.netMode == 1 && Netplay.clientSock.statusMax > 0) { Netplay.clientSock.statusCount++; } if (Main.verboseNetplay) { for (int i = start; i < start + length; i++) { } for (int j = start; j < start + length; j++) { byte arg_CD_0 = this.readBuffer[j]; } } if (Main.netMode == 2 && b != 38 && Netplay.serverSock[this.whoAmI].state == -1) { NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[1], 0, 0f, 0f, 0f, 0); return; } if (Main.netMode == 2 && Netplay.serverSock[this.whoAmI].state < 10 && b > 12 && b != 16 && b != 42 && b != 50 && b != 38 && b != 68) { NetMessage.BootPlayer(this.whoAmI, Lang.mp[2]); } if (this.reader == null) { this.ResetReader(); } this.reader.BaseStream.Position = (long)num; switch (b) { case 1: { if (Main.netMode != 2) { return; } if (Main.dedServ && Netplay.CheckBan(Netplay.serverSock[this.whoAmI].tcpClient.Client.RemoteEndPoint.ToString())) { NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[3], 0, 0f, 0f, 0f, 0); return; } if (Netplay.serverSock[this.whoAmI].state != 0) { return; } string a = this.reader.ReadString(); if (!(a == "Terraria" + Main.curRelease)) { NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[4], 0, 0f, 0f, 0f, 0); return; } if (string.IsNullOrEmpty(Netplay.password)) { Netplay.serverSock[this.whoAmI].state = 1; NetMessage.SendData(3, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0); return; } Netplay.serverSock[this.whoAmI].state = -1; NetMessage.SendData(37, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0); return; } case 2: if (Main.netMode != 1) { return; } Netplay.disconnect = true; Main.statusText = this.reader.ReadString(); return; case 3: { if (Main.netMode != 1) { return; } if (Netplay.clientSock.state == 1) { Netplay.clientSock.state = 2; } int num2 = (int)this.reader.ReadByte(); if (num2 != Main.myPlayer) { Main.player[num2] = (Player)Main.player[Main.myPlayer].Clone(); Main.player[Main.myPlayer] = new Player(); Main.player[num2].whoAmi = num2; Main.myPlayer = num2; } Player player = Main.player[num2]; NetMessage.SendData(4, -1, -1, player.name, num2, 0f, 0f, 0f, 0); NetMessage.SendData(68, -1, -1, "", num2, 0f, 0f, 0f, 0); NetMessage.SendData(16, -1, -1, "", num2, 0f, 0f, 0f, 0); NetMessage.SendData(42, -1, -1, "", num2, 0f, 0f, 0f, 0); NetMessage.SendData(50, -1, -1, "", num2, 0f, 0f, 0f, 0); for (int k = 0; k < 59; k++) { NetMessage.SendData(5, -1, -1, player.inventory[k].name, num2, (float)k, (float)player.inventory[k].prefix, 0f, 0); } for (int l = 0; l < 16; l++) { NetMessage.SendData(5, -1, -1, player.armor[l].name, num2, (float)(59 + l), (float)player.armor[l].prefix, 0f, 0); } for (int m = 0; m < 8; m++) { NetMessage.SendData(5, -1, -1, player.dye[m].name, num2, (float)(75 + m), (float)player.dye[m].prefix, 0f, 0); } NetMessage.SendData(6, -1, -1, "", 0, 0f, 0f, 0f, 0); if (Netplay.clientSock.state == 2) { Netplay.clientSock.state = 3; return; } return; } case 4: { int num3 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num3 = this.whoAmI; } if (num3 == Main.myPlayer && !Main.ServerSideCharacter) { return; } Player player2 = Main.player[num3]; player2.whoAmi = num3; if (this.reader.ReadByte() == 0) { player2.male = true; } else { player2.male = false; } player2.hair = (int)this.reader.ReadByte(); if (player2.hair >= 123) { player2.hair = 0; } player2.name = this.reader.ReadString().Trim().Trim(); player2.hairDye = this.reader.ReadByte(); player2.hideVisual = this.reader.ReadByte(); player2.hairColor = this.reader.ReadRGB(); player2.skinColor = this.reader.ReadRGB(); player2.eyeColor = this.reader.ReadRGB(); player2.shirtColor = this.reader.ReadRGB(); player2.underShirtColor = this.reader.ReadRGB(); player2.pantsColor = this.reader.ReadRGB(); player2.shoeColor = this.reader.ReadRGB(); player2.difficulty = this.reader.ReadByte(); if (Main.netMode != 2) { return; } bool flag = false; if (Netplay.serverSock[this.whoAmI].state < 10) { for (int n = 0; n < 255; n++) { if (n != num3 && player2.name == Main.player[n].name && Netplay.serverSock[n].active) { flag = true; } } } if (flag) { NetMessage.SendData(2, this.whoAmI, -1, player2.name + " " + Lang.mp[5], 0, 0f, 0f, 0f, 0); return; } if (player2.name.Length > Player.nameLen) { NetMessage.SendData(2, this.whoAmI, -1, "Name is too long.", 0, 0f, 0f, 0f, 0); return; } if (player2.name == "") { NetMessage.SendData(2, this.whoAmI, -1, "Empty name.", 0, 0f, 0f, 0f, 0); return; } Netplay.serverSock[this.whoAmI].oldName = player2.name; Netplay.serverSock[this.whoAmI].name = player2.name; NetMessage.SendData(4, -1, this.whoAmI, player2.name, num3, 0f, 0f, 0f, 0); return; } case 5: { int num4 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num4 = this.whoAmI; } if (num4 == Main.myPlayer && !Main.ServerSideCharacter) { return; } Player player3 = Main.player[num4]; lock (player3) { int num5 = (int)this.reader.ReadByte(); int stack = (int)this.reader.ReadInt16(); int num6 = (int)this.reader.ReadByte(); int type = (int)this.reader.ReadInt16(); if (num5 < 59) { player3.inventory[num5] = new Item(); player3.inventory[num5].netDefaults(type); player3.inventory[num5].stack = stack; player3.inventory[num5].Prefix(num6); if (num4 == Main.myPlayer && num5 == 58) { Main.mouseItem = player3.inventory[num5].Clone(); } } else { if (num5 >= 75 && num5 <= 82) { int num7 = num5 - 58 - 17; player3.dye[num7] = new Item(); player3.dye[num7].netDefaults(type); player3.dye[num7].stack = stack; player3.dye[num7].Prefix(num6); } else { int num8 = num5 - 58 - 1; player3.armor[num8] = new Item(); player3.armor[num8].netDefaults(type); player3.armor[num8].stack = stack; player3.armor[num8].Prefix(num6); } } if (Main.netMode == 2 && num4 == this.whoAmI) { NetMessage.SendData(5, -1, this.whoAmI, "", num4, (float)num5, (float)num6, 0f, 0); } return; } break; } case 6: break; case 7: { if (Main.netMode != 1) { return; } Main.time = (double)this.reader.ReadInt32(); BitsByte bitsByte = this.reader.ReadByte(); Main.dayTime = bitsByte[0]; Main.bloodMoon = bitsByte[1]; Main.eclipse = bitsByte[2]; Main.moonPhase = (int)this.reader.ReadByte(); Main.maxTilesX = (int)this.reader.ReadInt16(); Main.maxTilesY = (int)this.reader.ReadInt16(); Main.spawnTileX = (int)this.reader.ReadInt16(); Main.spawnTileY = (int)this.reader.ReadInt16(); Main.worldSurface = (double)this.reader.ReadInt16(); Main.rockLayer = (double)this.reader.ReadInt16(); Main.worldID = this.reader.ReadInt32(); Main.worldName = this.reader.ReadString(); Main.moonType = (int)this.reader.ReadByte(); WorldGen.setBG(0, (int)this.reader.ReadByte()); WorldGen.setBG(1, (int)this.reader.ReadByte()); WorldGen.setBG(2, (int)this.reader.ReadByte()); WorldGen.setBG(3, (int)this.reader.ReadByte()); WorldGen.setBG(4, (int)this.reader.ReadByte()); WorldGen.setBG(5, (int)this.reader.ReadByte()); WorldGen.setBG(6, (int)this.reader.ReadByte()); WorldGen.setBG(7, (int)this.reader.ReadByte()); Main.iceBackStyle = (int)this.reader.ReadByte(); Main.jungleBackStyle = (int)this.reader.ReadByte(); Main.hellBackStyle = (int)this.reader.ReadByte(); Main.windSpeedSet = this.reader.ReadSingle(); Main.numClouds = (int)this.reader.ReadByte(); for (int num9 = 0; num9 < 3; num9++) { Main.treeX[num9] = this.reader.ReadInt32(); } for (int num10 = 0; num10 < 4; num10++) { Main.treeStyle[num10] = (int)this.reader.ReadByte(); } for (int num11 = 0; num11 < 3; num11++) { Main.caveBackX[num11] = this.reader.ReadInt32(); } for (int num12 = 0; num12 < 4; num12++) { Main.caveBackStyle[num12] = (int)this.reader.ReadByte(); } Main.maxRaining = this.reader.ReadSingle(); Main.raining = (Main.maxRaining > 0f); BitsByte bitsByte2 = this.reader.ReadByte(); WorldGen.shadowOrbSmashed = bitsByte2[0]; NPC.downedBoss1 = bitsByte2[1]; NPC.downedBoss2 = bitsByte2[2]; NPC.downedBoss3 = bitsByte2[3]; Main.hardMode = bitsByte2[4]; NPC.downedClown = bitsByte2[5]; Main.ServerSideCharacter = bitsByte2[6]; NPC.downedPlantBoss = bitsByte2[7]; BitsByte bitsByte3 = this.reader.ReadByte(); NPC.downedMechBoss1 = bitsByte3[0]; NPC.downedMechBoss2 = bitsByte3[1]; NPC.downedMechBoss3 = bitsByte3[2]; NPC.downedMechBossAny = bitsByte3[3]; Main.cloudBGActive = (float)(bitsByte3[4] ? 1 : 0); WorldGen.crimson = bitsByte3[5]; Main.pumpkinMoon = bitsByte3[6]; Main.snowMoon = bitsByte3[7]; if (Netplay.clientSock.state == 3) { Netplay.clientSock.state = 4; return; } return; } case 8: { if (Main.netMode != 2) { return; } int num13 = this.reader.ReadInt32(); int num14 = this.reader.ReadInt32(); bool flag3 = true; if (num13 == -1 || num14 == -1) { flag3 = false; } else { if (num13 < 10 || num13 > Main.maxTilesX - 10) { flag3 = false; } else { if (num14 < 10 || num14 > Main.maxTilesY - 10) { flag3 = false; } } } int num15 = Netplay.GetSectionX(Main.spawnTileX) - 2; int num16 = Netplay.GetSectionY(Main.spawnTileY) - 1; int num17 = num15 + 5; int num18 = num16 + 3; if (num15 < 0) { num15 = 0; } if (num17 >= Main.maxSectionsX) { num17 = Main.maxSectionsX - 1; } if (num16 < 0) { num16 = 0; } if (num18 >= Main.maxSectionsY) { num18 = Main.maxSectionsY - 1; } int num19 = (num17 - num15) * (num18 - num16); int num20 = -1; int num21 = -1; if (flag3) { num13 = Netplay.GetSectionX(num13) - 2; num14 = Netplay.GetSectionY(num14) - 1; num20 = num13 + 5; num21 = num14 + 3; if (num13 < 0) { num13 = 0; } if (num20 >= Main.maxSectionsX) { num20 = Main.maxSectionsX - 1; } if (num14 < 0) { num14 = 0; } if (num21 >= Main.maxSectionsY) { num21 = Main.maxSectionsY - 1; } for (int num22 = num13; num22 < num20; num22++) { for (int num23 = num14; num23 < num21; num23++) { if (num22 < num15 || num22 >= num17 || num23 < num16 || num23 >= num18) { num19++; } } } } if (Netplay.serverSock[this.whoAmI].state == 2) { Netplay.serverSock[this.whoAmI].state = 3; } NetMessage.SendData(9, this.whoAmI, -1, Lang.inter[44], num19, 0f, 0f, 0f, 0); Netplay.serverSock[this.whoAmI].statusText2 = "is receiving tile data"; Netplay.serverSock[this.whoAmI].statusMax += num19; for (int num24 = num15; num24 < num17; num24++) { for (int num25 = num16; num25 < num18; num25++) { NetMessage.SendSection(this.whoAmI, num24, num25, false); } } if (flag3) { for (int num26 = num13; num26 < num20; num26++) { for (int num27 = num14; num27 < num21; num27++) { NetMessage.SendSection(this.whoAmI, num26, num27, true); } } NetMessage.SendData(11, this.whoAmI, -1, "", num13, (float)num14, (float)(num20 - 1), (float)(num21 - 1), 0); } NetMessage.SendData(11, this.whoAmI, -1, "", num15, (float)num16, (float)(num17 - 1), (float)(num18 - 1), 0); for (int num28 = 0; num28 < 400; num28++) { if (Main.item[num28].active) { NetMessage.SendData(21, this.whoAmI, -1, "", num28, 0f, 0f, 0f, 0); NetMessage.SendData(22, this.whoAmI, -1, "", num28, 0f, 0f, 0f, 0); } } for (int num29 = 0; num29 < 200; num29++) { if (Main.npc[num29].active) { NetMessage.SendData(23, this.whoAmI, -1, "", num29, 0f, 0f, 0f, 0); } } for (int num30 = 0; num30 < 1000; num30++) { if (Main.projectile[num30].active && (Main.projPet[Main.projectile[num30].type] || Main.projectile[num30].netImportant)) { NetMessage.SendData(27, this.whoAmI, -1, "", num30, 0f, 0f, 0f, 0); } } NetMessage.SendData(49, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0); NetMessage.SendData(57, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0); NetMessage.SendData(7, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0); return; } case 9: if (Main.netMode != 1) { return; } Netplay.clientSock.statusMax += this.reader.ReadInt32(); Netplay.clientSock.statusText = this.reader.ReadString(); return; case 10: if (Main.netMode != 1) { return; } NetMessage.DecompressTileBlock(this.readBuffer, num, length, true); return; case 11: if (Main.netMode != 1) { return; } WorldGen.SectionTileFrame((int)this.reader.ReadInt16(), (int)this.reader.ReadInt16(), (int)this.reader.ReadInt16(), (int)this.reader.ReadInt16()); return; case 12: { int num31 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num31 = this.whoAmI; } Player player4 = Main.player[num31]; player4.SpawnX = (int)this.reader.ReadInt16(); player4.SpawnY = (int)this.reader.ReadInt16(); player4.Spawn(); if (Main.netMode != 2 || Netplay.serverSock[this.whoAmI].state < 3) { return; } if (Netplay.serverSock[this.whoAmI].state == 3) { Netplay.serverSock[this.whoAmI].state = 10; NetMessage.greetPlayer(this.whoAmI); NetMessage.buffer[this.whoAmI].broadcast = true; NetMessage.syncPlayers(); NetMessage.SendData(12, -1, this.whoAmI, "", this.whoAmI, 0f, 0f, 0f, 0); NetMessage.SendData(74, this.whoAmI, -1, Main.player[this.whoAmI].name, Main.anglerQuest, 0f, 0f, 0f, 0); return; } NetMessage.SendData(12, -1, this.whoAmI, "", this.whoAmI, 0f, 0f, 0f, 0); return; } case 13: { int num32 = (int)this.reader.ReadByte(); if (num32 == Main.myPlayer && !Main.ServerSideCharacter) { return; } if (Main.netMode == 2) { num32 = this.whoAmI; } Player player5 = Main.player[num32]; BitsByte bitsByte4 = this.reader.ReadByte(); player5.controlUp = bitsByte4[0]; player5.controlDown = bitsByte4[1]; player5.controlLeft = bitsByte4[2]; player5.controlRight = bitsByte4[3]; player5.controlJump = bitsByte4[4]; player5.controlUseItem = bitsByte4[5]; player5.direction = (bitsByte4[6] ? 1 : -1); BitsByte bitsByte5 = this.reader.ReadByte(); if (bitsByte5[0]) { player5.pulley = true; player5.pulleyDir = (bitsByte5[1] ? 2 : 1); } else { player5.pulley = false; } player5.selectedItem = (int)this.reader.ReadByte(); player5.position = this.reader.ReadVector2(); if (bitsByte5[2]) { player5.velocity = this.reader.ReadVector2(); } if (Main.netMode == 2 && Netplay.serverSock[this.whoAmI].state == 10) { NetMessage.SendData(13, -1, this.whoAmI, "", num32, 0f, 0f, 0f, 0); return; } return; } case 14: { if (Main.netMode != 1) { return; } int num33 = (int)this.reader.ReadByte(); int num34 = (int)this.reader.ReadByte(); if (num34 == 1) { if (!Main.player[num33].active) { Main.player[num33] = new Player(); } Main.player[num33].active = true; return; } Main.player[num33].active = false; return; } case 15: case 67: return; case 16: { int num35 = (int)this.reader.ReadByte(); if (num35 == Main.myPlayer && !Main.ServerSideCharacter) { return; } if (Main.netMode == 2) { num35 = this.whoAmI; } Player player6 = Main.player[num35]; player6.statLife = (int)this.reader.ReadInt16(); player6.statLifeMax = (int)this.reader.ReadInt16(); if (player6.statLifeMax < 100) { player6.statLifeMax = 100; } player6.dead = (player6.statLife <= 0); if (Main.netMode == 2) { NetMessage.SendData(16, -1, this.whoAmI, "", num35, 0f, 0f, 0f, 0); return; } return; } case 17: { byte b2 = this.reader.ReadByte(); int num36 = (int)this.reader.ReadInt16(); int num37 = (int)this.reader.ReadInt16(); short num38 = this.reader.ReadInt16(); int num39 = (int)this.reader.ReadByte(); bool flag4 = num38 == 1; if (Main.tile[num36, num37] == null) { Main.tile[num36, num37] = new Tile(); } if (Main.netMode == 2) { if (!flag4) { if (b2 == 0 || b2 == 2 || b2 == 4) { Netplay.serverSock[this.whoAmI].spamDelBlock += 1f; } if (b2 == 1 || b2 == 3) { Netplay.serverSock[this.whoAmI].spamAddBlock += 1f; } } if (!Netplay.serverSock[this.whoAmI].tileSection[Netplay.GetSectionX(num36), Netplay.GetSectionY(num37)]) { flag4 = true; } } if (b2 == 0) { WorldGen.KillTile(num36, num37, flag4, false, false); } if (b2 == 1) { WorldGen.PlaceTile(num36, num37, (int)num38, false, true, -1, num39); } if (b2 == 2) { WorldGen.KillWall(num36, num37, flag4); } if (b2 == 3) { WorldGen.PlaceWall(num36, num37, (int)num38, false); } if (b2 == 4) { WorldGen.KillTile(num36, num37, flag4, false, true); } if (b2 == 5) { WorldGen.PlaceWire(num36, num37); } if (b2 == 6) { WorldGen.KillWire(num36, num37); } if (b2 == 7) { WorldGen.PoundTile(num36, num37); } if (b2 == 8) { WorldGen.PlaceActuator(num36, num37); } if (b2 == 9) { WorldGen.KillActuator(num36, num37); } if (b2 == 10) { WorldGen.PlaceWire2(num36, num37); } if (b2 == 11) { WorldGen.KillWire2(num36, num37); } if (b2 == 12) { WorldGen.PlaceWire3(num36, num37); } if (b2 == 13) { WorldGen.KillWire3(num36, num37); } if (b2 == 14) { WorldGen.SlopeTile(num36, num37, (int)num38); } if (b2 == 15) { Minecart.FrameTrack(num36, num37, true, false); } if (Main.netMode != 2) { return; } NetMessage.SendData(17, -1, this.whoAmI, "", (int)b2, (float)num36, (float)num37, (float)num38, num39); if (b2 == 1 && num38 == 53) { NetMessage.SendTileSquare(-1, num36, num37, 1); return; } return; } case 18: if (Main.netMode != 1) { return; } Main.dayTime = (this.reader.ReadByte() == 1); Main.time = (double)this.reader.ReadInt32(); Main.sunModY = this.reader.ReadInt16(); Main.moonModY = this.reader.ReadInt16(); return; case 19: { byte b3 = this.reader.ReadByte(); int num40 = (int)this.reader.ReadInt16(); int num41 = (int)this.reader.ReadInt16(); int num42 = (this.reader.ReadByte() == 0) ? -1 : 1; if (b3 == 0) { WorldGen.OpenDoor(num40, num41, num42); } else { if (b3 == 1) { WorldGen.CloseDoor(num40, num41, true); } } if (Main.netMode == 2) { NetMessage.SendData(19, -1, this.whoAmI, "", (int)b3, (float)num40, (float)num41, (float)((num42 == 1) ? 1 : 0), 0); return; } return; } case 20: { short num43 = this.reader.ReadInt16(); int num44 = (int)this.reader.ReadInt16(); int num45 = (int)this.reader.ReadInt16(); BitsByte bitsByte6 = 0; BitsByte bitsByte7 = 0; for (int num46 = num44; num46 < num44 + (int)num43; num46++) { for (int num47 = num45; num47 < num45 + (int)num43; num47++) { if (Main.tile[num46, num47] == null) { Main.tile[num46, num47] = new Tile(); } Tile tile = Main.tile[num46, num47]; bool flag5 = tile.active(); bitsByte6 = this.reader.ReadByte(); bitsByte7 = this.reader.ReadByte(); tile.active(bitsByte6[0]); tile.wall = (bitsByte6[2] ? 1 : 0); bool flag6 = bitsByte6[3]; if (Main.netMode != 2) { tile.liquid = (flag6 ? 1 : 0); } tile.wire(bitsByte6[4]); tile.halfBrick(bitsByte6[5]); tile.actuator(bitsByte6[6]); tile.inActive(bitsByte6[7]); tile.wire2(bitsByte7[0]); tile.wire3(bitsByte7[1]); if (bitsByte7[2]) { tile.color(this.reader.ReadByte()); } if (bitsByte7[3]) { tile.wallColor(this.reader.ReadByte()); } if (tile.active()) { int type2 = (int)tile.type; tile.type = this.reader.ReadUInt16(); if (Main.tileFrameImportant[(int)tile.type]) { tile.frameX = this.reader.ReadInt16(); tile.frameY = this.reader.ReadInt16(); } else { if (!flag5 || (int)tile.type != type2) { tile.frameX = -1; tile.frameY = -1; } } byte b4 = 0; if (bitsByte7[4]) { b4 += 1; } if (bitsByte7[5]) { b4 += 2; } if (bitsByte7[6]) { b4 += 4; } tile.slope(b4); } if (tile.wall > 0) { tile.wall = this.reader.ReadByte(); } if (flag6) { tile.liquid = this.reader.ReadByte(); tile.liquidType((int)this.reader.ReadByte()); } } } WorldGen.RangeFrame(num44, num45, num44 + (int)num43, num45 + (int)num43); if (Main.netMode == 2) { NetMessage.SendData((int)b, -1, this.whoAmI, "", (int)num43, (float)num44, (float)num45, 0f, 0); return; } return; } case 21: { int num48 = (int)this.reader.ReadInt16(); Vector2 position = this.reader.ReadVector2(); Vector2 velocity = this.reader.ReadVector2(); int stack2 = (int)this.reader.ReadInt16(); int pre = (int)this.reader.ReadByte(); int num49 = (int)this.reader.ReadByte(); int num50 = (int)this.reader.ReadInt16(); if (Main.netMode == 1) { if (num50 == 0) { Main.item[num48].active = false; return; } Item item = Main.item[num48]; item.netDefaults(num50); item.Prefix(pre); item.stack = stack2; item.position = position; item.velocity = velocity; item.active = true; item.wet = Collision.WetCollision(item.position, item.width, item.height); return; } else { if (num50 == 0) { if (num48 < 400) { Main.item[num48].active = false; NetMessage.SendData(21, -1, -1, "", num48, 0f, 0f, 0f, 0); return; } return; } else { bool flag7 = false; if (num48 == 400) { flag7 = true; } if (flag7) { Item item2 = new Item(); item2.netDefaults(num50); num48 = Item.NewItem((int)position.X, (int)position.Y, item2.width, item2.height, item2.type, stack2, true, 0, false); } Item item3 = Main.item[num48]; item3.netDefaults(num50); item3.Prefix(pre); item3.stack = stack2; item3.position = position; item3.velocity = velocity; item3.active = true; item3.owner = Main.myPlayer; if (flag7) { NetMessage.SendData(21, -1, -1, "", num48, 0f, 0f, 0f, 0); if (num49 == 0) { Main.item[num48].ownIgnore = this.whoAmI; Main.item[num48].ownTime = 100; } Main.item[num48].FindOwner(num48); return; } NetMessage.SendData(21, -1, this.whoAmI, "", num48, 0f, 0f, 0f, 0); return; } } break; } case 22: { int num51 = (int)this.reader.ReadInt16(); int num52 = (int)this.reader.ReadByte(); if (Main.netMode == 2 && Main.item[num51].owner != this.whoAmI) { return; } Main.item[num51].owner = num52; if (num52 == Main.myPlayer) { Main.item[num51].keepTime = 15; } else { Main.item[num51].keepTime = 0; } if (Main.netMode == 2) { Main.item[num51].owner = 255; Main.item[num51].keepTime = 15; NetMessage.SendData(22, -1, -1, "", num51, 0f, 0f, 0f, 0); return; } return; } case 23: { if (Main.netMode != 1) { return; } int num53 = (int)this.reader.ReadInt16(); Vector2 position2 = this.reader.ReadVector2(); Vector2 velocity2 = this.reader.ReadVector2(); int target = (int)this.reader.ReadByte(); BitsByte bitsByte8 = this.reader.ReadByte(); float[] array = new float[NPC.maxAI]; for (int num54 = 0; num54 < NPC.maxAI; num54++) { if (bitsByte8[num54 + 2]) { array[num54] = this.reader.ReadSingle(); } else { array[num54] = 0f; } } int num55 = (int)this.reader.ReadInt16(); int num56 = 0; if (!bitsByte8[7]) { if (Main.npcLifeBytes[num55] == 2) { num56 = (int)this.reader.ReadInt16(); } else { if (Main.npcLifeBytes[num55] == 4) { num56 = this.reader.ReadInt32(); } else { num56 = (int)this.reader.ReadSByte(); } } } int num57 = -1; NPC nPC = Main.npc[num53]; if (!nPC.active || nPC.netID != num55) { if (nPC.active) { num57 = nPC.type; } nPC.active = true; nPC.netDefaults(num55); } nPC.position = position2; nPC.velocity = velocity2; nPC.target = target; nPC.direction = (bitsByte8[0] ? 1 : -1); nPC.directionY = (bitsByte8[1] ? 1 : -1); nPC.spriteDirection = (bitsByte8[6] ? 1 : -1); if (bitsByte8[7]) { num56 = (nPC.life = nPC.lifeMax); } else { nPC.life = num56; } if (num56 <= 0) { nPC.active = false; } for (int num58 = 0; num58 < NPC.maxAI; num58++) { nPC.ai[num58] = array[num58]; } if (num57 > -1 && num57 != nPC.type) { nPC.xForm(num57, nPC.type); } if (num55 == 262) { NPC.plantBoss = num53; } if (num55 == 245) { NPC.golemBoss = num53; } if (Main.npcCatchable[nPC.type]) { nPC.releaseOwner = (short)this.reader.ReadByte(); return; } return; } case 24: { int num59 = (int)this.reader.ReadInt16(); int num60 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num60 = this.whoAmI; } Player player7 = Main.player[num60]; Main.npc[num59].StrikeNPC(player7.inventory[player7.selectedItem].damage, player7.inventory[player7.selectedItem].knockBack, player7.direction, false, false); if (Main.netMode == 2) { NetMessage.SendData(24, -1, this.whoAmI, "", num59, (float)num60, 0f, 0f, 0); NetMessage.SendData(23, -1, -1, "", num59, 0f, 0f, 0f, 0); return; } return; } case 25: { int num61 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num61 = this.whoAmI; } Color color = this.reader.ReadRGB(); if (Main.netMode == 2) { color = new Color(255, 255, 255); } string text = this.reader.ReadString(); if (Main.netMode == 1) { string newText = text; if (num61 < 255) { newText = "<" + Main.player[num61].name + "> " + text; Main.player[num61].chatText = text; Main.player[num61].chatShowTime = Main.chatLength / 2; } Main.NewText(newText, color.R, color.G, color.B, false); return; } if (Main.netMode != 2) { return; } string text2 = text.ToLower(); if (text2 == Lang.mp[6] || text2 == Lang.mp[21]) { string text3 = ""; for (int num62 = 0; num62 < 255; num62++) { if (Main.player[num62].active) { if (text3 == "") { text3 = Main.player[num62].name; } else { text3 = text3 + ", " + Main.player[num62].name; } } } NetMessage.SendData(25, this.whoAmI, -1, Lang.mp[7] + " " + text3 + ".", 255, 255f, 240f, 20f, 0); return; } if (text2.StartsWith("/me ")) { NetMessage.SendData(25, -1, -1, "*" + Main.player[this.whoAmI].name + " " + text.Substring(4), 255, 200f, 100f, 0f, 0); return; } if (text2 == Lang.mp[8]) { NetMessage.SendData(25, -1, -1, string.Concat(new object[] { "*", Main.player[this.whoAmI].name, " ", Lang.mp[9], " ", Main.rand.Next(1, 101) }), 255, 255f, 240f, 20f, 0); return; } if (text2.StartsWith("/p ")) { int team = Main.player[this.whoAmI].team; color = Main.teamColor[team]; if (team != 0) { for (int num63 = 0; num63 < 255; num63++) { if (Main.player[num63].team == team) { NetMessage.SendData(25, num63, -1, text.Substring(3), num61, (float)color.R, (float)color.G, (float)color.B, 0); } } return; } NetMessage.SendData(25, this.whoAmI, -1, Lang.mp[10], 255, 255f, 240f, 20f, 0); return; } else { if (Main.player[this.whoAmI].difficulty == 2) { color = Main.hcColor; } else { if (Main.player[this.whoAmI].difficulty == 1) { color = Main.mcColor; } } NetMessage.SendData(25, -1, -1, text, num61, (float)color.R, (float)color.G, (float)color.B, 0); if (Main.dedServ) { Console.WriteLine("<" + Main.player[this.whoAmI].name + "> " + text); return; } return; } break; } case 26: { int num64 = (int)this.reader.ReadByte(); if (Main.netMode == 2 && this.whoAmI != num64 && (!Main.player[num64].hostile || !Main.player[this.whoAmI].hostile)) { return; } int num65 = (int)(this.reader.ReadByte() - 1); int num66 = (int)this.reader.ReadInt16(); string text4 = this.reader.ReadString(); BitsByte bitsByte9 = this.reader.ReadByte(); bool flag8 = bitsByte9[0]; bool flag9 = bitsByte9[1]; Main.player[num64].Hurt(num66, num65, flag8, true, text4, flag9); if (Main.netMode == 2) { NetMessage.SendData(26, -1, this.whoAmI, text4, num64, (float)num65, (float)num66, (float)(flag8 ? 1 : 0), flag9 ? 1 : 0); return; } return; } case 27: { int num67 = (int)this.reader.ReadInt16(); Vector2 position3 = this.reader.ReadVector2(); Vector2 velocity3 = this.reader.ReadVector2(); float knockBack = this.reader.ReadSingle(); int damage = (int)this.reader.ReadInt16(); int num68 = (int)this.reader.ReadByte(); int num69 = (int)this.reader.ReadInt16(); BitsByte bitsByte10 = this.reader.ReadByte(); float[] array2 = new float[Projectile.maxAI]; for (int num70 = 0; num70 < Projectile.maxAI; num70++) { if (bitsByte10[num70]) { array2[num70] = this.reader.ReadSingle(); } else { array2[num70] = 0f; } } if (Main.netMode == 2) { num68 = this.whoAmI; if (Main.projHostile[num69]) { return; } } int num71 = 1000; for (int num72 = 0; num72 < 1000; num72++) { if (Main.projectile[num72].owner == num68 && Main.projectile[num72].identity == num67 && Main.projectile[num72].active) { num71 = num72; break; } } if (num71 == 1000) { for (int num73 = 0; num73 < 1000; num73++) { if (!Main.projectile[num73].active) { num71 = num73; break; } } } Projectile projectile = Main.projectile[num71]; if (!projectile.active || projectile.type != num69) { projectile.SetDefaults(num69); if (Main.netMode == 2) { Netplay.serverSock[this.whoAmI].spamProjectile += 1f; } } projectile.identity = num67; projectile.position = position3; projectile.velocity = velocity3; projectile.type = num69; projectile.damage = damage; projectile.knockBack = knockBack; projectile.owner = num68; for (int num74 = 0; num74 < Projectile.maxAI; num74++) { projectile.ai[num74] = array2[num74]; } if (Main.netMode == 2) { NetMessage.SendData(27, -1, this.whoAmI, "", num71, 0f, 0f, 0f, 0); return; } return; } case 28: { int num75 = (int)this.reader.ReadInt16(); int num76 = (int)this.reader.ReadInt16(); float num77 = this.reader.ReadSingle(); int num78 = (int)(this.reader.ReadByte() - 1); byte b5 = this.reader.ReadByte(); if (num76 >= 0) { Main.npc[num75].StrikeNPC(num76, num77, num78, b5 == 1, false); } else { Main.npc[num75].life = 0; Main.npc[num75].HitEffect(0, 10.0); Main.npc[num75].active = false; } if (Main.netMode != 2) { return; } NetMessage.SendData(28, -1, this.whoAmI, "", num75, (float)num76, num77, (float)num78, (int)b5); if (Main.npc[num75].life <= 0) { NetMessage.SendData(23, -1, -1, "", num75, 0f, 0f, 0f, 0); return; } Main.npc[num75].netUpdate = true; return; } case 29: { int num79 = (int)this.reader.ReadInt16(); int num80 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num80 = this.whoAmI; } for (int num81 = 0; num81 < 1000; num81++) { if (Main.projectile[num81].owner == num80 && Main.projectile[num81].identity == num79 && Main.projectile[num81].active) { Main.projectile[num81].Kill(); break; } } if (Main.netMode == 2) { NetMessage.SendData(29, -1, this.whoAmI, "", num79, (float)num80, 0f, 0f, 0); return; } return; } case 30: { int num82 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num82 = this.whoAmI; } bool flag10 = this.reader.ReadBoolean(); Main.player[num82].hostile = flag10; if (Main.netMode == 2) { NetMessage.SendData(30, -1, this.whoAmI, "", num82, 0f, 0f, 0f, 0); string str = " " + Lang.mp[flag10 ? 11 : 12]; Color color2 = Main.teamColor[Main.player[num82].team]; NetMessage.SendData(25, -1, -1, Main.player[num82].name + str, 255, (float)color2.R, (float)color2.G, (float)color2.B, 0); return; } return; } case 31: { if (Main.netMode != 2) { return; } int x = (int)this.reader.ReadInt16(); int y = (int)this.reader.ReadInt16(); int num83 = Chest.FindChest(x, y); if (num83 > -1 && Chest.UsingChest(num83) == -1) { for (int num84 = 0; num84 < Chest.maxItems; num84++) { NetMessage.SendData(32, this.whoAmI, -1, "", num83, (float)num84, 0f, 0f, 0); } NetMessage.SendData(33, this.whoAmI, -1, "", num83, 0f, 0f, 0f, 0); Main.player[this.whoAmI].chest = num83; return; } return; } case 32: { int num85 = (int)this.reader.ReadInt16(); int num86 = (int)this.reader.ReadByte(); int stack3 = (int)this.reader.ReadInt16(); int pre2 = (int)this.reader.ReadByte(); int type3 = (int)this.reader.ReadInt16(); if (Main.chest[num85] == null) { Main.chest[num85] = new Chest(false); } if (Main.chest[num85].item[num86] == null) { Main.chest[num85].item[num86] = new Item(); } Main.chest[num85].item[num86].netDefaults(type3); Main.chest[num85].item[num86].Prefix(pre2); Main.chest[num85].item[num86].stack = stack3; return; } case 33: { int num87 = (int)this.reader.ReadInt16(); int chestX = (int)this.reader.ReadInt16(); int chestY = (int)this.reader.ReadInt16(); int num88 = (int)this.reader.ReadByte(); string text5 = string.Empty; if (num88 != 0) { if (num88 <= 20) { text5 = this.reader.ReadString(); } else { if (num88 != 255) { num88 = 0; } } } if (Main.netMode == 1) { Player player8 = Main.player[Main.myPlayer]; if (player8.chest == -1) { Main.playerInventory = true; Main.PlaySound(10, -1, -1, 1); } else { if (player8.chest != num87 && num87 != -1) { Main.playerInventory = true; Main.PlaySound(12, -1, -1, 1); } else { if (player8.chest != -1 && num87 == -1) { Main.PlaySound(11, -1, -1, 1); } } } player8.chest = num87; player8.chestX = chestX; player8.chestY = chestY; return; } if (num88 != 0) { int chest = Main.player[this.whoAmI].chest; Chest chest2 = Main.chest[chest]; chest2.name = text5; NetMessage.SendData(69, -1, this.whoAmI, text5, chest, (float)chest2.x, (float)chest2.y, 0f, 0); } Main.player[this.whoAmI].chest = num87; return; } case 34: { byte b6 = this.reader.ReadByte(); int num89 = (int)this.reader.ReadInt16(); int num90 = (int)this.reader.ReadInt16(); int num91 = (int)this.reader.ReadInt16(); if (Main.netMode == 2) { if (b6 == 0) { int num92 = WorldGen.PlaceChest(num89, num90, 21, false, num91); if (num92 == -1) { NetMessage.SendData(34, this.whoAmI, -1, "", (int)b6, (float)num89, (float)num90, (float)num91, num92); Item.NewItem(num89 * 16, num90 * 16, 32, 32, Chest.itemSpawn[num91], 1, true, 0, false); return; } NetMessage.SendData(34, -1, -1, "", (int)b6, (float)num89, (float)num90, (float)num91, num92); return; } else { Tile tile2 = Main.tile[num89, num90]; if (tile2.type != 21) { return; } if (tile2.frameX % 36 != 0) { num89--; } if (tile2.frameY % 36 != 0) { num90--; } int number = Chest.FindChest(num89, num90); WorldGen.KillTile(num89, num90, false, false, false); if (!tile2.active()) { NetMessage.SendData(34, -1, -1, "", (int)b6, (float)num89, (float)num90, 0f, number); return; } return; } } else { int num93 = (int)this.reader.ReadInt16(); if (b6 != 0) { Chest.DestroyChestDirect(num89, num90, num93); WorldGen.KillTile(num89, num90, false, false, false); return; } if (num93 == -1) { WorldGen.KillTile(num89, num90, false, false, false); return; } WorldGen.PlaceChestDirect(num89, num90, 21, num91, num93); return; } break; } case 35: { int num94 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num94 = this.whoAmI; } int num95 = (int)this.reader.ReadInt16(); if (num94 != Main.myPlayer || Main.ServerSideCharacter) { Main.player[num94].HealEffect(num95, true); } if (Main.netMode == 2) { NetMessage.SendData(35, -1, this.whoAmI, "", num94, (float)num95, 0f, 0f, 0); return; } return; } case 36: { int num96 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num96 = this.whoAmI; } Player player9 = Main.player[num96]; BitsByte bitsByte11 = this.reader.ReadByte(); player9.zoneEvil = bitsByte11[0]; player9.zoneMeteor = bitsByte11[1]; player9.zoneDungeon = bitsByte11[2]; player9.zoneJungle = bitsByte11[3]; player9.zoneHoly = bitsByte11[4]; player9.zoneSnow = bitsByte11[5]; player9.zoneBlood = bitsByte11[6]; player9.zoneCandle = bitsByte11[7]; if (Main.netMode == 2) { NetMessage.SendData(36, -1, this.whoAmI, "", num96, 0f, 0f, 0f, 0); return; } return; } case 37: if (Main.netMode != 1) { return; } if (Main.autoPass) { NetMessage.SendData(38, -1, -1, Netplay.password, 0, 0f, 0f, 0f, 0); Main.autoPass = false; return; } Netplay.password = ""; Main.menuMode = 31; return; case 38: { if (Main.netMode != 2) { return; } string a2 = this.reader.ReadString(); if (a2 == Netplay.password) { Netplay.serverSock[this.whoAmI].state = 1; NetMessage.SendData(3, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0); return; } NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[1], 0, 0f, 0f, 0f, 0); return; } case 39: { if (Main.netMode != 1) { return; } int num97 = (int)this.reader.ReadInt16(); Main.item[num97].owner = 255; NetMessage.SendData(22, -1, -1, "", num97, 0f, 0f, 0f, 0); return; } case 40: { int num98 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num98 = this.whoAmI; } int talkNPC = (int)this.reader.ReadInt16(); Main.player[num98].talkNPC = talkNPC; if (Main.netMode == 2) { NetMessage.SendData(40, -1, this.whoAmI, "", num98, 0f, 0f, 0f, 0); return; } return; } case 41: { int num99 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num99 = this.whoAmI; } Player player10 = Main.player[num99]; float itemRotation = this.reader.ReadSingle(); int itemAnimation = (int)this.reader.ReadInt16(); player10.itemRotation = itemRotation; player10.itemAnimation = itemAnimation; player10.channel = player10.inventory[player10.selectedItem].channel; if (Main.netMode == 2) { NetMessage.SendData(41, -1, this.whoAmI, "", num99, 0f, 0f, 0f, 0); return; } return; } case 42: { int num100 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num100 = this.whoAmI; } else { if (Main.myPlayer == num100 && !Main.ServerSideCharacter) { return; } } int statMana = (int)this.reader.ReadInt16(); int statManaMax = (int)this.reader.ReadInt16(); Main.player[num100].statMana = statMana; Main.player[num100].statManaMax = statManaMax; return; } case 43: { int num101 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num101 = this.whoAmI; } int num102 = (int)this.reader.ReadInt16(); if (num101 != Main.myPlayer) { Main.player[num101].ManaEffect(num102); } if (Main.netMode == 2) { NetMessage.SendData(43, -1, this.whoAmI, "", num101, (float)num102, 0f, 0f, 0); return; } return; } case 44: { int num103 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num103 = this.whoAmI; } int num104 = (int)(this.reader.ReadByte() - 1); int num105 = (int)this.reader.ReadInt16(); byte b7 = this.reader.ReadByte(); string text6 = this.reader.ReadString(); Main.player[num103].KillMe((double)num105, num104, b7 == 1, text6); if (Main.netMode == 2) { NetMessage.SendData(44, -1, this.whoAmI, text6, num103, (float)num104, (float)num105, (float)b7, 0); return; } return; } case 45: { int num106 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num106 = this.whoAmI; } int num107 = (int)this.reader.ReadByte(); Player player11 = Main.player[num106]; int team2 = player11.team; player11.team = num107; Color color3 = Main.teamColor[num107]; if (Main.netMode == 2) { NetMessage.SendData(45, -1, this.whoAmI, "", num106, 0f, 0f, 0f, 0); string str2 = " " + Lang.mp[13 + num107]; for (int num108 = 0; num108 < 255; num108++) { if (num108 == this.whoAmI || (team2 > 0 && Main.player[num108].team == team2) || (num107 > 0 && Main.player[num108].team == num107)) { NetMessage.SendData(25, num108, -1, player11.name + str2, 255, (float)color3.R, (float)color3.G, (float)color3.B, 0); } } return; } return; } case 46: { if (Main.netMode != 2) { return; } int i2 = (int)this.reader.ReadInt16(); int j2 = (int)this.reader.ReadInt16(); int num109 = Sign.ReadSign(i2, j2); if (num109 >= 0) { NetMessage.SendData(47, this.whoAmI, -1, "", num109, 0f, 0f, 0f, 0); return; } return; } case 47: { int num110 = (int)this.reader.ReadInt16(); int x2 = (int)this.reader.ReadInt16(); int y2 = (int)this.reader.ReadInt16(); string text7 = this.reader.ReadString(); Main.sign[num110] = new Sign(); Main.sign[num110].x = x2; Main.sign[num110].y = y2; Sign.TextSign(num110, text7); if (Main.netMode == 1 && Main.sign[num110] != null) { Main.playerInventory = false; Main.player[Main.myPlayer].talkNPC = -1; Main.npcChatCornerItem = 0; Main.editSign = false; Main.PlaySound(10, -1, -1, 1); Main.player[Main.myPlayer].sign = num110; Main.npcChatText = Main.sign[num110].text; return; } return; } case 48: { int num111 = (int)this.reader.ReadInt16(); int num112 = (int)this.reader.ReadInt16(); byte liquid = this.reader.ReadByte(); byte liquidType = this.reader.ReadByte(); if (Main.netMode == 2 && Netplay.spamCheck) { int num113 = this.whoAmI; int num114 = (int)(Main.player[num113].position.X + (float)(Main.player[num113].width / 2)); int num115 = (int)(Main.player[num113].position.Y + (float)(Main.player[num113].height / 2)); int num116 = 10; int num117 = num114 - num116; int num118 = num114 + num116; int num119 = num115 - num116; int num120 = num115 + num116; if (num111 < num117 || num111 > num118 || num112 < num119 || num112 > num120) { NetMessage.BootPlayer(this.whoAmI, "Cheating attempt detected: Liquid spam"); return; } } if (Main.tile[num111, num112] == null) { Main.tile[num111, num112] = new Tile(); } lock (Main.tile[num111, num112]) { Main.tile[num111, num112].liquid = liquid; Main.tile[num111, num112].liquidType((int)liquidType); if (Main.netMode == 2) { WorldGen.SquareTileFrame(num111, num112, true); } return; } goto IL_3A0C; } case 49: goto IL_3A0C; case 50: { int num121 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num121 = this.whoAmI; } else { if (num121 == Main.myPlayer && !Main.ServerSideCharacter) { return; } } Player player12 = Main.player[num121]; for (int num122 = 0; num122 < 22; num122++) { player12.buffType[num122] = (int)this.reader.ReadByte(); if (player12.buffType[num122] > 0) { player12.buffTime[num122] = 60; } else { player12.buffTime[num122] = 0; } } if (Main.netMode == 2) { NetMessage.SendData(50, -1, this.whoAmI, "", num121, 0f, 0f, 0f, 0); return; } return; } case 51: { byte b8 = this.reader.ReadByte(); byte b9 = this.reader.ReadByte(); if (b9 == 1) { NPC.SpawnSkeletron(); return; } if (b9 != 2) { return; } if (Main.netMode == 2) { NetMessage.SendData(51, -1, this.whoAmI, "", (int)b8, (float)b9, 0f, 0f, 0); return; } Main.PlaySound(2, (int)Main.player[(int)b8].position.X, (int)Main.player[(int)b8].position.Y, 1); return; } case 52: { int number2 = (int)this.reader.ReadByte(); int num123 = (int)this.reader.ReadByte(); int num124 = (int)this.reader.ReadInt16(); int num125 = (int)this.reader.ReadInt16(); if (num123 == 1) { Chest.Unlock(num124, num125); if (Main.netMode == 2) { NetMessage.SendData(52, -1, this.whoAmI, "", number2, (float)num123, (float)num124, (float)num125, 0); NetMessage.SendTileSquare(-1, num124, num125, 2); } } if (num123 != 2) { return; } WorldGen.UnlockDoor(num124, num125); if (Main.netMode == 2) { NetMessage.SendData(52, -1, this.whoAmI, "", number2, (float)num123, (float)num124, (float)num125, 0); NetMessage.SendTileSquare(-1, num124, num125, 2); return; } return; } case 53: { int num126 = (int)this.reader.ReadInt16(); int type4 = (int)this.reader.ReadByte(); int time = (int)this.reader.ReadInt16(); Main.npc[num126].AddBuff(type4, time, true); if (Main.netMode == 2) { NetMessage.SendData(54, -1, -1, "", num126, 0f, 0f, 0f, 0); return; } return; } case 54: { if (Main.netMode != 1) { return; } int num127 = (int)this.reader.ReadInt16(); NPC nPC2 = Main.npc[num127]; for (int num128 = 0; num128 < 5; num128++) { nPC2.buffType[num128] = (int)this.reader.ReadByte(); nPC2.buffTime[num128] = (int)this.reader.ReadInt16(); } return; } case 55: { int num129 = (int)this.reader.ReadByte(); int num130 = (int)this.reader.ReadByte(); int num131 = (int)this.reader.ReadInt16(); if (Main.netMode == 2 && num129 != this.whoAmI && !Main.pvpBuff[num130]) { return; } if (Main.netMode == 1 && num129 == Main.myPlayer) { Main.player[num129].AddBuff(num130, num131, true); return; } if (Main.netMode == 2) { NetMessage.SendData(55, num129, -1, "", num129, (float)num130, (float)num131, 0f, 0); return; } return; } case 56: { int num132 = (int)this.reader.ReadInt16(); if (num132 < 0 || num132 >= 200) { return; } if (Main.netMode == 1) { Main.npc[num132].displayName = this.reader.ReadString(); return; } if (Main.netMode == 2) { NetMessage.SendData(56, this.whoAmI, -1, Main.npc[num132].displayName, num132, 0f, 0f, 0f, 0); return; } return; } case 57: if (Main.netMode != 1) { return; } WorldGen.tGood = this.reader.ReadByte(); WorldGen.tEvil = this.reader.ReadByte(); WorldGen.tBlood = this.reader.ReadByte(); return; case 58: { int num133 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num133 = this.whoAmI; } float num134 = this.reader.ReadSingle(); if (Main.netMode == 2) { NetMessage.SendData(58, -1, this.whoAmI, "", this.whoAmI, num134, 0f, 0f, 0); return; } Player player13 = Main.player[num133]; Main.harpNote = num134; int style = 26; if (player13.inventory[player13.selectedItem].type == 507) { style = 35; } Main.PlaySound(2, (int)player13.position.X, (int)player13.position.Y, style); return; } case 59: { int num135 = (int)this.reader.ReadInt16(); int num136 = (int)this.reader.ReadInt16(); Wiring.hitSwitch(num135, num136); if (Main.netMode == 2) { NetMessage.SendData(59, -1, this.whoAmI, "", num135, (float)num136, 0f, 0f, 0); return; } return; } case 60: { int num137 = (int)this.reader.ReadInt16(); int num138 = (int)this.reader.ReadInt16(); int num139 = (int)this.reader.ReadInt16(); byte b10 = this.reader.ReadByte(); if (num137 >= 200) { NetMessage.BootPlayer(this.whoAmI, "cheating attempt detected: Invalid kick-out"); return; } if (Main.netMode == 1) { Main.npc[num137].homeless = (b10 == 1); Main.npc[num137].homeTileX = num138; Main.npc[num137].homeTileY = num139; return; } if (b10 == 0) { WorldGen.kickOut(num137); return; } WorldGen.moveRoom(num138, num139, num137); return; } case 61: { int plr = this.reader.ReadInt32(); int num140 = this.reader.ReadInt32(); if (Main.netMode != 2) { return; } if (num140 == 4 || num140 == 13 || num140 == 50 || num140 == 125 || num140 == 126 || num140 == 134 || num140 == 127 || num140 == 128 || num140 == 222 || num140 == 245 || num140 == 266 || num140 == 370) { bool flag12 = !NPC.AnyNPCs(num140); if (flag12) { NPC.SpawnOnPlayer(plr, num140); return; } return; } else { if (num140 == -4) { if (!Main.dayTime) { NetMessage.SendData(25, -1, -1, Lang.misc[31], 255, 50f, 255f, 130f, 0); Main.startPumpkinMoon(); NetMessage.SendData(7, -1, -1, "", 0, 0f, 0f, 0f, 0); return; } return; } else { if (num140 == -5) { if (!Main.dayTime) { NetMessage.SendData(25, -1, -1, Lang.misc[34], 255, 50f, 255f, 130f, 0); Main.startSnowMoon(); NetMessage.SendData(7, -1, -1, "", 0, 0f, 0f, 0f, 0); return; } return; } else { if (num140 >= 0) { return; } int num141 = 1; if (num140 > -4) { num141 = -num140; } if (num141 > 0 && Main.invasionType == 0) { Main.invasionDelay = 0; Main.StartInvasion(num141); return; } return; } } } break; } case 62: { int num142 = (int)this.reader.ReadByte(); int num143 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num142 = this.whoAmI; } if (num143 == 1) { Main.player[num142].NinjaDodge(); } if (num143 == 2) { Main.player[num142].ShadowDodge(); } if (Main.netMode == 2) { NetMessage.SendData(62, -1, this.whoAmI, "", num142, (float)num143, 0f, 0f, 0); return; } return; } case 63: { int num144 = (int)this.reader.ReadInt16(); int num145 = (int)this.reader.ReadInt16(); byte b11 = this.reader.ReadByte(); WorldGen.paintTile(num144, num145, b11, false); if (Main.netMode == 2) { NetMessage.SendData(63, -1, this.whoAmI, "", num144, (float)num145, (float)b11, 0f, 0); return; } return; } case 64: { int num146 = (int)this.reader.ReadInt16(); int num147 = (int)this.reader.ReadInt16(); byte b12 = this.reader.ReadByte(); WorldGen.paintWall(num146, num147, b12, false); if (Main.netMode == 2) { NetMessage.SendData(64, -1, this.whoAmI, "", num146, (float)num147, (float)b12, 0f, 0); return; } return; } case 65: { BitsByte bitsByte12 = this.reader.ReadByte(); int num148 = (int)this.reader.ReadInt16(); if (Main.netMode == 2) { num148 = this.whoAmI; } Vector2 newPos = this.reader.ReadVector2(); int num149 = 0; int num150 = 0; if (bitsByte12[0]) { num149++; } if (bitsByte12[1]) { num149 += 2; } if (bitsByte12[2]) { num150++; } if (bitsByte12[3]) { num150++; } if (num149 == 0) { Main.player[num148].Teleport(newPos, num150); } else { if (num149 == 1) { Main.npc[num148].Teleport(newPos, num150); } } if (Main.netMode == 2 && num149 == 0) { NetMessage.SendData(65, -1, this.whoAmI, "", 0, (float)num148, newPos.X, newPos.Y, num150); return; } return; } case 66: { int num151 = (int)this.reader.ReadByte(); int num152 = (int)this.reader.ReadInt16(); if (num152 <= 0) { return; } Player player14 = Main.player[num151]; player14.statLife += num152; if (player14.statLife > player14.statLifeMax2) { player14.statLife = player14.statLifeMax2; } player14.HealEffect(num152, false); if (Main.netMode == 2) { NetMessage.SendData(66, -1, this.whoAmI, "", num151, (float)num152, 0f, 0f, 0); return; } return; } case 68: this.reader.ReadString(); return; case 69: { int num153 = (int)this.reader.ReadInt16(); int num154 = (int)this.reader.ReadInt16(); int num155 = (int)this.reader.ReadInt16(); if (Main.netMode == 1) { if (num153 < 0 || num153 >= 1000) { return; } Chest chest3 = Main.chest[num153]; if (chest3 == null) { chest3 = new Chest(false); chest3.x = num154; chest3.y = num155; Main.chest[num153] = chest3; } else { if (chest3.x != num154 || chest3.y != num155) { return; } } chest3.name = this.reader.ReadString(); return; } else { if (num153 < -1 || num153 >= 1000) { return; } if (num153 == -1) { num153 = Chest.FindChest(num154, num155); if (num153 == -1) { return; } } Chest chest4 = Main.chest[num153]; if (chest4.x != num154 || chest4.y != num155) { return; } NetMessage.SendData(69, this.whoAmI, -1, chest4.name, num153, (float)num154, (float)num155, 0f, 0); return; } break; } case 70: { if (Main.netMode != 2) { return; } int i3 = (int)this.reader.ReadInt16(); int who = (int)this.reader.ReadByte(); if (Main.netMode == 2) { who = this.whoAmI; } NPC.CatchNPC(i3, who); return; } case 71: { if (Main.netMode != 2) { return; } int x3 = this.reader.ReadInt32(); int y3 = this.reader.ReadInt32(); int type5 = (int)this.reader.ReadInt16(); byte style2 = this.reader.ReadByte(); NPC.ReleaseNPC(x3, y3, type5, (int)style2, this.whoAmI); return; } case 72: if (Main.netMode != 1) { return; } for (int num156 = 0; num156 < Chest.maxItems; num156++) { Main.travelShop[num156] = (int)this.reader.ReadInt16(); } return; case 73: Main.player[this.whoAmI].TeleportationPotion(); return; case 74: if (Main.netMode != 1) { return; } Main.anglerQuest = (int)this.reader.ReadByte(); Main.anglerQuestFinished = this.reader.ReadBoolean(); return; case 75: { if (Main.netMode != 2) { return; } string name = Main.player[this.whoAmI].name; if (!Main.anglerWhoFinishedToday.Contains(name)) { Main.anglerWhoFinishedToday.Add(name); return; } return; } case 76: { int num157 = (int)this.reader.ReadByte(); if (num157 == Main.myPlayer && !Main.ServerSideCharacter) { return; } if (Main.netMode == 2) { num157 = this.whoAmI; } Player player15 = Main.player[num157]; player15.anglerQuestsFinished = this.reader.ReadInt32(); if (Main.netMode == 2) { NetMessage.SendData(76, -1, this.whoAmI, "", num157, 0f, 0f, 0f, 0); return; } return; } default: return; } if (Main.netMode != 2) { return; } if (Netplay.serverSock[this.whoAmI].state == 1) { Netplay.serverSock[this.whoAmI].state = 2; } NetMessage.SendData(7, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0); return; IL_3A0C: if (Netplay.clientSock.state == 6) { Netplay.clientSock.state = 10; Main.player[Main.myPlayer].Spawn(); return; } }
private static void LoadChests(BinaryReader reader) { Chest chest = null; int num6; int num7; int num4 = reader.ReadInt16(); int num5 = reader.ReadInt16(); if (num5 < 40) { num6 = num5; num7 = 0; } else { num6 = 40; num7 = num5 - 40; } int index = 0; while (index < num4) { chest = new Chest(false) { x = reader.ReadInt32(), y = reader.ReadInt32(), name = reader.ReadString() }; int num3 = 0; while (num3 < num6) { short num = reader.ReadInt16(); Item item = new Item(); if (num > 0) { item.netDefaults(reader.ReadInt32()); item.stack = num; item.Prefix(reader.ReadByte()); } else if (num < 0) { item.netDefaults(reader.ReadInt32()); item.Prefix(reader.ReadByte()); item.stack = 1; } chest.item[num3] = item; num3++; } for (num3 = 0; num3 < num7; num3++) { if (reader.ReadInt16() > 0) { reader.ReadInt32(); reader.ReadByte(); } } Main.chest[index] = chest; index++; } while (index < 0x3e8) { Main.chest[index] = null; index++; } if (versionNumber < 0x73) { FixDresserChests(); } }
public override void SetupShop(Chest shop, ref int nextSlot) { shop.item[nextSlot].SetDefaults(mod.ItemType("EtherealSword")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("EtherealBow")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("EtherealStaff")); nextSlot++; shop.item[nextSlot].SetDefaults(mod.ItemType("EtherealSpear")); nextSlot++; }
public World(string path) { if (genRand == null) { genRand = new Random((int)DateTime.Now.Ticks); } using (FileStream stream = new FileStream(path, FileMode.Open)) { using (BinaryReader reader = new BinaryReader(stream)) { worldVersion = reader.ReadInt32(); Console.WriteLine("World version: " + worldVersion); if (worldVersion >= 28) { tileFrameImportant[4] = true; } Name = reader.ReadString(); Console.WriteLine("World name: " + Name); ID = reader.ReadInt32(); Console.WriteLine("World ID: " + ID); leftWorld = reader.ReadInt32(); Console.WriteLine("World left: " + leftWorld); rightWorld = reader.ReadInt32(); Console.WriteLine("World right: " + rightWorld); topWorld = reader.ReadInt32(); Console.WriteLine("World top: " + topWorld); bottomWorld = reader.ReadInt32(); Console.WriteLine("World bottom: " + bottomWorld); int tilesY = reader.ReadInt32(); Console.WriteLine("Tiles Y: " + tilesY); int tilesX = reader.ReadInt32(); Console.WriteLine("Tiles X: " + tilesX); Size = new Size(tilesX, tilesY); if (worldVersion >= 63) { moonType = reader.ReadByte(); Console.WriteLine("What is the moon type? " + moonType); } if (worldVersion >= 44) { treeX[0] = reader.ReadInt32(); treeX[1] = reader.ReadInt32(); treeX[2] = reader.ReadInt32(); Console.WriteLine("What are the tree type X coords? " + treeX[0] + " " + treeX[1] + " " + treeX[2]); treeStyles[0] = reader.ReadInt32(); treeStyles[1] = reader.ReadInt32(); treeStyles[2] = reader.ReadInt32(); treeStyles[3] = reader.ReadInt32(); Console.WriteLine("What are the tree styles? " + treeStyles[0] + " " + treeStyles[1] + " " + treeStyles[2] + " " + treeStyles[3]); } if (worldVersion >= 60) { caveX[0] = reader.ReadInt32(); caveX[1] = reader.ReadInt32(); caveX[2] = reader.ReadInt32(); Console.WriteLine("What are the cave back X coords? " + caveX[0] + " " + caveX[1] + " " + caveX[2]); caveBackStyles[0] = reader.ReadInt32(); caveBackStyles[1] = reader.ReadInt32(); caveBackStyles[2] = reader.ReadInt32(); caveBackStyles[3] = reader.ReadInt32(); Console.WriteLine("What are the cave back styles? " + caveBackStyles[0] + " " + caveBackStyles[1] + " " + caveBackStyles[2] + " " + caveBackStyles[3]); iceBackStyle = reader.ReadInt32(); Console.WriteLine("What is the ice back style? " + iceBackStyle); } if (worldVersion >= 61) { jungleBackStyle = reader.ReadInt32(); Console.WriteLine("What is the jungle back style? " + jungleBackStyle); hellBackStyle = reader.ReadInt32(); Console.WriteLine("What is the hell back style? " + hellBackStyle); } Spawn = new Point(reader.ReadInt32(), reader.ReadInt32()); Console.WriteLine("Spawn X: " + Spawn.X); Console.WriteLine("Spawn Y: " + Spawn.Y); worldSurface = reader.ReadDouble(); Console.WriteLine("World surface: " + worldSurface); rockLayer = reader.ReadDouble(); Console.WriteLine("Rock layer: " + rockLayer); double tempTime = reader.ReadDouble(); Console.WriteLine("Time: " + tempTime); bool tempDayTime = reader.ReadBoolean(); Console.WriteLine("Is it day? " + tempDayTime); int tempMoonPhase = reader.ReadInt32(); Console.WriteLine("Moon phase: " + tempMoonPhase); bool tempBloodMoon = reader.ReadBoolean(); Console.WriteLine("Is it a blood moon? " + tempBloodMoon); if (worldVersion >= 70) { bool tempEclipse = reader.ReadBoolean(); Console.WriteLine("Is it an eclipse? " + tempEclipse); } Dungeon = new Point(reader.ReadInt32(), reader.ReadInt32()); Console.WriteLine("Dungeon X: " + Dungeon.X); Console.WriteLine("Dungeon Y: " + Dungeon.Y); if (worldVersion >= 56) { crimsonWorld = reader.ReadBoolean(); Console.WriteLine("Crimson world? " + crimsonWorld); } downedBoss1 = reader.ReadBoolean(); Console.WriteLine("Is the Eye Of Cthulu dead? " + downedBoss1); downedBoss2 = reader.ReadBoolean(); Console.WriteLine("Is the Eater Of Worlds dead? " + downedBoss2); downedBoss3 = reader.ReadBoolean(); Console.WriteLine("Is Skeletron dead? " + downedBoss3); if (worldVersion >= 66) { downedBee = reader.ReadBoolean(); Console.WriteLine("Is the Queen Bee dead? " + downedBee); } if (worldVersion >= 44) { downedDestroyer = reader.ReadBoolean(); Console.WriteLine("Is The Destroyer dead? " + downedDestroyer); downedTwins = reader.ReadBoolean(); Console.WriteLine("Are The Twins dead? " + downedTwins); downedPrime = reader.ReadBoolean(); Console.WriteLine("Is Skeletron Prime dead? " + downedPrime); downedHardmodeBoss = reader.ReadBoolean(); Console.WriteLine("Is any hardmode boss dead? " + downedHardmodeBoss); } if (worldVersion >= 64) { downedPlantera = reader.ReadBoolean(); Console.WriteLine("Is Plantera dead? " + downedPlantera); downedGolem = reader.ReadBoolean(); Console.WriteLine("Is the Golem dead? " + downedGolem); } if (worldVersion >= 29) { savedGoblinTinkerer = reader.ReadBoolean(); Console.WriteLine("Is the goblin tinkerer saved? " + savedGoblinTinkerer); savedWizard = reader.ReadBoolean(); Console.WriteLine("Is the wizard saved? " + savedWizard); if (worldVersion >= 34) { savedMechanic = reader.ReadBoolean(); Console.WriteLine("Is the mechanic saved? " + savedMechanic); } defeatedGoblinInvasion = reader.ReadBoolean(); Console.WriteLine("Is the goblin invasion defeated? " + defeatedGoblinInvasion); if (worldVersion >= 32) { killedClown = reader.ReadBoolean(); Console.WriteLine("Is the clown dead? " + killedClown); } if (worldVersion >= 37) { defeatedFrostLegion = reader.ReadBoolean(); Console.WriteLine("Is the frost legion defeated? " + defeatedFrostLegion); } } if (worldVersion >= 56) { defeatedPirates = reader.ReadBoolean(); Console.WriteLine("Are the pirates defeated? " + defeatedPirates); } shadowOrbSmashed = reader.ReadBoolean(); Console.WriteLine("Is an orb broken? " + shadowOrbSmashed); spawnMeteor = reader.ReadBoolean(); Console.WriteLine("Is a meteor spawned? " + spawnMeteor); shadowOrbCount = reader.ReadByte(); Console.WriteLine("Orbs broken: " + shadowOrbCount); if (worldVersion >= 23) { altarsSmashed = reader.ReadInt32(); Console.WriteLine("Altars smashed: " + altarsSmashed); hardMode = reader.ReadBoolean(); Console.WriteLine("Is it hard mode? " + hardMode); } invasionDelay = reader.ReadInt32(); Console.WriteLine("Invasion delay: " + invasionDelay); invasionSize = reader.ReadInt32(); Console.WriteLine("Invasion size: " + invasionSize); invasionType = reader.ReadInt32(); Console.WriteLine("Invasion type: " + invasionType); invasionX = reader.ReadDouble(); Console.WriteLine("Invasion X: " + invasionX); if (worldVersion >= 53) { isRaining = reader.ReadBoolean(); Console.WriteLine("Is raining? " + isRaining); rainTime = reader.ReadInt32(); Console.WriteLine("Rain time: " + rainTime); maxRain = reader.ReadSingle(); Console.WriteLine("Maximum rain: " + maxRain); } if (worldVersion >= 54) { tier1 = reader.ReadInt32(); Console.WriteLine("What is the tier 1 ore? " + tier1); tier2 = reader.ReadInt32(); Console.WriteLine("What is the tier 2 ore? " + tier2); tier3 = reader.ReadInt32(); Console.WriteLine("What is the tier 3 ore? " + tier3); } if (worldVersion >= 55) { treeStyle = reader.ReadByte(); Console.WriteLine("What is the tree style? " + treeStyle); corruptionStyle = reader.ReadByte(); Console.WriteLine("What is the corruption style? " + corruptionStyle); jungleStyle = reader.ReadByte(); Console.WriteLine("What is the jungle style? " + jungleStyle); } if (worldVersion >= 60) { snowStyle = reader.ReadByte(); Console.WriteLine("What is the snow style? " + snowStyle); hallowStyle = reader.ReadByte(); Console.WriteLine("What is the hallow style? " + hallowStyle); crimsonStyle = reader.ReadByte(); Console.WriteLine("What is the crimson style? " + crimsonStyle); desertStyle = reader.ReadByte(); Console.WriteLine("What is the desert style? " + desertStyle); oceanStyle = reader.ReadByte(); Console.WriteLine("What is the ocean style? " + oceanStyle); cloudBackground = reader.ReadInt32(); Console.WriteLine("What is the cloud background? " + cloudBackground); } if (worldVersion >= 62) { numberOfClouds = reader.ReadInt16(); Console.WriteLine("Number of clouds: " + numberOfClouds); windSpeed = reader.ReadSingle(); Console.WriteLine("Wind speed: " + windSpeed); } for (int num4 = 0; num4 < MaxTilesX; num4++) { for (int num6 = 0; num6 < MaxTilesY; num6++) { tile[num4, num6] = new Tile(); } } for (int i = 0; i < tilesX; i++) { // float num3 = ((float)i) / ((float)tilesX); short repeatTile = 0; for (int n = 0; n < tilesY; n++) { if (repeatTile > 0) { tile[i, n] = tile[i, n - 1].Clone(); --repeatTile; } else { tile[i, n].Active = reader.ReadBoolean(); if (tile[i, n].Active) { tile[i, n].Type = reader.ReadByte(); if (tileFrameImportant[tile[i, n].Type]) { if ((worldVersion < 28 && tile[i, n].Type == 4) || (worldVersion < 40 && tile[i, n].Type == 19)) { tile[i, n].FrameX = -1; tile[i, n].FrameY = -1; } else { tile[i, n].FrameX = reader.ReadInt16(); tile[i, n].FrameY = reader.ReadInt16(); } } else { tile[i, n].FrameX = -1; tile[i, n].FrameY = -1; } if (worldVersion >= 48) { bool colorPresent = reader.ReadBoolean(); if (colorPresent) { tile[i, n].Color = reader.ReadByte(); } } } if (worldVersion < 26) // This no longer exists after world version 25. { tile[i, n].Lighted = reader.ReadBoolean(); } if (reader.ReadBoolean()) { tile[i, n].Wall = reader.ReadByte(); if (worldVersion >= 48) { bool wallColorPresent = reader.ReadBoolean(); if (wallColorPresent) { tile[i, n].WallColor = reader.ReadByte(); } } } if (reader.ReadBoolean()) { tile[i, n].Liquid = reader.ReadByte(); tile[i, n].Lava = reader.ReadBoolean(); if (worldVersion >= 51) { tile[i, n].Honey = reader.ReadBoolean(); } } if (worldVersion >= 33) { tile[i, n].Wire = reader.ReadBoolean(); } if (worldVersion >= 43) { tile[i, n].WireGreen = reader.ReadBoolean(); tile[i, n].WireBlue = reader.ReadBoolean(); } if (worldVersion >= 41) { tile[i, n].HalfTile = reader.ReadBoolean(); } if (worldVersion >= 49) { tile[i, n].TileSlope = reader.ReadByte(); } if (worldVersion >= 42) { tile[i, n].ActuatorPresent = reader.ReadBoolean(); tile[i, n].InActive = reader.ReadBoolean(); } if (worldVersion >= 25) { repeatTile = reader.ReadInt16(); //if (repeatTile + n > tilesY) Console.WriteLine("WARNING: Repeating " + repeatTile + " times and there's only " + (tilesY - n) + " left."); } } } } for (int j = 0; j < 1000; j++) { if (reader.ReadBoolean()) { chest[j] = new Chest(); chest[j].Position = new Microsoft.Xna.Framework.Vector2(reader.ReadInt32(), reader.ReadInt32()); for (int num6 = 0; num6 < Chest.MaxItems; num6++) { byte lowByte = reader.ReadByte(); short num7 = lowByte; if (worldVersion >= 59) { byte highByte = reader.ReadByte(); num7 = (short)((highByte << 8) | lowByte); } if (num7 > 0) { chest[j].Items[num6] = new Item(); if (worldVersion < 38) { string itemName = reader.ReadString(); chest[j].Items[num6].Name = itemName; } else { int itemID = reader.ReadInt32(); chest[j].Items[num6].Name = itemID.ToString(); // This belongs in a new field. } if (worldVersion >= 36) { byte itemPrefixID = reader.ReadByte(); // Do we need to save this? } chest[j].Items[num6].Count = num7; //Console.WriteLine("Chest contains " + chest[j].Items[num6].Count + " of " + chest[j].Items[num6].Name + "."); } } if (worldVersion >= 58) { for (int num6 = 0; num6 < Chest.MaxItems; num6++) { byte lowByte = reader.ReadByte(); short num7 = lowByte; if (worldVersion >= 59) { byte highByte = reader.ReadByte(); num7 = (short)((highByte << 8) | lowByte); } if (num7 > 0) { chest[j].ItemsMore[num6] = new Item(); if (worldVersion < 38) { string itemName = reader.ReadString(); chest[j].ItemsMore[num6].Name = itemName; } else { int itemID = reader.ReadInt32(); chest[j].ItemsMore[num6].Name = itemID.ToString(); // This belongs in a new field. } if (worldVersion >= 36) { byte itemPrefixID = reader.ReadByte(); // Do we need to save this? } chest[j].ItemsMore[num6].Count = num7; //Console.WriteLine("Chest contains " + chest[j].Items[num6].Count + " of " + chest[j].Items[num6].Name + "."); } } } } } for (int k = 0; k < 1000; k++) { if (reader.ReadBoolean()) { string str2 = reader.ReadString(); int num9 = reader.ReadInt32(); int num10 = reader.ReadInt32(); /*if (tile[num9, num10].Active && (tile[num9, num10].Type == 0x37)) { sign[k] = new Sign(); sign[k].Position = new Microsoft.Xna.Framework.Vector2(num9, num10); sign[k].Text = str2; }*/ } } bool flag = reader.ReadBoolean(); for (int m = 0; flag; m++) { npc[m] = new Npc(); npc[m].Name = reader.ReadString(); npc[m].Position.X = reader.ReadSingle(); npc[m].Position.Y = reader.ReadSingle(); npc[m].IsHomeless = reader.ReadBoolean(); npc[m].HomePosition = new Microsoft.Xna.Framework.Vector2(reader.ReadInt32(), reader.ReadInt32()); flag = reader.ReadBoolean(); } if (worldVersion >= 31) { String merchantName = reader.ReadString(); String nurseName = reader.ReadString(); String armsDealerName = reader.ReadString(); String dryadName = reader.ReadString(); String guideName = reader.ReadString(); String clothierName = reader.ReadString(); String demolitionistName = reader.ReadString(); String goblinTinkererName = reader.ReadString(); String wizardName = reader.ReadString(); if (worldVersion >= 34) { String mechanicName = reader.ReadString(); } if (worldVersion >= 65) { String truffleName = reader.ReadString(); String steampunkerName = reader.ReadString(); String dyeTraderName = reader.ReadString(); String partyGirlName = reader.ReadString(); String cyborgName = reader.ReadString(); String painterName = reader.ReadString(); String witchDoctorName = reader.ReadString(); String pirateName = reader.ReadString(); } } if (worldVersion >= 7) { Console.WriteLine("Success? " + reader.ReadBoolean()); String validateWorldName = reader.ReadString(); Console.WriteLine("World name matched? " + (Name == validateWorldName)); int validateWorldID = reader.ReadInt32(); Console.WriteLine("World ID matched? " + (ID == validateWorldID)); } Console.WriteLine((stream.Length - stream.Position) + " bytes left."); reader.Close(); waterLine = tilesY; } } FrameTiles(); }
public void GetData(int start, int length) { if (this.whoAmI < 256) { Netplay.serverSock[this.whoAmI].timeOut = 0; } else { Netplay.clientSock.timeOut = 0; } int num = start + 1; byte b = this.readBuffer[start]; if (ServerApi.Hooks.InvokeNetGetData(ref b, this, ref num, ref length)) { return; } Main.rxMsg++; Main.rxData += length; Main.rxMsgType[(int)b]++; Main.rxDataType[(int)b] += length; if (Main.netMode == 1 && Netplay.clientSock.statusMax > 0) { Netplay.clientSock.statusCount++; } if (Main.verboseNetplay) { for (int i = start; i < start + length; i++) { } for (int j = start; j < start + length; j++) { byte arg_CD_0 = this.readBuffer[j]; } } if (Main.netMode == 2 && b != 38 && Netplay.serverSock[this.whoAmI].state == -1) { NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[1], 0, 0f, 0f, 0f, 0); return; } if (Main.netMode == 2 && Netplay.serverSock[this.whoAmI].state < 10 && b > 12 && b != 16 && b != 42 && b != 50 && b != 38 && b != 68) { NetMessage.BootPlayer(this.whoAmI, Lang.mp[2]); } if (b == 1 && Main.netMode == 2) { if (Main.dedServ && Netplay.CheckBan(Netplay.serverSock[this.whoAmI].tcpClient.Client.RemoteEndPoint.ToString())) { NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[3], 0, 0f, 0f, 0f, 0); return; } if (Netplay.serverSock[this.whoAmI].state == 0) { string @string = Encoding.UTF8.GetString(this.readBuffer, start + 1, length - 1); if (!(@string == "Terraria" + Main.curRelease)) { NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[4], 0, 0f, 0f, 0f, 0); return; } if (Netplay.password == null || Netplay.password == "") { Netplay.serverSock[this.whoAmI].state = 1; NetMessage.SendData(3, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0); return; } Netplay.serverSock[this.whoAmI].state = -1; NetMessage.SendData(37, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0); return; } } else { if (b == 2 && Main.netMode == 1) { Netplay.disconnect = true; Main.statusText = Encoding.UTF8.GetString(this.readBuffer, start + 1, length - 1); return; } if (b == 3 && Main.netMode == 1) { if (Netplay.clientSock.state == 1) { Netplay.clientSock.state = 2; } int num2 = (int)this.readBuffer[start + 1]; if (num2 != Main.myPlayer) { Main.player[num2] = (Player)Main.player[Main.myPlayer].Clone(); Main.player[Main.myPlayer] = new Player(); Main.player[num2].whoAmi = num2; Main.myPlayer = num2; } NetMessage.SendData(4, -1, -1, Main.player[Main.myPlayer].name, Main.myPlayer, 0f, 0f, 0f, 0); NetMessage.SendData(68, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0); NetMessage.SendData(16, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0); NetMessage.SendData(42, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0); NetMessage.SendData(50, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0); for (int k = 0; k < 59; k++) { NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].inventory[k].name, Main.myPlayer, (float)k, (float)Main.player[Main.myPlayer].inventory[k].prefix, 0f, 0); } NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[0].name, Main.myPlayer, 59f, (float)Main.player[Main.myPlayer].armor[0].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[1].name, Main.myPlayer, 60f, (float)Main.player[Main.myPlayer].armor[1].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[2].name, Main.myPlayer, 61f, (float)Main.player[Main.myPlayer].armor[2].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[3].name, Main.myPlayer, 62f, (float)Main.player[Main.myPlayer].armor[3].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[4].name, Main.myPlayer, 63f, (float)Main.player[Main.myPlayer].armor[4].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[5].name, Main.myPlayer, 64f, (float)Main.player[Main.myPlayer].armor[5].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[6].name, Main.myPlayer, 65f, (float)Main.player[Main.myPlayer].armor[6].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[7].name, Main.myPlayer, 66f, (float)Main.player[Main.myPlayer].armor[7].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[8].name, Main.myPlayer, 67f, (float)Main.player[Main.myPlayer].armor[8].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[9].name, Main.myPlayer, 68f, (float)Main.player[Main.myPlayer].armor[9].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[10].name, Main.myPlayer, 69f, (float)Main.player[Main.myPlayer].armor[10].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[11].name, Main.myPlayer, 70f, (float)Main.player[Main.myPlayer].armor[11].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[12].name, Main.myPlayer, 71f, (float)Main.player[Main.myPlayer].armor[12].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[13].name, Main.myPlayer, 72f, (float)Main.player[Main.myPlayer].armor[13].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[14].name, Main.myPlayer, 73f, (float)Main.player[Main.myPlayer].armor[14].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[15].name, Main.myPlayer, 74f, (float)Main.player[Main.myPlayer].armor[15].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[0].name, Main.myPlayer, 75f, (float)Main.player[Main.myPlayer].dye[0].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[1].name, Main.myPlayer, 76f, (float)Main.player[Main.myPlayer].dye[1].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[2].name, Main.myPlayer, 77f, (float)Main.player[Main.myPlayer].dye[2].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[3].name, Main.myPlayer, 78f, (float)Main.player[Main.myPlayer].dye[3].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[4].name, Main.myPlayer, 79f, (float)Main.player[Main.myPlayer].dye[4].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[5].name, Main.myPlayer, 80f, (float)Main.player[Main.myPlayer].dye[5].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[6].name, Main.myPlayer, 81f, (float)Main.player[Main.myPlayer].dye[6].prefix, 0f, 0); NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[7].name, Main.myPlayer, 82f, (float)Main.player[Main.myPlayer].dye[7].prefix, 0f, 0); NetMessage.SendData(6, -1, -1, "", 0, 0f, 0f, 0f, 0); if (Netplay.clientSock.state == 2) { Netplay.clientSock.state = 3; return; } } else if (b == 4) { bool flag = false; int num3 = (int)this.readBuffer[start + 1]; if (Main.netMode == 2) { num3 = this.whoAmI; } if (num3 == Main.myPlayer && !Main.ServerSideCharacter) { return; } int num4 = (int)this.readBuffer[start + 2]; if (num4 >= 123) { num4 = 0; } Main.player[num3].hair = num4; Main.player[num3].whoAmi = num3; num += 2; byte b2 = this.readBuffer[num]; num++; if (b2 == 1) { Main.player[num3].male = true; } else { Main.player[num3].male = false; } Main.player[num3].hairDye = this.readBuffer[num]; num++; Main.player[num3].hideVisual = this.readBuffer[num]; num++; Main.player[num3].hairColor.R = this.readBuffer[num]; num++; Main.player[num3].hairColor.G = this.readBuffer[num]; num++; Main.player[num3].hairColor.B = this.readBuffer[num]; num++; Main.player[num3].skinColor.R = this.readBuffer[num]; num++; Main.player[num3].skinColor.G = this.readBuffer[num]; num++; Main.player[num3].skinColor.B = this.readBuffer[num]; num++; Main.player[num3].eyeColor.R = this.readBuffer[num]; num++; Main.player[num3].eyeColor.G = this.readBuffer[num]; num++; Main.player[num3].eyeColor.B = this.readBuffer[num]; num++; Main.player[num3].shirtColor.R = this.readBuffer[num]; num++; Main.player[num3].shirtColor.G = this.readBuffer[num]; num++; Main.player[num3].shirtColor.B = this.readBuffer[num]; num++; Main.player[num3].underShirtColor.R = this.readBuffer[num]; num++; Main.player[num3].underShirtColor.G = this.readBuffer[num]; num++; Main.player[num3].underShirtColor.B = this.readBuffer[num]; num++; Main.player[num3].pantsColor.R = this.readBuffer[num]; num++; Main.player[num3].pantsColor.G = this.readBuffer[num]; num++; Main.player[num3].pantsColor.B = this.readBuffer[num]; num++; Main.player[num3].shoeColor.R = this.readBuffer[num]; num++; Main.player[num3].shoeColor.G = this.readBuffer[num]; num++; Main.player[num3].shoeColor.B = this.readBuffer[num]; num++; byte difficulty = this.readBuffer[num]; Main.player[num3].difficulty = difficulty; num++; string text = Encoding.UTF8.GetString(this.readBuffer, num, length - num + start); text = text.Trim(); Main.player[num3].name = text.Trim(); if (Main.netMode == 2) { if (Netplay.serverSock[this.whoAmI].state < 10) { for (int l = 0; l < 255; l++) { if (l != num3 && text == Main.player[l].name && Netplay.serverSock[l].active) { flag = true; } } } if (flag) { if (!ServerApi.Hooks.InvokeNetNameCollision(num3, text)) { NetMessage.SendData(2, this.whoAmI, -1, text + " " + Lang.mp[5], 0, 0f, 0f, 0f, 0); return; } } if (text.Length > Player.nameLen) { NetMessage.SendData(2, this.whoAmI, -1, "Name is too long.", 0, 0f, 0f, 0f, 0); return; } if (text == "") { NetMessage.SendData(2, this.whoAmI, -1, "Empty name.", 0, 0f, 0f, 0f, 0); return; } Netplay.serverSock[this.whoAmI].oldName = text; Netplay.serverSock[this.whoAmI].name = text; NetMessage.SendData(4, -1, this.whoAmI, text, num3, 0f, 0f, 0f, 0); return; } } else { if (b == 5) { int num5 = (int)this.readBuffer[start + 1]; if (Main.netMode == 2) { num5 = this.whoAmI; } if (num5 == Main.myPlayer && !Main.ServerSideCharacter) { return; } lock (Main.player[num5]) { int num6 = (int)this.readBuffer[start + 2]; int stack = (int)BitConverter.ToInt16(this.readBuffer, start + 3); byte b3 = this.readBuffer[start + 5]; int type = (int)BitConverter.ToInt16(this.readBuffer, start + 6); if (num6 < 59) { Main.player[num5].inventory[num6] = new Item(); Main.player[num5].inventory[num6].netDefaults(type); Main.player[num5].inventory[num6].stack = stack; Main.player[num5].inventory[num6].Prefix((int)b3); if (num5 == Main.myPlayer && num6 == 58) { Main.mouseItem = Main.player[num5].inventory[num6].Clone(); } } else if (num6 >= 75 && num6 <= 82) { int num7 = num6 - 58 - 17; Main.player[num5].dye[num7] = new Item(); Main.player[num5].dye[num7].netDefaults(type); Main.player[num5].dye[num7].stack = stack; Main.player[num5].dye[num7].Prefix((int)b3); } else { Main.player[num5].armor[num6 - 58 - 1] = new Item(); Main.player[num5].armor[num6 - 58 - 1].netDefaults(type); Main.player[num5].armor[num6 - 58 - 1].stack = stack; Main.player[num5].armor[num6 - 58 - 1].Prefix((int)b3); } if (Main.netMode == 2 && num5 == this.whoAmI) { NetMessage.SendData(5, -1, this.whoAmI, "", num5, (float)num6, (float)b3, 0f, 0); } return; } } if (b == 6) { if (Main.netMode == 2) { if (Netplay.serverSock[this.whoAmI].state == 1) { Netplay.serverSock[this.whoAmI].state = 2; } NetMessage.SendData(7, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0); return; } } else if (b == 7) { if (Main.netMode == 1) { Main.time = (double)BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.dayTime = false; if (this.readBuffer[num] == 1) { Main.dayTime = true; } num++; Main.moonPhase = (int)this.readBuffer[num]; num++; int num8 = (int)this.readBuffer[num]; num++; int num9 = (int)this.readBuffer[num]; num++; if (num8 == 1) { Main.bloodMoon = true; } else { Main.bloodMoon = false; } if (num9 == 1) { Main.eclipse = true; } else { Main.eclipse = false; } Main.maxTilesX = BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.maxTilesY = BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.spawnTileX = BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.spawnTileY = BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.worldSurface = (double)BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.rockLayer = (double)BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.worldID = BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.moonType = (int)this.readBuffer[num]; num++; Main.treeX[0] = BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.treeX[1] = BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.treeX[2] = BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.treeStyle[0] = (int)this.readBuffer[num]; num++; Main.treeStyle[1] = (int)this.readBuffer[num]; num++; Main.treeStyle[2] = (int)this.readBuffer[num]; num++; Main.treeStyle[3] = (int)this.readBuffer[num]; num++; Main.caveBackX[0] = BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.caveBackX[1] = BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.caveBackX[2] = BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.caveBackStyle[0] = (int)this.readBuffer[num]; num++; Main.caveBackStyle[1] = (int)this.readBuffer[num]; num++; Main.caveBackStyle[2] = (int)this.readBuffer[num]; num++; Main.caveBackStyle[3] = (int)this.readBuffer[num]; num++; byte style = this.readBuffer[num]; num++; byte style2 = this.readBuffer[num]; num++; byte style3 = this.readBuffer[num]; num++; byte style4 = this.readBuffer[num]; num++; byte style5 = this.readBuffer[num]; num++; byte style6 = this.readBuffer[num]; num++; byte style7 = this.readBuffer[num]; num++; byte style8 = this.readBuffer[num]; num++; WorldGen.setBG(0, (int)style); WorldGen.setBG(1, (int)style2); WorldGen.setBG(2, (int)style3); WorldGen.setBG(3, (int)style4); WorldGen.setBG(4, (int)style5); WorldGen.setBG(5, (int)style6); WorldGen.setBG(6, (int)style7); WorldGen.setBG(7, (int)style8); Main.iceBackStyle = (int)this.readBuffer[num]; num++; Main.jungleBackStyle = (int)this.readBuffer[num]; num++; Main.hellBackStyle = (int)this.readBuffer[num]; num++; Main.windSpeedSet = BitConverter.ToSingle(this.readBuffer, num); num += 4; Main.numClouds = (int)this.readBuffer[num]; num++; byte b4 = this.readBuffer[num]; num++; byte b5 = this.readBuffer[num]; num++; float num10 = BitConverter.ToSingle(this.readBuffer, num); num += 4; Main.maxRaining = num10; if (num10 > 0f) { Main.raining = true; } else { Main.raining = false; } bool flag3 = false; bool crimson = false; if ((b4 & 1) == 1) { WorldGen.shadowOrbSmashed = true; } if ((b4 & 2) == 2) { NPC.downedBoss1 = true; } if ((b4 & 4) == 4) { NPC.downedBoss2 = true; } if ((b4 & 8) == 8) { NPC.downedBoss3 = true; } if ((b4 & 16) == 16) { Main.hardMode = true; } if ((b4 & 32) == 32) { NPC.downedClown = true; } if ((b4 & 64) == 64) { Main.ServerSideCharacter = true; } if ((b4 & 128) == 128) { NPC.downedPlantBoss = true; } if ((b5 & 1) == 1) { NPC.downedMechBoss1 = true; } if ((b5 & 2) == 2) { NPC.downedMechBoss2 = true; } if ((b5 & 4) == 4) { NPC.downedMechBoss3 = true; } if ((b5 & 8) == 8) { NPC.downedMechBossAny = true; } if ((b5 & 16) == 16) { flag3 = true; } if ((b5 & 32) == 32) { crimson = true; } if ((b5 & 64) == 64) { Main.pumpkinMoon = true; } else { Main.pumpkinMoon = false; } if ((b5 & 128) == 128) { Main.snowMoon = true; } else { Main.snowMoon = false; } if (flag3) { Main.cloudBGActive = 1f; } if (!flag3) { Main.cloudBGActive = 0f; } WorldGen.crimson = crimson; Main.worldName = Encoding.UTF8.GetString(this.readBuffer, num, length - num + start); if (Netplay.clientSock.state == 3) { Netplay.clientSock.state = 4; return; } } } else if (b == 8) { if (Main.netMode == 2) { int num11 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int num12 = BitConverter.ToInt32(this.readBuffer, num); num += 4; bool flag4 = true; if (num11 == -1 || num12 == -1) { flag4 = false; } else if (num11 < 10 || num11 > Main.maxTilesX - 10) { flag4 = false; } else if (num12 < 10 || num12 > Main.maxTilesY - 10) { flag4 = false; } int num13 = -1; int num14 = -1; int num15 = Netplay.GetSectionX(Main.spawnTileX) - 2; int num16 = Netplay.GetSectionY(Main.spawnTileY) - 1; int num17 = num15 + 5; int num18 = num16 + 3; if (num15 < 0) { num15 = 0; } if (num17 >= Main.maxSectionsX) { num17 = Main.maxSectionsX - 1; } if (num16 < 0) { num16 = 0; } if (num18 >= Main.maxSectionsY) { num18 = Main.maxSectionsY - 1; } int num19 = (num17 - num15) * (num18 - num16); if (flag4) { num11 = Netplay.GetSectionX(num11) - 2; num12 = Netplay.GetSectionY(num12) - 1; num13 = num11 + 5; num14 = num12 + 3; if (num15 < 0) { num15 = 0; } if (num17 >= Main.maxSectionsX) { num17 = Main.maxSectionsX - 1; } if (num16 < 0) { num16 = 0; } if (num18 >= Main.maxSectionsY) { num18 = Main.maxSectionsY - 1; } for (int m = num11; m < num13; m++) { for (int n = num12; n < num14; n++) { if (m < num15 || m >= num17 || n < num16 || n >= num18) { num19++; } } } } if (Netplay.serverSock[this.whoAmI].state == 2) { Netplay.serverSock[this.whoAmI].state = 3; } NetMessage.SendData(9, this.whoAmI, -1, Lang.inter[44], num19, 0f, 0f, 0f, 0); Netplay.serverSock[this.whoAmI].statusText2 = "is receiving tile data"; Netplay.serverSock[this.whoAmI].statusMax += num19; for (int num20 = num15; num20 < num17; num20++) { for (int num21 = num16; num21 < num18; num21++) { NetMessage.SendSection(this.whoAmI, num20, num21, false); } } if (flag4) { for (int num22 = num11; num22 < num13; num22++) { for (int num23 = num12; num23 < num14; num23++) { NetMessage.SendSection(this.whoAmI, num22, num23, true); } } NetMessage.SendData(11, this.whoAmI, -1, "", num11, (float)num12, (float)(num13 - 1), (float)(num14 - 1), 0); } NetMessage.SendData(11, this.whoAmI, -1, "", num15, (float)num16, (float)(num17 - 1), (float)(num18 - 1), 0); for (int num24 = 0; num24 < 400; num24++) { if (Main.item[num24].active) { NetMessage.SendData(21, this.whoAmI, -1, "", num24, 0f, 0f, 0f, 0); NetMessage.SendData(22, this.whoAmI, -1, "", num24, 0f, 0f, 0f, 0); } } for (int num25 = 0; num25 < 200; num25++) { if (Main.npc[num25].active) { NetMessage.SendData(23, this.whoAmI, -1, "", num25, 0f, 0f, 0f, 0); } } for (int num26 = 0; num26 < 1000; num26++) { if (Main.projectile[num26].active && (Main.projPet[Main.projectile[num26].type] || Main.projectile[num26].netImportant)) { NetMessage.SendData(27, this.whoAmI, -1, "", num26, 0f, 0f, 0f, 0); } } NetMessage.SendData(49, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0); NetMessage.SendData(57, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0); NetMessage.SendData(7, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0); return; } } else if (b == 9) { if (Main.netMode == 1) { int num27 = BitConverter.ToInt32(this.readBuffer, start + 1); string string2 = Encoding.UTF8.GetString(this.readBuffer, start + 5, length - 5); Netplay.clientSock.statusMax += num27; Netplay.clientSock.statusText = string2; return; } } else { if (b == 10 && Main.netMode == 1) { num = start + 1; NetMessage.DecompressTileBlock(this.readBuffer, num, length, true); return; } if (b == 11) { if (Main.netMode == 1) { int startX = (int)BitConverter.ToInt16(this.readBuffer, num); num += 4; int startY = (int)BitConverter.ToInt16(this.readBuffer, num); num += 4; int endX = (int)BitConverter.ToInt16(this.readBuffer, num); num += 4; int endY = (int)BitConverter.ToInt16(this.readBuffer, num); num += 4; WorldGen.SectionTileFrame(startX, startY, endX, endY); return; } } else if (b == 12) { int num28 = (int)this.readBuffer[num]; if (Main.netMode == 2) { num28 = this.whoAmI; } num++; Main.player[num28].SpawnX = BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.player[num28].SpawnY = BitConverter.ToInt32(this.readBuffer, num); num += 4; Main.player[num28].Spawn(); if (Main.netMode == 2 && Netplay.serverSock[this.whoAmI].state >= 3) { if (Netplay.serverSock[this.whoAmI].state == 3) { Netplay.serverSock[this.whoAmI].state = 10; NetMessage.greetPlayer(this.whoAmI); NetMessage.buffer[this.whoAmI].broadcast = true; NetMessage.syncPlayers(); NetMessage.SendData(12, -1, this.whoAmI, "", this.whoAmI, 0f, 0f, 0f, 0); return; } NetMessage.SendData(12, -1, this.whoAmI, "", this.whoAmI, 0f, 0f, 0f, 0); return; } } else if (b == 13) { int num29 = (int)this.readBuffer[num]; if (num29 == Main.myPlayer && !Main.ServerSideCharacter) { return; } if (Main.netMode == 1) { bool arg_1E83_0 = Main.player[num29].active; } if (Main.netMode == 2) { num29 = this.whoAmI; } num++; int num30 = (int)this.readBuffer[num]; num++; int selectedItem = (int)this.readBuffer[num]; num++; float x = BitConverter.ToSingle(this.readBuffer, num); num += 4; float num31 = BitConverter.ToSingle(this.readBuffer, num); num += 4; float x2 = BitConverter.ToSingle(this.readBuffer, num); num += 4; float y = BitConverter.ToSingle(this.readBuffer, num); num += 4; byte b6 = this.readBuffer[num]; num++; Main.player[num29].selectedItem = selectedItem; Main.player[num29].position.X = x; Main.player[num29].position.Y = num31; Main.player[num29].velocity.X = x2; Main.player[num29].velocity.Y = y; Main.player[num29].oldVelocity = Main.player[num29].velocity; Main.player[num29].fallStart = (int)(num31 / 16f); Main.player[num29].controlUp = false; Main.player[num29].controlDown = false; Main.player[num29].controlLeft = false; Main.player[num29].controlRight = false; Main.player[num29].controlJump = false; Main.player[num29].controlUseItem = false; Main.player[num29].direction = -1; if ((num30 & 1) == 1) { Main.player[num29].controlUp = true; } if ((num30 & 2) == 2) { Main.player[num29].controlDown = true; } if ((num30 & 4) == 4) { Main.player[num29].controlLeft = true; } if ((num30 & 8) == 8) { Main.player[num29].controlRight = true; } if ((num30 & 16) == 16) { Main.player[num29].controlJump = true; } if ((num30 & 32) == 32) { Main.player[num29].controlUseItem = true; } if ((num30 & 64) == 64) { Main.player[num29].direction = 1; } if ((b6 & 1) == 1) { Main.player[num29].pulley = true; if ((b6 & 2) == 2) { Main.player[num29].pulleyDir = 2; } else { Main.player[num29].pulleyDir = 1; } } else { Main.player[num29].pulley = false; } if (Main.netMode == 2 && Netplay.serverSock[this.whoAmI].state == 10) { NetMessage.SendData(13, -1, this.whoAmI, "", num29, 0f, 0f, 0f, 0); return; } } else if (b == 14) { if (Main.netMode == 1) { int num32 = (int)this.readBuffer[num]; num++; int num33 = (int)this.readBuffer[num]; if (num33 == 1) { if (!Main.player[num32].active) { Main.player[num32] = new Player(); } Main.player[num32].active = true; return; } Main.player[num32].active = false; return; } } else if (b == 15) { if (Main.netMode == 2) { return; } } else if (b == 16) { int num34 = (int)this.readBuffer[num]; num++; if (num34 == Main.myPlayer && !Main.ServerSideCharacter) { return; } int statLife = (int)BitConverter.ToInt16(this.readBuffer, num); num += 2; int num35 = (int)BitConverter.ToInt16(this.readBuffer, num); if (Main.netMode == 2) { num34 = this.whoAmI; } Main.player[num34].statLife = statLife; if (num35 < 100) { num35 = 100; } Main.player[num34].statLifeMax = num35; if (Main.player[num34].statLife <= 0) { Main.player[num34].dead = true; } if (Main.netMode == 2) { NetMessage.SendData(16, -1, this.whoAmI, "", num34, 0f, 0f, 0f, 0); return; } } else if (b == 17) { byte b7 = this.readBuffer[num]; num++; int num36 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int num37 = BitConverter.ToInt32(this.readBuffer, num); num += 4; short num38 = BitConverter.ToInt16(this.readBuffer, num); num += 2; int num39 = (int)this.readBuffer[num]; bool flag5 = false; if (num38 == 1) { flag5 = true; } if (Main.tile[num36, num37] == null) { Main.tile[num36, num37] = new Tile(); } if (Main.netMode == 2) { if (!flag5) { if (b7 == 0 || b7 == 2 || b7 == 4) { Netplay.serverSock[this.whoAmI].spamDelBlock += 1f; } else if (b7 == 1 || b7 == 3) { Netplay.serverSock[this.whoAmI].spamAddBlock += 1f; } } if (!Netplay.serverSock[this.whoAmI].tileSection[Netplay.GetSectionX(num36), Netplay.GetSectionY(num37)]) { flag5 = true; } } if (b7 == 0) { WorldGen.KillTile(num36, num37, flag5, false, false); } else if (b7 == 1) { WorldGen.PlaceTile(num36, num37, (int)num38, false, true, -1, num39); } else if (b7 == 2) { WorldGen.KillWall(num36, num37, flag5); } else if (b7 == 3) { WorldGen.PlaceWall(num36, num37, (int)num38, false); } else if (b7 == 4) { WorldGen.KillTile(num36, num37, flag5, false, true); } else if (b7 == 5) { WorldGen.PlaceWire(num36, num37); } else if (b7 == 6) { WorldGen.KillWire(num36, num37); } else if (b7 == 7) { WorldGen.PoundTile(num36, num37); } else if (b7 == 8) { WorldGen.PlaceActuator(num36, num37); } else if (b7 == 9) { WorldGen.KillActuator(num36, num37); } else if (b7 == 10) { WorldGen.PlaceWire2(num36, num37); } else if (b7 == 11) { WorldGen.KillWire2(num36, num37); } else if (b7 == 12) { WorldGen.PlaceWire3(num36, num37); } else if (b7 == 13) { WorldGen.KillWire3(num36, num37); } else if (b7 == 14) { WorldGen.SlopeTile(num36, num37, (int)num38); } if (Main.netMode == 2) { NetMessage.SendData(17, -1, this.whoAmI, "", (int)b7, (float)num36, (float)num37, (float)num38, num39); if (b7 == 1 && num38 == 53) { NetMessage.SendTileSquare(-1, num36, num37, 1); return; } } } else if (b == 18) { if (Main.netMode == 1) { byte b8 = this.readBuffer[num]; num++; int num40 = BitConverter.ToInt32(this.readBuffer, num); num += 4; short sunModY = BitConverter.ToInt16(this.readBuffer, num); num += 2; short moonModY = BitConverter.ToInt16(this.readBuffer, num); num += 2; if (b8 == 1) { Main.dayTime = true; } else { Main.dayTime = false; } Main.time = (double)num40; Main.sunModY = sunModY; Main.moonModY = moonModY; if (Main.netMode == 2) { NetMessage.SendData(18, -1, this.whoAmI, "", 0, 0f, 0f, 0f, 0); return; } } } else if (b == 19) { byte b9 = this.readBuffer[num]; num++; int num41 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int num42 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int num43 = (int)this.readBuffer[num]; int direction = 0; if (num43 == 0) { direction = -1; } if (b9 == 0) { WorldGen.OpenDoor(num41, num42, direction); } else if (b9 == 1) { WorldGen.CloseDoor(num41, num42, true); } if (Main.netMode == 2) { NetMessage.SendData(19, -1, this.whoAmI, "", (int)b9, (float)num41, (float)num42, (float)num43, 0); return; } } else if (b == 20) { short num44 = BitConverter.ToInt16(this.readBuffer, start + 1); int num45 = BitConverter.ToInt32(this.readBuffer, start + 3); int num46 = BitConverter.ToInt32(this.readBuffer, start + 7); num = start + 11; for (int num47 = num45; num47 < num45 + (int)num44; num47++) { for (int num48 = num46; num48 < num46 + (int)num44; num48++) { if (Main.tile[num47, num48] == null) { Main.tile[num47, num48] = new Tile(); } byte b10 = this.readBuffer[num]; num++; byte b11 = this.readBuffer[num]; num++; bool flag6 = Main.tile[num47, num48].active(); if ((b10 & 1) == 1) { Main.tile[num47, num48].active(true); } else { Main.tile[num47, num48].active(false); } if ((b10 & 4) == 4) { Main.tile[num47, num48].wall = 1; } else { Main.tile[num47, num48].wall = 0; } bool flag7 = false; if ((b10 & 8) == 8) { flag7 = true; } if (Main.netMode != 2) { if (flag7) { Main.tile[num47, num48].liquid = 1; } else { Main.tile[num47, num48].liquid = 0; } } if ((b10 & 16) == 16) { Main.tile[num47, num48].wire(true); } else { Main.tile[num47, num48].wire(false); } if ((b10 & 32) == 32) { Main.tile[num47, num48].halfBrick(true); } else { Main.tile[num47, num48].halfBrick(false); } if ((b10 & 64) == 64) { Main.tile[num47, num48].actuator(true); } else { Main.tile[num47, num48].actuator(false); } if ((b10 & 128) == 128) { Main.tile[num47, num48].inActive(true); } else { Main.tile[num47, num48].inActive(false); } if ((b11 & 1) == 1) { Main.tile[num47, num48].wire2(true); } else { Main.tile[num47, num48].wire2(false); } if ((b11 & 2) == 2) { Main.tile[num47, num48].wire3(true); } else { Main.tile[num47, num48].wire3(false); } if ((b11 & 4) == 4) { Main.tile[num47, num48].color(this.readBuffer[num]); num++; } if ((b11 & 8) == 8) { Main.tile[num47, num48].wallColor(this.readBuffer[num]); num++; } if (Main.tile[num47, num48].active()) { int type2 = (int)Main.tile[num47, num48].type; Main.tile[num47, num48].type = BitConverter.ToUInt16(this.readBuffer, num); num += 2; if (Main.tileFrameImportant[(int)Main.tile[num47, num48].type]) { Main.tile[num47, num48].frameX = BitConverter.ToInt16(this.readBuffer, num); num += 2; Main.tile[num47, num48].frameY = BitConverter.ToInt16(this.readBuffer, num); num += 2; } else if (!flag6 || (int)Main.tile[num47, num48].type != type2) { Main.tile[num47, num48].frameX = -1; Main.tile[num47, num48].frameY = -1; } byte b12 = 0; if ((b11 & 16) == 16) { b12 = (byte)(b12 + 1); } if ((b11 & 32) == 32) { b12 = (byte)(b12 + 2); } if ((b11 & 64) == 64) { b12 = (byte)(b12 + 4); } Main.tile[num47, num48].slope(b12); } if (Main.tile[num47, num48].wall > 0) { Main.tile[num47, num48].wall = this.readBuffer[num]; num++; } if (flag7) { Main.tile[num47, num48].liquid = this.readBuffer[num]; num++; byte liquidType = this.readBuffer[num]; num++; Main.tile[num47, num48].liquidType((int)liquidType); } } } WorldGen.RangeFrame(num45, num46, num45 + (int)num44, num46 + (int)num44); if (Main.netMode == 2) { NetMessage.SendData((int)b, -1, this.whoAmI, "", (int)num44, (float)num45, (float)num46, 0f, 0); return; } } else if (b == 21) { short num49 = BitConverter.ToInt16(this.readBuffer, num); num += 2; float num50 = BitConverter.ToSingle(this.readBuffer, num); num += 4; float num51 = BitConverter.ToSingle(this.readBuffer, num); num += 4; float x3 = BitConverter.ToSingle(this.readBuffer, num); num += 4; float y2 = BitConverter.ToSingle(this.readBuffer, num); num += 4; short stack2 = BitConverter.ToInt16(this.readBuffer, num); num += 2; byte pre = this.readBuffer[num]; num++; byte b13 = this.readBuffer[num]; num++; short num52 = BitConverter.ToInt16(this.readBuffer, num); if (Main.netMode == 1) { if (num52 == 0) { Main.item[(int)num49].active = false; return; } Main.item[(int)num49].netDefaults((int)num52); Main.item[(int)num49].Prefix((int)pre); Main.item[(int)num49].stack = (int)stack2; Main.item[(int)num49].position.X = num50; Main.item[(int)num49].position.Y = num51; Main.item[(int)num49].velocity.X = x3; Main.item[(int)num49].velocity.Y = y2; Main.item[(int)num49].active = true; Main.item[(int)num49].wet = Collision.WetCollision(Main.item[(int)num49].position, Main.item[(int)num49].width, Main.item[(int)num49].height); return; } else if (num52 == 0) { if (num49 < 400) { Main.item[(int)num49].active = false; NetMessage.SendData(21, -1, -1, "", (int)num49, 0f, 0f, 0f, 0); return; } } else { bool flag8 = false; if (num49 == 400) { flag8 = true; } if (flag8) { Item item = new Item(); item.netDefaults((int)num52); num49 = (short)Item.NewItem((int)num50, (int)num51, item.width, item.height, item.type, (int)stack2, true, 0, false); } Main.item[(int)num49].netDefaults((int)num52); Main.item[(int)num49].Prefix((int)pre); Main.item[(int)num49].stack = (int)stack2; Main.item[(int)num49].position.X = num50; Main.item[(int)num49].position.Y = num51; Main.item[(int)num49].velocity.X = x3; Main.item[(int)num49].velocity.Y = y2; Main.item[(int)num49].active = true; Main.item[(int)num49].owner = Main.myPlayer; if (flag8) { NetMessage.SendData(21, -1, -1, "", (int)num49, 0f, 0f, 0f, 0); if (b13 == 0) { Main.item[(int)num49].ownIgnore = this.whoAmI; Main.item[(int)num49].ownTime = 100; } Main.item[(int)num49].FindOwner((int)num49); return; } NetMessage.SendData(21, -1, this.whoAmI, "", (int)num49, 0f, 0f, 0f, 0); return; } } else if (b == 22) { short num53 = BitConverter.ToInt16(this.readBuffer, num); num += 2; byte b14 = this.readBuffer[num]; if (Main.netMode == 2 && Main.item[(int)num53].owner != this.whoAmI) { return; } Main.item[(int)num53].owner = (int)b14; if ((int)b14 == Main.myPlayer) { Main.item[(int)num53].keepTime = 15; } else { Main.item[(int)num53].keepTime = 0; } if (Main.netMode == 2) { Main.item[(int)num53].owner = 255; Main.item[(int)num53].keepTime = 15; NetMessage.SendData(22, -1, -1, "", (int)num53, 0f, 0f, 0f, 0); return; } } else if (b == 23 && Main.netMode == 1) { short num54 = BitConverter.ToInt16(this.readBuffer, num); num += 2; float x4 = BitConverter.ToSingle(this.readBuffer, num); num += 4; float y3 = BitConverter.ToSingle(this.readBuffer, num); num += 4; float x5 = BitConverter.ToSingle(this.readBuffer, num); num += 4; float y4 = BitConverter.ToSingle(this.readBuffer, num); num += 4; int target = (int)this.readBuffer[num]; num++; byte b15 = this.readBuffer[num]; num++; int direction2 = -1; int directionY = -1; if ((b15 & 1) == 1) { direction2 = 1; } if ((b15 & 2) == 2) { directionY = 1; } bool[] array = new bool[4]; if ((b15 & 4) == 4) { array[3] = true; } if ((b15 & 8) == 8) { array[2] = true; } if ((b15 & 16) == 16) { array[1] = true; } if ((b15 & 32) == 32) { array[0] = true; } int spriteDirection = -1; if ((b15 & 64) == 64) { spriteDirection = 1; } int num55 = BitConverter.ToInt32(this.readBuffer, num); num += 4; float[] array2 = new float[NPC.maxAI]; for (int num56 = 0; num56 < NPC.maxAI; num56++) { if (array[num56]) { array2[num56] = BitConverter.ToSingle(this.readBuffer, num); num += 4; } else { array2[num56] = 0f; } } int num57 = (int)BitConverter.ToInt16(this.readBuffer, num); num += 2; int num58 = -1; if (!Main.npc[(int)num54].active || Main.npc[(int)num54].netID != num57) { if (Main.npc[(int)num54].active) { num58 = Main.npc[(int)num54].type; } Main.npc[(int)num54].active = true; Main.npc[(int)num54].netDefaults(num57); } Main.npc[(int)num54].position.X = x4; Main.npc[(int)num54].position.Y = y3; Main.npc[(int)num54].velocity.X = x5; Main.npc[(int)num54].velocity.Y = y4; Main.npc[(int)num54].target = target; Main.npc[(int)num54].direction = direction2; Main.npc[(int)num54].directionY = directionY; Main.npc[(int)num54].spriteDirection = spriteDirection; Main.npc[(int)num54].life = num55; if (num55 <= 0) { Main.npc[(int)num54].active = false; } for (int num59 = 0; num59 < NPC.maxAI; num59++) { Main.npc[(int)num54].ai[num59] = array2[num59]; } if (num58 > -1 && num58 != Main.npc[(int)num54].type) { Main.npc[(int)num54].xForm(num58, Main.npc[(int)num54].type); } if (num57 == 262) { NPC.plantBoss = (int)num54; } if (num57 == 245) { NPC.golemBoss = (int)num54; } if (Main.npcCatchable[Main.npc[(int)num54].type]) { byte releaseOwner = this.readBuffer[num]; num++; Main.npc[(int)num54].releaseOwner = (short)releaseOwner; return; } } else if (b == 24) { short num60 = BitConverter.ToInt16(this.readBuffer, num); num += 2; byte b16 = this.readBuffer[num]; if (Main.netMode == 2) { b16 = (byte)this.whoAmI; } Main.npc[(int)num60].StrikeNPC(Main.player[(int)b16].inventory[Main.player[(int)b16].selectedItem].damage, Main.player[(int)b16].inventory[Main.player[(int)b16].selectedItem].knockBack, Main.player[(int)b16].direction, false, false); if (Main.netMode == 2) { NetMessage.SendData(24, -1, this.whoAmI, "", (int)num60, (float)b16, 0f, 0f, 0); NetMessage.SendData(23, -1, -1, "", (int)num60, 0f, 0f, 0f, 0); return; } } else if (b == 25) { int num61 = (int)this.readBuffer[start + 1]; if (Main.netMode == 2) { num61 = this.whoAmI; } byte b17 = this.readBuffer[start + 2]; byte b18 = this.readBuffer[start + 3]; byte b19 = this.readBuffer[start + 4]; if (Main.netMode == 2) { b17 = 255; b18 = 255; b19 = 255; } string string3 = Encoding.UTF8.GetString(this.readBuffer, start + 5, length - 5); if (Main.netMode == 1) { string newText = string3; if (num61 < 255) { newText = "<" + Main.player[num61].name + "> " + string3; Main.player[num61].chatText = string3; Main.player[num61].chatShowTime = Main.chatLength / 2; } Main.NewText(newText, b17, b18, b19, false); return; } if (Main.netMode == 2) { string text2 = string3.ToLower(); if (text2 == Lang.mp[6] || text2 == Lang.mp[21]) { string text3 = ""; for (int num62 = 0; num62 < 255; num62++) { if (Main.player[num62].active) { if (text3 == "") { text3 += Main.player[num62].name; } else { text3 = text3 + ", " + Main.player[num62].name; } } } NetMessage.SendData(25, this.whoAmI, -1, Lang.mp[7] + " " + text3 + ".", 255, 255f, 240f, 20f, 0); return; } if (text2.Length >= 4 && text2.Substring(0, 4) == "/me ") { NetMessage.SendData(25, -1, -1, "*" + Main.player[this.whoAmI].name + " " + string3.Substring(4), 255, 200f, 100f, 0f, 0); return; } if (text2 == Lang.mp[8]) { NetMessage.SendData(25, -1, -1, string.Concat(new object[] { "*", Main.player[this.whoAmI].name, " ", Lang.mp[9], " ", Main.rand.Next(1, 101) }), 255, 255f, 240f, 20f, 0); return; } if (text2.Length >= 3 && text2.Substring(0, 3) == "/p ") { if (Main.player[this.whoAmI].team != 0) { for (int num63 = 0; num63 < 255; num63++) { if (Main.player[num63].team == Main.player[this.whoAmI].team) { NetMessage.SendData(25, num63, -1, string3.Substring(3), num61, (float)Main.teamColor[Main.player[this.whoAmI].team].R, (float)Main.teamColor[Main.player[this.whoAmI].team].G, (float)Main.teamColor[Main.player[this.whoAmI].team].B, 0); } } return; } NetMessage.SendData(25, this.whoAmI, -1, Lang.mp[10], 255, 255f, 240f, 20f, 0); return; } else { if (Main.player[this.whoAmI].difficulty == 2) { b17 = Main.hcColor.R; b18 = Main.hcColor.G; b19 = Main.hcColor.B; } else if (Main.player[this.whoAmI].difficulty == 1) { b17 = Main.mcColor.R; b18 = Main.mcColor.G; b19 = Main.mcColor.B; } NetMessage.SendData(25, -1, -1, string3, num61, (float)b17, (float)b18, (float)b19, 0); if (Main.dedServ) { Console.WriteLine("<" + Main.player[this.whoAmI].name + "> " + string3); return; } } } } else if (b == 26) { byte b20 = this.readBuffer[num]; if (Main.netMode == 2 && this.whoAmI != (int)b20 && (!Main.player[(int)b20].hostile || !Main.player[this.whoAmI].hostile)) { return; } num++; int num64 = this.readBuffer[num] - 1; num++; short num65 = BitConverter.ToInt16(this.readBuffer, num); num += 2; byte b21 = this.readBuffer[num]; num++; bool pvp = false; byte b22 = this.readBuffer[num]; num++; bool crit = false; string string4 = Encoding.UTF8.GetString(this.readBuffer, num, length - num + start); if (b21 != 0) { pvp = true; } if (b22 != 0) { crit = true; } Main.player[(int)b20].Hurt((int)num65, num64, pvp, true, string4, crit); if (Main.netMode == 2) { NetMessage.SendData(26, -1, this.whoAmI, string4, (int)b20, (float)num64, (float)num65, (float)b21, (int)b22); return; } } else if (b == 27) { short num66 = BitConverter.ToInt16(this.readBuffer, num); num += 2; float x6 = BitConverter.ToSingle(this.readBuffer, num); num += 4; float y5 = BitConverter.ToSingle(this.readBuffer, num); num += 4; float x7 = BitConverter.ToSingle(this.readBuffer, num); num += 4; float y6 = BitConverter.ToSingle(this.readBuffer, num); num += 4; float knockBack = BitConverter.ToSingle(this.readBuffer, num); num += 4; short damage = BitConverter.ToInt16(this.readBuffer, num); num += 2; byte b23 = this.readBuffer[num]; num++; short num67 = BitConverter.ToInt16(this.readBuffer, num); num += 2; float[] array3 = new float[Projectile.maxAI]; if (Main.netMode == 2) { b23 = (byte)this.whoAmI; if (Main.projHostile[(int)num67]) { return; } } for (int num68 = 0; num68 < Projectile.maxAI; num68++) { array3[num68] = BitConverter.ToSingle(this.readBuffer, num); num += 4; } int num69 = 1000; for (int num70 = 0; num70 < 1000; num70++) { if (Main.projectile[num70].owner == (int)b23 && Main.projectile[num70].identity == (int)num66 && Main.projectile[num70].active) { num69 = num70; break; } } if (num69 == 1000) { for (int num71 = 0; num71 < 1000; num71++) { if (!Main.projectile[num71].active) { num69 = num71; break; } } } if (!Main.projectile[num69].active || Main.projectile[num69].type != (int)num67) { Main.projectile[num69].SetDefaults((int)num67); if (Main.netMode == 2) { Netplay.serverSock[this.whoAmI].spamProjectile += 1f; } } Main.projectile[num69].identity = (int)num66; Main.projectile[num69].position.X = x6; Main.projectile[num69].position.Y = y5; Main.projectile[num69].velocity.X = x7; Main.projectile[num69].velocity.Y = y6; Main.projectile[num69].damage = (int)damage; Main.projectile[num69].type = (int)num67; Main.projectile[num69].owner = (int)b23; Main.projectile[num69].knockBack = knockBack; for (int num72 = 0; num72 < Projectile.maxAI; num72++) { Main.projectile[num69].ai[num72] = array3[num72]; } if (Main.netMode == 2) { NetMessage.SendData(27, -1, this.whoAmI, "", num69, 0f, 0f, 0f, 0); return; } } else if (b == 28) { short num73 = BitConverter.ToInt16(this.readBuffer, num); num += 2; short num74 = BitConverter.ToInt16(this.readBuffer, num); num += 2; float num75 = BitConverter.ToSingle(this.readBuffer, num); num += 4; int num76 = this.readBuffer[num] - 1; num++; int num77 = (int)this.readBuffer[num]; if (num74 >= 0) { if (num77 == 1) { Main.npc[(int)num73].StrikeNPC((int)num74, num75, num76, true, false); } else { Main.npc[(int)num73].StrikeNPC((int)num74, num75, num76, false, false); } } else { Main.npc[(int)num73].life = 0; Main.npc[(int)num73].HitEffect(0, 10.0); Main.npc[(int)num73].active = false; } if (Main.netMode == 2) { if (Main.npc[(int)num73].life <= 0) { NetMessage.SendData(28, -1, this.whoAmI, "", (int)num73, (float)num74, num75, (float)num76, num77); NetMessage.SendData(23, -1, -1, "", (int)num73, 0f, 0f, 0f, 0); return; } NetMessage.SendData(28, -1, this.whoAmI, "", (int)num73, (float)num74, num75, (float)num76, num77); Main.npc[(int)num73].netUpdate = true; return; } } else if (b == 29) { short num78 = BitConverter.ToInt16(this.readBuffer, num); num += 2; byte b24 = this.readBuffer[num]; if (Main.netMode == 2) { b24 = (byte)this.whoAmI; } for (int num79 = 0; num79 < 1000; num79++) { if (Main.projectile[num79].owner == (int)b24 && Main.projectile[num79].identity == (int)num78 && Main.projectile[num79].active) { Main.projectile[num79].Kill(); break; } } if (Main.netMode == 2) { NetMessage.SendData(29, -1, this.whoAmI, "", (int)num78, (float)b24, 0f, 0f, 0); return; } } else if (b == 30) { byte b25 = this.readBuffer[num]; if (Main.netMode == 2) { b25 = (byte)this.whoAmI; } num++; byte b26 = this.readBuffer[num]; if (b26 == 1) { Main.player[(int)b25].hostile = true; } else { Main.player[(int)b25].hostile = false; } if (Main.netMode == 2) { NetMessage.SendData(30, -1, this.whoAmI, "", (int)b25, 0f, 0f, 0f, 0); string str = " " + Lang.mp[11]; if (b26 == 0) { str = " " + Lang.mp[12]; } NetMessage.SendData(25, -1, -1, Main.player[(int)b25].name + str, 255, (float)Main.teamColor[Main.player[(int)b25].team].R, (float)Main.teamColor[Main.player[(int)b25].team].G, (float)Main.teamColor[Main.player[(int)b25].team].B, 0); return; } } else if (b == 31) { if (Main.netMode == 2) { int x8 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int y7 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int num80 = Chest.FindChest(x8, y7); if (num80 > -1 && Chest.UsingChest(num80) == -1) { for (int num81 = 0; num81 < Chest.maxItems; num81++) { NetMessage.SendData(32, this.whoAmI, -1, "", num80, (float)num81, 0f, 0f, 0); } NetMessage.SendData(33, this.whoAmI, -1, "", num80, 0f, 0f, 0f, 0); Main.player[this.whoAmI].chest = num80; return; } } } else { if (b == 32) { int num82 = (int)BitConverter.ToInt16(this.readBuffer, num); num += 2; int num83 = (int)this.readBuffer[num]; num++; int stack3 = (int)BitConverter.ToInt16(this.readBuffer, num); num += 2; int pre2 = (int)this.readBuffer[num]; num++; int type3 = (int)BitConverter.ToInt16(this.readBuffer, num); if (Main.chest[num82] == null) { Main.chest[num82] = new Chest(false); } if (Main.chest[num82].item[num83] == null) { Main.chest[num82].item[num83] = new Item(); } Main.chest[num82].item[num83].netDefaults(type3); Main.chest[num82].item[num83].Prefix(pre2); Main.chest[num82].item[num83].stack = stack3; return; } if (b == 33) { int num84 = (int)BitConverter.ToInt16(this.readBuffer, num); num += 2; int chestX = BitConverter.ToInt32(this.readBuffer, num); num += 4; int chestY = BitConverter.ToInt32(this.readBuffer, num); num += 4; int num85 = (int)this.readBuffer[num]; num++; string text4 = string.Empty; if (num85 != 0) { if (num85 <= 20) { text4 = Encoding.UTF8.GetString(this.readBuffer, num, num85); } else if (num85 != 255) { num85 = 0; } } if (Main.netMode == 1) { if (Main.player[Main.myPlayer].chest == -1) { Main.playerInventory = true; Main.PlaySound(10, -1, -1, 1); } else if (Main.player[Main.myPlayer].chest != num84 && num84 != -1) { Main.playerInventory = true; Main.PlaySound(12, -1, -1, 1); } else if (Main.player[Main.myPlayer].chest != -1 && num84 == -1) { Main.PlaySound(11, -1, -1, 1); } Main.player[Main.myPlayer].chest = num84; Main.player[Main.myPlayer].chestX = chestX; Main.player[Main.myPlayer].chestY = chestY; return; } if (num85 != 0) { int chest = Main.player[this.whoAmI].chest; Chest chest2 = Main.chest[chest]; chest2.name = text4; NetMessage.SendData(69, -1, this.whoAmI, text4, chest, (float)chest2.x, (float)chest2.y, 0f, 0); } Main.player[this.whoAmI].chest = num84; return; } else if (b == 34) { byte b27 = this.readBuffer[num]; num++; int num86 = (int)BitConverter.ToInt16(this.readBuffer, num); num += 2; int num87 = (int)BitConverter.ToInt16(this.readBuffer, num); num += 2; short num88 = BitConverter.ToInt16(this.readBuffer, num); num += 2; if (Main.netMode == 2) { if (b27 == 0) { int num89 = WorldGen.PlaceChest(num86, num87, 21, false, (int)num88); if (num89 == -1) { NetMessage.SendData(34, this.whoAmI, -1, "", (int)b27, (float)num86, (float)num87, (float)num88, num89); Item.NewItem(num86 * 16, num87 * 16, 32, 32, Chest.itemSpawn[(int)num88], 1, true, 0, false); return; } NetMessage.SendData(34, -1, -1, "", (int)b27, (float)num86, (float)num87, (float)num88, num89); return; } else { Tile tile = Main.tile[num86, num87]; if (tile.type == 21) { if (tile.frameX % 36 != 0) { num86--; } if (tile.frameY % 36 != 0) { num87--; } int number = Chest.FindChest(num86, num87); WorldGen.KillTile(num86, num87, false, false, false); if (!Main.tile[num86, num87].active()) { NetMessage.SendData(34, -1, -1, "", (int)b27, (float)num86, (float)num87, 0f, number); return; } } } } else { short num90 = BitConverter.ToInt16(this.readBuffer, num); num += 2; if (b27 != 0) { Chest.DestroyChestDirect(num86, num87, (int)num90); WorldGen.KillTile(num86, num87, false, false, false); return; } if (num90 == -1) { WorldGen.KillTile(num86, num87, false, false, false); return; } WorldGen.PlaceChestDirect(num86, num87, 21, (int)num88, (int)num90); return; } } else if (b == 35) { int num91 = (int)this.readBuffer[num]; if (Main.netMode == 2) { num91 = this.whoAmI; } num++; int num92 = (int)BitConverter.ToInt16(this.readBuffer, num); num += 2; if (Main.netMode == 2) { NetMessage.SendData(35, -1, this.whoAmI, "", num91, (float)num92, 0f, 0f, 0); return; } } else if (b == 36) { int num93 = (int)this.readBuffer[num]; if (Main.netMode == 2) { num93 = this.whoAmI; } num++; byte b28 = this.readBuffer[num]; num++; if ((b28 & 1) == 1) { Main.player[num93].zoneEvil = true; } else { Main.player[num93].zoneEvil = false; } if ((b28 & 2) == 2) { Main.player[num93].zoneMeteor = true; } else { Main.player[num93].zoneMeteor = false; } if ((b28 & 4) == 4) { Main.player[num93].zoneDungeon = true; } else { Main.player[num93].zoneDungeon = false; } if ((b28 & 8) == 8) { Main.player[num93].zoneJungle = true; } else { Main.player[num93].zoneJungle = false; } if ((b28 & 16) == 16) { Main.player[num93].zoneHoly = true; } else { Main.player[num93].zoneHoly = false; } if ((b28 & 32) == 32) { Main.player[num93].zoneSnow = true; } else { Main.player[num93].zoneSnow = false; } if ((b28 & 64) == 64) { Main.player[num93].zoneBlood = true; } else { Main.player[num93].zoneBlood = false; } if ((b28 & 128) == 128) { Main.player[num93].zoneCandle = true; } else { Main.player[num93].zoneCandle = false; } if (Main.netMode == 2) { NetMessage.SendData(36, -1, this.whoAmI, "", num93, 0f, 0f, 0f, 0); return; } } else if (b == 37) { if (Main.netMode == 1) { if (Main.autoPass) { NetMessage.SendData(38, -1, -1, Netplay.password, 0, 0f, 0f, 0f, 0); Main.autoPass = false; return; } Netplay.password = ""; Main.menuMode = 31; return; } } else if (b == 38) { if (Main.netMode == 2) { string string5 = Encoding.UTF8.GetString(this.readBuffer, num, length - num + start); if (string5 == Netplay.password) { Netplay.serverSock[this.whoAmI].state = 1; NetMessage.SendData(3, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0); return; } NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[1], 0, 0f, 0f, 0f, 0); return; } } else { if (b == 39 && Main.netMode == 1) { short num94 = BitConverter.ToInt16(this.readBuffer, num); Main.item[(int)num94].owner = 255; NetMessage.SendData(22, -1, -1, "", (int)num94, 0f, 0f, 0f, 0); return; } if (b == 40) { byte b29 = this.readBuffer[num]; if (Main.netMode == 2) { b29 = (byte)this.whoAmI; } num++; int talkNPC = (int)BitConverter.ToInt16(this.readBuffer, num); num += 2; Main.player[(int)b29].talkNPC = talkNPC; if (Main.netMode == 2) { NetMessage.SendData(40, -1, this.whoAmI, "", (int)b29, 0f, 0f, 0f, 0); return; } } else if (b == 41) { byte b30 = this.readBuffer[num]; if (Main.netMode == 2) { b30 = (byte)this.whoAmI; } num++; float itemRotation = BitConverter.ToSingle(this.readBuffer, num); num += 4; int itemAnimation = (int)BitConverter.ToInt16(this.readBuffer, num); Main.player[(int)b30].itemRotation = itemRotation; Main.player[(int)b30].itemAnimation = itemAnimation; Main.player[(int)b30].channel = Main.player[(int)b30].inventory[Main.player[(int)b30].selectedItem].channel; if (Main.netMode == 2) { NetMessage.SendData(41, -1, this.whoAmI, "", (int)b30, 0f, 0f, 0f, 0); return; } } else if (b == 42) { int num95 = (int)this.readBuffer[num]; if (Main.netMode == 2) { num95 = this.whoAmI; } num++; int statMana = (int)BitConverter.ToInt16(this.readBuffer, num); num += 2; int statManaMax = (int)BitConverter.ToInt16(this.readBuffer, num); if (Main.netMode == 2) { num95 = this.whoAmI; } else if (Main.myPlayer == num95 && !Main.ServerSideCharacter) { return; } Main.player[num95].statMana = statMana; Main.player[num95].statManaMax = statManaMax; if (Main.netMode == 2) { NetMessage.SendData(42, -1, this.whoAmI, "", num95, 0f, 0f, 0f, 0); return; } } else if (b == 43) { int num96 = (int)this.readBuffer[num]; if (Main.netMode == 2) { num96 = this.whoAmI; } num++; int num97 = (int)BitConverter.ToInt16(this.readBuffer, num); num += 2; if (Main.netMode == 2) { NetMessage.SendData(43, -1, this.whoAmI, "", num96, (float)num97, 0f, 0f, 0); return; } } else if (b == 44) { byte b31 = this.readBuffer[num]; if ((int)b31 == Main.myPlayer) { return; } if (Main.netMode == 2) { b31 = (byte)this.whoAmI; } num++; int num98 = this.readBuffer[num] - 1; num++; short num99 = BitConverter.ToInt16(this.readBuffer, num); num += 2; byte b32 = this.readBuffer[num]; num++; string string6 = Encoding.UTF8.GetString(this.readBuffer, num, length - num + start); bool pvp2 = false; if (b32 != 0) { pvp2 = true; } Main.player[(int)b31].KillMe((double)num99, num98, pvp2, string6); if (Main.netMode == 2) { NetMessage.SendData(44, -1, this.whoAmI, string6, (int)b31, (float)num98, (float)num99, (float)b32, 0); return; } } else if (b == 45) { int num100 = (int)this.readBuffer[num]; if (Main.netMode == 2) { num100 = this.whoAmI; } num++; int num101 = (int)this.readBuffer[num]; num++; int team = Main.player[num100].team; Main.player[num100].team = num101; if (Main.netMode == 2) { NetMessage.SendData(45, -1, this.whoAmI, "", num100, 0f, 0f, 0f, 0); string str2 = ""; if (num101 == 0) { str2 = " " + Lang.mp[13]; } else if (num101 == 1) { str2 = " " + Lang.mp[14]; } else if (num101 == 2) { str2 = " " + Lang.mp[15]; } else if (num101 == 3) { str2 = " " + Lang.mp[16]; } else if (num101 == 4) { str2 = " " + Lang.mp[17]; } for (int num102 = 0; num102 < 255; num102++) { if (num102 == this.whoAmI || (team > 0 && Main.player[num102].team == team) || (num101 > 0 && Main.player[num102].team == num101)) { NetMessage.SendData(25, num102, -1, Main.player[num100].name + str2, 255, (float)Main.teamColor[num101].R, (float)Main.teamColor[num101].G, (float)Main.teamColor[num101].B, 0); } } return; } } else if (b == 46) { if (Main.netMode == 2) { int i2 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int j2 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int num103 = Sign.ReadSign(i2, j2); if (num103 >= 0) { NetMessage.SendData(47, this.whoAmI, -1, "", num103, 0f, 0f, 0f, 0); return; } } } else if (b == 47) { int num104 = (int)BitConverter.ToInt16(this.readBuffer, num); num += 2; int x9 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int y8 = BitConverter.ToInt32(this.readBuffer, num); num += 4; string string7 = Encoding.UTF8.GetString(this.readBuffer, num, length - num + start); Main.sign[num104] = new Sign(); Main.sign[num104].x = x9; Main.sign[num104].y = y8; Sign.TextSign(num104, string7); if (Main.netMode == 1 && Main.sign[num104] != null && num104 != Main.player[Main.myPlayer].sign) { Main.playerInventory = false; Main.player[Main.myPlayer].talkNPC = -1; Main.editSign = false; Main.PlaySound(10, -1, -1, 1); Main.player[Main.myPlayer].sign = num104; Main.npcChatText = Main.sign[num104].text; return; } } else { if (b == 48) { int num105 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int num106 = BitConverter.ToInt32(this.readBuffer, num); num += 4; byte liquid = this.readBuffer[num]; num++; byte liquidType2 = this.readBuffer[num]; num++; if (Main.netMode == 2 && Netplay.spamCheck) { int num107 = this.whoAmI; int num108 = (int)(Main.player[num107].position.X + (float)(Main.player[num107].width / 2)); int num109 = (int)(Main.player[num107].position.Y + (float)(Main.player[num107].height / 2)); int num110 = 10; int num111 = num108 - num110; int num112 = num108 + num110; int num113 = num109 - num110; int num114 = num109 + num110; if (num108 < num111 || num108 > num112 || num109 < num113 || num109 > num114) { NetMessage.BootPlayer(this.whoAmI, "Cheating attempt detected: Liquid spam"); return; } } if (Main.tile[num105, num106] == null) { Main.tile[num105, num106] = new Tile(); } lock (Main.tile[num105, num106]) { Main.tile[num105, num106].liquid = liquid; Main.tile[num105, num106].liquidType((int)liquidType2); if (Main.netMode == 2) { WorldGen.SquareTileFrame(num105, num106, true); } return; } } if (b == 49) { if (Netplay.clientSock.state == 6) { Netplay.clientSock.state = 10; Main.player[Main.myPlayer].Spawn(); return; } } else if (b == 50) { int num115 = (int)this.readBuffer[num]; num++; if (Main.netMode == 2) { num115 = this.whoAmI; } else if (num115 == Main.myPlayer && !Main.ServerSideCharacter) { return; } for (int num116 = 0; num116 < 22; num116++) { Main.player[num115].buffType[num116] = (int)this.readBuffer[num]; if (Main.player[num115].buffType[num116] > 0) { Main.player[num115].buffTime[num116] = 60; } else { Main.player[num115].buffTime[num116] = 0; } num++; } if (Main.netMode == 2) { NetMessage.SendData(50, -1, this.whoAmI, "", num115, 0f, 0f, 0f, 0); return; } } else if (b == 51) { byte b33 = this.readBuffer[num]; num++; byte b34 = this.readBuffer[num]; if (b34 == 1) { NPC.SpawnSkeletron(); return; } if (b34 == 2) { if (Main.netMode != 2) { Main.PlaySound(2, (int)Main.player[(int)b33].position.X, (int)Main.player[(int)b33].position.Y, 1); return; } if (Main.netMode == 2) { NetMessage.SendData(51, -1, this.whoAmI, "", (int)b33, (float)b34, 0f, 0f, 0); return; } } } else if (b == 52) { byte number2 = this.readBuffer[num]; num++; byte b35 = this.readBuffer[num]; num++; int num117 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int num118 = BitConverter.ToInt32(this.readBuffer, num); num += 4; if (b35 == 1) { Chest.Unlock(num117, num118); if (Main.netMode == 2) { NetMessage.SendData(52, -1, this.whoAmI, "", (int)number2, (float)b35, (float)num117, (float)num118, 0); NetMessage.SendTileSquare(-1, num117, num118, 2); } } if (b35 == 2) { WorldGen.UnlockDoor(num117, num118); if (Main.netMode == 2) { NetMessage.SendData(52, -1, this.whoAmI, "", (int)number2, (float)b35, (float)num117, (float)num118, 0); NetMessage.SendTileSquare(-1, num117, num118, 2); return; } } } else if (b == 53) { short num119 = BitConverter.ToInt16(this.readBuffer, num); num += 2; byte type4 = this.readBuffer[num]; num++; short time = BitConverter.ToInt16(this.readBuffer, num); num += 2; Main.npc[(int)num119].AddBuff((int)type4, (int)time, true); if (Main.netMode == 2) { NetMessage.SendData(54, -1, -1, "", (int)num119, 0f, 0f, 0f, 0); return; } } else if (b == 54) { if (Main.netMode == 1) { short num120 = BitConverter.ToInt16(this.readBuffer, num); num += 2; for (int num121 = 0; num121 < 5; num121++) { Main.npc[(int)num120].buffType[num121] = (int)this.readBuffer[num]; num++; Main.npc[(int)num120].buffTime[num121] = (int)BitConverter.ToInt16(this.readBuffer, num); num += 2; } return; } } else if (b == 55) { byte b36 = this.readBuffer[num]; num++; byte b37 = this.readBuffer[num]; num++; short num122 = BitConverter.ToInt16(this.readBuffer, num); num += 2; if (Main.netMode == 2 && (int)b36 != this.whoAmI && !Main.pvpBuff[(int)b37]) { return; } if (Main.netMode == 1 && (int)b36 == Main.myPlayer) { Main.player[(int)b36].AddBuff((int)b37, (int)num122, true); return; } if (Main.netMode == 2) { NetMessage.SendData(55, (int)b36, -1, "", (int)b36, (float)b37, (float)num122, 0f, 0); return; } } else if (b == 56) { if (Main.netMode == 1) { short num123 = BitConverter.ToInt16(this.readBuffer, num); if (num123 < 0 || num123 >= 200) { return; } num += 2; string string8 = Encoding.UTF8.GetString(this.readBuffer, num, length - num + start); Main.npc[(int)num123].displayName = string8; return; } else if (Main.netMode == 2) { short num124 = BitConverter.ToInt16(this.readBuffer, num); if (num124 < 0 || num124 >= 200) { return; } NetMessage.SendData(56, this.whoAmI, -1, Main.npc[(int)num124].displayName, (int)num124, 0f, 0f, 0f, 0); return; } } else if (b == 57) { if (Main.netMode == 1) { WorldGen.tGood = this.readBuffer[num]; num++; WorldGen.tEvil = this.readBuffer[num]; num++; WorldGen.tBlood = this.readBuffer[num]; return; } } else if (b == 58) { byte b38 = this.readBuffer[num]; if (Main.netMode == 2) { b38 = (byte)this.whoAmI; } num++; float num125 = BitConverter.ToSingle(this.readBuffer, num); num += 4; if (Main.netMode == 2) { NetMessage.SendData(58, -1, this.whoAmI, "", this.whoAmI, num125, 0f, 0f, 0); return; } Main.harpNote = num125; int style9 = 26; if (Main.player[(int)b38].inventory[Main.player[(int)b38].selectedItem].type == 507) { style9 = 35; } Main.PlaySound(2, (int)Main.player[(int)b38].position.X, (int)Main.player[(int)b38].position.Y, style9); return; } else if (b == 59) { int num126 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int num127 = BitConverter.ToInt32(this.readBuffer, num); num += 4; WorldGen.hitSwitch(num126, num127); if (Main.netMode == 2) { NetMessage.SendData(59, -1, this.whoAmI, "", num126, (float)num127, 0f, 0f, 0); return; } } else if (b == 60) { short num128 = BitConverter.ToInt16(this.readBuffer, num); num += 2; short num129 = BitConverter.ToInt16(this.readBuffer, num); num += 2; short num130 = BitConverter.ToInt16(this.readBuffer, num); num += 2; byte b39 = this.readBuffer[num]; num++; if (num128 >= 200) { NetMessage.BootPlayer(this.whoAmI, "Cheating attempt detected: Invalid kick-out"); return; } bool homeless = false; if (b39 == 1) { homeless = true; } if (Main.netMode == 1) { Main.npc[(int)num128].homeless = homeless; Main.npc[(int)num128].homeTileX = (int)num129; Main.npc[(int)num128].homeTileY = (int)num130; return; } if (b39 == 0) { WorldGen.kickOut((int)num128); return; } WorldGen.moveRoom((int)num129, (int)num130, (int)num128); return; } else if (b == 61) { int plr = BitConverter.ToInt32(this.readBuffer, num); num += 4; int num131 = BitConverter.ToInt32(this.readBuffer, num); num += 4; if (Main.netMode == 2) { if (num131 == 4 || num131 == 13 || num131 == 50 || num131 == 125 || num131 == 126 || num131 == 134 || num131 == 127 || num131 == 128 || num131 == 222 || num131 == 245 || num131 == 266) { bool flag10 = true; for (int num132 = 0; num132 < 200; num132++) { if (Main.npc[num132].active && Main.npc[num132].type == num131) { flag10 = false; } } if (flag10) { NPC.SpawnOnPlayer(plr, num131); return; } } else if (num131 == -4) { if (!Main.dayTime) { NetMessage.SendData(25, -1, -1, Lang.misc[31], 255, 50f, 255f, 130f, 0); Main.startPumpkinMoon(); NetMessage.SendData(7, -1, -1, "", 0, 0f, 0f, 0f, 0); return; } } else if (num131 == -5) { if (!Main.dayTime) { NetMessage.SendData(25, -1, -1, Lang.misc[34], 255, 50f, 255f, 130f, 0); Main.startSnowMoon(); NetMessage.SendData(7, -1, -1, "", 0, 0f, 0f, 0f, 0); return; } } else if (num131 < 0) { int num133 = -1; if (num131 == -1) { num133 = 1; } if (num131 == -2) { num133 = 2; } if (num131 == -3) { num133 = 3; } if (num133 > 0 && Main.invasionType == 0) { Main.invasionDelay = 0; Main.StartInvasion(num133); return; } } } } else if (b == 62) { int num134 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int num135 = BitConverter.ToInt32(this.readBuffer, num); num += 4; if (Main.netMode == 2) { num134 = this.whoAmI; } if (num135 == 1) { Main.player[num134].NinjaDodge(); } if (num135 == 2) { Main.player[num134].ShadowDodge(); } if (Main.netMode == 2) { NetMessage.SendData(62, -1, this.whoAmI, "", num134, (float)num135, 0f, 0f, 0); return; } } else if (b == 63) { int num136 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int num137 = BitConverter.ToInt32(this.readBuffer, num); num += 4; byte b40 = this.readBuffer[num]; WorldGen.paintTile(num136, num137, b40, false); if (Main.netMode == 2) { NetMessage.SendData(63, -1, this.whoAmI, "", num136, (float)num137, (float)b40, 0f, 0); return; } } else if (b == 64) { int num138 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int num139 = BitConverter.ToInt32(this.readBuffer, num); num += 4; byte b41 = this.readBuffer[num]; WorldGen.paintWall(num138, num139, b41, false); if (Main.netMode == 2) { NetMessage.SendData(64, -1, this.whoAmI, "", num138, (float)num139, (float)b41, 0f, 0); return; } } else if (b == 65) { byte b42 = this.readBuffer[num]; num++; short num140 = BitConverter.ToInt16(this.readBuffer, num); if (Main.netMode == 2) { num140 = (short)this.whoAmI; } num += 2; Vector2 newPos; newPos.X = BitConverter.ToSingle(this.readBuffer, num); num += 4; newPos.Y = BitConverter.ToSingle(this.readBuffer, num); num += 4; int num141 = 0; int num142 = 0; if ((b42 & 1) == 1) { num141++; } if ((b42 & 2) == 2) { num141 += 2; } if ((b42 & 4) == 4) { num142++; } if ((b42 & 8) == 8) { num142++; } if (num141 == 0) { Main.player[(int)num140].Teleport(newPos, num142); } else if (num141 == 1) { Main.npc[(int)num140].Teleport(newPos, num142); } if (Main.netMode == 2 && num141 == 0) { NetMessage.SendData(65, -1, this.whoAmI, "", 0, (float)num140, newPos.X, newPos.Y, num142); return; } } else if (b == 66) { int num143 = (int)this.readBuffer[num]; num++; int num144 = (int)BitConverter.ToInt16(this.readBuffer, num); num += 2; if (num144 > 0) { Main.player[num143].statLife += num144; if (Main.player[num143].statLife > Main.player[num143].statLifeMax) { Main.player[num143].statLife = Main.player[num143].statLifeMax; } if (Main.netMode == 2) { NetMessage.SendData(66, -1, this.whoAmI, "", num143, (float)num144, 0f, 0f, 0); return; } } } else { if (b == 67) { return; } if (b == 68) { Encoding.UTF8.GetString(this.readBuffer, start + 1, length - 1); return; } if (b == 69) { short num145 = BitConverter.ToInt16(this.readBuffer, num); num += 2; short num146 = BitConverter.ToInt16(this.readBuffer, num); num += 2; short num147 = BitConverter.ToInt16(this.readBuffer, num); num += 2; if (Main.netMode == 1) { if (num145 < 0 || num145 >= 1000) { return; } Chest chest3 = Main.chest[(int)num145]; if (chest3 == null) { chest3 = new Chest(false); chest3.x = (int)num146; chest3.y = (int)num147; Main.chest[(int)num145] = chest3; } else if (chest3.x != (int)num146 || chest3.y != (int)num147) { return; } byte count = this.readBuffer[num]; num++; string string9 = Encoding.UTF8.GetString(this.readBuffer, num, (int)count); chest3.name = string9; return; } else { if (num145 < -1 || num145 >= 1000) { return; } if (num145 == -1) { num145 = (short)Chest.FindChest((int)num146, (int)num147); if (num145 == -1) { return; } } Chest chest4 = Main.chest[(int)num145]; if (chest4.x != (int)num146 || chest4.y != (int)num147) { return; } NetMessage.SendData(69, this.whoAmI, -1, chest4.name, (int)num145, (float)num146, (float)num147, 0f, 0); return; } } else if (b == 70) { if (Main.netMode == 2) { int i3 = (int)BitConverter.ToInt16(this.readBuffer, num); NPC.CatchNPC(i3, -1); return; } } else if (b == 71) { if (Main.netMode == 2) { int x10 = BitConverter.ToInt32(this.readBuffer, num); num += 4; int y9 = BitConverter.ToInt32(this.readBuffer, num); num += 4; short type5 = BitConverter.ToInt16(this.readBuffer, num); num += 2; byte style10 = this.readBuffer[num]; num++; NPC.ReleaseNPC(x10, y9, (int)type5, (int)style10, this.whoAmI); return; } } else if (b == 72 && Main.netMode == 1) { for (int num148 = 0; num148 < Chest.maxItems; num148++) { Main.travelShop[num148] = (int)BitConverter.ToInt16(this.readBuffer, num); num += 2; } } } } } } } } } }
public void GetData(int start, int length, out int messageType) { if (this.whoAmI < 256) { Netplay.Clients[this.whoAmI].TimeOutTimer = 0; } else { Netplay.Connection.TimeOutTimer = 0; } int num = start + 1; byte b = this.readBuffer[start]; messageType = (int)b; if (b >= 105) { return; } Main.rxMsg++; Main.rxData += length; Main.rxMsgType[(int)b]++; Main.rxDataType[(int)b] += length; if (Main.netMode == 1 && Netplay.Connection.StatusMax > 0) { Netplay.Connection.StatusCount++; } if (Main.verboseNetplay) { for (int i = start; i < start + length; i++) { } for (int j = start; j < start + length; j++) { byte arg_D6_0 = this.readBuffer[j]; } } if (Main.netMode == 2 && b != 38 && Netplay.Clients[this.whoAmI].State == -1) { NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[1], 0, 0f, 0f, 0f, 0, 0, 0); return; } if (Main.netMode == 2 && Netplay.Clients[this.whoAmI].State < 10 && b > 12 && b != 93 && b != 16 && b != 42 && b != 50 && b != 38 && b != 68) { NetMessage.BootPlayer(this.whoAmI, Lang.mp[2]); } if (this.reader == null) { this.ResetReader(); } this.reader.BaseStream.Position = (long)num; switch (b) { case 1: { if (Main.netMode != 2) { return; } if (Main.dedServ && Netplay.IsBanned(Netplay.Clients[this.whoAmI].Socket.GetRemoteAddress())) { NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[3], 0, 0f, 0f, 0f, 0, 0, 0); return; } if (Netplay.Clients[this.whoAmI].State != 0) { return; } string a = this.reader.ReadString(); if (!(a == "Terraria" + Main.curRelease)) { NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[4], 0, 0f, 0f, 0f, 0, 0, 0); return; } if (string.IsNullOrEmpty(Netplay.ServerPassword)) { Netplay.Clients[this.whoAmI].State = 1; NetMessage.SendData(3, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); return; } Netplay.Clients[this.whoAmI].State = -1; NetMessage.SendData(37, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); return; } case 2: if (Main.netMode != 1) { return; } Netplay.disconnect = true; Main.statusText = this.reader.ReadString(); return; case 3: { if (Main.netMode != 1) { return; } if (Netplay.Connection.State == 1) { Netplay.Connection.State = 2; } int num2 = (int)this.reader.ReadByte(); if (num2 != Main.myPlayer) { Main.player[num2] = Main.ActivePlayerFileData.Player; Main.player[Main.myPlayer] = new Player(); } Main.player[num2].whoAmI = num2; Main.myPlayer = num2; Player player = Main.player[num2]; NetMessage.SendData(4, -1, -1, player.name, num2, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(68, -1, -1, "", num2, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(16, -1, -1, "", num2, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(42, -1, -1, "", num2, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(50, -1, -1, "", num2, 0f, 0f, 0f, 0, 0, 0); for (int k = 0; k < 59; k++) { NetMessage.SendData(5, -1, -1, player.inventory[k].name, num2, (float)k, (float)player.inventory[k].prefix, 0f, 0, 0, 0); } for (int l = 0; l < player.armor.Length; l++) { NetMessage.SendData(5, -1, -1, player.armor[l].name, num2, (float)(59 + l), (float)player.armor[l].prefix, 0f, 0, 0, 0); } for (int m = 0; m < player.dye.Length; m++) { NetMessage.SendData(5, -1, -1, player.dye[m].name, num2, (float)(58 + player.armor.Length + 1 + m), (float)player.dye[m].prefix, 0f, 0, 0, 0); } for (int n = 0; n < player.miscEquips.Length; n++) { NetMessage.SendData(5, -1, -1, "", num2, (float)(58 + player.armor.Length + player.dye.Length + 1 + n), (float)player.miscEquips[n].prefix, 0f, 0, 0, 0); } for (int num3 = 0; num3 < player.miscDyes.Length; num3++) { NetMessage.SendData(5, -1, -1, "", num2, (float)(58 + player.armor.Length + player.dye.Length + player.miscEquips.Length + 1 + num3), (float)player.miscDyes[num3].prefix, 0f, 0, 0, 0); } for (int num4 = 0; num4 < player.bank.item.Length; num4++) { NetMessage.SendData(5, -1, -1, "", num2, (float)(58 + player.armor.Length + player.dye.Length + player.miscEquips.Length + player.miscDyes.Length + 1 + num4), (float)player.bank.item[num4].prefix, 0f, 0, 0, 0); } for (int num5 = 0; num5 < player.bank2.item.Length; num5++) { NetMessage.SendData(5, -1, -1, "", num2, (float)(58 + player.armor.Length + player.dye.Length + player.miscEquips.Length + player.miscDyes.Length + player.bank.item.Length + 1 + num5), (float)player.bank2.item[num5].prefix, 0f, 0, 0, 0); } NetMessage.SendData(5, -1, -1, "", num2, (float)(58 + player.armor.Length + player.dye.Length + player.miscEquips.Length + player.miscDyes.Length + player.bank.item.Length + player.bank2.item.Length + 1), (float)player.trashItem.prefix, 0f, 0, 0, 0); NetMessage.SendData(6, -1, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); if (Netplay.Connection.State == 2) { Netplay.Connection.State = 3; return; } return; } case 4: { int num6 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num6 = this.whoAmI; } if (num6 == Main.myPlayer && !Main.ServerSideCharacter) { return; } Player player2 = Main.player[num6]; player2.whoAmI = num6; player2.skinVariant = (int)this.reader.ReadByte(); player2.skinVariant = (int)MathHelper.Clamp((float)player2.skinVariant, 0f, 7f); player2.hair = (int)this.reader.ReadByte(); if (player2.hair >= 134) { player2.hair = 0; } player2.name = this.reader.ReadString().Trim().Trim(); player2.hairDye = this.reader.ReadByte(); BitsByte bitsByte = this.reader.ReadByte(); for (int num7 = 0; num7 < 8; num7++) { player2.hideVisual[num7] = bitsByte[num7]; } bitsByte = this.reader.ReadByte(); for (int num8 = 0; num8 < 2; num8++) { player2.hideVisual[num8 + 8] = bitsByte[num8]; } player2.hideMisc = this.reader.ReadByte(); player2.hairColor = this.reader.ReadRGB(); player2.skinColor = this.reader.ReadRGB(); player2.eyeColor = this.reader.ReadRGB(); player2.shirtColor = this.reader.ReadRGB(); player2.underShirtColor = this.reader.ReadRGB(); player2.pantsColor = this.reader.ReadRGB(); player2.shoeColor = this.reader.ReadRGB(); BitsByte bitsByte2 = this.reader.ReadByte(); player2.difficulty = 0; if (bitsByte2[0]) { Player expr_B18 = player2; expr_B18.difficulty += 1; } if (bitsByte2[1]) { Player expr_B32 = player2; expr_B32.difficulty += 2; } if (player2.difficulty > 2) { player2.difficulty = 2; } player2.extraAccessory = bitsByte2[2]; if (Main.netMode != 2) { return; } bool flag = false; if (Netplay.Clients[this.whoAmI].State < 10) { for (int num9 = 0; num9 < 255; num9++) { if (num9 != num6 && player2.name == Main.player[num9].name && Netplay.Clients[num9].IsActive) { flag = true; } } } if (flag) { NetMessage.SendData(2, this.whoAmI, -1, player2.name + " " + Lang.mp[5], 0, 0f, 0f, 0f, 0, 0, 0); return; } if (player2.name.Length > Player.nameLen) { NetMessage.SendData(2, this.whoAmI, -1, "Name is too long.", 0, 0f, 0f, 0f, 0, 0, 0); return; } if (player2.name == "") { NetMessage.SendData(2, this.whoAmI, -1, "Empty name.", 0, 0f, 0f, 0f, 0, 0, 0); return; } Netplay.Clients[this.whoAmI].Name = player2.name; Netplay.Clients[this.whoAmI].Name = player2.name; NetMessage.SendData(4, -1, this.whoAmI, player2.name, num6, 0f, 0f, 0f, 0, 0, 0); return; } case 5: { int num10 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num10 = this.whoAmI; } if (num10 == Main.myPlayer && !Main.ServerSideCharacter && !Main.player[num10].IsStackingItems()) { return; } Player player3 = Main.player[num10]; lock (player3) { int num11 = (int)this.reader.ReadByte(); int stack = (int)this.reader.ReadInt16(); int num12 = (int)this.reader.ReadByte(); int type = (int)this.reader.ReadInt16(); Item[] array = null; int num13 = 0; bool flag3 = false; if (num11 > 58 + player3.armor.Length + player3.dye.Length + player3.miscEquips.Length + player3.miscDyes.Length + player3.bank.item.Length + player3.bank2.item.Length) { flag3 = true; } else if (num11 > 58 + player3.armor.Length + player3.dye.Length + player3.miscEquips.Length + player3.miscDyes.Length + player3.bank.item.Length) { num13 = num11 - 58 - (player3.armor.Length + player3.dye.Length + player3.miscEquips.Length + player3.miscDyes.Length + player3.bank.item.Length) - 1; array = player3.bank2.item; } else if (num11 > 58 + player3.armor.Length + player3.dye.Length + player3.miscEquips.Length + player3.miscDyes.Length) { num13 = num11 - 58 - (player3.armor.Length + player3.dye.Length + player3.miscEquips.Length + player3.miscDyes.Length) - 1; array = player3.bank.item; } else if (num11 > 58 + player3.armor.Length + player3.dye.Length + player3.miscEquips.Length) { num13 = num11 - 58 - (player3.armor.Length + player3.dye.Length + player3.miscEquips.Length) - 1; array = player3.miscDyes; } else if (num11 > 58 + player3.armor.Length + player3.dye.Length) { num13 = num11 - 58 - (player3.armor.Length + player3.dye.Length) - 1; array = player3.miscEquips; } else if (num11 > 58 + player3.armor.Length) { num13 = num11 - 58 - player3.armor.Length - 1; array = player3.dye; } else if (num11 > 58) { num13 = num11 - 58 - 1; array = player3.armor; } else { num13 = num11; array = player3.inventory; } if (flag3) { player3.trashItem = new Item(); player3.trashItem.netDefaults(type); player3.trashItem.stack = stack; player3.trashItem.Prefix(num12); } else if (num11 <= 58) { int type2 = array[num13].type; int stack2 = array[num13].stack; array[num13] = new Item(); array[num13].netDefaults(type); array[num13].stack = stack; array[num13].Prefix(num12); if (num10 == Main.myPlayer && num13 == 58) { Main.mouseItem = array[num13].Clone(); } if (num10 == Main.myPlayer && Main.netMode == 1) { Main.player[num10].inventoryChestStack[num11] = false; if (array[num13].stack != stack2 || array[num13].type != type2) { Recipe.FindRecipes(); Main.PlaySound(7, -1, -1, 1); } } } else { array[num13] = new Item(); array[num13].netDefaults(type); array[num13].stack = stack; array[num13].Prefix(num12); } if (Main.netMode == 2 && num10 == this.whoAmI && num11 <= 58 + player3.armor.Length + player3.dye.Length + player3.miscEquips.Length + player3.miscDyes.Length) { NetMessage.SendData(5, -1, this.whoAmI, "", num10, (float)num11, (float)num12, 0f, 0, 0, 0); } return; } break; } case 6: break; case 7: { if (Main.netMode != 1) { return; } try { Main.time = (double)this.reader.ReadInt32(); BitsByte bitsByte3 = this.reader.ReadByte(); Main.dayTime = bitsByte3[0]; Main.bloodMoon = bitsByte3[1]; Main.eclipse = bitsByte3[2]; Main.moonPhase = (int)this.reader.ReadByte(); Main.maxTilesX = (int)this.reader.ReadInt16(); Main.maxTilesY = (int)this.reader.ReadInt16(); Main.spawnTileX = (int)this.reader.ReadInt16(); Main.spawnTileY = (int)this.reader.ReadInt16(); Main.worldSurface = (double)this.reader.ReadInt16(); Main.rockLayer = (double)this.reader.ReadInt16(); Main.worldID = this.reader.ReadInt32(); Main.worldName = this.reader.ReadString(); Main.moonType = (int)this.reader.ReadByte(); WorldGen.setBG(0, (int)this.reader.ReadByte()); WorldGen.setBG(1, (int)this.reader.ReadByte()); WorldGen.setBG(2, (int)this.reader.ReadByte()); WorldGen.setBG(3, (int)this.reader.ReadByte()); WorldGen.setBG(4, (int)this.reader.ReadByte()); WorldGen.setBG(5, (int)this.reader.ReadByte()); WorldGen.setBG(6, (int)this.reader.ReadByte()); WorldGen.setBG(7, (int)this.reader.ReadByte()); Main.iceBackStyle = (int)this.reader.ReadByte(); Main.jungleBackStyle = (int)this.reader.ReadByte(); Main.hellBackStyle = (int)this.reader.ReadByte(); Main.windSpeedSet = this.reader.ReadSingle(); Main.numClouds = (int)this.reader.ReadByte(); for (int num14 = 0; num14 < 3; num14++) { Main.treeX[num14] = this.reader.ReadInt32(); } for (int num15 = 0; num15 < 4; num15++) { Main.treeStyle[num15] = (int)this.reader.ReadByte(); } for (int num16 = 0; num16 < 3; num16++) { Main.caveBackX[num16] = this.reader.ReadInt32(); } for (int num17 = 0; num17 < 4; num17++) { Main.caveBackStyle[num17] = (int)this.reader.ReadByte(); } Main.maxRaining = this.reader.ReadSingle(); Main.raining = (Main.maxRaining > 0f); BitsByte bitsByte4 = this.reader.ReadByte(); WorldGen.shadowOrbSmashed = bitsByte4[0]; NPC.downedBoss1 = bitsByte4[1]; NPC.downedBoss2 = bitsByte4[2]; NPC.downedBoss3 = bitsByte4[3]; Main.hardMode = bitsByte4[4]; NPC.downedClown = bitsByte4[5]; Main.ServerSideCharacter = bitsByte4[6]; NPC.downedPlantBoss = bitsByte4[7]; BitsByte bitsByte5 = this.reader.ReadByte(); NPC.downedMechBoss1 = bitsByte5[0]; NPC.downedMechBoss2 = bitsByte5[1]; NPC.downedMechBoss3 = bitsByte5[2]; // NPC.downedMechBoss4 = bitsByte5[3]; NPC.downedMechBossAny = bitsByte5[4]; Main.cloudBGActive = (float)(bitsByte5[5] ? 1 : 0); WorldGen.crimson = bitsByte5[6]; Main.pumpkinMoon = bitsByte5[7]; BitsByte bitsByte6 = this.reader.ReadByte(); Main.snowMoon = bitsByte6[0]; Main.expertMode = bitsByte6[1]; Main.fastForwardTime = bitsByte6[2]; Main.UpdateSundial(); bool flag4 = bitsByte6[3]; NPC.downedSlimeKing = bitsByte6[4]; NPC.downedQueenBee = bitsByte6[5]; NPC.downedFishron = bitsByte6[6]; NPC.downedMartians = bitsByte6[7]; BitsByte bitsByte7 = this.reader.ReadByte(); NPC.downedAncientCultist = bitsByte7[0]; NPC.downedMoonlord = bitsByte7[1]; NPC.downedHalloweenKing = bitsByte7[2]; NPC.downedHalloweenTree = bitsByte7[3]; NPC.downedChristmasIceQueen = bitsByte7[4]; NPC.downedChristmasSantank = bitsByte7[5]; NPC.downedChristmasTree = bitsByte7[6]; NPC.downedGolemBoss = bitsByte7[7]; // if (flag4) { Main.StartSlimeRain(true); } else { Main.StopSlimeRain(true); } Main.invasionType = (int)this.reader.ReadSByte(); Main.LobbyId = this.reader.ReadUInt64(); if (Netplay.Connection.State == 3) { Netplay.Connection.State = 4; return; } return; } catch (Exception e) { MessageBox.Show(e.ToString()); return; } } case 8: { if (Main.netMode != 2) { return; } int num18 = this.reader.ReadInt32(); int num19 = this.reader.ReadInt32(); bool flag5 = true; if (num18 == -1 || num19 == -1) { flag5 = false; } else if (num18 < 10 || num18 > Main.maxTilesX - 10) { flag5 = false; } else if (num19 < 10 || num19 > Main.maxTilesY - 10) { flag5 = false; } int num20 = Netplay.GetSectionX(Main.spawnTileX) - 2; int num21 = Netplay.GetSectionY(Main.spawnTileY) - 1; int num22 = num20 + 5; int num23 = num21 + 3; if (num20 < 0) { num20 = 0; } if (num22 >= Main.maxSectionsX) { num22 = Main.maxSectionsX - 1; } if (num21 < 0) { num21 = 0; } if (num23 >= Main.maxSectionsY) { num23 = Main.maxSectionsY - 1; } int num24 = (num22 - num20) * (num23 - num21); List<Point> list = new List<Point>(); for (int num25 = num20; num25 < num22; num25++) { for (int num26 = num21; num26 < num23; num26++) { list.Add(new Point(num25, num26)); } } int num27 = -1; int num28 = -1; if (flag5) { num18 = Netplay.GetSectionX(num18) - 2; num19 = Netplay.GetSectionY(num19) - 1; num27 = num18 + 5; num28 = num19 + 3; if (num18 < 0) { num18 = 0; } if (num27 >= Main.maxSectionsX) { num27 = Main.maxSectionsX - 1; } if (num19 < 0) { num19 = 0; } if (num28 >= Main.maxSectionsY) { num28 = Main.maxSectionsY - 1; } for (int num29 = num18; num29 < num27; num29++) { for (int num30 = num19; num30 < num28; num30++) { if (num29 < num20 || num29 >= num22 || num30 < num21 || num30 >= num23) { list.Add(new Point(num29, num30)); num24++; } } } } int num31 = 1; List<Point> list2; List<Point> list3; PortalHelper.SyncPortalsOnPlayerJoin(this.whoAmI, 1, list, out list2, out list3); num24 += list2.Count; if (Netplay.Clients[this.whoAmI].State == 2) { Netplay.Clients[this.whoAmI].State = 3; } NetMessage.SendData(9, this.whoAmI, -1, Lang.inter[44], num24, 0f, 0f, 0f, 0, 0, 0); Netplay.Clients[this.whoAmI].StatusText2 = "is receiving tile data"; Netplay.Clients[this.whoAmI].StatusMax += num24; for (int num32 = num20; num32 < num22; num32++) { for (int num33 = num21; num33 < num23; num33++) { NetMessage.SendSection(this.whoAmI, num32, num33, false); } } NetMessage.SendData(11, this.whoAmI, -1, "", num20, (float)num21, (float)(num22 - 1), (float)(num23 - 1), 0, 0, 0); if (flag5) { for (int num34 = num18; num34 < num27; num34++) { for (int num35 = num19; num35 < num28; num35++) { NetMessage.SendSection(this.whoAmI, num34, num35, true); } } NetMessage.SendData(11, this.whoAmI, -1, "", num18, (float)num19, (float)(num27 - 1), (float)(num28 - 1), 0, 0, 0); } for (int num36 = 0; num36 < list2.Count; num36++) { NetMessage.SendSection(this.whoAmI, list2[num36].X, list2[num36].Y, true); } for (int num37 = 0; num37 < list3.Count; num37++) { NetMessage.SendData(11, this.whoAmI, -1, "", list3[num37].X - num31, (float)(list3[num37].Y - num31), (float)(list3[num37].X + num31 + 1), (float)(list3[num37].Y + num31 + 1), 0, 0, 0); } for (int num38 = 0; num38 < 400; num38++) { if (Main.item[num38].active) { NetMessage.SendData(21, this.whoAmI, -1, "", num38, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(22, this.whoAmI, -1, "", num38, 0f, 0f, 0f, 0, 0, 0); } } for (int num39 = 0; num39 < 200; num39++) { if (Main.npc[num39].active) { NetMessage.SendData(23, this.whoAmI, -1, "", num39, 0f, 0f, 0f, 0, 0, 0); } } for (int num40 = 0; num40 < 1000; num40++) { if (Main.projectile[num40].active && (Main.projPet[Main.projectile[num40].type] || Main.projectile[num40].netImportant)) { NetMessage.SendData(27, this.whoAmI, -1, "", num40, 0f, 0f, 0f, 0, 0, 0); } } for (int num41 = 0; num41 < 251; num41++) { NetMessage.SendData(83, this.whoAmI, -1, "", num41, 0f, 0f, 0f, 0, 0, 0); } NetMessage.SendData(49, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(57, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(7, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(103, -1, -1, "", NPC.MoonLordCountdown, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(101, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); return; } case 9: if (Main.netMode != 1) { return; } Netplay.Connection.StatusMax += this.reader.ReadInt32(); Netplay.Connection.StatusText = this.reader.ReadString(); return; case 10: if (Main.netMode != 1) { return; } NetMessage.DecompressTileBlock(this.readBuffer, num, length); return; case 11: if (Main.netMode != 1) { return; } WorldGen.SectionTileFrame((int)this.reader.ReadInt16(), (int)this.reader.ReadInt16(), (int)this.reader.ReadInt16(), (int)this.reader.ReadInt16()); return; case 12: { int num42 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num42 = this.whoAmI; } Player player4 = Main.player[num42]; player4.SpawnX = (int)this.reader.ReadInt16(); player4.SpawnY = (int)this.reader.ReadInt16(); player4.Spawn(); if (num42 == Main.myPlayer && Main.netMode != 2) { Main.ActivePlayerFileData.StartPlayTimer(); Player.EnterWorld(Main.player[Main.myPlayer]); } if (Main.netMode != 2 || Netplay.Clients[this.whoAmI].State < 3) { return; } if (Netplay.Clients[this.whoAmI].State == 3) { Netplay.Clients[this.whoAmI].State = 10; NetMessage.greetPlayer(this.whoAmI); NetMessage.buffer[this.whoAmI].broadcast = true; NetMessage.syncPlayers(); NetMessage.SendData(12, -1, this.whoAmI, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(74, this.whoAmI, -1, Main.player[this.whoAmI].name, Main.anglerQuest, 0f, 0f, 0f, 0, 0, 0); return; } NetMessage.SendData(12, -1, this.whoAmI, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0); return; } case 13: { int num43 = (int)this.reader.ReadByte(); if (num43 == Main.myPlayer && !Main.ServerSideCharacter) { return; } if (Main.netMode == 2) { num43 = this.whoAmI; } Player player5 = Main.player[num43]; BitsByte bitsByte8 = this.reader.ReadByte(); player5.controlUp = bitsByte8[0]; player5.controlDown = bitsByte8[1]; player5.controlLeft = bitsByte8[2]; player5.controlRight = bitsByte8[3]; player5.controlJump = bitsByte8[4]; player5.controlUseItem = bitsByte8[5]; player5.direction = (bitsByte8[6] ? 1 : -1); BitsByte bitsByte9 = this.reader.ReadByte(); if (bitsByte9[0]) { player5.pulley = true; player5.pulleyDir = (byte)(bitsByte9[1] ? 2 : 1); } else { player5.pulley = false; } player5.selectedItem = (int)this.reader.ReadByte(); player5.position = this.reader.ReadVector2(); if (bitsByte9[2]) { player5.velocity = this.reader.ReadVector2(); } else { player5.velocity = Vector2.Zero; } player5.vortexStealthActive = bitsByte9[3]; player5.gravDir = (float)(bitsByte9[4] ? 1 : -1); if (Main.netMode == 2 && Netplay.Clients[this.whoAmI].State == 10) { NetMessage.SendData(13, -1, this.whoAmI, "", num43, 0f, 0f, 0f, 0, 0, 0); return; } return; } case 14: { if (Main.netMode != 1) { return; } int num44 = (int)this.reader.ReadByte(); int num45 = (int)this.reader.ReadByte(); if (num45 == 1) { if (!Main.player[num44].active) { Main.player[num44] = new Player(); } Main.player[num44].active = true; return; } Main.player[num44].active = false; return; } case 15: case 67: case 93: case 94: return; case 16: { int num46 = (int)this.reader.ReadByte(); if (num46 == Main.myPlayer && !Main.ServerSideCharacter) { return; } if (Main.netMode == 2) { num46 = this.whoAmI; } Player player6 = Main.player[num46]; player6.statLife = (int)this.reader.ReadInt16(); player6.statLifeMax = (int)this.reader.ReadInt16(); if (player6.statLifeMax < 100) { player6.statLifeMax = 100; } player6.dead = (player6.statLife <= 0); if (Main.netMode == 2) { NetMessage.SendData(16, -1, this.whoAmI, "", num46, 0f, 0f, 0f, 0, 0, 0); return; } return; } case 17: { byte b2 = this.reader.ReadByte(); int num47 = (int)this.reader.ReadInt16(); int num48 = (int)this.reader.ReadInt16(); short num49 = this.reader.ReadInt16(); int num50 = (int)this.reader.ReadByte(); bool flag6 = num49 == 1; if (!WorldGen.InWorld(num47, num48, 3)) { return; } if (Main.tile[num47, num48] == null) { Main.tile[num47, num48] = new Tile(); } if (Main.netMode == 2) { if (!flag6) { if (b2 == 0 || b2 == 2 || b2 == 4) { Netplay.Clients[this.whoAmI].SpamDeleteBlock += 1f; } if (b2 == 1 || b2 == 3) { Netplay.Clients[this.whoAmI].SpamAddBlock += 1f; } } if (!Netplay.Clients[this.whoAmI].TileSections[Netplay.GetSectionX(num47), Netplay.GetSectionY(num48)]) { flag6 = true; } } if (b2 == 0) { WorldGen.KillTile(num47, num48, flag6, false, false); } if (b2 == 1) { WorldGen.PlaceTile(num47, num48, (int)num49, false, true, -1, num50); } if (b2 == 2) { WorldGen.KillWall(num47, num48, flag6); } if (b2 == 3) { WorldGen.PlaceWall(num47, num48, (int)num49, false); } if (b2 == 4) { WorldGen.KillTile(num47, num48, flag6, false, true); } if (b2 == 5) { WorldGen.PlaceWire(num47, num48); } if (b2 == 6) { WorldGen.KillWire(num47, num48); } if (b2 == 7) { WorldGen.PoundTile(num47, num48); } if (b2 == 8) { WorldGen.PlaceActuator(num47, num48); } if (b2 == 9) { WorldGen.KillActuator(num47, num48); } if (b2 == 10) { WorldGen.PlaceWire2(num47, num48); } if (b2 == 11) { WorldGen.KillWire2(num47, num48); } if (b2 == 12) { WorldGen.PlaceWire3(num47, num48); } if (b2 == 13) { WorldGen.KillWire3(num47, num48); } if (b2 == 14) { WorldGen.SlopeTile(num47, num48, (int)num49); } if (b2 == 15) { Minecart.FrameTrack(num47, num48, true, false); } if (Main.netMode != 2) { return; } NetMessage.SendData(17, -1, this.whoAmI, "", (int)b2, (float)num47, (float)num48, (float)num49, num50, 0, 0); if (b2 == 1 && num49 == 53) { NetMessage.SendTileSquare(-1, num47, num48, 1); return; } return; } case 18: if (Main.netMode != 1) { return; } Main.dayTime = (this.reader.ReadByte() == 1); Main.time = (double)this.reader.ReadInt32(); Main.sunModY = this.reader.ReadInt16(); Main.moonModY = this.reader.ReadInt16(); return; case 19: { byte b3 = this.reader.ReadByte(); int num51 = (int)this.reader.ReadInt16(); int num52 = (int)this.reader.ReadInt16(); if (!WorldGen.InWorld(num51, num52, 3)) { return; } int num53 = (this.reader.ReadByte() == 0) ? -1 : 1; if (b3 == 0) { WorldGen.OpenDoor(num51, num52, num53); } else if (b3 == 1) { WorldGen.CloseDoor(num51, num52, true); } else if (b3 == 2) { WorldGen.ShiftTrapdoor(num51, num52, num53 == 1, 1); } else if (b3 == 3) { WorldGen.ShiftTrapdoor(num51, num52, num53 == 1, 0); } else if (b3 == 4) { WorldGen.ShiftTallGate(num51, num52, false); } else if (b3 == 5) { WorldGen.ShiftTallGate(num51, num52, true); } if (Main.netMode == 2) { NetMessage.SendData(19, -1, this.whoAmI, "", (int)b3, (float)num51, (float)num52, (float)((num53 == 1) ? 1 : 0), 0, 0, 0); return; } return; } case 20: { short num54 = this.reader.ReadInt16(); int num55 = (int)this.reader.ReadInt16(); int num56 = (int)this.reader.ReadInt16(); if (!WorldGen.InWorld(num55, num56, 3)) { return; } BitsByte bitsByte10 = 0; BitsByte bitsByte11 = 0; for (int num57 = num55; num57 < num55 + (int)num54; num57++) { for (int num58 = num56; num58 < num56 + (int)num54; num58++) { if (Main.tile[num57, num58] == null) { Main.tile[num57, num58] = new Tile(); } Tile tile = Main.tile[num57, num58]; bool flag7 = tile.active(); bitsByte10 = this.reader.ReadByte(); bitsByte11 = this.reader.ReadByte(); tile.active(bitsByte10[0]); tile.wall = (byte)(bitsByte10[2] ? 1 : 0); bool flag8 = bitsByte10[3]; if (Main.netMode != 2) { tile.liquid = (byte)(flag8 ? 1 : 0); } tile.wire(bitsByte10[4]); tile.halfBrick(bitsByte10[5]); tile.actuator(bitsByte10[6]); tile.inActive(bitsByte10[7]); tile.wire2(bitsByte11[0]); tile.wire3(bitsByte11[1]); if (bitsByte11[2]) { tile.color(this.reader.ReadByte()); } if (bitsByte11[3]) { tile.wallColor(this.reader.ReadByte()); } if (tile.active()) { int type3 = (int)tile.type; tile.type = this.reader.ReadUInt16(); if (Main.tileFrameImportant[(int)tile.type]) { tile.frameX = this.reader.ReadInt16(); tile.frameY = this.reader.ReadInt16(); } else if (!flag7 || (int)tile.type != type3) { tile.frameX = -1; tile.frameY = -1; } byte b4 = 0; if (bitsByte11[4]) { b4 += 1; } if (bitsByte11[5]) { b4 += 2; } if (bitsByte11[6]) { b4 += 4; } tile.slope(b4); } if (tile.wall > 0) { tile.wall = this.reader.ReadByte(); } if (flag8) { tile.liquid = this.reader.ReadByte(); tile.liquidType((int)this.reader.ReadByte()); } } } WorldGen.RangeFrame(num55, num56, num55 + (int)num54, num56 + (int)num54); if (Main.netMode == 2) { NetMessage.SendData((int)b, -1, this.whoAmI, "", (int)num54, (float)num55, (float)num56, 0f, 0, 0, 0); return; } return; } case 21: case 90: { int num59 = (int)this.reader.ReadInt16(); Vector2 position = this.reader.ReadVector2(); Vector2 velocity = this.reader.ReadVector2(); int stack3 = (int)this.reader.ReadInt16(); int pre = (int)this.reader.ReadByte(); int num60 = (int)this.reader.ReadByte(); int num61 = (int)this.reader.ReadInt16(); if (Main.netMode == 1) { if (num61 == 0) { Main.item[num59].active = false; return; } int num62 = num59; Item item = Main.item[num62]; bool newAndShiny = (item.newAndShiny || item.netID != num61) && ItemSlot.Options.HighlightNewItems && (num61 < 0 || num61 >= 3602 + Main.ulterrariaItems || !ItemID.Sets.NeverShiny[num61]); item.netDefaults(num61); item.newAndShiny = newAndShiny; item.Prefix(pre); item.stack = stack3; item.position = position; item.velocity = velocity; item.active = true; if (b == 90) { item.instanced = true; item.owner = Main.myPlayer; item.keepTime = 600; } item.wet = Collision.WetCollision(item.position, item.width, item.height); return; } else { if (Main.itemLockoutTime[num59] > 0) { return; } if (num61 == 0) { if (num59 < 400) { Main.item[num59].active = false; NetMessage.SendData(21, -1, -1, "", num59, 0f, 0f, 0f, 0, 0, 0); return; } return; } else { bool flag9 = false; if (num59 == 400) { flag9 = true; } if (flag9) { Item item2 = new Item(); item2.netDefaults(num61); num59 = Item.NewItem((int)position.X, (int)position.Y, item2.width, item2.height, item2.type, stack3, true, 0, false, false); } Item item3 = Main.item[num59]; item3.netDefaults(num61); item3.Prefix(pre); item3.stack = stack3; item3.position = position; item3.velocity = velocity; item3.active = true; item3.owner = Main.myPlayer; if (flag9) { NetMessage.SendData(21, -1, -1, "", num59, 0f, 0f, 0f, 0, 0, 0); if (num60 == 0) { Main.item[num59].ownIgnore = this.whoAmI; Main.item[num59].ownTime = 100; } Main.item[num59].FindOwner(num59); return; } NetMessage.SendData(21, -1, this.whoAmI, "", num59, 0f, 0f, 0f, 0, 0, 0); return; } } break; } case 22: { int num63 = (int)this.reader.ReadInt16(); int num64 = (int)this.reader.ReadByte(); if (Main.netMode == 2 && Main.item[num63].owner != this.whoAmI) { return; } Main.item[num63].owner = num64; if (num64 == Main.myPlayer) { Main.item[num63].keepTime = 15; } else { Main.item[num63].keepTime = 0; } if (Main.netMode == 2) { Main.item[num63].owner = 255; Main.item[num63].keepTime = 15; NetMessage.SendData(22, -1, -1, "", num63, 0f, 0f, 0f, 0, 0, 0); return; } return; } case 23: { if (Main.netMode != 1) { return; } int num65 = (int)this.reader.ReadInt16(); Vector2 position2 = this.reader.ReadVector2(); Vector2 velocity2 = this.reader.ReadVector2(); int target = (int)this.reader.ReadByte(); BitsByte bitsByte12 = this.reader.ReadByte(); float[] array2 = new float[NPC.maxAI]; for (int num66 = 0; num66 < NPC.maxAI; num66++) { if (bitsByte12[num66 + 2]) { array2[num66] = this.reader.ReadSingle(); } else { array2[num66] = 0f; } } int num67 = (int)this.reader.ReadInt16(); int num68 = 0; if (!bitsByte12[7]) { byte b5 = this.reader.ReadByte(); if (b5 == 2) { num68 = (int)this.reader.ReadInt16(); } else if (b5 == 4) { num68 = this.reader.ReadInt32(); } else { num68 = (int)this.reader.ReadSByte(); } } int num69 = -1; NPC nPC = Main.npc[num65]; if (!nPC.active || nPC.netID != num67) { if (nPC.active) { num69 = nPC.type; } nPC.active = true; nPC.netDefaults(num67); } nPC.position = position2; nPC.velocity = velocity2; nPC.target = target; nPC.direction = (bitsByte12[0] ? 1 : -1); nPC.directionY = (bitsByte12[1] ? 1 : -1); nPC.spriteDirection = (bitsByte12[6] ? 1 : -1); if (bitsByte12[7]) { num68 = (nPC.life = nPC.lifeMax); } else { nPC.life = num68; } if (num68 <= 0) { nPC.active = false; } for (int num70 = 0; num70 < NPC.maxAI; num70++) { nPC.ai[num70] = array2[num70]; } if (num69 > -1 && num69 != nPC.type) { nPC.TransformVisuals(num69, nPC.type); } if (num67 == 262) { NPC.plantBoss = num65; } if (num67 == 245) { NPC.golemBoss = num65; } if (Main.npcCatchable[nPC.type]) { nPC.releaseOwner = (short)this.reader.ReadByte(); return; } return; } case 24: { int num71 = (int)this.reader.ReadInt16(); int num72 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num72 = this.whoAmI; } Player player7 = Main.player[num72]; Main.npc[num71].StrikeNPC(player7.inventory[player7.selectedItem].damage, player7.inventory[player7.selectedItem].knockBack, player7.direction, false, false, false); if (Main.netMode == 2) { NetMessage.SendData(24, -1, this.whoAmI, "", num71, (float)num72, 0f, 0f, 0, 0, 0); NetMessage.SendData(23, -1, -1, "", num71, 0f, 0f, 0f, 0, 0, 0); return; } return; } case 25: { int num73 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num73 = this.whoAmI; } Color color = this.reader.ReadRGB(); if (Main.netMode == 2) { color = new Color(255, 255, 255); } string text = this.reader.ReadString(); if (Main.netMode == 1) { string newText = text; if (num73 < 255) { newText = NameTagHandler.GenerateTag(Main.player[num73].name) + " " + text; Main.player[num73].chatOverhead.NewMessage(text, Main.chatLength / 2); } Main.NewText(newText, color.R, color.G, color.B, false); return; } if (Main.netMode != 2) { return; } string text2 = text.ToLower(); if (text2 == Lang.mp[6] || text2 == Lang.mp[21]) { string text3 = ""; for (int num74 = 0; num74 < 255; num74++) { if (Main.player[num74].active) { if (text3 == "") { text3 = Main.player[num74].name; } else { text3 = text3 + ", " + Main.player[num74].name; } } } NetMessage.SendData(25, this.whoAmI, -1, Lang.mp[7] + " " + text3 + ".", 255, 255f, 240f, 20f, 0, 0, 0); return; } if (text2.StartsWith("/me ")) { NetMessage.SendData(25, -1, -1, "*" + Main.player[this.whoAmI].name + " " + text.Substring(4), 255, 200f, 100f, 0f, 0, 0, 0); return; } if (text2 == Lang.mp[8]) { NetMessage.SendData(25, -1, -1, string.Concat(new object[] { "*", Main.player[this.whoAmI].name, " ", Lang.mp[9], " ", Main.rand.Next(1, 101) }), 255, 255f, 240f, 20f, 0, 0, 0); return; } if (text2.StartsWith("/p ")) { int team = Main.player[this.whoAmI].team; color = Main.teamColor[team]; if (team != 0) { for (int num75 = 0; num75 < 255; num75++) { if (Main.player[num75].team == team) { NetMessage.SendData(25, num75, -1, text.Substring(3), num73, (float)color.R, (float)color.G, (float)color.B, 0, 0, 0); } } return; } NetMessage.SendData(25, this.whoAmI, -1, Lang.mp[10], 255, 255f, 240f, 20f, 0, 0, 0); return; } else { if (Main.player[this.whoAmI].difficulty == 2) { color = Main.hcColor; } else if (Main.player[this.whoAmI].difficulty == 1) { color = Main.mcColor; } NetMessage.SendData(25, -1, -1, text, num73, (float)color.R, (float)color.G, (float)color.B, 0, 0, 0); if (Main.dedServ) { Console.WriteLine("<" + Main.player[this.whoAmI].name + "> " + text); return; } return; } break; } case 26: { int num76 = (int)this.reader.ReadByte(); if (Main.netMode == 2 && this.whoAmI != num76 && (!Main.player[num76].hostile || !Main.player[this.whoAmI].hostile)) { return; } int num77 = (int)(this.reader.ReadByte() - 1); int num78 = (int)this.reader.ReadInt16(); string text4 = this.reader.ReadString(); BitsByte bitsByte13 = this.reader.ReadByte(); bool flag10 = bitsByte13[0]; bool flag11 = bitsByte13[1]; int num79 = bitsByte13[2] ? 0 : -1; if (bitsByte13[3]) { num79 = 1; } Main.player[num76].Hurt(num78, num77, flag10, true, text4, flag11, num79); if (Main.netMode == 2) { NetMessage.SendData(26, -1, this.whoAmI, text4, num76, (float)num77, (float)num78, (float)(flag10 ? 1 : 0), flag11 ? 1 : 0, num79, 0); return; } return; } case 27: { int num80 = (int)this.reader.ReadInt16(); Vector2 position3 = this.reader.ReadVector2(); Vector2 velocity3 = this.reader.ReadVector2(); float knockBack = this.reader.ReadSingle(); int damage = (int)this.reader.ReadInt16(); int num81 = (int)this.reader.ReadByte(); int num82 = (int)this.reader.ReadInt16(); BitsByte bitsByte14 = this.reader.ReadByte(); float[] array3 = new float[Projectile.maxAI]; for (int num83 = 0; num83 < Projectile.maxAI; num83++) { if (bitsByte14[num83]) { array3[num83] = this.reader.ReadSingle(); } else { array3[num83] = 0f; } } int num84 = (int)(bitsByte14[Projectile.maxAI] ? this.reader.ReadInt16() : -1); if (num84 >= 1000) { num84 = -1; } if (Main.netMode == 2) { num81 = this.whoAmI; if (Main.projHostile[num82]) { return; } } int num85 = 1000; for (int num86 = 0; num86 < 1000; num86++) { if (Main.projectile[num86].owner == num81 && Main.projectile[num86].identity == num80 && Main.projectile[num86].active) { num85 = num86; break; } } if (num85 == 1000) { for (int num87 = 0; num87 < 1000; num87++) { if (!Main.projectile[num87].active) { num85 = num87; break; } } } Projectile projectile = Main.projectile[num85]; if (!projectile.active || projectile.type != num82) { projectile.SetDefaults(num82); if (Main.netMode == 2) { Netplay.Clients[this.whoAmI].SpamProjectile += 1f; } } projectile.identity = num80; projectile.position = position3; projectile.velocity = velocity3; projectile.type = num82; projectile.damage = damage; projectile.knockBack = knockBack; projectile.owner = num81; for (int num88 = 0; num88 < Projectile.maxAI; num88++) { projectile.ai[num88] = array3[num88]; } if (num84 >= 0) { projectile.projUUID = num84; Main.projectileIdentity[num81, num84] = num85; } projectile.ProjectileFixDesperation(); if (Main.netMode == 2) { NetMessage.SendData(27, -1, this.whoAmI, "", num85, 0f, 0f, 0f, 0, 0, 0); return; } return; } case 28: { int num89 = (int)this.reader.ReadInt16(); int num90 = (int)this.reader.ReadInt16(); float num91 = this.reader.ReadSingle(); int num92 = (int)(this.reader.ReadByte() - 1); byte b6 = this.reader.ReadByte(); if (Main.netMode == 2) { if (num90 < 0) { num90 = 0; } Main.npc[num89].PlayerInteraction(this.whoAmI); } if (num90 >= 0) { Main.npc[num89].StrikeNPC(num90, num91, num92, b6 == 1, false, true); } else { Main.npc[num89].life = 0; Main.npc[num89].HitEffect(0, 10.0); Main.npc[num89].active = false; } if (Main.netMode != 2) { return; } NetMessage.SendData(28, -1, this.whoAmI, "", num89, (float)num90, num91, (float)num92, (int)b6, 0, 0); if (Main.npc[num89].life <= 0) { NetMessage.SendData(23, -1, -1, "", num89, 0f, 0f, 0f, 0, 0, 0); } else { Main.npc[num89].netUpdate = true; } if (Main.npc[num89].realLife < 0) { return; } if (Main.npc[Main.npc[num89].realLife].life <= 0) { NetMessage.SendData(23, -1, -1, "", Main.npc[num89].realLife, 0f, 0f, 0f, 0, 0, 0); return; } Main.npc[Main.npc[num89].realLife].netUpdate = true; return; } case 29: { int num93 = (int)this.reader.ReadInt16(); int num94 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num94 = this.whoAmI; } for (int num95 = 0; num95 < 1000; num95++) { if (Main.projectile[num95].owner == num94 && Main.projectile[num95].identity == num93 && Main.projectile[num95].active) { Main.projectile[num95].Kill(); break; } } if (Main.netMode == 2) { NetMessage.SendData(29, -1, this.whoAmI, "", num93, (float)num94, 0f, 0f, 0, 0, 0); return; } return; } case 30: { int num96 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num96 = this.whoAmI; } bool flag12 = this.reader.ReadBoolean(); Main.player[num96].hostile = flag12; if (Main.netMode == 2) { NetMessage.SendData(30, -1, this.whoAmI, "", num96, 0f, 0f, 0f, 0, 0, 0); string str = " " + Lang.mp[flag12 ? 11 : 12]; Color color2 = Main.teamColor[Main.player[num96].team]; NetMessage.SendData(25, -1, -1, Main.player[num96].name + str, 255, (float)color2.R, (float)color2.G, (float)color2.B, 0, 0, 0); return; } return; } case 31: { if (Main.netMode != 2) { return; } int x = (int)this.reader.ReadInt16(); int y = (int)this.reader.ReadInt16(); int num97 = Chest.FindChest(x, y); if (num97 > -1 && Chest.UsingChest(num97) == -1) { for (int num98 = 0; num98 < 40; num98++) { NetMessage.SendData(32, this.whoAmI, -1, "", num97, (float)num98, 0f, 0f, 0, 0, 0); } NetMessage.SendData(33, this.whoAmI, -1, "", num97, 0f, 0f, 0f, 0, 0, 0); Main.player[this.whoAmI].chest = num97; if (Main.myPlayer == this.whoAmI) { Main.recBigList = false; } NetMessage.SendData(80, -1, this.whoAmI, "", this.whoAmI, (float)num97, 0f, 0f, 0, 0, 0); return; } return; } case 32: { int num99 = (int)this.reader.ReadInt16(); int num100 = (int)this.reader.ReadByte(); int stack4 = (int)this.reader.ReadInt16(); int pre2 = (int)this.reader.ReadByte(); int type4 = (int)this.reader.ReadInt16(); if (Main.chest[num99] == null) { Main.chest[num99] = new Chest(false); } if (Main.chest[num99].item[num100] == null) { Main.chest[num99].item[num100] = new Item(); } Main.chest[num99].item[num100].netDefaults(type4); Main.chest[num99].item[num100].Prefix(pre2); Main.chest[num99].item[num100].stack = stack4; Recipe.FindRecipes(); return; } case 33: { int num101 = (int)this.reader.ReadInt16(); int num102 = (int)this.reader.ReadInt16(); int num103 = (int)this.reader.ReadInt16(); int num104 = (int)this.reader.ReadByte(); string text5 = string.Empty; if (num104 != 0) { if (num104 <= 20) { text5 = this.reader.ReadString(); } else if (num104 != 255) { num104 = 0; } } if (Main.netMode != 1) { if (num104 != 0) { int chest = Main.player[this.whoAmI].chest; Chest chest2 = Main.chest[chest]; chest2.name = text5; NetMessage.SendData(69, -1, this.whoAmI, text5, chest, (float)chest2.x, (float)chest2.y, 0f, 0, 0, 0); } Main.player[this.whoAmI].chest = num101; Recipe.FindRecipes(); NetMessage.SendData(80, -1, this.whoAmI, "", this.whoAmI, (float)num101, 0f, 0f, 0, 0, 0); return; } Player player8 = Main.player[Main.myPlayer]; if (player8.chest == -1) { Main.playerInventory = true; Main.PlaySound(10, -1, -1, 1); } else if (player8.chest != num101 && num101 != -1) { Main.playerInventory = true; Main.PlaySound(12, -1, -1, 1); Main.recBigList = false; } else if (player8.chest != -1 && num101 == -1) { Main.PlaySound(11, -1, -1, 1); Main.recBigList = false; } player8.chest = num101; player8.chestX = num102; player8.chestY = num103; Recipe.FindRecipes(); if (Main.tile[num102, num103].frameX >= 36 && Main.tile[num102, num103].frameX < 72) { AchievementsHelper.HandleSpecialEvent(Main.player[Main.myPlayer], 16); return; } return; } case 34: { byte b7 = this.reader.ReadByte(); int num105 = (int)this.reader.ReadInt16(); int num106 = (int)this.reader.ReadInt16(); int num107 = (int)this.reader.ReadInt16(); if (Main.netMode == 2) { if (b7 == 0) { int num108 = WorldGen.PlaceChest(num105, num106, 21, false, num107); if (num108 == -1) { NetMessage.SendData(34, this.whoAmI, -1, "", (int)b7, (float)num105, (float)num106, (float)num107, num108, 0, 0); Item.NewItem(num105 * 16, num106 * 16, 32, 32, Chest.chestItemSpawn[num107], 1, true, 0, false, false); return; } NetMessage.SendData(34, -1, -1, "", (int)b7, (float)num105, (float)num106, (float)num107, num108, 0, 0); return; } else if (b7 == 2) { int num109 = WorldGen.PlaceChest(num105, num106, 88, false, num107); if (num109 == -1) { NetMessage.SendData(34, this.whoAmI, -1, "", (int)b7, (float)num105, (float)num106, (float)num107, num109, 0, 0); Item.NewItem(num105 * 16, num106 * 16, 32, 32, Chest.dresserItemSpawn[num107], 1, true, 0, false, false); return; } NetMessage.SendData(34, -1, -1, "", (int)b7, (float)num105, (float)num106, (float)num107, num109, 0, 0); return; } else { Tile tile2 = Main.tile[num105, num106]; if (tile2.type == 21 && b7 == 1) { if (tile2.frameX % 36 != 0) { num105--; } if (tile2.frameY % 36 != 0) { num106--; } int number = Chest.FindChest(num105, num106); WorldGen.KillTile(num105, num106, false, false, false); if (!tile2.active()) { NetMessage.SendData(34, -1, -1, "", (int)b7, (float)num105, (float)num106, 0f, number, 0, 0); return; } return; } else { if (tile2.type != 88 || b7 != 3) { return; } num105 -= (int)(tile2.frameX % 54 / 18); if (tile2.frameY % 36 != 0) { num106--; } int number2 = Chest.FindChest(num105, num106); WorldGen.KillTile(num105, num106, false, false, false); if (!tile2.active()) { NetMessage.SendData(34, -1, -1, "", (int)b7, (float)num105, (float)num106, 0f, number2, 0, 0); return; } return; } } } else { int num110 = (int)this.reader.ReadInt16(); if (b7 == 0) { if (num110 == -1) { WorldGen.KillTile(num105, num106, false, false, false); return; } WorldGen.PlaceChestDirect(num105, num106, 21, num107, num110); return; } else { if (b7 != 2) { Chest.DestroyChestDirect(num105, num106, num110); WorldGen.KillTile(num105, num106, false, false, false); return; } if (num110 == -1) { WorldGen.KillTile(num105, num106, false, false, false); return; } WorldGen.PlaceDresserDirect(num105, num106, 88, num107, num110); return; } } break; } case 35: { int num111 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num111 = this.whoAmI; } int num112 = (int)this.reader.ReadInt16(); if (num111 != Main.myPlayer || Main.ServerSideCharacter) { Main.player[num111].HealEffect(num112, true); } if (Main.netMode == 2) { NetMessage.SendData(35, -1, this.whoAmI, "", num111, (float)num112, 0f, 0f, 0, 0, 0); return; } return; } case 36: { int num113 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num113 = this.whoAmI; } Player player9 = Main.player[num113]; player9.zone1 = this.reader.ReadByte(); player9.zone2 = this.reader.ReadByte(); if (Main.netMode == 2) { NetMessage.SendData(36, -1, this.whoAmI, "", num113, 0f, 0f, 0f, 0, 0, 0); return; } return; } case 37: if (Main.netMode != 1) { return; } if (Main.autoPass) { NetMessage.SendData(38, -1, -1, Netplay.ServerPassword, 0, 0f, 0f, 0f, 0, 0, 0); Main.autoPass = false; return; } Netplay.ServerPassword = ""; Main.menuMode = 31; return; case 38: { if (Main.netMode != 2) { return; } string a2 = this.reader.ReadString(); if (a2 == Netplay.ServerPassword) { Netplay.Clients[this.whoAmI].State = 1; NetMessage.SendData(3, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); return; } NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[1], 0, 0f, 0f, 0f, 0, 0, 0); return; } case 39: { if (Main.netMode != 1) { return; } int num114 = (int)this.reader.ReadInt16(); Main.item[num114].owner = 255; NetMessage.SendData(22, -1, -1, "", num114, 0f, 0f, 0f, 0, 0, 0); return; } case 40: { int num115 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num115 = this.whoAmI; } int talkNPC = (int)this.reader.ReadInt16(); Main.player[num115].talkNPC = talkNPC; if (Main.netMode == 2) { NetMessage.SendData(40, -1, this.whoAmI, "", num115, 0f, 0f, 0f, 0, 0, 0); return; } return; } case 41: { int num116 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num116 = this.whoAmI; } Player player10 = Main.player[num116]; float itemRotation = this.reader.ReadSingle(); int itemAnimation = (int)this.reader.ReadInt16(); player10.itemRotation = itemRotation; player10.itemAnimation = itemAnimation; player10.channel = player10.inventory[player10.selectedItem].channel; if (Main.netMode == 2) { NetMessage.SendData(41, -1, this.whoAmI, "", num116, 0f, 0f, 0f, 0, 0, 0); return; } return; } case 42: { int num117 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num117 = this.whoAmI; } else if (Main.myPlayer == num117 && !Main.ServerSideCharacter) { return; } int statMana = (int)this.reader.ReadInt16(); int statManaMax = (int)this.reader.ReadInt16(); Main.player[num117].statMana = statMana; Main.player[num117].statManaMax = statManaMax; return; } case 43: { int num118 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num118 = this.whoAmI; } int num119 = (int)this.reader.ReadInt16(); if (num118 != Main.myPlayer) { Main.player[num118].ManaEffect(num119); } if (Main.netMode == 2) { NetMessage.SendData(43, -1, this.whoAmI, "", num118, (float)num119, 0f, 0f, 0, 0, 0); return; } return; } case 44: { int num120 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num120 = this.whoAmI; } int num121 = (int)(this.reader.ReadByte() - 1); int num122 = (int)this.reader.ReadInt16(); byte b8 = this.reader.ReadByte(); string text6 = this.reader.ReadString(); Main.player[num120].KillMe((double)num122, num121, b8 == 1, text6); if (Main.netMode == 2) { NetMessage.SendData(44, -1, this.whoAmI, text6, num120, (float)num121, (float)num122, (float)b8, 0, 0, 0); return; } return; } case 45: { int num123 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num123 = this.whoAmI; } int num124 = (int)this.reader.ReadByte(); Player player11 = Main.player[num123]; int team2 = player11.team; player11.team = num124; Color color3 = Main.teamColor[num124]; if (Main.netMode == 2) { NetMessage.SendData(45, -1, this.whoAmI, "", num123, 0f, 0f, 0f, 0, 0, 0); string str2 = " " + Lang.mp[13 + num124]; if (num124 == 5) { str2 = " " + Lang.mp[22]; } for (int num125 = 0; num125 < 255; num125++) { if (num125 == this.whoAmI || (team2 > 0 && Main.player[num125].team == team2) || (num124 > 0 && Main.player[num125].team == num124)) { NetMessage.SendData(25, num125, -1, player11.name + str2, 255, (float)color3.R, (float)color3.G, (float)color3.B, 0, 0, 0); } } return; } return; } case 46: { if (Main.netMode != 2) { return; } int i2 = (int)this.reader.ReadInt16(); int j2 = (int)this.reader.ReadInt16(); int num126 = Sign.ReadSign(i2, j2, true); if (num126 >= 0) { NetMessage.SendData(47, this.whoAmI, -1, "", num126, (float)this.whoAmI, 0f, 0f, 0, 0, 0); return; } return; } case 47: { int num127 = (int)this.reader.ReadInt16(); int x2 = (int)this.reader.ReadInt16(); int y2 = (int)this.reader.ReadInt16(); string text7 = this.reader.ReadString(); string a3 = null; if (Main.sign[num127] != null) { a3 = Main.sign[num127].text; } Main.sign[num127] = new Sign(); Main.sign[num127].x = x2; Main.sign[num127].y = y2; Sign.TextSign(num127, text7); int num128 = (int)this.reader.ReadByte(); if (Main.netMode == 2 && a3 != text7) { num128 = this.whoAmI; NetMessage.SendData(47, -1, this.whoAmI, "", num127, (float)num128, 0f, 0f, 0, 0, 0); } if (Main.netMode == 1 && num128 == Main.myPlayer && Main.sign[num127] != null) { Main.playerInventory = false; Main.player[Main.myPlayer].talkNPC = -1; Main.npcChatCornerItem = 0; Main.editSign = false; Main.PlaySound(10, -1, -1, 1); Main.player[Main.myPlayer].sign = num127; Main.npcChatText = Main.sign[num127].text; return; } return; } case 48: { int num129 = (int)this.reader.ReadInt16(); int num130 = (int)this.reader.ReadInt16(); byte liquid = this.reader.ReadByte(); byte liquidType = this.reader.ReadByte(); if (Main.netMode == 2 && Netplay.spamCheck) { int num131 = this.whoAmI; int num132 = (int)(Main.player[num131].position.X + (float)(Main.player[num131].width / 2)); int num133 = (int)(Main.player[num131].position.Y + (float)(Main.player[num131].height / 2)); int num134 = 10; int num135 = num132 - num134; int num136 = num132 + num134; int num137 = num133 - num134; int num138 = num133 + num134; if (num129 < num135 || num129 > num136 || num130 < num137 || num130 > num138) { NetMessage.BootPlayer(this.whoAmI, "Cheating attempt detected: Liquid spam"); return; } } if (Main.tile[num129, num130] == null) { Main.tile[num129, num130] = new Tile(); } lock (Main.tile[num129, num130]) { Main.tile[num129, num130].liquid = liquid; Main.tile[num129, num130].liquidType((int)liquidType); if (Main.netMode == 2) { WorldGen.SquareTileFrame(num129, num130, true); } return; } goto IL_4824; } case 49: goto IL_4824; case 50: { int num139 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num139 = this.whoAmI; } else if (num139 == Main.myPlayer && !Main.ServerSideCharacter) { return; } Player player12 = Main.player[num139]; for (int num140 = 0; num140 < 22; num140++) { player12.buffType[num140] = (int)this.reader.ReadByte(); if (player12.buffType[num140] > 0) { player12.buffTime[num140] = 60; } else { player12.buffTime[num140] = 0; } } if (Main.netMode == 2) { NetMessage.SendData(50, -1, this.whoAmI, "", num139, 0f, 0f, 0f, 0, 0, 0); return; } return; } case 51: { byte b9 = this.reader.ReadByte(); byte b10 = this.reader.ReadByte(); if (b10 == 1) { NPC.SpawnSkeletron(); return; } if (b10 == 2) { if (Main.netMode == 2) { NetMessage.SendData(51, -1, this.whoAmI, "", (int)b9, (float)b10, 0f, 0f, 0, 0, 0); return; } Main.PlaySound(2, (int)Main.player[(int)b9].position.X, (int)Main.player[(int)b9].position.Y, 1); return; } else if (b10 == 3) { if (Main.netMode == 2) { Main.Sundialing(); return; } return; } else { if (b10 == 4) { Main.npc[(int)b9].BigMimicSpawnSmoke(); return; } return; } break; } case 52: { int num141 = (int)this.reader.ReadByte(); int num142 = (int)this.reader.ReadInt16(); int num143 = (int)this.reader.ReadInt16(); if (num141 == 1) { Chest.Unlock(num142, num143); if (Main.netMode == 2) { NetMessage.SendData(52, -1, this.whoAmI, "", 0, (float)num141, (float)num142, (float)num143, 0, 0, 0); NetMessage.SendTileSquare(-1, num142, num143, 2); } } if (num141 != 2) { return; } WorldGen.UnlockDoor(num142, num143); if (Main.netMode == 2) { NetMessage.SendData(52, -1, this.whoAmI, "", 0, (float)num141, (float)num142, (float)num143, 0, 0, 0); NetMessage.SendTileSquare(-1, num142, num143, 2); return; } return; } case 53: { int num144 = (int)this.reader.ReadInt16(); int type5 = (int)this.reader.ReadByte(); int time = (int)this.reader.ReadInt16(); Main.npc[num144].AddBuff(type5, time, true); if (Main.netMode == 2) { NetMessage.SendData(54, -1, -1, "", num144, 0f, 0f, 0f, 0, 0, 0); return; } return; } case 54: { if (Main.netMode != 1) { return; } int num145 = (int)this.reader.ReadInt16(); NPC nPC2 = Main.npc[num145]; for (int num146 = 0; num146 < 5; num146++) { nPC2.buffType[num146] = (int)this.reader.ReadByte(); nPC2.buffTime[num146] = (int)this.reader.ReadInt16(); } return; } case 55: { int num147 = (int)this.reader.ReadByte(); int num148 = (int)this.reader.ReadByte(); int num149 = (int)this.reader.ReadInt16(); if (Main.netMode == 2 && num147 != this.whoAmI && !Main.pvpBuff[num148]) { return; } if (Main.netMode == 1 && num147 == Main.myPlayer) { Main.player[num147].AddBuff(num148, num149, true); return; } if (Main.netMode == 2) { NetMessage.SendData(55, num147, -1, "", num147, (float)num148, (float)num149, 0f, 0, 0, 0); return; } return; } case 56: { int num150 = (int)this.reader.ReadInt16(); if (num150 < 0 || num150 >= 200) { return; } string displayName = this.reader.ReadString(); if (Main.netMode == 1) { Main.npc[num150].displayName = displayName; return; } if (Main.netMode == 2) { NetMessage.SendData(56, this.whoAmI, -1, Main.npc[num150].displayName, num150, 0f, 0f, 0f, 0, 0, 0); return; } return; } case 57: if (Main.netMode != 1) { return; } WorldGen.tGood = this.reader.ReadByte(); WorldGen.tEvil = this.reader.ReadByte(); WorldGen.tBlood = this.reader.ReadByte(); return; case 58: { int num151 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num151 = this.whoAmI; } float num152 = this.reader.ReadSingle(); if (Main.netMode == 2) { NetMessage.SendData(58, -1, this.whoAmI, "", this.whoAmI, num152, 0f, 0f, 0, 0, 0); return; } Player player13 = Main.player[num151]; Main.harpNote = num152; int style = 26; if (player13.inventory[player13.selectedItem].type == 507) { style = 35; } Main.PlaySound(2, (int)player13.position.X, (int)player13.position.Y, style); return; } case 59: { int num153 = (int)this.reader.ReadInt16(); int num154 = (int)this.reader.ReadInt16(); Wiring.HitSwitch(num153, num154); if (Main.netMode == 2) { NetMessage.SendData(59, -1, this.whoAmI, "", num153, (float)num154, 0f, 0f, 0, 0, 0); return; } return; } case 60: { int num155 = (int)this.reader.ReadInt16(); int num156 = (int)this.reader.ReadInt16(); int num157 = (int)this.reader.ReadInt16(); byte b11 = this.reader.ReadByte(); if (num155 >= 200) { NetMessage.BootPlayer(this.whoAmI, "cheating attempt detected: Invalid kick-out"); return; } if (Main.netMode == 1) { Main.npc[num155].homeless = (b11 == 1); Main.npc[num155].homeTileX = num156; Main.npc[num155].homeTileY = num157; return; } if (b11 == 0) { WorldGen.kickOut(num155); return; } WorldGen.moveRoom(num156, num157, num155); return; } case 61: { int plr = (int)this.reader.ReadInt16(); int num158 = (int)this.reader.ReadInt16(); if (Main.netMode != 2) { return; } if (num158 >= 0 && num158 < 540 + Main.ulterrariaNPCs && NPCID.Sets.MPAllowedEnemies[num158]) { bool flag14 = !NPC.AnyNPCs(num158); if (flag14) { NPC.SpawnOnPlayer(plr, num158); return; } return; } else if (num158 == -4) { if (!Main.dayTime) { NetMessage.SendData(25, -1, -1, Lang.misc[31], 255, 50f, 255f, 130f, 0, 0, 0); Main.startPumpkinMoon(); NetMessage.SendData(7, -1, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(78, -1, -1, "", 0, 1f, 2f, 1f, 0, 0, 0); return; } return; } else if (num158 == -5) { if (!Main.dayTime) { NetMessage.SendData(25, -1, -1, Lang.misc[34], 255, 50f, 255f, 130f, 0, 0, 0); Main.startSnowMoon(); NetMessage.SendData(7, -1, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(78, -1, -1, "", 0, 1f, 1f, 1f, 0, 0, 0); return; } return; } else if (num158 == -6) { if (Main.dayTime && !Main.eclipse) { NetMessage.SendData(25, -1, -1, Lang.misc[20], 255, 50f, 255f, 130f, 0, 0, 0); Main.eclipse = true; NetMessage.SendData(7, -1, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); return; } return; } else { if (num158 == -7) { NetMessage.SendData(25, -1, -1, "martian moon toggled", 255, 50f, 255f, 130f, 0, 0, 0); Main.invasionDelay = 0; Main.StartInvasion(4); NetMessage.SendData(7, -1, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); NetMessage.SendData(78, -1, -1, "", 0, 1f, (float)(Main.invasionType + 2), 0f, 0, 0, 0); return; } if (num158 == -8) { if (NPC.downedGolemBoss && Main.hardMode && !NPC.AnyDanger() && !NPC.AnyoneNearCultists()) { WorldGen.StartImpendingDoom(); NetMessage.SendData(7, -1, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); return; } return; } else { if (num158 < 0) { int num159 = 1; if (num158 > -5) { num159 = -num158; } if (num159 > 0 && Main.invasionType == 0) { Main.invasionDelay = 0; Main.StartInvasion(num159); } NetMessage.SendData(78, -1, -1, "", 0, 1f, (float)(Main.invasionType + 2), 0f, 0, 0, 0); return; } return; } } break; } case 62: { int num160 = (int)this.reader.ReadByte(); int num161 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num160 = this.whoAmI; } if (num161 == 1) { Main.player[num160].NinjaDodge(); } if (num161 == 2) { Main.player[num160].ShadowDodge(); } if (Main.netMode == 2) { NetMessage.SendData(62, -1, this.whoAmI, "", num160, (float)num161, 0f, 0f, 0, 0, 0); return; } return; } case 63: { int num162 = (int)this.reader.ReadInt16(); int num163 = (int)this.reader.ReadInt16(); byte b12 = this.reader.ReadByte(); WorldGen.paintTile(num162, num163, b12, false); if (Main.netMode == 2) { NetMessage.SendData(63, -1, this.whoAmI, "", num162, (float)num163, (float)b12, 0f, 0, 0, 0); return; } return; } case 64: { int num164 = (int)this.reader.ReadInt16(); int num165 = (int)this.reader.ReadInt16(); byte b13 = this.reader.ReadByte(); WorldGen.paintWall(num164, num165, b13, false); if (Main.netMode == 2) { NetMessage.SendData(64, -1, this.whoAmI, "", num164, (float)num165, (float)b13, 0f, 0, 0, 0); return; } return; } case 65: { BitsByte bitsByte15 = this.reader.ReadByte(); int num166 = (int)this.reader.ReadInt16(); if (Main.netMode == 2) { num166 = this.whoAmI; } Vector2 vector = this.reader.ReadVector2(); int num167 = 0; int num168 = 0; if (bitsByte15[0]) { num167++; } if (bitsByte15[1]) { num167 += 2; } if (bitsByte15[2]) { num168++; } if (bitsByte15[3]) { num168 += 2; } if (num167 == 0) { Main.player[num166].Teleport(vector, num168, 0); } else if (num167 == 1) { Main.npc[num166].Teleport(vector, num168, 0); } else if (num167 == 2) { Main.player[num166].Teleport(vector, num168, 0); if (Main.netMode == 2) { RemoteClient.CheckSection(this.whoAmI, vector, 1); NetMessage.SendData(65, -1, -1, "", 0, (float)num166, vector.X, vector.Y, num168, 0, 0); int num169 = -1; float num170 = 9999f; for (int num171 = 0; num171 < 255; num171++) { if (Main.player[num171].active && num171 != this.whoAmI) { Vector2 vector2 = Main.player[num171].position - Main.player[this.whoAmI].position; if (vector2.Length() < num170) { num170 = vector2.Length(); num169 = num171; } } } if (num169 >= 0) { NetMessage.SendData(25, -1, -1, Main.player[this.whoAmI].name + " has teleported to " + Main.player[num169].name, 255, 250f, 250f, 0f, 0, 0, 0); } } } if (Main.netMode == 2 && num167 == 0) { NetMessage.SendData(65, -1, this.whoAmI, "", 0, (float)num166, vector.X, vector.Y, num168, 0, 0); return; } return; } case 66: { int num172 = (int)this.reader.ReadByte(); int num173 = (int)this.reader.ReadInt16(); if (num173 <= 0) { return; } Player player14 = Main.player[num172]; player14.statLife += num173; if (player14.statLife > player14.statLifeMax2) { player14.statLife = player14.statLifeMax2; } player14.HealEffect(num173, false); if (Main.netMode == 2) { NetMessage.SendData(66, -1, this.whoAmI, "", num172, (float)num173, 0f, 0f, 0, 0, 0); return; } return; } case 68: this.reader.ReadString(); return; case 69: { int num174 = (int)this.reader.ReadInt16(); int num175 = (int)this.reader.ReadInt16(); int num176 = (int)this.reader.ReadInt16(); if (Main.netMode == 1) { if (num174 < 0 || num174 >= 1000) { return; } Chest chest3 = Main.chest[num174]; if (chest3 == null) { chest3 = new Chest(false); chest3.x = num175; chest3.y = num176; Main.chest[num174] = chest3; } else if (chest3.x != num175 || chest3.y != num176) { return; } chest3.name = this.reader.ReadString(); return; } else { if (num174 < -1 || num174 >= 1000) { return; } if (num174 == -1) { num174 = Chest.FindChest(num175, num176); if (num174 == -1) { return; } } Chest chest4 = Main.chest[num174]; if (chest4.x != num175 || chest4.y != num176) { return; } NetMessage.SendData(69, this.whoAmI, -1, chest4.name, num174, (float)num175, (float)num176, 0f, 0, 0, 0); return; } break; } case 70: { if (Main.netMode != 2) { return; } int num177 = (int)this.reader.ReadInt16(); int who = (int)this.reader.ReadByte(); if (Main.netMode == 2) { who = this.whoAmI; } if (num177 < 200 && num177 >= 0) { NPC.CatchNPC(num177, who); return; } return; } case 71: { if (Main.netMode != 2) { return; } int x3 = this.reader.ReadInt32(); int y3 = this.reader.ReadInt32(); int type6 = (int)this.reader.ReadInt16(); byte style2 = this.reader.ReadByte(); NPC.ReleaseNPC(x3, y3, type6, (int)style2, this.whoAmI); return; } case 72: if (Main.netMode != 1) { return; } for (int num178 = 0; num178 < 40; num178++) { Main.travelShop[num178] = (int)this.reader.ReadInt16(); } return; case 73: Main.player[this.whoAmI].TeleportationPotion(); return; case 74: if (Main.netMode != 1) { return; } Main.anglerQuest = (int)this.reader.ReadByte(); Main.anglerQuestFinished = this.reader.ReadBoolean(); return; case 75: { if (Main.netMode != 2) { return; } string name = Main.player[this.whoAmI].name; if (!Main.anglerWhoFinishedToday.Contains(name)) { Main.anglerWhoFinishedToday.Add(name); return; } return; } case 76: { int num179 = (int)this.reader.ReadByte(); if (num179 == Main.myPlayer && !Main.ServerSideCharacter) { return; } if (Main.netMode == 2) { num179 = this.whoAmI; } Player player15 = Main.player[num179]; player15.anglerQuestsFinished = this.reader.ReadInt32(); if (Main.netMode == 2) { NetMessage.SendData(76, -1, this.whoAmI, "", num179, 0f, 0f, 0f, 0, 0, 0); return; } return; } case 77: { short type7 = this.reader.ReadInt16(); ushort tileType = this.reader.ReadUInt16(); short x4 = this.reader.ReadInt16(); short y4 = this.reader.ReadInt16(); Animation.NewTemporaryAnimation((int)type7, tileType, (int)x4, (int)y4); return; } case 78: if (Main.netMode != 1) { return; } Main.ReportInvasionProgress(this.reader.ReadInt32(), this.reader.ReadInt32(), (int)this.reader.ReadSByte(), (int)this.reader.ReadSByte()); return; case 79: { int x5 = (int)this.reader.ReadInt16(); int y5 = (int)this.reader.ReadInt16(); short type8 = this.reader.ReadInt16(); int style3 = (int)this.reader.ReadInt16(); int num180 = (int)this.reader.ReadByte(); int random = (int)this.reader.ReadSByte(); int direction; if (this.reader.ReadBoolean()) { direction = 1; } else { direction = -1; } if (Main.netMode == 2) { Netplay.Clients[this.whoAmI].SpamAddBlock += 1f; if (!WorldGen.InWorld(x5, y5, 10) || !Netplay.Clients[this.whoAmI].TileSections[Netplay.GetSectionX(x5), Netplay.GetSectionY(y5)]) { return; } } WorldGen.PlaceObject(x5, y5, (int)type8, false, style3, num180, random, direction); if (Main.netMode == 2) { NetMessage.SendObjectPlacment(this.whoAmI, x5, y5, (int)type8, style3, num180, random, direction); return; } return; } case 80: { if (Main.netMode != 1) { return; } int num181 = (int)this.reader.ReadByte(); int num182 = (int)this.reader.ReadInt16(); if (num182 >= -3 && num182 < 1000) { Main.player[num181].chest = num182; Recipe.FindRecipes(); return; } return; } case 81: { if (Main.netMode != 1) { return; } int x6 = (int)this.reader.ReadSingle(); int y6 = (int)this.reader.ReadSingle(); Color color4 = this.reader.ReadRGB(); string text8 = this.reader.ReadString(); CombatText.NewText(new Rectangle(x6, y6, 0, 0), color4, text8, false, false); return; } case 82: NetManager.Instance.Read(this.reader, this.whoAmI); return; case 83: { if (Main.netMode != 1) { return; } int num183 = (int)this.reader.ReadInt16(); int num184 = this.reader.ReadInt32(); if (num183 >= 0 && num183 < 251) { NPC.killCount[num183] = num184; return; } return; } case 84: { byte b14 = this.reader.ReadByte(); float stealth = this.reader.ReadSingle(); Main.player[(int)b14].stealth = stealth; if (Main.netMode == 2) { NetMessage.SendData(84, -1, this.whoAmI, "", (int)b14, 0f, 0f, 0f, 0, 0, 0); return; } return; } case 85: { int num185 = this.whoAmI; byte b15 = this.reader.ReadByte(); if (Main.netMode == 2 && num185 < 255 && b15 < 58) { Chest.ServerPlaceItem(this.whoAmI, (int)b15); return; } return; } case 86: { if (Main.netMode != 1) { return; } int key = this.reader.ReadInt32(); bool flag15 = !this.reader.ReadBoolean(); if (!flag15) { TileEntity tileEntity = TileEntity.Read(this.reader); TileEntity.ByID[tileEntity.ID] = tileEntity; TileEntity.ByPosition[tileEntity.Position] = tileEntity; return; } TileEntity tileEntity2; if (TileEntity.ByID.TryGetValue(key, out tileEntity2) && (tileEntity2 is TETrainingDummy || tileEntity2 is TEItemFrame)) { TileEntity.ByID.Remove(key); TileEntity.ByPosition.Remove(tileEntity2.Position); return; } return; } case 87: { if (Main.netMode != 2) { return; } int num186 = (int)this.reader.ReadInt16(); int num187 = (int)this.reader.ReadInt16(); int num188 = (int)this.reader.ReadByte(); if (num186 < 0 || num186 >= Main.maxTilesX) { return; } if (num187 < 0 || num187 >= Main.maxTilesY) { return; } if (TileEntity.ByPosition.ContainsKey(new Point16(num186, num187))) { return; } switch (num188) { case 0: if (!TETrainingDummy.ValidTile(num186, num187)) { return; } TETrainingDummy.Place(num186, num187); return; case 1: { if (!TEItemFrame.ValidTile(num186, num187)) { return; } int number3 = TEItemFrame.Place(num186, num187); NetMessage.SendData(86, -1, -1, "", number3, (float)num186, (float)num187, 0f, 0, 0, 0); return; } default: return; } break; } case 88: { if (Main.netMode != 1) { return; } int num189 = (int)this.reader.ReadInt16(); if (num189 < 0 || num189 > 400) { return; } Item item4 = Main.item[num189]; BitsByte bitsByte16 = this.reader.ReadByte(); if (bitsByte16[0]) { item4.color.PackedValue = this.reader.ReadUInt32(); } if (bitsByte16[1]) { item4.damage = (int)this.reader.ReadUInt16(); } if (bitsByte16[2]) { item4.knockBack = this.reader.ReadSingle(); } if (bitsByte16[3]) { item4.useAnimation = (int)this.reader.ReadUInt16(); } if (bitsByte16[4]) { item4.useTime = (int)this.reader.ReadUInt16(); } if (bitsByte16[5]) { item4.shoot = (int)this.reader.ReadInt16(); } if (bitsByte16[6]) { item4.shootSpeed = this.reader.ReadSingle(); } if (!bitsByte16[7]) { return; } bitsByte16 = this.reader.ReadByte(); if (bitsByte16[0]) { item4.width = (int)this.reader.ReadInt16(); } if (bitsByte16[1]) { item4.height = (int)this.reader.ReadInt16(); } if (bitsByte16[2]) { item4.scale = this.reader.ReadSingle(); } if (bitsByte16[3]) { item4.ammo = (int)this.reader.ReadInt16(); } if (bitsByte16[4]) { item4.useAmmo = (int)this.reader.ReadInt16(); } if (bitsByte16[5]) { item4.notAmmo = this.reader.ReadBoolean(); return; } return; } case 89: { if (Main.netMode != 2) { return; } int x7 = (int)this.reader.ReadInt16(); int y7 = (int)this.reader.ReadInt16(); int netid = (int)this.reader.ReadInt16(); int prefix = (int)this.reader.ReadByte(); int stack5 = (int)this.reader.ReadInt16(); TEItemFrame.TryPlacing(x7, y7, netid, prefix, stack5); return; } case 91: { if (Main.netMode != 1) { return; } int num190 = this.reader.ReadInt32(); int num191 = (int)this.reader.ReadByte(); if (num191 != 255) { int meta = (int)this.reader.ReadUInt16(); int num192 = (int)this.reader.ReadByte(); int num193 = (int)this.reader.ReadByte(); int metadata = 0; if (num193 < 0) { metadata = (int)this.reader.ReadInt16(); } WorldUIAnchor worldUIAnchor = EmoteBubble.DeserializeNetAnchor(num191, meta); lock (EmoteBubble.byID) { if (!EmoteBubble.byID.ContainsKey(num190)) { EmoteBubble.byID[num190] = new EmoteBubble(num193, worldUIAnchor, num192); } else { EmoteBubble.byID[num190].lifeTime = num192; EmoteBubble.byID[num190].lifeTimeStart = num192; EmoteBubble.byID[num190].emote = num193; EmoteBubble.byID[num190].anchor = worldUIAnchor; } EmoteBubble.byID[num190].ID = num190; EmoteBubble.byID[num190].metadata = metadata; return; } goto IL_63B1; } if (EmoteBubble.byID.ContainsKey(num190)) { EmoteBubble.byID.Remove(num190); return; } return; } case 92: goto IL_63B1; case 95: { if (Main.netMode != 2) { return; } ushort num194 = this.reader.ReadUInt16(); if (num194 < 0 || num194 >= 1000) { return; } Projectile projectile2 = Main.projectile[(int)num194]; if (projectile2.type != 602) { return; } projectile2.Kill(); if (Main.netMode != 0) { NetMessage.SendData(29, -1, -1, "", projectile2.whoAmI, (float)projectile2.owner, 0f, 0f, 0, 0, 0); return; } return; } case 96: { int num195 = (int)this.reader.ReadByte(); Player player16 = Main.player[num195]; int num196 = (int)this.reader.ReadInt16(); Vector2 newPos = this.reader.ReadVector2(); Vector2 velocity4 = this.reader.ReadVector2(); int lastPortalColorIndex = num196 + ((num196 % 2 == 0) ? 1 : -1); player16.lastPortalColorIndex = lastPortalColorIndex; player16.Teleport(newPos, 4, num196); player16.velocity = velocity4; return; } case 97: if (Main.netMode != 1) { return; } AchievementsHelper.NotifyNPCKilledDirect(Main.player[Main.myPlayer], (int)this.reader.ReadInt16()); return; case 98: if (Main.netMode != 1) { return; } AchievementsHelper.NotifyProgressionEvent((int)this.reader.ReadInt16()); return; case 99: { int num197 = (int)this.reader.ReadByte(); if (Main.netMode == 2) { num197 = this.whoAmI; } Player player17 = Main.player[num197]; player17.MinionTargetPoint = this.reader.ReadVector2(); if (Main.netMode == 2) { NetMessage.SendData(99, -1, this.whoAmI, "", num197, 0f, 0f, 0f, 0, 0, 0); return; } return; } case 100: { int num198 = (int)this.reader.ReadUInt16(); NPC nPC3 = Main.npc[num198]; int num199 = (int)this.reader.ReadInt16(); Vector2 newPos2 = this.reader.ReadVector2(); Vector2 velocity5 = this.reader.ReadVector2(); int lastPortalColorIndex2 = num199 + ((num199 % 2 == 0) ? 1 : -1); nPC3.lastPortalColorIndex = lastPortalColorIndex2; nPC3.Teleport(newPos2, 4, num199); nPC3.velocity = velocity5; return; } case 101: if (Main.netMode == 2) { return; } NPC.ShieldStrengthTowerSolar = (int)this.reader.ReadUInt16(); NPC.ShieldStrengthTowerVortex = (int)this.reader.ReadUInt16(); NPC.ShieldStrengthTowerNebula = (int)this.reader.ReadUInt16(); NPC.ShieldStrengthTowerStardust = (int)this.reader.ReadUInt16(); if (NPC.ShieldStrengthTowerSolar < 0) { NPC.ShieldStrengthTowerSolar = 0; } if (NPC.ShieldStrengthTowerVortex < 0) { NPC.ShieldStrengthTowerVortex = 0; } if (NPC.ShieldStrengthTowerNebula < 0) { NPC.ShieldStrengthTowerNebula = 0; } if (NPC.ShieldStrengthTowerStardust < 0) { NPC.ShieldStrengthTowerStardust = 0; } if (NPC.ShieldStrengthTowerSolar > NPC.LunarShieldPowerExpert) { NPC.ShieldStrengthTowerSolar = NPC.LunarShieldPowerExpert; } if (NPC.ShieldStrengthTowerVortex > NPC.LunarShieldPowerExpert) { NPC.ShieldStrengthTowerVortex = NPC.LunarShieldPowerExpert; } if (NPC.ShieldStrengthTowerNebula > NPC.LunarShieldPowerExpert) { NPC.ShieldStrengthTowerNebula = NPC.LunarShieldPowerExpert; } if (NPC.ShieldStrengthTowerStardust > NPC.LunarShieldPowerExpert) { NPC.ShieldStrengthTowerStardust = NPC.LunarShieldPowerExpert; return; } return; case 102: { int num200 = (int)this.reader.ReadByte(); byte b16 = this.reader.ReadByte(); Vector2 other = this.reader.ReadVector2(); if (Main.netMode == 2) { num200 = this.whoAmI; NetMessage.SendData(102, -1, -1, "", num200, (float)b16, other.X, other.Y, 0, 0, 0); return; } Player player18 = Main.player[num200]; for (int num201 = 0; num201 < 255; num201++) { Player player19 = Main.player[num201]; if (player19.active && !player19.dead && (player18.team == 0 || player18.team == player19.team) && player19.Distance(other) < 700f) { Vector2 value = player18.Center - player19.Center; Vector2 vector3 = Vector2.Normalize(value); if (!vector3.HasNaNs()) { int type9 = 90; float num202 = 0f; float num203 = 0.209439516f; Vector2 spinningpoint = new Vector2(0f, -8f); Vector2 value2 = new Vector2(-3f); float num204 = 0f; float num205 = 0.005f; byte b17 = b16; if (b17 != 173) { if (b17 != 176) { if (b17 == 179) { type9 = 86; } } else { type9 = 88; } } else { type9 = 90; } int num206 = 0; while ((float)num206 < value.Length() / 6f) { Vector2 position4 = player19.Center + 6f * (float)num206 * vector3 + spinningpoint.RotatedBy((double)num202, default(Vector2)) + value2; num202 += num203; int num207 = Dust.NewDust(position4, 6, 6, type9, 0f, 0f, 100, default(Color), 1.5f); Main.dust[num207].noGravity = true; Main.dust[num207].velocity = Vector2.Zero; num204 = (Main.dust[num207].fadeIn = num204 + num205); Main.dust[num207].velocity += vector3 * 1.5f; num206++; } } player19.NebulaLevelup((int)b16); } } return; } case 103: if (Main.netMode == 1) { NPC.MoonLordCountdown = this.reader.ReadInt32(); return; } return; case 104: { if (Main.netMode != 1 || Main.npcShop <= 0) { return; } Item[] item5 = Main.instance.shop[Main.npcShop].item; int num208 = (int)this.reader.ReadByte(); int type10 = (int)this.reader.ReadInt16(); int stack6 = (int)this.reader.ReadInt16(); int pre3 = (int)this.reader.ReadByte(); int value3 = this.reader.ReadInt32(); BitsByte bitsByte17 = this.reader.ReadByte(); if (num208 < item5.Length) { item5[num208] = new Item(); item5[num208].netDefaults(type10); item5[num208].stack = stack6; item5[num208].Prefix(pre3); item5[num208].value = value3; item5[num208].buyOnce = bitsByte17[0]; return; } return; } default: return; } if (Main.netMode != 2) { return; } if (Netplay.Clients[this.whoAmI].State == 1) { Netplay.Clients[this.whoAmI].State = 2; Netplay.Clients[this.whoAmI].ResetSections(); } NetMessage.SendData(7, this.whoAmI, -1, "", 0, 0f, 0f, 0f, 0, 0, 0); Main.SyncAnInvasion(this.whoAmI); return; IL_4824: if (Netplay.Connection.State == 6) { Netplay.Connection.State = 10; Main.ActivePlayerFileData.StartPlayTimer(); Player.EnterWorld(Main.player[Main.myPlayer]); Main.player[Main.myPlayer].Spawn(); return; } return; IL_63B1: int num209 = (int)this.reader.ReadInt16(); float num210 = this.reader.ReadSingle(); float num211 = this.reader.ReadSingle(); float num212 = this.reader.ReadSingle(); if (num209 < 0 || num209 > 200) { return; } if (Main.netMode == 1) { Main.npc[num209].moneyPing(new Vector2(num211, num212)); Main.npc[num209].extraValue = num210; return; } Main.npc[num209].extraValue += num210; NetMessage.SendData(92, -1, -1, "", num209, Main.npc[num209].extraValue, num211, num212, 0, 0, 0); return; }
/// <summary> /// Shows the chest to the specified player. /// </summary> /// <param name="player">The player, which must not be <c>null</c>.</param> /// <param name="newChestId">A new chest ID to use for showing the chest.</param> public void ShowTo(TSPlayer player, int newChestId) { if (RefillTime != null && DateTime.UtcNow - _lastRefill > RefillTime) { Debug.WriteLine($"DEBUG: Chest at {X}, {Y} was refilled"); _lastRefill = DateTime.UtcNow; for (var i = 0; i < Terraria.Chest.maxItems; ++i) { Items[i] = OriginalItems[i]; } } var session = player.GetSession(); if (!session.ChestToId.TryGetValue(this, out var chestId)) { chestId = newChestId; // Remove all mappings of the old chest ID. foreach (var kvp in session.ChestToId.Where(kvp => kvp.Value == chestId).ToList()) { session.ChestToId.Remove(kvp); } session.IdToChest.Remove(chestId); } session.ChestToId[this] = chestId; session.IdToChest[chestId] = this; Debug.WriteLine($"DEBUG: {player.Name} accessing chest at {X}, {Y} (ID: {chestId})"); lock (ChestLock) { var terrariaChest = new Terraria.Chest { x = X, y = Y, name = Name }; Main.chest[chestId] = terrariaChest; player.SendData(PacketTypes.ChestName, "", chestId, X, Y); for (var i = 0; i < Terraria.Chest.maxItems; ++i) { var item = new Item(); item.SetDefaults(Items[i].NetId); item.stack = Items[i].Stack; item.prefix = Items[i].PrefixId; terrariaChest.item[i] = item; player.SendData(PacketTypes.ChestItem, "", chestId, i); } player.SendData(PacketTypes.ChestOpen, "", chestId); Main.chest[chestId] = null; } player.TPlayer.chest = chestId; // Sync player chest indices for everyone. We have to ensure that each player only receives the chest ID // that they received for the chest. foreach (var player2 in TShock.Players.Where(p => p?.Active == true && p != player)) { var session2 = player2.GetSession(); if (session2.ChestToId.TryGetValue(this, out var chestId2)) { player2.SendData(PacketTypes.SyncPlayerChestIndex, "", player.Index, chestId2); } } }
public static void ReadChests(this BinaryReader reader, int x, int y) { int num = (int)reader.ReadInt32(); int num2 = (int)reader.ReadInt16(); TSPlayer.All.SendInfoMessage("Total Chests: {0}, Total Slots: {1}", num, num2); int num3; int num4; if (num2 < 40) { num3 = num2; num4 = 0; } else { num3 = 40; num4 = num2 - 40; } int i; for (i = 0; i < num; i++) { for (int c = 0; c < 1000; c++) { if (Main.chest[c] == null) { Chest chest = new Chest(false); chest.x = reader.ReadInt32() + x; chest.y = reader.ReadInt32() + y; chest.name = reader.ReadString(); TSPlayer.All.SendInfoMessage("Load: {0}x{1} Offset: {2}x{3}", chest.x, chest.y, chest.x - x, chest.y - y); for (int j = 0; j < num3; j++) { short num5 = reader.ReadInt16(); Item item = new Item(); if (num5 > 0) { item.netDefaults(reader.ReadInt16()); item.stack = (int)num5; item.Prefix((int)reader.ReadByte()); } else if (num5 < 0) { item.netDefaults(reader.ReadInt16()); item.Prefix((int)reader.ReadByte()); item.stack = 1; } chest.item[j] = item; } for (int j = 0; j < num4; j++) { short num5 = reader.ReadInt16(); if (num5 > 0) { reader.ReadInt16(); reader.ReadByte(); } } Main.chest[i] = chest; break; } } } TSPlayer.All.SendInfoMessage("{0} Chests Loaded.", num); }
internal static bool WriteChest(Chest chest, BinaryWriter writer) { bool flag; byte[] data; using (MemoryStream stream = new MemoryStream()) { using (BinaryWriter invWriter = new BinaryWriter(stream)) { flag = PlayerIO.WriteInventory(chest.item, invWriter, true); invWriter.Flush(); data = stream.ToArray(); } } if (flag) { writer.Write(chest.x); writer.Write(chest.y); writer.Write(data); } return flag; }
public void GetData(int start, int length, out int messageType) { if (this.whoAmI < 256) Netplay.Clients[this.whoAmI].TimeOutTimer = 0; else Netplay.Connection.TimeOutTimer = 0; int bufferStart = start + 1; byte num1 = this.readBuffer[start]; messageType = (int)num1; if ((int)num1 >= 105) return; ++Main.rxMsg; Main.rxData += length; ++Main.rxMsgType[(int)num1]; Main.rxDataType[(int)num1] += length; if (Main.netMode == 1 && Netplay.Connection.StatusMax > 0) ++Netplay.Connection.StatusCount; if (Main.verboseNetplay) { int num2 = start; while (num2 < start + length) ++num2; for (int index = start; index < start + length; ++index) { int num3 = (int)this.readBuffer[index]; } } if (Main.netMode == 2 && (int)num1 != 38 && Netplay.Clients[this.whoAmI].State == -1) { NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[1], 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); } else { if (Main.netMode == 2 && Netplay.Clients[this.whoAmI].State < 10 && ((int)num1 > 12 && (int)num1 != 93) && ((int)num1 != 16 && (int)num1 != 42 && ((int)num1 != 50 && (int)num1 != 38)) && (int)num1 != 68) NetMessage.BootPlayer(this.whoAmI, Lang.mp[2]); if (this.reader == null) this.ResetReader(); this.reader.BaseStream.Position = (long)bufferStart; switch (num1) { case (byte)1: if (Main.netMode != 2) break; if (Main.dedServ && Netplay.IsBanned(Netplay.Clients[this.whoAmI].Socket.GetRemoteAddress())) { NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[3], 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; } if (Netplay.Clients[this.whoAmI].State != 0) break; if (this.reader.ReadString() == "Terraria" + (object)Main.curRelease) { if (string.IsNullOrEmpty(Netplay.ServerPassword)) { Netplay.Clients[this.whoAmI].State = 1; NetMessage.SendData(3, this.whoAmI, -1, "", 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; } Netplay.Clients[this.whoAmI].State = -1; NetMessage.SendData(37, this.whoAmI, -1, "", 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; } NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[4], 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)2: if (Main.netMode != 1) break; Netplay.disconnect = true; Main.statusText = this.reader.ReadString(); break; case (byte)3: if (Main.netMode != 1) break; if (Netplay.Connection.State == 1) Netplay.Connection.State = 2; int number1 = (int)this.reader.ReadByte(); if (number1 != Main.myPlayer) { Main.player[number1] = Main.ActivePlayerFileData.Player; Main.player[Main.myPlayer] = new Player(); } Main.player[number1].whoAmI = number1; Main.myPlayer = number1; Player player1 = Main.player[number1]; NetMessage.SendData(4, -1, -1, player1.name, number1, 0.0f, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(68, -1, -1, "", number1, 0.0f, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(16, -1, -1, "", number1, 0.0f, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(42, -1, -1, "", number1, 0.0f, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(50, -1, -1, "", number1, 0.0f, 0.0f, 0.0f, 0, 0, 0); for (int index = 0; index < 59; ++index) NetMessage.SendData(5, -1, -1, player1.inventory[index].name, number1, (float)index, (float)player1.inventory[index].prefix, 0.0f, 0, 0, 0); for (int index = 0; index < player1.armor.Length; ++index) NetMessage.SendData(5, -1, -1, player1.armor[index].name, number1, (float)(59 + index), (float)player1.armor[index].prefix, 0.0f, 0, 0, 0); for (int index = 0; index < player1.dye.Length; ++index) NetMessage.SendData(5, -1, -1, player1.dye[index].name, number1, (float)(58 + player1.armor.Length + 1 + index), (float)player1.dye[index].prefix, 0.0f, 0, 0, 0); for (int index = 0; index < player1.miscEquips.Length; ++index) NetMessage.SendData(5, -1, -1, "", number1, (float)(58 + player1.armor.Length + player1.dye.Length + 1 + index), (float)player1.miscEquips[index].prefix, 0.0f, 0, 0, 0); for (int index = 0; index < player1.miscDyes.Length; ++index) NetMessage.SendData(5, -1, -1, "", number1, (float)(58 + player1.armor.Length + player1.dye.Length + player1.miscEquips.Length + 1 + index), (float)player1.miscDyes[index].prefix, 0.0f, 0, 0, 0); for (int index = 0; index < player1.bank.item.Length; ++index) NetMessage.SendData(5, -1, -1, "", number1, (float)(58 + player1.armor.Length + player1.dye.Length + player1.miscEquips.Length + player1.miscDyes.Length + 1 + index), (float)player1.bank.item[index].prefix, 0.0f, 0, 0, 0); for (int index = 0; index < player1.bank2.item.Length; ++index) NetMessage.SendData(5, -1, -1, "", number1, (float)(58 + player1.armor.Length + player1.dye.Length + player1.miscEquips.Length + player1.miscDyes.Length + player1.bank.item.Length + 1 + index), (float)player1.bank2.item[index].prefix, 0.0f, 0, 0, 0); NetMessage.SendData(5, -1, -1, "", number1, (float)(58 + player1.armor.Length + player1.dye.Length + player1.miscEquips.Length + player1.miscDyes.Length + player1.bank.item.Length + player1.bank2.item.Length + 1), (float)player1.trashItem.prefix, 0.0f, 0, 0, 0); NetMessage.SendData(6, -1, -1, "", 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); if (Netplay.Connection.State != 2) break; Netplay.Connection.State = 3; break; case (byte)4: int number2 = (int)this.reader.ReadByte(); if (Main.netMode == 2) number2 = this.whoAmI; if (number2 == Main.myPlayer && !Main.ServerSideCharacter) break; Player player2 = Main.player[number2]; player2.whoAmI = number2; player2.skinVariant = (int)this.reader.ReadByte(); player2.skinVariant = (int)MathHelper.Clamp((float)player2.skinVariant, 0.0f, 7f); player2.hair = (int)this.reader.ReadByte(); if (player2.hair >= 134) player2.hair = 0; player2.name = this.reader.ReadString().Trim().Trim(); player2.hairDye = this.reader.ReadByte(); BitsByte bitsByte1 = (BitsByte)this.reader.ReadByte(); for (int index = 0; index < 8; ++index) player2.hideVisual[index] = bitsByte1[index]; bitsByte1 = (BitsByte)this.reader.ReadByte(); for (int index = 0; index < 2; ++index) player2.hideVisual[index + 8] = bitsByte1[index]; player2.hideMisc = (BitsByte)this.reader.ReadByte(); player2.hairColor = Utils.ReadRGB(this.reader); player2.skinColor = Utils.ReadRGB(this.reader); player2.eyeColor = Utils.ReadRGB(this.reader); player2.shirtColor = Utils.ReadRGB(this.reader); player2.underShirtColor = Utils.ReadRGB(this.reader); player2.pantsColor = Utils.ReadRGB(this.reader); player2.shoeColor = Utils.ReadRGB(this.reader); BitsByte bitsByte2 = (BitsByte)this.reader.ReadByte(); player2.difficulty = (byte)0; if (bitsByte2[0]) ++player2.difficulty; if (bitsByte2[1]) player2.difficulty += (byte)2; if ((int)player2.difficulty > 2) player2.difficulty = (byte)2; player2.extraAccessory = bitsByte2[2]; if (Main.netMode != 2) break; bool flag1 = false; if (Netplay.Clients[this.whoAmI].State < 10) { for (int index = 0; index < (int)byte.MaxValue; ++index) { if (index != number2 && player2.name == Main.player[index].name && Netplay.Clients[index].IsActive) flag1 = true; } } if (flag1) { NetMessage.SendData(2, this.whoAmI, -1, player2.name + " " + Lang.mp[5], 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; } if (player2.name.Length > Player.nameLen) { NetMessage.SendData(2, this.whoAmI, -1, "Name is too long.", 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; } if (player2.name == "") { NetMessage.SendData(2, this.whoAmI, -1, "Empty name.", 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; } Netplay.Clients[this.whoAmI].Name = player2.name; Netplay.Clients[this.whoAmI].Name = player2.name; NetMessage.SendData(4, -1, this.whoAmI, player2.name, number2, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)5: int number3 = (int)this.reader.ReadByte(); if (Main.netMode == 2) number3 = this.whoAmI; if (number3 == Main.myPlayer && !Main.ServerSideCharacter && !Main.player[number3].IsStackingItems()) break; Player player3 = Main.player[number3]; lock (player3) { int local_24 = (int)this.reader.ReadByte(); int local_25 = (int)this.reader.ReadInt16(); int local_26 = (int)this.reader.ReadByte(); int local_27 = (int)this.reader.ReadInt16(); Item[] local_28 = (Item[])null; int local_29 = 0; bool local_30 = false; if (local_24 > 58 + player3.armor.Length + player3.dye.Length + player3.miscEquips.Length + player3.miscDyes.Length + player3.bank.item.Length + player3.bank2.item.Length) local_30 = true; else if (local_24 > 58 + player3.armor.Length + player3.dye.Length + player3.miscEquips.Length + player3.miscDyes.Length + player3.bank.item.Length) { local_29 = local_24 - 58 - (player3.armor.Length + player3.dye.Length + player3.miscEquips.Length + player3.miscDyes.Length + player3.bank.item.Length) - 1; local_28 = player3.bank2.item; } else if (local_24 > 58 + player3.armor.Length + player3.dye.Length + player3.miscEquips.Length + player3.miscDyes.Length) { local_29 = local_24 - 58 - (player3.armor.Length + player3.dye.Length + player3.miscEquips.Length + player3.miscDyes.Length) - 1; local_28 = player3.bank.item; } else if (local_24 > 58 + player3.armor.Length + player3.dye.Length + player3.miscEquips.Length) { local_29 = local_24 - 58 - (player3.armor.Length + player3.dye.Length + player3.miscEquips.Length) - 1; local_28 = player3.miscDyes; } else if (local_24 > 58 + player3.armor.Length + player3.dye.Length) { local_29 = local_24 - 58 - (player3.armor.Length + player3.dye.Length) - 1; local_28 = player3.miscEquips; } else if (local_24 > 58 + player3.armor.Length) { local_29 = local_24 - 58 - player3.armor.Length - 1; local_28 = player3.dye; } else if (local_24 > 58) { local_29 = local_24 - 58 - 1; local_28 = player3.armor; } else { local_29 = local_24; local_28 = player3.inventory; } if (local_30) { player3.trashItem = new Item(); player3.trashItem.netDefaults(local_27); player3.trashItem.stack = local_25; player3.trashItem.Prefix(local_26); } else if (local_24 <= 58) { int local_31 = local_28[local_29].itemId; int local_32 = local_28[local_29].stack; local_28[local_29] = new Item(); local_28[local_29].netDefaults(local_27); local_28[local_29].stack = local_25; local_28[local_29].Prefix(local_26); if (number3 == Main.myPlayer && local_29 == 58) Main.mouseItem = local_28[local_29].Clone(); if (number3 == Main.myPlayer && Main.netMode == 1) { Main.player[number3].inventoryChestStack[local_24] = false; if (local_28[local_29].stack != local_32 || local_28[local_29].itemId != local_31) Main.PlaySound(7, -1, -1, 1); } } else { local_28[local_29] = new Item(); local_28[local_29].netDefaults(local_27); local_28[local_29].stack = local_25; local_28[local_29].Prefix(local_26); } if (Main.netMode != 2 || number3 != this.whoAmI) break; NetMessage.SendData(5, -1, this.whoAmI, "", number3, (float)local_24, (float)local_26, 0.0f, 0, 0, 0); break; } case (byte)6: if (Main.netMode != 2) break; if (Netplay.Clients[this.whoAmI].State == 1) { Netplay.Clients[this.whoAmI].State = 2; Netplay.Clients[this.whoAmI].ResetSections(); } NetMessage.SendData(7, this.whoAmI, -1, "", 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); Main.SyncAnInvasion(this.whoAmI); break; case (byte)7: if (Main.netMode != 1) break; Main.time = (double)this.reader.ReadInt32(); BitsByte bitsByte3 = (BitsByte)this.reader.ReadByte(); Main.dayTime = bitsByte3[0]; Main.bloodMoon = bitsByte3[1]; Main.eclipse = bitsByte3[2]; Main.moonPhase = (int)this.reader.ReadByte(); Main.maxTilesX = (int)this.reader.ReadInt16(); Main.maxTilesY = (int)this.reader.ReadInt16(); Main.spawnTileX = (int)this.reader.ReadInt16(); Main.spawnTileY = (int)this.reader.ReadInt16(); Main.worldSurface = (double)this.reader.ReadInt16(); Main.rockLayer = (double)this.reader.ReadInt16(); Main.worldID = this.reader.ReadInt32(); Main.worldName = this.reader.ReadString(); Main.moonType = (int)this.reader.ReadByte(); WorldGen.setBG(0, (int)this.reader.ReadByte()); WorldGen.setBG(1, (int)this.reader.ReadByte()); WorldGen.setBG(2, (int)this.reader.ReadByte()); WorldGen.setBG(3, (int)this.reader.ReadByte()); WorldGen.setBG(4, (int)this.reader.ReadByte()); WorldGen.setBG(5, (int)this.reader.ReadByte()); WorldGen.setBG(6, (int)this.reader.ReadByte()); WorldGen.setBG(7, (int)this.reader.ReadByte()); Main.iceBackStyle = (int)this.reader.ReadByte(); Main.jungleBackStyle = (int)this.reader.ReadByte(); Main.hellBackStyle = (int)this.reader.ReadByte(); Main.windSpeedSet = this.reader.ReadSingle(); Main.numClouds = (int)this.reader.ReadByte(); for (int index = 0; index < 3; ++index) Main.treeX[index] = this.reader.ReadInt32(); for (int index = 0; index < 4; ++index) Main.treeStyle[index] = (int)this.reader.ReadByte(); for (int index = 0; index < 3; ++index) Main.caveBackX[index] = this.reader.ReadInt32(); for (int index = 0; index < 4; ++index) Main.caveBackStyle[index] = (int)this.reader.ReadByte(); Main.maxRaining = this.reader.ReadSingle(); Main.raining = (double)Main.maxRaining > 0.0; BitsByte bitsByte4 = (BitsByte)this.reader.ReadByte(); WorldGen.shadowOrbSmashed = bitsByte4[0]; NPC.downedBoss1 = bitsByte4[1]; NPC.downedBoss2 = bitsByte4[2]; NPC.downedBoss3 = bitsByte4[3]; Main.hardMode = bitsByte4[4]; NPC.downedClown = bitsByte4[5]; Main.ServerSideCharacter = bitsByte4[6]; NPC.downedPlantBoss = bitsByte4[7]; BitsByte bitsByte5 = (BitsByte)this.reader.ReadByte(); NPC.downedMechBoss1 = bitsByte5[0]; NPC.downedMechBoss2 = bitsByte5[1]; NPC.downedMechBoss3 = bitsByte5[2]; NPC.downedMechBossAny = bitsByte5[3]; Main.cloudBGActive = bitsByte5[4] ? 1f : 0.0f; WorldGen.crimson = bitsByte5[5]; Main.pumpkinMoon = bitsByte5[6]; Main.snowMoon = bitsByte5[7]; BitsByte bitsByte6 = (BitsByte)this.reader.ReadByte(); Main.expertMode = bitsByte6[0]; Main.fastForwardTime = bitsByte6[1]; Main.UpdateSundial(); bool flag2 = bitsByte6[2]; NPC.downedSlimeKing = bitsByte6[3]; NPC.downedQueenBee = bitsByte6[4]; NPC.downedFishron = bitsByte6[5]; NPC.downedMartians = bitsByte6[6]; NPC.downedAncientCultist = bitsByte6[7]; BitsByte bitsByte7 = (BitsByte)this.reader.ReadByte(); NPC.downedMoonlord = bitsByte7[0]; NPC.downedHalloweenKing = bitsByte7[1]; NPC.downedHalloweenTree = bitsByte7[2]; NPC.downedChristmasIceQueen = bitsByte7[3]; NPC.downedChristmasSantank = bitsByte7[4]; NPC.downedChristmasTree = bitsByte7[5]; if (flag2) Main.StartSlimeRain(true); else Main.StopSlimeRain(true); Main.invasionType = (int)this.reader.ReadSByte(); Main.LobbyId = this.reader.ReadUInt64(); if (Netplay.Connection.State != 3) break; Netplay.Connection.State = 4; break; case (byte)8: if (Main.netMode != 2) break; int num2 = this.reader.ReadInt32(); int y1 = this.reader.ReadInt32(); bool flag3 = true; if (num2 == -1 || y1 == -1) flag3 = false; else if (num2 < 10 || num2 > Main.maxTilesX - 10) flag3 = false; else if (y1 < 10 || y1 > Main.maxTilesY - 10) flag3 = false; int number4 = Netplay.GetSectionX(Main.spawnTileX) - 2; int num3 = Netplay.GetSectionY(Main.spawnTileY) - 1; int num4 = number4 + 5; int num5 = num3 + 3; if (number4 < 0) number4 = 0; if (num4 >= Main.maxSectionsX) num4 = Main.maxSectionsX - 1; if (num3 < 0) num3 = 0; if (num5 >= Main.maxSectionsY) num5 = Main.maxSectionsY - 1; int num6 = (num4 - number4) * (num5 - num3); List<Point> dontInclude = new List<Point>(); for (int x = number4; x < num4; ++x) { for (int y2 = num3; y2 < num5; ++y2) dontInclude.Add(new Point(x, y2)); } int num7 = -1; int num8 = -1; if (flag3) { num2 = Netplay.GetSectionX(num2) - 2; y1 = Netplay.GetSectionY(y1) - 1; num7 = num2 + 5; num8 = y1 + 3; if (num2 < 0) num2 = 0; if (num7 >= Main.maxSectionsX) num7 = Main.maxSectionsX - 1; if (y1 < 0) y1 = 0; if (num8 >= Main.maxSectionsY) num8 = Main.maxSectionsY - 1; for (int x = num2; x < num7; ++x) { for (int y2 = y1; y2 < num8; ++y2) { if (x < number4 || x >= num4 || (y2 < num3 || y2 >= num5)) { dontInclude.Add(new Point(x, y2)); ++num6; } } } } int num9 = 1; List<Point> portals; List<Point> portalCenters; PortalHelper.SyncPortalsOnPlayerJoin(this.whoAmI, 1, dontInclude, out portals, out portalCenters); int number5 = num6 + portals.Count; if (Netplay.Clients[this.whoAmI].State == 2) Netplay.Clients[this.whoAmI].State = 3; NetMessage.SendData(9, this.whoAmI, -1, Lang.inter[44], number5, 0.0f, 0.0f, 0.0f, 0, 0, 0); Netplay.Clients[this.whoAmI].StatusText2 = "is receiving tile data"; Netplay.Clients[this.whoAmI].StatusMax += number5; for (int sectionX = number4; sectionX < num4; ++sectionX) { for (int sectionY = num3; sectionY < num5; ++sectionY) NetMessage.SendSection(this.whoAmI, sectionX, sectionY, false); } NetMessage.SendData(11, this.whoAmI, -1, "", number4, (float)num3, (float)(num4 - 1), (float)(num5 - 1), 0, 0, 0); if (flag3) { for (int sectionX = num2; sectionX < num7; ++sectionX) { for (int sectionY = y1; sectionY < num8; ++sectionY) NetMessage.SendSection(this.whoAmI, sectionX, sectionY, true); } NetMessage.SendData(11, this.whoAmI, -1, "", num2, (float)y1, (float)(num7 - 1), (float)(num8 - 1), 0, 0, 0); } for (int index = 0; index < portals.Count; ++index) NetMessage.SendSection(this.whoAmI, portals[index].X, portals[index].Y, true); for (int index = 0; index < portalCenters.Count; ++index) NetMessage.SendData(11, this.whoAmI, -1, "", portalCenters[index].X - num9, (float)(portalCenters[index].Y - num9), (float)(portalCenters[index].X + num9 + 1), (float)(portalCenters[index].Y + num9 + 1), 0, 0, 0); for (int number6 = 0; number6 < 400; ++number6) { if (Main.item[number6].active) { NetMessage.SendData(21, this.whoAmI, -1, "", number6, 0.0f, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(22, this.whoAmI, -1, "", number6, 0.0f, 0.0f, 0.0f, 0, 0, 0); } } for (int number6 = 0; number6 < 200; ++number6) { if (Main.npc[number6].active) NetMessage.SendData(23, this.whoAmI, -1, "", number6, 0.0f, 0.0f, 0.0f, 0, 0, 0); } for (int number6 = 0; number6 < 1000; ++number6) { if (Main.projectile[number6].active && (Main.projPet[Main.projectile[number6].type] || Main.projectile[number6].netImportant)) NetMessage.SendData(27, this.whoAmI, -1, "", number6, 0.0f, 0.0f, 0.0f, 0, 0, 0); } for (int number6 = 0; number6 < 251; ++number6) NetMessage.SendData(83, this.whoAmI, -1, "", number6, 0.0f, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(49, this.whoAmI, -1, "", 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(57, this.whoAmI, -1, "", 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(7, this.whoAmI, -1, "", 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(103, -1, -1, "", NPC.MoonLordCountdown, 0.0f, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(101, this.whoAmI, -1, "", 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)9: if (Main.netMode != 1) break; Netplay.Connection.StatusMax += this.reader.ReadInt32(); Netplay.Connection.StatusText = this.reader.ReadString(); break; case (byte)10: if (Main.netMode != 1) break; NetMessage.DecompressTileBlock(this.readBuffer, bufferStart, length); break; case (byte)11: if (Main.netMode != 1) break; WorldGen.SectionTileFrame((int)this.reader.ReadInt16(), (int)this.reader.ReadInt16(), (int)this.reader.ReadInt16(), (int)this.reader.ReadInt16()); break; case (byte)12: int index1 = (int)this.reader.ReadByte(); if (Main.netMode == 2) index1 = this.whoAmI; Player player4 = Main.player[index1]; player4.SpawnX = (int)this.reader.ReadInt16(); player4.SpawnY = (int)this.reader.ReadInt16(); player4.Spawn(); if (index1 == Main.myPlayer && Main.netMode != 2) { Main.ActivePlayerFileData.StartPlayTimer(); Player.EnterWorld(Main.player[Main.myPlayer]); } if (Main.netMode != 2 || Netplay.Clients[this.whoAmI].State < 3) break; if (Netplay.Clients[this.whoAmI].State == 3) { Netplay.Clients[this.whoAmI].State = 10; NetMessage.greetPlayer(this.whoAmI); NetMessage.buffer[this.whoAmI].broadcast = true; NetMessage.syncPlayers(); NetMessage.SendData(12, -1, this.whoAmI, "", this.whoAmI, 0.0f, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(74, this.whoAmI, -1, Main.player[this.whoAmI].name, Main.anglerQuest, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; } NetMessage.SendData(12, -1, this.whoAmI, "", this.whoAmI, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)13: int number7 = (int)this.reader.ReadByte(); if (number7 == Main.myPlayer && !Main.ServerSideCharacter) break; if (Main.netMode == 2) number7 = this.whoAmI; Player player5 = Main.player[number7]; BitsByte bitsByte8 = (BitsByte)this.reader.ReadByte(); player5.controlUp = bitsByte8[0]; player5.controlDown = bitsByte8[1]; player5.controlLeft = bitsByte8[2]; player5.controlRight = bitsByte8[3]; player5.controlJump = bitsByte8[4]; player5.controlUseItem = bitsByte8[5]; player5.direction = bitsByte8[6] ? 1 : -1; BitsByte bitsByte9 = (BitsByte)this.reader.ReadByte(); if (bitsByte9[0]) { player5.pulley = true; player5.pulleyDir = bitsByte9[1] ? (byte)2 : (byte)1; } else player5.pulley = false; player5.selectedItem = (int)this.reader.ReadByte(); player5.position = Utils.ReadVector2(this.reader); if (bitsByte9[2]) player5.velocity = Utils.ReadVector2(this.reader); player5.vortexStealthActive = bitsByte9[3]; player5.gravDir = bitsByte9[4] ? 1f : -1f; if (Main.netMode != 2 || Netplay.Clients[this.whoAmI].State != 10) break; NetMessage.SendData(13, -1, this.whoAmI, "", number7, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)14: if (Main.netMode != 1) break; int index2 = (int)this.reader.ReadByte(); if ((int)this.reader.ReadByte() == 1) { if (!Main.player[index2].active) Main.player[index2] = new Player(); Main.player[index2].active = true; break; } Main.player[index2].active = false; break; case (byte)16: int number8 = (int)this.reader.ReadByte(); if (number8 == Main.myPlayer && !Main.ServerSideCharacter) break; if (Main.netMode == 2) number8 = this.whoAmI; Player player6 = Main.player[number8]; player6.statLife = (int)this.reader.ReadInt16(); player6.statLifeMax = (int)this.reader.ReadInt16(); if (player6.statLifeMax < 100) player6.statLifeMax = 100; player6.dead = player6.statLife <= 0; if (Main.netMode != 2) break; NetMessage.SendData(16, -1, this.whoAmI, "", number8, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)17: byte num10 = this.reader.ReadByte(); int index3 = (int)this.reader.ReadInt16(); int index4 = (int)this.reader.ReadInt16(); short num11 = this.reader.ReadInt16(); int num12 = (int)this.reader.ReadByte(); bool fail = (int)num11 == 1; if (!WorldGen.InWorld(index3, index4, 3)) break; if (Main.tile[index3, index4] == null) Main.tile[index3, index4] = new Tile(); if (Main.netMode == 2) { if (!fail) { if ((int)num10 == 0 || (int)num10 == 2 || (int)num10 == 4) ++Netplay.Clients[this.whoAmI].SpamDeleteBlock; if ((int)num10 == 1 || (int)num10 == 3) ++Netplay.Clients[this.whoAmI].SpamAddBlock; } if (!Netplay.Clients[this.whoAmI].TileSections[Netplay.GetSectionX(index3), Netplay.GetSectionY(index4)]) fail = true; } if ((int)num10 == 0) WorldGen.KillTile(index3, index4, fail, false, false); if ((int)num10 == 1) WorldGen.PlaceTile(index3, index4, (int)num11, false, true, -1, num12); if ((int)num10 == 2) WorldGen.KillWall(index3, index4, fail); if ((int)num10 == 3) WorldGen.PlaceWall(index3, index4, (int)num11, false); if ((int)num10 == 4) WorldGen.KillTile(index3, index4, fail, false, true); if (num10 == 5 || num10 == 8 || num10 == 10 || num10 == 12) WorldGen.PlaceWire(index3, index4, Tile.k_HACK_GetNetworkWireType(num10)); if (num10 == 6 || num10 == 9 || num10 == 11 || num10 == 13) WorldGen.KillWire(index3, index4, Tile.k_HACK_GetNetworkWireType(num10)); if ((int)num10 == 7) WorldGen.PoundTile(index3, index4); if ((int)num10 == 14) WorldGen.SlopeTile(index3, index4, (int)num11); if ((int)num10 == 15) Minecart.FrameTrack(index3, index4, true, false); if (Main.netMode != 2) break; NetMessage.SendData(17, -1, this.whoAmI, "", (int)num10, (float)index3, (float)index4, (float)num11, num12, 0, 0); if ((int)num10 != 1 || (int)num11 != 53) break; NetMessage.SendTileSquare(-1, index3, index4, 1); break; case (byte)18: if (Main.netMode != 1) break; Main.dayTime = (int)this.reader.ReadByte() == 1; Main.time = (double)this.reader.ReadInt32(); Main.sunModY = this.reader.ReadInt16(); Main.moonModY = this.reader.ReadInt16(); break; case (byte)19: byte num13 = this.reader.ReadByte(); int num14 = (int)this.reader.ReadInt16(); int num15 = (int)this.reader.ReadInt16(); if (!WorldGen.InWorld(num14, num15, 3)) break; int direction1 = (int)this.reader.ReadByte() == 0 ? -1 : 1; if ((int)num13 == 0) WorldGen.OpenDoor(num14, num15, direction1); else if ((int)num13 == 1) WorldGen.CloseDoor(num14, num15, true); else if ((int)num13 == 2) WorldGen.ShiftTrapdoor(num14, num15, direction1 == 1, 1); else if ((int)num13 == 3) WorldGen.ShiftTrapdoor(num14, num15, direction1 == 1, 0); else if ((int)num13 == 4) WorldGen.ShiftTallGate(num14, num15, false); else if ((int)num13 == 5) WorldGen.ShiftTallGate(num14, num15, true); if (Main.netMode != 2) break; NetMessage.SendData(19, -1, this.whoAmI, "", (int)num13, (float)num14, (float)num15, direction1 == 1 ? 1f : 0.0f, 0, 0, 0); break; case (byte)20: short num16 = this.reader.ReadInt16(); int num17 = (int)this.reader.ReadInt16(); int num18 = (int)this.reader.ReadInt16(); if (!WorldGen.InWorld(num17, num18, 3)) break; BitsByte bitsByte10 = (BitsByte)(byte)0; BitsByte bitsByte11 = (BitsByte)(byte)0; for (int index5 = num17; index5 < num17 + (int)num16; ++index5) { for (int index6 = num18; index6 < num18 + (int)num16; ++index6) { if (Main.tile[index5, index6] == null) Main.tile[index5, index6] = new Tile(); Tile tile = Main.tile[index5, index6]; bool flag4 = tile.active(); BitsByte bitsByte12 = (BitsByte)this.reader.ReadByte(); BitsByte bitsByte13 = (BitsByte)this.reader.ReadByte(); tile.active(bitsByte12[0]); tile.wall = bitsByte12[2] ? (byte)1 : (byte)0; bool flag5 = bitsByte12[3]; if (Main.netMode != 2) tile.liquid = flag5 ? (byte)1 : (byte)0; tile.k_SetWireFlags(k_WireFlags.WIRE_RED, bitsByte12[4]); tile.halfBrick(bitsByte12[5]); tile.k_SetWireFlags(k_WireFlags.WIRE_ACTUATOR, bitsByte12[6]); tile.inActive(bitsByte12[7]); tile.k_SetWireFlags(k_WireFlags.WIRE_GREEN, bitsByte13[0]); tile.k_SetWireFlags(k_WireFlags.WIRE_BLUE, bitsByte13[1]); if (bitsByte13[2]) tile.color(this.reader.ReadByte()); if (bitsByte13[3]) tile.wallColor(this.reader.ReadByte()); if (tile.active()) { int num19 = (int)tile.type; tile.type = this.reader.ReadUInt16(); if (Main.tileFrameImportant[(int)tile.type]) { tile.frameX = this.reader.ReadInt16(); tile.frameY = this.reader.ReadInt16(); } else if (!flag4 || (int)tile.type != num19) { tile.frameX = (short)-1; tile.frameY = (short)-1; } byte slope = (byte)0; if (bitsByte13[4]) ++slope; if (bitsByte13[5]) slope += (byte)2; if (bitsByte13[6]) slope += (byte)4; tile.slope(slope); } if ((int)tile.wall > 0) tile.wall = this.reader.ReadByte(); if (flag5) { tile.liquid = this.reader.ReadByte(); tile.liquidType((int)this.reader.ReadByte()); } } } WorldGen.RangeFrame(num17, num18, num17 + (int)num16, num18 + (int)num16); if (Main.netMode != 2) break; NetMessage.SendData((int)num1, -1, this.whoAmI, "", (int)num16, (float)num17, (float)num18, 0.0f, 0, 0, 0); break; case (byte)21: case (byte)90: int index7 = (int)this.reader.ReadInt16(); Vector2 vector2_1 = Utils.ReadVector2(this.reader); Vector2 vector2_2 = Utils.ReadVector2(this.reader); int Stack = (int)this.reader.ReadInt16(); int pre1 = (int)this.reader.ReadByte(); int num20 = (int)this.reader.ReadByte(); int type1 = (int)this.reader.ReadInt16(); if (Main.netMode == 1) { if (type1 == 0) { Main.item[index7].active = false; break; } Item obj = Main.item[index7]; bool flag4 = (obj.newAndShiny || obj.netID != type1) && ItemSlot.Options.HighlightNewItems; obj.netDefaults(type1); obj.newAndShiny = flag4; obj.Prefix(pre1); obj.stack = Stack; obj.position = vector2_1; obj.velocity = vector2_2; obj.active = true; if ((int)num1 == 90) { obj.instanced = true; obj.owner = Main.myPlayer; obj.keepTime = 600; } obj.wet = Collision.WetCollision(obj.position, obj.width, obj.height); break; } if (Main.itemLockoutTime[index7] > 0) break; if (type1 == 0) { if (index7 >= 400) break; Main.item[index7].active = false; NetMessage.SendData(21, -1, -1, "", index7, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; } bool flag6 = false; if (index7 == 400) flag6 = true; if (flag6) { Item obj = new Item(); obj.netDefaults(type1); index7 = Item.NewItem((int)vector2_1.X, (int)vector2_1.Y, obj.width, obj.height, obj.itemId, Stack, true, 0, false); } Item obj1 = Main.item[index7]; obj1.netDefaults(type1); obj1.Prefix(pre1); obj1.stack = Stack; obj1.position = vector2_1; obj1.velocity = vector2_2; obj1.active = true; obj1.owner = Main.myPlayer; if (flag6) { NetMessage.SendData(21, -1, -1, "", index7, 0.0f, 0.0f, 0.0f, 0, 0, 0); if (num20 == 0) { Main.item[index7].ownIgnore = this.whoAmI; Main.item[index7].ownTime = 100; } Main.item[index7].FindOwner(index7); break; } NetMessage.SendData(21, -1, this.whoAmI, "", index7, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)22: int number9 = (int)this.reader.ReadInt16(); int num21 = (int)this.reader.ReadByte(); if (Main.netMode == 2 && Main.item[number9].owner != this.whoAmI) break; Main.item[number9].owner = num21; Main.item[number9].keepTime = num21 != Main.myPlayer ? 0 : 15; if (Main.netMode != 2) break; Main.item[number9].owner = (int)byte.MaxValue; Main.item[number9].keepTime = 15; NetMessage.SendData(22, -1, -1, "", number9, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)23: if (Main.netMode != 1) break; int index8 = (int)this.reader.ReadInt16(); Vector2 vector2_3 = Utils.ReadVector2(this.reader); Vector2 vector2_4 = Utils.ReadVector2(this.reader); int num22 = (int)this.reader.ReadByte(); BitsByte bitsByte14 = (BitsByte)this.reader.ReadByte(); float[] numArray1 = new float[NPC.maxAI]; for (int index5 = 0; index5 < NPC.maxAI; ++index5) numArray1[index5] = !bitsByte14[index5 + 2] ? 0.0f : this.reader.ReadSingle(); int type2 = (int)this.reader.ReadInt16(); int num23 = 0; if (!bitsByte14[7]) { switch (this.reader.ReadByte()) { case (byte)2: num23 = (int)this.reader.ReadInt16(); break; case (byte)4: num23 = this.reader.ReadInt32(); break; default: num23 = (int)this.reader.ReadSByte(); break; } } int oldType = -1; NPC npc1 = Main.npc[index8]; if (!npc1.active || npc1.netID != type2) { if (npc1.active) oldType = npc1.type; npc1.active = true; npc1.netDefaults(type2); } npc1.position = vector2_3; npc1.velocity = vector2_4; npc1.target = num22; npc1.direction = bitsByte14[0] ? 1 : -1; npc1.directionY = bitsByte14[1] ? 1 : -1; npc1.spriteDirection = bitsByte14[6] ? 1 : -1; if (bitsByte14[7]) num23 = npc1.life = npc1.lifeMax; else npc1.life = num23; if (num23 <= 0) npc1.active = false; for (int index5 = 0; index5 < NPC.maxAI; ++index5) npc1.ai[index5] = numArray1[index5]; if (oldType > -1 && oldType != npc1.type) npc1.TransformVisuals(oldType, npc1.type); if (type2 == 262) NPC.plantBoss = index8; if (type2 == 245) NPC.golemBoss = index8; if (!Main.npcCatchable[npc1.type]) break; npc1.releaseOwner = (short)this.reader.ReadByte(); break; case (byte)24: int number10 = (int)this.reader.ReadInt16(); int index9 = (int)this.reader.ReadByte(); if (Main.netMode == 2) index9 = this.whoAmI; Player player7 = Main.player[index9]; Main.npc[number10].StrikeNPC(player7.inventory[player7.selectedItem].damage, player7.inventory[player7.selectedItem].knockBack, player7.direction, false, false, false); if (Main.netMode != 2) break; NetMessage.SendData(24, -1, this.whoAmI, "", number10, (float)index9, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(23, -1, -1, "", number10, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)25: int number11 = (int)this.reader.ReadByte(); if (Main.netMode == 2) number11 = this.whoAmI; Color color1 = Utils.ReadRGB(this.reader); if (Main.netMode == 2) color1 = new Color((int)byte.MaxValue, (int)byte.MaxValue, (int)byte.MaxValue); string str1 = this.reader.ReadString(); if (Main.netMode == 1) { string newText = str1; if (number11 < (int)byte.MaxValue) { newText = NameTagHandler.GenerateTag(Main.player[number11].name) + " " + str1; Main.player[number11].chatOverhead.NewMessage(str1, Main.chatLength / 2); } Main.NewText(newText, color1.R, color1.G, color1.B, false); break; } if (Main.netMode != 2) break; string str2 = str1.ToLower(); if (str2 == Lang.mp[6] || str2 == Lang.mp[21]) { string str3 = ""; for (int index5 = 0; index5 < (int)byte.MaxValue; ++index5) { if (Main.player[index5].active) str3 = !(str3 == "") ? str3 + ", " + Main.player[index5].name : Main.player[index5].name; } NetMessage.SendData(25, this.whoAmI, -1, Lang.mp[7] + " " + str3 + ".", (int)byte.MaxValue, (float)byte.MaxValue, 240f, 20f, 0, 0, 0); break; } if (str2.StartsWith("/me ")) { NetMessage.SendData(25, -1, -1, "*" + Main.player[this.whoAmI].name + " " + str1.Substring(4), (int)byte.MaxValue, 200f, 100f, 0.0f, 0, 0, 0); break; } if (str2 == Lang.mp[8]) { NetMessage.SendData(25, -1, -1, "*" + (object)Main.player[this.whoAmI].name + " " + Lang.mp[9] + " " + (string)(object)Main.rand.Next(1, 101), (int)byte.MaxValue, (float)byte.MaxValue, 240f, 20f, 0, 0, 0); break; } if (str2.StartsWith("/p ")) { int index5 = Main.player[this.whoAmI].team; Color color2 = Main.teamColor[index5]; if (index5 != 0) { for (int remoteClient = 0; remoteClient < (int)byte.MaxValue; ++remoteClient) { if (Main.player[remoteClient].team == index5) NetMessage.SendData(25, remoteClient, -1, str1.Substring(3), number11, (float)color2.R, (float)color2.G, (float)color2.B, 0, 0, 0); } break; } NetMessage.SendData(25, this.whoAmI, -1, Lang.mp[10], (int)byte.MaxValue, (float)byte.MaxValue, 240f, 20f, 0, 0, 0); break; } if ((int)Main.player[this.whoAmI].difficulty == 2) color1 = Main.hcColor; else if ((int)Main.player[this.whoAmI].difficulty == 1) color1 = Main.mcColor; NetMessage.SendData(25, -1, -1, str1, number11, (float)color1.R, (float)color1.G, (float)color1.B, 0, 0, 0); if (!Main.dedServ) break; Console.WriteLine("<" + Main.player[this.whoAmI].name + "> " + str1); break; case (byte)26: int number12 = (int)this.reader.ReadByte(); if (Main.netMode == 2 && this.whoAmI != number12 && (!Main.player[number12].hostile || !Main.player[this.whoAmI].hostile)) break; int hitDirection1 = (int)this.reader.ReadByte() - 1; int Damage1 = (int)this.reader.ReadInt16(); string str4 = this.reader.ReadString(); BitsByte bitsByte15 = (BitsByte)this.reader.ReadByte(); bool pvp = bitsByte15[0]; bool Crit = bitsByte15[1]; Main.player[number12].Hurt(Damage1, hitDirection1, pvp, true, str4, Crit); if (Main.netMode != 2) break; NetMessage.SendData(26, -1, this.whoAmI, str4, number12, (float)hitDirection1, (float)Damage1, pvp ? 1f : 0.0f, Crit ? 1 : 0, 0, 0); break; case (byte)27: int num24 = (int)this.reader.ReadInt16(); Vector2 vector2_5 = Utils.ReadVector2(this.reader); Vector2 vector2_6 = Utils.ReadVector2(this.reader); float num25 = this.reader.ReadSingle(); int num26 = (int)this.reader.ReadInt16(); int own = (int)this.reader.ReadByte(); int Type1 = (int)this.reader.ReadInt16(); BitsByte bitsByte16 = (BitsByte)this.reader.ReadByte(); float[] numArray2 = new float[Projectile.maxAI]; for (int index5 = 0; index5 < Projectile.maxAI; ++index5) numArray2[index5] = !bitsByte16[index5] ? 0.0f : this.reader.ReadSingle(); if (Main.netMode == 2) { own = this.whoAmI; if (Main.projHostile[Type1]) break; } int number13 = 1000; for (int index5 = 0; index5 < 1000; ++index5) { if (Main.projectile[index5].owner == own && Main.projectile[index5].identity == num24 && Main.projectile[index5].active) { number13 = index5; break; } } if (number13 == 1000) { for (int index5 = 0; index5 < 1000; ++index5) { if (!Main.projectile[index5].active) { number13 = index5; break; } } } Projectile projectile1 = Main.projectile[number13]; if (!projectile1.active || projectile1.type != Type1) { projectile1.SetDefaults(Type1); if (Main.netMode == 2) ++Netplay.Clients[this.whoAmI].SpamProjectile; } projectile1.identity = num24; projectile1.position = vector2_5; projectile1.velocity = vector2_6; projectile1.type = Type1; projectile1.damage = num26; projectile1.knockBack = num25; projectile1.owner = own; for (int index5 = 0; index5 < Projectile.maxAI; ++index5) projectile1.ai[index5] = numArray2[index5]; projectile1.ProjectileFixDesperation(own); if (Main.netMode != 2) break; NetMessage.SendData(27, -1, this.whoAmI, "", number13, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)28: int number14 = (int)this.reader.ReadInt16(); int Damage2 = (int)this.reader.ReadInt16(); float num27 = this.reader.ReadSingle(); int hitDirection2 = (int)this.reader.ReadByte() - 1; byte num28 = this.reader.ReadByte(); if (Main.netMode == 2) Main.npc[number14].PlayerInteraction(this.whoAmI); if (Damage2 >= 0) { Main.npc[number14].StrikeNPC(Damage2, num27, hitDirection2, (int)num28 == 1, false, true); } else { Main.npc[number14].life = 0; Main.npc[number14].HitEffect(0, 10.0); Main.npc[number14].active = false; } if (Main.netMode != 2) break; NetMessage.SendData(28, -1, this.whoAmI, "", number14, (float)Damage2, num27, (float)hitDirection2, (int)num28, 0, 0); if (Main.npc[number14].life <= 0) { NetMessage.SendData(23, -1, -1, "", number14, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; } Main.npc[number14].netUpdate = true; break; case (byte)29: int number15 = (int)this.reader.ReadInt16(); int num29 = (int)this.reader.ReadByte(); if (Main.netMode == 2) num29 = this.whoAmI; for (int index5 = 0; index5 < 1000; ++index5) { if (Main.projectile[index5].owner == num29 && Main.projectile[index5].identity == number15 && Main.projectile[index5].active) { Main.projectile[index5].Kill(); break; } } if (Main.netMode != 2) break; NetMessage.SendData(29, -1, this.whoAmI, "", number15, (float)num29, 0.0f, 0.0f, 0, 0, 0); break; case (byte)30: int number16 = (int)this.reader.ReadByte(); if (Main.netMode == 2) number16 = this.whoAmI; bool flag7 = this.reader.ReadBoolean(); Main.player[number16].hostile = flag7; if (Main.netMode != 2) break; NetMessage.SendData(30, -1, this.whoAmI, "", number16, 0.0f, 0.0f, 0.0f, 0, 0, 0); string str5 = " " + Lang.mp[flag7 ? 11 : 12]; Color color3 = Main.teamColor[Main.player[number16].team]; NetMessage.SendData(25, -1, -1, Main.player[number16].name + str5, (int)byte.MaxValue, (float)color3.R, (float)color3.G, (float)color3.B, 0, 0, 0); break; case (byte)31: if (Main.netMode != 2) break; int X1 = (int)this.reader.ReadInt16(); int Y1 = (int)this.reader.ReadInt16(); int chest1 = Chest.FindChest(X1, Y1); if (chest1 <= -1 || Chest.UsingChest(chest1) != -1) break; for (int index5 = 0; index5 < 40; ++index5) NetMessage.SendData(32, this.whoAmI, -1, "", chest1, (float)index5, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(33, this.whoAmI, -1, "", chest1, 0.0f, 0.0f, 0.0f, 0, 0, 0); Main.player[this.whoAmI].chest = chest1; if (Main.myPlayer == this.whoAmI) Main.recBigList = false; Recipe.FindRecipes(); NetMessage.SendData(80, -1, this.whoAmI, "", this.whoAmI, (float)chest1, 0.0f, 0.0f, 0, 0, 0); if ((int)Main.tile[X1, Y1].frameX < 36 || (int)Main.tile[X1, Y1].frameX >= 72) break; AchievementsHelper.HandleSpecialEvent(Main.player[this.whoAmI], 16); break; case (byte)32: int index10 = (int)this.reader.ReadInt16(); int index11 = (int)this.reader.ReadByte(); int num30 = (int)this.reader.ReadInt16(); int pre2 = (int)this.reader.ReadByte(); int type3 = (int)this.reader.ReadInt16(); if (Main.chest[index10] == null) Main.chest[index10] = new Chest(false); if (Main.chest[index10].item[index11] == null) Main.chest[index10].item[index11] = new Item(); Main.chest[index10].item[index11].netDefaults(type3); Main.chest[index10].item[index11].Prefix(pre2); Main.chest[index10].item[index11].stack = num30; Recipe.FindRecipes(); break; case (byte)33: int num31 = (int)this.reader.ReadInt16(); int num32 = (int)this.reader.ReadInt16(); int num33 = (int)this.reader.ReadInt16(); int num34 = (int)this.reader.ReadByte(); string text1 = string.Empty; if (num34 != 0) { if (num34 <= 20) text1 = this.reader.ReadString(); else if (num34 != (int)byte.MaxValue) num34 = 0; } if (Main.netMode == 1) { Player player8 = Main.player[Main.myPlayer]; if (player8.chest == -1) { Main.playerInventory = true; Main.PlaySound(10, -1, -1, 1); } else if (player8.chest != num31 && num31 != -1) { Main.playerInventory = true; Main.PlaySound(12, -1, -1, 1); Main.recBigList = false; } else if (player8.chest != -1 && num31 == -1) { Main.PlaySound(11, -1, -1, 1); Main.recBigList = false; } player8.chest = num31; player8.chestX = num32; player8.chestY = num33; Recipe.FindRecipes(); break; } if (num34 != 0) { int number6 = Main.player[this.whoAmI].chest; Chest chest2 = Main.chest[number6]; chest2.name = text1; NetMessage.SendData(69, -1, this.whoAmI, text1, number6, (float)chest2.x, (float)chest2.y, 0.0f, 0, 0, 0); } Main.player[this.whoAmI].chest = num31; Recipe.FindRecipes(); NetMessage.SendData(80, -1, this.whoAmI, "", this.whoAmI, (float)num31, 0.0f, 0.0f, 0, 0, 0); break; case (byte)34: byte num35 = this.reader.ReadByte(); int index12 = (int)this.reader.ReadInt16(); int index13 = (int)this.reader.ReadInt16(); int style1 = (int)this.reader.ReadInt16(); if (Main.netMode == 2) { if ((int)num35 == 0) { int number5_1 = WorldGen.PlaceChest(index12, index13, (ushort)21, false, style1); if (number5_1 == -1) { NetMessage.SendData(34, this.whoAmI, -1, "", (int)num35, (float)index12, (float)index13, (float)style1, number5_1, 0, 0); Item.NewItem(index12 * 16, index13 * 16, 32, 32, Chest.chestItemSpawn[style1], 1, true, 0, false); break; } NetMessage.SendData(34, -1, -1, "", (int)num35, (float)index12, (float)index13, (float)style1, number5_1, 0, 0); break; } if ((int)num35 == 2) { int number5_1 = WorldGen.PlaceChest(index12, index13, (ushort)88, false, style1); if (number5_1 == -1) { NetMessage.SendData(34, this.whoAmI, -1, "", (int)num35, (float)index12, (float)index13, (float)style1, number5_1, 0, 0); Item.NewItem(index12 * 16, index13 * 16, 32, 32, Chest.dresserItemSpawn[style1], 1, true, 0, false); break; } NetMessage.SendData(34, -1, -1, "", (int)num35, (float)index12, (float)index13, (float)style1, number5_1, 0, 0); break; } Tile tile = Main.tile[index12, index13]; if ((int)tile.type == 21 && (int)num35 == 1) { if ((int)tile.frameX % 36 != 0) --index12; if ((int)tile.frameY % 36 != 0) --index13; int chest2 = Chest.FindChest(index12, index13); WorldGen.KillTile(index12, index13, false, false, false); if (tile.active()) break; NetMessage.SendData(34, -1, -1, "", (int)num35, (float)index12, (float)index13, 0.0f, chest2, 0, 0); break; } if ((int)tile.type != 88 || (int)num35 != 3) break; int num19 = index12 - (int)tile.frameX % 54 / 18; if ((int)tile.frameY % 36 != 0) --index13; int chest3 = Chest.FindChest(num19, index13); WorldGen.KillTile(num19, index13, false, false, false); if (tile.active()) break; NetMessage.SendData(34, -1, -1, "", (int)num35, (float)num19, (float)index13, 0.0f, chest3, 0, 0); break; } int id = (int)this.reader.ReadInt16(); if ((int)num35 == 0) { if (id == -1) { WorldGen.KillTile(index12, index13, false, false, false); break; } WorldGen.PlaceChestDirect(index12, index13, (ushort)21, style1, id); break; } if ((int)num35 == 2) { if (id == -1) { WorldGen.KillTile(index12, index13, false, false, false); break; } WorldGen.PlaceDresserDirect(index12, index13, (ushort)88, style1, id); break; } Chest.DestroyChestDirect(index12, index13, id); WorldGen.KillTile(index12, index13, false, false, false); break; case (byte)35: int number17 = (int)this.reader.ReadByte(); if (Main.netMode == 2) number17 = this.whoAmI; int healAmount1 = (int)this.reader.ReadInt16(); if (number17 != Main.myPlayer || Main.ServerSideCharacter) Main.player[number17].HealEffect(healAmount1, true); if (Main.netMode != 2) break; NetMessage.SendData(35, -1, this.whoAmI, "", number17, (float)healAmount1, 0.0f, 0.0f, 0, 0, 0); break; case (byte)36: int number18 = (int)this.reader.ReadByte(); if (Main.netMode == 2) number18 = this.whoAmI; Player player9 = Main.player[number18]; player9.zone1 = (BitsByte)this.reader.ReadByte(); player9.zone2 = (BitsByte)this.reader.ReadByte(); if (Main.netMode != 2) break; NetMessage.SendData(36, -1, this.whoAmI, "", number18, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)37: if (Main.netMode != 1) break; if (Main.autoPass) { NetMessage.SendData(38, -1, -1, Netplay.ServerPassword, 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); Main.autoPass = false; break; } Netplay.ServerPassword = ""; Main.menuMode = 31; break; case (byte)38: if (Main.netMode != 2) break; if (this.reader.ReadString() == Netplay.ServerPassword) { Netplay.Clients[this.whoAmI].State = 1; NetMessage.SendData(3, this.whoAmI, -1, "", 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; } NetMessage.SendData(2, this.whoAmI, -1, Lang.mp[1], 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)39: if (Main.netMode != 1) break; int number19 = (int)this.reader.ReadInt16(); Main.item[number19].owner = (int)byte.MaxValue; NetMessage.SendData(22, -1, -1, "", number19, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)40: int number20 = (int)this.reader.ReadByte(); if (Main.netMode == 2) number20 = this.whoAmI; int num36 = (int)this.reader.ReadInt16(); Main.player[number20].talkNPC = num36; if (Main.netMode != 2) break; NetMessage.SendData(40, -1, this.whoAmI, "", number20, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)41: int number21 = (int)this.reader.ReadByte(); if (Main.netMode == 2) number21 = this.whoAmI; Player player10 = Main.player[number21]; float num37 = this.reader.ReadSingle(); int num38 = (int)this.reader.ReadInt16(); player10.itemRotation = num37; player10.itemAnimation = num38; player10.channel = player10.inventory[player10.selectedItem].channel; if (Main.netMode != 2) break; NetMessage.SendData(41, -1, this.whoAmI, "", number21, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)42: int index14 = (int)this.reader.ReadByte(); if (Main.netMode == 2) index14 = this.whoAmI; else if (Main.myPlayer == index14 && !Main.ServerSideCharacter) break; int num39 = (int)this.reader.ReadInt16(); int num40 = (int)this.reader.ReadInt16(); Main.player[index14].statMana = num39; Main.player[index14].statManaMax = num40; break; case (byte)43: int number22 = (int)this.reader.ReadByte(); if (Main.netMode == 2) number22 = this.whoAmI; int manaAmount = (int)this.reader.ReadInt16(); if (number22 != Main.myPlayer) Main.player[number22].ManaEffect(manaAmount); if (Main.netMode != 2) break; NetMessage.SendData(43, -1, this.whoAmI, "", number22, (float)manaAmount, 0.0f, 0.0f, 0, 0, 0); break; case (byte)44: int number23 = (int)this.reader.ReadByte(); if (Main.netMode == 2) number23 = this.whoAmI; int hitDirection3 = (int)this.reader.ReadByte() - 1; int num41 = (int)this.reader.ReadInt16(); byte num42 = this.reader.ReadByte(); string str6 = this.reader.ReadString(); Main.player[number23].KillMe((double)num41, hitDirection3, (int)num42 == 1, str6); if (Main.netMode != 2) break; NetMessage.SendData(44, -1, this.whoAmI, str6, number23, (float)hitDirection3, (float)num41, (float)num42, 0, 0, 0); break; case (byte)45: int number24 = (int)this.reader.ReadByte(); if (Main.netMode == 2) number24 = this.whoAmI; int index15 = (int)this.reader.ReadByte(); Player player11 = Main.player[number24]; int num43 = player11.team; player11.team = index15; Color color4 = Main.teamColor[index15]; if (Main.netMode != 2) break; NetMessage.SendData(45, -1, this.whoAmI, "", number24, 0.0f, 0.0f, 0.0f, 0, 0, 0); string str7 = " " + Lang.mp[13 + index15]; if (index15 == 5) str7 = " " + Lang.mp[22]; for (int remoteClient = 0; remoteClient < (int)byte.MaxValue; ++remoteClient) { if (remoteClient == this.whoAmI || num43 > 0 && Main.player[remoteClient].team == num43 || index15 > 0 && Main.player[remoteClient].team == index15) NetMessage.SendData(25, remoteClient, -1, player11.name + str7, (int)byte.MaxValue, (float)color4.R, (float)color4.G, (float)color4.B, 0, 0, 0); } break; case (byte)46: if (Main.netMode != 2) break; int number25 = Sign.ReadSign((int)this.reader.ReadInt16(), (int)this.reader.ReadInt16(), true); if (number25 < 0) break; NetMessage.SendData(47, this.whoAmI, -1, "", number25, (float)this.whoAmI, 0.0f, 0.0f, 0, 0, 0); break; case (byte)47: int index16 = (int)this.reader.ReadInt16(); int num44 = (int)this.reader.ReadInt16(); int num45 = (int)this.reader.ReadInt16(); string text2 = this.reader.ReadString(); string str8 = (string)null; if (Main.sign[index16] != null) str8 = Main.sign[index16].text; Main.sign[index16] = new Sign(); Main.sign[index16].x = num44; Main.sign[index16].y = num45; Sign.TextSign(index16, text2); int num46 = (int)this.reader.ReadByte(); if (Main.netMode == 2 && str8 != text2) { num46 = this.whoAmI; NetMessage.SendData(47, -1, this.whoAmI, "", index16, (float)num46, 0.0f, 0.0f, 0, 0, 0); } if (Main.netMode != 1 || num46 != Main.myPlayer || Main.sign[index16] == null) break; Main.playerInventory = false; Main.player[Main.myPlayer].talkNPC = -1; Main.npcChatCornerItem = 0; Main.editSign = false; Main.PlaySound(10, -1, -1, 1); Main.player[Main.myPlayer].sign = index16; Main.npcChatText = Main.sign[index16].text; break; case (byte)48: int i1 = (int)this.reader.ReadInt16(); int j1 = (int)this.reader.ReadInt16(); byte num47 = this.reader.ReadByte(); byte num48 = this.reader.ReadByte(); if (Main.netMode == 2 && Netplay.spamCheck) { int index5 = this.whoAmI; int num19 = (int)((double)Main.player[index5].position.X + (double)(Main.player[index5].width / 2)); int num49 = (int)((double)Main.player[index5].position.Y + (double)(Main.player[index5].height / 2)); int num50 = 10; int num51 = num19 - num50; int num52 = num19 + num50; int num53 = num49 - num50; int num54 = num49 + num50; if (i1 < num51 || i1 > num52 || (j1 < num53 || j1 > num54)) { NetMessage.BootPlayer(this.whoAmI, "Cheating attempt detected: Liquid spam"); break; } } if (Main.tile[i1, j1] == null) Main.tile[i1, j1] = new Tile(); lock (Main.tile[i1, j1]) { Main.tile[i1, j1].liquid = num47; Main.tile[i1, j1].liquidType((int)num48); if (Main.netMode != 2) break; WorldGen.SquareTileFrame(i1, j1, true); break; } case (byte)49: if (Netplay.Connection.State != 6) break; Netplay.Connection.State = 10; Main.ActivePlayerFileData.StartPlayTimer(); Player.EnterWorld(Main.player[Main.myPlayer]); Main.player[Main.myPlayer].Spawn(); break; case (byte)50: int number26 = (int)this.reader.ReadByte(); if (Main.netMode == 2) number26 = this.whoAmI; else if (number26 == Main.myPlayer && !Main.ServerSideCharacter) break; Player player12 = Main.player[number26]; for (int index5 = 0; index5 < 22; ++index5) { player12.buffType[index5] = (int)this.reader.ReadByte(); player12.buffTime[index5] = player12.buffType[index5] <= 0 ? 0 : 60; } if (Main.netMode != 2) break; NetMessage.SendData(50, -1, this.whoAmI, "", number26, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)51: byte num55 = this.reader.ReadByte(); byte num56 = this.reader.ReadByte(); switch (num56) { case (byte)1: NPC.SpawnSkeletron(); return; case (byte)2: if (Main.netMode == 2) { NetMessage.SendData(51, -1, this.whoAmI, "", (int)num55, (float)num56, 0.0f, 0.0f, 0, 0, 0); return; } Main.PlaySound(2, (int)Main.player[(int)num55].position.X, (int)Main.player[(int)num55].position.Y, 1); return; case (byte)3: if (Main.netMode != 2) return; Main.Sundialing(); return; case (byte)4: Main.npc[(int)num55].BigMimicSpawnSmoke(); return; default: return; } case (byte)52: int num57 = (int)this.reader.ReadByte(); int num58 = (int)this.reader.ReadInt16(); int num59 = (int)this.reader.ReadInt16(); if (num57 == 1) { Chest.Unlock(num58, num59); if (Main.netMode == 2) { NetMessage.SendData(52, -1, this.whoAmI, "", 0, (float)num57, (float)num58, (float)num59, 0, 0, 0); NetMessage.SendTileSquare(-1, num58, num59, 2); } } if (num57 != 2) break; WorldGen.UnlockDoor(num58, num59); if (Main.netMode != 2) break; NetMessage.SendData(52, -1, this.whoAmI, "", 0, (float)num57, (float)num58, (float)num59, 0, 0, 0); NetMessage.SendTileSquare(-1, num58, num59, 2); break; case (byte)53: int number27 = (int)this.reader.ReadInt16(); int type4 = (int)this.reader.ReadByte(); int time1 = (int)this.reader.ReadInt16(); Main.npc[number27].AddBuff(type4, time1, true); if (Main.netMode != 2) break; NetMessage.SendData(54, -1, -1, "", number27, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)54: if (Main.netMode != 1) break; int index17 = (int)this.reader.ReadInt16(); NPC npc2 = Main.npc[index17]; for (int index5 = 0; index5 < 5; ++index5) { npc2.buffType[index5] = (int)this.reader.ReadByte(); npc2.buffTime[index5] = (int)this.reader.ReadInt16(); } break; case (byte)55: int index18 = (int)this.reader.ReadByte(); int type5 = (int)this.reader.ReadByte(); int time1_1 = (int)this.reader.ReadInt16(); if (Main.netMode == 2 && index18 != this.whoAmI && !Main.pvpBuff[type5]) break; if (Main.netMode == 1 && index18 == Main.myPlayer) { Main.player[index18].AddBuff(type5, time1_1, true); break; } if (Main.netMode != 2) break; NetMessage.SendData(55, index18, -1, "", index18, (float)type5, (float)time1_1, 0.0f, 0, 0, 0); break; case (byte)56: int number28 = (int)this.reader.ReadInt16(); if (number28 < 0 || number28 >= 200) break; string str9 = this.reader.ReadString(); if (Main.netMode == 1) { Main.npc[number28].displayName = str9; break; } if (Main.netMode != 2) break; NetMessage.SendData(56, this.whoAmI, -1, Main.npc[number28].displayName, number28, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)57: if (Main.netMode != 1) break; WorldGen.tGood = this.reader.ReadByte(); WorldGen.tEvil = this.reader.ReadByte(); WorldGen.tBlood = this.reader.ReadByte(); break; case (byte)58: int index19 = (int)this.reader.ReadByte(); if (Main.netMode == 2) index19 = this.whoAmI; float number2_1 = this.reader.ReadSingle(); if (Main.netMode == 2) { NetMessage.SendData(58, -1, this.whoAmI, "", this.whoAmI, number2_1, 0.0f, 0.0f, 0, 0, 0); break; } Player player13 = Main.player[index19]; Main.harpNote = number2_1; int Style = 26; if (player13.inventory[player13.selectedItem].itemId == 507) Style = 35; Main.PlaySound(2, (int)player13.position.X, (int)player13.position.Y, Style); break; case (byte)59: int num60 = (int)this.reader.ReadInt16(); int j2 = (int)this.reader.ReadInt16(); Wiring.HitSwitch(num60, j2); if (Main.netMode != 2) break; NetMessage.SendData(59, -1, this.whoAmI, "", num60, (float)j2, 0.0f, 0.0f, 0, 0, 0); break; case (byte)60: int n = (int)this.reader.ReadInt16(); int x1 = (int)this.reader.ReadInt16(); int y3 = (int)this.reader.ReadInt16(); byte num61 = this.reader.ReadByte(); if (n >= 200) { NetMessage.BootPlayer(this.whoAmI, "cheating attempt detected: Invalid kick-out"); break; } if (Main.netMode == 1) { Main.npc[n].homeless = (int)num61 == 1; Main.npc[n].homeTileX = x1; Main.npc[n].homeTileY = y3; break; } if ((int)num61 == 0) { WorldGen.kickOut(n); break; } WorldGen.moveRoom(x1, y3, n); break; case (byte)61: int plr = this.reader.ReadInt32(); int Type2 = this.reader.ReadInt32(); if (Main.netMode != 2) break; if (Type2 >= 0 && Type2 < 540 && NPCID.Sets.MPAllowedEnemies[Type2]) { if (NPC.AnyNPCs(Type2)) break; NPC.SpawnOnPlayer(plr, Type2); break; } if (Type2 == -4) { if (Main.dayTime) break; NetMessage.SendData(25, -1, -1, Lang.misc[31], (int)byte.MaxValue, 50f, (float)byte.MaxValue, 130f, 0, 0, 0); Main.startPumpkinMoon(); NetMessage.SendData(7, -1, -1, "", 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(78, -1, -1, "", 0, 1f, 2f, 1f, 0, 0, 0); break; } if (Type2 == -5) { if (Main.dayTime) break; NetMessage.SendData(25, -1, -1, Lang.misc[34], (int)byte.MaxValue, 50f, (float)byte.MaxValue, 130f, 0, 0, 0); Main.startSnowMoon(); NetMessage.SendData(7, -1, -1, "", 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(78, -1, -1, "", 0, 1f, 1f, 1f, 0, 0, 0); break; } if (Type2 == -6) { if (!Main.dayTime || Main.eclipse) break; NetMessage.SendData(25, -1, -1, Lang.misc[20], (int)byte.MaxValue, 50f, (float)byte.MaxValue, 130f, 0, 0, 0); Main.eclipse = true; NetMessage.SendData(7, -1, -1, "", 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; } if (Type2 == -7) { NetMessage.SendData(25, -1, -1, "martian moon toggled", (int)byte.MaxValue, 50f, (float)byte.MaxValue, 130f, 0, 0, 0); Main.invasionDelay = 0; Main.StartInvasion(4); NetMessage.SendData(7, -1, -1, "", 0, 0.0f, 0.0f, 0.0f, 0, 0, 0); NetMessage.SendData(78, -1, -1, "", 0, 1f, (float)(Main.invasionType + 2), 0.0f, 0, 0, 0); break; } if (Type2 >= 0) break; int type6 = 1; if (Type2 > -5) type6 = -Type2; if (type6 > 0 && Main.invasionType == 0) { Main.invasionDelay = 0; Main.StartInvasion(type6); } NetMessage.SendData(78, -1, -1, "", 0, 1f, (float)(Main.invasionType + 2), 0.0f, 0, 0, 0); break; case (byte)62: int number29 = (int)this.reader.ReadByte(); int num62 = (int)this.reader.ReadByte(); if (Main.netMode == 2) number29 = this.whoAmI; if (num62 == 1) Main.player[number29].NinjaDodge(); if (num62 == 2) Main.player[number29].ShadowDodge(); if (Main.netMode != 2) break; NetMessage.SendData(62, -1, this.whoAmI, "", number29, (float)num62, 0.0f, 0.0f, 0, 0, 0); break; case (byte)63: int num63 = (int)this.reader.ReadInt16(); int y4 = (int)this.reader.ReadInt16(); byte color5 = this.reader.ReadByte(); WorldGen.paintTile(num63, y4, color5, false); if (Main.netMode != 2) break; NetMessage.SendData(63, -1, this.whoAmI, "", num63, (float)y4, (float)color5, 0.0f, 0, 0, 0); break; case (byte)64: int num64 = (int)this.reader.ReadInt16(); int y5 = (int)this.reader.ReadInt16(); byte color6 = this.reader.ReadByte(); WorldGen.paintWall(num64, y5, color6, false); if (Main.netMode != 2) break; NetMessage.SendData(64, -1, this.whoAmI, "", num64, (float)y5, (float)color6, 0.0f, 0, 0, 0); break; case (byte)65: BitsByte bitsByte17 = (BitsByte)this.reader.ReadByte(); int index20 = (int)this.reader.ReadInt16(); if (Main.netMode == 2) index20 = this.whoAmI; Vector2 vector2_7 = Utils.ReadVector2(this.reader); int num65 = 0; int num66 = 0; if (bitsByte17[0]) ++num65; if (bitsByte17[1]) num65 += 2; if (bitsByte17[2]) ++num66; if (bitsByte17[3]) num66 += 2; if (num65 == 0) Main.player[index20].Teleport(vector2_7, num66, 0); else if (num65 == 1) Main.npc[index20].Teleport(vector2_7, num66, 0); else if (num65 == 2) { Main.player[index20].Teleport(vector2_7, num66, 0); if (Main.netMode == 2) { RemoteClient.CheckSection(this.whoAmI, vector2_7, 1); NetMessage.SendData(65, -1, -1, "", 0, (float)index20, vector2_7.X, vector2_7.Y, num66, 0, 0); int index5 = -1; float num19 = 9999f; for (int index6 = 0; index6 < (int)byte.MaxValue; ++index6) { if (Main.player[index6].active && index6 != this.whoAmI) { Vector2 vector2_8 = Main.player[index6].position - Main.player[this.whoAmI].position; if ((double)vector2_8.Length() < (double)num19) { num19 = vector2_8.Length(); index5 = index6; } } } if (index5 >= 0) NetMessage.SendData(25, -1, -1, Main.player[this.whoAmI].name + " has teleported to " + Main.player[index5].name, (int)byte.MaxValue, 250f, 250f, 0.0f, 0, 0, 0); } } if (Main.netMode != 2 || num65 != 0) break; NetMessage.SendData(65, -1, this.whoAmI, "", 0, (float)index20, vector2_7.X, vector2_7.Y, num66, 0, 0); break; case (byte)66: int number30 = (int)this.reader.ReadByte(); int healAmount2 = (int)this.reader.ReadInt16(); if (healAmount2 <= 0) break; Player player14 = Main.player[number30]; player14.statLife += healAmount2; if (player14.statLife > player14.statLifeMax2) player14.statLife = player14.statLifeMax2; player14.HealEffect(healAmount2, false); if (Main.netMode != 2) break; NetMessage.SendData(66, -1, this.whoAmI, "", number30, (float)healAmount2, 0.0f, 0.0f, 0, 0, 0); break; case (byte)68: this.reader.ReadString(); break; case (byte)69: int number31 = (int)this.reader.ReadInt16(); int X2 = (int)this.reader.ReadInt16(); int Y2 = (int)this.reader.ReadInt16(); if (Main.netMode == 1) { if (number31 < 0 || number31 >= 1000) break; Chest chest2 = Main.chest[number31]; if (chest2 == null) { chest2 = new Chest(false); chest2.x = X2; chest2.y = Y2; Main.chest[number31] = chest2; } else if (chest2.x != X2 || chest2.y != Y2) break; chest2.name = this.reader.ReadString(); break; } if (number31 < -1 || number31 >= 1000) break; if (number31 == -1) { number31 = Chest.FindChest(X2, Y2); if (number31 == -1) break; } Chest chest4 = Main.chest[number31]; if (chest4.x != X2 || chest4.y != Y2) break; NetMessage.SendData(69, this.whoAmI, -1, chest4.name, number31, (float)X2, (float)Y2, 0.0f, 0, 0, 0); break; case (byte)70: if (Main.netMode != 2) break; int i2 = (int)this.reader.ReadInt16(); int who = (int)this.reader.ReadByte(); if (Main.netMode == 2) who = this.whoAmI; if (i2 >= 200 || i2 < 0) break; NPC.CatchNPC(i2, who); break; case (byte)71: if (Main.netMode != 2) break; NPC.ReleaseNPC(this.reader.ReadInt32(), this.reader.ReadInt32(), (int)this.reader.ReadInt16(), (int)this.reader.ReadByte(), this.whoAmI); break; case (byte)72: if (Main.netMode != 1) break; for (int index5 = 0; index5 < 40; ++index5) Main.travelShop[index5] = (int)this.reader.ReadInt16(); break; case (byte)73: Main.player[this.whoAmI].TeleportationPotion(); break; case (byte)74: if (Main.netMode != 1) break; Main.anglerQuest = (int)this.reader.ReadByte(); Main.anglerQuestFinished = this.reader.ReadBoolean(); break; case (byte)75: if (Main.netMode != 2) break; string str10 = Main.player[this.whoAmI].name; if (Main.anglerWhoFinishedToday.Contains(str10)) break; Main.anglerWhoFinishedToday.Add(str10); break; case (byte)76: int number32 = (int)this.reader.ReadByte(); if (number32 == Main.myPlayer && !Main.ServerSideCharacter) break; if (Main.netMode == 2) number32 = this.whoAmI; Main.player[number32].anglerQuestsFinished = this.reader.ReadInt32(); if (Main.netMode != 2) break; NetMessage.SendData(76, -1, this.whoAmI, "", number32, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)77: Animation.NewTemporaryAnimation((int)this.reader.ReadInt16(), this.reader.ReadUInt16(), (int)this.reader.ReadInt16(), (int)this.reader.ReadInt16()); break; case (byte)78: if (Main.netMode != 1) break; Main.ReportInvasionProgress((int)this.reader.ReadInt16(), (int)this.reader.ReadInt16(), (int)this.reader.ReadSByte(), (int)this.reader.ReadSByte()); break; case (byte)79: int x2 = (int)this.reader.ReadInt16(); int y6 = (int)this.reader.ReadInt16(); short num67 = this.reader.ReadInt16(); int style2 = (int)this.reader.ReadByte(); int num68 = (int)this.reader.ReadByte(); int random = (int)this.reader.ReadSByte(); int direction2 = !this.reader.ReadBoolean() ? -1 : 1; if (Main.netMode == 2) { ++Netplay.Clients[this.whoAmI].SpamAddBlock; if (!WorldGen.InWorld(x2, y6, 10) || !Netplay.Clients[this.whoAmI].TileSections[Netplay.GetSectionX(x2), Netplay.GetSectionY(y6)]) break; } WorldGen.PlaceObject(x2, y6, (int)num67, false, style2, num68, random, direction2); if (Main.netMode != 2) break; NetMessage.SendObjectPlacment(this.whoAmI, x2, y6, (int)num67, style2, num68, random, direction2); break; case (byte)80: if (Main.netMode != 1) break; int index21 = (int)this.reader.ReadByte(); int num69 = (int)this.reader.ReadInt16(); if (num69 < -3 || num69 >= 1000) break; Main.player[index21].chest = num69; Recipe.FindRecipes(); break; case (byte)81: if (Main.netMode != 1) break; CombatText.NewText(new Rectangle((int)this.reader.ReadSingle(), (int)this.reader.ReadSingle(), 0, 0), Utils.ReadRGB(this.reader), this.reader.ReadString(), false, false); break; case (byte)82: NetManager.Instance.Read(this.reader, this.whoAmI); break; case (byte)83: if (Main.netMode != 1) break; int index22 = (int)this.reader.ReadInt16(); int num70 = this.reader.ReadInt32(); if (index22 < 0 || index22 >= 251) break; NPC.killCount[index22] = num70; break; case (byte)84: byte num71 = this.reader.ReadByte(); float num72 = this.reader.ReadSingle(); Main.player[(int)num71].stealth = num72; if (Main.netMode != 2) break; NetMessage.SendData(84, -1, this.whoAmI, "", (int)num71, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)85: int num73 = this.whoAmI; byte num74 = this.reader.ReadByte(); if (Main.netMode != 2 || num73 >= (int)byte.MaxValue || (int)num74 >= 58) break; Chest.ServerPlaceItem(this.whoAmI, (int)num74); break; case (byte)86: if (Main.netMode != 1) break; int key1 = this.reader.ReadInt32(); if (!this.reader.ReadBoolean()) { TileEntity tileEntity; if (!TileEntity.ByID.TryGetValue(key1, out tileEntity) || !(tileEntity is TETrainingDummy) && !(tileEntity is TEItemFrame)) break; TileEntity.ByID.Remove(key1); TileEntity.ByPosition.Remove(tileEntity.Position); break; } TileEntity tileEntity1 = TileEntity.Read(this.reader); TileEntity.ByID[tileEntity1.ID] = tileEntity1; TileEntity.ByPosition[tileEntity1.Position] = tileEntity1; break; case (byte)87: if (Main.netMode != 2) break; int num75 = (int)this.reader.ReadInt16(); int num76 = (int)this.reader.ReadInt16(); int num77 = (int)this.reader.ReadByte(); if (num75 < 0 || num75 >= Main.maxTilesX || (num76 < 0 || num76 >= Main.maxTilesY) || TileEntity.ByPosition.ContainsKey(new Point16(num75, num76))) break; switch (num77) { case 0: if (!TETrainingDummy.ValidTile(num75, num76)) return; TETrainingDummy.Place(num75, num76); return; case 1: if (!TEItemFrame.ValidTile(num75, num76)) return; NetMessage.SendData(86, -1, -1, "", TEItemFrame.Place(num75, num76), (float)num75, (float)num76, 0.0f, 0, 0, 0); return; default: return; } case (byte)88: if (Main.netMode != 1) break; int index23 = (int)this.reader.ReadInt16(); if (index23 < 0 || index23 > 400) break; Item obj2 = Main.item[index23]; BitsByte bitsByte18 = (BitsByte)this.reader.ReadByte(); if (bitsByte18[0]) obj2.color.PackedValue = this.reader.ReadUInt32(); if (bitsByte18[1]) obj2.damage = (int)this.reader.ReadUInt16(); if (bitsByte18[2]) obj2.knockBack = this.reader.ReadSingle(); if (bitsByte18[3]) obj2.useAnimation = (int)this.reader.ReadUInt16(); if (bitsByte18[4]) obj2.useTime = (int)this.reader.ReadUInt16(); if (bitsByte18[5]) obj2.shoot = (int)this.reader.ReadInt16(); if (bitsByte18[6]) obj2.shootSpeed = this.reader.ReadSingle(); if (!bitsByte18[7]) break; bitsByte18 = (BitsByte)this.reader.ReadByte(); if (bitsByte18[0]) obj2.width = (int)this.reader.ReadInt16(); if (bitsByte18[1]) obj2.height = (int)this.reader.ReadInt16(); if (!bitsByte18[2]) break; obj2.scale = this.reader.ReadSingle(); break; case (byte)89: if (Main.netMode != 2) break; TEItemFrame.TryPlacing((int)this.reader.ReadInt16(), (int)this.reader.ReadInt16(), (int)this.reader.ReadInt16(), (int)this.reader.ReadByte(), (int)this.reader.ReadInt16()); break; case (byte)91: if (Main.netMode != 1) break; int key2 = this.reader.ReadInt32(); int type7 = (int)this.reader.ReadByte(); if (type7 == (int)byte.MaxValue) { if (!EmoteBubble.byID.ContainsKey(key2)) break; EmoteBubble.byID.Remove(key2); break; } int meta = (int)this.reader.ReadUInt16(); int time2 = (int)this.reader.ReadByte(); int emotion = (int)this.reader.ReadByte(); int num78 = 0; if (emotion < 0) num78 = (int)this.reader.ReadInt16(); WorldUIAnchor bubbleAnchor = EmoteBubble.DeserializeNetAnchor(type7, meta); lock (EmoteBubble.byID) { if (!EmoteBubble.byID.ContainsKey(key2)) { EmoteBubble.byID[key2] = new EmoteBubble(emotion, bubbleAnchor, time2); } else { EmoteBubble.byID[key2].lifeTime = time2; EmoteBubble.byID[key2].lifeTimeStart = time2; EmoteBubble.byID[key2].emote = emotion; EmoteBubble.byID[key2].anchor = bubbleAnchor; } EmoteBubble.byID[key2].ID = key2; EmoteBubble.byID[key2].metadata = num78; break; } case (byte)92: int number33 = (int)this.reader.ReadInt16(); float num79 = this.reader.ReadSingle(); float num80 = this.reader.ReadSingle(); float num81 = this.reader.ReadSingle(); if (Main.netMode == 1) { Main.npc[number33].moneyPing(new Vector2(num80, num81)); Main.npc[number33].extraValue = num79; break; } Main.npc[number33].extraValue += num79; NetMessage.SendData(92, -1, -1, "", number33, Main.npc[number33].extraValue, num80, num81, 0, 0, 0); break; case (byte)95: if (Main.netMode != 2) break; ushort num82 = this.reader.ReadUInt16(); if ((int)num82 < 0 || (int)num82 >= 1000) break; Projectile projectile2 = Main.projectile[(int)num82]; if (projectile2.type != 602) break; projectile2.Kill(); if (Main.netMode == 0) break; NetMessage.SendData(29, -1, -1, "", projectile2.whoAmI, (float)projectile2.owner, 0.0f, 0.0f, 0, 0, 0); break; case (byte)96: int index24 = (int)this.reader.ReadByte(); Player player15 = Main.player[index24]; int extraInfo1 = (int)this.reader.ReadInt16(); Vector2 newPos1 = Utils.ReadVector2(this.reader); Vector2 vector2_9 = Utils.ReadVector2(this.reader); int num83 = extraInfo1 + (extraInfo1 % 2 == 0 ? 1 : -1); player15.lastPortalColorIndex = num83; player15.Teleport(newPos1, 4, extraInfo1); player15.velocity = vector2_9; break; case (byte)97: if (Main.netMode != 1) break; AchievementsHelper.NotifyNPCKilledDirect(Main.player[Main.myPlayer], (int)this.reader.ReadInt16()); break; case (byte)98: if (Main.netMode != 1) break; AchievementsHelper.NotifyProgressionEvent((int)this.reader.ReadInt16()); break; case (byte)99: int number34 = (int)this.reader.ReadByte(); if (Main.netMode == 2) number34 = this.whoAmI; Main.player[number34].MinionTargetPoint = Utils.ReadVector2(this.reader); if (Main.netMode != 2) break; NetMessage.SendData(99, -1, this.whoAmI, "", number34, 0.0f, 0.0f, 0.0f, 0, 0, 0); break; case (byte)100: int index25 = (int)this.reader.ReadUInt16(); NPC npc3 = Main.npc[index25]; int extraInfo2 = (int)this.reader.ReadInt16(); Vector2 newPos2 = Utils.ReadVector2(this.reader); Vector2 vector2_10 = Utils.ReadVector2(this.reader); int num84 = extraInfo2 + (extraInfo2 % 2 == 0 ? 1 : -1); npc3.lastPortalColorIndex = num84; npc3.Teleport(newPos2, 4, extraInfo2); npc3.velocity = vector2_10; break; case (byte)101: if (Main.netMode == 2) break; NPC.ShieldStrengthTowerSolar = (int)this.reader.ReadUInt16(); NPC.ShieldStrengthTowerVortex = (int)this.reader.ReadUInt16(); NPC.ShieldStrengthTowerNebula = (int)this.reader.ReadUInt16(); NPC.ShieldStrengthTowerStardust = (int)this.reader.ReadUInt16(); if (NPC.ShieldStrengthTowerSolar < 0) NPC.ShieldStrengthTowerSolar = 0; if (NPC.ShieldStrengthTowerVortex < 0) NPC.ShieldStrengthTowerVortex = 0; if (NPC.ShieldStrengthTowerNebula < 0) NPC.ShieldStrengthTowerNebula = 0; if (NPC.ShieldStrengthTowerStardust < 0) NPC.ShieldStrengthTowerStardust = 0; if (NPC.ShieldStrengthTowerSolar > NPC.LunarShieldPowerExpert) NPC.ShieldStrengthTowerSolar = NPC.LunarShieldPowerExpert; if (NPC.ShieldStrengthTowerVortex > NPC.LunarShieldPowerExpert) NPC.ShieldStrengthTowerVortex = NPC.LunarShieldPowerExpert; if (NPC.ShieldStrengthTowerNebula > NPC.LunarShieldPowerExpert) NPC.ShieldStrengthTowerNebula = NPC.LunarShieldPowerExpert; if (NPC.ShieldStrengthTowerStardust <= NPC.LunarShieldPowerExpert) break; NPC.ShieldStrengthTowerStardust = NPC.LunarShieldPowerExpert; break; case (byte)102: int index26 = (int)this.reader.ReadByte(); byte num85 = this.reader.ReadByte(); Vector2 Other = Utils.ReadVector2(this.reader); if (Main.netMode == 2) { NetMessage.SendData(102, -1, -1, "", this.whoAmI, (float)num85, Other.X, Other.Y, 0, 0, 0); break; } Player player16 = Main.player[index26]; for (int index5 = 0; index5 < (int)byte.MaxValue; ++index5) { Player player8 = Main.player[index5]; if (player8.active && !player8.dead && (player16.team == 0 || player16.team == player8.team) && (double)player8.Distance(Other) < 700.0) { Vector2 vector2_8 = player16.Center - player8.Center; Vector2 vec = Vector2.Normalize(vector2_8); if (!Utils.HasNaNs(vec)) { int Type3 = 90; float num19 = 0.0f; float num49 = 0.2094395f; Vector2 spinningpoint = new Vector2(0.0f, -8f); Vector2 vector2_11 = new Vector2(-3f); float num50 = 0.0f; float num51 = 0.005f; switch (num85) { case (byte)173: Type3 = 90; break; case (byte)176: Type3 = 88; break; case (byte)179: Type3 = 86; break; } for (int index6 = 0; (double)index6 < (double)vector2_8.Length() / 6.0; ++index6) { Vector2 Position = player8.Center + 6f * (float)index6 * vec + Utils.RotatedBy(spinningpoint, (double)num19, new Vector2()) + vector2_11; num19 += num49; int index27 = Dust.NewDust(Position, 6, 6, Type3, 0.0f, 0.0f, 100, new Color(), 1.5f); Main.dust[index27].noGravity = true; Main.dust[index27].velocity = Vector2.Zero; Main.dust[index27].fadeIn = (num50 += num51); Main.dust[index27].velocity += vec * 1.5f; } } player8.NebulaLevelup((int)num85); } } break; case (byte)103: if (Main.netMode != 1) break; NPC.MoonLordCountdown = this.reader.ReadInt32(); break; case (byte)104: if (Main.netMode != 1 || Main.npcShop <= 0) break; Item[] objArray = Main.instance.shop[Main.npcShop].item; int index28 = (int)this.reader.ReadByte(); int type8 = (int)this.reader.ReadInt16(); int num86 = (int)this.reader.ReadInt16(); int pre3 = (int)this.reader.ReadByte(); int num87 = this.reader.ReadInt32(); BitsByte bitsByte19 = (BitsByte)this.reader.ReadByte(); if (index28 >= objArray.Length) break; objArray[index28] = new Item(); objArray[index28].netDefaults(type8); objArray[index28].stack = num86; objArray[index28].Prefix(pre3); objArray[index28].value = num87; objArray[index28].buyOnce = bitsByte19[0]; break; } } }