public List <ItemId> GetItems() { //maxTileSets var sitems = new List <ItemId>(); for (int i = -1; i > -255; i--) { var curItem = new Item(); var head = curItem.headSlot; curItem.netDefaults(i); if (string.IsNullOrWhiteSpace(curItem.Name)) { break; } sitems.Add(new ItemId(i, curItem.Name, GetItemType(curItem))); } for (int i = 0; i < maxItemTypes; i++) { try { var curitem = new Terraria.Item(); curitem.netDefaults(i); //curitem.SetDefaults(i); sitems.Add(new ItemId(i, curitem.Name, GetItemType(curitem))); } catch { } } //sitems.AddRange(HardCodedItems); return(sitems); }
public override void ReadExtraData(BinaryReader reader) { item = new Item(); item.netDefaults((int)reader.ReadInt16()); item.Prefix((int)reader.ReadByte()); item.stack = (int)reader.ReadInt16(); }
/// <summary> /// Adds all the original vanilla items. /// </summary> internal static void FillVanilla() { for (int i = -24 /* some phasesabre */; i < ItemID.Count; i++) { //if (i > -19 /* phasesabres stop at -19 because Redigit */ && i <= 0) // copper etc items, using <=1.2-style netids instead of the new types (backwards compatibility needed for terraria code that still uses those netids) if (i == 0) continue; Item it = new Item(); it.netDefaults(i); ItemDef def = new ItemDef(Lang.itemName(it.type, true)); def.InternalName = it.name; def.Type = it.type; def.NetID = i; CopyItemToDef(def, it); DefFromType.Add(i, def); // TODO Fix overlapping names //VanillaDefFromName.Add(it.name, def); } Recipes.AddVanillaRecipeReferences(); }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int num48 = (int)ReadInt16(readBuffer); var position = ReadVector2(readBuffer); var velocity = ReadVector2(readBuffer); int stack2 = (int)ReadInt16(readBuffer); int pre = (int)ReadByte(readBuffer); int num49 = (int)ReadByte(readBuffer); int num50 = (int)ReadInt16(readBuffer); { if (num50 == 0) { if (num48 < 400) { Main.item[num48].active = false; NewNetMessage.SendData(21, -1, -1, String.Empty, 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) { NewNetMessage.SendData(21, -1, -1, String.Empty, num48, 0f, 0f, 0f, 0); if (num49 == 0) { Main.item[num48].ownIgnore = whoAmI; Main.item[num48].ownTime = 100; } Main.item[num48].FindOwner(num48); return; } NewNetMessage.SendData(21, -1, whoAmI, String.Empty, num48, 0f, 0f, 0f, 0); return; } } }
internal static void ReadModItem(Item item, BinaryReader reader) { string modName = reader.ReadString(); string itemName = reader.ReadString(); Mod mod = ModLoader.GetMod(modName); int type = mod == null ? 0 : mod.ItemType(itemName); if (type != 0) { item.netDefaults(type); int dataLength = reader.ReadUInt16(); if (dataLength > 0) { byte[] data = reader.ReadBytes(dataLength); using (MemoryStream memoryStream = new MemoryStream(data)) { using (BinaryReader customReader = new BinaryReader(memoryStream)) { item.modItem.LoadCustomData(customReader); } } } if (type == ModLoader.GetMod("ModLoader").ItemType("MysteryItem")) { MysteryItem mystery = item.modItem as MysteryItem; modName = mystery.GetModName(); itemName = mystery.GetItemName(); mod = ModLoader.GetMod(modName); type = mod == null ? 0 : mod.ItemType(itemName); if (type != 0) { item.netDefaults(type); } } } else { item.netDefaults(ModLoader.GetMod("ModLoader").ItemType("MysteryItem")); MysteryItem mystery = item.modItem as MysteryItem; mystery.SetModName(modName); mystery.SetItemName(itemName); reader.ReadBytes(reader.ReadUInt16()); } item.Prefix(reader.ReadByte()); }
TextSnippet ITagHandler.Parse(string text, Color baseColor, string options) { Item obj = new Item(); int result1; if (int.TryParse(text, out result1)) obj.netDefaults(result1); else obj.SetDefaults(text); if (obj.itemId <= 0) return new TextSnippet(text); obj.stack = 1; if (options != null) { string[] strArray = options.Split(','); for (int index = 0; index < strArray.Length; ++index) { if (strArray[index].Length != 0) { switch (strArray[index][0]) { case 'p': int result2; if (int.TryParse(strArray[index].Substring(1), out result2)) { obj.Prefix(Utils.Clamp<int>(result2, 0, 84)); continue; } continue; case 's': case 'x': int result3; if (int.TryParse(strArray[index].Substring(1), out result3)) { obj.stack = Utils.Clamp<int>(result3, 1, obj.maxStack); continue; } continue; default: continue; } } } } string str = ""; if (obj.stack > 1) str = " (" + obj.stack + ")"; ItemSnippet itemSnippet = new ItemSnippet(obj); itemSnippet.Text = "[" + obj.AffixName() + str + "]"; itemSnippet.CheckForHover = true; itemSnippet.DeleteWhole = true; return itemSnippet; }
public List <ItemId> GetItems() { var banners = new Dictionary <int, int>(); for (int bannerId = 0; bannerId < Terraria.Main.MaxBannerTypes; bannerId++) { int itemId = Terraria.Item.BannerToItem(bannerId); banners[itemId] = bannerId; } const int maxBanner = 289; //maxTileSets var sitems = new List <ItemId>(); for (int i = -255; i < maxItemTypes; i++) { try { var curitem = new Terraria.Item(); curitem.netDefaults(i); if (string.IsNullOrWhiteSpace(curitem.Name)) { continue; } var isFood = i >= 0 ? Terraria.ID.ItemID.Sets.IsFood[i] : false; var isRackable = (i >= 0 ? Terraria.ID.ItemID.Sets.CanBePlacedOnWeaponRacks[i] : false) || curitem.fishingPole > 0 || (curitem.damage > 0 && curitem.useStyle != 0); var isDeprecated = i >= 0 ? Terraria.ID.ItemID.Sets.Deprecated[i] : false; string name = curitem.Name; int banner = 0; banners.TryGetValue(i, out banner); if (isDeprecated) { name += " (Deprecated)"; } //curitem.SetDefaults(i); sitems.Add(new ItemId(i, name, GetItemType(curitem)) { IsFood = isFood, Banner = banner, Head = curitem.headSlot, Body = curitem.bodySlot, Legs = curitem.legSlot, Accessory = curitem.accessory, Rack = isRackable }); } catch { } } //sitems.AddRange(HardCodedItems); return(sitems); }
public override void Draw(SpriteBatch sb, bool mouseOver) { //base.Draw(sb, mouseOver); StarterSet set = StarterSet.Sets[StarterSet.SelectedSet]; Item drawItem = new Item(); for (int i = 0; i < set.Items.Length; i++) { drawItem.netDefaults(set.Items[i]); DrawItem(drawItem, sb, position + new Vector2(0f, i * (drawItem.GetTexture().Height + 5f))); //sb.Draw(drawItem.GetTexture(), position + new Vector2(0f, i * (drawItem.GetTexture().Height + 5f)), ComposeColour(drawItem)); } if (set.ArmourHead != 0) { drawItem.netDefaults(set.ArmourHead); DrawItem(drawItem, sb, position + new Vector2(ARMOUR_OFFSET, 0f)); //sb.Draw(drawItem.GetTexture(), position + new Vector2(ARMOUR_OFFSET, 0f ), ComposeColour(drawItem)); } if (set.ArmourBody != 0) { drawItem.netDefaults(set.ArmourBody); DrawItem(drawItem, sb, position + new Vector2(ARMOUR_OFFSET, 2f * drawItem.GetTexture().Height + 5f)); //sb.Draw(drawItem.GetTexture(), position + new Vector2(ARMOUR_OFFSET, 2f * drawItem.GetTexture().Height + 5f), ComposeColour(drawItem)); } if (set.ArmourLegs != 0) { drawItem.netDefaults(set.ArmourLegs); DrawItem(drawItem, sb, position + new Vector2(ARMOUR_OFFSET, 4f * drawItem.GetTexture().Height + 10f)); //sb.Draw(drawItem.GetTexture(), position + new Vector2(ARMOUR_OFFSET, 4f * drawItem.GetTexture().Height + 10f), ComposeColour(drawItem)); } }
public TerrariaWrapper() { base.Initialize(); Terraria.Item curItem = new Item(); for (int i = -1; i > -255; i--) { curItem = new Item(); curItem.netDefaults(i); if (string.IsNullOrWhiteSpace(curItem.name)) break; HardCodedItems.Add(new ItemId(curItem.type, curItem.name, GetItemType(curItem))); } }
public TerrariaWrapper() { Main.dedServ = true; Main.showSplash = false; this.Initialize(); Terraria.Item curItem = new Item(); for (int i = -1; i > -255; i--) { curItem = new Item(); curItem.netDefaults(i); if (string.IsNullOrWhiteSpace(curItem.name)) break; HardCodedItems.Add(new ItemId(curItem.type, curItem.name, GetItemType(curItem))); } }
public List <ItemId> GetItems() { //maxTileSets var sitems = new List <ItemId>(); for (int i = -255; i < maxItemTypes; i++) { try { var curitem = new Terraria.Item(); curitem.netDefaults(i); if (string.IsNullOrWhiteSpace(curitem.Name)) { continue; } var isFood = Terraria.ID.ItemID.Sets.IsFood[i]; var isRackable = Terraria.ID.ItemID.Sets.CanBePlacedOnWeaponRacks[i] || curitem.fishingPole > 0 || (curitem.damage > 0 && curitem.useStyle != 0); var isDeprecated = Terraria.ID.ItemID.Sets.Deprecated[i]; string name = curitem.Name; if (isDeprecated) { name += " (Deprecated)"; } //curitem.SetDefaults(i); sitems.Add(new ItemId(i, name, GetItemType(curitem)) { IsFood = isFood, Head = curitem.headSlot, Body = curitem.bodySlot, Legs = curitem.legSlot, Accessory = curitem.accessory, Rack = isRackable }); } catch { } } //sitems.AddRange(HardCodedItems); return(sitems); }
protected void DrawChat() { if (Main.player[Main.myPlayer].talkNPC < 0 && Main.player[Main.myPlayer].sign == -1) { Main.npcChatText = ""; return; } if (Main.netMode == 0 && Main.autoPause && Main.player[Main.myPlayer].talkNPC >= 0) { if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 105) { Main.npc[Main.player[Main.myPlayer].talkNPC].Transform(107); } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 106) { Main.npc[Main.player[Main.myPlayer].talkNPC].Transform(108); } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 123) { Main.npc[Main.player[Main.myPlayer].talkNPC].Transform(124); } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 354) { Main.npc[Main.player[Main.myPlayer].talkNPC].Transform(353); } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 376) { Main.npc[Main.player[Main.myPlayer].talkNPC].Transform(369); } } Color color = new Color(200, 200, 200, 200); int num = (int)((Main.mouseTextColor * 2 + 255) / 3); Color textColor = new Color(num, num, num, num); int num2; string[] array = Utils.WordwrapString(Main.npcChatText, Main.fontMouseText, 460, 10, out num2); if (Main.editSign) { this.textBlinkerCount++; if (this.textBlinkerCount >= 20) { if (this.textBlinkerState == 0) { this.textBlinkerState = 1; } else { this.textBlinkerState = 0; } this.textBlinkerCount = 0; } if (this.textBlinkerState == 1) { string[] array2; IntPtr intPtr; (array2 = array)[(int)(intPtr = (IntPtr)num2)] = array2[(int)intPtr] + "|"; } } num2++; Main.spriteBatch.Draw(Main.chatBackTexture, new Vector2((float)(Main.screenWidth / 2 - Main.chatBackTexture.Width / 2), 100f), new Rectangle?(new Rectangle(0, 0, Main.chatBackTexture.Width, (num2 + 1) * 30)), color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); Main.spriteBatch.Draw(Main.chatBackTexture, new Vector2((float)(Main.screenWidth / 2 - Main.chatBackTexture.Width / 2), (float)(100 + (num2 + 1) * 30)), new Rectangle?(new Rectangle(0, Main.chatBackTexture.Height - 30, Main.chatBackTexture.Width, 30)), color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); for (int i = 0; i < num2; i++) { Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, array[i], (float)(170 + (Main.screenWidth - 800) / 2), (float)(120 + i * 30), textColor, Color.Black, Vector2.Zero, 1f); } if (Main.npcChatCornerItem != 0) { Vector2 vector = new Vector2((float)(Main.screenWidth / 2 + Main.chatBackTexture.Width / 2), (float)(100 + (num2 + 1) * 30 + 30)); vector -= Vector2.One * 8f; Item item = new Item(); item.netDefaults(Main.npcChatCornerItem); float num3 = 1f; Texture2D texture2D = Main.itemTexture[item.type]; if (texture2D.Width > 32 || texture2D.Height > 32) { if (texture2D.Width > texture2D.Height) { num3 = 32f / (float)texture2D.Width; } else { num3 = 32f / (float)texture2D.Height; } } Main.spriteBatch.Draw(texture2D, vector, null, item.GetAlpha(Color.White), 0f, new Vector2((float)texture2D.Width, (float)texture2D.Height), num3, SpriteEffects.None, 0f); if (item.color != default(Color)) { Main.spriteBatch.Draw(texture2D, vector, null, item.GetColor(item.color), 0f, new Vector2((float)texture2D.Width, (float)texture2D.Height), num3, SpriteEffects.None, 0f); } if (new Rectangle((int)vector.X - (int)((float)texture2D.Width * num3), (int)vector.Y - (int)((float)texture2D.Height * num3), (int)((float)texture2D.Width * num3), (int)((float)texture2D.Height * num3)).Contains(new Point(Main.mouseX, Main.mouseY))) { this.MouseText(item.name, -11, 0); } } num = (int)Main.mouseTextColor; textColor = new Color(num, (int)((double)num / 1.1), num / 2, num); string text = ""; string text2 = ""; int num4 = Main.player[Main.myPlayer].statLifeMax2 - Main.player[Main.myPlayer].statLife; for (int j = 0; j < 22; j++) { int num5 = Main.player[Main.myPlayer].buffType[j]; if (Main.debuff[num5] && Main.player[Main.myPlayer].buffTime[j] > 0 && num5 != 28 && num5 != 34 && num5 != 87 && num5 != 89 && num5 != 21 && num5 != 86) { num4 += 1000; } } if (Main.player[Main.myPlayer].sign > -1) { if (Main.editSign) { text = Lang.inter[47]; } else { text = Lang.inter[48]; } } else { if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 20) { text = Lang.inter[28]; text2 = Lang.inter[49]; } else { if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 353) { text = Lang.inter[28]; text2 = "Hair Style"; } else { if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 368) { text = Lang.inter[28]; } else { if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 369) { text = Lang.inter[64]; } else { if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 17 || Main.npc[Main.player[Main.myPlayer].talkNPC].type == 19 || Main.npc[Main.player[Main.myPlayer].talkNPC].type == 38 || Main.npc[Main.player[Main.myPlayer].talkNPC].type == 54 || Main.npc[Main.player[Main.myPlayer].talkNPC].type == 107 || Main.npc[Main.player[Main.myPlayer].talkNPC].type == 108 || Main.npc[Main.player[Main.myPlayer].talkNPC].type == 124 || Main.npc[Main.player[Main.myPlayer].talkNPC].type == 142 || Main.npc[Main.player[Main.myPlayer].talkNPC].type == 160 || Main.npc[Main.player[Main.myPlayer].talkNPC].type == 178 || Main.npc[Main.player[Main.myPlayer].talkNPC].type == 207 || Main.npc[Main.player[Main.myPlayer].talkNPC].type == 208 || Main.npc[Main.player[Main.myPlayer].talkNPC].type == 209 || Main.npc[Main.player[Main.myPlayer].talkNPC].type == 227 || Main.npc[Main.player[Main.myPlayer].talkNPC].type == 228 || Main.npc[Main.player[Main.myPlayer].talkNPC].type == 229) { text = Lang.inter[28]; if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 107) { text2 = Lang.inter[19]; } } else { if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 37) { if (!Main.dayTime) { text = Lang.inter[50]; } } else { if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 22) { text = Lang.inter[51]; text2 = Lang.inter[25]; } else { if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 18) { string text3 = ""; int num6 = 0; int num7 = 0; int num8 = 0; int num9 = 0; int num10 = num4; if (num10 > 0) { num10 = (int)((double)num10 * 0.75); if (num10 < 1) { num10 = 1; } } if (num10 < 0) { num10 = 0; } num4 = num10; if (num10 >= 1000000) { num6 = num10 / 1000000; num10 -= num6 * 1000000; } if (num10 >= 10000) { num7 = num10 / 10000; num10 -= num7 * 10000; } if (num10 >= 100) { num8 = num10 / 100; num10 -= num8 * 100; } if (num10 >= 1) { num9 = num10; } if (num6 > 0) { object obj = text3; text3 = string.Concat(new object[] { obj, num6, " ", Lang.inter[15], " " }); } if (num7 > 0) { object obj2 = text3; text3 = string.Concat(new object[] { obj2, num7, " ", Lang.inter[16], " " }); } if (num8 > 0) { object obj3 = text3; text3 = string.Concat(new object[] { obj3, num8, " ", Lang.inter[17], " " }); } if (num9 > 0) { object obj4 = text3; text3 = string.Concat(new object[] { obj4, num9, " ", Lang.inter[18], " " }); } float num11 = (float)Main.mouseTextColor / 255f; if (num6 > 0) { textColor = new Color((int)((byte)(220f * num11)), (int)((byte)(220f * num11)), (int)((byte)(198f * num11)), (int)Main.mouseTextColor); } else { if (num7 > 0) { textColor = new Color((int)((byte)(224f * num11)), (int)((byte)(201f * num11)), (int)((byte)(92f * num11)), (int)Main.mouseTextColor); } else { if (num8 > 0) { textColor = new Color((int)((byte)(181f * num11)), (int)((byte)(192f * num11)), (int)((byte)(193f * num11)), (int)Main.mouseTextColor); } else { if (num9 > 0) { textColor = new Color((int)((byte)(246f * num11)), (int)((byte)(138f * num11)), (int)((byte)(96f * num11)), (int)Main.mouseTextColor); } } } } text = Lang.inter[54] + " (" + text3 + ")"; if (num10 == 0) { text = Lang.inter[54]; } } } } } } } } } } int num12 = 180 + (Main.screenWidth - 800) / 2; int num13 = 130 + num2 * 30; float scale = 0.9f; if (Main.mouseX > num12 && (float)Main.mouseX < (float)num12 + Main.fontMouseText.MeasureString(text).X && Main.mouseY > num13 && (float)Main.mouseY < (float)num13 + Main.fontMouseText.MeasureString(text).Y) { Main.player[Main.myPlayer].mouseInterface = true; scale = 1.1f; if (!Main.npcChatFocus2) { Main.PlaySound(12, -1, -1, 1); } Main.npcChatFocus2 = true; Main.player[Main.myPlayer].releaseUseItem = false; } else { if (Main.npcChatFocus2) { Main.PlaySound(12, -1, -1, 1); } Main.npcChatFocus2 = false; } Vector2 origin = Main.fontMouseText.MeasureString(text) * 0.5f; Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, (float)num12 + origin.X, (float)num13 + origin.Y, textColor, Color.Black, origin, scale); string text4 = Lang.inter[52]; textColor = new Color(num, (int)((double)num / 1.1), num / 2, num); num12 = num12 + (int)Main.fontMouseText.MeasureString(text).X + 20; int num14 = num12 + (int)Main.fontMouseText.MeasureString(text4).X; num13 = 130 + num2 * 30; scale = 0.9f; if (Main.mouseX > num12 && (float)Main.mouseX < (float)num12 + Main.fontMouseText.MeasureString(text4).X && Main.mouseY > num13 && (float)Main.mouseY < (float)num13 + Main.fontMouseText.MeasureString(text4).Y) { scale = 1.1f; if (!Main.npcChatFocus1) { Main.PlaySound(12, -1, -1, 1); } Main.npcChatFocus1 = true; Main.player[Main.myPlayer].releaseUseItem = false; Main.player[Main.myPlayer].controlUseItem = false; } else { if (Main.npcChatFocus1) { Main.PlaySound(12, -1, -1, 1); } Main.npcChatFocus1 = false; } origin = Main.fontMouseText.MeasureString(text4) * 0.5f; Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text4, (float)num12 + origin.X, (float)num13 + origin.Y, textColor, Color.Black, origin, scale); if (text2 != "") { num12 = num14 + (int)Main.fontMouseText.MeasureString(text2).X / 3; num13 = 130 + num2 * 30; scale = 0.9f; if (Main.mouseX > num12 && (float)Main.mouseX < (float)num12 + Main.fontMouseText.MeasureString(text2).X && Main.mouseY > num13 && (float)Main.mouseY < (float)num13 + Main.fontMouseText.MeasureString(text2).Y) { Main.player[Main.myPlayer].mouseInterface = true; scale = 1.1f; if (!Main.npcChatFocus3) { Main.PlaySound(12, -1, -1, 1); } Main.npcChatFocus3 = true; Main.player[Main.myPlayer].releaseUseItem = false; } else { if (Main.npcChatFocus3) { Main.PlaySound(12, -1, -1, 1); } Main.npcChatFocus3 = false; } origin = Main.fontMouseText.MeasureString(text2) * 0.5f; Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text2, (float)num12 + origin.X, (float)num13 + origin.Y, textColor, Color.Black, origin, scale); } if (Main.mouseLeft && Main.mouseLeftRelease) { Main.mouseLeftRelease = false; Main.player[Main.myPlayer].releaseUseItem = false; Main.player[Main.myPlayer].mouseInterface = true; if (Main.npcChatFocus1) { Main.player[Main.myPlayer].talkNPC = -1; Main.player[Main.myPlayer].sign = -1; Main.npcChatCornerItem = 0; Main.editSign = false; Main.npcChatText = ""; Main.PlaySound(11, -1, -1, 1); return; } if (Main.npcChatFocus2) { if (Main.player[Main.myPlayer].sign != -1) { if (!Main.editSign) { Main.PlaySound(12, -1, -1, 1); Main.editSign = true; Main.clrInput(); return; } Main.PlaySound(12, -1, -1, 1); int num15 = Main.player[Main.myPlayer].sign; Sign.TextSign(num15, Main.npcChatText); Main.editSign = false; if (Main.netMode == 1) { NetMessage.SendData(47, -1, -1, "", num15, 0f, 0f, 0f, 0); return; } } else { if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 369) { Main.npcChatCornerItem = 0; Main.PlaySound(12, -1, -1, 1); bool flag = false; if (!Main.anglerQuestFinished && !Main.anglerWhoFinishedToday.Contains(Main.player[Main.myPlayer].name)) { int num16 = Main.player[Main.myPlayer].FindItem(Main.anglerQuestItemNetIDs[Main.anglerQuest]); if (num16 != -1) { Main.player[Main.myPlayer].inventory[num16].stack--; if (Main.player[Main.myPlayer].inventory[num16].stack <= 0) { Main.player[Main.myPlayer].inventory[num16] = new Item(); } flag = true; Main.PlaySound(24, -1, -1, 1); Main.player[Main.myPlayer].anglerQuestsFinished++; Main.player[Main.myPlayer].GetAnglerReward(); } } Main.npcChatText = Lang.AnglerQuestChat(flag); if (flag) { Main.anglerQuestFinished = true; if (Main.netMode == 1) { NetMessage.SendData(75, -1, -1, "", 0, 0f, 0f, 0f, 0); return; } Main.anglerWhoFinishedToday.Add(Main.player[Main.myPlayer].name); return; } } else { if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 17) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 1; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 19) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 2; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 124) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 8; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 142) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 9; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 353) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 18; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 368) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 19; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 37) { if (Main.netMode == 0) { NPC.SpawnSkeletron(); } else { NetMessage.SendData(51, -1, -1, "", Main.myPlayer, 1f, 0f, 0f, 0); } Main.npcChatText = ""; return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 20) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 3; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 38) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 4; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 54) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 5; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 107) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 6; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 108) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 7; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 160) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 10; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 178) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 11; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 207) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 12; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 208) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 13; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 209) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 14; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 227) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 15; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 228) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 16; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 229) { Main.playerInventory = true; Main.npcChatText = ""; Main.npcShop = 17; this.shop[Main.npcShop].SetupShop(Main.npcShop); Main.PlaySound(12, -1, -1, 1); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 22) { Main.PlaySound(12, -1, -1, 1); Main.HelpText(); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 18) { Main.PlaySound(12, -1, -1, 1); if (num4 > 0) { if (Main.player[Main.myPlayer].BuyItem(num4)) { Main.PlaySound(2, -1, -1, 4); Main.player[Main.myPlayer].HealEffect(Main.player[Main.myPlayer].statLifeMax2 - Main.player[Main.myPlayer].statLife, true); if ((double)Main.player[Main.myPlayer].statLife < (double)Main.player[Main.myPlayer].statLifeMax2 * 0.25) { Main.npcChatText = Lang.dialog(227, false); } else { if ((double)Main.player[Main.myPlayer].statLife < (double)Main.player[Main.myPlayer].statLifeMax2 * 0.5) { Main.npcChatText = Lang.dialog(228, false); } else { if ((double)Main.player[Main.myPlayer].statLife < (double)Main.player[Main.myPlayer].statLifeMax2 * 0.75) { Main.npcChatText = Lang.dialog(229, false); } else { Main.npcChatText = Lang.dialog(230, false); } } } Main.player[Main.myPlayer].statLife = Main.player[Main.myPlayer].statLifeMax2; for (int k = 0; k < 22; k++) { int num17 = Main.player[Main.myPlayer].buffType[k]; if (Main.debuff[num17] && Main.player[Main.myPlayer].buffTime[k] > 0 && num17 != 28 && num17 != 34 && num17 != 87 && num17 != 89 && num17 != 21 && num17 != 86) { Main.player[Main.myPlayer].DelBuff(k); } } return; } int num18 = Main.rand.Next(3); if (num18 == 0) { Main.npcChatText = Lang.dialog(52, false); } if (num18 == 1) { Main.npcChatText = Lang.dialog(53, false); } if (num18 == 2) { Main.npcChatText = Lang.dialog(54, false); return; } } else { int num19 = Main.rand.Next(3); if (num19 == 0) { Main.npcChatText = Lang.dialog(55, false); } if (num19 == 1) { Main.npcChatText = Lang.dialog(56, false); } if (num19 == 2) { Main.npcChatText = Lang.dialog(57, false); return; } } } } } } else { if (Main.npcChatFocus3 && Main.player[Main.myPlayer].talkNPC >= 0) { if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 20) { Main.PlaySound(12, -1, -1, 1); Main.npcChatText = Lang.evilGood(); return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 22) { Main.playerInventory = true; Main.npcChatText = ""; Main.PlaySound(12, -1, -1, 1); Main.craftGuide = true; return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 107) { Main.playerInventory = true; Main.npcChatText = ""; Main.PlaySound(12, -1, -1, 1); Main.reforge = true; return; } if (Main.npc[Main.player[Main.myPlayer].talkNPC].type == 353) { Main.OpenHairWindow(); } } } } }
protected void DrawTiles(bool solidOnly = true) { if (!solidOnly) { Main.critterCage = false; } Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); int num = (int)(255f * (1f - Main.gfxQuality) + 30f * Main.gfxQuality); int num2 = (int)(50f * (1f - Main.gfxQuality) + 2f * Main.gfxQuality); Vector2 zero = new Vector2((float)Main.offScreenRange, (float)Main.offScreenRange); if (Main.drawToScreen) { zero = Vector2.Zero; } int num3 = 0; int[] array = new int[1000]; int[] array2 = new int[1000]; int num4 = array.Length - 1; int num5 = (int)((Main.screenPosition.X - zero.X) / 16f - 1f); int num6 = (int)((Main.screenPosition.X + (float)Main.screenWidth + zero.X) / 16f) + 2; int num7 = (int)((Main.screenPosition.Y - zero.Y) / 16f - 1f); int num8 = (int)((Main.screenPosition.Y + (float)Main.screenHeight + zero.Y) / 16f) + 5; if (num5 < 0) { num5 = 0; } if (num6 > Main.maxTilesX) { num6 = Main.maxTilesX; } if (num7 < 0) { num7 = 0; } if (num8 > Main.maxTilesY) { num8 = Main.maxTilesY; } if (Main.sectionManager.FrameSectionsLeft > 0) { TimeLogger.DetailedDrawReset(); WorldGen.SectionTileFrameWithCheck(num5, num7, num6, num8); TimeLogger.DetailedDrawTime(5); } int num9 = 16; Color[] array3 = new Color[9]; for (int i = num7; i < num8 + 4; i++) { for (int j = num5 - 2; j < num6 + 2; j++) { Tile tile = Main.tile[j, i]; if (tile == null) { tile = new Tile(); Main.tile[j, i] = tile; Main.mapTime += 60; } ushort type = tile.type; bool flag = Main.tileSolid[(int)type]; if (type == 11) { flag = true; } if (tile.active() && flag == solidOnly) { if (!Main.tileSetsLoaded[(int)type]) { this.LoadTiles((int)type); } SpriteEffects effects = SpriteEffects.None; if (type == 3 || type == 13 || type == 20 || type == 24 || type == 49 || type == 50 || type == 52 || type == 61 || type == 62 || type == 71 || type == 73 || type == 74 || type == 81 || type == 82 || type == 83 || type == 84 || type == 91 || type == 92 || type == 93 || type == 110 || type == 113 || type == 115 || type == 135 || type == 141 || type == 165 || type == 174 || type == 201 || type == 205 || type == 227 || type == 270 || type == 271) { if (j % 2 == 1) { effects = SpriteEffects.FlipHorizontally; } } else { if (type == 184) { if (tile.frameY < 108) { if (j % 2 == 1) { effects = SpriteEffects.FlipHorizontally; } } else { if (i % 2 == 1) { effects = SpriteEffects.FlipVertically; } } } else { if (type == 185 && tile.frameY == 0 && j % 2 == 1) { effects = SpriteEffects.FlipHorizontally; } } } Color color = Lighting.GetColor(j, i); int num10 = 0; int num11 = 16; if (type >= 330 && type <= 333) { num10 += 2; } if (type == 4 && WorldGen.SolidTile(j, i - 1)) { num10 = 2; if (WorldGen.SolidTile(j - 1, i + 1) || WorldGen.SolidTile(j + 1, i + 1)) { num10 = 4; } } if (type == 336) { num10 = 2; } if (type >= 275 && type <= 282) { num10 = 2; } if (type == 285 || type == 286 || type == 309 || type == 310) { num10 = 2; } if (type == 100 || type == 283) { num10 = 2; } if (type == 78 || type == 85 || type == 210 || type == 133 || type == 134 || type == 233) { num10 = 2; } if (type == 33 || type == 49 || type == 174) { num10 = -4; } if (type == 3 || type == 4 || type == 5 || type == 24 || type == 33 || type == 49 || type == 61 || type == 71 || type == 110 || type == 174 || type == 201 || type == 323 || type == 324) { num11 = 20; } else { if (type == 16 || type == 17 || type == 18 || type == 20 || type == 26 || type == 27 || type == 32 || type == 69 || type == 72 || type == 77 || type == 80) { num11 = 18; } else { if (type == 14 || type == 15 || type == 21) { if (tile.frameY == 18) { num11 = 18; } } else { if (type == 137) { num11 = 18; } else { if (type == 135) { num10 = 2; num11 = 18; } else { if (type == 254) { num10 = 2; } else { if (type == 132) { num10 = 2; num11 = 18; } else { num11 = 16; } } } } } } } if (type == 52) { num10 -= 2; } if (type == 324) { num10 = -2; } if (type == 231 || type == 238) { num10 += 2; } if (type == 207) { num10 = 2; } if (type == 4 || type == 5 || type == 323 || type == 324) { num9 = 20; } else { num9 = 16; } if (type == 73 || type == 74 || type == 113) { num10 -= 12; num11 = 32; } if (type == 227) { num9 = 32; num11 = 38; if (tile.frameX == 238) { num10 -= 6; } else { num10 -= 20; } } if (type == 185 || type == 186 || type == 187) { num10 = 2; if (type == 185) { if (tile.frameY == 18 && tile.frameX >= 576 && tile.frameX <= 882) { Main.tileShine2[185] = true; } else { Main.tileShine2[185] = false; } } else { if (type == 186) { if (tile.frameX >= 864 && tile.frameX <= 1170) { Main.tileShine2[186] = true; } else { Main.tileShine2[186] = false; } } } } if (type == 178 && tile.frameY <= 36) { num10 = 2; } if (type == 184) { num9 = 20; if (tile.frameY <= 36) { num10 = 2; } else { if (tile.frameY <= 108) { num10 = -2; } } } if (type == 28) { num10 += 2; } if (type == 81) { num10 -= 8; num11 = 26; num9 = 24; } if (type == 105) { num10 = 2; } if (type == 124) { num11 = 18; } if (type == 137) { num11 = 18; } if (type == 138) { num11 = 18; } if (type == 139 || type == 142 || type == 143) { num10 = 2; } int num12 = 0; if (tile.halfBrick()) { num12 = 8; } int num13 = Main.tileFrame[(int)type] * 38; int num14 = 0; if (type == 272) { num13 = 0; } if (type == 106) { num13 = Main.tileFrame[(int)type] * 54; } if (type >= 300 && type <= 308) { num13 = Main.tileFrame[(int)type] * 54; num10 = 2; } if (type == 12) { num13 = Main.tileFrame[(int)type] * 36; } if (type == 96) { num13 = Main.tileFrame[(int)type] * 36; } if (type == 238) { num13 = Main.tileFrame[(int)type] * 36; } if (type == 31) { num13 = Main.tileFrame[(int)type] * 36; } if (type == 215) { num13 = Main.tileFrame[(int)type] * 36; num10 = 2; } if (type == 231) { num13 = Main.tileFrame[(int)type] * 54; num10 = 2; } if (type == 243) { num13 = Main.tileFrame[(int)type] * 54; num10 = 2; } if (type == 247) { num13 = Main.tileFrame[(int)type] * 54; num10 = 2; } if (type == 244) { num10 = 2; if (tile.frameX < 54) { num13 = Main.tileFrame[(int)type] * 36; } else { num13 = 0; } } if (type == 235) { num13 = Main.tileFrame[(int)type] * 18; } if (type == 217 || type == 218) { num13 = Main.tileFrame[(int)type] * 36; num10 = 2; } if (type == 219 || type == 220) { num13 = Main.tileFrame[(int)type] * 54; num10 = 2; } if (type == 270 || type == 271) { int k = Main.tileFrame[(int)type] + j % 6; if (j % 2 == 0) { k += 3; } if (j % 3 == 0) { k += 3; } if (j % 4 == 0) { k += 3; } while (k > 5) { k -= 6; } num14 = k * 18; num13 = 0; } if ((type >= 275 && type <= 281) || type == 296 || type == 297 || type == 309) { Main.critterCage = true; int num15 = j - (int)(tile.frameX / 18); int num16 = i - (int)(tile.frameY / 18); int num17 = num15 / 6 * (num16 / 4); num17 %= Main.cageFrames; if (type == 275) { num13 = Main.bunnyCageFrame[num17] * 54; } if (type == 276) { num13 = Main.squirrelCageFrame[num17] * 54; } if (type == 277) { num13 = Main.mallardCageFrame[num17] * 54; } if (type == 278) { num13 = Main.duckCageFrame[num17] * 54; } if (type == 279) { num13 = Main.birdCageFrame[num17] * 54; } if (type == 280) { num13 = Main.blueBirdCageFrame[num17] * 54; } if (type == 281) { num13 = Main.redBirdCageFrame[num17] * 54; } if (type == 296) { num13 = Main.scorpionCageFrame[0, num17] * 54; } if (type == 297) { num13 = Main.scorpionCageFrame[0, num17] * 54; } if (type == 309) { num13 = Main.penguinCageFrame[num17] * 54; } } else { if (type == 285 || type == 286 || type == 298 || type == 299 || type == 310 || type == 339) { Main.critterCage = true; int num18 = j - (int)(tile.frameX / 18); int num19 = i - (int)(tile.frameY / 18); int num20 = num18 / 3 * (num19 / 3); num20 %= Main.cageFrames; if (type == 285) { num13 = Main.snailCageFrame[num20] * 36; } if (type == 286) { num13 = Main.snail2CageFrame[num20] * 36; } if (type == 298) { num13 = Main.frogCageFrame[num20] * 36; } if (type == 299) { num13 = Main.mouseCageFrame[num20] * 36; } if (type == 310) { num13 = Main.wormCageFrame[num20] * 36; } if (type == 339) { num13 = Main.grasshopperCageFrame[num20] * 36; } } else { if (type == 282 || (type >= 288 && type <= 295) || (type >= 316 && type <= 318)) { Main.critterCage = true; int num21 = j - (int)(tile.frameX / 18); int num22 = i - (int)(tile.frameY / 18); int num23 = num21 / 2 * (num22 / 3); num23 %= Main.cageFrames; if (type == 282) { num13 = Main.fishBowlFrame[num23] * 36; } else { if (type >= 288 && type <= 295) { int num24 = (int)(type - 288); num13 = Main.butterflyCageFrame[num24, num23] * 36; } else { if (type >= 316 && type <= 318) { int num25 = (int)(type - 316); num13 = Main.jellyfishCageFrame[num25, num23] * 36; } } } } else { if (type == 207) { if (tile.frameY >= 72) { num13 = Main.tileFrame[(int)type]; int num26 = j; if (tile.frameX % 36 != 0) { num26--; } num13 += num26 % 6; if (num13 >= 6) { num13 -= 6; } num13 *= 72; } else { num13 = 0; } } else { if (type == 326 || type == 327 || type == 328 || type == 329 || type == 336) { num13 = Main.tileFrame[(int)type] * 90; } } } } } if (Main.player[Main.myPlayer].dangerSense) { bool flag2 = false || type == 135 || type == 137 || type == 138 || type == 141 || type == 210; if (tile.slope() == 0 && !tile.inActive()) { flag2 = (flag2 || type == 32 || type == 69 || type == 48 || type == 232 || type == 51 || type == 229); if (!Main.player[Main.myPlayer].fireWalk) { flag2 = (flag2 || type == 37 || type == 58 || type == 76); } if (!Main.player[Main.myPlayer].iceSkate) { flag2 = (flag2 || type == 162); } } if (flag2) { if (color.R < 255) { color.R = 255; } if (color.G < 50) { color.G = 50; } if (color.B < 50) { color.B = 50; } color.A = Main.mouseTextColor; if (!Main.gamePaused && base.IsActive && Main.rand.Next(30) == 0) { int num27 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 60, 0f, 0f, 100, default(Color), 0.3f); Main.dust[num27].fadeIn = 1f; Main.dust[num27].velocity *= 0.1f; Main.dust[num27].noLight = true; Main.dust[num27].noGravity = true; } } } if (Main.player[Main.myPlayer].findTreasure) { bool flag3 = false; if (type == 185 && tile.frameY == 18 && tile.frameX >= 576 && tile.frameX <= 882) { flag3 = true; } if (type == 186 && tile.frameX >= 864 && tile.frameX <= 1170) { flag3 = true; } if (flag3 || type == 6 || type == 7 || type == 8 || type == 9 || type == 12 || type == 21 || type == 22 || type == 28 || type == 107 || type == 108 || type == 111 || (type >= 63 && type <= 68) || Main.tileAlch[(int)type] || type == 166 || type == 167 || type == 168 || type == 169 || type == 178 || type == 211 || type == 221 || type == 222 || type == 223 || type == 236) { byte b = 200; byte b2 = 170; if (color.R < b) { color.R = b; } if (color.G < b2) { color.G = b2; } color.A = Main.mouseTextColor; if (!Main.gamePaused && base.IsActive && Main.rand.Next(60) == 0) { int num28 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 204, 0f, 0f, 150, default(Color), 0.3f); Main.dust[num28].fadeIn = 1f; Main.dust[num28].velocity *= 0.1f; Main.dust[num28].noLight = true; } } } if (!Main.gamePaused && base.IsActive && (Lighting.lightMode < 2 || Main.rand.Next(4) == 0)) { if (type == 238 && Main.rand.Next(10) == 0) { int num29 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 168, 0f, 0f, 0, default(Color), 1f); Main.dust[num29].noGravity = true; Main.dust[num29].alpha = 200; } if (type == 244 && tile.frameX == 18 && tile.frameY == 18 && Main.rand.Next(2) == 0) { if (Main.rand.Next(500) == 0) { Gore.NewGore(new Vector2((float)(j * 16 + 8), (float)(i * 16 + 8)), default(Vector2), 415, (float)Main.rand.Next(51, 101) * 0.01f); } else { if (Main.rand.Next(250) == 0) { Gore.NewGore(new Vector2((float)(j * 16 + 8), (float)(i * 16 + 8)), default(Vector2), 414, (float)Main.rand.Next(51, 101) * 0.01f); } else { if (Main.rand.Next(80) == 0) { Gore.NewGore(new Vector2((float)(j * 16 + 8), (float)(i * 16 + 8)), default(Vector2), 413, (float)Main.rand.Next(51, 101) * 0.01f); } else { if (Main.rand.Next(10) == 0) { Gore.NewGore(new Vector2((float)(j * 16 + 8), (float)(i * 16 + 8)), default(Vector2), 412, (float)Main.rand.Next(51, 101) * 0.01f); } else { if (Main.rand.Next(3) == 0) { Gore.NewGore(new Vector2((float)(j * 16 + 8), (float)(i * 16 + 8)), default(Vector2), 411, (float)Main.rand.Next(51, 101) * 0.01f); } } } } } } if (type == 139 && tile.frameX == 36 && tile.frameY % 36 == 0 && Main.time % 7.0 == 0.0 && Main.rand.Next(3) == 0) { int num30 = Main.rand.Next(570, 573); Vector2 position = new Vector2((float)(j * 16 + 8), (float)(i * 16 - 8)); Vector2 velocity = new Vector2(Main.windSpeed * 2f, -0.5f); velocity.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.01f; velocity.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.01f; if (num30 == 572) { position.X -= 8f; } if (num30 == 571) { position.X -= 4f; } Gore.NewGore(position, velocity, num30, 0.8f); } if (type == 165 && tile.frameX >= 162 && tile.frameX <= 214 && tile.frameY == 72 && Main.rand.Next(60) == 0) { int num31 = Dust.NewDust(new Vector2((float)(j * 16 + 2), (float)(i * 16 + 6)), 8, 4, 153, 0f, 0f, 0, default(Color), 1f); Main.dust[num31].scale -= (float)Main.rand.Next(3) * 0.1f; Main.dust[num31].velocity.Y = 0f; Dust expr_160B_cp_0 = Main.dust[num31]; expr_160B_cp_0.velocity.X = expr_160B_cp_0.velocity.X * 0.05f; Main.dust[num31].alpha = 100; } if (type == 42 && tile.frameX == 0) { int num32 = (int)(tile.frameY / 36); int num33 = (int)(tile.frameY / 18 % 2); if (num32 == 7 && num33 == 1) { if (Main.rand.Next(50) == 0) { int num34 = Dust.NewDust(new Vector2((float)(j * 16 + 4), (float)(i * 16 + 4)), 8, 8, 58, 0f, 0f, 150, default(Color), 1f); Main.dust[num34].velocity *= 0.5f; } if (Main.rand.Next(100) == 0) { int num35 = Gore.NewGore(new Vector2((float)(j * 16 - 2), (float)(i * 16 - 4)), default(Vector2), Main.rand.Next(16, 18), 1f); Main.gore[num35].scale *= 0.7f; Main.gore[num35].velocity *= 0.25f; } } else { if (num32 == 29 && num33 == 1 && Main.rand.Next(40) == 0) { int num36 = Dust.NewDust(new Vector2((float)(j * 16 + 4), (float)(i * 16)), 8, 8, 59, 0f, 0f, 100, default(Color), 1f); if (Main.rand.Next(3) != 0) { Main.dust[num36].noGravity = true; } Main.dust[num36].velocity *= 0.3f; Dust expr_1804_cp_0 = Main.dust[num36]; expr_1804_cp_0.velocity.Y = expr_1804_cp_0.velocity.Y - 1.5f; } } } if (type == 215 && Main.rand.Next(2) == 0 && ((Main.drawToScreen && Main.rand.Next(4) == 0) || !Main.drawToScreen) && tile.frameY == 0) { int num37 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16 - 4)), 8, 8, 31, 0f, 0f, 100, default(Color), 1f); if (tile.frameX == 0) { Dust expr_18AE_cp_0 = Main.dust[num37]; expr_18AE_cp_0.position.X = expr_18AE_cp_0.position.X + (float)Main.rand.Next(8); } if (tile.frameX == 36) { Dust expr_18DE_cp_0 = Main.dust[num37]; expr_18DE_cp_0.position.X = expr_18DE_cp_0.position.X - (float)Main.rand.Next(8); } Main.dust[num37].alpha += Main.rand.Next(100); Main.dust[num37].velocity *= 0.2f; Dust expr_1940_cp_0 = Main.dust[num37]; expr_1940_cp_0.velocity.Y = expr_1940_cp_0.velocity.Y - (0.5f + (float)Main.rand.Next(10) * 0.1f); Main.dust[num37].fadeIn = 0.5f + (float)Main.rand.Next(10) * 0.1f; if (Main.rand.Next(4) == 0) { num37 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 8, 8, 6, 0f, 0f, 0, default(Color), 1f); if (tile.frameX == 0) { Dust expr_19EA_cp_0 = Main.dust[num37]; expr_19EA_cp_0.position.X = expr_19EA_cp_0.position.X + (float)Main.rand.Next(8); } if (tile.frameX == 36) { Dust expr_1A1A_cp_0 = Main.dust[num37]; expr_1A1A_cp_0.position.X = expr_1A1A_cp_0.position.X - (float)Main.rand.Next(8); } if (Main.rand.Next(20) != 0) { Main.dust[num37].noGravity = true; Main.dust[num37].scale *= 1f + (float)Main.rand.Next(10) * 0.1f; Dust expr_1A88_cp_0 = Main.dust[num37]; expr_1A88_cp_0.velocity.Y = expr_1A88_cp_0.velocity.Y - 1f; } } } if (type == 4 && Main.rand.Next(40) == 0 && tile.frameX < 66) { int num38 = (int)(tile.frameY / 22); if (num38 == 0) { num38 = 6; } else { if (num38 == 8) { num38 = 75; } else { if (num38 == 9) { num38 = 135; } else { if (num38 == 10) { num38 = 158; } else { if (num38 == 11) { num38 = 169; } else { if (num38 == 12) { num38 = 156; } else { num38 = 58 + num38; } } } } } } int num39; if (tile.frameX == 22) { num39 = Dust.NewDust(new Vector2((float)(j * 16 + 6), (float)(i * 16)), 4, 4, num38, 0f, 0f, 100, default(Color), 1f); } if (tile.frameX == 44) { num39 = Dust.NewDust(new Vector2((float)(j * 16 + 2), (float)(i * 16)), 4, 4, num38, 0f, 0f, 100, default(Color), 1f); } else { num39 = Dust.NewDust(new Vector2((float)(j * 16 + 4), (float)(i * 16)), 4, 4, num38, 0f, 0f, 100, default(Color), 1f); } if (Main.rand.Next(3) != 0) { Main.dust[num39].noGravity = true; } Main.dust[num39].velocity *= 0.3f; Dust expr_1C3A_cp_0 = Main.dust[num39]; expr_1C3A_cp_0.velocity.Y = expr_1C3A_cp_0.velocity.Y - 1.5f; } if (type == 93 && Main.rand.Next(40) == 0 && tile.frameX == 0) { int num40 = (int)(tile.frameY / 54); if (tile.frameY / 18 % 3 == 0) { int num41 = num40; if (num41 == 0) { goto IL_1CE8; } int num42; switch (num41) { case 6: case 7: case 8: case 10: case 14: case 15: case 16: goto IL_1CE8; case 20: num42 = 59; goto IL_1CF6; } num42 = -1; IL_1CF6: if (num42 != -1) { int num43 = Dust.NewDust(new Vector2((float)(j * 16 + 4), (float)(i * 16 + 2)), 4, 4, num42, 0f, 0f, 100, default(Color), 1f); if (Main.rand.Next(3) != 0) { Main.dust[num43].noGravity = true; } Main.dust[num43].velocity *= 0.3f; Dust expr_1D82_cp_0 = Main.dust[num43]; expr_1D82_cp_0.velocity.Y = expr_1D82_cp_0.velocity.Y - 1.5f; goto IL_1D93; } goto IL_1D93; IL_1CE8: num42 = 6; goto IL_1CF6; } } IL_1D93: if (type == 100 && Main.rand.Next(40) == 0 && tile.frameX < 36) { int num44 = (int)(tile.frameY / 36); if (tile.frameY / 18 % 2 == 0) { int num45; switch (num44) { case 0: case 2: case 5: case 7: case 8: case 10: case 12: case 14: case 15: case 16: num45 = 6; break; case 1: case 3: case 4: case 6: case 9: case 11: case 13: case 17: case 18: case 19: goto IL_1E4C; case 20: num45 = 59; break; default: goto IL_1E4C; } IL_1E4F: if (num45 != -1) { Vector2 position2; if (tile.frameX == 0) { if (Main.rand.Next(3) == 0) { position2 = new Vector2((float)(j * 16 + 4), (float)(i * 16 + 2)); } else { position2 = new Vector2((float)(j * 16 + 14), (float)(i * 16 + 2)); } } else { if (Main.rand.Next(3) == 0) { position2 = new Vector2((float)(j * 16 + 6), (float)(i * 16 + 2)); } else { position2 = new Vector2((float)(j * 16), (float)(i * 16 + 2)); } } int num46 = Dust.NewDust(position2, 4, 4, num45, 0f, 0f, 100, default(Color), 1f); if (Main.rand.Next(3) != 0) { Main.dust[num46].noGravity = true; } Main.dust[num46].velocity *= 0.3f; Dust expr_1F4F_cp_0 = Main.dust[num46]; expr_1F4F_cp_0.velocity.Y = expr_1F4F_cp_0.velocity.Y - 1.5f; goto IL_1F60; } goto IL_1F60; IL_1E4C: num45 = -1; goto IL_1E4F; } } IL_1F60: if (type == 98 && Main.rand.Next(40) == 0 && tile.frameY == 0 && tile.frameX == 0) { int num47 = Dust.NewDust(new Vector2((float)(j * 16 + 12), (float)(i * 16 + 2)), 4, 4, 6, 0f, 0f, 100, default(Color), 1f); if (Main.rand.Next(3) != 0) { Main.dust[num47].noGravity = true; } Main.dust[num47].velocity *= 0.3f; Dust expr_2016_cp_0 = Main.dust[num47]; expr_2016_cp_0.velocity.Y = expr_2016_cp_0.velocity.Y - 1.5f; } if (type == 49 && Main.rand.Next(2) == 0) { int num48 = Dust.NewDust(new Vector2((float)(j * 16 + 4), (float)(i * 16 - 4)), 4, 4, 172, 0f, 0f, 100, default(Color), 1f); if (Main.rand.Next(3) == 0) { Main.dust[num48].scale = 0.5f; } else { Main.dust[num48].scale = 0.9f; Main.dust[num48].noGravity = true; } Main.dust[num48].velocity *= 0.3f; Dust expr_20ED_cp_0 = Main.dust[num48]; expr_20ED_cp_0.velocity.Y = expr_20ED_cp_0.velocity.Y - 1.5f; } if (type == 34 && Main.rand.Next(40) == 0 && tile.frameX < 54) { int num49 = (int)(tile.frameY / 54); int num50 = (int)(tile.frameX / 18 % 3); int num51 = (int)(tile.frameY / 18 % 3); if (num51 == 1 && num50 != 1) { int num41 = num49; int num52; switch (num41) { case 0: case 1: case 2: case 3: case 4: case 5: case 12: case 13: case 16: goto IL_21D3; case 6: case 7: case 8: case 9: case 10: case 11: case 14: case 15: goto IL_21DE; default: switch (num41) { case 19: case 21: goto IL_21D3; case 20: goto IL_21DE; default: if (num41 != 25) { goto IL_21DE; } num52 = 59; break; } break; } IL_21E1: if (num52 != 1) { int num53 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16 + 2)), 14, 6, num52, 0f, 0f, 100, default(Color), 1f); if (Main.rand.Next(3) != 0) { Main.dust[num53].noGravity = true; } Main.dust[num53].velocity *= 0.3f; Dust expr_226C_cp_0 = Main.dust[num53]; expr_226C_cp_0.velocity.Y = expr_226C_cp_0.velocity.Y - 1.5f; goto IL_227D; } goto IL_227D; IL_21DE: num52 = -1; goto IL_21E1; IL_21D3: num52 = 6; goto IL_21E1; } } IL_227D: if (type == 22 && Main.rand.Next(400) == 0) { Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 14, 0f, 0f, 0, default(Color), 1f); } else { if ((type == 23 || type == 24 || type == 32) && Main.rand.Next(500) == 0) { Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 14, 0f, 0f, 0, default(Color), 1f); } else { if (type == 25 && Main.rand.Next(700) == 0) { Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 14, 0f, 0f, 0, default(Color), 1f); } else { if (type == 112 && Main.rand.Next(700) == 0) { Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 14, 0f, 0f, 0, default(Color), 1f); } else { if (type == 31 && Main.rand.Next(20) == 0) { if (tile.frameX >= 36) { int num54 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 5, 0f, 0f, 100, default(Color), 1f); Main.dust[num54].velocity.Y = 0f; Dust expr_246A_cp_0 = Main.dust[num54]; expr_246A_cp_0.velocity.X = expr_246A_cp_0.velocity.X * 0.3f; } else { Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 14, 0f, 0f, 100, default(Color), 1f); } } else { if (type == 26 && Main.rand.Next(20) == 0) { if (tile.frameX >= 54) { int num55 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 5, 0f, 0f, 100, default(Color), 1f); Main.dust[num55].scale = 1.5f; Main.dust[num55].noGravity = true; Main.dust[num55].velocity *= 0.75f; } else { Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 14, 0f, 0f, 100, default(Color), 1f); } } else { if ((type == 71 || type == 72) && Main.rand.Next(500) == 0) { Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 41, 0f, 0f, 250, default(Color), 0.8f); } else { if ((type == 17 || type == 77 || type == 133) && Main.rand.Next(40) == 0) { if (tile.frameX == 18 & tile.frameY == 18) { int num56 = Dust.NewDust(new Vector2((float)(j * 16 - 4), (float)(i * 16 - 6)), 8, 6, 6, 0f, 0f, 100, default(Color), 1f); if (Main.rand.Next(3) != 0) { Main.dust[num56].noGravity = true; } } } else { if (type == 37 && Main.rand.Next(250) == 0) { int num57 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 6, 0f, 0f, 0, default(Color), (float)Main.rand.Next(3)); if (Main.dust[num57].scale > 1f) { Main.dust[num57].noGravity = true; } } else { if ((type == 58 || type == 76) && Main.rand.Next(250) == 0) { int num58 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 6, 0f, 0f, 0, default(Color), (float)Main.rand.Next(3)); if (Main.dust[num58].scale > 1f) { Main.dust[num58].noGravity = true; } Main.dust[num58].noLight = true; } else { if (type == 61) { if (tile.frameX == 144) { if (Main.rand.Next(60) == 0) { int num59 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 44, 0f, 0f, 250, default(Color), 0.4f); Main.dust[num59].fadeIn = 0.7f; } color.A = (byte)(245f - (float)Main.mouseTextColor * 1.5f); color.R = (byte)(245f - (float)Main.mouseTextColor * 1.5f); color.B = (byte)(245f - (float)Main.mouseTextColor * 1.5f); color.G = (byte)(245f - (float)Main.mouseTextColor * 1.5f); } } else { if (Main.tileShine[(int)type] > 0) { Main.tileShine[211] = 500; if (color.R > 20 || color.B > 20 || color.G > 20) { int num60 = (int)color.R; if ((int)color.G > num60) { num60 = (int)color.G; } if ((int)color.B > num60) { num60 = (int)color.B; } num60 /= 30; if (Main.rand.Next(Main.tileShine[(int)type]) < num60 && (type != 21 || (tile.frameX >= 36 && tile.frameX < 180) || (tile.frameX >= 360 && tile.frameX < 1008))) { Color white = Color.White; if (type == 178) { int num61 = (int)(tile.frameX / 18); if (num61 == 0) { white = new Color(255, 0, 255, 255); } else { if (num61 == 1) { white = new Color(255, 255, 0, 255); } else { if (num61 == 2) { white = new Color(0, 0, 255, 255); } else { if (num61 == 3) { white = new Color(0, 255, 0, 255); } else { if (num61 == 4) { white = new Color(255, 0, 0, 255); } else { if (num61 == 5) { white = new Color(255, 255, 255, 255); } else { if (num61 == 6) { white = new Color(255, 255, 0, 255); } } } } } } } int num62 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 43, 0f, 0f, 254, white, 0.5f); Main.dust[num62].velocity *= 0f; } else { if (type == 63) { white = new Color(0, 0, 255, 255); } if (type == 64) { white = new Color(255, 0, 0, 255); } if (type == 65) { white = new Color(0, 255, 0, 255); } if (type == 66) { white = new Color(255, 255, 0, 255); } if (type == 67) { white = new Color(255, 0, 255, 255); } if (type == 68) { white = new Color(255, 255, 255, 255); } if (type == 12) { white = new Color(255, 0, 0, 255); } if (type == 204) { white = new Color(255, 0, 0, 255); } if (type == 211) { white = new Color(50, 255, 100, 255); } int num63 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 43, 0f, 0f, 254, white, 0.5f); Main.dust[num63].velocity *= 0f; } } } } } } } } } } } } } } } } if (type == 269 || type == 128) { int num64 = (int)(tile.frameY / 18); if (num64 == 2) { if (tile.frameX >= 100) { bool flag4 = false; int l = (int)Main.tile[j, i - 1].frameX; if (l >= 100) { int num65 = 0; while (l >= 100) { num65++; l -= 100; } int num41 = num65; if (num41 <= 36) { if (num41 != 15 && num41 != 36) { goto IL_2CD6; } } else { switch (num41) { case 41: case 42: break; default: switch (num41) { case 58: case 59: case 60: case 61: case 62: case 63: break; default: goto IL_2CD6; } break; } } flag4 = true; } IL_2CD6: if (!flag4) { array[num3] = j; array2[num3] = i; num3++; } } if (Main.tile[j, i - 1].frameX >= 100) { array[num3] = j; array2[num3] = i - 1; num3++; } if (Main.tile[j, i - 2].frameX >= 100) { array[num3] = j; array2[num3] = i - 2; num3++; } } } if (type == 5 && tile.frameY >= 198 && tile.frameX >= 22) { array[num3] = j; array2[num3] = i; num3++; } if (type == 323 && tile.frameX <= 132 && tile.frameX >= 88) { array[num3] = j; array2[num3] = i; num3++; } if (type == 237 && tile.frameX == 18 && tile.frameY == 0) { array[num3] = j; array2[num3] = i; num3++; } if (type == 334) { int num66 = (int)(tile.frameY / 18); if (num66 == 1 && tile.frameX >= 5000) { int m = (int)Main.tile[j, i].frameX; int num67 = 0; while (m >= 5000) { num67++; m -= 5000; } if (num67 == 1 || num67 == 4) { array[num3] = j; array2[num3] = i; num3++; } } } if (type == 5 && tile.frameY >= 198 && tile.frameX >= 22) { array[num3] = j; array2[num3] = i; num3++; } if (type == 323 && tile.frameX <= 132 && tile.frameX >= 88) { array[num3] = j; array2[num3] = i; num3++; } if (type == 237 && tile.frameX == 18 && tile.frameY == 0) { array[num3] = j; array2[num3] = i; num3++; } if (type == 72 && tile.frameX >= 36) { int num68 = 0; if (tile.frameY == 18) { num68 = 1; } else { if (tile.frameY == 36) { num68 = 2; } } Main.spriteBatch.Draw(Main.shroomCapTexture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X - 22), (float)(i * 16 - (int)Main.screenPosition.Y - 26)) + zero, new Rectangle?(new Rectangle(num68 * 62, 0, 60, 42)), Lighting.GetColor(j, i), 0f, default(Vector2), 1f, effects, 0f); } if (color.R > 1 || color.G > 1 || color.B > 1) { Tile tile2 = Main.tile[j + 1, i]; Tile tile3 = Main.tile[j - 1, i]; Tile tile4 = Main.tile[j, i - 1]; Tile tile5 = Main.tile[j, i + 1]; if (tile2 == null) { tile2 = new Tile(); Main.tile[j + 1, i] = tile2; } if (tile3 == null) { tile3 = new Tile(); Main.tile[j - 1, i] = tile3; } if (tile4 == null) { tile4 = new Tile(); Main.tile[j, i - 1] = tile4; } if (tile5 == null) { tile5 = new Tile(); Main.tile[j, i + 1] = tile5; } if (solidOnly && flag && !tile.inActive() && !Main.tileSolidTop[(int)type]) { bool flag5 = false; if (tile.halfBrick()) { int num69 = 160; if (((int)tile3.liquid > num69 || (int)tile2.liquid > num69) && this.waterfallManager.CheckForWaterfall(j, i)) { flag5 = true; } } if (!flag5) { int num70 = 0; bool flag6 = false; bool flag7 = false; bool flag8 = false; bool flag9 = false; int num71 = 0; bool flag10 = false; int num72 = (int)tile.slope(); if (tile3.liquid > 0 && num72 != 1 && num72 != 3) { flag6 = true; switch (tile3.liquidType()) { case 0: flag10 = true; break; case 1: num71 = 1; break; case 2: num71 = 11; break; } if ((int)tile3.liquid > num70) { num70 = (int)tile3.liquid; } } if (tile2.liquid > 0 && num72 != 2 && num72 != 4) { flag7 = true; switch (tile2.liquidType()) { case 0: flag10 = true; break; case 1: num71 = 1; break; case 2: num71 = 11; break; } if ((int)tile2.liquid > num70) { num70 = (int)tile2.liquid; } } if (tile4.liquid > 0 && num72 != 3 && num72 != 4) { flag8 = true; switch (tile4.liquidType()) { case 0: flag10 = true; break; case 1: num71 = 1; break; case 2: num71 = 11; break; } } if (tile5.liquid > 0 && num72 != 1 && num72 != 2) { if (tile5.liquid > 240) { flag9 = true; } switch (tile5.liquidType()) { case 0: flag10 = true; break; case 1: num71 = 1; break; case 2: num71 = 11; break; } } if (num71 == 0) { num71 = Main.waterStyle; } if ((flag8 || flag9 || flag6 || flag7) && (!flag10 || num71 != 1)) { Color color2 = Lighting.GetColor(j, i); Vector2 value = new Vector2((float)(j * 16), (float)(i * 16)); Rectangle value2 = new Rectangle(0, 4, 16, 16); if (flag9 && (flag6 || flag7)) { flag6 = true; flag7 = true; } if ((!flag8 || (!flag6 && !flag7)) && (!flag9 || !flag8)) { if (flag8) { value2 = new Rectangle(0, 4, 16, 4); if (tile.halfBrick() || tile.slope() != 0) { value2 = new Rectangle(0, 4, 16, 12); } } else { if (flag9 && !flag6 && !flag7) { value = new Vector2((float)(j * 16), (float)(i * 16 + 12)); value2 = new Rectangle(0, 4, 16, 4); } else { float num73 = (float)(256 - num70); num73 /= 32f; int y = 4; if (tile4.liquid == 0 && !WorldGen.SolidTile(j, i - 1)) { y = 0; } if ((flag6 && flag7) || tile.halfBrick() || tile.slope() != 0) { value = new Vector2((float)(j * 16), (float)(i * 16 + (int)num73 * 2)); value2 = new Rectangle(0, y, 16, 16 - (int)num73 * 2); } else { if (flag6) { value = new Vector2((float)(j * 16), (float)(i * 16 + (int)num73 * 2)); value2 = new Rectangle(0, y, 4, 16 - (int)num73 * 2); } else { value = new Vector2((float)(j * 16 + 12), (float)(i * 16 + (int)num73 * 2)); value2 = new Rectangle(0, y, 4, 16 - (int)num73 * 2); } } } } } float num74 = 0.5f; if (num71 == 1) { num74 = 1f; } else { if (num71 == 11) { num74 *= 1.7f; if (num74 > 1f) { num74 = 1f; } } } if ((double)i < Main.worldSurface || num74 > 1f) { num74 = 1f; if (tile4.wall > 0 || tile3.wall > 0 || tile2.wall > 0 || tile5.wall > 0) { num74 = 0.65f; } if (tile.wall > 0) { num74 = 0.5f; } } if (tile.halfBrick() && tile4.liquid > 0 && tile.wall > 0) { num74 = 0f; } float num75 = (float)color2.R * num74; float num76 = (float)color2.G * num74; float num77 = (float)color2.B * num74; float num78 = (float)color2.A * num74; color2 = new Color((int)((byte)num75), (int)((byte)num76), (int)((byte)num77), (int)((byte)num78)); Main.spriteBatch.Draw(Main.liquidTexture[num71], value - Main.screenPosition + zero, new Rectangle?(value2), color2, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } } } if (type == 314) { if (tile.inActive()) { color = tile.actColor(color); } else { if (Main.tileShine2[(int)type]) { color = Main.shine(color, (int)type); } } int num79; int num80; Minecart.TrackColors(j, i, tile, out num79, out num80); Texture2D texture; if (Main.canDrawColorTile(type, num79)) { texture = Main.tileAltTexture[(int)type, num79]; } else { texture = Main.tileTexture[(int)type]; } Texture2D texture2; if (Main.canDrawColorTile(type, num80)) { texture2 = Main.tileAltTexture[(int)type, num80]; } else { texture2 = Main.tileTexture[(int)type]; } tile.frameNumber(); if (tile.frameY != -1) { Main.spriteBatch.Draw(texture2, new Vector2((float)(j * 16 - (int)Main.screenPosition.X), (float)(i * 16 - (int)Main.screenPosition.Y)) + zero, new Rectangle?(Minecart.GetSourceRect((int)tile.frameY, Main.tileFrame[314])), color, 0f, default(Vector2), 1f, effects, 0f); } Main.spriteBatch.Draw(texture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X), (float)(i * 16 - (int)Main.screenPosition.Y)) + zero, new Rectangle?(Minecart.GetSourceRect((int)tile.frameX, Main.tileFrame[314])), color, 0f, default(Vector2), 1f, effects, 0f); if (Minecart.DrawLeftDecoration((int)tile.frameY)) { Main.spriteBatch.Draw(texture2, new Vector2((float)(j * 16 - (int)Main.screenPosition.X), (float)((i + 1) * 16 - (int)Main.screenPosition.Y)) + zero, new Rectangle?(Minecart.GetSourceRect(36, 0)), color, 0f, default(Vector2), 1f, effects, 0f); } if (Minecart.DrawLeftDecoration((int)tile.frameX)) { Main.spriteBatch.Draw(texture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X), (float)((i + 1) * 16 - (int)Main.screenPosition.Y)) + zero, new Rectangle?(Minecart.GetSourceRect(36, 0)), color, 0f, default(Vector2), 1f, effects, 0f); } if (Minecart.DrawRightDecoration((int)tile.frameY)) { Main.spriteBatch.Draw(texture2, new Vector2((float)(j * 16 - (int)Main.screenPosition.X), (float)((i + 1) * 16 - (int)Main.screenPosition.Y)) + zero, new Rectangle?(Minecart.GetSourceRect(37, Main.tileFrame[314])), color, 0f, default(Vector2), 1f, effects, 0f); } if (Minecart.DrawRightDecoration((int)tile.frameX)) { Main.spriteBatch.Draw(texture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X), (float)((i + 1) * 16 - (int)Main.screenPosition.Y)) + zero, new Rectangle?(Minecart.GetSourceRect(37, 0)), color, 0f, default(Vector2), 1f, effects, 0f); } if (Minecart.DrawBumper((int)tile.frameX)) { Main.spriteBatch.Draw(texture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X), (float)((i - 1) * 16 - (int)Main.screenPosition.Y)) + zero, new Rectangle?(Minecart.GetSourceRect(39, 0)), color, 0f, default(Vector2), 1f, effects, 0f); } else { if (Minecart.DrawBouncyBumper((int)tile.frameX)) { Main.spriteBatch.Draw(texture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X), (float)((i - 1) * 16 - (int)Main.screenPosition.Y)) + zero, new Rectangle?(Minecart.GetSourceRect(38, 0)), color, 0f, default(Vector2), 1f, effects, 0f); } } } else { if (type == 51) { Color color3 = Lighting.GetColor(j, i); float num81 = 0.5f; float num82 = (float)color3.R * num81; float num83 = (float)color3.G * num81; float num84 = (float)color3.B * num81; float num85 = (float)color3.A * num81; color3 = new Color((int)((byte)num82), (int)((byte)num83), (int)((byte)num84), (int)((byte)num85)); if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color3, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color3, 0f, default(Vector2), 1f, effects, 0f); } } else { if (type == 171) { if (tile.frameX >= 10) { int num86 = 0; if ((tile.frameY & 1) == 1) { num86++; } if ((tile.frameY & 2) == 2) { num86 += 2; } if ((tile.frameY & 4) == 4) { num86 += 4; } int num87 = 0; if ((tile.frameY & 8) == 8) { num87++; } if ((tile.frameY & 16) == 16) { num87 += 2; } if ((tile.frameY & 32) == 32) { num87 += 4; } int num88 = 0; if ((tile.frameY & 64) == 64) { num88++; } if ((tile.frameY & 128) == 128) { num88 += 2; } if ((tile.frameY & 256) == 256) { num88 += 4; } if ((tile.frameY & 512) == 512) { num88 += 8; } int num89 = 0; if ((tile.frameY & 1024) == 1024) { num89++; } if ((tile.frameY & 2048) == 2048) { num89 += 2; } if ((tile.frameY & 4096) == 4096) { num89 += 4; } if ((tile.frameY & 8192) == 8192) { num89 += 8; } Color color4 = Lighting.GetColor(j + 1, i + 4); Main.spriteBatch.Draw(Main.xmasTree[0], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle(0, 0, 64, 128)), color4, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); if (num86 > 0) { num86--; Color color5 = color4; if (num86 != 3) { color5 = new Color(255, 255, 255, 255); } Main.spriteBatch.Draw(Main.xmasTree[3], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle(66 * num86, 0, 64, 128)), color5, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } if (num87 > 0) { num87--; Main.spriteBatch.Draw(Main.xmasTree[1], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle(66 * num87, 0, 64, 128)), color4, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } if (num88 > 0) { num88--; Main.spriteBatch.Draw(Main.xmasTree[2], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle(66 * num88, 0, 64, 128)), color4, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } if (num89 > 0) { num89--; Main.spriteBatch.Draw(Main.xmasTree[4], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle(66 * num89, 130 * Main.tileFrame[171], 64, 128)), new Color(255, 255, 255, 255), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } } } else { if (type == 160 && !tile.halfBrick()) { Color color6 = default(Color); color6 = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 255); if (tile.inActive()) { color6 = tile.actColor(color6); } if (tile.slope() == 0) { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color6, 0f, default(Vector2), 1f, effects, 0f); } else { if (tile.slope() > 2) { if (tile.slope() == 3) { for (int n = 0; n < 8; n++) { int num90 = 2; int num91 = n * 2; int num92 = n * -2; int num93 = 16 - n * 2; if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num91, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + n * num90 + num92)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num91, (int)(tile.frameY + 16) - num93, num90, num93)), color6, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num91, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + n * num90 + num92)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num91, (int)(tile.frameY + 16) - num93, num90, num93)), color6, 0f, default(Vector2), 1f, effects, 0f); } } } else { for (int num94 = 0; num94 < 8; num94++) { int num95 = 2; int num96 = 16 - num94 * num95 - num95; int num97 = 16 - num94 * num95; int num98 = num94 * -2; if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num96, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num94 * num95 + num98)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num96, (int)(tile.frameY + 16) - num97, num95, num97)), color6, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num96, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num94 * num95 + num98)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num96, (int)(tile.frameY + 16) - num97, num95, num97)), color6, 0f, default(Vector2), 1f, effects, 0f); } } } if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, 16, 2)), color6, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, 16, 2)), color6, 0f, default(Vector2), 1f, effects, 0f); } } else { if (tile.slope() == 1) { for (int num99 = 0; num99 < 8; num99++) { int num100 = 2; int num101 = num99 * 2; int height = 14 - num99 * num100; Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num101, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num99 * num100)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num101, (int)tile.frameY, num100, height)), color6, 0f, default(Vector2), 1f, effects, 0f); } } if (tile.slope() == 2) { for (int num102 = 0; num102 < 8; num102++) { int num103 = 2; int num104 = 16 - num102 * num103 - num103; int height2 = 14 - num102 * num103; Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num104, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num102 * num103)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num104, (int)tile.frameY, num103, height2)), color6, 0f, default(Vector2), 1f, effects, 0f); } } Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 14)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)(tile.frameY + 14), 16, 2)), color6, 0f, default(Vector2), 1f, effects, 0f); } } } else { if (tile.slope() > 0) { if (tile.inActive()) { color = tile.actColor(color); } else { if (Main.tileShine2[(int)type]) { color = Main.shine(color, (int)type); } } if (tile.type == 19) { if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, 16, 16)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, 16, 16)), color, 0f, default(Vector2), 1f, effects, 0f); } if (tile.slope() == 1 && Main.tile[j + 1, i + 1].active() && Main.tile[j + 1, i + 1].slope() != 2 && !Main.tile[j + 1, i + 1].halfBrick()) { if (Main.tile[j + 1, i + 1].type == 19 && Main.tile[j + 1, i + 1].slope() == 0) { if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 16)) + zero, new Rectangle?(new Rectangle(324, (int)tile.frameY, 16, 16)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 16)) + zero, new Rectangle?(new Rectangle(324, (int)tile.frameY, 16, 16)), color, 0f, default(Vector2), 1f, effects, 0f); } } else { if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 16)) + zero, new Rectangle?(new Rectangle(198, (int)tile.frameY, 16, 16)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 16)) + zero, new Rectangle?(new Rectangle(198, (int)tile.frameY, 16, 16)), color, 0f, default(Vector2), 1f, effects, 0f); } } } else { if (tile.slope() == 2 && Main.tile[j - 1, i + 1].active() && Main.tile[j - 1, i + 1].slope() != 1 && !Main.tile[j - 1, i + 1].halfBrick()) { if (Main.tile[j - 1, i + 1].type == 19 && Main.tile[j - 1, i + 1].slope() == 0) { if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 16)) + zero, new Rectangle?(new Rectangle(306, (int)tile.frameY, 16, 16)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 16)) + zero, new Rectangle?(new Rectangle(306, (int)tile.frameY, 16, 16)), color, 0f, default(Vector2), 1f, effects, 0f); } } else { if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 16)) + zero, new Rectangle?(new Rectangle(162, (int)tile.frameY, 16, 16)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 16)) + zero, new Rectangle?(new Rectangle(162, (int)tile.frameY, 16, 16)), color, 0f, default(Vector2), 1f, effects, 0f); } } } } } else { if (tile.slope() > 2) { if (tile.slope() == 3) { for (int num105 = 0; num105 < 8; num105++) { int num106 = 2; int num107 = num105 * 2; int num108 = num105 * -2; int num109 = 16 - num105 * 2; if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num107, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num105 * num106 + num108)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num107 + num14, (int)(tile.frameY + 16) - num109 + num13, num106, num109)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num107, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num105 * num106 + num108)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num107 + num14, (int)(tile.frameY + 16) - num109 + num13, num106, num109)), color, 0f, default(Vector2), 1f, effects, 0f); } } } else { for (int num110 = 0; num110 < 8; num110++) { int num111 = 2; int num112 = 16 - num110 * num111 - num111; int num113 = 16 - num110 * num111; int num114 = num110 * -2; if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num112, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num110 * num111 + num114)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num112 + num14, (int)(tile.frameY + 16) - num113 + num13, num111, num113)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num112, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num110 * num111 + num114)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num112 + num14, (int)(tile.frameY + 16) - num113 + num13, num111, num113)), color, 0f, default(Vector2), 1f, effects, 0f); } } } if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num14, (int)tile.frameY + num13, 16, 2)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num14, (int)tile.frameY + num13, 16, 2)), color, 0f, default(Vector2), 1f, effects, 0f); } } else { if (tile.slope() == 1) { for (int num115 = 0; num115 < 8; num115++) { int num116 = 2; int num117 = num115 * 2; int height3 = 14 - num115 * num116; if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num117, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num115 * num116)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num117 + num14, (int)tile.frameY + num13, num116, height3)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num117, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num115 * num116)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num117 + num14, (int)tile.frameY + num13, num116, height3)), color, 0f, default(Vector2), 1f, effects, 0f); } } } if (tile.slope() == 2) { for (int num118 = 0; num118 < 8; num118++) { int num119 = 2; int num120 = 16 - num118 * num119 - num119; int height4 = 14 - num118 * num119; if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num120, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num118 * num119)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num120 + num14, (int)tile.frameY + num13, num119, height4)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num120, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num118 * num119)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num120 + num14, (int)tile.frameY + num13, num119, height4)), color, 0f, default(Vector2), 1f, effects, 0f); } } } if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 14)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num14, (int)(tile.frameY + 14) + num13, 16, 2)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 14)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num14, (int)(tile.frameY + 14) + num13, 16, 2)), color, 0f, default(Vector2), 1f, effects, 0f); } } } } else { if (type == 129) { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(200, 200, 200, 0), 0f, default(Vector2), 1f, effects, 0f); } else { if (Main.tileAlch[(int)type]) { num11 = 20; num10 = -1; int num121 = (int)type; int num122 = (int)(tile.frameX / 18); if (num121 > 82) { if (num122 == 0 && Main.dayTime) { num121 = 84; } if (num122 == 1 && !Main.dayTime) { num121 = 84; } if (num122 == 3 && Main.bloodMoon) { num121 = 84; } if (num122 == 4 && (Main.raining || Main.cloudAlpha > 0f)) { num121 = 84; } } if (num121 == 84) { if (num122 == 0 && Main.rand.Next(100) == 0) { int num123 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16 - 4)), 16, 16, 19, 0f, 0f, 160, default(Color), 0.1f); Dust expr_5AF7_cp_0 = Main.dust[num123]; expr_5AF7_cp_0.velocity.X = expr_5AF7_cp_0.velocity.X / 2f; Dust expr_5B15_cp_0 = Main.dust[num123]; expr_5B15_cp_0.velocity.Y = expr_5B15_cp_0.velocity.Y / 2f; Main.dust[num123].noGravity = true; Main.dust[num123].fadeIn = 1f; } if (num122 == 1 && Main.rand.Next(100) == 0) { Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 41, 0f, 0f, 250, default(Color), 0.8f); } if (num122 == 3) { if (Main.rand.Next(200) == 0) { int num124 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 14, 0f, 0f, 100, default(Color), 0.2f); Main.dust[num124].fadeIn = 1.2f; } if (Main.rand.Next(75) == 0) { int num125 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 27, 0f, 0f, 100, default(Color), 1f); Dust expr_5C58_cp_0 = Main.dust[num125]; expr_5C58_cp_0.velocity.X = expr_5C58_cp_0.velocity.X / 2f; Dust expr_5C76_cp_0 = Main.dust[num125]; expr_5C76_cp_0.velocity.Y = expr_5C76_cp_0.velocity.Y / 2f; } } if (num122 == 4 && Main.rand.Next(150) == 0) { int num126 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 8, 16, 0f, 0f, 0, default(Color), 1f); Dust expr_5CEB_cp_0 = Main.dust[num126]; expr_5CEB_cp_0.velocity.X = expr_5CEB_cp_0.velocity.X / 3f; Dust expr_5D09_cp_0 = Main.dust[num126]; expr_5D09_cp_0.velocity.Y = expr_5D09_cp_0.velocity.Y / 3f; Dust expr_5D27_cp_0 = Main.dust[num126]; expr_5D27_cp_0.velocity.Y = expr_5D27_cp_0.velocity.Y - 0.7f; Main.dust[num126].alpha = 50; Main.dust[num126].scale *= 0.1f; Main.dust[num126].fadeIn = 0.9f; Main.dust[num126].noGravity = true; } if (num122 == 5) { if (Main.rand.Next(40) == 0) { int num127 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16 - 6)), 16, 16, 6, 0f, 0f, 0, default(Color), 1.5f); Dust expr_5DE0_cp_0 = Main.dust[num127]; expr_5DE0_cp_0.velocity.Y = expr_5DE0_cp_0.velocity.Y - 2f; Main.dust[num127].noGravity = true; } color.A = Main.mouseTextColor / 2; color.G = Main.mouseTextColor; color.B = Main.mouseTextColor; } if (num122 == 6) { if (Main.rand.Next(30) == 0) { Color newColor = new Color(50, 255, 255, 255); int num128 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, 43, 0f, 0f, 254, newColor, 0.5f); Main.dust[num128].velocity *= 0f; } byte b3 = (Main.mouseTextColor + color.G * 2) / 3; byte b4 = (Main.mouseTextColor + color.B * 2) / 3; if (b3 > color.G) { color.G = b3; } if (b4 > color.B) { color.B = b4; } } } if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } else { this.LoadTiles(num121); Main.spriteBatch.Draw(Main.tileTexture[num121], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } } else { if (type == 80) { bool flag11 = false; bool flag12 = false; bool flag13 = false; if (!Main.canDrawColorTile(j, i)) { int num129 = j; if (tile.frameX == 36) { num129--; } if (tile.frameX == 54) { num129++; } if (tile.frameX == 108) { if (tile.frameY == 18) { num129--; } else { num129++; } } int num130 = i; bool flag14 = false; if (Main.tile[num129, num130].type == 80 && Main.tile[num129, num130].active()) { flag14 = true; } while (!Main.tile[num129, num130].active() || !Main.tileSolid[(int)Main.tile[num129, num130].type] || !flag14) { if (Main.tile[num129, num130].type == 80 && Main.tile[num129, num130].active()) { flag14 = true; } num130++; if (num130 > i + 20) { break; } } if (Main.tile[num129, num130].type == 112) { flag11 = true; } if (Main.tile[num129, num130].type == 116) { flag12 = true; } if (Main.tile[num129, num130].type == 234) { flag13 = true; } } if (flag11) { Main.spriteBatch.Draw(Main.evilCactusTexture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } else { if (flag13) { Main.spriteBatch.Draw(Main.crimsonCactusTexture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } else { if (flag12) { Main.spriteBatch.Draw(Main.goodCactusTexture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } else { if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } } } } } else { if (type == 272 && !tile.halfBrick() && !Main.tile[j - 1, i].halfBrick() && !Main.tile[j + 1, i].halfBrick()) { int num131 = Main.tileFrame[(int)type]; num131 += j % 2; num131 += i % 2; num131 += j % 3; for (num131 += i % 3; num131 > 1; num131 -= 2) { } num131 *= 90; if (tile.inActive()) { color = tile.actColor(color); } else { if (Main.tileShine2[(int)type]) { color = Main.shine(color, (int)type); } } if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY + num131, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY + num131, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } } else { if (type == 160) { color = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 255); } if (type != 19 && Main.tileSolid[(int)type] && !tile.halfBrick() && (Main.tile[j - 1, i].halfBrick() || Main.tile[j + 1, i].halfBrick())) { if (tile.inActive()) { color = tile.actColor(color); } else { if (Main.tileShine2[(int)type]) { color = Main.shine(color, (int)type); } } if (Main.tile[j - 1, i].halfBrick() && Main.tile[j + 1, i].halfBrick()) { if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 8)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)(tile.frameY + 8), num9, 8)), color, 0f, default(Vector2), 1f, effects, 0f); Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle(126, 0, 16, 8)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 8)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)(tile.frameY + 8), num9, 8)), color, 0f, default(Vector2), 1f, effects, 0f); if (!Main.tile[j, i - 1].bottomSlope() && Main.tile[j, i - 1].type == type) { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle(90, 0, 16, 8)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle(126, 0, 16, 8)), color, 0f, default(Vector2), 1f, effects, 0f); } } } else { if (Main.tile[j - 1, i].halfBrick()) { if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 8)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)(tile.frameY + 8), num9, 8)), color, 0f, default(Vector2), 1f, effects, 0f); Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + 4f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)(tile.frameX + 4), (int)tile.frameY, num9 - 4, num11)), color, 0f, default(Vector2), 1f, effects, 0f); Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle(126, 0, 4, 8)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 8)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)(tile.frameY + 8), num9, 8)), color, 0f, default(Vector2), 1f, effects, 0f); Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + 4f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)(tile.frameX + 4), (int)tile.frameY, num9 - 4, num11)), color, 0f, default(Vector2), 1f, effects, 0f); Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle(126, 0, 4, 8)), color, 0f, default(Vector2), 1f, effects, 0f); } } else { if (Main.tile[j + 1, i].halfBrick()) { if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 8)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)(tile.frameY + 8), num9, 8)), color, 0f, default(Vector2), 1f, effects, 0f); Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9 - 4, num11)), color, 0f, default(Vector2), 1f, effects, 0f); Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + 12f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle(138, 0, 4, 8)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 8)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)(tile.frameY + 8), num9, 8)), color, 0f, default(Vector2), 1f, effects, 0f); Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9 - 4, num11)), color, 0f, default(Vector2), 1f, effects, 0f); Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + 12f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle(138, 0, 4, 8)), color, 0f, default(Vector2), 1f, effects, 0f); } } else { if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } } } } } else { if (Lighting.lightMode < 2 && Main.tileSolid[(int)type] && type != 137 && type != 235 && !tile.halfBrick() && !tile.inActive()) { if ((int)color.R > num || (double)color.G > (double)num * 1.1 || (double)color.B > (double)num * 1.2) { Lighting.GetColor9Slice(j, i, ref array3); bool flag15 = tile.inActive(); bool flag16 = Main.tileShine2[(int)type]; Texture2D texture; if (Main.canDrawColorTile(j, i)) { texture = Main.tileAltTexture[(int)type, (int)tile.color()]; } else { texture = Main.tileTexture[(int)type]; } for (int num132 = 0; num132 < 9; num132++) { int num133 = 0; int num134 = 0; int width = 4; int height5 = 4; switch (num132) { case 1: width = 8; num133 = 4; break; case 2: num133 = 12; break; case 3: height5 = 8; num134 = 4; break; case 4: width = 8; height5 = 8; num133 = 4; num134 = 4; break; case 5: num133 = 12; num134 = 4; height5 = 8; break; case 6: num134 = 12; break; case 7: width = 8; height5 = 4; num133 = 4; num134 = 12; break; case 8: num133 = 12; num134 = 12; break; } Color color7 = color; Color color8 = array3[num132]; color7.R = (color.R + color8.R) / 2; color7.G = (color.G + color8.G) / 2; color7.B = (color.B + color8.B) / 2; if (flag15) { color7 = tile.actColor(color7); } else { if (flag16) { color7 = Main.shine(color7, (int)type); } } Main.spriteBatch.Draw(texture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num133, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num134)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num133 + num14, (int)tile.frameY + num134 + num13, width, height5)), color7, 0f, default(Vector2), 1f, effects, 0f); } } else { if ((int)color.R > num2 || (double)color.G > (double)num2 * 1.1 || (double)color.B > (double)num2 * 1.2) { Lighting.GetColor4Slice(j, i, ref array3); bool flag17 = tile.inActive(); bool flag18 = Main.tileShine2[(int)type]; Texture2D texture; if (Main.canDrawColorTile(j, i)) { texture = Main.tileAltTexture[(int)type, (int)tile.color()]; } else { texture = Main.tileTexture[(int)type]; } for (int num135 = 0; num135 < 4; num135++) { int num136 = 0; int num137 = 0; switch (num135) { case 1: num136 = 8; break; case 2: num137 = 8; break; case 3: num136 = 8; num137 = 8; break; } Color color9 = color; Color color10 = array3[num135]; color9.R = (color.R + color10.R) / 2; color9.G = (color.G + color10.G) / 2; color9.B = (color.B + color10.B) / 2; if (flag17) { color9 = tile.actColor(color9); } else { if (flag18) { color9 = Main.shine(color9, (int)type); } } Main.spriteBatch.Draw(texture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)num136, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num137)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num136 + num14, (int)tile.frameY + num137 + num13, 8, 8)), color9, 0f, default(Vector2), 1f, effects, 0f); } } else { if (tile.inActive()) { color = tile.actColor(color); } else { if (Main.tileShine2[(int)type]) { color = Main.shine(color, (int)type); } } Texture2D texture; if (Main.canDrawColorTile(j, i)) { texture = Main.tileAltTexture[(int)type, (int)tile.color()]; } else { texture = Main.tileTexture[(int)type]; } Main.spriteBatch.Draw(texture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num14, (int)tile.frameY + num13, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } } } else { if (Lighting.lightMode < 2 && Main.tileShine2[(int)type]) { if (type == 21) { if (tile.frameX >= 36 && tile.frameX < 178) { color = Main.shine(color, (int)type); } } else { if (!tile.inActive()) { color = Main.shine(color, (int)type); } } } if (tile.inActive()) { color = tile.actColor(color); } if (type == 128 || type == 269) { int num138; for (num138 = (int)tile.frameX; num138 >= 100; num138 -= 100) { } Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle(num138, (int)tile.frameY, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } else { if (type == 334) { int num139 = (int)tile.frameX; int num140 = 0; while (num139 >= 5000) { num139 -= 5000; num140++; } if (num140 != 0) { num139 = (num140 - 1) * 18; } Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle(num139, (int)tile.frameY, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } else { if (type == 5) { int num141 = -1; int num142 = j; int num143 = i; if (tile.frameX == 66 && tile.frameY <= 45) { num142++; } if (tile.frameX == 88 && tile.frameY >= 66 && tile.frameY <= 110) { num142--; } if (tile.frameX == 22 && tile.frameY >= 132) { num142--; } if (tile.frameX == 44 && tile.frameY >= 132) { num142++; } while (Main.tile[num142, num143].active() && Main.tile[num142, num143].type == 5) { num143++; } if (Main.tile[num142, num143].active() && Main.tile[num142, num143].type == 23) { num141 = 0; } if (Main.tile[num142, num143].active() && Main.tile[num142, num143].type == 60) { num141 = 1; } if (Main.tile[num142, num143].active() && Main.tile[num142, num143].type == 70) { num141 = 6; } if (Main.tile[num142, num143].active() && Main.tile[num142, num143].type == 60 && (double)num143 > Main.worldSurface) { num141 = 5; } if (Main.tile[num142, num143].active() && Main.tile[num142, num143].type == 109) { num141 = 2; } if (Main.tile[num142, num143].active() && Main.tile[num142, num143].type == 147) { num141 = 3; if (WorldGen.snowBG == 0) { num141 = -1; } } if (Main.tile[num142, num143].active() && Main.tile[num142, num143].type == 199) { num141 = 4; } if (num141 == -1 || Main.canDrawColorTile(j, i)) { if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } } else { Main.spriteBatch.Draw(Main.woodTexture[num141], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } } else { if (type == 323) { int num144 = -1; int num145 = j; int num146 = i; while (Main.tile[num145, num146].active() && Main.tile[num145, num146].type == 323) { num146++; } if (Main.tile[num145, num146].active() && Main.tile[num145, num146].type == 53) { num144 = 0; } if (Main.tile[num145, num146].active() && Main.tile[num145, num146].type == 234) { num144 = 1; } if (Main.tile[num145, num146].active() && Main.tile[num145, num146].type == 116) { num144 = 2; } if (Main.tile[num145, num146].active() && Main.tile[num145, num146].type == 112) { num144 = 3; } int y2 = 22 * num144; int frameY = (int)tile.frameY; if (Main.canDrawColorTile(j, i)) { Main.spriteBatch.Draw(Main.tileAltTexture[(int)type, (int)tile.color()], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)frameY, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, y2, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(Main.tileTexture[(int)type], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + (float)frameY, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, y2, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } } else { if (num12 == 8 && (!Main.tile[j, i + 1].active() || !Main.tileSolid[(int)Main.tile[j, i + 1].type] || Main.tile[j, i + 1].halfBrick())) { Texture2D texture; if (Main.canDrawColorTile(j, i)) { texture = Main.tileAltTexture[(int)type, (int)tile.color()]; } else { texture = Main.tileTexture[(int)type]; } if (type == 19) { Main.spriteBatch.Draw(texture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num12)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), color, 0f, default(Vector2), 1f, effects, 0f); } else { Main.spriteBatch.Draw(texture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num12)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11 - num12 - 4)), color, 0f, default(Vector2), 1f, effects, 0f); Main.spriteBatch.Draw(texture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + 12)) + zero, new Rectangle?(new Rectangle(144, 66, num9, 4)), color, 0f, default(Vector2), 1f, effects, 0f); } } else { Texture2D texture; if (Main.canDrawColorTile(j, i)) { texture = Main.tileAltTexture[(int)type, (int)tile.color()]; } else { texture = Main.tileTexture[(int)type]; } Main.spriteBatch.Draw(texture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10 + num12)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num14, (int)tile.frameY + num13, num9, num11 - num12)), color, 0f, default(Vector2), 1f, effects, 0f); } if (type == 286) { Main.spriteBatch.Draw(Main.glowSnailTexture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num14, (int)tile.frameY + num13, num9, num11)), new Color(75, 100, 255, 0), 0f, default(Vector2), 1f, effects, 0f); } if (type == 270) { Main.spriteBatch.Draw(Main.fireflyJarTexture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num14, (int)tile.frameY, num9, num11)), new Color(200, 200, 200, 0), 0f, default(Vector2), 1f, effects, 0f); } if (type == 271) { Main.spriteBatch.Draw(Main.lightningbugJarTexture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num14, (int)tile.frameY, num9, num11)), new Color(200, 200, 200, 0), 0f, default(Vector2), 1f, effects, 0f); } if (type == 316 || type == 317 || type == 318) { int num147 = j - (int)(tile.frameX / 18); int num148 = i - (int)(tile.frameY / 18); int num149 = num147 / 2 * (num148 / 3); num149 %= Main.cageFrames; Main.spriteBatch.Draw(Main.jellyfishBowlTexture[(int)(type - 316)], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX + num14, (int)tile.frameY + Main.jellyfishCageFrame[(int)(type - 316), num149] * 36, num9, num11)), new Color(200, 200, 200, 0), 0f, default(Vector2), 1f, effects, 0f); } if (type == 149 && tile.frameX < 54) { Main.spriteBatch.Draw(Main.xmasLightTexture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(200, 200, 200, 0), 0f, default(Vector2), 1f, effects, 0f); } if (type == 300 || type == 302 || type == 303 || type == 306) { int num150 = 9; if (type == 302) { num150 = 10; } if (type == 303) { num150 = 11; } if (type == 306) { num150 = 12; } Main.spriteBatch.Draw(Main.FlameTexture[num150], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY + num13, num9, num11)), new Color(200, 200, 200, 0), 0f, default(Vector2), 1f, effects, 0f); } else { if (Main.tileFlame[(int)type]) { int num151 = (int)type; int num152 = 0; if (num151 == 4) { num152 = 0; } else { if (num151 == 33 || num151 == 174) { num152 = 1; } else { if (num151 == 100 || num151 == 173) { num152 = 2; } else { if (num151 == 34) { num152 = 3; } else { if (num151 == 93) { num152 = 4; } else { if (num151 == 49) { num152 = 5; } else { if (num151 == 98) { num152 = 6; } else { if (num151 == 35) { num152 = 7; } else { if (num151 == 42) { num152 = 13; } } } } } } } } } if (num152 == 7) { for (int num153 = 0; num153 < 4; num153++) { float num154 = (float)Main.rand.Next(-10, 11) * 0.15f; float num155 = (float)Main.rand.Next(-10, 10) * 0.15f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num154, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num155) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } if (num152 == 1) { int num156 = (int)(Main.tile[j, i].frameY / 22); if (num156 == 5 || num156 == 6 || num156 == 7 || num156 == 10) { for (int num157 = 0; num157 < 7; num157++) { float num158 = (float)Main.rand.Next(-10, 11) * 0.075f; float num159 = (float)Main.rand.Next(-10, 11) * 0.075f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num158, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num159) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num156 == 8) { for (int num160 = 0; num160 < 7; num160++) { float num161 = (float)Main.rand.Next(-10, 11) * 0.3f; float num162 = (float)Main.rand.Next(-10, 11) * 0.3f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num161, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num162) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num156 == 12) { for (int num163 = 0; num163 < 7; num163++) { float num164 = (float)Main.rand.Next(-10, 11) * 0.1f; float num165 = (float)Main.rand.Next(-10, 1) * 0.15f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num164, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num165) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num156 == 14) { for (int num166 = 0; num166 < 8; num166++) { float num167 = (float)Main.rand.Next(-10, 11) * 0.1f; float num168 = (float)Main.rand.Next(-10, 11) * 0.1f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num167, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num168) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(75, 75, 75, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num156 == 16) { for (int num169 = 0; num169 < 4; num169++) { float num170 = (float)Main.rand.Next(-10, 11) * 0.15f; float num171 = (float)Main.rand.Next(-10, 11) * 0.15f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num170, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num171) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(75, 75, 75, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { for (int num172 = 0; num172 < 7; num172++) { float num173 = (float)Main.rand.Next(-10, 11) * 0.15f; float num174 = (float)Main.rand.Next(-10, 1) * 0.35f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num173, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num174) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, effects, 0f); } } } } } } } else { if (num152 == 2) { int num175 = (int)(Main.tile[j, i].frameY / 36); if (num175 == 3) { for (int num176 = 0; num176 < 3; num176++) { float num177 = (float)Main.rand.Next(-10, 11) * 0.05f; float num178 = (float)Main.rand.Next(-10, 11) * 0.15f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num177, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num178) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num175 == 6) { for (int num179 = 0; num179 < 5; num179++) { float num180 = (float)Main.rand.Next(-10, 11) * 0.15f; float num181 = (float)Main.rand.Next(-10, 11) * 0.15f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num180, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num181) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(75, 75, 75, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num175 == 9) { for (int num182 = 0; num182 < 7; num182++) { float num183 = (float)Main.rand.Next(-10, 11) * 0.3f; float num184 = (float)Main.rand.Next(-10, 11) * 0.3f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num183, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num184) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num175 == 11) { for (int num185 = 0; num185 < 7; num185++) { float num186 = (float)Main.rand.Next(-10, 11) * 0.1f; float num187 = (float)Main.rand.Next(-10, 1) * 0.15f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num186, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num187) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num175 == 13) { for (int num188 = 0; num188 < 8; num188++) { float num189 = (float)Main.rand.Next(-10, 11) * 0.1f; float num190 = (float)Main.rand.Next(-10, 11) * 0.1f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num189, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num190) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(75, 75, 75, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { for (int num191 = 0; num191 < 7; num191++) { float num192 = (float)Main.rand.Next(-10, 11) * 0.15f; float num193 = (float)Main.rand.Next(-10, 1) * 0.35f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num192, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num193) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, effects, 0f); } } } } } } } else { if (num152 == 3) { int num194 = (int)(Main.tile[j, i].frameY / 54); if (num194 == 8) { for (int num195 = 0; num195 < 7; num195++) { float num196 = (float)Main.rand.Next(-10, 11) * 0.075f; float num197 = (float)Main.rand.Next(-10, 11) * 0.075f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num196, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num197) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num194 == 9) { for (int num198 = 0; num198 < 3; num198++) { float num199 = (float)Main.rand.Next(-10, 11) * 0.05f; float num200 = (float)Main.rand.Next(-10, 11) * 0.15f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num199, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num200) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num194 == 11) { for (int num201 = 0; num201 < 7; num201++) { float num202 = (float)Main.rand.Next(-10, 11) * 0.3f; float num203 = (float)Main.rand.Next(-10, 11) * 0.3f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num202, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num203) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num194 == 15) { for (int num204 = 0; num204 < 7; num204++) { float num205 = (float)Main.rand.Next(-10, 11) * 0.1f; float num206 = (float)Main.rand.Next(-10, 1) * 0.15f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num205, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num206) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num194 == 17 || num194 == 20) { for (int num207 = 0; num207 < 7; num207++) { float num208 = (float)Main.rand.Next(-10, 11) * 0.075f; float num209 = (float)Main.rand.Next(-10, 11) * 0.075f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num208, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num209) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num194 == 18) { for (int num210 = 0; num210 < 8; num210++) { float num211 = (float)Main.rand.Next(-10, 11) * 0.1f; float num212 = (float)Main.rand.Next(-10, 11) * 0.1f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num211, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num212) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(75, 75, 75, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { for (int num213 = 0; num213 < 7; num213++) { float num214 = (float)Main.rand.Next(-10, 11) * 0.15f; float num215 = (float)Main.rand.Next(-10, 1) * 0.35f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num214, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num215) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, effects, 0f); } } } } } } } } else { if (num152 == 4) { int num216 = (int)(Main.tile[j, i].frameY / 54); if (num216 == 1) { for (int num217 = 0; num217 < 3; num217++) { float num218 = (float)Main.rand.Next(-10, 11) * 0.15f; float num219 = (float)Main.rand.Next(-10, 11) * 0.15f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num218, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num219) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num216 == 2 || num216 == 4) { for (int num220 = 0; num220 < 7; num220++) { float num221 = (float)Main.rand.Next(-10, 11) * 0.075f; float num222 = (float)Main.rand.Next(-10, 11) * 0.075f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num221, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num222) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num216 == 3) { for (int num223 = 0; num223 < 7; num223++) { float num224 = (float)Main.rand.Next(-10, 11) * 0.2f; float num225 = (float)Main.rand.Next(-20, 1) * 0.35f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num224, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num225) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num216 == 5) { for (int num226 = 0; num226 < 7; num226++) { float num227 = (float)Main.rand.Next(-10, 11) * 0.3f; float num228 = (float)Main.rand.Next(-10, 11) * 0.3f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num227, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num228) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num216 == 9) { for (int num229 = 0; num229 < 7; num229++) { float num230 = (float)Main.rand.Next(-10, 11) * 0.1f; float num231 = (float)Main.rand.Next(-10, 1) * 0.15f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num230, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num231) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num216 == 13) { for (int num232 = 0; num232 < 8; num232++) { float num233 = (float)Main.rand.Next(-10, 11) * 0.1f; float num234 = (float)Main.rand.Next(-10, 11) * 0.1f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num233, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num234) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(75, 75, 75, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num216 == 12) { float num235 = (float)Main.rand.Next(-10, 11) * 0.01f; float num236 = (float)Main.rand.Next(-10, 11) * 0.01f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num235, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num236) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(Main.rand.Next(90, 111), Main.rand.Next(90, 111), Main.rand.Next(90, 111), 0), 0f, default(Vector2), 1f, effects, 0f); } else { for (int num237 = 0; num237 < 7; num237++) { float num238 = (float)Main.rand.Next(-10, 11) * 0.15f; float num239 = (float)Main.rand.Next(-10, 1) * 0.35f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num238, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num239) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, effects, 0f); } } } } } } } } } else { if (num152 == 13) { int num240 = (int)(tile.frameY / 36); if (num240 == 1 || num240 == 3 || num240 == 6 || num240 == 8 || num240 == 19 || num240 == 27 || num240 == 29 || num240 == 30 || num240 == 31 || num240 == 32) { for (int num241 = 0; num241 < 7; num241++) { float num242 = (float)Main.rand.Next(-10, 11) * 0.15f; float num243 = (float)Main.rand.Next(-10, 1) * 0.35f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num242, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num243) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num240 == 25 || num240 == 16 || num240 == 2) { for (int num244 = 0; num244 < 7; num244++) { float num245 = (float)Main.rand.Next(-10, 11) * 0.15f; float num246 = (float)Main.rand.Next(-10, 1) * 0.1f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num245, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num246) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(50, 50, 50, 0), 0f, default(Vector2), 1f, effects, 0f); } } else { if (num240 == 29) { for (int num247 = 0; num247 < 7; num247++) { float num248 = (float)Main.rand.Next(-10, 11) * 0.15f; float num249 = (float)Main.rand.Next(-10, 1) * 0.15f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num248, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num249) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(25, 25, 25, 0), 0f, default(Vector2), 1f, effects, 0f); } } } } } else { for (int num250 = 0; num250 < 7; num250++) { float num251 = (float)Main.rand.Next(-10, 11) * 0.15f; float num252 = (float)Main.rand.Next(-10, 1) * 0.35f; Main.spriteBatch.Draw(Main.FlameTexture[num152], new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f + num251, (float)(i * 16 - (int)Main.screenPosition.Y + num10) + num252) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, effects, 0f); } } } } } } } } if (type == 144) { Main.spriteBatch.Draw(Main.timerTexture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color(200, 200, 200, 0), 0f, default(Vector2), 1f, effects, 0f); } if (type == 237) { Main.spriteBatch.Draw(Main.sunAltarTexture, new Vector2((float)(j * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(i * 16 - (int)Main.screenPosition.Y + num10)) + zero, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, num9, num11)), new Color((int)(Main.mouseTextColor / 2), (int)(Main.mouseTextColor / 2), (int)(Main.mouseTextColor / 2), 0), 0f, default(Vector2), 1f, effects, 0f); } } } } } } } } } } } } } } } } } } } } for (int num253 = array.Length - 1; num253 > num4; num253--) { int num254 = array[num253]; int num255 = array2[num253]; Tile tile6 = Main.tile[num254, num255]; ushort type2 = tile6.type; if ((type2 == 128 || type2 == 269) && tile6.frameX >= 100) { int num256 = (int)(tile6.frameY / 18); int num257 = (int)tile6.frameX; int num258 = 0; while (num257 >= 100) { num258++; num257 -= 100; } int num259 = -4; SpriteEffects effects2 = SpriteEffects.FlipHorizontally; if (num257 >= 36) { effects2 = SpriteEffects.None; num259 = -4; } if (num256 == 0) { this.LoadArmorHead(num258); Main.spriteBatch.Draw(Main.armorHeadTexture[num258], new Vector2((float)(num254 * 16 - (int)Main.screenPosition.X + num259), (float)(num255 * 16 - (int)Main.screenPosition.Y - 12)) + zero, new Rectangle?(new Rectangle(0, 0, 40, 36)), Lighting.GetColor(num254, num255), 0f, default(Vector2), 1f, effects2, 0f); } else { if (num256 == 1) { int num260 = -1; int num41 = num258; if (num41 <= 36) { if (num41 != 15) { if (num41 == 36) { num260 = 89; } } else { num260 = 88; } } else { switch (num41) { case 41: num260 = 97; break; case 42: num260 = 90; break; default: switch (num41) { case 58: num260 = 91; break; case 59: num260 = 92; break; case 60: num260 = 93; break; case 61: num260 = 94; break; case 62: num260 = 95; break; case 63: num260 = 96; break; default: switch (num41) { case 165: num260 = 99; break; case 166: num260 = 100; break; case 167: if (type2 == 128) { num260 = 101; } else { num260 = 102; } break; } break; } break; } } if (num260 != -1) { this.LoadArmorLegs(num260); Main.spriteBatch.Draw(Main.armorLegTexture[num260], new Vector2((float)(num254 * 16 - (int)Main.screenPosition.X + num259), (float)(num255 * 16 - (int)Main.screenPosition.Y - 28)) + zero, new Rectangle?(new Rectangle(0, 0, 40, 54)), Lighting.GetColor(num254, num255), 0f, default(Vector2), 1f, effects2, 0f); } this.LoadArmorBody(num258); if (type2 == 269) { Main.spriteBatch.Draw(Main.femaleBodyTexture[num258], new Vector2((float)(num254 * 16 - (int)Main.screenPosition.X + num259), (float)(num255 * 16 - (int)Main.screenPosition.Y - 28)) + zero, new Rectangle?(new Rectangle(0, 0, 40, 54)), Lighting.GetColor(num254, num255), 0f, default(Vector2), 1f, effects2, 0f); } else { Main.spriteBatch.Draw(Main.armorBodyTexture[num258], new Vector2((float)(num254 * 16 - (int)Main.screenPosition.X + num259), (float)(num255 * 16 - (int)Main.screenPosition.Y - 28)) + zero, new Rectangle?(new Rectangle(0, 0, 40, 54)), Lighting.GetColor(num254, num255), 0f, default(Vector2), 1f, effects2, 0f); } } else { if (num256 == 2) { this.LoadArmorLegs(num258); Main.spriteBatch.Draw(Main.armorLegTexture[num258], new Vector2((float)(num254 * 16 - (int)Main.screenPosition.X + num259), (float)(num255 * 16 - (int)Main.screenPosition.Y - 44)) + zero, new Rectangle?(new Rectangle(0, 0, 40, 54)), Lighting.GetColor(num254, num255), 0f, default(Vector2), 1f, effects2, 0f); } } } } } for (int num261 = 0; num261 < num3; num261++) { int num262 = array[num261]; int num263 = array2[num261]; Tile tile7 = Main.tile[num262, num263]; ushort type3 = tile7.type; if (type3 == 237) { Main.spriteBatch.Draw(Main.sunOrbTexture, new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X) + (float)num9 / 2f, (float)(num263 * 16 - (int)Main.screenPosition.Y - 36)) + zero, new Rectangle?(new Rectangle(0, 0, Main.sunOrbTexture.Width, Main.sunOrbTexture.Height)), new Color((int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor, 0), Main.sunCircle, new Vector2((float)(Main.sunOrbTexture.Width / 2), (float)(Main.sunOrbTexture.Height / 2)), 1f, SpriteEffects.None, 0f); } if ((type3 == 128 || type3 == 269) && tile7.frameX >= 100) { int num264 = (int)(tile7.frameY / 18); int num265 = (int)tile7.frameX; int num266 = 0; while (num265 >= 100) { num266++; num265 -= 100; } int num267 = -4; SpriteEffects effects3 = SpriteEffects.FlipHorizontally; if (num265 >= 36) { effects3 = SpriteEffects.None; num267 = -4; } if (num264 == 0) { this.LoadArmorHead(num266); Main.spriteBatch.Draw(Main.armorHeadTexture[num266], new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X + num267), (float)(num263 * 16 - (int)Main.screenPosition.Y - 12)) + zero, new Rectangle?(new Rectangle(0, 0, 40, 36)), Lighting.GetColor(num262, num263), 0f, default(Vector2), 1f, effects3, 0f); } else { if (num264 == 1) { int num268 = -1; int num41 = num266; if (num41 <= 36) { if (num41 != 15) { if (num41 == 36) { num268 = 89; } } else { num268 = 88; } } else { switch (num41) { case 41: num268 = 97; break; case 42: num268 = 90; break; default: switch (num41) { case 58: num268 = 91; break; case 59: num268 = 92; break; case 60: num268 = 93; break; case 61: num268 = 94; break; case 62: num268 = 95; break; case 63: num268 = 96; break; default: switch (num41) { case 165: num268 = 99; break; case 166: num268 = 100; break; case 167: if (type3 == 128) { num268 = 101; } else { num268 = 102; } break; } break; } break; } } if (num268 != -1) { this.LoadArmorLegs(num268); Main.spriteBatch.Draw(Main.armorLegTexture[num268], new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X + num267), (float)(num263 * 16 - (int)Main.screenPosition.Y - 28)) + zero, new Rectangle?(new Rectangle(0, 0, 40, 54)), Lighting.GetColor(num262, num263), 0f, default(Vector2), 1f, effects3, 0f); } this.LoadArmorBody(num266); if (type3 == 269) { Main.spriteBatch.Draw(Main.femaleBodyTexture[num266], new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X + num267), (float)(num263 * 16 - (int)Main.screenPosition.Y - 28)) + zero, new Rectangle?(new Rectangle(0, 0, 40, 54)), Lighting.GetColor(num262, num263), 0f, default(Vector2), 1f, effects3, 0f); } else { Main.spriteBatch.Draw(Main.armorBodyTexture[num266], new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X + num267), (float)(num263 * 16 - (int)Main.screenPosition.Y - 28)) + zero, new Rectangle?(new Rectangle(0, 0, 40, 54)), Lighting.GetColor(num262, num263), 0f, default(Vector2), 1f, effects3, 0f); } } else { if (num264 == 2) { this.LoadArmorLegs(num266); Main.spriteBatch.Draw(Main.armorLegTexture[num266], new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X + num267), (float)(num263 * 16 - (int)Main.screenPosition.Y - 44)) + zero, new Rectangle?(new Rectangle(0, 0, 40, 54)), Lighting.GetColor(num262, num263), 0f, default(Vector2), 1f, effects3, 0f); } } } } if (type3 == 334 && tile7.frameX >= 5000) { short arg_B6AA_0 = tile7.frameY / 18; int num269 = (int)tile7.frameX; int num270 = 0; int num271 = num269 % 5000; num271 -= 100; while (num269 >= 5000) { num270++; num269 -= 5000; } int num272 = (int)Main.tile[num262 + 1, num263].frameX; if (num272 >= 25000) { num272 -= 25000; } else { num272 -= 10000; } Item item = new Item(); item.netDefaults(num271); item.Prefix(num272); Texture2D texture2D = Main.itemTexture[item.type]; int width2 = texture2D.Width; int height6 = texture2D.Height; float num273 = 1f; if (width2 > 40 || height6 > 40) { if (width2 > height6) { num273 = 40f / (float)width2; } else { num273 = 40f / (float)height6; } } num273 *= item.scale; SpriteEffects effects4 = SpriteEffects.None; if (num270 >= 3) { effects4 = SpriteEffects.FlipHorizontally; } Color color11 = Lighting.GetColor(num262, num263); Main.spriteBatch.Draw(texture2D, new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X + 24), (float)(num263 * 16 - (int)Main.screenPosition.Y + 8)) + zero, new Rectangle?(new Rectangle(0, 0, width2, height6)), Lighting.GetColor(num262, num263), 0f, new Vector2((float)(width2 / 2), (float)(height6 / 2)), num273, effects4, 0f); if (item.color != default(Color)) { Main.spriteBatch.Draw(texture2D, new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X + 24), (float)(num263 * 16 - (int)Main.screenPosition.Y + 8)) + zero, new Rectangle?(new Rectangle(0, 0, width2, height6)), item.GetColor(color11), 0f, new Vector2((float)(width2 / 2), (float)(height6 / 2)), num273, effects4, 0f); } } try { if (type3 == 5 && tile7.frameY >= 198 && tile7.frameX >= 22) { int num274 = 0; if (tile7.frameX == 22) { if (tile7.frameY == 220) { num274 = 1; } else { if (tile7.frameY == 242) { num274 = 2; } } int num275 = 0; int num276 = 80; int num277 = 80; int num278 = 32; int num279 = 0; int num280 = num263; while (num280 < num263 + 100) { if (Main.tile[num262, num280].type == 2) { num275 = Main.GetTreeStyle(num262); break; } if (Main.tile[num262, num280].type == 23) { num275 = 1; break; } if (Main.tile[num262, num280].type == 70) { num275 = 14; break; } if (Main.tile[num262, num280].type == 60) { num275 = 2; if (WorldGen.jungleBG == 1) { num275 = 11; } if ((double)num280 > Main.worldSurface) { num275 = 13; } num276 = 114; num277 = 96; num278 = 48; break; } if (Main.tile[num262, num280].type == 147) { num275 = 4; if (WorldGen.snowBG == 0) { num275 = 12; break; } break; } else { if (Main.tile[num262, num280].type == 199) { num275 = 5; break; } if (Main.tile[num262, num280].type == 109) { num275 = 3; num277 = 140; if (num262 % 3 == 1) { num274 += 3; break; } if (num262 % 3 == 2) { num274 += 6; break; } break; } else { num280++; } } } if (num275 == 14) { float num281 = (float)Main.rand.Next(28, 42) * 0.005f; num281 += (float)(270 - (int)Main.mouseTextColor) / 1000f; Lighting.addLight(num262, num263, 0.1f, 0.2f + num281 / 2f, 0.7f + num281); } if (tile7.color() > 0) { Main.checkTreeAlt[num275, (int)tile7.color()] = true; } if (tile7.color() > 0 && Main.treeAltTextureDrawn[num275, (int)tile7.color()]) { Main.spriteBatch.Draw(Main.treeTopAltTexture[num275, (int)tile7.color()], new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X - num278), (float)(num263 * 16 - (int)Main.screenPosition.Y - num277 + 16 + num279)) + zero, new Rectangle?(new Rectangle(num274 * (num276 + 2), 0, num276, num277)), Lighting.GetColor(num262, num263), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } else { Main.spriteBatch.Draw(Main.treeTopTexture[num275], new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X - num278), (float)(num263 * 16 - (int)Main.screenPosition.Y - num277 + 16 + num279)) + zero, new Rectangle?(new Rectangle(num274 * (num276 + 2), 0, num276, num277)), Lighting.GetColor(num262, num263), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } } else { if (tile7.frameX == 44) { if (tile7.frameY == 220) { num274 = 1; } else { if (tile7.frameY == 242) { num274 = 2; } } int num282 = 0; int num283 = num263; while (num283 < num263 + 100) { if (Main.tile[num262 + 1, num283].type == 2) { num282 = Main.GetTreeStyle(num262 + 1); break; } if (Main.tile[num262 + 1, num283].type == 23) { num282 = 1; break; } if (Main.tile[num262 + 1, num283].type == 70) { num282 = 14; break; } if (Main.tile[num262 + 1, num283].type == 60) { num282 = 2; if ((double)num283 > Main.worldSurface) { num282 = 13; break; } break; } else { if (Main.tile[num262 + 1, num283].type == 147) { num282 = 4; if (WorldGen.snowBG == 0) { num282 = 12; break; } break; } else { if (Main.tile[num262 + 1, num283].type == 199) { num282 = 5; break; } if (Main.tile[num262 + 1, num283].type == 109) { num282 = 3; if (num262 % 3 == 1) { num274 += 3; break; } if (num262 % 3 == 2) { num274 += 6; break; } break; } else { num283++; } } } } if (num282 == 14) { float num284 = (float)Main.rand.Next(28, 42) * 0.005f; num284 += (float)(270 - (int)Main.mouseTextColor) / 1000f; Lighting.addLight(num262, num263, 0.1f, 0.2f + num284 / 2f, 0.7f + num284); } if (tile7.color() > 0) { Main.checkTreeAlt[num282, (int)tile7.color()] = true; } if (tile7.color() > 0 && Main.treeAltTextureDrawn[num282, (int)tile7.color()]) { Main.spriteBatch.Draw(Main.treeBranchAltTexture[num282, (int)tile7.color()], new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X - 24), (float)(num263 * 16 - (int)Main.screenPosition.Y - 12)) + zero, new Rectangle?(new Rectangle(0, num274 * 42, 40, 40)), Lighting.GetColor(num262, num263), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } else { Main.spriteBatch.Draw(Main.treeBranchTexture[num282], new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X - 24), (float)(num263 * 16 - (int)Main.screenPosition.Y - 12)) + zero, new Rectangle?(new Rectangle(0, num274 * 42, 40, 40)), Lighting.GetColor(num262, num263), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } } else { if (tile7.frameX == 66) { if (tile7.frameY == 220) { num274 = 1; } else { if (tile7.frameY == 242) { num274 = 2; } } int num285 = 0; int num286 = num263; while (num286 < num263 + 100) { if (Main.tile[num262 - 1, num286].type == 2) { num285 = Main.GetTreeStyle(num262 - 1); break; } if (Main.tile[num262 - 1, num286].type == 23) { num285 = 1; break; } if (Main.tile[num262 - 1, num286].type == 70) { num285 = 14; break; } if (Main.tile[num262 - 1, num286].type == 60) { num285 = 2; if ((double)num286 > Main.worldSurface) { num285 = 13; break; } break; } else { if (Main.tile[num262 - 1, num286].type == 147) { num285 = 4; if (WorldGen.snowBG == 0) { num285 = 12; break; } break; } else { if (Main.tile[num262 - 1, num286].type == 199) { num285 = 5; break; } if (Main.tile[num262 - 1, num286].type == 109) { num285 = 3; if (num262 % 3 == 1) { num274 += 3; break; } if (num262 % 3 == 2) { num274 += 6; break; } break; } else { num286++; } } } } if (num285 == 14) { float num287 = (float)Main.rand.Next(28, 42) * 0.005f; num287 += (float)(270 - (int)Main.mouseTextColor) / 1000f; Lighting.addLight(num262, num263, 0.1f, 0.2f + num287 / 2f, 0.7f + num287); } if (tile7.color() > 0) { Main.checkTreeAlt[num285, (int)tile7.color()] = true; } if (tile7.color() > 0 && Main.treeAltTextureDrawn[num285, (int)tile7.color()]) { Main.spriteBatch.Draw(Main.treeBranchAltTexture[num285, (int)tile7.color()], new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X), (float)(num263 * 16 - (int)Main.screenPosition.Y - 12)) + zero, new Rectangle?(new Rectangle(42, num274 * 42, 40, 40)), Lighting.GetColor(num262, num263), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } else { Main.spriteBatch.Draw(Main.treeBranchTexture[num285], new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X), (float)(num263 * 16 - (int)Main.screenPosition.Y - 12)) + zero, new Rectangle?(new Rectangle(42, num274 * 42, 40, 40)), Lighting.GetColor(num262, num263), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } } } } } if (type3 == 323 && tile7.frameX >= 88 && tile7.frameX <= 132) { int num288 = 0; if (tile7.frameX == 110) { num288 = 1; } else { if (tile7.frameX == 132) { num288 = 2; } } int num289 = 15; int num290 = 0; int num291 = 80; int num292 = 80; int num293 = 32; int num294 = 0; for (int num295 = num263; num295 < num263 + 100; num295++) { if (Main.tile[num262, num295].type == 53) { num290 = 0; break; } if (Main.tile[num262, num295].type == 234) { num290 = 1; break; } if (Main.tile[num262, num295].type == 116) { num290 = 2; break; } if (Main.tile[num262, num295].type == 112) { num290 = 3; break; } } int frameY2 = (int)Main.tile[num262, num263].frameY; int y3 = num290 * 82; if (tile7.color() > 0) { Main.checkTreeAlt[num289, (int)tile7.color()] = true; } if (tile7.color() > 0 && Main.treeAltTextureDrawn[num289, (int)tile7.color()]) { Main.spriteBatch.Draw(Main.treeTopAltTexture[num289, (int)tile7.color()], new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X - num293 + frameY2), (float)(num263 * 16 - (int)Main.screenPosition.Y - num292 + 16 + num294)) + zero, new Rectangle?(new Rectangle(num288 * (num291 + 2), y3, num291, num292)), Lighting.GetColor(num262, num263), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } else { Main.spriteBatch.Draw(Main.treeTopTexture[num289], new Vector2((float)(num262 * 16 - (int)Main.screenPosition.X - num293 + frameY2), (float)(num263 * 16 - (int)Main.screenPosition.Y - num292 + 16 + num294)) + zero, new Rectangle?(new Rectangle(num288 * (num291 + 2), y3, num291, num292)), Lighting.GetColor(num262, num263), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } } } catch { } } if (solidOnly) { TimeLogger.DrawTime(0, stopwatch.Elapsed.TotalMilliseconds); return; } TimeLogger.DrawTime(1, stopwatch.Elapsed.TotalMilliseconds); }
/// <summary> /// Applies server config data to the player /// </summary> /// <param name="player"></param> public void ApplyToPlayer(Player player) { //player.male = this.Male; player.statMana = this.Mana; player.statLife = this.Health; player.statLifeMax = this.MaxHealth; player.SpawnX = this.SpawnX; player.SpawnY = this.SpawnY; player.hideVisual = this.HideVisual; player.hairDye = this.HairDye; player.hair = this.Hair; player.difficulty = this.Difficulty; player.hairColor = this.HairColor.ToXna(); player.skinColor = this.SkinColor.ToXna(); player.eyeColor = this.EyeColor.ToXna(); player.shirtColor = this.ShirtColor.ToXna(); player.underShirtColor = this.UnderShirtColor.ToXna(); player.pantsColor = this.PantsColor.ToXna(); player.shoeColor = this.ShoeColor.ToXna(); //Reset and populate inventory player.inventory = Enumerable.Repeat(new Item(), player.inventory.Length).ToArray(); foreach (var slotItem in this.Inventory) { var item = new Terraria.Item(); item.netDefaults(slotItem.NetId); item.stack = slotItem.Stack; item.Prefix(slotItem.Prefix); player.inventory[slotItem.Slot] = item; } //Reset and populate dye player.dye = Enumerable.Repeat(new Item(), player.dye.Length).ToArray(); foreach (var slotItem in this.Dye) { var item = new Terraria.Item(); item.netDefaults(slotItem.NetId); item.Prefix(slotItem.Prefix); player.dye[slotItem.Slot] = item; } //Reset and populate armor player.armor = Enumerable.Repeat(new Item(), player.armor.Length).ToArray(); foreach (var slotItem in this.Armor) { var item = new Terraria.Item(); item.netDefaults(slotItem.NetId); item.Prefix(slotItem.Prefix); player.armor[slotItem.Slot] = item; } //Update client this.Send(player); }
private static bool HandleItemDrop(GetDataHandlerArgs args) { var id = args.Data.ReadInt16(); var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle()); var vel = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle()); var stacks = args.Data.ReadInt16(); var prefix = args.Data.ReadInt8(); var noDelay = args.Data.ReadInt8() == 1; var type = args.Data.ReadInt16(); if (OnItemDrop(id, pos, vel, stacks, prefix, noDelay, type)) return true; // player is attempting to crash clients if (type < -48 || type >= Main.maxItemTypes) { args.Player.SendData(PacketTypes.ItemDrop, "", id); return true; } if (prefix > Item.maxPrefixes) //make sure the prefix is a legit value { args.Player.SendData(PacketTypes.ItemDrop, "", id); return true; } if (type == 0) //Item removed, let client do this to prevent item duplication client side (but only if it passed the range check) { if (TShock.CheckRangePermission(args.Player, (int)(Main.item[id].position.X / 16f), (int)(Main.item[id].position.Y / 16f))) { args.Player.SendData(PacketTypes.ItemDrop, "", id); return true; } return false; } if (TShock.CheckRangePermission(args.Player, (int)(pos.X / 16f), (int)(pos.Y / 16f))) { args.Player.SendData(PacketTypes.ItemDrop, "", id); return true; } if (Main.item[id].active && Main.item[id].netID != type) //stop the client from changing the item type of a drop but only if the client isn't picking up the item { args.Player.SendData(PacketTypes.ItemDrop, "", id); return true; } Item item = new Item(); item.netDefaults(type); if ((stacks > item.maxStack || stacks <= 0) || (TShock.Itembans.ItemIsBanned(item.name, args.Player) && !args.Player.Group.HasPermission(Permissions.allowdroppingbanneditems))) { args.Player.SendData(PacketTypes.ItemDrop, "", id); return true; } if ((Main.ServerSideCharacter) && (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - args.Player.LoginMS < TShock.ServerSideCharacterConfig.LogonDiscardThreshold)) { //Player is probably trying to sneak items onto the server in their hands!!! TShock.Log.ConsoleInfo("Player {0} tried to sneak {1} onto the server!", args.Player.Name, item.name); args.Player.SendData(PacketTypes.ItemDrop, "", id); return true; } if (TShock.CheckIgnores(args.Player)) { args.Player.SendData(PacketTypes.ItemDrop, "", id); return true; } return false; }
private static bool HandlePlayerSlot(GetDataHandlerArgs args) { byte plr = args.Data.ReadInt8(); byte slot = args.Data.ReadInt8(); short stack = args.Data.ReadInt16(); byte prefix = args.Data.ReadInt8(); short type = args.Data.ReadInt16(); // Players send a slot update packet for each inventory slot right after they've joined. bool bypassTrashCanCheck = false; if (plr == args.Player.Index && !args.Player.HasSentInventory && slot == NetItem.MaxInventory) { args.Player.HasSentInventory = true; bypassTrashCanCheck = true; } if (OnPlayerSlot(plr, slot, stack, prefix, type) || plr != args.Player.Index || slot < 0 || slot > NetItem.MaxInventory) return true; if (args.Player.IgnoreSSCPackets) { args.Player.SendData(PacketTypes.PlayerSlot, "", args.Player.Index, slot, prefix); return true; } // Garabage? Or will it cause some internal initialization or whatever? var item = new Item(); item.netDefaults(type); item.Prefix(prefix); if (args.Player.IsLoggedIn) { args.Player.PlayerData.StoreSlot(slot, type, prefix, stack); } else if (Main.ServerSideCharacter && TShock.Config.DisableLoginBeforeJoin && !bypassTrashCanCheck && args.Player.HasSentInventory && !args.Player.Group.HasPermission(Permissions.bypassssc)) { // The player might have moved an item to their trash can before they performed a single login attempt yet. args.Player.IgnoreActionsForClearingTrashCan = true; } if (slot == 58) //this is the hand { item.stack = stack; args.Player.ItemInHand = item; } return false; }
private static bool HandleItemDrop(GetDataHandlerArgs args) { var id = args.Data.ReadInt16(); var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle()); var vel = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle()); var stacks = args.Data.ReadInt8(); var prefix = args.Data.ReadInt8(); var type = args.Data.ReadInt16(); if (type == 0) //Item removed, let client do this to prevent item duplication client side { return false; } if (TShock.CheckRangePermission(args.Player, (int)(pos.X / 16f), (int)(pos.Y / 16f))) { args.Player.SendData(PacketTypes.ItemDrop, "", id); return true; } Item item = new Item(); item.netDefaults(type); if (stacks > item.maxStack || TShock.Itembans.ItemIsBanned(item.name, args.Player)) { args.Player.SendData(PacketTypes.ItemDrop, "", id); return true; } if (TShock.CheckIgnores(args.Player)) { args.Player.SendData(PacketTypes.ItemDrop, "", id); return true; } return false; }
public static void KillTile(int i, int j, bool fail = false, bool effectOnly = false, bool noItem = false) { if (i >= 0 && j >= 0 && i < Main.maxTilesX && j < Main.maxTilesY) { Tile tile = Main.tile[i, j]; if (tile == null) { tile = new Tile(); Main.tile[i, j] = tile; } if (tile.active()) { if (j >= 1 && Main.tile[i, j - 1] == null) { Main.tile[i, j - 1] = new Tile(); } if (j >= 1 && Main.tile[i, j - 1].active() && ((Main.tile[i, j - 1].type == 5 && tile.type != 5) || (Main.tile[i, j - 1].type == 323 && tile.type != 323) || (Main.tile[i, j - 1].type == 21 && tile.type != 21) || (Main.tile[i, j - 1].type == 26 && tile.type != 26) || (Main.tile[i, j - 1].type == 72 && tile.type != 72) || (Main.tile[i, j - 1].type == 12 && tile.type != 12))) { if (Main.tile[i, j - 1].type == 5) { if ((Main.tile[i, j - 1].frameX != 66 || Main.tile[i, j - 1].frameY < 0 || Main.tile[i, j - 1].frameY > 44) && (Main.tile[i, j - 1].frameX != 88 || Main.tile[i, j - 1].frameY < 66 || Main.tile[i, j - 1].frameY > 110) && Main.tile[i, j - 1].frameY < 198) { return; } } else { if (Main.tile[i, j - 1].type != 323 || Main.tile[i, j - 1].frameX == 66 || Main.tile[i, j - 1].frameX == 220) { return; } } } if (tile.type == 10 && tile.frameY >= 594 && tile.frameY <= 646) { fail = true; } if (tile.type == 138) { fail = WorldGen.CheckBoulderChest(i, j); } if (tile.type == 235) { int frameX = (int)tile.frameX; int num = i - frameX % 54 / 18; for (int k = 0; k < 3; k++) { if (Main.tile[num + k, j - 1].active() && Main.tile[num + k, j - 1].type == 21) { fail = true; break; } } } if (!effectOnly && !WorldGen.stopDrops) { if (tile.type == 127) { Main.PlaySound(2, i * 16, j * 16, 27); } else { if (tile.type == 147 || tile.type == 224) { Main.PlaySound(2, i * 16, j * 16, WorldGen.genRand.Next(48, 50)); } else { if (tile.type == 161 || tile.type == 163 || tile.type == 164 || tile.type == 200) { Main.PlaySound(2, i * 16, j * 16, 50); } else { if (tile.type == 3 || tile.type == 110) { Main.PlaySound(6, i * 16, j * 16, 1); if (tile.frameX == 144) { Item.NewItem(i * 16, j * 16, 16, 16, 5, 1, false, 0, false); } } else { if (tile.type == 254) { Main.PlaySound(6, i * 16, j * 16, 1); } else { if (tile.type == 24) { Main.PlaySound(6, i * 16, j * 16, 1); if (tile.frameX == 144) { Item.NewItem(i * 16, j * 16, 16, 16, 60, 1, false, 0, false); } } else { if (Main.tileAlch[(int)tile.type] || tile.type == 32 || tile.type == 51 || tile.type == 52 || tile.type == 61 || tile.type == 62 || tile.type == 69 || tile.type == 71 || tile.type == 73 || tile.type == 74 || tile.type == 113 || tile.type == 115 || tile.type == 184 || tile.type == 192 || tile.type == 205 || tile.type == 233) { Main.PlaySound(6, i * 16, j * 16, 1); } else { if (tile.type == 201) { Main.PlaySound(6, i * 16, j * 16, 1); } else { if (tile.type == 1 || tile.type == 6 || tile.type == 7 || tile.type == 8 || tile.type == 9 || tile.type == 22 || tile.type == 140 || tile.type == 25 || tile.type == 37 || tile.type == 38 || tile.type == 39 || tile.type == 41 || tile.type == 43 || tile.type == 44 || tile.type == 45 || tile.type == 46 || tile.type == 47 || tile.type == 48 || tile.type == 56 || tile.type == 58 || tile.type == 63 || tile.type == 64 || tile.type == 65 || tile.type == 66 || tile.type == 67 || tile.type == 68 || tile.type == 75 || tile.type == 76 || tile.type == 107 || tile.type == 108 || tile.type == 111 || tile.type == 117 || tile.type == 118 || tile.type == 119 || tile.type == 120 || tile.type == 121 || tile.type == 122 || tile.type == 150 || tile.type == 151 || tile.type == 152 || tile.type == 153 || tile.type == 154 || tile.type == 155 || tile.type == 156 || tile.type == 160 || tile.type == 161 || tile.type == 166 || tile.type == 167 || tile.type == 168 || tile.type == 169 || tile.type == 175 || tile.type == 176 || tile.type == 177 || tile.type == 203 || tile.type == 202 || tile.type == 204 || tile.type == 206 || tile.type == 211 || tile.type == 221 || tile.type == 222 || tile.type == 223 || tile.type == 226 || tile.type == 248 || tile.type == 249 || tile.type == 250 || tile.type == 272 || tile.type == 273 || tile.type == 274 || tile.type == 284 || tile.type == 325) { Main.PlaySound(21, i * 16, j * 16, 1); } else { if (tile.type == 231 || tile.type == 195) { Main.PlaySound(4, i * 16, j * 16, 1); } else { if (tile.type == 26 && tile.frameX >= 54) { Main.PlaySound(4, i * 16, j * 16, 1); } else { if (tile.type == 314) { Main.PlaySound(2, i * 16, j * 16, 52); } else { if (tile.type >= 330 && tile.type <= 333) { Main.PlaySound(18, i * 16, j * 16, 1); } else { if (tile.type != 138) { Main.PlaySound(0, i * 16, j * 16, 1); } } } } } } } } } } } } } } if ((tile.type == 162 || tile.type == 129 || (tile.type == 165 && tile.frameX < 54)) && !fail) { Main.PlaySound(2, i * 16, j * 16, 27); } } int num2 = 10; if (tile.type == 231) { num2 = 6; } if (tile.type == 128 || tile.type == 269) { int num3 = i; int l = (int)tile.frameX; int m; for (m = (int)tile.frameX; m >= 100; m -= 100) { } while (m >= 36) { m -= 36; } if (m == 18) { l = (int)Main.tile[i - 1, j].frameX; num3--; } if (l >= 100) { int num4 = 0; while (l >= 100) { l -= 100; num4++; } int num5 = (int)(Main.tile[num3, j].frameY / 18); if (num5 == 0) { Item.NewItem(i * 16, j * 16, 16, 16, Item.headType[num4], 1, false, 0, false); } if (num5 == 1) { Item.NewItem(i * 16, j * 16, 16, 16, Item.bodyType[num4], 1, false, 0, false); } if (num5 == 2) { Item.NewItem(i * 16, j * 16, 16, 16, Item.legType[num4], 1, false, 0, false); } for (l = (int)Main.tile[num3, j].frameX; l >= 100; l -= 100) { } Main.tile[num3, j].frameX = (short)l; } } if (tile.type == 334) { int num6 = i; int n = (int)tile.frameX; int num7 = (int)tile.frameX; int num8 = 0; while (num7 >= 5000) { num7 -= 5000; num8++; } if (num8 != 0) { num7 = (num8 - 1) * 18; } num7 %= 54; if (num7 == 18) { n = (int)Main.tile[i - 1, j].frameX; num6--; } if (num7 == 36) { n = (int)Main.tile[i - 2, j].frameX; num6 -= 2; } if (n >= 5000) { int num9 = n % 5000; num9 -= 100; int num10 = (int)Main.tile[num6 + 1, j].frameX; if (num10 >= 25000) { num10 -= 25000; } else { num10 -= 10000; } if (Main.netMode != 1) { Item item = new Item(); item.netDefaults(num9); item.Prefix(num10); int num11 = Item.NewItem(i * 16, j * 16, 16, 16, num9, 1, true, 0, false); item.position = Main.item[num11].position; Main.item[num11] = item; NetMessage.SendData(21, -1, -1, "", num11, 0f, 0f, 0f, 0); } n = (int)Main.tile[num6, j].frameX; int num12 = 0; while (n >= 5000) { n -= 5000; num12++; } if (num12 != 0) { n = (num12 - 1) * 18; } Main.tile[num6, j].frameX = (short)n; Main.tile[num6 + 1, j].frameX = (short)(n + 18); } } if (fail) { num2 = 3; } if (tile.type == 138) { num2 = 0; } if (tile.type >= 300 && tile.type <= 308) { num2 = 0; } if (tile.type == 125) { num2 = 0; } if (tile.type == 287) { num2 = 0; } int num13 = 0; while (num13 < num2) { int num14 = 0; if (tile.type == 216) { num14 = -1; } if (tile.type == 335) { num14 = -1; } if (tile.type == 338) { num14 = -1; } if (tile.type == 0) { num14 = 0; } if (tile.type == 192) { num14 = 3; } if (tile.type == 208) { num14 = 126; } if (tile.type == 16) { num14 = 1; if (tile.frameX >= 36) { num14 = 82; } } if (tile.type == 1 || tile.type == 17 || tile.type == 38 || tile.type == 39 || tile.type == 41 || tile.type == 43 || tile.type == 44 || tile.type == 48 || Main.tileStone[(int)tile.type] || tile.type == 85 || tile.type == 90 || tile.type == 92 || tile.type == 96 || tile.type == 97 || tile.type == 99 || tile.type == 117 || tile.type == 130 || tile.type == 131 || tile.type == 132 || tile.type == 135 || tile.type == 135 || tile.type == 142 || tile.type == 143 || tile.type == 144 || tile.type == 210 || tile.type == 207 || tile.type == 235 || tile.type == 247 || tile.type == 272 || tile.type == 273 || tile.type == 283) { num14 = 1; } if (tile.type == 311) { num14 = 207; } if (tile.type == 312) { num14 = 208; } if (tile.type == 313) { num14 = 209; } if (tile.type == 104) { num14 = -1; } if (tile.type == 95 || tile.type == 98 || tile.type == 100 || tile.type == 174 || tile.type == 173) { num14 = 6; } if (tile.type == 30 || tile.type == 86 || tile.type == 94 || tile.type == 106 || tile.type == 114 || tile.type == 124 || tile.type == 128 || tile.type == 269) { num14 = 7; } if (tile.type == 334) { num14 = 7; } ushort type = tile.type; if (type <= 89) { switch (type) { case 10: case 11: goto IL_1144; default: switch (type) { case 87: case 89: goto IL_1144; } break; } } else { if (type == 93 || type == 139) { goto IL_1144; } switch (type) { case 319: case 320: goto IL_1144; } } IL_1147: if (tile.type == 240) { int num15 = (int)(tile.frameX / 54); if (tile.frameY >= 54) { num15 += 36; } num14 = 7; if (num15 == 16 || num15 == 17) { num14 = 26; } if (num15 >= 46 && num15 <= 49) { num14 = -1; } } if (tile.type == 241) { num14 = 1; } if (tile.type == 242) { num14 = -1; } if (tile.type == 246) { num14 = -1; } if (tile.type == 36) { num14 = -1; } if (tile.type == 170) { num14 = 196; } if (tile.type == 315) { num14 = 225; } if (tile.type == 171) { if (Main.rand.Next(2) == 0) { num14 = 196; } else { num14 = -1; } } if (tile.type == 326) { num14 = 13; } if (tile.type == 327) { num14 = 13; } if (tile.type == 336) { num14 = 6; } if (tile.type == 328) { num14 = 13; } if (tile.type == 329) { num14 = 13; } if (tile.type == 330) { num14 = 9; } if (tile.type == 331) { num14 = 11; } if (tile.type == 332) { num14 = 19; } if (tile.type == 333) { num14 = 11; } if (tile.type == 101) { num14 = -1; } if (tile.type == 19) { int num16 = (int)(tile.frameY / 18); if (num16 == 0 || num16 == 9 || num16 == 10 || num16 == 11 || num16 == 12) { num14 = 7; } else { if (num16 == 1) { num14 = 77; } else { if (num16 == 2) { num14 = 78; } else { if (num16 == 3) { num14 = 79; } else { if (num16 == 4) { num14 = 26; } else { if (num16 == 5) { num14 = 126; } else { if (num16 == 13) { num14 = 109; } else { if (num16 == 14) { num14 = 13; } else { if (num16 >= 15 || num16 <= 16) { num14 = -1; } else { if (num16 == 17) { num14 = 215; } else { if (num16 == 18) { num14 = 214; } else { num14 = 1; } } } } } } } } } } } } if (tile.type == 79) { int num17 = (int)(tile.frameY / 36); if (num17 == 0) { num14 = 7; } else { if (num17 == 1) { num14 = 77; } else { if (num17 == 2) { num14 = 78; } else { if (num17 == 3) { num14 = 79; } else { if (num17 == 4) { num14 = 126; } else { if (num17 == 8) { num14 = 109; } else { if (num17 >= 9) { num14 = -1; } else { num14 = 1; } } } } } } } } if (tile.type == 18) { int num18 = (int)(tile.frameX / 36); if (num18 == 0) { num14 = 7; } else { if (num18 == 1) { num14 = 77; } else { if (num18 == 2) { num14 = 78; } else { if (num18 == 3) { num14 = 79; } else { if (num18 == 4) { num14 = 26; } else { if (num18 == 5) { num14 = 40; } else { if (num18 == 6) { num14 = 5; } else { if (num18 == 7) { num14 = 26; } else { if (num18 == 8) { num14 = 4; } else { if (num18 == 9) { num14 = 126; } else { if (num18 == 10) { num14 = 148; } else { if (num18 == 11 || num18 == 12 || num18 == 13) { num14 = 1; } else { if (num18 == 14) { num14 = 109; } else { if (num18 == 15) { num14 = 126; } else { num14 = -1; } } } } } } } } } } } } } } } if (tile.type == 14 || tile.type == 87 || tile.type == 88) { num14 = -1; } if (tile.type >= 255 && tile.type <= 261) { int num19 = (int)(tile.type - 255); num14 = 86 + num19; if (num19 == 6) { num14 = 138; } } if (tile.type >= 262 && tile.type <= 268) { int num20 = (int)(tile.type - 262); num14 = 86 + num20; if (num20 == 6) { num14 = 138; } } if (tile.type == 178) { int num21 = (int)(tile.frameX / 18); num14 = 86 + num21; if (num21 == 6) { num14 = 138; } } if (tile.type == 186) { if (tile.frameX <= 360) { num14 = 26; } else { if (tile.frameX <= 846) { num14 = 1; } else { if (tile.frameX <= 954) { num14 = 9; } else { if (tile.frameX <= 1062) { num14 = 11; } else { if (tile.frameX <= 1170) { num14 = 10; } else { if (tile.frameX <= 1332) { num14 = 0; } else { if (tile.frameX <= 1386) { num14 = 10; } else { num14 = 80; } } } } } } } } if (tile.type == 187) { if (tile.frameX <= 144) { num14 = 1; } else { if (tile.frameX <= 306) { num14 = 38; } else { if (tile.frameX <= 468) { num14 = 36; } else { if (tile.frameX <= 738) { num14 = 30; } else { if (tile.frameX <= 970) { num14 = 1; } else { if (tile.frameX <= 1132) { num14 = 148; } else { if (tile.frameX <= 1132) { num14 = 155; } else { if (tile.frameX <= 1348) { num14 = 1; } else { if (tile.frameX <= 1564) { num14 = 0; } } } } } } } } } } if (tile.type == 105) { num14 = 1; if (tile.frameX >= 1548 && tile.frameX <= 1654) { num14 = 148; } } if (tile.type == 337) { num14 = 1; } if (tile.type == 239) { int num22 = (int)(tile.frameX / 18); if (num22 == 0) { num14 = 9; } if (num22 == 1) { num14 = 81; } if (num22 == 2) { num14 = 8; } if (num22 == 3) { num14 = 82; } if (num22 == 4) { num14 = 11; } if (num22 == 5) { num14 = 83; } if (num22 == 6) { num14 = 10; } if (num22 == 7) { num14 = 84; } if (num22 == 8) { num14 = 14; } if (num22 == 9) { num14 = 23; } if (num22 == 10) { num14 = 25; } if (num22 == 11) { num14 = 48; } if (num22 == 12) { num14 = 144; } if (num22 == 13) { num14 = 49; } if (num22 == 14) { num14 = 145; } if (num22 == 15) { num14 = 50; } if (num22 == 16) { num14 = 146; } if (num22 == 17) { num14 = 128; } if (num22 == 18) { num14 = 84; } if (num22 == 19) { num14 = 117; } if (num22 == 20) { num14 = 26; } } if (tile.type == 185) { if (tile.frameY == 18) { int num23 = (int)(tile.frameX / 36); if (num23 < 6) { num14 = 1; } else { if (num23 < 16) { num14 = 26; } else { if (num23 == 16) { num14 = 9; } else { if (num23 == 17) { num14 = 11; } else { if (num23 == 18) { num14 = 10; } else { if (num23 == 19) { num14 = 86; } else { if (num23 == 20) { num14 = 87; } else { if (num23 == 21) { num14 = 88; } else { if (num23 == 22) { num14 = 89; } else { if (num23 == 23) { num14 = 90; } else { if (num23 == 24) { num14 = 91; } else { if (num23 < 31) { num14 = 80; } else { if (num23 < 33) { num14 = 7; } else { if (num23 < 34) { num14 = 8; } else { if (num23 < 39) { num14 = 30; } else { if (num23 < 42) { num14 = 1; } } } } } } } } } } } } } } } } } else { int num24 = (int)(tile.frameX / 18); if (num24 < 6) { num14 = 1; } else { if (num24 < 12) { num14 = 0; } else { if (num24 < 27) { num14 = 26; } else { if (num24 < 32) { num14 = 1; } else { if (num24 < 35) { num14 = 0; } else { if (num24 < 46) { num14 = 80; } else { if (num24 < 52) { num14 = 30; } } } } } } } } } if (tile.type == 184) { int num25 = (int)(tile.frameX / 22); num14 = 93 + num25; } if (tile.type == 237) { num14 = 148; } if (tile.type == 157) { num14 = 77; } if (tile.type == 158 || tile.type == 232) { num14 = 78; } if (tile.type == 159) { num14 = 78; } if (tile.type == 15) { num14 = -1; } if (tile.type == 191) { num14 = 7; } if (tile.type == 5) { num14 = 7; if (i > 5 && i < Main.maxTilesX - 5) { int num26 = i; int num27 = j; if (tile.frameX == 66 && tile.frameY <= 45) { num26++; } if (tile.frameX == 88 && tile.frameY >= 66 && tile.frameY <= 110) { num26--; } if (tile.frameX == 22 && tile.frameY >= 132 && tile.frameY <= 176) { num26--; } if (tile.frameX == 44 && tile.frameY >= 132 && tile.frameY <= 176) { num26++; } if (tile.frameX == 44 && tile.frameY >= 132 && tile.frameY <= 176) { num26++; } if (tile.frameX == 44 && tile.frameY >= 198) { num26++; } if (tile.frameX == 66 && tile.frameY >= 198) { num26--; } while (Main.tile[num26, num27] != null && (!Main.tile[num26, num27].active() || !Main.tileSolid[(int)Main.tile[num26, num27].type])) { num27++; } if (Main.tile[num26, num27] != null) { if (Main.tile[num26, num27].active() && Main.tile[num26, num27].type == 23) { num14 = 77; } if (Main.tile[num26, num27].active() && Main.tile[num26, num27].type == 60) { num14 = 78; } if (Main.tile[num26, num27].active() && Main.tile[num26, num27].type == 70) { num14 = 26; } if (Main.tile[num26, num27].active() && Main.tile[num26, num27].type == 109) { num14 = 79; } if (Main.tile[num26, num27].active() && Main.tile[num26, num27].type == 199) { num14 = 121; } if (Main.tile[num26, num27].active() && Main.tile[num26, num27].type == 147) { num14 = 122; } } } } if (tile.type == 323) { num14 = 215; if (i > 5 && i < Main.maxTilesX - 5) { int num28 = j; while (Main.tile[i, num28] != null && (!Main.tile[i, num28].active() || !Main.tileSolid[(int)Main.tile[i, num28].type])) { num28++; } if (Main.tile[i, num28] != null) { if (Main.tile[i, num28].active() && Main.tile[i, num28].type == 234) { num14 = 121; } if (Main.tile[i, num28].active() && Main.tile[i, num28].type == 116) { num14 = 79; } if (Main.tile[i, num28].active() && Main.tile[i, num28].type == 112) { num14 = 77; } } } } if (tile.type == 137) { num14 = 1; int num29 = (int)(tile.frameY / 18); if (num29 > 0) { num14 = 148; } } if (tile.type == 212) { num14 = -1; } if (tile.type == 213) { num14 = 129; } if (tile.type == 214) { num14 = 1; } if (tile.type == 215) { num14 = 6; } if (tile.type == 325) { num14 = 81; } if (tile.type == 251) { num14 = 189; } if (tile.type == 252) { num14 = 190; } if (tile.type == 253) { num14 = 191; } if (tile.type == 254) { if (tile.frameX < 72) { num14 = 3; } else { if (tile.frameX < 108) { num14 = 3; if (Main.rand.Next(3) == 0) { num14 = 189; } } else { if (tile.frameX < 144) { num14 = 3; if (Main.rand.Next(2) == 0) { num14 = 189; } } else { num14 = 3; if (Main.rand.Next(4) != 0) { num14 = 189; } } } } } if (tile.type == 21) { if (tile.frameX >= 1008) { num14 = -1; } else { if (tile.frameX >= 612) { num14 = 11; } else { if (tile.frameX >= 576) { num14 = 148; } else { if (tile.frameX >= 540) { num14 = 26; } else { if (tile.frameX >= 504) { num14 = 126; } else { if (tile.frameX >= 468) { num14 = 116; } else { if (tile.frameX >= 432) { num14 = 7; } else { if (tile.frameX >= 396) { num14 = 11; } else { if (tile.frameX >= 360) { num14 = 10; } else { if (tile.frameX >= 324) { num14 = 79; } else { if (tile.frameX >= 288) { num14 = 78; } else { if (tile.frameX >= 252) { num14 = 77; } else { if (tile.frameX >= 216) { num14 = 1; } else { if (tile.frameX >= 180) { num14 = 7; } else { if (tile.frameX >= 108) { num14 = 37; } else { if (tile.frameX >= 36) { num14 = 10; } else { num14 = 7; } } } } } } } } } } } } } } } } } if (tile.type == 2) { if (WorldGen.genRand.Next(2) == 0) { num14 = 0; } else { num14 = 2; } } if (Main.tileMoss[(int)tile.type]) { num14 = (int)(tile.type - 179 + 93); } if (tile.type == 127) { num14 = 67; } if (tile.type == 91) { num14 = -1; } if (tile.type == 198) { num14 = 109; } if (tile.type == 26) { if (tile.frameX >= 54) { num14 = 5; } else { num14 = 8; } } if (tile.type == 34) { num14 = -1; } if (tile.type == 6) { num14 = 8; } if (tile.type == 7 || tile.type == 47 || tile.type == 284) { num14 = 9; } if (tile.type == 8 || tile.type == 45 || tile.type == 102) { num14 = 10; } if (tile.type == 9 || tile.type == 42 || tile.type == 46 || tile.type == 126 || tile.type == 136) { num14 = 11; } if (tile.type == 166 || tile.type == 175) { num14 = 81; } if (tile.type == 167) { num14 = 82; } if (tile.type == 168 || tile.type == 176) { num14 = 83; } if (tile.type == 169 || tile.type == 177) { num14 = 84; } if (tile.type == 199) { num14 = 117; } if (tile.type == 205) { num14 = 125; } if (tile.type == 201) { num14 = 125; } if (tile.type == 211) { num14 = 128; } if (tile.type == 227) { int num30 = (int)(tile.frameX / 34); if (num30 == 0 || num30 == 1) { num14 = 26; } else { if (num30 == 3) { num14 = 3; } else { if (num30 == 2 || num30 == 4 || num30 == 5 || num30 == 6) { num14 = 40; } else { if (num30 == 7) { num14 = 117; } } } } } if (tile.type == 204) { num14 = 117; if (WorldGen.genRand.Next(2) == 0) { num14 = 1; } } if (tile.type == 203) { num14 = 117; } if (tile.type == 243) { if (Main.rand.Next(2) == 0) { num14 = 7; } else { num14 = 13; } } if (tile.type == 244) { if (Main.rand.Next(2) == 0) { num14 = 1; } else { num14 = 13; } } else { if ((tile.type >= 275 && tile.type <= 282) || (tile.type == 285 || tile.type == 286 || (tile.type >= 288 && tile.type <= 297)) || (tile.type >= 316 && tile.type <= 318) || tile.type == 298 || tile.type == 299 || tile.type == 309 || tile.type == 310 || tile.type == 339) { num14 = 13; if (Main.rand.Next(3) != 0) { num14 = -1; } } } if (tile.type == 13) { if (tile.frameX >= 90) { num14 = -1; } else { num14 = 13; } } if (tile.type == 189) { num14 = 16; } if (tile.type == 12) { num14 = 12; } if (tile.type == 3 || tile.type == 73) { num14 = 3; } if (tile.type == 54) { num14 = 13; } if (tile.type == 22 || tile.type == 140) { num14 = 14; } if (tile.type == 78) { num14 = 22; } if (tile.type == 28) { num14 = 22; if (tile.frameY >= 72 && tile.frameY <= 90) { num14 = 1; } if (tile.frameY >= 144 && tile.frameY <= 234) { num14 = 48; } if (tile.frameY >= 252 && tile.frameY <= 358) { num14 = 85; } if (tile.frameY >= 360 && tile.frameY <= 466) { num14 = 26; } if (tile.frameY >= 468 && tile.frameY <= 574) { num14 = 36; } if (tile.frameY >= 576 && tile.frameY <= 790) { num14 = 18; } if (tile.frameY >= 792 && tile.frameY <= 898) { num14 = 5; } if (tile.frameY >= 900 && tile.frameY <= 1006) { num14 = 0; } if (tile.frameY >= 1008 && tile.frameY <= 1114) { num14 = 148; } } if (tile.type == 163) { num14 = 118; } if (tile.type == 164) { num14 = 119; } if (tile.type == 200) { num14 = 120; } if (tile.type == 221 || tile.type == 248) { num14 = 144; } if (tile.type == 222 || tile.type == 249) { num14 = 145; } if (tile.type == 223 || tile.type == 250) { num14 = 146; } if (tile.type == 224) { num14 = 149; } if (tile.type == 225) { num14 = 147; } if (tile.type == 229) { num14 = 153; } if (tile.type == 231) { num14 = 153; if (Main.rand.Next(3) == 0) { num14 = 26; } } if (tile.type == 226) { num14 = 148; } if (tile.type == 103) { num14 = -1; } if (tile.type == 29) { num14 = 23; } if (tile.type == 40) { num14 = 28; } if (tile.type == 49) { num14 = 29; } if (tile.type == 50) { num14 = 22; } if (tile.type == 51) { num14 = 30; } if (tile.type == 52) { num14 = 3; } if (tile.type == 53 || tile.type == 81 || tile.type == 151 || tile.type == 202 || tile.type == 274) { num14 = 32; } if (tile.type == 56 || tile.type == 152) { num14 = 37; } if (tile.type == 75) { num14 = 109; } if (tile.type == 57 || tile.type == 119 || tile.type == 141 || tile.type == 234) { num14 = 36; } if (tile.type == 59 || tile.type == 120) { num14 = 38; } if (tile.type == 61 || tile.type == 62 || tile.type == 74 || tile.type == 80 || tile.type == 188 || tile.type == 233 || tile.type == 236) { num14 = 40; } if (tile.type == 238) { if (WorldGen.genRand.Next(3) == 0) { num14 = 167; } else { num14 = 166; } } if (tile.type == 69) { num14 = 7; } if (tile.type == 71 || tile.type == 72 || tile.type == 190) { num14 = 26; } if (tile.type == 70) { num14 = 17; } if (tile.type == 112) { num14 = 14; } if (tile.type == 123) { num14 = 53; } if (tile.type == 161) { num14 = 80; } if (tile.type == 206) { num14 = 80; } if (tile.type == 162) { num14 = 80; } if (tile.type == 165) { if (tile.frameX < 54) { num14 = 80; } else { if (tile.frameX >= 324) { num14 = 117; } else { if (tile.frameX >= 270) { num14 = 14; } else { if (tile.frameX >= 216) { num14 = 1; } else { if (tile.frameX >= 162) { num14 = 147; } else { if (tile.frameX >= 108) { num14 = 30; } else { num14 = 1; } } } } } } } if (tile.type == 193) { num14 = 4; } if (tile.type == 194) { num14 = 26; } if (tile.type == 195) { num14 = 5; } if (tile.type == 196) { num14 = 108; } if (tile.type == 197) { num14 = 4; } if (tile.type == 153) { num14 = 26; } if (tile.type == 154) { num14 = 32; } if (tile.type == 155) { num14 = 2; } if (tile.type == 156) { num14 = 1; } if (tile.type == 116 || tile.type == 118 || tile.type == 147 || tile.type == 148) { num14 = 51; } if (tile.type == 109) { if (WorldGen.genRand.Next(2) == 0) { num14 = 0; } else { num14 = 47; } } if (tile.type == 110 || tile.type == 113 || tile.type == 115) { num14 = 47; } if (tile.type == 107 || tile.type == 121) { num14 = 48; } if (tile.type == 108 || tile.type == 122 || tile.type == 146) { num14 = 49; } if (tile.type == 111 || tile.type == 145 || tile.type == 150) { num14 = 50; } if (tile.type == 133) { num14 = 50; if (tile.frameX >= 54) { num14 = 146; } } if (tile.type == 134) { num14 = 49; if (tile.frameX >= 36) { num14 = 145; } } if (tile.type == 149) { num14 = 49; } if (Main.tileAlch[(int)tile.type]) { int num31 = (int)(tile.frameX / 18); if (num31 == 0) { num14 = 3; } if (num31 == 1) { num14 = 3; } if (num31 == 2) { num14 = 7; } if (num31 == 3) { num14 = 17; } if (num31 == 4) { num14 = 3; } if (num31 == 5) { num14 = 6; } if (num31 == 6) { num14 = 224; } } if (tile.type == 58 || tile.type == 76 || tile.type == 77) { if (WorldGen.genRand.Next(2) == 0) { num14 = 6; } else { num14 = 25; } } if (tile.type == 37) { if (WorldGen.genRand.Next(2) == 0) { num14 = 6; } else { num14 = 23; } } if (tile.type == 32) { if (WorldGen.genRand.Next(2) == 0) { num14 = 14; } else { num14 = 24; } } if (tile.type == 23 || tile.type == 24) { if (WorldGen.genRand.Next(2) == 0) { num14 = 14; } else { num14 = 17; } } if (tile.type == 25 || tile.type == 31) { if (tile.type == 31 && tile.frameX >= 36) { num14 = 5; } else { if (WorldGen.genRand.Next(2) == 0) { num14 = 14; } else { num14 = 1; } } } if (tile.type == 20) { int num32 = (int)(tile.frameX / 54); if (num32 == 1) { num14 = 122; } else { if (num32 == 2) { num14 = 78; } else { if (num32 == 3) { num14 = 77; } else { if (num32 == 4) { num14 = 121; } else { if (num32 == 5) { num14 = 79; } else { num14 = 7; } } } } } } if (tile.type == 27) { if (WorldGen.genRand.Next(2) == 0) { num14 = 3; } else { num14 = 19; } } if (tile.type == 129) { if (tile.frameX == 0 || tile.frameX == 54 || tile.frameX == 108) { num14 = 68; } else { if (tile.frameX == 18 || tile.frameX == 72 || tile.frameX == 126) { num14 = 69; } else { num14 = 70; } } } if (tile.type == 4) { int num33 = (int)(tile.frameY / 22); if (num33 == 0) { num14 = 6; } else { if (num33 == 8) { num14 = 75; } else { if (num33 == 9) { num14 = 135; } else { if (num33 == 10) { num14 = 158; } else { if (num33 == 11) { num14 = 169; } else { if (num33 == 12) { num14 = 156; } else { num14 = 58 + num33; } } } } } } } if (tile.type == 35) { num14 = 189; if (tile.frameX < 36 && WorldGen.genRand.Next(2) == 0) { num14 = 6; } } if ((tile.type == 34 || tile.type == 42) && Main.rand.Next(2) == 0) { num14 = 6; } if (tile.type == 270) { num14 = -1; } if (tile.type == 271) { num14 = -1; } if (tile.type == 79 || tile.type == 90 || tile.type == 101) { num14 = -1; } if (tile.type == 33 || tile.type == 34 || tile.type == 42 || tile.type == 93 || tile.type == 100) { num14 = -1; } if (tile.type == 321) { num14 = 214; } if (tile.type == 322) { num14 = 215; } if (num14 >= 0) { if (tile.type == 160) { int num34 = Dust.NewDust(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.75f); Main.dust[num34].noGravity = true; } else { if (tile.type == 323) { int frameY = (int)tile.frameY; Dust.NewDust(new Vector2((float)(i * 16 + frameY), (float)(j * 16)), 16, 16, num14, 0f, 0f, 0, default(Color), 1f); } else { if (tile.type == 314) { int num35 = Dust.NewDust(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16, 213, (float)Main.rand.Next(-2, 3), (float)Main.rand.Next(-2, 3), 0, default(Color), 1f); Main.dust[num35].noGravity = true; Main.dust[num35].fadeIn = Main.dust[num35].scale + 1f + 0.01f * (float)Main.rand.Next(0, 51); Main.dust[num35].noGravity = true; } else { if (tile.type == 178) { int num36 = Dust.NewDust(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16, num14, 0f, 0f, 75, default(Color), 0.75f); Main.dust[num36].noLight = true; } else { if (tile.type == 193 || (tile.type == 18 && num14 == 4)) { Dust.NewDust(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16, num14, 0f, 0f, 75, new Color(0, 80, 255, 100), 0.75f); } else { if (tile.type == 197) { Dust.NewDust(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16, num14, 0f, 0f, 75, new Color(97, 200, 255, 100), 0.75f); } else { if (tile.type == 185 && num14 >= 86 && num14 <= 91) { int num37 = Dust.NewDust(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16, num14, 0f, 0f, 75, default(Color), 0.75f); Main.dust[num37].noLight = true; } else { Dust.NewDust(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16, num14, 0f, 0f, 0, default(Color), 1f); } } } } } } } } num13++; continue; IL_1144: num14 = -1; goto IL_1147; } if (effectOnly) { return; } if (fail) { if (tile.type == 2 || tile.type == 23 || tile.type == 109 || tile.type == 199) { tile.type = 0; } if (tile.type == 60 || tile.type == 70) { tile.type = 59; } if (Main.tileMoss[(int)tile.type]) { tile.type = 1; } WorldGen.SquareTileFrame(i, j, true); return; } if (tile.type == 21 && Main.netMode != 1) { int num38 = (int)(tile.frameX / 18); int y = j - (int)(tile.frameY / 18); while (num38 > 1) { num38 -= 2; } num38 = i - num38; if (!Chest.DestroyChest(num38, y)) { return; } } if (tile.type == 51 && tile.wall == 62 && WorldGen.genRand.Next(4) != 0) { noItem = true; } if (!noItem && !WorldGen.stopDrops && Main.netMode != 1) { int num39 = -1; int num40 = -1; if ((double)j < Main.worldSurface) { if (tile.type == 3 || tile.type == 60) { num39 = 400; num40 = 100; } if (tile.type == 73 || tile.type == 74) { num39 = 200; num40 = 50; } } else { if (tile.type == 3 || tile.type == 60) { num39 = 600; } if (tile.type == 73 || tile.type == 74) { num39 = 300; } } if (tile.type == 185) { if (tile.frameY == 0 && tile.frameX < 214) { num39 = 6; } if (tile.frameY == 18 && (tile.frameX < 214 || tile.frameX >= 1368)) { num39 = 6; } } else { if (tile.type == 186) { if (tile.frameX >= 378 && tile.frameX <= 700) { num39 = 6; } } else { if (tile.type == 187) { if (tile.frameX >= 756 && tile.frameX <= 916) { num39 = 6; } if (tile.frameX <= 322) { num39 = 6; } } } } if (NPC.CountNPCS(357) < 5 && num39 > 0 && Main.rand.Next(num39) == 0) { int num41 = NPC.NewNPC(i * 16 + 10, j * 16, 357, 0); Main.npc[num41].TargetClosest(true); Main.npc[num41].velocity.Y = (float)Main.rand.Next(-50, -21) * 0.1f; Main.npc[num41].velocity.X = (float)Main.rand.Next(0, 26) * 0.1f * (float)(-(float)Main.npc[num41].direction); Main.npc[num41].direction *= -1; Main.npc[num41].netUpdate = true; } if (NPC.CountNPCS(377) < 5 && num40 > 0 && Main.rand.Next(num40) == 0) { int num42 = NPC.NewNPC(i * 16 + 10, j * 16, 377, 0); Main.npc[num42].TargetClosest(true); Main.npc[num42].velocity.Y = (float)Main.rand.Next(-50, -21) * 0.1f; Main.npc[num42].velocity.X = (float)Main.rand.Next(0, 26) * 0.1f * (float)(-(float)Main.npc[num42].direction); Main.npc[num42].direction *= -1; Main.npc[num42].netUpdate = true; } int num43 = 0; if (tile.type == 0 || tile.type == 2 || tile.type == 109) { num43 = 2; } else { if (tile.type == 1) { num43 = 3; } else { if (tile.type == 3 || tile.type == 73) { if (Main.rand.Next(2) == 0 && (Main.player[(int)Player.FindClosest(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16)].HasItem(281) || Main.player[(int)Player.FindClosest(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16)].HasItem(986))) { num43 = 283; } } else { if (tile.type == 227) { int num44 = (int)(tile.frameX / 34); num43 = 1107 + num44; } else { if (tile.type == 4) { int num45 = (int)(tile.frameY / 22); if (num45 == 0) { num43 = 8; } else { if (num45 == 8) { num43 = 523; } else { if (num45 == 9) { num43 = 974; } else { if (num45 == 10) { num43 = 1245; } else { if (num45 == 11) { num43 = 1333; } else { if (num45 == 12) { num43 = 2274; } else { num43 = 426 + num45; } } } } } } } else { if (tile.type == 239) { int num46 = (int)(tile.frameX / 18); if (num46 == 0) { num43 = 20; } if (num46 == 1) { num43 = 703; } if (num46 == 2) { num43 = 22; } if (num46 == 3) { num43 = 704; } if (num46 == 4) { num43 = 21; } if (num46 == 5) { num43 = 705; } if (num46 == 6) { num43 = 19; } if (num46 == 7) { num43 = 706; } if (num46 == 8) { num43 = 57; } if (num46 == 9) { num43 = 117; } if (num46 == 10) { num43 = 175; } if (num46 == 11) { num43 = 381; } if (num46 == 12) { num43 = 1184; } if (num46 == 13) { num43 = 382; } if (num46 == 14) { num43 = 1191; } if (num46 == 15) { num43 = 391; } if (num46 == 16) { num43 = 1198; } if (num46 == 17) { num43 = 1006; } if (num46 == 18) { num43 = 1225; } if (num46 == 19) { num43 = 1257; } if (num46 == 20) { num43 = 1552; } } else { if (tile.type == 315) { num43 = 2435; } else { if (tile.type == 330) { num43 = 71; } else { if (tile.type == 331) { num43 = 72; } else { if (tile.type == 332) { num43 = 73; } else { if (tile.type == 333) { num43 = 74; } else { if (tile.type == 5) { if (tile.frameX >= 22 && tile.frameY >= 198) { if (Main.netMode != 1) { if (WorldGen.genRand.Next(2) == 0) { int num47 = j; while (Main.tile[i, num47] != null && (!Main.tile[i, num47].active() || !Main.tileSolid[(int)Main.tile[i, num47].type] || Main.tileSolidTop[(int)Main.tile[i, num47].type])) { num47++; } if (Main.tile[i, num47] != null) { if (Main.tile[i, num47].type == 2 || Main.tile[i, num47].type == 109 || Main.tile[i, num47].type == 147) { num43 = 27; } else { num43 = 9; } } } else { num43 = 9; } } } else { num43 = 9; } if (num43 == 9) { int num48 = i; int num49 = j; if (tile.frameX == 66 && tile.frameY <= 45) { num48++; } if (tile.frameX == 88 && tile.frameY >= 66 && tile.frameY <= 110) { num48--; } if (tile.frameX == 22 && tile.frameY >= 132 && tile.frameY <= 176) { num48--; } if (tile.frameX == 44 && tile.frameY >= 132 && tile.frameY <= 176) { num48++; } if (tile.frameX == 44 && tile.frameY >= 198) { num48++; } if (tile.frameX == 66 && tile.frameY >= 198) { num48--; } while (!Main.tile[num48, num49].active() || !Main.tileSolid[(int)Main.tile[num48, num49].type]) { num49++; } if (Main.tile[num48, num49].active()) { ushort type = Main.tile[num48, num49].type; if (type <= 70) { if (type != 23) { if (type != 60) { if (type == 70) { num43 = 183; } } else { num43 = 620; } } else { num43 = 619; } } else { if (type != 109) { if (type != 147) { if (type == 199) { num43 = 911; } } else { num43 = 2503; } } else { num43 = 621; } } } } } else { if (tile.type == 323) { num43 = 2504; int num50 = j; while (!Main.tile[i, num50].active() || !Main.tileSolid[(int)Main.tile[i, num50].type]) { num50++; } if (Main.tile[i, num50].active()) { ushort type = Main.tile[i, num50].type; if (type != 112) { if (type != 116) { if (type == 234) { num43 = 911; } } else { num43 = 621; } } else { num43 = 619; } } } else { if (tile.type >= 255 && tile.type <= 261) { num43 = (int)(1970 + tile.type - 255); } else { if (tile.type >= 262 && tile.type <= 268) { num43 = (int)(1970 + tile.type - 262); } else { if (tile.type == 171) { if (tile.frameX >= 10) { WorldGen.dropXmasTree(i, j, 0); WorldGen.dropXmasTree(i, j, 1); WorldGen.dropXmasTree(i, j, 2); WorldGen.dropXmasTree(i, j, 3); } } else { if (tile.type == 324) { switch (tile.frameY / 22) { case 0: num43 = 2625; break; case 1: num43 = 2626; break; } } else { if (tile.type == 272) { num43 = 1344; } else { if (tile.type == 273) { num43 = 2119; } else { if (tile.type == 274) { num43 = 2120; } else { if (tile.type == 326) { num43 = 2693; Main.PlaySound(13, i * 16, j * 16, 1); } else { if (tile.type == 327) { num43 = 2694; Main.PlaySound(13, i * 16, j * 16, 1); } else { if (tile.type == 328) { num43 = 2695; Main.PlaySound(13, i * 16, j * 16, 1); } else { if (tile.type == 329) { num43 = 2697; Main.PlaySound(13, i * 16, j * 16, 1); } else { if (tile.type == 336) { num43 = 2701; } else { if (tile.type == 251) { num43 = 1725; } else { if (tile.type == 252) { num43 = 1727; } else { if (tile.type == 253) { num43 = 1729; } else { if (tile.type == 325) { num43 = 2692; } else { if (tile.type == 170) { num43 = 1872; } else { if (tile.type == 284) { num43 = 2173; } else { if (tile.type == 214) { num43 = 85; } else { if (tile.type == 213) { num43 = 965; } else { if (tile.type == 211) { num43 = 947; } else { if (tile.type == 6) { num43 = 11; } else { if (tile.type == 7) { num43 = 12; } else { if (tile.type == 8) { num43 = 13; } else { if (tile.type == 9) { num43 = 14; } else { if (tile.type == 202) { num43 = 824; } else { if (tile.type == 234) { num43 = 1246; } else { if (tile.type == 226) { num43 = 1101; } else { if (tile.type == 224) { num43 = 1103; } else { if (tile.type == 36) { num43 = 1869; } else { if (tile.type == 311) { num43 = 2260; } else { if (tile.type == 312) { num43 = 2261; } else { if (tile.type == 313) { num43 = 2262; } else { if (tile.type == 229) { num43 = 1125; } else { if (tile.type == 230) { num43 = 1127; } else { if (tile.type == 225) { if (WorldGen.genRand.Next(3) == 0) { tile.honey(true); tile.liquid = 255; } else { num43 = 1124; if (Main.netMode != 1 && WorldGen.genRand.Next(2) == 0) { int num51 = 1; if (WorldGen.genRand.Next(3) == 0) { num51 = 2; } for (int num52 = 0; num52 < num51; num52++) { int type2 = WorldGen.genRand.Next(210, 212); int num53 = NPC.NewNPC(i * 16 + 8, j * 16 + 15, type2, 1); Main.npc[num53].velocity.X = (float)WorldGen.genRand.Next(-200, 201) * 0.002f; Main.npc[num53].velocity.Y = (float)WorldGen.genRand.Next(-200, 201) * 0.002f; Main.npc[num53].netUpdate = true; } } } } else { if (tile.type == 221) { num43 = 1104; } else { if (tile.type == 222) { num43 = 1105; } else { if (tile.type == 223) { num43 = 1106; } else { if (tile.type == 248) { num43 = 1589; } else { if (tile.type == 249) { num43 = 1591; } else { if (tile.type == 250) { num43 = 1593; } else { if (tile.type == 191) { num43 = 9; } else { if (tile.type == 203) { num43 = 836; } else { if (tile.type == 204) { num43 = 880; } else { if (tile.type == 166) { num43 = 699; } else { if (tile.type == 167) { num43 = 700; } else { if (tile.type == 168) { num43 = 701; } else { if (tile.type == 169) { num43 = 702; } else { if (tile.type == 123) { num43 = 424; } else { if (tile.type == 124) { num43 = 480; } else { if (tile.type == 157) { num43 = 619; } else { if (tile.type == 158) { num43 = 620; } else { if (tile.type == 159) { num43 = 621; } else { if (tile.type == 161) { num43 = 664; } else { if (tile.type == 206) { num43 = 883; } else { if (tile.type == 232) { num43 = 1150; } else { if (tile.type == 198) { num43 = 775; } else { if (tile.type == 314) { num43 = Minecart.GetTrackItem(tile); } else { if (tile.type == 189) { num43 = 751; } else { if (tile.type == 195) { num43 = 763; } else { if (tile.type == 194) { num43 = 766; } else { if (tile.type == 193) { num43 = 762; } else { if (tile.type == 196) { num43 = 765; } else { if (tile.type == 197) { num43 = 767; } else { if (tile.type == 178) { int num54 = (int)(tile.frameX / 18); if (num54 == 0) { num43 = 181; } else { if (num54 == 1) { num43 = 180; } else { if (num54 == 2) { num43 = 177; } else { if (num54 == 3) { num43 = 179; } else { if (num54 == 4) { num43 = 178; } else { if (num54 == 5) { num43 = 182; } else { if (num54 == 6) { num43 = 999; } } } } } } } } else { if (tile.type == 149) { if (tile.frameX == 0 || tile.frameX == 54) { num43 = 596; } else { if (tile.frameX == 18 || tile.frameX == 72) { num43 = 597; } else { if (tile.frameX == 36 || tile.frameX == 90) { num43 = 598; } } } } else { if (tile.type == 13) { Main.PlaySound(13, i * 16, j * 16, 1); int num55 = (int)(tile.frameX / 18); if (num55 == 1) { num43 = 28; } else { if (num55 == 2) { num43 = 110; } else { if (num55 == 3) { num43 = 350; } else { if (num55 == 4) { num43 = 351; } else { if (num55 == 5) { num43 = 2234; } else { if (num55 == 6) { num43 = 2244; } else { if (num55 == 7) { num43 = 2257; } else { if (num55 == 8) { num43 = 2258; } else { num43 = 31; } } } } } } } } } else { if (tile.type == 19) { int num56 = (int)(tile.frameY / 18); if (num56 == 0) { num43 = 94; } else { if (num56 == 1) { num43 = 631; } else { if (num56 == 2) { num43 = 632; } else { if (num56 == 3) { num43 = 633; } else { if (num56 == 4) { num43 = 634; } else { if (num56 == 5) { num43 = 913; } else { if (num56 == 6) { num43 = 1384; } else { if (num56 == 7) { num43 = 1385; } else { if (num56 == 8) { num43 = 1386; } else { if (num56 == 9) { num43 = 1387; } else { if (num56 == 10) { num43 = 1388; } else { if (num56 == 11) { num43 = 1389; } else { if (num56 == 12) { num43 = 1418; } else { if (num56 == 13) { num43 = 1457; } else { if (num56 == 14) { num43 = 1702; } else { if (num56 == 15) { num43 = 1796; } else { if (num56 == 16) { num43 = 1818; } else { if (num56 == 17) { num43 = 2518; } else { if (num56 == 18) { num43 = 2549; } else { if (num56 == 19) { num43 = 2566; } else { if (num56 == 20) { num43 = 2581; } else { if (num56 == 21) { num43 = 2627; } else { if (num56 == 22) { num43 = 2628; } else { if (num56 == 23) { num43 = 2629; } else { if (num56 == 24) { num43 = 2630; } else { if (num56 == 25) { num43 = 2744; } } } } } } } } } } } } } } } } } } } } } } } } } } } else { if (tile.type == 22) { num43 = 56; } else { if (tile.type == 140) { num43 = 577; } else { if (tile.type == 23) { num43 = 2; } else { if (tile.type == 25) { num43 = 61; } else { if (tile.type == 30) { num43 = 9; } else { if (tile.type == 191) { num43 = 9; } else { if (tile.type == 208) { num43 = 911; } else { if (tile.type == 33) { int num57 = (int)(tile.frameY / 22); num43 = 105; if (num57 == 1) { num43 = 1405; } else { if (num57 == 2) { num43 = 1406; } else { if (num57 == 3) { num43 = 1407; } else { if (num57 >= 4 && num57 <= 13) { num43 = 2045 + num57 - 4; } else { if (num57 >= 14 && num57 <= 16) { num43 = 2153 + num57 - 14; } else { if (num57 == 17) { num43 = 2236; } else { if (num57 == 18) { num43 = 2523; } else { if (num57 == 19) { num43 = 2542; } else { if (num57 == 20) { num43 = 2556; } else { if (num57 == 21) { num43 = 2571; } else { if (num57 == 22) { num43 = 2648; } else { if (num57 == 23) { num43 = 2649; } else { if (num57 == 24) { num43 = 2650; } else { if (num57 == 25) { num43 = 2651; } } } } } } } } } } } } } } } else { if (tile.type == 174) { num43 = 713; } else { if (tile.type == 37) { num43 = 116; } else { if (tile.type == 38) { num43 = 129; } else { if (tile.type == 39) { num43 = 131; } else { if (tile.type == 40) { num43 = 133; } else { if (tile.type == 41) { num43 = 134; } else { if (tile.type == 43) { num43 = 137; } else { if (tile.type == 44) { num43 = 139; } else { if (tile.type == 45) { num43 = 141; } else { if (tile.type == 46) { num43 = 143; } else { if (tile.type == 47) { num43 = 145; } else { if (tile.type == 48) { num43 = 147; } else { if (tile.type == 49) { num43 = 148; } else { if (tile.type == 51) { num43 = 150; } else { if (tile.type == 53) { num43 = 169; } else { if (tile.type == 151) { num43 = 607; } else { if (tile.type == 152) { num43 = 609; } else { if (tile.type == 54) { num43 = 170; Main.PlaySound(13, i * 16, j * 16, 1); } else { if (tile.type == 56) { num43 = 173; } else { if (tile.type == 57) { num43 = 172; } else { if (tile.type == 58) { num43 = 174; } else { if (tile.type == 60) { num43 = 176; } else { if (tile.type == 70) { num43 = 176; } else { if (tile.type == 75) { num43 = 192; } else { if (tile.type == 76) { num43 = 214; } else { if (tile.type == 78) { num43 = 222; } else { if (tile.type == 81) { num43 = 275; } else { if (tile.type == 80) { num43 = 276; } else { if (tile.type == 188) { num43 = 276; } else { if (tile.type == 107) { num43 = 364; } else { if (tile.type == 108) { num43 = 365; } else { if (tile.type == 111) { num43 = 366; } else { if (tile.type == 150) { num43 = 604; } else { if (tile.type == 112) { num43 = 370; } else { if (tile.type == 116) { num43 = 408; } else { if (tile.type == 117) { num43 = 409; } else { if (tile.type == 129) { num43 = 502; } else { if (tile.type == 118) { num43 = 412; } else { if (tile.type == 119) { num43 = 413; } else { if (tile.type == 120) { num43 = 414; } else { if (tile.type == 121) { num43 = 415; } else { if (tile.type == 122) { num43 = 416; } else { if (tile.type == 136) { num43 = 538; } else { if (tile.type == 137) { int num58 = (int)(tile.frameY / 18); if (num58 == 0) { num43 = 539; } if (num58 == 1) { num43 = 1146; } if (num58 == 2) { num43 = 1147; } if (num58 == 3) { num43 = 1148; } if (num58 == 4) { num43 = 1149; } } else { if (tile.type == 141) { num43 = 580; } else { if (tile.type == 145) { num43 = 586; } else { if (tile.type == 146) { num43 = 591; } else { if (tile.type == 147) { num43 = 593; } else { if (tile.type == 148) { num43 = 594; } else { if (tile.type == 153) { num43 = 611; } else { if (tile.type == 154) { num43 = 612; } else { if (tile.type == 155) { num43 = 613; } else { if (tile.type == 156) { num43 = 614; } else { if (tile.type == 160) { num43 = 662; } else { if (tile.type == 175) { num43 = 717; } else { if (tile.type == 176) { num43 = 718; } else { if (tile.type == 177) { num43 = 719; } else { if (tile.type == 163) { num43 = 833; } else { if (tile.type == 164) { num43 = 834; } else { if (tile.type == 200) { num43 = 835; } else { if (tile.type == 210) { num43 = 937; } else { if (tile.type == 135) { int num59 = (int)(tile.frameY / 18); if (num59 == 0) { num43 = 529; } if (num59 == 1) { num43 = 541; } if (num59 == 2) { num43 = 542; } if (num59 == 3) { num43 = 543; } if (num59 == 4) { num43 = 852; } if (num59 == 5) { num43 = 853; } if (num59 == 6) { num43 = 1151; } } else { if (tile.type == 144) { if (tile.frameX == 0) { num43 = 583; } if (tile.frameX == 18) { num43 = 584; } if (tile.frameX == 36) { num43 = 585; } } else { if (tile.type == 130) { num43 = 511; } else { if (tile.type == 131) { num43 = 512; } else { if (tile.type == 61 || tile.type == 74) { if (tile.frameX == 144 && tile.type == 61) { Item.NewItem(i * 16, j * 16, 16, 16, 331, WorldGen.genRand.Next(2, 4), false, 0, false); } else { if (tile.frameX == 162 && tile.type == 61) { num43 = 223; } else { if (tile.frameX >= 108 && tile.frameX <= 126 && tile.type == 61 && WorldGen.genRand.Next(20) == 0) { num43 = 208; } else { if (WorldGen.genRand.Next(100) == 0) { num43 = 195; } } } } } else { if (tile.type == 59 || tile.type == 60) { num43 = 176; } else { if (tile.type == 190) { num43 = 183; } else { if (tile.type == 71 || tile.type == 72) { if (WorldGen.genRand.Next(50) == 0) { num43 = 194; } else { if (WorldGen.genRand.Next(2) == 0) { num43 = 183; } } } else { if (tile.type >= 63 && tile.type <= 68) { num43 = (int)(tile.type - 63 + 177); } else { if (tile.type == 50) { if (tile.frameX == 90) { num43 = 165; } else { num43 = 149; } } else { if (Main.tileAlch[(int)tile.type]) { if (tile.type > 82) { int num60 = (int)(tile.frameX / 18); bool flag = false; num43 = 313 + num60; int type3 = 307 + num60; if (tile.type == 84) { flag = true; } if (num60 == 0 && Main.dayTime) { flag = true; } if (num60 == 1 && !Main.dayTime) { flag = true; } if (num60 == 3 && Main.bloodMoon) { flag = true; } if (num60 == 4 && (Main.raining || Main.cloudAlpha > 0f)) { flag = true; } if (num60 == 6) { num43 = 2358; type3 = 2357; } if (flag) { Item.NewItem(i * 16, j * 16, 16, 16, type3, WorldGen.genRand.Next(1, 4), false, 0, false); } } } else { if (tile.type == 321) { num43 = 2503; } else { if (tile.type == 322) { num43 = 2504; } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } if (num43 > 0) { Item.NewItem(i * 16, j * 16, 16, 16, num43, 1, false, -1, false); } } tile.active(false); tile.halfBrick(false); tile.frameX = -1; tile.frameY = -1; tile.color(0); tile.frameNumber(0); if (tile.type == 58 && j > Main.maxTilesY - 200) { tile.lava(true); tile.liquid = 128; } tile.type = 0; tile.inActive(false); WorldGen.SquareTileFrame(i, j, true); } } }
private static bool HandleItemDrop(GetDataHandlerArgs args) { var id = args.Data.ReadInt16(); var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle()); var vel = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle()); var stacks = args.Data.ReadInt16(); var prefix = args.Data.ReadInt8(); var noDelay = args.Data.ReadBoolean(); var type = args.Data.ReadInt16(); if (OnItemDrop(id, pos, vel, stacks, prefix, noDelay, type)) return true; // player is attempting to crash clients if (type < -48 || type >= Main.maxItemTypes) { return true; } if (type == 0) //Item removed, let client do this to prevent item duplication client side { return false; } if (TShock.CheckRangePermission(args.Player, (int) (pos.X/16f), (int) (pos.Y/16f))) { args.Player.SendData(PacketTypes.ItemDrop, "", id); return true; } Item item = new Item(); item.netDefaults(type); if ((stacks > item.maxStack || stacks <= 0) || (TShock.Itembans.ItemIsBanned(item.name, args.Player) && !args.Player.Group.HasPermission(Permissions.allowdroppingbanneditems))) { args.Player.SendData(PacketTypes.ItemDrop, "", id); return true; } if ((TShock.Config.ServerSideCharacter) && (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - args.Player.LoginMS < TShock.Config.LogonDiscardThreshold)) { //Player is probably trying to sneak items onto the server in their hands!!! Log.ConsoleInfo(string.Format("Player {0} tried to sneak {1} onto the server!", args.Player.Name, item.name)); args.Player.SendData(PacketTypes.ItemDrop, "", id); return true; } if (TShock.CheckIgnores(args.Player)) { args.Player.SendData(PacketTypes.ItemDrop, "", id); return true; } return false; }
public static bool CheckInventory(TSPlayer player) { PlayerData playerData = player.PlayerData; bool check = true; if (player.TPlayer.statLifeMax > playerData.maxHealth) { player.SendMessage("Error: Your max health exceeded (" + playerData.maxHealth + ") which is stored on server", Color.Cyan); check = false; } Item[] inventory = player.TPlayer.inventory; Item[] armor = player.TPlayer.armor; for (int i = 0; i < NetItem.maxNetInventory; i++) { if (i < 49) { Item item = new Item(); Item serverItem = new Item(); if (inventory[i] != null && inventory[i].netID != 0) { if (playerData.inventory[i].netID != inventory[i].netID) { item.netDefaults(inventory[i].netID); item.Prefix(inventory[i].prefix); item.AffixName(); player.SendMessage(player.IgnoreActionsForInventory = "Your item (" + item.name + ") needs to be deleted.", Color.Cyan); check = false; } else if (playerData.inventory[i].prefix != inventory[i].prefix) { item.netDefaults(inventory[i].netID); item.Prefix(inventory[i].prefix); item.AffixName(); player.SendMessage(player.IgnoreActionsForInventory = "Your item (" + item.name + ") needs to be deleted.", Color.Cyan); check = false; } else if (inventory[i].stack > playerData.inventory[i].stack) { item.netDefaults(inventory[i].netID); item.Prefix(inventory[i].prefix); item.AffixName(); player.SendMessage( player.IgnoreActionsForInventory = "Your item (" + item.name + ") (" + inventory[i].stack + ") needs to have it's stack decreased to (" + playerData.inventory[i].stack + ").", Color.Cyan); check = false; } } } else { Item item = new Item(); Item serverItem = new Item(); if (armor[i - 48] != null && armor[i - 48].netID != 0) { if (playerData.inventory[i].netID != armor[i - 48].netID) { item.netDefaults(armor[i - 48].netID); item.Prefix(armor[i - 48].prefix); item.AffixName(); player.SendMessage(player.IgnoreActionsForInventory = "Your armor (" + item.name + ") needs to be deleted.", Color.Cyan); check = false; } else if (playerData.inventory[i].prefix != armor[i - 48].prefix) { item.netDefaults(armor[i - 48].netID); item.Prefix(armor[i - 48].prefix); item.AffixName(); player.SendMessage(player.IgnoreActionsForInventory = "Your armor (" + item.name + ") needs to be deleted.", Color.Cyan); check = false; } else if (armor[i - 48].stack > playerData.inventory[i].stack) { item.netDefaults(armor[i - 48].netID); item.Prefix(armor[i - 48].prefix); item.AffixName(); player.SendMessage( player.IgnoreActionsForInventory = "Your armor (" + item.name + ") (" + inventory[i].stack + ") needs to have it's stack decreased to (" + playerData.inventory[i].stack + ").", Color.Cyan); check = false; } } } } return check; }
public static bool HackedInventory(TSPlayer player) { bool check = false; Item[] inventory = player.TPlayer.inventory; Item[] armor = player.TPlayer.armor; for (int i = 0; i < NetItem.maxNetInventory; i++) { if (i < 49) { Item item = new Item(); if (inventory[i] != null && inventory[i].netID != 0) { item.netDefaults(inventory[i].netID); item.Prefix(inventory[i].prefix); item.AffixName(); if (inventory[i].stack > item.maxStack) { check = true; player.SendMessage( String.Format("Stack cheat detected. Remove item {0} ({1}) and then rejoin", item.name, inventory[i].stack), Color.Cyan); } } } else { Item item = new Item(); if (armor[i - 48] != null && armor[i - 48].netID != 0) { item.netDefaults(armor[i - 48].netID); item.Prefix(armor[i - 48].prefix); item.AffixName(); if (armor[i - 48].stack > item.maxStack) { check = true; player.SendMessage( String.Format("Stack cheat detected. Remove armor {0} ({1}) and then rejoin", item.name, armor[i - 48].stack), Color.Cyan); } } } } return check; }
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 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; } } } } } } } } } }
//SEACH IDs public static List<Item> GetItemByName(string name) { var found = new List<Item>(); for (int i = -24; i < Main.maxItemTypes; i++) { try { Item item = new Item(); item.netDefaults(i); if (item.name.ToLower().Contains(name.ToLower())) found.Add(item); } catch { } } return found; }
/* Search IDs */ public static List<object> ItemIdSearch(string search) { try { var found = new List<object>(); for (int i = -48; i < Main.maxItemTypes; i++) { Item item = new Item(); item.netDefaults(i); if (item.name.ToLower().Contains(search.ToLower())) found.Add(item); } return found; } catch { return new List<object>(); } }
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; } }
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; } } }
/// <summary>HackedInventory - Checks to see if a user has a hacked inventory. In addition, messages players the result.</summary> /// <param name="player">player - The TSPlayer object.</param> /// <returns>bool - True if the player has a hacked inventory.</returns> public static bool HackedInventory(TSPlayer player) { bool check = false; Item[] inventory = player.TPlayer.inventory; Item[] armor = player.TPlayer.armor; Item[] dye = player.TPlayer.dye; Item[] miscEquips = player.TPlayer.miscEquips; Item[] miscDyes = player.TPlayer.miscDyes; Item[] piggy = player.TPlayer.bank.item; Item[] safe = player.TPlayer.bank2.item; Item trash = player.TPlayer.trashItem; for (int i = 0; i < NetItem.MaxInventory; i++) { if (i < NetItem.InventorySlots) { //0-58 Item item = new Item(); if (inventory[i] != null && inventory[i].netID != 0) { item.netDefaults(inventory[i].netID); item.Prefix(inventory[i].prefix); item.AffixName(); if (inventory[i].stack > item.maxStack) { check = true; player.SendMessage( String.Format("Stack cheat detected. Remove item {0} ({1}) and then rejoin", item.name, inventory[i].stack), Color.Cyan); } } } else if (i < NetItem.InventorySlots + NetItem.ArmorSlots) { //59-78 Item item = new Item(); var index = i - NetItem.InventorySlots; if (armor[index] != null && armor[index].netID != 0) { item.netDefaults(armor[index].netID); item.Prefix(armor[index].prefix); item.AffixName(); if (armor[index].stack > item.maxStack) { check = true; player.SendMessage( String.Format("Stack cheat detected. Remove armor {0} ({1}) and then rejoin", item.name, armor[index].stack), Color.Cyan); } } } else if (i < NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots) { //79-88 Item item = new Item(); var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots); if (dye[index] != null && dye[index].netID != 0) { item.netDefaults(dye[index].netID); item.Prefix(dye[index].prefix); item.AffixName(); if (dye[index].stack > item.maxStack) { check = true; player.SendMessage( String.Format("Stack cheat detected. Remove dye {0} ({1}) and then rejoin", item.name, dye[index].stack), Color.Cyan); } } } else if (i < NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots) { //89-93 Item item = new Item(); var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots); if (miscEquips[index] != null && miscEquips[index].netID != 0) { item.netDefaults(miscEquips[index].netID); item.Prefix(miscEquips[index].prefix); item.AffixName(); if (miscEquips[index].stack > item.maxStack) { check = true; player.SendMessage( String.Format("Stack cheat detected. Remove item {0} ({1}) and then rejoin", item.name, miscEquips[index].stack), Color.Cyan); } } } else if (i < NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots + NetItem.MiscDyeSlots) { //93-98 Item item = new Item(); var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots); if (miscDyes[index] != null && miscDyes[index].netID != 0) { item.netDefaults(miscDyes[index].netID); item.Prefix(miscDyes[index].prefix); item.AffixName(); if (miscDyes[index].stack > item.maxStack) { check = true; player.SendMessage( String.Format("Stack cheat detected. Remove item dye {0} ({1}) and then rejoin", item.name, miscDyes[index].stack), Color.Cyan); } } } else if (i < NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots + NetItem.MiscDyeSlots + NetItem.PiggySlots) { //98-138 Item item = new Item(); var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots + NetItem.MiscDyeSlots); if (piggy[index] != null && piggy[index].netID != 0) { item.netDefaults(piggy[index].netID); item.Prefix(piggy[index].prefix); item.AffixName(); if (piggy[index].stack > item.maxStack) { check = true; player.SendMessage( String.Format("Stack cheat detected. Remove Piggy-bank item {0} ({1}) and then rejoin", item.name, piggy[index].stack), Color.Cyan); } } } else if (i < NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots + NetItem.MiscDyeSlots + NetItem.PiggySlots + NetItem.SafeSlots) { //138-178 Item item = new Item(); var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots + NetItem.MiscDyeSlots + NetItem.PiggySlots); if (safe[index] != null && safe[index].netID != 0) { item.netDefaults(safe[index].netID); item.Prefix(safe[index].prefix); item.AffixName(); if (safe[index].stack > item.maxStack) { check = true; player.SendMessage( String.Format("Stack cheat detected. Remove Safe item {0} ({1}) and then rejoin", item.name, safe[index].stack), Color.Cyan); } } } else { Item item = new Item(); if (trash != null && trash.netID != 0) { item.netDefaults(trash.netID); item.Prefix(trash.prefix); item.AffixName(); if (trash.stack > item.maxStack) { check = true; player.SendMessage( String.Format("Stack cheat detected. Remove trash item {0} ({1}) and then rejoin", item.name, trash.stack), Color.Cyan); } } } } return check; }
private static bool HandlePlayerSlot(GetDataHandlerArgs args) { int plr = args.Data.ReadInt8(); int slot = args.Data.ReadInt8(); int stack = args.Data.ReadInt8(); short prefix = (short) args.Data.ReadInt8(); int type = (int) args.Data.ReadInt16(); if (plr != args.Player.Index) { return true; } if (slot < 0 || slot > NetItem.maxNetInventory) { return true; } var item = new Item(); item.netDefaults(type); item.Prefix(prefix); if (stack > item.maxStack && type != 0 && args.Player.IgnoreActionsForCheating != "none" && !args.Player.Group.HasPermission(Permissions.ignorestackhackdetection)) { args.Player.IgnoreActionsForCheating = "Item Hack: " + item.name + " (" + stack + ") exceeds max stack of " + item.maxStack; } if (args.Player.IsLoggedIn) { args.Player.PlayerData.StoreSlot(slot, type, prefix, stack); } return false; }
/// <summary>ComputeMaxStyles - Computes the max styles...</summary> private void ComputeMaxStyles() { var item = new Item(); for (int i = 0; i < Main.maxItemTypes; i++) { item.netDefaults(i); if (item.placeStyle > 0) { if (GetDataHandlers.MaxPlaceStyles.ContainsKey(item.createTile)) { if (item.placeStyle > GetDataHandlers.MaxPlaceStyles[item.createTile]) GetDataHandlers.MaxPlaceStyles[item.createTile] = item.placeStyle; } else GetDataHandlers.MaxPlaceStyles.Add(item.createTile, item.placeStyle); } } }
private static bool HandleChestItem(GetDataHandlerArgs args) { var id = args.Data.ReadInt16(); var slot = args.Data.ReadInt8(); var stacks = args.Data.ReadInt16(); var prefix = args.Data.ReadInt8(); var type = args.Data.ReadInt16(); if (OnChestItemChange(id, slot, stacks, prefix, type)) return true; if (args.TPlayer.chest != id) { return false; } if (TShock.CheckIgnores(args.Player)) { args.Player.SendData(PacketTypes.ChestItem, "", id, slot); return true; } Item item = new Item(); item.netDefaults(type); if (stacks > item.maxStack || TShock.Itembans.ItemIsBanned(item.name, args.Player)) { return false; } if (TShock.CheckTilePermission(args.Player, Main.chest[id].x, Main.chest[id].y) && TShock.Config.RegionProtectChests) { return false; } if (TShock.CheckRangePermission(args.Player, Main.chest[id].x, Main.chest[id].y)) { return false; } return false; }
public void SetItem() { #if Full_API Item = new Item(); Item.netDefaults(NetID); Item.stack = Amount; Item.Prefix(Prefix); #endif }
void OnInitialize(EventArgs e) { Directory.CreateDirectory("worldedit"); #region Commands TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.selection.all", All, "/all") { HelpText = "Sets the worldedit selection to the entire world." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.region.biome", Biome, "/biome") { HelpText = "Converts biomes in the worldedit selection." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.clipboard.copy", Copy, "/copy") { HelpText = "Copies the worldedit selection to the clipboard." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.clipboard.cut", Cut, "/cut") { HelpText = "Copies the worldedit selection to the clipboard, then deletes it." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.utils.drain", Drain, "/drain") { HelpText = "Drains liquids in the worldedit selection." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.utils.fixgrass", FixGrass, "/fixgrass") { HelpText = "Fixes suffocated grass in the worldedit selection." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.utils.fixhalves", FixHalves, "/fixhalves") { HelpText = "Fixes half blocks in the worldedit selection." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.utils.fixslopes", FixSlopes, "/fixslopes") { HelpText = "Fixes covered slopes in the worldedit selection." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.clipboard.flip", Flip, "/flip") { HelpText = "Flips the worldedit clipboard." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.utils.flood", Flood, "/flood") { HelpText = "Floods liquids in the worldedit selection." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.utils.mow", Mow, "/mow") { HelpText = "Mows grass, thorns, and vines in the worldedit selection." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.selection.near", Near, "/near") { AllowServer = false, HelpText = "Sets the worldedit selection to a radius around you." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.region.paint", Paint, "/paint") { HelpText = "Paints tiles in the worldedit selection." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.region.paintwall", PaintWall, "/paintwall") { HelpText = "Paints walls in the worldedit selection." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.clipboard.paste", Paste, "/paste") { HelpText = "Pastes the clipboard to the worldedit selection." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.selection.point", Point1, "/point1") { HelpText = "Sets the positions of the worldedit selection's first point." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.selection.point", Point2, "/point2") { HelpText = "Sets the positions of the worldedit selection's second point." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.history.redo", Redo, "/redo") { HelpText = "Redoes a number of worldedit actions." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.selection.region", RegionCmd, "/region") { HelpText = "Selects a region as a worldedit selection." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.selection.resize", Resize, "/resize") { HelpText = "Resizes the worldedit selection in a direction." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.clipboard.rotate", Rotate, "/rotate") { HelpText = "Rotates the worldedit clipboard." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.schematic", Schematic, "/schematic", "/schem") { HelpText = "Manages worldedit schematics." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.selection.selecttype", Select, "/select") { HelpText = "Sets the worldedit selection function." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.region.set", Set, "/set") { HelpText = "Sets tiles in the worldedit selection." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.region.setwall", SetWall, "/setwall") { HelpText = "Sets walls in the worldedit selection." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.region.setwire", SetWire, "/setwire") { HelpText = "Sets wires in the worldedit selection." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.selection.shift", Shift, "/shift") { HelpText = "Shifts the worldedit selection in a direction." }); TShockAPI.Commands.ChatCommands.Add(new Command("worldedit.history.undo", Undo, "/undo") { HelpText = "Undoes a number of worldedit actions." }); #endregion #region Database switch (TShock.Config.StorageType.ToLowerInvariant()) { case "mysql": string[] host = TShock.Config.MySqlHost.Split(':'); Database = 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, "worldedit.sqlite"); Database = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql)); break; } var sqlcreator = new SqlTableCreator(Database, Database.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator()); sqlcreator.EnsureTableStructure(new SqlTable("WorldEdit", new SqlColumn("Account", MySqlDbType.VarChar) { Primary = true, Length = 50 }, new SqlColumn("RedoLevel", MySqlDbType.Int32), new SqlColumn("UndoLevel", MySqlDbType.Int32))); #endregion #region Biomes // Format: dirt, stone, ice, sand, grass, plants, tall plants, vines, thorn Biomes.Add("crimson", new[] { 0, 203, 200, 234, 199, -1, -1, 205, 32 }); Biomes.Add("corruption", new[] { 0, 25, 163, 112, 23, 24, -1, -1, 32 }); Biomes.Add("hallow", new[] { 0, 117, 164, 116, 109, 110, 113, 52, -1 }); Biomes.Add("jungle", new[] { 59, 1, 161, 53, 60, 61, 74, 62, 69 }); Biomes.Add("mushroom", new[] { 59, 1, 161, 53, 70, 71, -1, -1, -1 }); Biomes.Add("normal", new[] { 0, 1, 161, 53, 2, 3, 73, 52, -1 }); Biomes.Add("snow", new[] { 147, 161, 161, 53, 147, -1, -1, -1, -1 }); #endregion #region Colors Colors.Add("blank", 0); Main.player[Main.myPlayer] = new Player(); var item = new Item(); for (int i = -48; i < Main.maxItemTypes; i++) { item.netDefaults(i); if (item.paint > 0) Colors.Add(item.name.Substring(0, item.name.Length - 6).ToLowerInvariant(), item.paint); } #endregion #region Selections Selections.Add("altcheckers", (i, j, plr) => ((i + j) & 1) == 0); Selections.Add("checkers", (i, j, plr) => ((i + j) & 1) == 1); Selections.Add("ellipse", (i, j, plr) => { PlayerInfo info = plr.GetPlayerInfo(); int X = Math.Min(info.X, info.X2); int Y = Math.Min(info.Y, info.Y2); int X2 = Math.Max(info.X, info.X2); int Y2 = Math.Max(info.Y, info.Y2); Vector2 center = new Vector2((float)(X2 - X) / 2, (float)(Y2 - Y) / 2); float major = Math.Max(center.X, center.Y); float minor = Math.Min(center.X, center.Y); if (center.Y > center.X) { float temp = major; major = minor; minor = temp; } return (i - center.X - X) * (i - center.X - X) / (major * major) + (j - center.Y - Y) * (j - center.Y - Y) / (minor * minor) <= 1; }); Selections.Add("normal", (i, j, plr) => true); Selections.Add("outline", (i, j, plr) => { PlayerInfo info = plr.GetPlayerInfo(); return i == info.X || i == info.X2 || j == info.Y || j == info.Y2; }); #endregion #region Tiles Tiles.Add("air", -1); Tiles.Add("lava", -2); Tiles.Add("honey", -3); Tiles.Add("water", -4); foreach (var fi in typeof(TileID).GetFields()) { string name = fi.Name; var sb = new StringBuilder(); for (int i = 0; i < name.Length; i++) { if (Char.IsUpper(name[i])) sb.Append(" ").Append(Char.ToLower(name[i])); else sb.Append(name[i]); } Tiles.Add(sb.ToString(1, sb.Length - 1), (ushort)fi.GetValue(null)); } #endregion #region Walls Walls.Add("air", 0); foreach (var fi in typeof(WallID).GetFields()) { string name = fi.Name; var sb = new StringBuilder(); for (int i = 0; i < name.Length; i++) { if (Char.IsUpper(name[i])) sb.Append(" ").Append(Char.ToLower(name[i])); else sb.Append(name[i]); } Walls.Add(sb.ToString(1, sb.Length - 1), (byte)fi.GetValue(null)); } #endregion ThreadPool.QueueUserWorkItem(QueueCallback); }