Deathmax

Untitled

May 26th, 2011
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 167.11 KB | None | 0 0
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Input;
  3. using System;
  4. using System.IO;
  5. using System.Security.Cryptography;
  6. using System.Text;
  7. namespace Terraria
  8. {
  9.     public class Player
  10.     {
  11.         public bool pvpDeath;
  12.         public bool zoneDungeon;
  13.         public bool zoneEvil;
  14.         public bool zoneMeteor;
  15.         public bool zoneJungle;
  16.         public bool boneArmor;
  17.         public int townNPCs;
  18.         public Vector2 position;
  19.         public Vector2 velocity;
  20.         public Vector2 oldVelocity;
  21.         public double headFrameCounter;
  22.         public double bodyFrameCounter;
  23.         public double legFrameCounter;
  24.         public bool immune;
  25.         public int immuneTime;
  26.         public int immuneAlphaDirection;
  27.         public int immuneAlpha;
  28.         public int team;
  29.         public string chatText = "";
  30.         public int sign = -1;
  31.         public int chatShowTime;
  32.         public int activeNPCs;
  33.         public bool mouseInterface;
  34.         public int changeItem = -1;
  35.         public int selectedItem;
  36.         public Item[] armor = new Item[8];
  37.         public int itemAnimation;
  38.         public int itemAnimationMax;
  39.         public int itemTime;
  40.         public float itemRotation;
  41.         public int itemWidth;
  42.         public int itemHeight;
  43.         public Vector2 itemLocation;
  44.         public int breathCD;
  45.         public int breathMax = 200;
  46.         public int breath = 200;
  47.         public string setBonus = "";
  48.         public Item[] inventory = new Item[44];
  49.         public Item[] bank = new Item[Chest.maxItems];
  50.         public float headRotation;
  51.         public float bodyRotation;
  52.         public float legRotation;
  53.         public Vector2 headPosition;
  54.         public Vector2 bodyPosition;
  55.         public Vector2 legPosition;
  56.         public Vector2 headVelocity;
  57.         public Vector2 bodyVelocity;
  58.         public Vector2 legVelocity;
  59.         public bool dead;
  60.         public int respawnTimer;
  61.         public string name = "";
  62.         public int attackCD;
  63.         public int potionDelay;
  64.         public bool wet;
  65.         public byte wetCount;
  66.         public bool lavaWet;
  67.         public int hitTile;
  68.         public int hitTileX;
  69.         public int hitTileY;
  70.         public int jump;
  71.         public int head = -1;
  72.         public int body = -1;
  73.         public int legs = -1;
  74.         public Rectangle headFrame;
  75.         public Rectangle bodyFrame;
  76.         public Rectangle legFrame;
  77.         public Rectangle hairFrame;
  78.         public bool controlLeft;
  79.         public bool controlRight;
  80.         public bool controlUp;
  81.         public bool controlDown;
  82.         public bool controlJump;
  83.         public bool controlUseItem;
  84.         public bool controlUseTile;
  85.         public bool controlThrow;
  86.         public bool controlInv;
  87.         public bool releaseJump;
  88.         public bool releaseUseItem;
  89.         public bool releaseUseTile;
  90.         public bool releaseInventory;
  91.         public bool delayUseItem;
  92.         public bool active;
  93.         public int width = 20;
  94.         public int height = 42;
  95.         public int direction = 1;
  96.         public bool showItemIcon;
  97.         public int showItemIcon2;
  98.         public int whoAmi;
  99.         public int runSoundDelay;
  100.         public float shadow;
  101.         public float manaCost = 1f;
  102.         public bool fireWalk;
  103.         public Vector2[] shadowPos = new Vector2[3];
  104.         public int shadowCount;
  105.         public bool channel;
  106.         public int step = -1;
  107.         public float meleeSpeed = 1f;
  108.         public int statDefense;
  109.         public int statAttack;
  110.         public int statLifeMax = 100;
  111.         public int statLife = 100;
  112.         public int statMana;
  113.         public int statManaMax;
  114.         public int lifeRegen;
  115.         public int lifeRegenCount;
  116.         public int manaRegen;
  117.         public int manaRegenCount;
  118.         public int manaRegenDelay;
  119.         public bool noKnockback;
  120.         public int SpawnX = -1;
  121.         public int SpawnY = -1;
  122.         public int[] spX = new int[200];
  123.         public int[] spY = new int[200];
  124.         public string[] spN = new string[200];
  125.         public int[] spI = new int[200];
  126.         public static int tileRangeX = 5;
  127.         public static int tileRangeY = 4;
  128.         private static int tileTargetX;
  129.         private static int tileTargetY;
  130.         private static int jumpHeight = 15;
  131.         private static float jumpSpeed = 5.01f;
  132.         public bool[] adjTile = new bool[80];
  133.         public bool[] oldAdjTile = new bool[80];
  134.         private static int itemGrabRange = 38;
  135.         private static float itemGrabSpeed = 0.45f;
  136.         private static float itemGrabSpeedMax = 4f;
  137.         public Color hairColor = new Color(215, 90, 55);
  138.         public Color skinColor = new Color(255, 125, 90);
  139.         public Color eyeColor = new Color(105, 90, 75);
  140.         public Color shirtColor = new Color(175, 165, 140);
  141.         public Color underShirtColor = new Color(160, 180, 215);
  142.         public Color pantsColor = new Color(255, 230, 175);
  143.         public Color shoeColor = new Color(160, 105, 60);
  144.         public int hair;
  145.         public bool hostile;
  146.         public int accWatch;
  147.         public int accDepthMeter;
  148.         public bool accFlipper;
  149.         public bool doubleJump;
  150.         public bool jumpAgain;
  151.         public bool spawnMax;
  152.         public int[] grappling = new int[20];
  153.         public int grapCount;
  154.         public int rocketDelay;
  155.         public int rocketDelay2;
  156.         public bool rocketRelease;
  157.         public bool rocketFrame;
  158.         public bool rocketBoots;
  159.         public bool canRocket;
  160.         public bool jumpBoost;
  161.         public bool noFallDmg;
  162.         public int swimTime;
  163.         public int chest = -1;
  164.         public int chestX;
  165.         public int chestY;
  166.         public int talkNPC = -1;
  167.         public int fallStart;
  168.         public int slowCount;
  169.         public void HealEffect(int healAmount)
  170.         {
  171.             CombatText.NewText(new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height), new Color(100, 100, 255, 255), string.Concat(healAmount));
  172.             if (Main.netMode == 1 && this.whoAmi == Main.myPlayer)
  173.             {
  174.                 NetMessage.SendData(35, -1, -1, "", this.whoAmi, (float)healAmount, 0f, 0f);
  175.             }
  176.         }
  177.         public void ManaEffect(int manaAmount)
  178.         {
  179.             CombatText.NewText(new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height), new Color(180, 50, 255, 255), string.Concat(manaAmount));
  180.             if (Main.netMode == 1 && this.whoAmi == Main.myPlayer)
  181.             {
  182.                 NetMessage.SendData(43, -1, -1, "", this.whoAmi, (float)manaAmount, 0f, 0f);
  183.             }
  184.         }
  185.         public static byte FindClosest(Vector2 Position, int Width, int Height)
  186.         {
  187.             byte result = 0;
  188.             for (int i = 0; i < 8; i++)
  189.             {
  190.                 if (Main.player[i].active)
  191.                 {
  192.                     result = (byte)i;
  193.                     break;
  194.                 }
  195.             }
  196.             float num = -1f;
  197.             for (int j = 0; j < 8; j++)
  198.             {
  199.                 if (Main.player[j].active && !Main.player[j].dead && (num == -1f || Math.Abs(Main.player[j].position.X + (float)(Main.player[j].width / 2) - Position.X + (float)(Width / 2)) + Math.Abs(Main.player[j].position.Y + (float)(Main.player[j].height / 2) - Position.Y + (float)(Height / 2)) < num))
  200.                 {
  201.                     num = Math.Abs(Main.player[j].position.X + (float)(Main.player[j].width / 2) - Position.X + (float)(Width / 2)) + Math.Abs(Main.player[j].position.Y + (float)(Main.player[j].height / 2) - Position.Y + (float)(Height / 2));
  202.                     result = (byte)j;
  203.                 }
  204.             }
  205.             return result;
  206.         }
  207.         public void UpdatePlayer(int i)
  208.         {
  209.             float num = 10f;
  210.             float num2 = 0.4f;
  211.             Player.jumpHeight = 15;
  212.             Player.jumpSpeed = 5.01f;
  213.             if (this.wet)
  214.             {
  215.                 num2 = 0.2f;
  216.                 num = 5f;
  217.                 Player.jumpHeight = 30;
  218.                 Player.jumpSpeed = 6.01f;
  219.             }
  220.             float num3 = 3f;
  221.             float num4 = 0.08f;
  222.             float num5 = 0.2f;
  223.             float num6 = num3;
  224.             if (this.active)
  225.             {
  226.                 this.shadowCount++;
  227.                 if (this.shadowCount == 1)
  228.                 {
  229.                     this.shadowPos[2] = this.shadowPos[1];
  230.                 }
  231.                 else
  232.                 {
  233.                     if (this.shadowCount == 2)
  234.                     {
  235.                         this.shadowPos[1] = this.shadowPos[0];
  236.                     }
  237.                     else
  238.                     {
  239.                         if (this.shadowCount >= 3)
  240.                         {
  241.                             this.shadowCount = 0;
  242.                             this.shadowPos[0] = this.position;
  243.                         }
  244.                     }
  245.                 }
  246.                 this.whoAmi = i;
  247.                 if (this.runSoundDelay > 0)
  248.                 {
  249.                     this.runSoundDelay--;
  250.                 }
  251.                 if (this.attackCD > 0)
  252.                 {
  253.                     this.attackCD--;
  254.                 }
  255.                 if (this.itemAnimation == 0)
  256.                 {
  257.                     this.attackCD = 0;
  258.                 }
  259.                 if (this.chatShowTime > 0)
  260.                 {
  261.                     this.chatShowTime--;
  262.                 }
  263.                 if (this.potionDelay > 0)
  264.                 {
  265.                     this.potionDelay--;
  266.                 }
  267.                 if (this.dead)
  268.                 {
  269.                     if (i == Main.myPlayer)
  270.                     {
  271.                         Main.npcChatText = "";
  272.                         Main.editSign = false;
  273.                     }
  274.                     this.sign = -1;
  275.                     this.talkNPC = -1;
  276.                     this.statLife = 0;
  277.                     this.channel = false;
  278.                     this.potionDelay = 0;
  279.                     this.chest = -1;
  280.                     this.changeItem = -1;
  281.                     this.itemAnimation = 0;
  282.                     this.immuneAlpha += 2;
  283.                     if (this.immuneAlpha > 255)
  284.                     {
  285.                         this.immuneAlpha = 255;
  286.                     }
  287.                     this.respawnTimer--;
  288.                     this.headPosition += this.headVelocity;
  289.                     this.bodyPosition += this.bodyVelocity;
  290.                     this.legPosition += this.legVelocity;
  291.                     this.headRotation += this.headVelocity.X * 0.1f;
  292.                     this.bodyRotation += this.bodyVelocity.X * 0.1f;
  293.                     this.legRotation += this.legVelocity.X * 0.1f;
  294.                     this.headVelocity.Y = this.headVelocity.Y + 0.1f;
  295.                     this.bodyVelocity.Y = this.bodyVelocity.Y + 0.1f;
  296.                     this.legVelocity.Y = this.legVelocity.Y + 0.1f;
  297.                     this.headVelocity.X = this.headVelocity.X * 0.99f;
  298.                     this.bodyVelocity.X = this.bodyVelocity.X * 0.99f;
  299.                     this.legVelocity.X = this.legVelocity.X * 0.99f;
  300.                     if (this.respawnTimer <= 0 && Main.myPlayer == this.whoAmi)
  301.                     {
  302.                         this.Spawn();
  303.                         return;
  304.                     }
  305.                 }
  306.                 else
  307.                 {
  308.                     if (i == Main.myPlayer)
  309.                     {
  310.                         this.zoneEvil = false;
  311.                         if (Main.evilTiles >= 500)
  312.                         {
  313.                             this.zoneEvil = true;
  314.                         }
  315.                         this.zoneMeteor = false;
  316.                         if (Main.meteorTiles >= 50)
  317.                         {
  318.                             this.zoneMeteor = true;
  319.                         }
  320.                         this.zoneDungeon = false;
  321.                         if (Main.dungeonTiles >= 250 && (double)this.position.Y > Main.worldSurface * 16.0 + (double)Main.screenHeight)
  322.                         {
  323.                             int num7 = (int)this.position.X / 16;
  324.                             int num8 = (int)this.position.Y / 16;
  325.                             if (Main.tile[num7, num8].wall > 0 && !Main.wallHouse[(int)Main.tile[num7, num8].wall])
  326.                             {
  327.                                 this.zoneDungeon = true;
  328.                             }
  329.                         }
  330.                         this.zoneJungle = false;
  331.                         if (Main.jungleTiles >= 200)
  332.                         {
  333.                             this.zoneJungle = true;
  334.                         }
  335.                         this.controlUp = false;
  336.                         this.controlLeft = false;
  337.                         this.controlDown = false;
  338.                         this.controlRight = false;
  339.                         this.controlJump = false;
  340.                         this.controlUseItem = false;
  341.                         this.controlUseTile = false;
  342.                         this.controlThrow = false;
  343.                         this.controlInv = false;
  344.                         if (Main.hasFocus)
  345.                         {
  346.                             if (!Main.chatMode && !Main.editSign)
  347.                             {
  348.                                 Keys[] pressedKeys = Main.keyState.GetPressedKeys();
  349.                                 for (int j = 0; j < pressedKeys.Length; j++)
  350.                                 {
  351.                                     string a = string.Concat(pressedKeys[j]);
  352.                                     if (a == Main.cUp)
  353.                                     {
  354.                                         this.controlUp = true;
  355.                                     }
  356.                                     if (a == Main.cLeft)
  357.                                     {
  358.                                         this.controlLeft = true;
  359.                                     }
  360.                                     if (a == Main.cDown)
  361.                                     {
  362.                                         this.controlDown = true;
  363.                                     }
  364.                                     if (a == Main.cRight)
  365.                                     {
  366.                                         this.controlRight = true;
  367.                                     }
  368.                                     if (a == Main.cJump)
  369.                                     {
  370.                                         this.controlJump = true;
  371.                                     }
  372.                                     if (a == Main.cThrowItem)
  373.                                     {
  374.                                         this.controlThrow = true;
  375.                                     }
  376.                                     if (a == Main.cInv)
  377.                                     {
  378.                                         this.controlInv = true;
  379.                                     }
  380.                                 }
  381.                                 if (this.controlLeft && this.controlRight)
  382.                                 {
  383.                                     this.controlLeft = false;
  384.                                     this.controlRight = false;
  385.                                 }
  386.                             }
  387.                             if (Main.mouseState.LeftButton == ButtonState.Pressed && !this.mouseInterface)
  388.                             {
  389.                                 this.controlUseItem = true;
  390.                             }
  391.                             if (Main.mouseState.RightButton == ButtonState.Pressed && !this.mouseInterface)
  392.                             {
  393.                                 this.controlUseTile = true;
  394.                             }
  395.                             if (this.controlInv)
  396.                             {
  397.                                 if (this.releaseInventory)
  398.                                 {
  399.                                     if (this.talkNPC >= 0)
  400.                                     {
  401.                                         this.talkNPC = -1;
  402.                                         Main.npcChatText = "";
  403.                                         Main.PlaySound(11, -1, -1, 1);
  404.                                     }
  405.                                     else
  406.                                     {
  407.                                         if (this.sign >= 0)
  408.                                         {
  409.                                             this.sign = -1;
  410.                                             Main.editSign = false;
  411.                                             Main.npcChatText = "";
  412.                                             Main.PlaySound(11, -1, -1, 1);
  413.                                         }
  414.                                         else
  415.                                         {
  416.                                             if (!Main.playerInventory)
  417.                                             {
  418.                                                 Recipe.FindRecipes();
  419.                                                 Main.playerInventory = true;
  420.                                                 Main.PlaySound(10, -1, -1, 1);
  421.                                             }
  422.                                             else
  423.                                             {
  424.                                                 Main.playerInventory = false;
  425.                                                 Main.PlaySound(11, -1, -1, 1);
  426.                                             }
  427.                                         }
  428.                                     }
  429.                                 }
  430.                                 this.releaseInventory = false;
  431.                             }
  432.                             else
  433.                             {
  434.                                 this.releaseInventory = true;
  435.                             }
  436.                             if (this.delayUseItem)
  437.                             {
  438.                                 if (!this.controlUseItem)
  439.                                 {
  440.                                     this.delayUseItem = false;
  441.                                 }
  442.                                 this.controlUseItem = false;
  443.                             }
  444.                             if (this.itemAnimation == 0 && this.itemTime == 0)
  445.                             {
  446.                                 if ((this.controlThrow && this.inventory[this.selectedItem].type > 0 && !Main.chatMode) || (((Main.mouseState.LeftButton == ButtonState.Pressed && !this.mouseInterface && Main.mouseLeftRelease) || !Main.playerInventory) && Main.mouseItem.type > 0))
  447.                                 {
  448.                                     Item item = new Item();
  449.                                     bool flag = false;
  450.                                     if (((Main.mouseState.LeftButton == ButtonState.Pressed && !this.mouseInterface && Main.mouseLeftRelease) || !Main.playerInventory) && Main.mouseItem.type > 0)
  451.                                     {
  452.                                         item = this.inventory[this.selectedItem];
  453.                                         this.inventory[this.selectedItem] = Main.mouseItem;
  454.                                         this.delayUseItem = true;
  455.                                         this.controlUseItem = false;
  456.                                         flag = true;
  457.                                     }
  458.                                     int num9 = Item.NewItem((int)this.position.X, (int)this.position.Y, this.width, this.height, this.inventory[this.selectedItem].type, 1, false);
  459.                                     if (!flag && this.inventory[this.selectedItem].type == 8 && this.inventory[this.selectedItem].stack > 1)
  460.                                     {
  461.                                         this.inventory[this.selectedItem].stack--;
  462.                                     }
  463.                                     else
  464.                                     {
  465.                                         this.inventory[this.selectedItem].position = Main.item[num9].position;
  466.                                         Main.item[num9] = this.inventory[this.selectedItem];
  467.                                         this.inventory[this.selectedItem] = new Item();
  468.                                     }
  469.                                     if (Main.netMode == 0)
  470.                                     {
  471.                                         Main.item[num9].noGrabDelay = 100;
  472.                                     }
  473.                                     Main.item[num9].velocity.Y = -2f;
  474.                                     Main.item[num9].velocity.X = (float)(4 * this.direction) + this.velocity.X;
  475.                                     if (((Main.mouseState.LeftButton == ButtonState.Pressed && !this.mouseInterface) || !Main.playerInventory) && Main.mouseItem.type > 0)
  476.                                     {
  477.                                         this.inventory[this.selectedItem] = item;
  478.                                         Main.mouseItem = new Item();
  479.                                     }
  480.                                     else
  481.                                     {
  482.                                         this.itemAnimation = 10;
  483.                                         this.itemAnimationMax = 10;
  484.                                     }
  485.                                     Recipe.FindRecipes();
  486.                                     if (Main.netMode == 1)
  487.                                     {
  488.                                         NetMessage.SendData(21, -1, -1, "", num9, 0f, 0f, 0f);
  489.                                     }
  490.                                 }
  491.                                 if (!Main.playerInventory)
  492.                                 {
  493.                                     int num10 = this.selectedItem;
  494.                                     if (!Main.chatMode)
  495.                                     {
  496.                                         if (Main.keyState.IsKeyDown(Keys.D1))
  497.                                         {
  498.                                             this.selectedItem = 0;
  499.                                         }
  500.                                         if (Main.keyState.IsKeyDown(Keys.D2))
  501.                                         {
  502.                                             this.selectedItem = 1;
  503.                                         }
  504.                                         if (Main.keyState.IsKeyDown(Keys.D3))
  505.                                         {
  506.                                             this.selectedItem = 2;
  507.                                         }
  508.                                         if (Main.keyState.IsKeyDown(Keys.D4))
  509.                                         {
  510.                                             this.selectedItem = 3;
  511.                                         }
  512.                                         if (Main.keyState.IsKeyDown(Keys.D5))
  513.                                         {
  514.                                             this.selectedItem = 4;
  515.                                         }
  516.                                         if (Main.keyState.IsKeyDown(Keys.D6))
  517.                                         {
  518.                                             this.selectedItem = 5;
  519.                                         }
  520.                                         if (Main.keyState.IsKeyDown(Keys.D7))
  521.                                         {
  522.                                             this.selectedItem = 6;
  523.                                         }
  524.                                         if (Main.keyState.IsKeyDown(Keys.D8))
  525.                                         {
  526.                                             this.selectedItem = 7;
  527.                                         }
  528.                                         if (Main.keyState.IsKeyDown(Keys.D9))
  529.                                         {
  530.                                             this.selectedItem = 8;
  531.                                         }
  532.                                         if (Main.keyState.IsKeyDown(Keys.D0))
  533.                                         {
  534.                                             this.selectedItem = 9;
  535.                                         }
  536.                                     }
  537.                                     if (num10 != this.selectedItem)
  538.                                     {
  539.                                         Main.PlaySound(12, -1, -1, 1);
  540.                                     }
  541.                                     int k;
  542.                                     for (k = (Main.mouseState.ScrollWheelValue - Main.oldMouseState.ScrollWheelValue) / 120; k > 9; k -= 10)
  543.                                     {
  544.                                     }
  545.                                     while (k < 0)
  546.                                     {
  547.                                         k += 10;
  548.                                     }
  549.                                     this.selectedItem -= k;
  550.                                     if (k != 0)
  551.                                     {
  552.                                         Main.PlaySound(12, -1, -1, 1);
  553.                                     }
  554.                                     if (this.changeItem >= 0)
  555.                                     {
  556.                                         if (this.selectedItem != this.changeItem)
  557.                                         {
  558.                                             Main.PlaySound(12, -1, -1, 1);
  559.                                         }
  560.                                         this.selectedItem = this.changeItem;
  561.                                         this.changeItem = -1;
  562.                                     }
  563.                                     while (this.selectedItem > 9)
  564.                                     {
  565.                                         this.selectedItem -= 10;
  566.                                     }
  567.                                     while (this.selectedItem < 0)
  568.                                     {
  569.                                         this.selectedItem += 10;
  570.                                     }
  571.                                 }
  572.                                 else
  573.                                 {
  574.                                     int num11 = (Main.mouseState.ScrollWheelValue - Main.oldMouseState.ScrollWheelValue) / 120;
  575.                                     Main.focusRecipe += num11;
  576.                                     if (Main.focusRecipe > Main.numAvailableRecipes - 1)
  577.                                     {
  578.                                         Main.focusRecipe = Main.numAvailableRecipes - 1;
  579.                                     }
  580.                                     if (Main.focusRecipe < 0)
  581.                                     {
  582.                                         Main.focusRecipe = 0;
  583.                                     }
  584.                                 }
  585.                             }
  586.                         }
  587.                         if (Main.netMode == 1)
  588.                         {
  589.                             bool flag2 = false;
  590.                             if (this.statLife != Main.clientPlayer.statLife || this.statLifeMax != Main.clientPlayer.statLifeMax)
  591.                             {
  592.                                 NetMessage.SendData(16, -1, -1, "", Main.myPlayer, 0f, 0f, 0f);
  593.                                 flag2 = true;
  594.                             }
  595.                             if (this.statMana != Main.clientPlayer.statMana || this.statManaMax != Main.clientPlayer.statManaMax)
  596.                             {
  597.                                 NetMessage.SendData(42, -1, -1, "", Main.myPlayer, 0f, 0f, 0f);
  598.                                 flag2 = true;
  599.                             }
  600.                             if (this.controlUp != Main.clientPlayer.controlUp)
  601.                             {
  602.                                 flag2 = true;
  603.                             }
  604.                             if (this.controlDown != Main.clientPlayer.controlDown)
  605.                             {
  606.                                 flag2 = true;
  607.                             }
  608.                             if (this.controlLeft != Main.clientPlayer.controlLeft)
  609.                             {
  610.                                 flag2 = true;
  611.                             }
  612.                             if (this.controlRight != Main.clientPlayer.controlRight)
  613.                             {
  614.                                 flag2 = true;
  615.                             }
  616.                             if (this.controlJump != Main.clientPlayer.controlJump)
  617.                             {
  618.                                 flag2 = true;
  619.                             }
  620.                             if (this.controlUseItem != Main.clientPlayer.controlUseItem)
  621.                             {
  622.                                 flag2 = true;
  623.                             }
  624.                             if (this.selectedItem != Main.clientPlayer.selectedItem)
  625.                             {
  626.                                 flag2 = true;
  627.                             }
  628.                             if (flag2)
  629.                             {
  630.                                 NetMessage.SendData(13, -1, -1, "", Main.myPlayer, 0f, 0f, 0f);
  631.                             }
  632.                         }
  633.                         if (Main.playerInventory)
  634.                         {
  635.                             this.AdjTiles();
  636.                         }
  637.                         if (this.chest != -1)
  638.                         {
  639.                             int num12 = (int)(((double)this.position.X + (double)this.width * 0.5) / 16.0);
  640.                             int num13 = (int)(((double)this.position.Y + (double)this.height * 0.5) / 16.0);
  641.                             if (num12 < this.chestX - 5 || num12 > this.chestX + 6 || num13 < this.chestY - 4 || num13 > this.chestY + 5)
  642.                             {
  643.                                 if (this.chest != -1)
  644.                                 {
  645.                                     Main.PlaySound(11, -1, -1, 1);
  646.                                 }
  647.                                 this.chest = -1;
  648.                             }
  649.                             if (!Main.tile[this.chestX, this.chestY].active)
  650.                             {
  651.                                 Main.PlaySound(11, -1, -1, 1);
  652.                                 this.chest = -1;
  653.                             }
  654.                         }
  655.                         if (this.velocity.Y == 0f)
  656.                         {
  657.                             int num14 = (int)(this.position.Y / 16f) - this.fallStart;
  658.                             if (num14 > 25 && !this.noFallDmg)
  659.                             {
  660.                                 int damage = (num14 - 25) * 10;
  661.                                 this.immune = false;
  662.                                 this.Hurt(damage, -this.direction, false, false);
  663.                             }
  664.                             this.fallStart = (int)(this.position.Y / 16f);
  665.                         }
  666.                         if (this.rocketDelay > 0 || this.wet)
  667.                         {
  668.                             this.fallStart = (int)(this.position.Y / 16f);
  669.                         }
  670.                     }
  671.                     if (this.mouseInterface)
  672.                     {
  673.                         this.delayUseItem = true;
  674.                     }
  675.                     Player.tileTargetX = (int)(((float)Main.mouseState.X + Main.screenPosition.X) / 16f);
  676.                     Player.tileTargetY = (int)(((float)Main.mouseState.Y + Main.screenPosition.Y) / 16f);
  677.                     if (this.immune)
  678.                     {
  679.                         this.immuneTime--;
  680.                         if (this.immuneTime <= 0)
  681.                         {
  682.                             this.immune = false;
  683.                         }
  684.                         this.immuneAlpha += this.immuneAlphaDirection * 50;
  685.                         if (this.immuneAlpha <= 50)
  686.                         {
  687.                             this.immuneAlphaDirection = 1;
  688.                         }
  689.                         else
  690.                         {
  691.                             if (this.immuneAlpha >= 205)
  692.                             {
  693.                                 this.immuneAlphaDirection = -1;
  694.                             }
  695.                         }
  696.                     }
  697.                     else
  698.                     {
  699.                         this.immuneAlpha = 0;
  700.                     }
  701.                     if (this.manaRegenDelay > 0)
  702.                     {
  703.                         this.manaRegenDelay--;
  704.                     }
  705.                     this.statDefense = 0;
  706.                     this.accWatch = 0;
  707.                     this.accDepthMeter = 0;
  708.                     this.lifeRegen = 0;
  709.                     this.manaCost = 1f;
  710.                     this.meleeSpeed = 1f;
  711.                     this.boneArmor = false;
  712.                     this.rocketBoots = false;
  713.                     this.fireWalk = false;
  714.                     this.noKnockback = false;
  715.                     this.jumpBoost = false;
  716.                     this.noFallDmg = false;
  717.                     this.accFlipper = false;
  718.                     this.spawnMax = false;
  719.                     if (this.manaRegenDelay == 0)
  720.                     {
  721.                         this.manaRegen = this.statManaMax / 30 + 1;
  722.                     }
  723.                     else
  724.                     {
  725.                         this.manaRegen = 0;
  726.                     }
  727.                     this.doubleJump = false;
  728.                     for (int l = 0; l < 8; l++)
  729.                     {
  730.                         this.statDefense += this.armor[l].defense;
  731.                         this.lifeRegen += this.armor[l].lifeRegen;
  732.                         this.manaRegen += this.armor[l].manaRegen;
  733.                         if (this.armor[l].type == 193)
  734.                         {
  735.                             this.fireWalk = true;
  736.                         }
  737.                     }
  738.                     this.head = this.armor[0].headSlot;
  739.                     this.body = this.armor[1].bodySlot;
  740.                     this.legs = this.armor[2].legSlot;
  741.                     for (int m = 3; m < 8; m++)
  742.                     {
  743.                         if (this.armor[m].type == 15 && this.accWatch < 1)
  744.                         {
  745.                             this.accWatch = 1;
  746.                         }
  747.                         if (this.armor[m].type == 16 && this.accWatch < 2)
  748.                         {
  749.                             this.accWatch = 2;
  750.                         }
  751.                         if (this.armor[m].type == 17 && this.accWatch < 3)
  752.                         {
  753.                             this.accWatch = 3;
  754.                         }
  755.                         if (this.armor[m].type == 18 && this.accDepthMeter < 1)
  756.                         {
  757.                             this.accDepthMeter = 1;
  758.                         }
  759.                         if (this.armor[m].type == 53)
  760.                         {
  761.                             this.doubleJump = true;
  762.                         }
  763.                         if (this.armor[m].type == 54)
  764.                         {
  765.                             num6 = 6f;
  766.                         }
  767.                         if (this.armor[m].type == 128)
  768.                         {
  769.                             this.rocketBoots = true;
  770.                         }
  771.                         if (this.armor[m].type == 156)
  772.                         {
  773.                             this.noKnockback = true;
  774.                         }
  775.                         if (this.armor[m].type == 158)
  776.                         {
  777.                             this.noFallDmg = true;
  778.                         }
  779.                         if (this.armor[m].type == 159)
  780.                         {
  781.                             this.jumpBoost = true;
  782.                         }
  783.                         if (this.armor[m].type == 187)
  784.                         {
  785.                             this.accFlipper = true;
  786.                         }
  787.                         if (this.armor[m].type == 211)
  788.                         {
  789.                             this.meleeSpeed *= 0.9f;
  790.                         }
  791.                         if (this.armor[m].type == 223)
  792.                         {
  793.                             this.spawnMax = true;
  794.                         }
  795.                         if (this.armor[m].type == 212)
  796.                         {
  797.                             num4 *= 1.1f;
  798.                             num3 *= 1.1f;
  799.                         }
  800.                     }
  801.                     this.lifeRegenCount += this.lifeRegen;
  802.                     while (this.lifeRegenCount >= 120)
  803.                     {
  804.                         this.lifeRegenCount -= 120;
  805.                         if (this.statLife < this.statLifeMax)
  806.                         {
  807.                             this.statLife++;
  808.                         }
  809.                         if (this.statLife > this.statLifeMax)
  810.                         {
  811.                             this.statLife = this.statLifeMax;
  812.                         }
  813.                     }
  814.                     this.manaRegenCount += this.manaRegen;
  815.                     while (this.manaRegenCount >= 120)
  816.                     {
  817.                         this.manaRegenCount -= 120;
  818.                         if (this.statMana < this.statManaMax)
  819.                         {
  820.                             this.statMana++;
  821.                         }
  822.                         if (this.statMana > this.statManaMax)
  823.                         {
  824.                             this.statMana = this.statManaMax;
  825.                         }
  826.                     }
  827.                     if (this.head == 11)
  828.                     {
  829.                         int i2 = (int)(this.position.X + (float)(this.width / 2) + (float)(8 * this.direction)) / 16;
  830.                         int j2 = (int)(this.position.Y + 2f) / 16;
  831.                         Lighting.addLight(i2, j2, 0.8f);
  832.                     }
  833.                     if (this.jumpBoost)
  834.                     {
  835.                         Player.jumpHeight = 20;
  836.                         Player.jumpSpeed = 6.51f;
  837.                     }
  838.                     this.setBonus = "";
  839.                     if ((this.head == 1 && this.body == 1 && this.legs == 1) || (this.head == 2 && this.body == 2 && this.legs == 2))
  840.                     {
  841.                         this.setBonus = "2 defense";
  842.                         this.statDefense++;
  843.                     }
  844.                     if ((this.head == 3 && this.body == 3 && this.legs == 3) || (this.head == 4 && this.body == 4 && this.legs == 4))
  845.                     {
  846.                         this.setBonus = "3 defense";
  847.                         this.statDefense += 2;
  848.                     }
  849.                     if (this.head == 5 && this.body == 5 && this.legs == 5)
  850.                     {
  851.                         this.setBonus = "15 % increased melee speed";
  852.                         this.meleeSpeed *= 0.85f;
  853.                         if (Main.rand.Next(10) == 0)
  854.                         {
  855.                             Vector2 arg_1429_0 = new Vector2(this.position.X, this.position.Y);
  856.                             int arg_1429_1 = this.width;
  857.                             int arg_1429_2 = this.height;
  858.                             int arg_1429_3 = 14;
  859.                             float arg_1429_4 = 0f;
  860.                             float arg_1429_5 = 0f;
  861.                             int arg_1429_6 = 200;
  862.                             Color newColor = default(Color);
  863.                             Dust.NewDust(arg_1429_0, arg_1429_1, arg_1429_2, arg_1429_3, arg_1429_4, arg_1429_5, arg_1429_6, newColor, 1.2f);
  864.                         }
  865.                     }
  866.                     if (this.head == 6 && this.body == 6 && this.legs == 6)
  867.                     {
  868.                         this.setBonus = "20% reduced mana usage";
  869.                         this.manaCost *= 0.8f;
  870.                         if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) > 1f && !this.rocketFrame)
  871.                         {
  872.                             for (int n = 0; n < 2; n++)
  873.                             {
  874.                                 Vector2 arg_151B_0 = new Vector2(this.position.X - this.velocity.X * 2f, this.position.Y - 2f - this.velocity.Y * 2f);
  875.                                 int arg_151B_1 = this.width;
  876.                                 int arg_151B_2 = this.height;
  877.                                 int arg_151B_3 = 6;
  878.                                 float arg_151B_4 = 0f;
  879.                                 float arg_151B_5 = 0f;
  880.                                 int arg_151B_6 = 100;
  881.                                 Color newColor = default(Color);
  882.                                 int num15 = Dust.NewDust(arg_151B_0, arg_151B_1, arg_151B_2, arg_151B_3, arg_151B_4, arg_151B_5, arg_151B_6, newColor, 2f);
  883.                                 Main.dust[num15].noGravity = true;
  884.                                 Dust expr_153D_cp_0 = Main.dust[num15];
  885.                                 expr_153D_cp_0.velocity.X = expr_153D_cp_0.velocity.X - this.velocity.X * 0.5f;
  886.                                 Dust expr_1567_cp_0 = Main.dust[num15];
  887.                                 expr_1567_cp_0.velocity.Y = expr_1567_cp_0.velocity.Y - this.velocity.Y * 0.5f;
  888.                             }
  889.                         }
  890.                     }
  891.                     if (this.head == 7 && this.body == 7 && this.legs == 7)
  892.                     {
  893.                         num4 *= 1.3f;
  894.                         num3 *= 1.3f;
  895.                         this.setBonus = "30% increased movement speed";
  896.                         this.boneArmor = true;
  897.                     }
  898.                     if (this.head == 8 && this.body == 8 && this.legs == 8)
  899.                     {
  900.                         this.setBonus = "25% reduced mana usage";
  901.                         this.manaCost *= 0.75f;
  902.                         this.meleeSpeed *= 0.9f;
  903.                         if (Main.rand.Next(10) == 0)
  904.                         {
  905.                             Vector2 arg_1677_0 = new Vector2(this.position.X, this.position.Y);
  906.                             int arg_1677_1 = this.width;
  907.                             int arg_1677_2 = this.height;
  908.                             int arg_1677_3 = 14;
  909.                             float arg_1677_4 = 0f;
  910.                             float arg_1677_5 = 0f;
  911.                             int arg_1677_6 = 200;
  912.                             Color newColor = default(Color);
  913.                             Dust.NewDust(arg_1677_0, arg_1677_1, arg_1677_2, arg_1677_3, arg_1677_4, arg_1677_5, arg_1677_6, newColor, 1.2f);
  914.                         }
  915.                     }
  916.                     if (this.head == 9 && this.body == 9 && this.legs == 9)
  917.                     {
  918.                         this.setBonus = "10 defense";
  919.                         if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) > 1f && !this.rocketFrame)
  920.                         {
  921.                             for (int num16 = 0; num16 < 2; num16++)
  922.                             {
  923.                                 Vector2 arg_175A_0 = new Vector2(this.position.X - this.velocity.X * 2f, this.position.Y - 2f - this.velocity.Y * 2f);
  924.                                 int arg_175A_1 = this.width;
  925.                                 int arg_175A_2 = this.height;
  926.                                 int arg_175A_3 = 6;
  927.                                 float arg_175A_4 = 0f;
  928.                                 float arg_175A_5 = 0f;
  929.                                 int arg_175A_6 = 100;
  930.                                 Color newColor = default(Color);
  931.                                 int num17 = Dust.NewDust(arg_175A_0, arg_175A_1, arg_175A_2, arg_175A_3, arg_175A_4, arg_175A_5, arg_175A_6, newColor, 2f);
  932.                                 Main.dust[num17].noGravity = true;
  933.                                 Dust expr_177C_cp_0 = Main.dust[num17];
  934.                                 expr_177C_cp_0.velocity.X = expr_177C_cp_0.velocity.X - this.velocity.X * 0.5f;
  935.                                 Dust expr_17A6_cp_0 = Main.dust[num17];
  936.                                 expr_17A6_cp_0.velocity.Y = expr_17A6_cp_0.velocity.Y - this.velocity.Y * 0.5f;
  937.                             }
  938.                         }
  939.                     }
  940.                     if (!this.doubleJump)
  941.                     {
  942.                         this.jumpAgain = false;
  943.                     }
  944.                     else
  945.                     {
  946.                         if (this.velocity.Y == 0f)
  947.                         {
  948.                             this.jumpAgain = true;
  949.                         }
  950.                     }
  951.                     if ((double)this.meleeSpeed < 0.7)
  952.                     {
  953.                         this.meleeSpeed = 0.7f;
  954.                     }
  955.                     if (this.grappling[0] == -1)
  956.                     {
  957.                         if (this.controlLeft && this.velocity.X > -num3)
  958.                         {
  959.                             if (this.velocity.X > num5)
  960.                             {
  961.                                 this.velocity.X = this.velocity.X - num5;
  962.                             }
  963.                             this.velocity.X = this.velocity.X - num4;
  964.                             if (this.itemAnimation == 0 || this.inventory[this.selectedItem].useTurn)
  965.                             {
  966.                                 this.direction = -1;
  967.                             }
  968.                         }
  969.                         else
  970.                         {
  971.                             if (this.controlRight && this.velocity.X < num3)
  972.                             {
  973.                                 if (this.velocity.X < -num5)
  974.                                 {
  975.                                     this.velocity.X = this.velocity.X + num5;
  976.                                 }
  977.                                 this.velocity.X = this.velocity.X + num4;
  978.                                 if (this.itemAnimation == 0 || this.inventory[this.selectedItem].useTurn)
  979.                                 {
  980.                                     this.direction = 1;
  981.                                 }
  982.                             }
  983.                             else
  984.                             {
  985.                                 if (this.controlLeft && this.velocity.X > -num6)
  986.                                 {
  987.                                     if (this.itemAnimation == 0 || this.inventory[this.selectedItem].useTurn)
  988.                                     {
  989.                                         this.direction = -1;
  990.                                     }
  991.                                     if (this.velocity.Y == 0f)
  992.                                     {
  993.                                         if (this.velocity.X > num5)
  994.                                         {
  995.                                             this.velocity.X = this.velocity.X - num5;
  996.                                         }
  997.                                         this.velocity.X = this.velocity.X - num4 * 0.2f;
  998.                                     }
  999.                                     if (this.velocity.X < -(num6 + num3) / 2f && this.velocity.Y == 0f)
  1000.                                     {
  1001.                                         if (this.runSoundDelay == 0 && this.velocity.Y == 0f)
  1002.                                         {
  1003.                                             Main.PlaySound(17, (int)this.position.X, (int)this.position.Y, 1);
  1004.                                             this.runSoundDelay = 9;
  1005.                                         }
  1006.                                         Vector2 arg_1A7F_0 = new Vector2(this.position.X - 4f, this.position.Y + (float)this.height);
  1007.                                         int arg_1A7F_1 = this.width + 8;
  1008.                                         int arg_1A7F_2 = 4;
  1009.                                         int arg_1A7F_3 = 16;
  1010.                                         float arg_1A7F_4 = -this.velocity.X * 0.5f;
  1011.                                         float arg_1A7F_5 = this.velocity.Y * 0.5f;
  1012.                                         int arg_1A7F_6 = 50;
  1013.                                         Color newColor = default(Color);
  1014.                                         int num18 = Dust.NewDust(arg_1A7F_0, arg_1A7F_1, arg_1A7F_2, arg_1A7F_3, arg_1A7F_4, arg_1A7F_5, arg_1A7F_6, newColor, 1.5f);
  1015.                                         Main.dust[num18].velocity.X = Main.dust[num18].velocity.X * 0.2f;
  1016.                                         Main.dust[num18].velocity.Y = Main.dust[num18].velocity.Y * 0.2f;
  1017.                                     }
  1018.                                 }
  1019.                                 else
  1020.                                 {
  1021.                                     if (this.controlRight && this.velocity.X < num6)
  1022.                                     {
  1023.                                         if (this.itemAnimation == 0 || this.inventory[this.selectedItem].useTurn)
  1024.                                         {
  1025.                                             this.direction = 1;
  1026.                                         }
  1027.                                         if (this.velocity.Y == 0f)
  1028.                                         {
  1029.                                             if (this.velocity.X < -num5)
  1030.                                             {
  1031.                                                 this.velocity.X = this.velocity.X + num5;
  1032.                                             }
  1033.                                             this.velocity.X = this.velocity.X + num4 * 0.2f;
  1034.                                         }
  1035.                                         if (this.velocity.X > (num6 + num3) / 2f && this.velocity.Y == 0f)
  1036.                                         {
  1037.                                             if (this.runSoundDelay == 0 && this.velocity.Y == 0f)
  1038.                                             {
  1039.                                                 Main.PlaySound(17, (int)this.position.X, (int)this.position.Y, 1);
  1040.                                                 this.runSoundDelay = 9;
  1041.                                             }
  1042.                                             Vector2 arg_1C47_0 = new Vector2(this.position.X - 4f, this.position.Y + (float)this.height);
  1043.                                             int arg_1C47_1 = this.width + 8;
  1044.                                             int arg_1C47_2 = 4;
  1045.                                             int arg_1C47_3 = 16;
  1046.                                             float arg_1C47_4 = -this.velocity.X * 0.5f;
  1047.                                             float arg_1C47_5 = this.velocity.Y * 0.5f;
  1048.                                             int arg_1C47_6 = 50;
  1049.                                             Color newColor = default(Color);
  1050.                                             int num19 = Dust.NewDust(arg_1C47_0, arg_1C47_1, arg_1C47_2, arg_1C47_3, arg_1C47_4, arg_1C47_5, arg_1C47_6, newColor, 1.5f);
  1051.                                             Main.dust[num19].velocity.X = Main.dust[num19].velocity.X * 0.2f;
  1052.                                             Main.dust[num19].velocity.Y = Main.dust[num19].velocity.Y * 0.2f;
  1053.                                         }
  1054.                                     }
  1055.                                     else
  1056.                                     {
  1057.                                         if (this.velocity.Y == 0f)
  1058.                                         {
  1059.                                             if (this.velocity.X > num5)
  1060.                                             {
  1061.                                                 this.velocity.X = this.velocity.X - num5;
  1062.                                             }
  1063.                                             else
  1064.                                             {
  1065.                                                 if (this.velocity.X < -num5)
  1066.                                                 {
  1067.                                                     this.velocity.X = this.velocity.X + num5;
  1068.                                                 }
  1069.                                                 else
  1070.                                                 {
  1071.                                                     this.velocity.X = 0f;
  1072.                                                 }
  1073.                                             }
  1074.                                         }
  1075.                                         else
  1076.                                         {
  1077.                                             if ((double)this.velocity.X > (double)num5 * 0.5)
  1078.                                             {
  1079.                                                 this.velocity.X = this.velocity.X - num5 * 0.5f;
  1080.                                             }
  1081.                                             else
  1082.                                             {
  1083.                                                 if ((double)this.velocity.X < (double)(-(double)num5) * 0.5)
  1084.                                                 {
  1085.                                                     this.velocity.X = this.velocity.X + num5 * 0.5f;
  1086.                                                 }
  1087.                                                 else
  1088.                                                 {
  1089.                                                     this.velocity.X = 0f;
  1090.                                                 }
  1091.                                             }
  1092.                                         }
  1093.                                     }
  1094.                                 }
  1095.                             }
  1096.                         }
  1097.                         if (this.controlJump)
  1098.                         {
  1099.                             if (this.jump > 0)
  1100.                             {
  1101.                                 if (this.velocity.Y > -Player.jumpSpeed + num2 * 2f)
  1102.                                 {
  1103.                                     this.jump = 0;
  1104.                                 }
  1105.                                 else
  1106.                                 {
  1107.                                     this.velocity.Y = -Player.jumpSpeed;
  1108.                                     this.jump--;
  1109.                                 }
  1110.                             }
  1111.                             else
  1112.                             {
  1113.                                 if ((this.velocity.Y == 0f || this.jumpAgain || (this.wet && this.accFlipper)) && this.releaseJump)
  1114.                                 {
  1115.                                     bool flag3 = false;
  1116.                                     if (this.wet && this.accFlipper)
  1117.                                     {
  1118.                                         if (this.swimTime == 0)
  1119.                                         {
  1120.                                             this.swimTime = 30;
  1121.                                         }
  1122.                                         flag3 = true;
  1123.                                     }
  1124.                                     this.jumpAgain = false;
  1125.                                     this.canRocket = false;
  1126.                                     this.rocketRelease = false;
  1127.                                     if (this.velocity.Y == 0f && this.doubleJump)
  1128.                                     {
  1129.                                         this.jumpAgain = true;
  1130.                                     }
  1131.                                     if (this.velocity.Y == 0f || flag3)
  1132.                                     {
  1133.                                         this.velocity.Y = -Player.jumpSpeed;
  1134.                                         this.jump = Player.jumpHeight;
  1135.                                     }
  1136.                                     else
  1137.                                     {
  1138.                                         Main.PlaySound(16, (int)this.position.X, (int)this.position.Y, 1);
  1139.                                         this.velocity.Y = -Player.jumpSpeed;
  1140.                                         this.jump = Player.jumpHeight / 2;
  1141.                                         for (int num20 = 0; num20 < 10; num20++)
  1142.                                         {
  1143.                                             Vector2 arg_1F77_0 = new Vector2(this.position.X - 34f, this.position.Y + (float)this.height - 16f);
  1144.                                             int arg_1F77_1 = 102;
  1145.                                             int arg_1F77_2 = 32;
  1146.                                             int arg_1F77_3 = 16;
  1147.                                             float arg_1F77_4 = -this.velocity.X * 0.5f;
  1148.                                             float arg_1F77_5 = this.velocity.Y * 0.5f;
  1149.                                             int arg_1F77_6 = 100;
  1150.                                             Color newColor = default(Color);
  1151.                                             int num21 = Dust.NewDust(arg_1F77_0, arg_1F77_1, arg_1F77_2, arg_1F77_3, arg_1F77_4, arg_1F77_5, arg_1F77_6, newColor, 1.5f);
  1152.                                             Main.dust[num21].velocity.X = Main.dust[num21].velocity.X * 0.5f - this.velocity.X * 0.1f;
  1153.                                             Main.dust[num21].velocity.Y = Main.dust[num21].velocity.Y * 0.5f - this.velocity.Y * 0.3f;
  1154.                                         }
  1155.                                         int num22 = Gore.NewGore(new Vector2(this.position.X + (float)(this.width / 2) - 16f, this.position.Y + (float)this.height - 16f), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(11, 14));
  1156.                                         Main.gore[num22].velocity.X = Main.gore[num22].velocity.X * 0.1f - this.velocity.X * 0.1f;
  1157.                                         Main.gore[num22].velocity.Y = Main.gore[num22].velocity.Y * 0.1f - this.velocity.Y * 0.05f;
  1158.                                         num22 = Gore.NewGore(new Vector2(this.position.X - 36f, this.position.Y + (float)this.height - 16f), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(11, 14));
  1159.                                         Main.gore[num22].velocity.X = Main.gore[num22].velocity.X * 0.1f - this.velocity.X * 0.1f;
  1160.                                         Main.gore[num22].velocity.Y = Main.gore[num22].velocity.Y * 0.1f - this.velocity.Y * 0.05f;
  1161.                                         num22 = Gore.NewGore(new Vector2(this.position.X + (float)this.width + 4f, this.position.Y + (float)this.height - 16f), new Vector2(-this.velocity.X, -this.velocity.Y), Main.rand.Next(11, 14));
  1162.                                         Main.gore[num22].velocity.X = Main.gore[num22].velocity.X * 0.1f - this.velocity.X * 0.1f;
  1163.                                         Main.gore[num22].velocity.Y = Main.gore[num22].velocity.Y * 0.1f - this.velocity.Y * 0.05f;
  1164.                                     }
  1165.                                 }
  1166.                             }
  1167.                             this.releaseJump = false;
  1168.                         }
  1169.                         else
  1170.                         {
  1171.                             this.jump = 0;
  1172.                             this.releaseJump = true;
  1173.                             this.rocketRelease = true;
  1174.                         }
  1175.                         if (this.doubleJump && !this.jumpAgain && this.velocity.Y < 0f && !this.rocketBoots && !this.accFlipper)
  1176.                         {
  1177.                             Vector2 arg_2369_0 = new Vector2(this.position.X - 4f, this.position.Y + (float)this.height);
  1178.                             int arg_2369_1 = this.width + 8;
  1179.                             int arg_2369_2 = 4;
  1180.                             int arg_2369_3 = 16;
  1181.                             float arg_2369_4 = -this.velocity.X * 0.5f;
  1182.                             float arg_2369_5 = this.velocity.Y * 0.5f;
  1183.                             int arg_2369_6 = 100;
  1184.                             Color newColor = default(Color);
  1185.                             int num23 = Dust.NewDust(arg_2369_0, arg_2369_1, arg_2369_2, arg_2369_3, arg_2369_4, arg_2369_5, arg_2369_6, newColor, 1.5f);
  1186.                             Main.dust[num23].velocity.X = Main.dust[num23].velocity.X * 0.5f - this.velocity.X * 0.1f;
  1187.                             Main.dust[num23].velocity.Y = Main.dust[num23].velocity.Y * 0.5f - this.velocity.Y * 0.3f;
  1188.                         }
  1189.                         if (this.velocity.Y > -Player.jumpSpeed && this.velocity.Y != 0f)
  1190.                         {
  1191.                             this.canRocket = true;
  1192.                         }
  1193.                         if (this.rocketBoots && this.controlJump && this.rocketDelay == 0 && this.canRocket && this.rocketRelease && !this.jumpAgain)
  1194.                         {
  1195.                             int num24 = 7;
  1196.                             if (this.statMana >= (int)((float)num24 * this.manaCost))
  1197.                             {
  1198.                                 this.manaRegenDelay = 180;
  1199.                                 this.statMana -= (int)((float)num24 * this.manaCost);
  1200.                                 this.rocketDelay = 10;
  1201.                                 if (this.rocketDelay2 <= 0)
  1202.                                 {
  1203.                                     Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 13);
  1204.                                     this.rocketDelay2 = 30;
  1205.                                 }
  1206.                             }
  1207.                             else
  1208.                             {
  1209.                                 this.canRocket = false;
  1210.                             }
  1211.                         }
  1212.                         if (this.rocketDelay2 > 0)
  1213.                         {
  1214.                             this.rocketDelay2--;
  1215.                         }
  1216.                         if (this.rocketDelay == 0)
  1217.                         {
  1218.                             this.rocketFrame = false;
  1219.                         }
  1220.                         if (this.rocketDelay > 0)
  1221.                         {
  1222.                             this.rocketFrame = true;
  1223.                             for (int num25 = 0; num25 < 2; num25++)
  1224.                             {
  1225.                                 if (num25 == 0)
  1226.                                 {
  1227.                                     Vector2 arg_2563_0 = new Vector2(this.position.X - 4f, this.position.Y + (float)this.height - 10f);
  1228.                                     int arg_2563_1 = 8;
  1229.                                     int arg_2563_2 = 8;
  1230.                                     int arg_2563_3 = 6;
  1231.                                     float arg_2563_4 = 0f;
  1232.                                     float arg_2563_5 = 0f;
  1233.                                     int arg_2563_6 = 100;
  1234.                                     Color newColor = default(Color);
  1235.                                     int num26 = Dust.NewDust(arg_2563_0, arg_2563_1, arg_2563_2, arg_2563_3, arg_2563_4, arg_2563_5, arg_2563_6, newColor, 2.5f);
  1236.                                     Main.dust[num26].noGravity = true;
  1237.                                     Main.dust[num26].velocity.X = Main.dust[num26].velocity.X * 1f - 2f - this.velocity.X * 0.3f;
  1238.                                     Main.dust[num26].velocity.Y = Main.dust[num26].velocity.Y * 1f + 2f - this.velocity.Y * 0.3f;
  1239.                                 }
  1240.                                 else
  1241.                                 {
  1242.                                     Vector2 arg_2656_0 = new Vector2(this.position.X + (float)this.width - 4f, this.position.Y + (float)this.height - 10f);
  1243.                                     int arg_2656_1 = 8;
  1244.                                     int arg_2656_2 = 8;
  1245.                                     int arg_2656_3 = 6;
  1246.                                     float arg_2656_4 = 0f;
  1247.                                     float arg_2656_5 = 0f;
  1248.                                     int arg_2656_6 = 100;
  1249.                                     Color newColor = default(Color);
  1250.                                     int num27 = Dust.NewDust(arg_2656_0, arg_2656_1, arg_2656_2, arg_2656_3, arg_2656_4, arg_2656_5, arg_2656_6, newColor, 2.5f);
  1251.                                     Main.dust[num27].noGravity = true;
  1252.                                     Main.dust[num27].velocity.X = Main.dust[num27].velocity.X * 1f + 2f - this.velocity.X * 0.3f;
  1253.                                     Main.dust[num27].velocity.Y = Main.dust[num27].velocity.Y * 1f + 2f - this.velocity.Y * 0.3f;
  1254.                                 }
  1255.                             }
  1256.                             if (this.rocketDelay == 0)
  1257.                             {
  1258.                                 this.releaseJump = true;
  1259.                             }
  1260.                             this.rocketDelay--;
  1261.                             this.velocity.Y = this.velocity.Y - 0.1f;
  1262.                             if (this.velocity.Y > 0f)
  1263.                             {
  1264.                                 this.velocity.Y = this.velocity.Y - 0.3f;
  1265.                             }
  1266.                             if (this.velocity.Y < -Player.jumpSpeed)
  1267.                             {
  1268.                                 this.velocity.Y = -Player.jumpSpeed;
  1269.                             }
  1270.                         }
  1271.                         else
  1272.                         {
  1273.                             this.velocity.Y = this.velocity.Y + num2;
  1274.                         }
  1275.                         if (this.velocity.Y > num)
  1276.                         {
  1277.                             this.velocity.Y = num;
  1278.                         }
  1279.                     }
  1280.                     for (int num28 = 0; num28 < 200; num28++)
  1281.                     {
  1282.                         if (Main.item[num28].active && Main.item[num28].noGrabDelay == 0 && Main.item[num28].owner == i)
  1283.                         {
  1284.                             Rectangle rectangle = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
  1285.                             if (rectangle.Intersects(new Rectangle((int)Main.item[num28].position.X, (int)Main.item[num28].position.Y, Main.item[num28].width, Main.item[num28].height)))
  1286.                             {
  1287.                                 if (i == Main.myPlayer && (this.inventory[this.selectedItem].type != 0 || this.itemAnimation <= 0))
  1288.                                 {
  1289.                                     if (Main.item[num28].type == 58)
  1290.                                     {
  1291.                                         Main.PlaySound(7, (int)this.position.X, (int)this.position.Y, 1);
  1292.                                         this.statLife += 20;
  1293.                                         if (Main.myPlayer == this.whoAmi)
  1294.                                         {
  1295.                                             this.HealEffect(20);
  1296.                                         }
  1297.                                         if (this.statLife > this.statLifeMax)
  1298.                                         {
  1299.                                             this.statLife = this.statLifeMax;
  1300.                                         }
  1301.                                         Main.item[num28] = new Item();
  1302.                                         if (Main.netMode == 1)
  1303.                                         {
  1304.                                             NetMessage.SendData(21, -1, -1, "", num28, 0f, 0f, 0f);
  1305.                                         }
  1306.                                     }
  1307.                                     else
  1308.                                     {
  1309.                                         if (Main.item[num28].type == 184)
  1310.                                         {
  1311.                                             Main.PlaySound(7, (int)this.position.X, (int)this.position.Y, 1);
  1312.                                             this.statMana += 20;
  1313.                                             if (Main.myPlayer == this.whoAmi)
  1314.                                             {
  1315.                                                 this.ManaEffect(20);
  1316.                                             }
  1317.                                             if (this.statMana > this.statManaMax)
  1318.                                             {
  1319.                                                 this.statMana = this.statManaMax;
  1320.                                             }
  1321.                                             Main.item[num28] = new Item();
  1322.                                             if (Main.netMode == 1)
  1323.                                             {
  1324.                                                 NetMessage.SendData(21, -1, -1, "", num28, 0f, 0f, 0f);
  1325.                                             }
  1326.                                         }
  1327.                                         else
  1328.                                         {
  1329.                                             Main.item[num28] = this.GetItem(i, Main.item[num28]);
  1330.                                             if (Main.netMode == 1)
  1331.                                             {
  1332.                                                 NetMessage.SendData(21, -1, -1, "", num28, 0f, 0f, 0f);
  1333.                                             }
  1334.                                         }
  1335.                                     }
  1336.                                 }
  1337.                             }
  1338.                             else
  1339.                             {
  1340.                                 rectangle = new Rectangle((int)this.position.X - Player.itemGrabRange, (int)this.position.Y - Player.itemGrabRange, this.width + Player.itemGrabRange * 2, this.height + Player.itemGrabRange * 2);
  1341.                                 if (rectangle.Intersects(new Rectangle((int)Main.item[num28].position.X, (int)Main.item[num28].position.Y, Main.item[num28].width, Main.item[num28].height)) && this.ItemSpace(Main.item[num28]))
  1342.                                 {
  1343.                                     Main.item[num28].beingGrabbed = true;
  1344.                                     if ((double)this.position.X + (double)this.width * 0.5 > (double)Main.item[num28].position.X + (double)Main.item[num28].width * 0.5)
  1345.                                     {
  1346.                                         if (Main.item[num28].velocity.X < Player.itemGrabSpeedMax + this.velocity.X)
  1347.                                         {
  1348.                                             Item expr_2B70_cp_0 = Main.item[num28];
  1349.                                             expr_2B70_cp_0.velocity.X = expr_2B70_cp_0.velocity.X + Player.itemGrabSpeed;
  1350.                                         }
  1351.                                         if (Main.item[num28].velocity.X < 0f)
  1352.                                         {
  1353.                                             Item expr_2BAA_cp_0 = Main.item[num28];
  1354.                                             expr_2BAA_cp_0.velocity.X = expr_2BAA_cp_0.velocity.X + Player.itemGrabSpeed * 0.75f;
  1355.                                         }
  1356.                                     }
  1357.                                     else
  1358.                                     {
  1359.                                         if (Main.item[num28].velocity.X > -Player.itemGrabSpeedMax + this.velocity.X)
  1360.                                         {
  1361.                                             Item expr_2BF9_cp_0 = Main.item[num28];
  1362.                                             expr_2BF9_cp_0.velocity.X = expr_2BF9_cp_0.velocity.X - Player.itemGrabSpeed;
  1363.                                         }
  1364.                                         if (Main.item[num28].velocity.X > 0f)
  1365.                                         {
  1366.                                             Item expr_2C30_cp_0 = Main.item[num28];
  1367.                                             expr_2C30_cp_0.velocity.X = expr_2C30_cp_0.velocity.X - Player.itemGrabSpeed * 0.75f;
  1368.                                         }
  1369.                                     }
  1370.                                     if ((double)this.position.Y + (double)this.height * 0.5 > (double)Main.item[num28].position.Y + (double)Main.item[num28].height * 0.5)
  1371.                                     {
  1372.                                         if (Main.item[num28].velocity.Y < Player.itemGrabSpeedMax)
  1373.                                         {
  1374.                                             Item expr_2CB9_cp_0 = Main.item[num28];
  1375.                                             expr_2CB9_cp_0.velocity.Y = expr_2CB9_cp_0.velocity.Y + Player.itemGrabSpeed;
  1376.                                         }
  1377.                                         if (Main.item[num28].velocity.Y < 0f)
  1378.                                         {
  1379.                                             Item expr_2CF3_cp_0 = Main.item[num28];
  1380.                                             expr_2CF3_cp_0.velocity.Y = expr_2CF3_cp_0.velocity.Y + Player.itemGrabSpeed * 0.75f;
  1381.                                         }
  1382.                                     }
  1383.                                     else
  1384.                                     {
  1385.                                         if (Main.item[num28].velocity.Y > -Player.itemGrabSpeedMax)
  1386.                                         {
  1387.                                             Item expr_2D33_cp_0 = Main.item[num28];
  1388.                                             expr_2D33_cp_0.velocity.Y = expr_2D33_cp_0.velocity.Y - Player.itemGrabSpeed;
  1389.                                         }
  1390.                                         if (Main.item[num28].velocity.Y > 0f)
  1391.                                         {
  1392.                                             Item expr_2D6A_cp_0 = Main.item[num28];
  1393.                                             expr_2D6A_cp_0.velocity.Y = expr_2D6A_cp_0.velocity.Y - Player.itemGrabSpeed * 0.75f;
  1394.                                         }
  1395.                                     }
  1396.                                 }
  1397.                             }
  1398.                         }
  1399.                     }
  1400.                     if (this.position.X / 16f - (float)Player.tileRangeX <= (float)Player.tileTargetX && (this.position.X + (float)this.width) / 16f + (float)Player.tileRangeX - 1f >= (float)Player.tileTargetX && this.position.Y / 16f - (float)Player.tileRangeY <= (float)Player.tileTargetY && (this.position.Y + (float)this.height) / 16f + (float)Player.tileRangeY - 2f >= (float)Player.tileTargetY && Main.tile[Player.tileTargetX, Player.tileTargetY].active)
  1401.                     {
  1402.                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 79)
  1403.                         {
  1404.                             this.showItemIcon = true;
  1405.                             this.showItemIcon2 = 224;
  1406.                         }
  1407.                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 21)
  1408.                         {
  1409.                             this.showItemIcon = true;
  1410.                             this.showItemIcon2 = 48;
  1411.                         }
  1412.                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 4)
  1413.                         {
  1414.                             this.showItemIcon = true;
  1415.                             this.showItemIcon2 = 8;
  1416.                         }
  1417.                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 13)
  1418.                         {
  1419.                             this.showItemIcon = true;
  1420.                             if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameX == 18)
  1421.                             {
  1422.                                 this.showItemIcon2 = 28;
  1423.                             }
  1424.                             else
  1425.                             {
  1426.                                 if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameX == 36)
  1427.                                 {
  1428.                                     this.showItemIcon2 = 110;
  1429.                                 }
  1430.                                 else
  1431.                                 {
  1432.                                     this.showItemIcon2 = 31;
  1433.                                 }
  1434.                             }
  1435.                         }
  1436.                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 29)
  1437.                         {
  1438.                             this.showItemIcon = true;
  1439.                             this.showItemIcon2 = 87;
  1440.                         }
  1441.                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 33)
  1442.                         {
  1443.                             this.showItemIcon = true;
  1444.                             this.showItemIcon2 = 105;
  1445.                         }
  1446.                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 49)
  1447.                         {
  1448.                             this.showItemIcon = true;
  1449.                             this.showItemIcon2 = 148;
  1450.                         }
  1451.                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 50 && Main.tile[Player.tileTargetX, Player.tileTargetY].frameX == 90)
  1452.                         {
  1453.                             this.showItemIcon = true;
  1454.                             this.showItemIcon2 = 165;
  1455.                         }
  1456.                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 55)
  1457.                         {
  1458.                             int num29 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18);
  1459.                             int num30 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 18);
  1460.                             while (num29 > 1)
  1461.                             {
  1462.                                 num29 -= 2;
  1463.                             }
  1464.                             int num31 = Player.tileTargetX - num29;
  1465.                             int num32 = Player.tileTargetY - num30;
  1466.                             Main.signBubble = true;
  1467.                             Main.signX = num31 * 16 + 16;
  1468.                             Main.signY = num32 * 16;
  1469.                         }
  1470.                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 10 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 11)
  1471.                         {
  1472.                             this.showItemIcon = true;
  1473.                             this.showItemIcon2 = 25;
  1474.                         }
  1475.                         if (this.controlUseTile)
  1476.                         {
  1477.                             if (this.releaseUseTile)
  1478.                             {
  1479.                                 if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 4 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 13 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 33 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 49 || (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 50 && Main.tile[Player.tileTargetX, Player.tileTargetY].frameX == 90))
  1480.                                 {
  1481.                                     WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY, false, false, false);
  1482.                                     if (Main.netMode == 1)
  1483.                                     {
  1484.                                         NetMessage.SendData(17, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f);
  1485.                                     }
  1486.                                 }
  1487.                                 else
  1488.                                 {
  1489.                                     if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 79)
  1490.                                     {
  1491.                                         int num33 = Player.tileTargetX;
  1492.                                         int num34 = Player.tileTargetY;
  1493.                                         num33 += (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18 * -1);
  1494.                                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameX >= 72)
  1495.                                         {
  1496.                                             num33 += 4;
  1497.                                             num33++;
  1498.                                         }
  1499.                                         else
  1500.                                         {
  1501.                                             num33 += 2;
  1502.                                         }
  1503.                                         num34 += (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 18 * -1);
  1504.                                         num34 += 2;
  1505.                                         if (Player.CheckSpawn(num33, num34))
  1506.                                         {
  1507.                                             this.ChangeSpawn(num33, num34);
  1508.                                             Main.NewText("Spawn point set!", 255, 240, 20);
  1509.                                         }
  1510.                                     }
  1511.                                     else
  1512.                                     {
  1513.                                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 55)
  1514.                                         {
  1515.                                             bool flag4 = true;
  1516.                                             if (this.sign >= 0)
  1517.                                             {
  1518.                                                 int num35 = Sign.ReadSign(Player.tileTargetX, Player.tileTargetY);
  1519.                                                 if (num35 == this.sign)
  1520.                                                 {
  1521.                                                     this.sign = -1;
  1522.                                                     Main.npcChatText = "";
  1523.                                                     Main.editSign = false;
  1524.                                                     Main.PlaySound(11, -1, -1, 1);
  1525.                                                     flag4 = false;
  1526.                                                 }
  1527.                                             }
  1528.                                             if (flag4)
  1529.                                             {
  1530.                                                 if (Main.netMode == 0)
  1531.                                                 {
  1532.                                                     this.talkNPC = -1;
  1533.                                                     Main.playerInventory = false;
  1534.                                                     Main.editSign = false;
  1535.                                                     Main.PlaySound(10, -1, -1, 1);
  1536.                                                     int num36 = Sign.ReadSign(Player.tileTargetX, Player.tileTargetY);
  1537.                                                     this.sign = num36;
  1538.                                                     Main.npcChatText = Main.sign[num36].text;
  1539.                                                 }
  1540.                                                 else
  1541.                                                 {
  1542.                                                     int num37 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18);
  1543.                                                     int num38 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 18);
  1544.                                                     while (num37 > 1)
  1545.                                                     {
  1546.                                                         num37 -= 2;
  1547.                                                     }
  1548.                                                     int num39 = Player.tileTargetX - num37;
  1549.                                                     int num40 = Player.tileTargetY - num38;
  1550.                                                     if (Main.tile[num39, num40].type == 55)
  1551.                                                     {
  1552.                                                         NetMessage.SendData(46, -1, -1, "", num39, (float)num40, 0f, 0f);
  1553.                                                     }
  1554.                                                 }
  1555.                                             }
  1556.                                         }
  1557.                                         else
  1558.                                         {
  1559.                                             if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 10)
  1560.                                             {
  1561.                                                 WorldGen.OpenDoor(Player.tileTargetX, Player.tileTargetY, this.direction);
  1562.                                                 NetMessage.SendData(19, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, (float)this.direction);
  1563.                                             }
  1564.                                             else
  1565.                                             {
  1566.                                                 if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 11)
  1567.                                                 {
  1568.                                                     if (WorldGen.CloseDoor(Player.tileTargetX, Player.tileTargetY, false))
  1569.                                                     {
  1570.                                                         NetMessage.SendData(19, -1, -1, "", 1, (float)Player.tileTargetX, (float)Player.tileTargetY, (float)this.direction);
  1571.                                                     }
  1572.                                                 }
  1573.                                                 else
  1574.                                                 {
  1575.                                                     if ((Main.tile[Player.tileTargetX, Player.tileTargetY].type == 21 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 29) && this.talkNPC == -1)
  1576.                                                     {
  1577.                                                         bool flag5 = false;
  1578.                                                         int num41 = Player.tileTargetX - (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18);
  1579.                                                         int num42 = Player.tileTargetY - (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 18);
  1580.                                                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 29)
  1581.                                                         {
  1582.                                                             flag5 = true;
  1583.                                                         }
  1584.                                                         if (Main.netMode == 1 && !flag5)
  1585.                                                         {
  1586.                                                             if (num41 == this.chestX && num42 == this.chestY && this.chest != -1)
  1587.                                                             {
  1588.                                                                 this.chest = -1;
  1589.                                                                 Main.PlaySound(11, -1, -1, 1);
  1590.                                                             }
  1591.                                                             else
  1592.                                                             {
  1593.                                                                 NetMessage.SendData(31, -1, -1, "", num41, (float)num42, 0f, 0f);
  1594.                                                             }
  1595.                                                         }
  1596.                                                         else
  1597.                                                         {
  1598.                                                             int num43 = -1;
  1599.                                                             if (flag5)
  1600.                                                             {
  1601.                                                                 num43 = -2;
  1602.                                                             }
  1603.                                                             else
  1604.                                                             {
  1605.                                                                 num43 = Chest.FindChest(num41, num42);
  1606.                                                             }
  1607.                                                             if (num43 != -1)
  1608.                                                             {
  1609.                                                                 if (num43 == this.chest)
  1610.                                                                 {
  1611.                                                                     this.chest = -1;
  1612.                                                                     Main.PlaySound(11, -1, -1, 1);
  1613.                                                                 }
  1614.                                                                 else
  1615.                                                                 {
  1616.                                                                     if (num43 != this.chest && this.chest == -1)
  1617.                                                                     {
  1618.                                                                         this.chest = num43;
  1619.                                                                         Main.playerInventory = true;
  1620.                                                                         Main.PlaySound(10, -1, -1, 1);
  1621.                                                                         this.chestX = num41;
  1622.                                                                         this.chestY = num42;
  1623.                                                                     }
  1624.                                                                     else
  1625.                                                                     {
  1626.                                                                         this.chest = num43;
  1627.                                                                         Main.playerInventory = true;
  1628.                                                                         Main.PlaySound(12, -1, -1, 1);
  1629.                                                                         this.chestX = num41;
  1630.                                                                         this.chestY = num42;
  1631.                                                                     }
  1632.                                                                 }
  1633.                                                             }
  1634.                                                         }
  1635.                                                     }
  1636.                                                 }
  1637.                                             }
  1638.                                         }
  1639.                                     }
  1640.                                 }
  1641.                             }
  1642.                             this.releaseUseTile = false;
  1643.                         }
  1644.                         else
  1645.                         {
  1646.                             this.releaseUseTile = true;
  1647.                         }
  1648.                     }
  1649.                     if (Main.myPlayer == this.whoAmi)
  1650.                     {
  1651.                         if (this.talkNPC >= 0)
  1652.                         {
  1653.                             Rectangle rectangle2 = new Rectangle((int)(this.position.X + (float)(this.width / 2) - (float)(Player.tileRangeX * 16)), (int)(this.position.Y + (float)(this.height / 2) - (float)(Player.tileRangeY * 16)), Player.tileRangeX * 16 * 2, Player.tileRangeY * 16 * 2);
  1654.                             Rectangle value = new Rectangle((int)Main.npc[this.talkNPC].position.X, (int)Main.npc[this.talkNPC].position.Y, Main.npc[this.talkNPC].width, Main.npc[this.talkNPC].height);
  1655.                             if (!rectangle2.Intersects(value) || this.chest != -1 || !Main.npc[this.talkNPC].active)
  1656.                             {
  1657.                                 if (this.chest == -1)
  1658.                                 {
  1659.                                     Main.PlaySound(11, -1, -1, 1);
  1660.                                 }
  1661.                                 this.talkNPC = -1;
  1662.                                 Main.npcChatText = "";
  1663.                             }
  1664.                         }
  1665.                         if (this.sign >= 0)
  1666.                         {
  1667.                             Rectangle rectangle3 = new Rectangle((int)(this.position.X + (float)(this.width / 2) - (float)(Player.tileRangeX * 16)), (int)(this.position.Y + (float)(this.height / 2) - (float)(Player.tileRangeY * 16)), Player.tileRangeX * 16 * 2, Player.tileRangeY * 16 * 2);
  1668.                             Rectangle value2 = new Rectangle(Main.sign[this.sign].x * 16, Main.sign[this.sign].y * 16, 32, 32);
  1669.                             if (!rectangle3.Intersects(value2))
  1670.                             {
  1671.                                 Main.PlaySound(11, -1, -1, 1);
  1672.                                 this.sign = -1;
  1673.                                 Main.editSign = false;
  1674.                                 Main.npcChatText = "";
  1675.                             }
  1676.                         }
  1677.                         if (Main.editSign)
  1678.                         {
  1679.                             if (this.sign == -1)
  1680.                             {
  1681.                                 Main.editSign = false;
  1682.                             }
  1683.                             else
  1684.                             {
  1685.                                 Main.npcChatText = Main.GetInputText(Main.npcChatText);
  1686.                                 if (Main.inputTextEnter)
  1687.                                 {
  1688.                                     byte[] bytes = new byte[]
  1689.                                     {
  1690.                                         10
  1691.                                     };
  1692.                                     Main.npcChatText += Encoding.ASCII.GetString(bytes);
  1693.                                 }
  1694.                             }
  1695.                         }
  1696.                         Rectangle rectangle4 = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
  1697.                         for (int num44 = 0; num44 < 1000; num44++)
  1698.                         {
  1699.                             if (Main.npc[num44].active && !Main.npc[num44].friendly && rectangle4.Intersects(new Rectangle((int)Main.npc[num44].position.X, (int)Main.npc[num44].position.Y, Main.npc[num44].width, Main.npc[num44].height)))
  1700.                             {
  1701.                                 int hitDirection = -1;
  1702.                                 if (Main.npc[num44].position.X + (float)(Main.npc[num44].width / 2) < this.position.X + (float)(this.width / 2))
  1703.                                 {
  1704.                                     hitDirection = 1;
  1705.                                 }
  1706.                                 this.Hurt(Main.npc[num44].damage, hitDirection, false, false);
  1707.                             }
  1708.                         }
  1709.                         Vector2 vector = Collision.HurtTiles(this.position, this.velocity, this.width, this.height, this.fireWalk);
  1710.                         if (vector.Y != 0f)
  1711.                         {
  1712.                             this.Hurt((int)vector.Y, (int)vector.X, false, false);
  1713.                         }
  1714.                     }
  1715.                     if (this.grappling[0] >= 0)
  1716.                     {
  1717.                         this.rocketDelay = 0;
  1718.                         this.rocketFrame = false;
  1719.                         this.canRocket = false;
  1720.                         this.rocketRelease = false;
  1721.                         this.fallStart = (int)(this.position.Y / 16f);
  1722.                         float num45 = 0f;
  1723.                         float num46 = 0f;
  1724.                         for (int num47 = 0; num47 < this.grapCount; num47++)
  1725.                         {
  1726.                             num45 += Main.projectile[this.grappling[num47]].position.X + (float)(Main.projectile[this.grappling[num47]].width / 2);
  1727.                             num46 += Main.projectile[this.grappling[num47]].position.Y + (float)(Main.projectile[this.grappling[num47]].height / 2);
  1728.                         }
  1729.                         num45 /= (float)this.grapCount;
  1730.                         num46 /= (float)this.grapCount;
  1731.                         Vector2 vector2 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
  1732.                         float num48 = num45 - vector2.X;
  1733.                         float num49 = num46 - vector2.Y;
  1734.                         float num50 = (float)Math.Sqrt((double)(num48 * num48 + num49 * num49));
  1735.                         float num51 = 11f;
  1736.                         float num52 = num50;
  1737.                         if (num50 > num51)
  1738.                         {
  1739.                             num52 = num51 / num50;
  1740.                         }
  1741.                         else
  1742.                         {
  1743.                             num52 = 1f;
  1744.                         }
  1745.                         num48 *= num52;
  1746.                         num49 *= num52;
  1747.                         this.velocity.X = num48;
  1748.                         this.velocity.Y = num49;
  1749.                         if (this.itemAnimation == 0)
  1750.                         {
  1751.                             if (this.velocity.X > 0f)
  1752.                             {
  1753.                                 this.direction = 1;
  1754.                             }
  1755.                             if (this.velocity.X < 0f)
  1756.                             {
  1757.                                 this.direction = -1;
  1758.                             }
  1759.                         }
  1760.                         if (this.controlJump)
  1761.                         {
  1762.                             if (this.releaseJump)
  1763.                             {
  1764.                                 if (this.velocity.Y == 0f || (this.wet && (double)this.velocity.Y > -0.02 && (double)this.velocity.Y < 0.02))
  1765.                                 {
  1766.                                     this.velocity.Y = -Player.jumpSpeed;
  1767.                                     this.jump = Player.jumpHeight / 2;
  1768.                                     this.releaseJump = false;
  1769.                                 }
  1770.                                 else
  1771.                                 {
  1772.                                     this.velocity.Y = this.velocity.Y + 0.01f;
  1773.                                     this.releaseJump = false;
  1774.                                 }
  1775.                                 if (this.doubleJump)
  1776.                                 {
  1777.                                     this.jumpAgain = true;
  1778.                                 }
  1779.                                 this.grappling[0] = 0;
  1780.                                 this.grapCount = 0;
  1781.                                 for (int num53 = 0; num53 < 1000; num53++)
  1782.                                 {
  1783.                                     if (Main.projectile[num53].active && Main.projectile[num53].owner == i && Main.projectile[num53].aiStyle == 7)
  1784.                                     {
  1785.                                         Main.projectile[num53].Kill();
  1786.                                     }
  1787.                                 }
  1788.                             }
  1789.                         }
  1790.                         else
  1791.                         {
  1792.                             this.releaseJump = true;
  1793.                         }
  1794.                     }
  1795.                     if (Collision.StickyTiles(this.position, this.velocity, this.width, this.height))
  1796.                     {
  1797.                         this.fallStart = (int)(this.position.Y / 16f);
  1798.                         this.jump = 0;
  1799.                         if (this.velocity.X > 1f)
  1800.                         {
  1801.                             this.velocity.X = 1f;
  1802.                         }
  1803.                         if (this.velocity.X < -1f)
  1804.                         {
  1805.                             this.velocity.X = -1f;
  1806.                         }
  1807.                         if (this.velocity.Y > 1f)
  1808.                         {
  1809.                             this.velocity.Y = 1f;
  1810.                         }
  1811.                         if (this.velocity.Y < -5f)
  1812.                         {
  1813.                             this.velocity.Y = -5f;
  1814.                         }
  1815.                         if ((double)this.velocity.X > 0.75 || (double)this.velocity.X < -0.75)
  1816.                         {
  1817.                             this.velocity.X = this.velocity.X * 0.85f;
  1818.                         }
  1819.                         else
  1820.                         {
  1821.                             this.velocity.X = this.velocity.X * 0.6f;
  1822.                         }
  1823.                         if (this.velocity.Y < 0f)
  1824.                         {
  1825.                             this.velocity.Y = this.velocity.Y * 0.96f;
  1826.                         }
  1827.                         else
  1828.                         {
  1829.                             this.velocity.Y = this.velocity.Y * 0.3f;
  1830.                         }
  1831.                     }
  1832.                     bool flag6 = Collision.DrownCollision(this.position, this.width, this.height);
  1833.                     if (this.inventory[this.selectedItem].type == 186)
  1834.                     {
  1835.                         try
  1836.                         {
  1837.                             int num54 = (int)((this.position.X + (float)(this.width / 2) + (float)(6 * this.direction)) / 16f);
  1838.                             int num55 = (int)((this.position.Y - 44f) / 16f);
  1839.                             if (Main.tile[num54, num55].liquid < 128)
  1840.                             {
  1841.                                 if (Main.tile[num54, num55] == null)
  1842.                                 {
  1843.                                     Main.tile[num54, num55] = new Tile();
  1844.                                 }
  1845.                                 if (!Main.tile[num54, num55].active || !Main.tileSolid[(int)Main.tile[num54, num55].type] || Main.tileSolidTop[(int)Main.tile[num54, num55].type])
  1846.                                 {
  1847.                                     flag6 = false;
  1848.                                 }
  1849.                             }
  1850.                         }
  1851.                         catch
  1852.                         {
  1853.                         }
  1854.                     }
  1855.                     if (Main.myPlayer == i)
  1856.                     {
  1857.                         if (flag6)
  1858.                         {
  1859.                             this.breathCD++;
  1860.                             int num56 = 7;
  1861.                             if (this.inventory[this.selectedItem].type == 186)
  1862.                             {
  1863.                                 num56 *= 2;
  1864.                             }
  1865.                             if (this.breathCD >= num56)
  1866.                             {
  1867.                                 this.breathCD = 0;
  1868.                                 this.breath--;
  1869.                                 if (this.breath <= 0)
  1870.                                 {
  1871.                                     this.breath = 0;
  1872.                                     this.statLife -= 2;
  1873.                                     if (this.statLife <= 0)
  1874.                                     {
  1875.                                         this.statLife = 0;
  1876.                                         this.KillMe(10.0, 0, false);
  1877.                                     }
  1878.                                 }
  1879.                             }
  1880.                         }
  1881.                         else
  1882.                         {
  1883.                             this.breath += 3;
  1884.                             if (this.breath > this.breathMax)
  1885.                             {
  1886.                                 this.breath = this.breathMax;
  1887.                             }
  1888.                             this.breathCD = 0;
  1889.                         }
  1890.                     }
  1891.                     if (flag6 && Main.rand.Next(20) == 0)
  1892.                     {
  1893.                         if (this.inventory[this.selectedItem].type == 186)
  1894.                         {
  1895.                             Vector2 arg_4117_0 = new Vector2(this.position.X + (float)(10 * this.direction) + 4f, this.position.Y - 54f);
  1896.                             int arg_4117_1 = this.width - 8;
  1897.                             int arg_4117_2 = 8;
  1898.                             int arg_4117_3 = 34;
  1899.                             float arg_4117_4 = 0f;
  1900.                             float arg_4117_5 = 0f;
  1901.                             int arg_4117_6 = 0;
  1902.                             Color newColor = default(Color);
  1903.                             Dust.NewDust(arg_4117_0, arg_4117_1, arg_4117_2, arg_4117_3, arg_4117_4, arg_4117_5, arg_4117_6, newColor, 1.2f);
  1904.                         }
  1905.                         else
  1906.                         {
  1907.                             Vector2 arg_4170_0 = new Vector2(this.position.X + (float)(12 * this.direction), this.position.Y + 4f);
  1908.                             int arg_4170_1 = this.width - 8;
  1909.                             int arg_4170_2 = 8;
  1910.                             int arg_4170_3 = 34;
  1911.                             float arg_4170_4 = 0f;
  1912.                             float arg_4170_5 = 0f;
  1913.                             int arg_4170_6 = 0;
  1914.                             Color newColor = default(Color);
  1915.                             Dust.NewDust(arg_4170_0, arg_4170_1, arg_4170_2, arg_4170_3, arg_4170_4, arg_4170_5, arg_4170_6, newColor, 1.2f);
  1916.                         }
  1917.                     }
  1918.                     bool flag7 = Collision.LavaCollision(this.position, this.width, this.height);
  1919.                     if (flag7)
  1920.                     {
  1921.                         if (Main.myPlayer == i)
  1922.                         {
  1923.                             this.Hurt(100, 0, false, false);
  1924.                         }
  1925.                         this.lavaWet = true;
  1926.                     }
  1927.                     bool flag8 = Collision.WetCollision(this.position, this.width, this.height);
  1928.                     if (flag8)
  1929.                     {
  1930.                         if (!this.wet)
  1931.                         {
  1932.                             if (this.wetCount == 0)
  1933.                             {
  1934.                                 this.wetCount = 10;
  1935.                                 if (!flag7)
  1936.                                 {
  1937.                                     for (int num57 = 0; num57 < 50; num57++)
  1938.                                     {
  1939.                                         Vector2 arg_4253_0 = new Vector2(this.position.X - 6f, this.position.Y + (float)(this.height / 2) - 8f);
  1940.                                         int arg_4253_1 = this.width + 12;
  1941.                                         int arg_4253_2 = 24;
  1942.                                         int arg_4253_3 = 33;
  1943.                                         float arg_4253_4 = 0f;
  1944.                                         float arg_4253_5 = 0f;
  1945.                                         int arg_4253_6 = 0;
  1946.                                         Color newColor = default(Color);
  1947.                                         int num58 = Dust.NewDust(arg_4253_0, arg_4253_1, arg_4253_2, arg_4253_3, arg_4253_4, arg_4253_5, arg_4253_6, newColor, 1f);
  1948.                                         Dust expr_4267_cp_0 = Main.dust[num58];
  1949.                                         expr_4267_cp_0.velocity.Y = expr_4267_cp_0.velocity.Y - 4f;
  1950.                                         Dust expr_4285_cp_0 = Main.dust[num58];
  1951.                                         expr_4285_cp_0.velocity.X = expr_4285_cp_0.velocity.X * 2.5f;
  1952.                                         Main.dust[num58].scale = 1.3f;
  1953.                                         Main.dust[num58].alpha = 100;
  1954.                                         Main.dust[num58].noGravity = true;
  1955.                                     }
  1956.                                     Main.PlaySound(19, (int)this.position.X, (int)this.position.Y, 0);
  1957.                                 }
  1958.                                 else
  1959.                                 {
  1960.                                     for (int num59 = 0; num59 < 20; num59++)
  1961.                                     {
  1962.                                         Vector2 arg_4359_0 = new Vector2(this.position.X - 6f, this.position.Y + (float)(this.height / 2) - 8f);
  1963.                                         int arg_4359_1 = this.width + 12;
  1964.                                         int arg_4359_2 = 24;
  1965.                                         int arg_4359_3 = 35;
  1966.                                         float arg_4359_4 = 0f;
  1967.                                         float arg_4359_5 = 0f;
  1968.                                         int arg_4359_6 = 0;
  1969.                                         Color newColor = default(Color);
  1970.                                         int num60 = Dust.NewDust(arg_4359_0, arg_4359_1, arg_4359_2, arg_4359_3, arg_4359_4, arg_4359_5, arg_4359_6, newColor, 1f);
  1971.                                         Dust expr_436D_cp_0 = Main.dust[num60];
  1972.                                         expr_436D_cp_0.velocity.Y = expr_436D_cp_0.velocity.Y - 1.5f;
  1973.                                         Dust expr_438B_cp_0 = Main.dust[num60];
  1974.                                         expr_438B_cp_0.velocity.X = expr_438B_cp_0.velocity.X * 2.5f;
  1975.                                         Main.dust[num60].scale = 1.3f;
  1976.                                         Main.dust[num60].alpha = 100;
  1977.                                         Main.dust[num60].noGravity = true;
  1978.                                     }
  1979.                                     Main.PlaySound(19, (int)this.position.X, (int)this.position.Y, 1);
  1980.                                 }
  1981.                             }
  1982.                             this.wet = true;
  1983.                         }
  1984.                     }
  1985.                     else
  1986.                     {
  1987.                         if (this.wet)
  1988.                         {
  1989.                             this.wet = false;
  1990.                             if (this.jump > Player.jumpHeight / 5)
  1991.                             {
  1992.                                 this.jump = Player.jumpHeight / 5;
  1993.                             }
  1994.                             if (this.wetCount == 0)
  1995.                             {
  1996.                                 this.wetCount = 10;
  1997.                                 if (!this.lavaWet)
  1998.                                 {
  1999.                                     for (int num61 = 0; num61 < 50; num61++)
  2000.                                     {
  2001.                                         Vector2 arg_44AC_0 = new Vector2(this.position.X - 6f, this.position.Y + (float)(this.height / 2));
  2002.                                         int arg_44AC_1 = this.width + 12;
  2003.                                         int arg_44AC_2 = 24;
  2004.                                         int arg_44AC_3 = 33;
  2005.                                         float arg_44AC_4 = 0f;
  2006.                                         float arg_44AC_5 = 0f;
  2007.                                         int arg_44AC_6 = 0;
  2008.                                         Color newColor = default(Color);
  2009.                                         int num62 = Dust.NewDust(arg_44AC_0, arg_44AC_1, arg_44AC_2, arg_44AC_3, arg_44AC_4, arg_44AC_5, arg_44AC_6, newColor, 1f);
  2010.                                         Dust expr_44C0_cp_0 = Main.dust[num62];
  2011.                                         expr_44C0_cp_0.velocity.Y = expr_44C0_cp_0.velocity.Y - 4f;
  2012.                                         Dust expr_44DE_cp_0 = Main.dust[num62];
  2013.                                         expr_44DE_cp_0.velocity.X = expr_44DE_cp_0.velocity.X * 2.5f;
  2014.                                         Main.dust[num62].scale = 1.3f;
  2015.                                         Main.dust[num62].alpha = 100;
  2016.                                         Main.dust[num62].noGravity = true;
  2017.                                     }
  2018.                                     Main.PlaySound(19, (int)this.position.X, (int)this.position.Y, 0);
  2019.                                 }
  2020.                                 else
  2021.                                 {
  2022.                                     for (int num63 = 0; num63 < 20; num63++)
  2023.                                     {
  2024.                                         Vector2 arg_45B2_0 = new Vector2(this.position.X - 6f, this.position.Y + (float)(this.height / 2) - 8f);
  2025.                                         int arg_45B2_1 = this.width + 12;
  2026.                                         int arg_45B2_2 = 24;
  2027.                                         int arg_45B2_3 = 35;
  2028.                                         float arg_45B2_4 = 0f;
  2029.                                         float arg_45B2_5 = 0f;
  2030.                                         int arg_45B2_6 = 0;
  2031.                                         Color newColor = default(Color);
  2032.                                         int num64 = Dust.NewDust(arg_45B2_0, arg_45B2_1, arg_45B2_2, arg_45B2_3, arg_45B2_4, arg_45B2_5, arg_45B2_6, newColor, 1f);
  2033.                                         Dust expr_45C6_cp_0 = Main.dust[num64];
  2034.                                         expr_45C6_cp_0.velocity.Y = expr_45C6_cp_0.velocity.Y - 1.5f;
  2035.                                         Dust expr_45E4_cp_0 = Main.dust[num64];
  2036.                                         expr_45E4_cp_0.velocity.X = expr_45E4_cp_0.velocity.X * 2.5f;
  2037.                                         Main.dust[num64].scale = 1.3f;
  2038.                                         Main.dust[num64].alpha = 100;
  2039.                                         Main.dust[num64].noGravity = true;
  2040.                                     }
  2041.                                     Main.PlaySound(19, (int)this.position.X, (int)this.position.Y, 1);
  2042.                                 }
  2043.                             }
  2044.                         }
  2045.                     }
  2046.                     if (!this.wet)
  2047.                     {
  2048.                         this.lavaWet = false;
  2049.                     }
  2050.                     if (this.wetCount > 0)
  2051.                     {
  2052.                         this.wetCount -= 1;
  2053.                     }
  2054.                     if (this.wet)
  2055.                     {
  2056.                         if (this.wet)
  2057.                         {
  2058.                             Vector2 vector3 = this.velocity;
  2059.                             this.velocity = Collision.TileCollision(this.position, this.velocity, this.width, this.height, this.controlDown, false);
  2060.                             Vector2 value3 = this.velocity * 0.5f;
  2061.                             if (this.velocity.X != vector3.X)
  2062.                             {
  2063.                                 value3.X = this.velocity.X;
  2064.                             }
  2065.                             if (this.velocity.Y != vector3.Y)
  2066.                             {
  2067.                                 value3.Y = this.velocity.Y;
  2068.                             }
  2069.                             this.position += value3;
  2070.                         }
  2071.                     }
  2072.                     else
  2073.                     {
  2074.                         this.velocity = Collision.TileCollision(this.position, this.velocity, this.width, this.height, this.controlDown, false);
  2075.                         this.position += this.velocity;
  2076.                     }
  2077.                     if (this.position.X < Main.leftWorld + 336f + 16f)
  2078.                     {
  2079.                         this.position.X = Main.leftWorld + 336f + 16f;
  2080.                         this.velocity.X = 0f;
  2081.                     }
  2082.                     if (this.position.X + (float)this.width > Main.rightWorld - 336f - 32f)
  2083.                     {
  2084.                         this.position.X = Main.rightWorld - 336f - 32f - (float)this.width;
  2085.                         this.velocity.X = 0f;
  2086.                     }
  2087.                     if (this.position.Y < Main.topWorld + 336f + 16f)
  2088.                     {
  2089.                         this.position.Y = Main.topWorld + 336f + 16f;
  2090.                         this.velocity.Y = 0f;
  2091.                     }
  2092.                     if (this.position.Y > Main.bottomWorld - 336f - 32f - (float)this.height)
  2093.                     {
  2094.                         this.position.Y = Main.bottomWorld - 336f - 32f - (float)this.height;
  2095.                         this.velocity.Y = 0f;
  2096.                     }
  2097.                     this.ItemCheck(i);
  2098.                     this.PlayerFrame();
  2099.                     if (this.statLife > this.statLifeMax)
  2100.                     {
  2101.                         this.statLife = this.statLifeMax;
  2102.                     }
  2103.                     this.grappling[0] = -1;
  2104.                     this.grapCount = 0;
  2105.                 }
  2106.             }
  2107.         }
  2108.         public bool SellItem(int price)
  2109.         {
  2110.             if (price <= 0)
  2111.             {
  2112.                 return false;
  2113.             }
  2114.             Item[] array = new Item[44];
  2115.             for (int i = 0; i < 44; i++)
  2116.             {
  2117.                 array[i] = new Item();
  2118.                 array[i] = (Item)this.inventory[i].Clone();
  2119.             }
  2120.             int j = price / 5;
  2121.             if (j < 1)
  2122.             {
  2123.                 j = 1;
  2124.             }
  2125.             bool flag = false;
  2126.             while (j >= 1000000)
  2127.             {
  2128.                 if (flag)
  2129.                 {
  2130.                     break;
  2131.                 }
  2132.                 int num = -1;
  2133.                 for (int k = 43; k >= 0; k--)
  2134.                 {
  2135.                     if (num == -1 && (this.inventory[k].type == 0 || this.inventory[k].stack == 0))
  2136.                     {
  2137.                         num = k;
  2138.                     }
  2139.                     while (this.inventory[k].type == 74 && this.inventory[k].stack < this.inventory[k].maxStack && j >= 1000000)
  2140.                     {
  2141.                         this.inventory[k].stack++;
  2142.                         j -= 1000000;
  2143.                         this.DoCoins(k);
  2144.                         if (this.inventory[k].stack == 0 && num == -1)
  2145.                         {
  2146.                             num = k;
  2147.                         }
  2148.                     }
  2149.                 }
  2150.                 if (j >= 1000000)
  2151.                 {
  2152.                     if (num == -1)
  2153.                     {
  2154.                         flag = true;
  2155.                     }
  2156.                     else
  2157.                     {
  2158.                         this.inventory[num].SetDefaults(74);
  2159.                         j -= 1000000;
  2160.                     }
  2161.                 }
  2162.             }
  2163.             while (j >= 10000)
  2164.             {
  2165.                 if (flag)
  2166.                 {
  2167.                     break;
  2168.                 }
  2169.                 int num2 = -1;
  2170.                 for (int l = 43; l >= 0; l--)
  2171.                 {
  2172.                     if (num2 == -1 && (this.inventory[l].type == 0 || this.inventory[l].stack == 0))
  2173.                     {
  2174.                         num2 = l;
  2175.                     }
  2176.                     while (this.inventory[l].type == 73 && this.inventory[l].stack < this.inventory[l].maxStack && j >= 10000)
  2177.                     {
  2178.                         this.inventory[l].stack++;
  2179.                         j -= 10000;
  2180.                         this.DoCoins(l);
  2181.                         if (this.inventory[l].stack == 0 && num2 == -1)
  2182.                         {
  2183.                             num2 = l;
  2184.                         }
  2185.                     }
  2186.                 }
  2187.                 if (j >= 10000)
  2188.                 {
  2189.                     if (num2 == -1)
  2190.                     {
  2191.                         flag = true;
  2192.                     }
  2193.                     else
  2194.                     {
  2195.                         this.inventory[num2].SetDefaults(73);
  2196.                         j -= 10000;
  2197.                     }
  2198.                 }
  2199.             }
  2200.             while (j >= 100)
  2201.             {
  2202.                 if (flag)
  2203.                 {
  2204.                     break;
  2205.                 }
  2206.                 int num3 = -1;
  2207.                 for (int m = 43; m >= 0; m--)
  2208.                 {
  2209.                     if (num3 == -1 && (this.inventory[m].type == 0 || this.inventory[m].stack == 0))
  2210.                     {
  2211.                         num3 = m;
  2212.                     }
  2213.                     while (this.inventory[m].type == 72 && this.inventory[m].stack < this.inventory[m].maxStack && j >= 100)
  2214.                     {
  2215.                         this.inventory[m].stack++;
  2216.                         j -= 100;
  2217.                         this.DoCoins(m);
  2218.                         if (this.inventory[m].stack == 0 && num3 == -1)
  2219.                         {
  2220.                             num3 = m;
  2221.                         }
  2222.                     }
  2223.                 }
  2224.                 if (j >= 100)
  2225.                 {
  2226.                     if (num3 == -1)
  2227.                     {
  2228.                         flag = true;
  2229.                     }
  2230.                     else
  2231.                     {
  2232.                         this.inventory[num3].SetDefaults(72);
  2233.                         j -= 100;
  2234.                     }
  2235.                 }
  2236.             }
  2237.             while (j >= 1 && !flag)
  2238.             {
  2239.                 int num4 = -1;
  2240.                 for (int n = 43; n >= 0; n--)
  2241.                 {
  2242.                     if (num4 == -1 && (this.inventory[n].type == 0 || this.inventory[n].stack == 0))
  2243.                     {
  2244.                         num4 = n;
  2245.                     }
  2246.                     while (this.inventory[n].type == 71 && this.inventory[n].stack < this.inventory[n].maxStack && j >= 1)
  2247.                     {
  2248.                         this.inventory[n].stack++;
  2249.                         j--;
  2250.                         this.DoCoins(n);
  2251.                         if (this.inventory[n].stack == 0 && num4 == -1)
  2252.                         {
  2253.                             num4 = n;
  2254.                         }
  2255.                     }
  2256.                 }
  2257.                 if (j >= 1)
  2258.                 {
  2259.                     if (num4 == -1)
  2260.                     {
  2261.                         flag = true;
  2262.                     }
  2263.                     else
  2264.                     {
  2265.                         this.inventory[num4].SetDefaults(71);
  2266.                         j--;
  2267.                     }
  2268.                 }
  2269.             }
  2270.             if (flag)
  2271.             {
  2272.                 for (int num5 = 0; num5 < 44; num5++)
  2273.                 {
  2274.                     this.inventory[num5] = (Item)array[num5].Clone();
  2275.                 }
  2276.                 return false;
  2277.             }
  2278.             return true;
  2279.         }
  2280.         public bool BuyItem(int price)
  2281.         {
  2282.             if (price == 0)
  2283.             {
  2284.                 return false;
  2285.             }
  2286.             int num = 0;
  2287.             int i = price;
  2288.             Item[] array = new Item[44];
  2289.             for (int j = 0; j < 44; j++)
  2290.             {
  2291.                 array[j] = new Item();
  2292.                 array[j] = (Item)this.inventory[j].Clone();
  2293.                 if (this.inventory[j].type == 71)
  2294.                 {
  2295.                     num += this.inventory[j].stack;
  2296.                 }
  2297.                 if (this.inventory[j].type == 72)
  2298.                 {
  2299.                     num += this.inventory[j].stack * 100;
  2300.                 }
  2301.                 if (this.inventory[j].type == 73)
  2302.                 {
  2303.                     num += this.inventory[j].stack * 10000;
  2304.                 }
  2305.                 if (this.inventory[j].type == 74)
  2306.                 {
  2307.                     num += this.inventory[j].stack * 1000000;
  2308.                 }
  2309.             }
  2310.             if (num >= price)
  2311.             {
  2312.                 i = price;
  2313.                 while (i > 0)
  2314.                 {
  2315.                     if (i >= 1000000)
  2316.                     {
  2317.                         for (int k = 0; k < 44; k++)
  2318.                         {
  2319.                             if (this.inventory[k].type == 74)
  2320.                             {
  2321.                                 while (this.inventory[k].stack > 0 && i >= 1000000)
  2322.                                 {
  2323.                                     i -= 1000000;
  2324.                                     this.inventory[k].stack--;
  2325.                                     if (this.inventory[k].stack == 0)
  2326.                                     {
  2327.                                         this.inventory[k].type = 0;
  2328.                                     }
  2329.                                 }
  2330.                             }
  2331.                         }
  2332.                     }
  2333.                     if (i >= 10000)
  2334.                     {
  2335.                         for (int l = 0; l < 44; l++)
  2336.                         {
  2337.                             if (this.inventory[l].type == 73)
  2338.                             {
  2339.                                 while (this.inventory[l].stack > 0 && i >= 10000)
  2340.                                 {
  2341.                                     i -= 10000;
  2342.                                     this.inventory[l].stack--;
  2343.                                     if (this.inventory[l].stack == 0)
  2344.                                     {
  2345.                                         this.inventory[l].type = 0;
  2346.                                     }
  2347.                                 }
  2348.                             }
  2349.                         }
  2350.                     }
  2351.                     if (i >= 100)
  2352.                     {
  2353.                         for (int m = 0; m < 44; m++)
  2354.                         {
  2355.                             if (this.inventory[m].type == 72)
  2356.                             {
  2357.                                 while (this.inventory[m].stack > 0 && i >= 100)
  2358.                                 {
  2359.                                     i -= 100;
  2360.                                     this.inventory[m].stack--;
  2361.                                     if (this.inventory[m].stack == 0)
  2362.                                     {
  2363.                                         this.inventory[m].type = 0;
  2364.                                     }
  2365.                                 }
  2366.                             }
  2367.                         }
  2368.                     }
  2369.                     if (i >= 1)
  2370.                     {
  2371.                         for (int n = 0; n < 44; n++)
  2372.                         {
  2373.                             if (this.inventory[n].type == 71)
  2374.                             {
  2375.                                 while (this.inventory[n].stack > 0 && i >= 1)
  2376.                                 {
  2377.                                     i--;
  2378.                                     this.inventory[n].stack--;
  2379.                                     if (this.inventory[n].stack == 0)
  2380.                                     {
  2381.                                         this.inventory[n].type = 0;
  2382.                                     }
  2383.                                 }
  2384.                             }
  2385.                         }
  2386.                     }
  2387.                     if (i > 0)
  2388.                     {
  2389.                         int num2 = -1;
  2390.                         for (int num3 = 43; num3 >= 0; num3--)
  2391.                         {
  2392.                             if (this.inventory[num3].type == 0 || this.inventory[num3].stack == 0)
  2393.                             {
  2394.                                 num2 = num3;
  2395.                                 break;
  2396.                             }
  2397.                         }
  2398.                         if (num2 < 0)
  2399.                         {
  2400.                             for (int num4 = 0; num4 < 44; num4++)
  2401.                             {
  2402.                                 this.inventory[num4] = (Item)array[num4].Clone();
  2403.                             }
  2404.                             return false;
  2405.                         }
  2406.                         bool flag = true;
  2407.                         if (i >= 10000)
  2408.                         {
  2409.                             for (int num5 = 0; num5 < 44; num5++)
  2410.                             {
  2411.                                 if (this.inventory[num5].type == 74 && this.inventory[num5].stack >= 1)
  2412.                                 {
  2413.                                     this.inventory[num5].stack--;
  2414.                                     if (this.inventory[num5].stack == 0)
  2415.                                     {
  2416.                                         this.inventory[num5].type = 0;
  2417.                                     }
  2418.                                     this.inventory[num2].SetDefaults(73);
  2419.                                     this.inventory[num2].stack = 100;
  2420.                                     flag = false;
  2421.                                     break;
  2422.                                 }
  2423.                             }
  2424.                         }
  2425.                         else
  2426.                         {
  2427.                             if (i >= 100)
  2428.                             {
  2429.                                 for (int num6 = 0; num6 < 44; num6++)
  2430.                                 {
  2431.                                     if (this.inventory[num6].type == 73 && this.inventory[num6].stack >= 1)
  2432.                                     {
  2433.                                         this.inventory[num6].stack--;
  2434.                                         if (this.inventory[num6].stack == 0)
  2435.                                         {
  2436.                                             this.inventory[num6].type = 0;
  2437.                                         }
  2438.                                         this.inventory[num2].SetDefaults(72);
  2439.                                         this.inventory[num2].stack = 100;
  2440.                                         flag = false;
  2441.                                         break;
  2442.                                     }
  2443.                                 }
  2444.                             }
  2445.                             else
  2446.                             {
  2447.                                 if (i >= 1)
  2448.                                 {
  2449.                                     for (int num7 = 0; num7 < 44; num7++)
  2450.                                     {
  2451.                                         if (this.inventory[num7].type == 72 && this.inventory[num7].stack >= 1)
  2452.                                         {
  2453.                                             this.inventory[num7].stack--;
  2454.                                             if (this.inventory[num7].stack == 0)
  2455.                                             {
  2456.                                                 this.inventory[num7].type = 0;
  2457.                                             }
  2458.                                             this.inventory[num2].SetDefaults(71);
  2459.                                             this.inventory[num2].stack = 100;
  2460.                                             flag = false;
  2461.                                             break;
  2462.                                         }
  2463.                                     }
  2464.                                 }
  2465.                             }
  2466.                         }
  2467.                         if (flag)
  2468.                         {
  2469.                             if (i < 10000)
  2470.                             {
  2471.                                 for (int num8 = 0; num8 < 44; num8++)
  2472.                                 {
  2473.                                     if (this.inventory[num8].type == 73 && this.inventory[num8].stack >= 1)
  2474.                                     {
  2475.                                         this.inventory[num8].stack--;
  2476.                                         if (this.inventory[num8].stack == 0)
  2477.                                         {
  2478.                                             this.inventory[num8].type = 0;
  2479.                                         }
  2480.                                         this.inventory[num2].SetDefaults(72);
  2481.                                         this.inventory[num2].stack = 100;
  2482.                                         flag = false;
  2483.                                         break;
  2484.                                     }
  2485.                                 }
  2486.                             }
  2487.                             if (flag && i < 1000000)
  2488.                             {
  2489.                                 for (int num9 = 0; num9 < 44; num9++)
  2490.                                 {
  2491.                                     if (this.inventory[num9].type == 74 && this.inventory[num9].stack >= 1)
  2492.                                     {
  2493.                                         this.inventory[num9].stack--;
  2494.                                         if (this.inventory[num9].stack == 0)
  2495.                                         {
  2496.                                             this.inventory[num9].type = 0;
  2497.                                         }
  2498.                                         this.inventory[num2].SetDefaults(73);
  2499.                                         this.inventory[num2].stack = 100;
  2500.                                         flag = false;
  2501.                                         break;
  2502.                                     }
  2503.                                 }
  2504.                             }
  2505.                         }
  2506.                     }
  2507.                 }
  2508.                 return true;
  2509.             }
  2510.             return false;
  2511.         }
  2512.         public void AdjTiles()
  2513.         {
  2514.             int num = 4;
  2515.             int num2 = 3;
  2516.             for (int i = 0; i < 80; i++)
  2517.             {
  2518.                 this.oldAdjTile[i] = this.adjTile[i];
  2519.                 this.adjTile[i] = false;
  2520.             }
  2521.             int num3 = (int)((this.position.X + (float)(this.width / 2)) / 16f);
  2522.             int num4 = (int)((this.position.Y + (float)this.height) / 16f);
  2523.             for (int j = num3 - num; j <= num3 + num; j++)
  2524.             {
  2525.                 for (int k = num4 - num2; k < num4 + num2; k++)
  2526.                 {
  2527.                     if (Main.tile[j, k].active)
  2528.                     {
  2529.                         this.adjTile[(int)Main.tile[j, k].type] = true;
  2530.                         if (Main.tile[j, k].type == 77)
  2531.                         {
  2532.                             this.adjTile[17] = true;
  2533.                         }
  2534.                     }
  2535.                 }
  2536.             }
  2537.             if (Main.playerInventory)
  2538.             {
  2539.                 bool flag = false;
  2540.                 for (int l = 0; l < 80; l++)
  2541.                 {
  2542.                     if (this.oldAdjTile[l] != this.adjTile[l])
  2543.                     {
  2544.                         flag = true;
  2545.                         break;
  2546.                     }
  2547.                 }
  2548.                 if (flag)
  2549.                 {
  2550.                     Recipe.FindRecipes();
  2551.                 }
  2552.             }
  2553.         }
  2554.         public void PlayerFrame()
  2555.         {
  2556.             if (this.swimTime > 0)
  2557.             {
  2558.                 this.swimTime--;
  2559.                 if (!this.wet)
  2560.                 {
  2561.                     this.swimTime = 0;
  2562.                 }
  2563.             }
  2564.             this.head = this.armor[0].headSlot;
  2565.             this.body = this.armor[1].bodySlot;
  2566.             this.legs = this.armor[2].legSlot;
  2567.             this.bodyFrame.Width = 40;
  2568.             this.bodyFrame.Height = 56;
  2569.             this.legFrame.Width = 40;
  2570.             this.legFrame.Height = 56;
  2571.             this.bodyFrame.X = 0;
  2572.             this.legFrame.X = 0;
  2573.             if (this.itemAnimation > 0 && this.inventory[this.selectedItem].useStyle != 10)
  2574.             {
  2575.                 if (this.inventory[this.selectedItem].useStyle == 1 || this.inventory[this.selectedItem].type == 0)
  2576.                 {
  2577.                     if ((double)this.itemAnimation < (double)this.itemAnimationMax * 0.333)
  2578.                     {
  2579.                         this.bodyFrame.Y = this.bodyFrame.Height * 3;
  2580.                     }
  2581.                     else
  2582.                     {
  2583.                         if ((double)this.itemAnimation < (double)this.itemAnimationMax * 0.666)
  2584.                         {
  2585.                             this.bodyFrame.Y = this.bodyFrame.Height * 2;
  2586.                         }
  2587.                         else
  2588.                         {
  2589.                             this.bodyFrame.Y = this.bodyFrame.Height;
  2590.                         }
  2591.                     }
  2592.                 }
  2593.                 else
  2594.                 {
  2595.                     if (this.inventory[this.selectedItem].useStyle == 2)
  2596.                     {
  2597.                         if ((double)this.itemAnimation < (double)this.itemAnimationMax * 0.5)
  2598.                         {
  2599.                             this.bodyFrame.Y = this.bodyFrame.Height * 4;
  2600.                         }
  2601.                         else
  2602.                         {
  2603.                             this.bodyFrame.Y = this.bodyFrame.Height * 5;
  2604.                         }
  2605.                     }
  2606.                     else
  2607.                     {
  2608.                         if (this.inventory[this.selectedItem].useStyle == 3)
  2609.                         {
  2610.                             if ((double)this.itemAnimation > (double)this.itemAnimationMax * 0.666)
  2611.                             {
  2612.                                 this.bodyFrame.Y = this.bodyFrame.Height * 3;
  2613.                             }
  2614.                             else
  2615.                             {
  2616.                                 this.bodyFrame.Y = this.bodyFrame.Height * 3;
  2617.                             }
  2618.                         }
  2619.                         else
  2620.                         {
  2621.                             if (this.inventory[this.selectedItem].useStyle == 4)
  2622.                             {
  2623.                                 this.bodyFrame.Y = this.bodyFrame.Height * 2;
  2624.                             }
  2625.                             else
  2626.                             {
  2627.                                 if (this.inventory[this.selectedItem].useStyle == 5)
  2628.                                 {
  2629.                                     float num = this.itemRotation * (float)this.direction;
  2630.                                     this.bodyFrame.Y = this.bodyFrame.Height * 3;
  2631.                                     if ((double)num < -0.75)
  2632.                                     {
  2633.                                         this.bodyFrame.Y = this.bodyFrame.Height * 2;
  2634.                                     }
  2635.                                     if ((double)num > 0.6)
  2636.                                     {
  2637.                                         this.bodyFrame.Y = this.bodyFrame.Height * 4;
  2638.                                     }
  2639.                                 }
  2640.                             }
  2641.                         }
  2642.                     }
  2643.                 }
  2644.             }
  2645.             else
  2646.             {
  2647.                 if (this.inventory[this.selectedItem].holdStyle == 1)
  2648.                 {
  2649.                     this.bodyFrame.Y = this.bodyFrame.Height * 3;
  2650.                 }
  2651.                 else
  2652.                 {
  2653.                     if (this.inventory[this.selectedItem].holdStyle == 2)
  2654.                     {
  2655.                         this.bodyFrame.Y = this.bodyFrame.Height * 2;
  2656.                     }
  2657.                     else
  2658.                     {
  2659.                         if (this.grappling[0] >= 0)
  2660.                         {
  2661.                             Vector2 vector = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
  2662.                             float num2 = 0f;
  2663.                             float num3 = 0f;
  2664.                             for (int i = 0; i < this.grapCount; i++)
  2665.                             {
  2666.                                 num2 += Main.projectile[this.grappling[i]].position.X + (float)(Main.projectile[this.grappling[i]].width / 2);
  2667.                                 num3 += Main.projectile[this.grappling[i]].position.Y + (float)(Main.projectile[this.grappling[i]].height / 2);
  2668.                             }
  2669.                             num2 /= (float)this.grapCount;
  2670.                             num3 /= (float)this.grapCount;
  2671.                             num2 -= vector.X;
  2672.                             num3 -= vector.Y;
  2673.                             if (num3 < 0f && Math.Abs(num3) > Math.Abs(num2))
  2674.                             {
  2675.                                 this.bodyFrame.Y = this.bodyFrame.Height * 2;
  2676.                             }
  2677.                             else
  2678.                             {
  2679.                                 if (num3 > 0f && Math.Abs(num3) > Math.Abs(num2))
  2680.                                 {
  2681.                                     this.bodyFrame.Y = this.bodyFrame.Height * 4;
  2682.                                 }
  2683.                                 else
  2684.                                 {
  2685.                                     this.bodyFrame.Y = this.bodyFrame.Height * 3;
  2686.                                 }
  2687.                             }
  2688.                         }
  2689.                         else
  2690.                         {
  2691.                             if (this.swimTime > 0)
  2692.                             {
  2693.                                 if (this.swimTime > 20)
  2694.                                 {
  2695.                                     this.bodyFrame.Y = 0;
  2696.                                 }
  2697.                                 else
  2698.                                 {
  2699.                                     if (this.swimTime > 10)
  2700.                                     {
  2701.                                         this.bodyFrame.Y = this.bodyFrame.Height * 5;
  2702.                                     }
  2703.                                     else
  2704.                                     {
  2705.                                         this.bodyFrame.Y = 0;
  2706.                                     }
  2707.                                 }
  2708.                             }
  2709.                             else
  2710.                             {
  2711.                                 if (this.velocity.Y != 0f)
  2712.                                 {
  2713.                                     this.bodyFrameCounter = 0.0;
  2714.                                     this.bodyFrame.Y = this.bodyFrame.Height * 5;
  2715.                                 }
  2716.                                 else
  2717.                                 {
  2718.                                     if (this.velocity.X != 0f)
  2719.                                     {
  2720.                                         this.bodyFrameCounter += (double)Math.Abs(this.velocity.X) * 1.5;
  2721.                                         this.bodyFrame.Y = this.legFrame.Y;
  2722.                                     }
  2723.                                     else
  2724.                                     {
  2725.                                         this.bodyFrameCounter = 0.0;
  2726.                                         this.bodyFrame.Y = 0;
  2727.                                     }
  2728.                                 }
  2729.                             }
  2730.                         }
  2731.                     }
  2732.                 }
  2733.             }
  2734.             if (this.swimTime > 0)
  2735.             {
  2736.                 this.legFrameCounter += 2.0;
  2737.                 while (this.legFrameCounter > 8.0)
  2738.                 {
  2739.                     this.legFrameCounter -= 8.0;
  2740.                     this.legFrame.Y = this.legFrame.Y + this.legFrame.Height;
  2741.                 }
  2742.                 if (this.legFrame.Y < this.legFrame.Height * 7)
  2743.                 {
  2744.                     this.legFrame.Y = this.legFrame.Height * 19;
  2745.                     return;
  2746.                 }
  2747.                 if (this.legFrame.Y > this.legFrame.Height * 19)
  2748.                 {
  2749.                     this.legFrame.Y = this.legFrame.Height * 7;
  2750.                     return;
  2751.                 }
  2752.             }
  2753.             else
  2754.             {
  2755.                 if (this.velocity.Y != 0f || this.grappling[0] > -1)
  2756.                 {
  2757.                     this.legFrameCounter = 0.0;
  2758.                     this.legFrame.Y = this.legFrame.Height * 5;
  2759.                     return;
  2760.                 }
  2761.                 if (this.velocity.X != 0f)
  2762.                 {
  2763.                     this.legFrameCounter += (double)Math.Abs(this.velocity.X) * 1.3;
  2764.                     while (this.legFrameCounter > 8.0)
  2765.                     {
  2766.                         this.legFrameCounter -= 8.0;
  2767.                         this.legFrame.Y = this.legFrame.Y + this.legFrame.Height;
  2768.                     }
  2769.                     if (this.legFrame.Y < this.legFrame.Height * 7)
  2770.                     {
  2771.                         this.legFrame.Y = this.legFrame.Height * 19;
  2772.                         return;
  2773.                     }
  2774.                     if (this.legFrame.Y > this.legFrame.Height * 19)
  2775.                     {
  2776.                         this.legFrame.Y = this.legFrame.Height * 7;
  2777.                         return;
  2778.                     }
  2779.                 }
  2780.                 else
  2781.                 {
  2782.                     this.legFrameCounter = 0.0;
  2783.                     this.legFrame.Y = 0;
  2784.                 }
  2785.             }
  2786.         }
  2787.         public void Spawn()
  2788.         {
  2789.             if (this.whoAmi == Main.myPlayer)
  2790.             {
  2791.                 this.FindSpawn();
  2792.                 if (!Player.CheckSpawn(this.SpawnX, this.SpawnY))
  2793.                 {
  2794.                     this.SpawnX = -1;
  2795.                     this.SpawnY = -1;
  2796.                 }
  2797.             }
  2798.             if (Main.netMode == 1 && this.whoAmi == Main.myPlayer)
  2799.             {
  2800.                 NetMessage.SendData(12, -1, -1, "", Main.myPlayer, 0f, 0f, 0f);
  2801.                 Main.gameMenu = false;
  2802.             }
  2803.             this.headPosition = default(Vector2);
  2804.             this.bodyPosition = default(Vector2);
  2805.             this.legPosition = default(Vector2);
  2806.             this.headRotation = 0f;
  2807.             this.bodyRotation = 0f;
  2808.             this.legRotation = 0f;
  2809.             if (this.statLife <= 0)
  2810.             {
  2811.                 this.statLife = 100;
  2812.                 this.breath = this.breathMax;
  2813.                 if (this.spawnMax)
  2814.                 {
  2815.                     this.statLife = this.statLifeMax;
  2816.                     this.statMana = this.statManaMax;
  2817.                 }
  2818.             }
  2819.             this.immune = true;
  2820.             this.dead = false;
  2821.             this.immuneTime = 0;
  2822.             this.active = true;
  2823.             if (this.SpawnX >= 0 && this.SpawnY >= 0)
  2824.             {
  2825.                 this.position.X = (float)(this.SpawnX * 16 + 8 - this.width / 2);
  2826.                 this.position.Y = (float)(this.SpawnY * 16 - this.height);
  2827.             }
  2828.             else
  2829.             {
  2830.                 this.position.X = (float)(Main.spawnTileX * 16 + 8 - this.width / 2);
  2831.                 this.position.Y = (float)(Main.spawnTileY * 16 - this.height);
  2832.                 for (int i = Main.spawnTileX - 1; i < Main.spawnTileX + 2; i++)
  2833.                 {
  2834.                     for (int j = Main.spawnTileY - 3; j < Main.spawnTileY; j++)
  2835.                     {
  2836.                         if (Main.tileSolid[(int)Main.tile[i, j].type] && !Main.tileSolidTop[(int)Main.tile[i, j].type])
  2837.                         {
  2838.                             if (Main.tile[i, j].liquid > 0)
  2839.                             {
  2840.                                 Main.tile[i, j].lava = false;
  2841.                                 Main.tile[i, j].liquid = 0;
  2842.                                 WorldGen.SquareTileFrame(i, j, true);
  2843.                             }
  2844.                             WorldGen.KillTile(i, j, false, false, false);
  2845.                         }
  2846.                     }
  2847.                 }
  2848.             }
  2849.             this.wet = Collision.WetCollision(this.position, this.width, this.height);
  2850.             this.wetCount = 0;
  2851.             this.lavaWet = false;
  2852.             this.fallStart = (int)(this.position.Y / 16f);
  2853.             this.velocity.X = 0f;
  2854.             this.velocity.Y = 0f;
  2855.             this.talkNPC = -1;
  2856.             if (this.pvpDeath)
  2857.             {
  2858.                 this.pvpDeath = false;
  2859.                 this.immuneTime = 300;
  2860.                 this.statLife = this.statLifeMax;
  2861.             }
  2862.             if (this.whoAmi == Main.myPlayer)
  2863.             {
  2864.                 Lighting.lightCounter = Lighting.lightSkip + 1;
  2865.                 Main.screenPosition.X = this.position.X + (float)(this.width / 2) - (float)(Main.screenWidth / 2);
  2866.                 Main.screenPosition.Y = this.position.Y + (float)(this.height / 2) - (float)(Main.screenHeight / 2);
  2867.             }
  2868.         }
  2869.         public double Hurt(int Damage, int hitDirection, bool pvp = false, bool quiet = false)
  2870.         {
  2871.             if (!this.immune && !Main.godMode)
  2872.             {
  2873.                 int num = Damage;
  2874.                 if (pvp)
  2875.                 {
  2876.                     num *= 2;
  2877.                 }
  2878.                 double num2 = Main.CalculateDamage(num, this.statDefense);
  2879.                 if (num2 >= 1.0)
  2880.                 {
  2881.                     if (Main.netMode == 1 && this.whoAmi == Main.myPlayer && !quiet)
  2882.                     {
  2883.                         int num3 = 0;
  2884.                         if (pvp)
  2885.                         {
  2886.                             num3 = 1;
  2887.                         }
  2888.                         NetMessage.SendData(13, -1, -1, "", this.whoAmi, 0f, 0f, 0f);
  2889.                         NetMessage.SendData(16, -1, -1, "", this.whoAmi, 0f, 0f, 0f);
  2890.                         NetMessage.SendData(26, -1, -1, "", this.whoAmi, (float)hitDirection, (float)Damage, (float)num3);
  2891.                     }
  2892.                     CombatText.NewText(new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height), new Color(255, 80, 90, 255), string.Concat((int)num2));
  2893.                     this.statLife -= (int)num2;
  2894.                     this.immune = true;
  2895.                     this.immuneTime = 40;
  2896.                     if (pvp)
  2897.                     {
  2898.                         this.immuneTime = 8;
  2899.                     }
  2900.                     if (!this.noKnockback && hitDirection != 0)
  2901.                     {
  2902.                         this.velocity.X = 4.5f * (float)hitDirection;
  2903.                         this.velocity.Y = -3.5f;
  2904.                     }
  2905.                     if (this.boneArmor)
  2906.                     {
  2907.                         Main.PlaySound(3, (int)this.position.X, (int)this.position.Y, 2);
  2908.                     }
  2909.                     else
  2910.                     {
  2911.                         if (this.hair == 5 || this.hair == 6 || this.hair == 9 || this.hair == 11)
  2912.                         {
  2913.                             Main.PlaySound(20, (int)this.position.X, (int)this.position.Y, 1);
  2914.                         }
  2915.                         else
  2916.                         {
  2917.                             Main.PlaySound(1, (int)this.position.X, (int)this.position.Y, 1);
  2918.                         }
  2919.                     }
  2920.                     if (this.statLife > 0)
  2921.                     {
  2922.                         int num4 = 0;
  2923.                         while ((double)num4 < num2 / (double)this.statLifeMax * 100.0)
  2924.                         {
  2925.                             if (this.boneArmor)
  2926.                             {
  2927.                                 Dust.NewDust(this.position, this.width, this.height, 26, (float)(2 * hitDirection), -2f, 0, default(Color), 1f);
  2928.                             }
  2929.                             else
  2930.                             {
  2931.                                 Dust.NewDust(this.position, this.width, this.height, 5, (float)(2 * hitDirection), -2f, 0, default(Color), 1f);
  2932.                             }
  2933.                             num4++;
  2934.                         }
  2935.                     }
  2936.                     else
  2937.                     {
  2938.                         this.statLife = 0;
  2939.                         if (this.whoAmi == Main.myPlayer)
  2940.                         {
  2941.                             this.KillMe(num2, hitDirection, pvp);
  2942.                         }
  2943.                     }
  2944.                 }
  2945.                 if (pvp)
  2946.                 {
  2947.                     num2 = Main.CalculateDamage(num, this.statDefense);
  2948.                 }
  2949.                 return num2;
  2950.             }
  2951.             return 0.0;
  2952.         }
  2953.         public void KillMe(double dmg, int hitDirection, bool pvp = false)
  2954.         {
  2955.             if (Main.godMode && Main.myPlayer == this.whoAmi)
  2956.             {
  2957.                 return;
  2958.             }
  2959.             if (this.dead)
  2960.             {
  2961.                 return;
  2962.             }
  2963.             if (pvp)
  2964.             {
  2965.                 this.pvpDeath = true;
  2966.             }
  2967.             Main.PlaySound(5, (int)this.position.X, (int)this.position.Y, 1);
  2968.             this.headVelocity.Y = (float)Main.rand.Next(-40, -10) * 0.1f;
  2969.             this.bodyVelocity.Y = (float)Main.rand.Next(-40, -10) * 0.1f;
  2970.             this.legVelocity.Y = (float)Main.rand.Next(-40, -10) * 0.1f;
  2971.             this.headVelocity.X = (float)Main.rand.Next(-20, 21) * 0.1f + (float)(2 * hitDirection);
  2972.             this.bodyVelocity.X = (float)Main.rand.Next(-20, 21) * 0.1f + (float)(2 * hitDirection);
  2973.             this.legVelocity.X = (float)Main.rand.Next(-20, 21) * 0.1f + (float)(2 * hitDirection);
  2974.             int num = 0;
  2975.             while ((double)num < 20.0 + dmg / (double)this.statLifeMax * 100.0)
  2976.             {
  2977.                 if (this.boneArmor)
  2978.                 {
  2979.                     Dust.NewDust(this.position, this.width, this.height, 26, (float)(2 * hitDirection), -2f, 0, default(Color), 1f);
  2980.                 }
  2981.                 else
  2982.                 {
  2983.                     Dust.NewDust(this.position, this.width, this.height, 5, (float)(2 * hitDirection), -2f, 0, default(Color), 1f);
  2984.                 }
  2985.                 num++;
  2986.             }
  2987.             this.dead = true;
  2988.             this.respawnTimer = 600;
  2989.             this.immuneAlpha = 0;
  2990.             if (Main.netMode == 2)
  2991.             {
  2992.                 NetMessage.SendData(25, -1, -1, this.name + " was slain...", 8, 225f, 25f, 25f);
  2993.             }
  2994.             if (this.whoAmi == Main.myPlayer)
  2995.             {
  2996.                 WorldGen.saveToonWhilePlaying();
  2997.             }
  2998.             if (Main.netMode == 1 && this.whoAmi == Main.myPlayer)
  2999.             {
  3000.                 int num2 = 0;
  3001.                 if (pvp)
  3002.                 {
  3003.                     num2 = 1;
  3004.                 }
  3005.                 NetMessage.SendData(44, -1, -1, "", this.whoAmi, (float)hitDirection, (float)((int)dmg), (float)num2);
  3006.             }
  3007.             if (!pvp && this.whoAmi == Main.myPlayer)
  3008.             {
  3009.                 this.DropItems();
  3010.             }
  3011.         }
  3012.         public bool ItemSpace(Item newItem)
  3013.         {
  3014.             if (newItem.type == 58)
  3015.             {
  3016.                 return true;
  3017.             }
  3018.             if (newItem.type == 184)
  3019.             {
  3020.                 return true;
  3021.             }
  3022.             int num = 40;
  3023.             if (newItem.type == 71 || newItem.type == 72 || newItem.type == 73 || newItem.type == 74)
  3024.             {
  3025.                 num = 44;
  3026.             }
  3027.             for (int i = 0; i < num; i++)
  3028.             {
  3029.                 if (this.inventory[i].type == 0)
  3030.                 {
  3031.                     return true;
  3032.                 }
  3033.             }
  3034.             for (int j = 0; j < num; j++)
  3035.             {
  3036.                 if (this.inventory[j].type > 0 && this.inventory[j].stack < this.inventory[j].maxStack && newItem.IsTheSameAs(this.inventory[j]))
  3037.                 {
  3038.                     return true;
  3039.                 }
  3040.             }
  3041.             return false;
  3042.         }
  3043.         public void DoCoins(int i)
  3044.         {
  3045.             if (this.inventory[i].stack == 100 && (this.inventory[i].type == 71 || this.inventory[i].type == 72 || this.inventory[i].type == 73))
  3046.             {
  3047.                 this.inventory[i].SetDefaults(this.inventory[i].type + 1);
  3048.                 for (int j = 0; j < 44; j++)
  3049.                 {
  3050.                     if (this.inventory[j].IsTheSameAs(this.inventory[i]) && j != i && this.inventory[j].stack < this.inventory[j].maxStack)
  3051.                     {
  3052.                         this.inventory[j].stack++;
  3053.                         this.inventory[i].SetDefaults("");
  3054.                         this.inventory[i].active = false;
  3055.                         this.inventory[i].name = "";
  3056.                         this.inventory[i].type = 0;
  3057.                         this.inventory[i].stack = 0;
  3058.                         this.DoCoins(j);
  3059.                     }
  3060.                 }
  3061.             }
  3062.         }
  3063.         public Item GetItem(int plr, Item newItem)
  3064.         {
  3065.             if (newItem.noGrabDelay > 0)
  3066.             {
  3067.                 return newItem;
  3068.             }
  3069.             int num = 0;
  3070.             if (newItem.type == 71 || newItem.type == 72 || newItem.type == 73 || newItem.type == 74)
  3071.             {
  3072.                 num = -4;
  3073.             }
  3074.             for (int i = num; i < 40; i++)
  3075.             {
  3076.                 int num2 = i;
  3077.                 if (num2 < 0)
  3078.                 {
  3079.                     num2 = 44 + i;
  3080.                 }
  3081.                 if (this.inventory[num2].type > 0 && this.inventory[num2].stack < this.inventory[num2].maxStack && newItem.IsTheSameAs(this.inventory[num2]))
  3082.                 {
  3083.                     Main.PlaySound(7, (int)this.position.X, (int)this.position.Y, 1);
  3084.                     if (newItem.stack + this.inventory[num2].stack <= this.inventory[num2].maxStack)
  3085.                     {
  3086.                         this.inventory[num2].stack += newItem.stack;
  3087.                         this.DoCoins(num2);
  3088.                         if (plr == Main.myPlayer)
  3089.                         {
  3090.                             Recipe.FindRecipes();
  3091.                         }
  3092.                         return new Item();
  3093.                     }
  3094.                     newItem.stack -= this.inventory[num2].maxStack - this.inventory[num2].stack;
  3095.                     this.inventory[num2].stack = this.inventory[num2].maxStack;
  3096.                     this.DoCoins(num2);
  3097.                     if (plr == Main.myPlayer)
  3098.                     {
  3099.                         Recipe.FindRecipes();
  3100.                     }
  3101.                 }
  3102.             }
  3103.             for (int j = num; j < 40; j++)
  3104.             {
  3105.                 int num3 = j;
  3106.                 if (num3 < 0)
  3107.                 {
  3108.                     num3 = 44 + j;
  3109.                 }
  3110.                 if (this.inventory[num3].type == 0)
  3111.                 {
  3112.                     this.inventory[num3] = newItem;
  3113.                     this.DoCoins(num3);
  3114.                     Main.PlaySound(7, (int)this.position.X, (int)this.position.Y, 1);
  3115.                     if (plr == Main.myPlayer)
  3116.                     {
  3117.                         Recipe.FindRecipes();
  3118.                     }
  3119.                     return new Item();
  3120.                 }
  3121.             }
  3122.             return newItem;
  3123.         }
  3124.         public void ItemCheck(int i)
  3125.         {
  3126.             if (this.inventory[this.selectedItem].autoReuse)
  3127.             {
  3128.                 this.releaseUseItem = true;
  3129.                 if (this.itemAnimation == 1 && this.inventory[this.selectedItem].stack > 0)
  3130.                 {
  3131.                     this.itemAnimation = 0;
  3132.                 }
  3133.             }
  3134.             if (this.controlUseItem && this.itemAnimation == 0 && this.releaseUseItem && this.inventory[this.selectedItem].useStyle > 0)
  3135.             {
  3136.                 bool flag = true;
  3137.                 if (this.inventory[this.selectedItem].shoot == 6 || this.inventory[this.selectedItem].shoot == 19 || this.inventory[this.selectedItem].shoot == 33)
  3138.                 {
  3139.                     for (int j = 0; j < 1000; j++)
  3140.                     {
  3141.                         if (Main.projectile[j].active && Main.projectile[j].owner == Main.myPlayer && Main.projectile[j].type == this.inventory[this.selectedItem].shoot)
  3142.                         {
  3143.                             flag = false;
  3144.                         }
  3145.                     }
  3146.                 }
  3147.                 if (this.inventory[this.selectedItem].potion)
  3148.                 {
  3149.                     if (this.potionDelay <= 0)
  3150.                     {
  3151.                         this.potionDelay = Item.potionDelay;
  3152.                     }
  3153.                     else
  3154.                     {
  3155.                         flag = false;
  3156.                     }
  3157.                 }
  3158.                 if (this.inventory[this.selectedItem].mana > 0)
  3159.                 {
  3160.                     if (this.statMana >= (int)((float)this.inventory[this.selectedItem].mana * this.manaCost))
  3161.                     {
  3162.                         this.statMana -= (int)((float)this.inventory[this.selectedItem].mana * this.manaCost);
  3163.                     }
  3164.                     else
  3165.                     {
  3166.                         flag = false;
  3167.                     }
  3168.                 }
  3169.                 if (this.inventory[this.selectedItem].type == 43 && Main.dayTime)
  3170.                 {
  3171.                     flag = false;
  3172.                 }
  3173.                 if (this.inventory[this.selectedItem].type == 70 && !this.zoneEvil)
  3174.                 {
  3175.                     flag = false;
  3176.                 }
  3177.                 if (this.inventory[this.selectedItem].shoot == 17 && flag && i == Main.myPlayer)
  3178.                 {
  3179.                     int num = (int)((float)Main.mouseState.X + Main.screenPosition.X) / 16;
  3180.                     int num2 = (int)((float)Main.mouseState.Y + Main.screenPosition.Y) / 16;
  3181.                     if (Main.tile[num, num2].active && (Main.tile[num, num2].type == 0 || Main.tile[num, num2].type == 2 || Main.tile[num, num2].type == 23))
  3182.                     {
  3183.                         WorldGen.KillTile(num, num2, false, false, true);
  3184.                         if (!Main.tile[num, num2].active)
  3185.                         {
  3186.                             if (Main.netMode == 1)
  3187.                             {
  3188.                                 NetMessage.SendData(17, -1, -1, "", 4, (float)num, (float)num2, 0f);
  3189.                             }
  3190.                         }
  3191.                         else
  3192.                         {
  3193.                             flag = false;
  3194.                         }
  3195.                     }
  3196.                     else
  3197.                     {
  3198.                         flag = false;
  3199.                     }
  3200.                 }
  3201.                 if (flag && this.inventory[this.selectedItem].useAmmo > 0)
  3202.                 {
  3203.                     flag = false;
  3204.                     for (int k = 0; k < 44; k++)
  3205.                     {
  3206.                         if (this.inventory[k].ammo == this.inventory[this.selectedItem].useAmmo && this.inventory[k].stack > 0)
  3207.                         {
  3208.                             flag = true;
  3209.                             break;
  3210.                         }
  3211.                     }
  3212.                 }
  3213.                 if (flag)
  3214.                 {
  3215.                     if (this.grappling[0] > -1)
  3216.                     {
  3217.                         if (this.controlRight)
  3218.                         {
  3219.                             this.direction = 1;
  3220.                         }
  3221.                         else
  3222.                         {
  3223.                             if (this.controlLeft)
  3224.                             {
  3225.                                 this.direction = -1;
  3226.                             }
  3227.                         }
  3228.                     }
  3229.                     this.channel = this.inventory[this.selectedItem].channel;
  3230.                     this.attackCD = 0;
  3231.                     if (this.inventory[this.selectedItem].shoot > 0 || this.inventory[this.selectedItem].damage == 0)
  3232.                     {
  3233.                         this.meleeSpeed = 1f;
  3234.                     }
  3235.                     this.itemAnimation = (int)((float)this.inventory[this.selectedItem].useAnimation * this.meleeSpeed);
  3236.                     this.itemAnimationMax = (int)((float)this.inventory[this.selectedItem].useAnimation * this.meleeSpeed);
  3237.                     if (this.inventory[this.selectedItem].useSound > 0)
  3238.                     {
  3239.                         Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, this.inventory[this.selectedItem].useSound);
  3240.                     }
  3241.                 }
  3242.                 if (flag && this.inventory[this.selectedItem].shoot == 18)
  3243.                 {
  3244.                     for (int l = 0; l < 1000; l++)
  3245.                     {
  3246.                         if (Main.projectile[l].active && Main.projectile[l].owner == i && Main.projectile[l].type == this.inventory[this.selectedItem].shoot)
  3247.                         {
  3248.                             Main.projectile[l].Kill();
  3249.                         }
  3250.                     }
  3251.                 }
  3252.             }
  3253.             if (!this.controlUseItem)
  3254.             {
  3255.                 this.channel = false;
  3256.             }
  3257.             if (this.itemAnimation > 0)
  3258.             {
  3259.                 if (this.inventory[this.selectedItem].mana > 0)
  3260.                 {
  3261.                     this.manaRegenDelay = 180;
  3262.                 }
  3263.                 this.itemHeight = Main.itemTexture[this.inventory[this.selectedItem].type].Height;
  3264.                 this.itemWidth = Main.itemTexture[this.inventory[this.selectedItem].type].Width;
  3265.                 this.itemAnimation--;
  3266.                 if (this.inventory[this.selectedItem].useStyle == 1)
  3267.                 {
  3268.                     if ((double)this.itemAnimation < (double)this.itemAnimationMax * 0.333)
  3269.                     {
  3270.                         float num3 = 10f;
  3271.                         if (Main.itemTexture[this.inventory[this.selectedItem].type].Width > 32)
  3272.                         {
  3273.                             num3 = 14f;
  3274.                         }
  3275.                         this.itemLocation.X = this.position.X + (float)this.width * 0.5f + ((float)Main.itemTexture[this.inventory[this.selectedItem].type].Width * 0.5f - num3) * (float)this.direction;
  3276.                         this.itemLocation.Y = this.position.Y + 24f;
  3277.                     }
  3278.                     else
  3279.                     {
  3280.                         if ((double)this.itemAnimation < (double)this.itemAnimationMax * 0.666)
  3281.                         {
  3282.                             float num4 = 10f;
  3283.                             if (Main.itemTexture[this.inventory[this.selectedItem].type].Width > 32)
  3284.                             {
  3285.                                 num4 = 18f;
  3286.                             }
  3287.                             this.itemLocation.X = this.position.X + (float)this.width * 0.5f + ((float)Main.itemTexture[this.inventory[this.selectedItem].type].Width * 0.5f - num4) * (float)this.direction;
  3288.                             num4 = 10f;
  3289.                             if (Main.itemTexture[this.inventory[this.selectedItem].type].Height > 32)
  3290.                             {
  3291.                                 num4 = 8f;
  3292.                             }
  3293.                             this.itemLocation.Y = this.position.Y + num4;
  3294.                         }
  3295.                         else
  3296.                         {
  3297.                             float num5 = 6f;
  3298.                             if (Main.itemTexture[this.inventory[this.selectedItem].type].Width > 32)
  3299.                             {
  3300.                                 num5 = 14f;
  3301.                             }
  3302.                             this.itemLocation.X = this.position.X + (float)this.width * 0.5f - ((float)Main.itemTexture[this.inventory[this.selectedItem].type].Width * 0.5f - num5) * (float)this.direction;
  3303.                             num5 = 10f;
  3304.                             if (Main.itemTexture[this.inventory[this.selectedItem].type].Height > 32)
  3305.                             {
  3306.                                 num5 = 10f;
  3307.                             }
  3308.                             this.itemLocation.Y = this.position.Y + num5;
  3309.                         }
  3310.                     }
  3311.                     this.itemRotation = ((float)this.itemAnimation / (float)this.itemAnimationMax - 0.5f) * (float)(-(float)this.direction) * 3.5f - (float)this.direction * 0.3f;
  3312.                 }
  3313.                 else
  3314.                 {
  3315.                     if (this.inventory[this.selectedItem].useStyle == 2)
  3316.                     {
  3317.                         this.itemRotation = (float)this.itemAnimation / (float)this.itemAnimationMax * (float)this.direction * 2f + -1.4f * (float)this.direction;
  3318.                         if ((double)this.itemAnimation < (double)this.itemAnimationMax * 0.5)
  3319.                         {
  3320.                             this.itemLocation.X = this.position.X + (float)this.width * 0.5f + ((float)Main.itemTexture[this.inventory[this.selectedItem].type].Width * 0.5f - 9f - this.itemRotation * 12f * (float)this.direction) * (float)this.direction;
  3321.                             this.itemLocation.Y = this.position.Y + 38f + this.itemRotation * (float)this.direction * 4f;
  3322.                         }
  3323.                         else
  3324.                         {
  3325.                             this.itemLocation.X = this.position.X + (float)this.width * 0.5f + ((float)Main.itemTexture[this.inventory[this.selectedItem].type].Width * 0.5f - 9f - this.itemRotation * 16f * (float)this.direction) * (float)this.direction;
  3326.                             this.itemLocation.Y = this.position.Y + 38f + this.itemRotation * (float)this.direction;
  3327.                         }
  3328.                     }
  3329.                     else
  3330.                     {
  3331.                         if (this.inventory[this.selectedItem].useStyle == 3)
  3332.                         {
  3333.                             if ((double)this.itemAnimation > (double)this.itemAnimationMax * 0.666)
  3334.                             {
  3335.                                 this.itemLocation.X = -1000f;
  3336.                                 this.itemLocation.Y = -1000f;
  3337.                                 this.itemRotation = -1.3f * (float)this.direction;
  3338.                             }
  3339.                             else
  3340.                             {
  3341.                                 this.itemLocation.X = this.position.X + (float)this.width * 0.5f + ((float)Main.itemTexture[this.inventory[this.selectedItem].type].Width * 0.5f - 4f) * (float)this.direction;
  3342.                                 this.itemLocation.Y = this.position.Y + 24f;
  3343.                                 float num6 = (float)this.itemAnimation / (float)this.itemAnimationMax * (float)Main.itemTexture[this.inventory[this.selectedItem].type].Width * (float)this.direction * this.inventory[this.selectedItem].scale * 1.2f - (float)(10 * this.direction);
  3344.                                 if (num6 > -4f && this.direction == -1)
  3345.                                 {
  3346.                                     num6 = -8f;
  3347.                                 }
  3348.                                 if (num6 < 4f && this.direction == 1)
  3349.                                 {
  3350.                                     num6 = 8f;
  3351.                                 }
  3352.                                 this.itemLocation.X = this.itemLocation.X - num6;
  3353.                                 this.itemRotation = 0.8f * (float)this.direction;
  3354.                             }
  3355.                         }
  3356.                         else
  3357.                         {
  3358.                             if (this.inventory[this.selectedItem].useStyle == 4)
  3359.                             {
  3360.                                 this.itemRotation = 0f;
  3361.                                 this.itemLocation.X = this.position.X + (float)this.width * 0.5f + ((float)Main.itemTexture[this.inventory[this.selectedItem].type].Width * 0.5f - 9f - this.itemRotation * 14f * (float)this.direction) * (float)this.direction;
  3362.                                 this.itemLocation.Y = this.position.Y + (float)Main.itemTexture[this.inventory[this.selectedItem].type].Height * 0.5f;
  3363.                             }
  3364.                             else
  3365.                             {
  3366.                                 if (this.inventory[this.selectedItem].useStyle == 5)
  3367.                                 {
  3368.                                     this.itemLocation.X = this.position.X + (float)this.width * 0.5f - (float)Main.itemTexture[this.inventory[this.selectedItem].type].Width * 0.5f - (float)(this.direction * 2);
  3369.                                     this.itemLocation.Y = this.position.Y + (float)this.height * 0.5f - (float)Main.itemTexture[this.inventory[this.selectedItem].type].Height * 0.5f;
  3370.                                 }
  3371.                             }
  3372.                         }
  3373.                     }
  3374.                 }
  3375.             }
  3376.             else
  3377.             {
  3378.                 if (this.inventory[this.selectedItem].holdStyle == 1)
  3379.                 {
  3380.                     this.itemLocation.X = this.position.X + (float)this.width * 0.5f + ((float)Main.itemTexture[this.inventory[this.selectedItem].type].Width * 0.5f + 4f) * (float)this.direction;
  3381.                     this.itemLocation.Y = this.position.Y + 24f;
  3382.                     this.itemRotation = 0f;
  3383.                 }
  3384.                 else
  3385.                 {
  3386.                     if (this.inventory[this.selectedItem].holdStyle == 2)
  3387.                     {
  3388.                         this.itemLocation.X = this.position.X + (float)this.width * 0.5f + (float)(6 * this.direction);
  3389.                         this.itemLocation.Y = this.position.Y + 16f;
  3390.                         this.itemRotation = 0.79f * (float)(-(float)this.direction);
  3391.                     }
  3392.                 }
  3393.             }
  3394.             if (this.inventory[this.selectedItem].type == 8)
  3395.             {
  3396.                 int maxValue = 20;
  3397.                 if (this.itemAnimation > 0)
  3398.                 {
  3399.                     maxValue = 7;
  3400.                 }
  3401.                 if (this.direction == -1)
  3402.                 {
  3403.                     if (Main.rand.Next(maxValue) == 0)
  3404.                     {
  3405.                         Vector2 arg_E6B_0 = new Vector2(this.itemLocation.X - 16f, this.itemLocation.Y - 14f);
  3406.                         int arg_E6B_1 = 4;
  3407.                         int arg_E6B_2 = 4;
  3408.                         int arg_E6B_3 = 6;
  3409.                         float arg_E6B_4 = 0f;
  3410.                         float arg_E6B_5 = 0f;
  3411.                         int arg_E6B_6 = 100;
  3412.                         Color newColor = default(Color);
  3413.                         Dust.NewDust(arg_E6B_0, arg_E6B_1, arg_E6B_2, arg_E6B_3, arg_E6B_4, arg_E6B_5, arg_E6B_6, newColor, 1f);
  3414.                     }
  3415.                     Lighting.addLight((int)((this.itemLocation.X - 16f + this.velocity.X) / 16f), (int)((this.itemLocation.Y - 14f) / 16f), 1f);
  3416.                 }
  3417.                 else
  3418.                 {
  3419.                     if (Main.rand.Next(maxValue) == 0)
  3420.                     {
  3421.                         Vector2 arg_F0F_0 = new Vector2(this.itemLocation.X + 6f, this.itemLocation.Y - 14f);
  3422.                         int arg_F0F_1 = 4;
  3423.                         int arg_F0F_2 = 4;
  3424.                         int arg_F0F_3 = 6;
  3425.                         float arg_F0F_4 = 0f;
  3426.                         float arg_F0F_5 = 0f;
  3427.                         int arg_F0F_6 = 100;
  3428.                         Color newColor = default(Color);
  3429.                         Dust.NewDust(arg_F0F_0, arg_F0F_1, arg_F0F_2, arg_F0F_3, arg_F0F_4, arg_F0F_5, arg_F0F_6, newColor, 1f);
  3430.                     }
  3431.                     Lighting.addLight((int)((this.itemLocation.X + 6f + this.velocity.X) / 16f), (int)((this.itemLocation.Y - 14f) / 16f), 1f);
  3432.                 }
  3433.             }
  3434.             else
  3435.             {
  3436.                 if (this.inventory[this.selectedItem].type == 105)
  3437.                 {
  3438.                     int maxValue2 = 20;
  3439.                     if (this.itemAnimation > 0)
  3440.                     {
  3441.                         maxValue2 = 7;
  3442.                     }
  3443.                     if (this.direction == -1)
  3444.                     {
  3445.                         if (Main.rand.Next(maxValue2) == 0)
  3446.                         {
  3447.                             Vector2 arg_FE8_0 = new Vector2(this.itemLocation.X - 12f, this.itemLocation.Y - 20f);
  3448.                             int arg_FE8_1 = 4;
  3449.                             int arg_FE8_2 = 4;
  3450.                             int arg_FE8_3 = 6;
  3451.                             float arg_FE8_4 = 0f;
  3452.                             float arg_FE8_5 = 0f;
  3453.                             int arg_FE8_6 = 100;
  3454.                             Color newColor = default(Color);
  3455.                             Dust.NewDust(arg_FE8_0, arg_FE8_1, arg_FE8_2, arg_FE8_3, arg_FE8_4, arg_FE8_5, arg_FE8_6, newColor, 1f);
  3456.                         }
  3457.                         Lighting.addLight((int)((this.itemLocation.X - 16f + this.velocity.X) / 16f), (int)((this.itemLocation.Y - 14f) / 16f), 1f);
  3458.                     }
  3459.                     else
  3460.                     {
  3461.                         if (Main.rand.Next(maxValue2) == 0)
  3462.                         {
  3463.                             Vector2 arg_108C_0 = new Vector2(this.itemLocation.X + 4f, this.itemLocation.Y - 20f);
  3464.                             int arg_108C_1 = 4;
  3465.                             int arg_108C_2 = 4;
  3466.                             int arg_108C_3 = 6;
  3467.                             float arg_108C_4 = 0f;
  3468.                             float arg_108C_5 = 0f;
  3469.                             int arg_108C_6 = 100;
  3470.                             Color newColor = default(Color);
  3471.                             Dust.NewDust(arg_108C_0, arg_108C_1, arg_108C_2, arg_108C_3, arg_108C_4, arg_108C_5, arg_108C_6, newColor, 1f);
  3472.                         }
  3473.                         Lighting.addLight((int)((this.itemLocation.X + 6f + this.velocity.X) / 16f), (int)((this.itemLocation.Y - 14f) / 16f), 1f);
  3474.                     }
  3475.                 }
  3476.                 else
  3477.                 {
  3478.                     if (this.inventory[this.selectedItem].type == 148)
  3479.                     {
  3480.                         int maxValue3 = 10;
  3481.                         if (this.itemAnimation > 0)
  3482.                         {
  3483.                             maxValue3 = 7;
  3484.                         }
  3485.                         if (this.direction == -1)
  3486.                         {
  3487.                             if (Main.rand.Next(maxValue3) == 0)
  3488.                             {
  3489.                                 Vector2 arg_1169_0 = new Vector2(this.itemLocation.X - 12f, this.itemLocation.Y - 20f);
  3490.                                 int arg_1169_1 = 4;
  3491.                                 int arg_1169_2 = 4;
  3492.                                 int arg_1169_3 = 29;
  3493.                                 float arg_1169_4 = 0f;
  3494.                                 float arg_1169_5 = 0f;
  3495.                                 int arg_1169_6 = 100;
  3496.                                 Color newColor = default(Color);
  3497.                                 Dust.NewDust(arg_1169_0, arg_1169_1, arg_1169_2, arg_1169_3, arg_1169_4, arg_1169_5, arg_1169_6, newColor, 1f);
  3498.                             }
  3499.                             Lighting.addLight((int)((this.itemLocation.X - 16f + this.velocity.X) / 16f), (int)((this.itemLocation.Y - 14f) / 16f), 1f);
  3500.                         }
  3501.                         else
  3502.                         {
  3503.                             if (Main.rand.Next(maxValue3) == 0)
  3504.                             {
  3505.                                 Vector2 arg_120E_0 = new Vector2(this.itemLocation.X + 4f, this.itemLocation.Y - 20f);
  3506.                                 int arg_120E_1 = 4;
  3507.                                 int arg_120E_2 = 4;
  3508.                                 int arg_120E_3 = 29;
  3509.                                 float arg_120E_4 = 0f;
  3510.                                 float arg_120E_5 = 0f;
  3511.                                 int arg_120E_6 = 100;
  3512.                                 Color newColor = default(Color);
  3513.                                 Dust.NewDust(arg_120E_0, arg_120E_1, arg_120E_2, arg_120E_3, arg_120E_4, arg_120E_5, arg_120E_6, newColor, 1f);
  3514.                             }
  3515.                             Lighting.addLight((int)((this.itemLocation.X + 6f + this.velocity.X) / 16f), (int)((this.itemLocation.Y - 14f) / 16f), 1f);
  3516.                         }
  3517.                     }
  3518.                 }
  3519.             }
  3520.             if (this.controlUseItem)
  3521.             {
  3522.                 this.releaseUseItem = false;
  3523.             }
  3524.             else
  3525.             {
  3526.                 this.releaseUseItem = true;
  3527.             }
  3528.             if (this.itemTime > 0)
  3529.             {
  3530.                 this.itemTime--;
  3531.             }
  3532.             if (i == Main.myPlayer)
  3533.             {
  3534.                 if (this.inventory[this.selectedItem].shoot > 0 && this.itemAnimation > 0 && this.itemTime == 0)
  3535.                 {
  3536.                     int num7 = this.inventory[this.selectedItem].shoot;
  3537.                     float num8 = this.inventory[this.selectedItem].shootSpeed;
  3538.                     bool flag2 = false;
  3539.                     int num9 = this.inventory[this.selectedItem].damage;
  3540.                     float num10 = this.inventory[this.selectedItem].knockBack;
  3541.                     if (num7 == 13 || num7 == 32)
  3542.                     {
  3543.                         this.grappling[0] = -1;
  3544.                         this.grapCount = 0;
  3545.                         for (int m = 0; m < 1000; m++)
  3546.                         {
  3547.                             if (Main.projectile[m].active && Main.projectile[m].owner == i && Main.projectile[m].type == 13)
  3548.                             {
  3549.                                 Main.projectile[m].Kill();
  3550.                             }
  3551.                         }
  3552.                     }
  3553.                     if (this.inventory[this.selectedItem].useAmmo > 0)
  3554.                     {
  3555.                         for (int n = 0; n < 44; n++)
  3556.                         {
  3557.                             if (this.inventory[n].ammo == this.inventory[this.selectedItem].useAmmo && this.inventory[n].stack > 0)
  3558.                             {
  3559.                                 if (this.inventory[n].shoot > 0)
  3560.                                 {
  3561.                                     num7 = this.inventory[n].shoot;
  3562.                                 }
  3563.                                 num8 += this.inventory[n].shootSpeed;
  3564.                                 num9 += this.inventory[n].damage;
  3565.                                 num10 += this.inventory[n].knockBack;
  3566.                                 this.inventory[n].stack--;
  3567.                                 if (this.inventory[n].stack <= 0)
  3568.                                 {
  3569.                                     this.inventory[n].active = false;
  3570.                                     this.inventory[n].name = "";
  3571.                                     this.inventory[n].type = 0;
  3572.                                 }
  3573.                                 flag2 = true;
  3574.                                 break;
  3575.                             }
  3576.                         }
  3577.                     }
  3578.                     else
  3579.                     {
  3580.                         flag2 = true;
  3581.                     }
  3582.                     if (num7 == 9 && (double)this.position.Y > Main.worldSurface * 16.0 + (double)(Main.screenHeight / 2))
  3583.                     {
  3584.                         flag2 = false;
  3585.                     }
  3586.                     if (flag2)
  3587.                     {
  3588.                         if (num7 == 1 && this.inventory[this.selectedItem].type == 120)
  3589.                         {
  3590.                             num7 = 2;
  3591.                         }
  3592.                         this.itemTime = this.inventory[this.selectedItem].useTime;
  3593.                         if ((float)Main.mouseState.X + Main.screenPosition.X > this.position.X + (float)this.width * 0.5f)
  3594.                         {
  3595.                             this.direction = 1;
  3596.                         }
  3597.                         else
  3598.                         {
  3599.                             this.direction = -1;
  3600.                         }
  3601.                         Vector2 vector = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
  3602.                         if (num7 == 9)
  3603.                         {
  3604.                             vector = new Vector2(this.position.X + (float)this.width * 0.5f + (float)(Main.rand.Next(601) * -(float)this.direction), this.position.Y + (float)this.height * 0.5f - 300f - (float)Main.rand.Next(100));
  3605.                             num10 = 0f;
  3606.                         }
  3607.                         float num11 = (float)Main.mouseState.X + Main.screenPosition.X - vector.X;
  3608.                         float num12 = (float)Main.mouseState.Y + Main.screenPosition.Y - vector.Y;
  3609.                         float num13 = (float)Math.Sqrt((double)(num11 * num11 + num12 * num12));
  3610.                         num13 = num8 / num13;
  3611.                         num11 *= num13;
  3612.                         num12 *= num13;
  3613.                         if (num7 == 12)
  3614.                         {
  3615.                             vector.X += num11 * 3f;
  3616.                             vector.Y += num12 * 3f;
  3617.                         }
  3618.                         if (this.inventory[this.selectedItem].useStyle == 5)
  3619.                         {
  3620.                             this.itemRotation = (float)Math.Atan2((double)(num12 * (float)this.direction), (double)(num11 * (float)this.direction));
  3621.                             NetMessage.SendData(13, -1, -1, "", this.whoAmi, 0f, 0f, 0f);
  3622.                             NetMessage.SendData(41, -1, -1, "", this.whoAmi, 0f, 0f, 0f);
  3623.                         }
  3624.                         if (num7 == 17)
  3625.                         {
  3626.                             vector.X = (float)Main.mouseState.X + Main.screenPosition.X;
  3627.                             vector.Y = (float)Main.mouseState.Y + Main.screenPosition.Y;
  3628.                         }
  3629.                         Projectile.NewProjectile(vector.X, vector.Y, num11, num12, num7, num9, num10, i);
  3630.                     }
  3631.                     else
  3632.                     {
  3633.                         if (this.inventory[this.selectedItem].useStyle == 5)
  3634.                         {
  3635.                             this.itemRotation = 0f;
  3636.                             NetMessage.SendData(41, -1, -1, "", this.whoAmi, 0f, 0f, 0f);
  3637.                         }
  3638.                     }
  3639.                 }
  3640.                 if (this.inventory[this.selectedItem].type >= 205 && this.inventory[this.selectedItem].type <= 207 && this.position.X / 16f - (float)Player.tileRangeX - (float)this.inventory[this.selectedItem].tileBoost <= (float)Player.tileTargetX && (this.position.X + (float)this.width) / 16f + (float)Player.tileRangeX + (float)this.inventory[this.selectedItem].tileBoost - 1f >= (float)Player.tileTargetX && this.position.Y / 16f - (float)Player.tileRangeY - (float)this.inventory[this.selectedItem].tileBoost <= (float)Player.tileTargetY && (this.position.Y + (float)this.height) / 16f + (float)Player.tileRangeY + (float)this.inventory[this.selectedItem].tileBoost - 2f >= (float)Player.tileTargetY)
  3641.                 {
  3642.                     this.showItemIcon = true;
  3643.                     if (this.itemTime == 0 && this.itemAnimation > 0 && this.controlUseItem)
  3644.                     {
  3645.                         if (this.inventory[this.selectedItem].type == 205)
  3646.                         {
  3647.                             bool lava = Main.tile[Player.tileTargetX, Player.tileTargetY].lava;
  3648.                             int num14 = 0;
  3649.                             for (int num15 = Player.tileTargetX - 1; num15 <= Player.tileTargetX + 1; num15++)
  3650.                             {
  3651.                                 for (int num16 = Player.tileTargetY - 1; num16 <= Player.tileTargetY + 1; num16++)
  3652.                                 {
  3653.                                     if (Main.tile[num15, num16].lava == lava)
  3654.                                     {
  3655.                                         num14 += (int)Main.tile[num15, num16].liquid;
  3656.                                     }
  3657.                                 }
  3658.                             }
  3659.                             if (Main.tile[Player.tileTargetX, Player.tileTargetY].liquid > 0 && num14 > 100)
  3660.                             {
  3661.                                 bool lava2 = Main.tile[Player.tileTargetX, Player.tileTargetY].lava;
  3662.                                 if (!Main.tile[Player.tileTargetX, Player.tileTargetY].lava)
  3663.                                 {
  3664.                                     this.inventory[this.selectedItem].SetDefaults(206);
  3665.                                 }
  3666.                                 else
  3667.                                 {
  3668.                                     this.inventory[this.selectedItem].SetDefaults(207);
  3669.                                 }
  3670.                                 Main.PlaySound(19, (int)this.position.X, (int)this.position.Y, 1);
  3671.                                 this.itemTime = this.inventory[this.selectedItem].useTime;
  3672.                                 int num17 = (int)Main.tile[Player.tileTargetX, Player.tileTargetY].liquid;
  3673.                                 Main.tile[Player.tileTargetX, Player.tileTargetY].liquid = 0;
  3674.                                 Main.tile[Player.tileTargetX, Player.tileTargetY].lava = false;
  3675.                                 WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY, false);
  3676.                                 if (Main.netMode == 1)
  3677.                                 {
  3678.                                     NetMessage.sendWater(Player.tileTargetX, Player.tileTargetY);
  3679.                                 }
  3680.                                 else
  3681.                                 {
  3682.                                     Liquid.AddWater(Player.tileTargetX, Player.tileTargetY);
  3683.                                 }
  3684.                                 for (int num18 = Player.tileTargetX - 1; num18 <= Player.tileTargetX + 1; num18++)
  3685.                                 {
  3686.                                     for (int num19 = Player.tileTargetY - 1; num19 <= Player.tileTargetY + 1; num19++)
  3687.                                     {
  3688.                                         if (num17 < 256 && Main.tile[num18, num19].lava == lava)
  3689.                                         {
  3690.                                             int num20 = (int)Main.tile[num18, num19].liquid;
  3691.                                             if (num20 + num17 > 255)
  3692.                                             {
  3693.                                                 num20 = 255 - num17;
  3694.                                             }
  3695.                                             num17 += num20;
  3696.                                             Tile expr_1B85 = Main.tile[num18, num19];
  3697.                                             expr_1B85.liquid -= (byte)num20;
  3698.                                             Main.tile[num18, num19].lava = lava2;
  3699.                                             if (Main.tile[num18, num19].liquid == 0)
  3700.                                             {
  3701.                                                 Main.tile[num18, num19].lava = false;
  3702.                                             }
  3703.                                             WorldGen.SquareTileFrame(num18, num19, false);
  3704.                                             if (Main.netMode == 1)
  3705.                                             {
  3706.                                                 NetMessage.sendWater(num18, num19);
  3707.                                             }
  3708.                                             else
  3709.                                             {
  3710.                                                 Liquid.AddWater(num18, num19);
  3711.                                             }
  3712.                                         }
  3713.                                     }
  3714.                                 }
  3715.                             }
  3716.                         }
  3717.                         else
  3718.                         {
  3719.                             if (Main.tile[Player.tileTargetX, Player.tileTargetY].liquid < 200 && (!Main.tile[Player.tileTargetX, Player.tileTargetY].active || !Main.tileSolid[(int)Main.tile[Player.tileTargetX, Player.tileTargetY].type] || !Main.tileSolidTop[(int)Main.tile[Player.tileTargetX, Player.tileTargetY].type]))
  3720.                             {
  3721.                                 if (this.inventory[this.selectedItem].type == 207)
  3722.                                 {
  3723.                                     if (Main.tile[Player.tileTargetX, Player.tileTargetY].liquid == 0 || Main.tile[Player.tileTargetX, Player.tileTargetY].lava)
  3724.                                     {
  3725.                                         Main.PlaySound(19, (int)this.position.X, (int)this.position.Y, 1);
  3726.                                         Main.tile[Player.tileTargetX, Player.tileTargetY].lava = true;
  3727.                                         Main.tile[Player.tileTargetX, Player.tileTargetY].liquid = 255;
  3728.                                         WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY, true);
  3729.                                         this.inventory[this.selectedItem].SetDefaults(205);
  3730.                                         this.itemTime = this.inventory[this.selectedItem].useTime;
  3731.                                         if (Main.netMode == 1)
  3732.                                         {
  3733.                                             NetMessage.sendWater(Player.tileTargetX, Player.tileTargetY);
  3734.                                         }
  3735.                                     }
  3736.                                 }
  3737.                                 else
  3738.                                 {
  3739.                                     if (Main.tile[Player.tileTargetX, Player.tileTargetY].liquid == 0 || !Main.tile[Player.tileTargetX, Player.tileTargetY].lava)
  3740.                                     {
  3741.                                         Main.PlaySound(19, (int)this.position.X, (int)this.position.Y, 1);
  3742.                                         Main.tile[Player.tileTargetX, Player.tileTargetY].lava = false;
  3743.                                         Main.tile[Player.tileTargetX, Player.tileTargetY].liquid = 255;
  3744.                                         WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY, true);
  3745.                                         this.inventory[this.selectedItem].SetDefaults(205);
  3746.                                         this.itemTime = this.inventory[this.selectedItem].useTime;
  3747.                                         if (Main.netMode == 1)
  3748.                                         {
  3749.                                             NetMessage.sendWater(Player.tileTargetX, Player.tileTargetY);
  3750.                                         }
  3751.                                     }
  3752.                                 }
  3753.                             }
  3754.                         }
  3755.                     }
  3756.                 }
  3757.                 if ((this.inventory[this.selectedItem].pick > 0 || this.inventory[this.selectedItem].axe > 0 || this.inventory[this.selectedItem].hammer > 0) && this.position.X / 16f - (float)Player.tileRangeX - (float)this.inventory[this.selectedItem].tileBoost <= (float)Player.tileTargetX && (this.position.X + (float)this.width) / 16f + (float)Player.tileRangeX + (float)this.inventory[this.selectedItem].tileBoost - 1f >= (float)Player.tileTargetX && this.position.Y / 16f - (float)Player.tileRangeY - (float)this.inventory[this.selectedItem].tileBoost <= (float)Player.tileTargetY && (this.position.Y + (float)this.height) / 16f + (float)Player.tileRangeY + (float)this.inventory[this.selectedItem].tileBoost - 2f >= (float)Player.tileTargetY)
  3758.                 {
  3759.                     this.showItemIcon = true;
  3760.                     if (Main.tile[Player.tileTargetX, Player.tileTargetY].active && this.itemTime == 0 && this.itemAnimation > 0 && this.controlUseItem)
  3761.                     {
  3762.                         if (this.hitTileX != Player.tileTargetX || this.hitTileY != Player.tileTargetY)
  3763.                         {
  3764.                             this.hitTile = 0;
  3765.                             this.hitTileX = Player.tileTargetX;
  3766.                             this.hitTileY = Player.tileTargetY;
  3767.                         }
  3768.                         if (Main.tileNoFail[(int)Main.tile[Player.tileTargetX, Player.tileTargetY].type])
  3769.                         {
  3770.                             this.hitTile = 100;
  3771.                         }
  3772.                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].type != 27)
  3773.                         {
  3774.                             if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 4 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 10 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 11 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 12 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 13 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 14 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 15 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 16 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 17 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 18 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 19 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 21 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 26 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 28 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 29 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 31 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 33 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 34 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 35 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 36 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 42 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 48 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 49 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 50 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 54 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 55 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 77 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 78 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 79)
  3775.                             {
  3776.                                 if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 48)
  3777.                                 {
  3778.                                     this.hitTile += this.inventory[this.selectedItem].hammer / 3;
  3779.                                 }
  3780.                                 else
  3781.                                 {
  3782.                                     this.hitTile += this.inventory[this.selectedItem].hammer;
  3783.                                 }
  3784.                                 if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 77 && this.inventory[this.selectedItem].hammer < 60)
  3785.                                 {
  3786.                                     this.hitTile = 0;
  3787.                                 }
  3788.                                 if (this.inventory[this.selectedItem].hammer > 0)
  3789.                                 {
  3790.                                     if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 26)
  3791.                                     {
  3792.                                         this.Hurt(this.statLife / 2, -this.direction, false, false);
  3793.                                         WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY, true, false, false);
  3794.                                         if (Main.netMode == 1)
  3795.                                         {
  3796.                                             NetMessage.SendData(17, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, 1f);
  3797.                                         }
  3798.                                     }
  3799.                                     else
  3800.                                     {
  3801.                                         if (this.hitTile >= 100)
  3802.                                         {
  3803.                                             if (Main.netMode == 1 && Main.tile[Player.tileTargetX, Player.tileTargetY].type == 21)
  3804.                                             {
  3805.                                                 WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY, true, false, false);
  3806.                                                 NetMessage.SendData(17, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, 1f);
  3807.                                                 NetMessage.SendData(34, -1, -1, "", Player.tileTargetX, (float)Player.tileTargetY, 0f, 0f);
  3808.                                             }
  3809.                                             else
  3810.                                             {
  3811.                                                 this.hitTile = 0;
  3812.                                                 WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY, false, false, false);
  3813.                                                 if (Main.netMode == 1)
  3814.                                                 {
  3815.                                                     NetMessage.SendData(17, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f);
  3816.                                                 }
  3817.                                             }
  3818.                                         }
  3819.                                         else
  3820.                                         {
  3821.                                             WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY, true, false, false);
  3822.                                             if (Main.netMode == 1)
  3823.                                             {
  3824.                                                 NetMessage.SendData(17, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, 1f);
  3825.                                             }
  3826.                                         }
  3827.                                     }
  3828.                                     this.itemTime = this.inventory[this.selectedItem].useTime;
  3829.                                 }
  3830.                             }
  3831.                             else
  3832.                             {
  3833.                                 if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 5 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 30 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 72)
  3834.                                 {
  3835.                                     if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 30)
  3836.                                     {
  3837.                                         this.hitTile += this.inventory[this.selectedItem].axe * 5;
  3838.                                     }
  3839.                                     else
  3840.                                     {
  3841.                                         this.hitTile += this.inventory[this.selectedItem].axe;
  3842.                                     }
  3843.                                     if (this.inventory[this.selectedItem].axe > 0)
  3844.                                     {
  3845.                                         if (this.hitTile >= 100)
  3846.                                         {
  3847.                                             this.hitTile = 0;
  3848.                                             WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY, false, false, false);
  3849.                                             if (Main.netMode == 1)
  3850.                                             {
  3851.                                                 NetMessage.SendData(17, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f);
  3852.                                             }
  3853.                                         }
  3854.                                         else
  3855.                                         {
  3856.                                             WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY, true, false, false);
  3857.                                             if (Main.netMode == 1)
  3858.                                             {
  3859.                                                 NetMessage.SendData(17, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, 1f);
  3860.                                             }
  3861.                                         }
  3862.                                         this.itemTime = this.inventory[this.selectedItem].useTime;
  3863.                                     }
  3864.                                 }
  3865.                                 else
  3866.                                 {
  3867.                                     if (this.inventory[this.selectedItem].pick > 0)
  3868.                                     {
  3869.                                         if (Main.tileDungeon[(int)Main.tile[Player.tileTargetX, Player.tileTargetY].type] || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 37 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 25 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 58)
  3870.                                         {
  3871.                                             this.hitTile += this.inventory[this.selectedItem].pick / 2;
  3872.                                         }
  3873.                                         else
  3874.                                         {
  3875.                                             this.hitTile += this.inventory[this.selectedItem].pick;
  3876.                                         }
  3877.                                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 25 && this.inventory[this.selectedItem].pick < 65)
  3878.                                         {
  3879.                                             this.hitTile = 0;
  3880.                                         }
  3881.                                         else
  3882.                                         {
  3883.                                             if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 37 && this.inventory[this.selectedItem].pick < 55)
  3884.                                             {
  3885.                                                 this.hitTile = 0;
  3886.                                             }
  3887.                                             else
  3888.                                             {
  3889.                                                 if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 56 && this.inventory[this.selectedItem].pick < 65)
  3890.                                                 {
  3891.                                                     this.hitTile = 0;
  3892.                                                 }
  3893.                                                 else
  3894.                                                 {
  3895.                                                     if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 58 && this.inventory[this.selectedItem].pick < 65)
  3896.                                                     {
  3897.                                                         this.hitTile = 0;
  3898.                                                     }
  3899.                                                 }
  3900.                                             }
  3901.                                         }
  3902.                                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 0 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 40 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 53 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 59)
  3903.                                         {
  3904.                                             this.hitTile += this.inventory[this.selectedItem].pick;
  3905.                                         }
  3906.                                         if (this.hitTile >= 100)
  3907.                                         {
  3908.                                             this.hitTile = 0;
  3909.                                             WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY, false, false, false);
  3910.                                             if (Main.netMode == 1)
  3911.                                             {
  3912.                                                 NetMessage.SendData(17, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f);
  3913.                                             }
  3914.                                         }
  3915.                                         else
  3916.                                         {
  3917.                                             WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY, true, false, false);
  3918.                                             if (Main.netMode == 1)
  3919.                                             {
  3920.                                                 NetMessage.SendData(17, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, 1f);
  3921.                                             }
  3922.                                         }
  3923.                                         this.itemTime = this.inventory[this.selectedItem].useTime;
  3924.                                     }
  3925.                                 }
  3926.                             }
  3927.                         }
  3928.                     }
  3929.                     if (Main.tile[Player.tileTargetX, Player.tileTargetY].wall > 0 && this.itemTime == 0 && this.itemAnimation > 0 && this.controlUseItem && this.inventory[this.selectedItem].hammer > 0)
  3930.                     {
  3931.                         bool flag3 = true;
  3932.                         if (!Main.wallHouse[(int)Main.tile[Player.tileTargetX, Player.tileTargetY].wall])
  3933.                         {
  3934.                             flag3 = false;
  3935.                             for (int num21 = Player.tileTargetX - 1; num21 < Player.tileTargetX + 2; num21++)
  3936.                             {
  3937.                                 for (int num22 = Player.tileTargetY - 1; num22 < Player.tileTargetY + 2; num22++)
  3938.                                 {
  3939.                                     if (Main.tile[num21, num22].wall != Main.tile[Player.tileTargetX, Player.tileTargetY].wall)
  3940.                                     {
  3941.                                         flag3 = true;
  3942.                                         break;
  3943.                                     }
  3944.                                 }
  3945.                             }
  3946.                         }
  3947.                         if (flag3)
  3948.                         {
  3949.                             if (this.hitTileX != Player.tileTargetX || this.hitTileY != Player.tileTargetY)
  3950.                             {
  3951.                                 this.hitTile = 0;
  3952.                                 this.hitTileX = Player.tileTargetX;
  3953.                                 this.hitTileY = Player.tileTargetY;
  3954.                             }
  3955.                             this.hitTile += this.inventory[this.selectedItem].hammer;
  3956.                             if (this.hitTile >= 100)
  3957.                             {
  3958.                                 this.hitTile = 0;
  3959.                                 WorldGen.KillWall(Player.tileTargetX, Player.tileTargetY, false);
  3960.                                 if (Main.netMode == 1)
  3961.                                 {
  3962.                                     NetMessage.SendData(17, -1, -1, "", 2, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f);
  3963.                                 }
  3964.                             }
  3965.                             else
  3966.                             {
  3967.                                 WorldGen.KillWall(Player.tileTargetX, Player.tileTargetY, true);
  3968.                                 if (Main.netMode == 1)
  3969.                                 {
  3970.                                     NetMessage.SendData(17, -1, -1, "", 2, (float)Player.tileTargetX, (float)Player.tileTargetY, 1f);
  3971.                                 }
  3972.                             }
  3973.                             this.itemTime = this.inventory[this.selectedItem].useTime;
  3974.                         }
  3975.                     }
  3976.                 }
  3977.                 if (this.inventory[this.selectedItem].type == 29 && this.itemAnimation > 0 && this.statLifeMax < 400 && this.itemTime == 0)
  3978.                 {
  3979.                     this.itemTime = this.inventory[this.selectedItem].useTime;
  3980.                     this.statLifeMax += 20;
  3981.                     this.statLife += 20;
  3982.                     if (Main.myPlayer == this.whoAmi)
  3983.                     {
  3984.                         this.HealEffect(20);
  3985.                     }
  3986.                 }
  3987.                 if (this.inventory[this.selectedItem].type == 109 && this.itemAnimation > 0 && this.statManaMax < 200 && this.itemTime == 0)
  3988.                 {
  3989.                     this.itemTime = this.inventory[this.selectedItem].useTime;
  3990.                     this.statManaMax += 20;
  3991.                     this.statMana += 20;
  3992.                     if (Main.myPlayer == this.whoAmi)
  3993.                     {
  3994.                         this.ManaEffect(20);
  3995.                     }
  3996.                 }
  3997.                 if (this.inventory[this.selectedItem].createTile >= 0 && this.position.X / 16f - (float)Player.tileRangeX - (float)this.inventory[this.selectedItem].tileBoost <= (float)Player.tileTargetX && (this.position.X + (float)this.width) / 16f + (float)Player.tileRangeX + (float)this.inventory[this.selectedItem].tileBoost - 1f >= (float)Player.tileTargetX && this.position.Y / 16f - (float)Player.tileRangeY - (float)this.inventory[this.selectedItem].tileBoost <= (float)Player.tileTargetY && (this.position.Y + (float)this.height) / 16f + (float)Player.tileRangeY + (float)this.inventory[this.selectedItem].tileBoost - 2f >= (float)Player.tileTargetY)
  3998.                 {
  3999.                     this.showItemIcon = true;
  4000.                     if ((!Main.tile[Player.tileTargetX, Player.tileTargetY].active || this.inventory[this.selectedItem].createTile == 23 || this.inventory[this.selectedItem].createTile == 2 || this.inventory[this.selectedItem].createTile == 60 || this.inventory[this.selectedItem].createTile == 70) && this.itemTime == 0 && this.itemAnimation > 0 && this.controlUseItem)
  4001.                     {
  4002.                         bool flag4 = false;
  4003.                         if (this.inventory[this.selectedItem].createTile == 23 || this.inventory[this.selectedItem].createTile == 2)
  4004.                         {
  4005.                             if (Main.tile[Player.tileTargetX, Player.tileTargetY].active && Main.tile[Player.tileTargetX, Player.tileTargetY].type == 0)
  4006.                             {
  4007.                                 flag4 = true;
  4008.                             }
  4009.                         }
  4010.                         else
  4011.                         {
  4012.                             if (this.inventory[this.selectedItem].createTile == 60 || this.inventory[this.selectedItem].createTile == 70)
  4013.                             {
  4014.                                 if (Main.tile[Player.tileTargetX, Player.tileTargetY].active && Main.tile[Player.tileTargetX, Player.tileTargetY].type == 59)
  4015.                                 {
  4016.                                     flag4 = true;
  4017.                                 }
  4018.                             }
  4019.                             else
  4020.                             {
  4021.                                 if (this.inventory[this.selectedItem].createTile == 4)
  4022.                                 {
  4023.                                     int num23 = (int)Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type;
  4024.                                     int num24 = (int)Main.tile[Player.tileTargetX - 1, Player.tileTargetY].type;
  4025.                                     int num25 = (int)Main.tile[Player.tileTargetX + 1, Player.tileTargetY].type;
  4026.                                     int num26 = (int)Main.tile[Player.tileTargetX - 1, Player.tileTargetY - 1].type;
  4027.                                     int num27 = (int)Main.tile[Player.tileTargetX + 1, Player.tileTargetY - 1].type;
  4028.                                     int num28 = (int)Main.tile[Player.tileTargetX - 1, Player.tileTargetY - 1].type;
  4029.                                     int num29 = (int)Main.tile[Player.tileTargetX + 1, Player.tileTargetY + 1].type;
  4030.                                     if (!Main.tile[Player.tileTargetX, Player.tileTargetY + 1].active)
  4031.                                     {
  4032.                                         num23 = -1;
  4033.                                     }
  4034.                                     if (!Main.tile[Player.tileTargetX - 1, Player.tileTargetY].active)
  4035.                                     {
  4036.                                         num24 = -1;
  4037.                                     }
  4038.                                     if (!Main.tile[Player.tileTargetX + 1, Player.tileTargetY].active)
  4039.                                     {
  4040.                                         num25 = -1;
  4041.                                     }
  4042.                                     if (!Main.tile[Player.tileTargetX - 1, Player.tileTargetY - 1].active)
  4043.                                     {
  4044.                                         num26 = -1;
  4045.                                     }
  4046.                                     if (!Main.tile[Player.tileTargetX + 1, Player.tileTargetY - 1].active)
  4047.                                     {
  4048.                                         num27 = -1;
  4049.                                     }
  4050.                                     if (!Main.tile[Player.tileTargetX - 1, Player.tileTargetY + 1].active)
  4051.                                     {
  4052.                                         num28 = -1;
  4053.                                     }
  4054.                                     if (!Main.tile[Player.tileTargetX + 1, Player.tileTargetY + 1].active)
  4055.                                     {
  4056.                                         num29 = -1;
  4057.                                     }
  4058.                                     if (num23 >= 0 && Main.tileSolid[num23] && !Main.tileNoAttach[num23])
  4059.                                     {
  4060.                                         flag4 = true;
  4061.                                     }
  4062.                                     else
  4063.                                     {
  4064.                                         if ((num24 >= 0 && Main.tileSolid[num24] && !Main.tileNoAttach[num24]) || (num24 == 5 && num26 == 5 && num28 == 5))
  4065.                                         {
  4066.                                             flag4 = true;
  4067.                                         }
  4068.                                         else
  4069.                                         {
  4070.                                             if ((num25 >= 0 && Main.tileSolid[num25] && !Main.tileNoAttach[num25]) || (num25 == 5 && num27 == 5 && num29 == 5))
  4071.                                             {
  4072.                                                 flag4 = true;
  4073.                                             }
  4074.                                         }
  4075.                                     }
  4076.                                 }
  4077.                                 else
  4078.                                 {
  4079.                                     if (this.inventory[this.selectedItem].createTile == 78)
  4080.                                     {
  4081.                                         if (Main.tile[Player.tileTargetX, Player.tileTargetY + 1].active && (Main.tileSolid[(int)Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type] || Main.tileTable[(int)Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type]))
  4082.                                         {
  4083.                                             flag4 = true;
  4084.                                         }
  4085.                                     }
  4086.                                     else
  4087.                                     {
  4088.                                         if (this.inventory[this.selectedItem].createTile == 13 || this.inventory[this.selectedItem].createTile == 29 || this.inventory[this.selectedItem].createTile == 33 || this.inventory[this.selectedItem].createTile == 49)
  4089.                                         {
  4090.                                             if (Main.tile[Player.tileTargetX, Player.tileTargetY + 1].active && Main.tileTable[(int)Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type])
  4091.                                             {
  4092.                                                 flag4 = true;
  4093.                                             }
  4094.                                         }
  4095.                                         else
  4096.                                         {
  4097.                                             if (this.inventory[this.selectedItem].createTile == 51)
  4098.                                             {
  4099.                                                 if (Main.tile[Player.tileTargetX + 1, Player.tileTargetY].active || Main.tile[Player.tileTargetX + 1, Player.tileTargetY].wall > 0 || Main.tile[Player.tileTargetX - 1, Player.tileTargetY].active || Main.tile[Player.tileTargetX - 1, Player.tileTargetY].wall > 0 || Main.tile[Player.tileTargetX, Player.tileTargetY + 1].active || Main.tile[Player.tileTargetX, Player.tileTargetY + 1].wall > 0 || Main.tile[Player.tileTargetX, Player.tileTargetY - 1].active || Main.tile[Player.tileTargetX, Player.tileTargetY - 1].wall > 0)
  4100.                                                 {
  4101.                                                     flag4 = true;
  4102.                                                 }
  4103.                                             }
  4104.                                             else
  4105.                                             {
  4106.                                                 if ((Main.tile[Player.tileTargetX + 1, Player.tileTargetY].active && Main.tileSolid[(int)Main.tile[Player.tileTargetX + 1, Player.tileTargetY].type]) || (Main.tile[Player.tileTargetX + 1, Player.tileTargetY].wall > 0 || (Main.tile[Player.tileTargetX - 1, Player.tileTargetY].active && Main.tileSolid[(int)Main.tile[Player.tileTargetX - 1, Player.tileTargetY].type])) || (Main.tile[Player.tileTargetX - 1, Player.tileTargetY].wall > 0 || (Main.tile[Player.tileTargetX, Player.tileTargetY + 1].active && Main.tileSolid[(int)Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type])) || (Main.tile[Player.tileTargetX, Player.tileTargetY + 1].wall > 0 || (Main.tile[Player.tileTargetX, Player.tileTargetY - 1].active && Main.tileSolid[(int)Main.tile[Player.tileTargetX, Player.tileTargetY - 1].type])) || Main.tile[Player.tileTargetX, Player.tileTargetY - 1].wall > 0)
  4107.                                                 {
  4108.                                                     flag4 = true;
  4109.                                                 }
  4110.                                             }
  4111.                                         }
  4112.                                     }
  4113.                                 }
  4114.                             }
  4115.                         }
  4116.                         if (flag4 && WorldGen.PlaceTile(Player.tileTargetX, Player.tileTargetY, this.inventory[this.selectedItem].createTile, false, false, this.whoAmi))
  4117.                         {
  4118.                             this.itemTime = this.inventory[this.selectedItem].useTime;
  4119.                             if (Main.netMode == 1)
  4120.                             {
  4121.                                 NetMessage.SendData(17, -1, -1, "", 1, (float)Player.tileTargetX, (float)Player.tileTargetY, (float)this.inventory[this.selectedItem].createTile);
  4122.                             }
  4123.                             if (this.inventory[this.selectedItem].createTile == 15)
  4124.                             {
  4125.                                 if (this.direction == 1)
  4126.                                 {
  4127.                                     Tile expr_3734 = Main.tile[Player.tileTargetX, Player.tileTargetY];
  4128.                                     expr_3734.frameX += 18;
  4129.                                     Tile expr_3759 = Main.tile[Player.tileTargetX, Player.tileTargetY - 1];
  4130.                                     expr_3759.frameX += 18;
  4131.                                 }
  4132.                                 if (Main.netMode == 1)
  4133.                                 {
  4134.                                     NetMessage.SendTileSquare(-1, Player.tileTargetX - 1, Player.tileTargetY - 1, 3);
  4135.                                 }
  4136.                             }
  4137.                             else
  4138.                             {
  4139.                                 if (this.inventory[this.selectedItem].createTile == 79 && Main.netMode == 1)
  4140.                                 {
  4141.                                     NetMessage.SendTileSquare(-1, Player.tileTargetX, Player.tileTargetY, 5);
  4142.                                 }
  4143.                             }
  4144.                         }
  4145.                     }
  4146.                 }
  4147.                 if (this.inventory[this.selectedItem].createWall >= 0)
  4148.                 {
  4149.                     Player.tileTargetX = (int)(((float)Main.mouseState.X + Main.screenPosition.X) / 16f);
  4150.                     Player.tileTargetY = (int)(((float)Main.mouseState.Y + Main.screenPosition.Y) / 16f);
  4151.                     if (this.position.X / 16f - (float)Player.tileRangeX - (float)this.inventory[this.selectedItem].tileBoost <= (float)Player.tileTargetX && (this.position.X + (float)this.width) / 16f + (float)Player.tileRangeX + (float)this.inventory[this.selectedItem].tileBoost - 1f >= (float)Player.tileTargetX && this.position.Y / 16f - (float)Player.tileRangeY - (float)this.inventory[this.selectedItem].tileBoost <= (float)Player.tileTargetY && (this.position.Y + (float)this.height) / 16f + (float)Player.tileRangeY + (float)this.inventory[this.selectedItem].tileBoost - 2f >= (float)Player.tileTargetY)
  4152.                     {
  4153.                         this.showItemIcon = true;
  4154.                         if (this.itemTime == 0 && this.itemAnimation > 0 && this.controlUseItem && (Main.tile[Player.tileTargetX + 1, Player.tileTargetY].active || Main.tile[Player.tileTargetX + 1, Player.tileTargetY].wall > 0 || Main.tile[Player.tileTargetX - 1, Player.tileTargetY].active || Main.tile[Player.tileTargetX - 1, Player.tileTargetY].wall > 0 || Main.tile[Player.tileTargetX, Player.tileTargetY + 1].active || Main.tile[Player.tileTargetX, Player.tileTargetY + 1].wall > 0 || Main.tile[Player.tileTargetX, Player.tileTargetY - 1].active || Main.tile[Player.tileTargetX, Player.tileTargetY - 1].wall > 0) && (int)Main.tile[Player.tileTargetX, Player.tileTargetY].wall != this.inventory[this.selectedItem].createWall)
  4155.                         {
  4156.                             WorldGen.PlaceWall(Player.tileTargetX, Player.tileTargetY, this.inventory[this.selectedItem].createWall, false);
  4157.                             if ((int)Main.tile[Player.tileTargetX, Player.tileTargetY].wall == this.inventory[this.selectedItem].createWall)
  4158.                             {
  4159.                                 this.itemTime = this.inventory[this.selectedItem].useTime;
  4160.                                 if (Main.netMode == 1)
  4161.                                 {
  4162.                                     NetMessage.SendData(17, -1, -1, "", 3, (float)Player.tileTargetX, (float)Player.tileTargetY, (float)this.inventory[this.selectedItem].createWall);
  4163.                                 }
  4164.                             }
  4165.                         }
  4166.                     }
  4167.                 }
  4168.             }
  4169.             if (this.inventory[this.selectedItem].damage >= 0 && this.inventory[this.selectedItem].type > 0 && !this.inventory[this.selectedItem].noMelee && this.itemAnimation > 0)
  4170.             {
  4171.                 bool flag5 = false;
  4172.                 Rectangle rectangle = new Rectangle((int)this.itemLocation.X, (int)this.itemLocation.Y, Main.itemTexture[this.inventory[this.selectedItem].type].Width, Main.itemTexture[this.inventory[this.selectedItem].type].Height);
  4173.                 rectangle.Width = (int)((float)rectangle.Width * this.inventory[this.selectedItem].scale);
  4174.                 rectangle.Height = (int)((float)rectangle.Height * this.inventory[this.selectedItem].scale);
  4175.                 if (this.direction == -1)
  4176.                 {
  4177.                     rectangle.X -= rectangle.Width;
  4178.                 }
  4179.                 rectangle.Y -= rectangle.Height;
  4180.                 if (this.inventory[this.selectedItem].useStyle == 1)
  4181.                 {
  4182.                     if ((double)this.itemAnimation < (double)this.itemAnimationMax * 0.333)
  4183.                     {
  4184.                         if (this.direction == -1)
  4185.                         {
  4186.                             rectangle.X -= (int)((double)rectangle.Width * 1.4 - (double)rectangle.Width);
  4187.                         }
  4188.                         rectangle.Width = (int)((double)rectangle.Width * 1.4);
  4189.                         rectangle.Y += (int)((double)rectangle.Height * 0.5);
  4190.                         rectangle.Height = (int)((double)rectangle.Height * 1.1);
  4191.                     }
  4192.                     else
  4193.                     {
  4194.                         if ((double)this.itemAnimation >= (double)this.itemAnimationMax * 0.666)
  4195.                         {
  4196.                             if (this.direction == 1)
  4197.                             {
  4198.                                 rectangle.X -= (int)((double)rectangle.Width * 1.2);
  4199.                             }
  4200.                             rectangle.Width *= 2;
  4201.                             rectangle.Y -= (int)((double)rectangle.Height * 1.4 - (double)rectangle.Height);
  4202.                             rectangle.Height = (int)((double)rectangle.Height * 1.4);
  4203.                         }
  4204.                     }
  4205.                 }
  4206.                 else
  4207.                 {
  4208.                     if (this.inventory[this.selectedItem].useStyle == 3)
  4209.                     {
  4210.                         if ((double)this.itemAnimation > (double)this.itemAnimationMax * 0.666)
  4211.                         {
  4212.                             flag5 = true;
  4213.                         }
  4214.                         else
  4215.                         {
  4216.                             if (this.direction == -1)
  4217.                             {
  4218.                                 rectangle.X -= (int)((double)rectangle.Width * 1.4 - (double)rectangle.Width);
  4219.                             }
  4220.                             rectangle.Width = (int)((double)rectangle.Width * 1.4);
  4221.                             rectangle.Y += (int)((double)rectangle.Height * 0.6);
  4222.                             rectangle.Height = (int)((double)rectangle.Height * 0.6);
  4223.                         }
  4224.                     }
  4225.                 }
  4226.                 if (!flag5)
  4227.                 {
  4228.                     if ((this.inventory[this.selectedItem].type == 44 || this.inventory[this.selectedItem].type == 45 || this.inventory[this.selectedItem].type == 46 || this.inventory[this.selectedItem].type == 103 || this.inventory[this.selectedItem].type == 104) && Main.rand.Next(15) == 0)
  4229.                     {
  4230.                         Vector2 arg_3F0E_0 = new Vector2((float)rectangle.X, (float)rectangle.Y);
  4231.                         int arg_3F0E_1 = rectangle.Width;
  4232.                         int arg_3F0E_2 = rectangle.Height;
  4233.                         int arg_3F0E_3 = 14;
  4234.                         float arg_3F0E_4 = (float)(this.direction * 2);
  4235.                         float arg_3F0E_5 = 0f;
  4236.                         int arg_3F0E_6 = 150;
  4237.                         Color newColor = default(Color);
  4238.                         Dust.NewDust(arg_3F0E_0, arg_3F0E_1, arg_3F0E_2, arg_3F0E_3, arg_3F0E_4, arg_3F0E_5, arg_3F0E_6, newColor, 1.3f);
  4239.                     }
  4240.                     if (this.inventory[this.selectedItem].type == 65)
  4241.                     {
  4242.                         if (Main.rand.Next(5) == 0)
  4243.                         {
  4244.                             Vector2 arg_3F7D_0 = new Vector2((float)rectangle.X, (float)rectangle.Y);
  4245.                             int arg_3F7D_1 = rectangle.Width;
  4246.                             int arg_3F7D_2 = rectangle.Height;
  4247.                             int arg_3F7D_3 = 15;
  4248.                             float arg_3F7D_4 = 0f;
  4249.                             float arg_3F7D_5 = 0f;
  4250.                             int arg_3F7D_6 = 150;
  4251.                             Color newColor = default(Color);
  4252.                             Dust.NewDust(arg_3F7D_0, arg_3F7D_1, arg_3F7D_2, arg_3F7D_3, arg_3F7D_4, arg_3F7D_5, arg_3F7D_6, newColor, 1.2f);
  4253.                         }
  4254.                         if (Main.rand.Next(10) == 0)
  4255.                         {
  4256.                             Gore.NewGore(new Vector2((float)rectangle.X, (float)rectangle.Y), default(Vector2), Main.rand.Next(16, 18));
  4257.                         }
  4258.                     }
  4259.                     if (this.inventory[this.selectedItem].type == 190 || this.inventory[this.selectedItem].type == 213)
  4260.                     {
  4261.                         Vector2 arg_4057_0 = new Vector2((float)rectangle.X, (float)rectangle.Y);
  4262.                         int arg_4057_1 = rectangle.Width;
  4263.                         int arg_4057_2 = rectangle.Height;
  4264.                         int arg_4057_3 = 40;
  4265.                         float arg_4057_4 = this.velocity.X * 0.2f + (float)(this.direction * 3);
  4266.                         float arg_4057_5 = this.velocity.Y * 0.2f;
  4267.                         int arg_4057_6 = 0;
  4268.                         Color newColor = default(Color);
  4269.                         int num30 = Dust.NewDust(arg_4057_0, arg_4057_1, arg_4057_2, arg_4057_3, arg_4057_4, arg_4057_5, arg_4057_6, newColor, 1.2f);
  4270.                         Main.dust[num30].noGravity = true;
  4271.                     }
  4272.                     if (this.inventory[this.selectedItem].type == 121)
  4273.                     {
  4274.                         for (int num31 = 0; num31 < 2; num31++)
  4275.                         {
  4276.                             Vector2 arg_40EE_0 = new Vector2((float)rectangle.X, (float)rectangle.Y);
  4277.                             int arg_40EE_1 = rectangle.Width;
  4278.                             int arg_40EE_2 = rectangle.Height;
  4279.                             int arg_40EE_3 = 6;
  4280.                             float arg_40EE_4 = this.velocity.X * 0.2f + (float)(this.direction * 3);
  4281.                             float arg_40EE_5 = this.velocity.Y * 0.2f;
  4282.                             int arg_40EE_6 = 100;
  4283.                             Color newColor = default(Color);
  4284.                             int num32 = Dust.NewDust(arg_40EE_0, arg_40EE_1, arg_40EE_2, arg_40EE_3, arg_40EE_4, arg_40EE_5, arg_40EE_6, newColor, 2.5f);
  4285.                             Main.dust[num32].noGravity = true;
  4286.                             Dust expr_4110_cp_0 = Main.dust[num32];
  4287.                             expr_4110_cp_0.velocity.X = expr_4110_cp_0.velocity.X * 2f;
  4288.                             Dust expr_412E_cp_0 = Main.dust[num32];
  4289.                             expr_412E_cp_0.velocity.Y = expr_412E_cp_0.velocity.Y * 2f;
  4290.                         }
  4291.                     }
  4292.                     if (this.inventory[this.selectedItem].type == 122 || this.inventory[this.selectedItem].type == 217)
  4293.                     {
  4294.                         Vector2 arg_41DD_0 = new Vector2((float)rectangle.X, (float)rectangle.Y);
  4295.                         int arg_41DD_1 = rectangle.Width;
  4296.                         int arg_41DD_2 = rectangle.Height;
  4297.                         int arg_41DD_3 = 6;
  4298.                         float arg_41DD_4 = this.velocity.X * 0.2f + (float)(this.direction * 3);
  4299.                         float arg_41DD_5 = this.velocity.Y * 0.2f;
  4300.                         int arg_41DD_6 = 100;
  4301.                         Color newColor = default(Color);
  4302.                         int num33 = Dust.NewDust(arg_41DD_0, arg_41DD_1, arg_41DD_2, arg_41DD_3, arg_41DD_4, arg_41DD_5, arg_41DD_6, newColor, 1.9f);
  4303.                         Main.dust[num33].noGravity = true;
  4304.                     }
  4305.                     if (this.inventory[this.selectedItem].type == 155)
  4306.                     {
  4307.                         Vector2 arg_4270_0 = new Vector2((float)rectangle.X, (float)rectangle.Y);
  4308.                         int arg_4270_1 = rectangle.Width;
  4309.                         int arg_4270_2 = rectangle.Height;
  4310.                         int arg_4270_3 = 29;
  4311.                         float arg_4270_4 = this.velocity.X * 0.2f + (float)(this.direction * 3);
  4312.                         float arg_4270_5 = this.velocity.Y * 0.2f;
  4313.                         int arg_4270_6 = 100;
  4314.                         Color newColor = default(Color);
  4315.                         int num34 = Dust.NewDust(arg_4270_0, arg_4270_1, arg_4270_2, arg_4270_3, arg_4270_4, arg_4270_5, arg_4270_6, newColor, 2f);
  4316.                         Main.dust[num34].noGravity = true;
  4317.                         Dust expr_4292_cp_0 = Main.dust[num34];
  4318.                         expr_4292_cp_0.velocity.X = expr_4292_cp_0.velocity.X / 2f;
  4319.                         Dust expr_42B0_cp_0 = Main.dust[num34];
  4320.                         expr_42B0_cp_0.velocity.Y = expr_42B0_cp_0.velocity.Y / 2f;
  4321.                     }
  4322.                     if (this.inventory[this.selectedItem].type >= 198 && this.inventory[this.selectedItem].type <= 203)
  4323.                     {
  4324.                         Lighting.addLight((int)((this.itemLocation.X + 6f + this.velocity.X) / 16f), (int)((this.itemLocation.Y - 14f) / 16f), 0.5f);
  4325.                     }
  4326.                     if (Main.myPlayer == i)
  4327.                     {
  4328.                         int num35 = rectangle.X / 16;
  4329.                         int num36 = (rectangle.X + rectangle.Width) / 16 + 1;
  4330.                         int num37 = rectangle.Y / 16;
  4331.                         int num38 = (rectangle.Y + rectangle.Height) / 16 + 1;
  4332.                         for (int num39 = num35; num39 < num36; num39++)
  4333.                         {
  4334.                             for (int num40 = num37; num40 < num38; num40++)
  4335.                             {
  4336.                                 if (Main.tile[num39, num40].type == 3 || Main.tile[num39, num40].type == 24 || Main.tile[num39, num40].type == 28 || Main.tile[num39, num40].type == 32 || Main.tile[num39, num40].type == 51 || Main.tile[num39, num40].type == 52 || Main.tile[num39, num40].type == 61 || Main.tile[num39, num40].type == 62 || Main.tile[num39, num40].type == 69 || Main.tile[num39, num40].type == 71 || Main.tile[num39, num40].type == 73 || Main.tile[num39, num40].type == 74)
  4337.                                 {
  4338.                                     WorldGen.KillTile(num39, num40, false, false, false);
  4339.                                     if (Main.netMode == 1)
  4340.                                     {
  4341.                                         NetMessage.SendData(17, -1, -1, "", 0, (float)num39, (float)num40, 0f);
  4342.                                     }
  4343.                                 }
  4344.                             }
  4345.                         }
  4346.                         for (int num41 = 0; num41 < 1000; num41++)
  4347.                         {
  4348.                             if (Main.npc[num41].active && Main.npc[num41].immune[i] == 0 && this.attackCD == 0 && !Main.npc[num41].friendly)
  4349.                             {
  4350.                                 Rectangle value = new Rectangle((int)Main.npc[num41].position.X, (int)Main.npc[num41].position.Y, Main.npc[num41].width, Main.npc[num41].height);
  4351.                                 if (rectangle.Intersects(value) && (Main.npc[num41].noTileCollide || Collision.CanHit(this.position, this.width, this.height, Main.npc[num41].position, Main.npc[num41].width, Main.npc[num41].height)))
  4352.                                 {
  4353.                                     Main.npc[num41].StrikeNPC(this.inventory[this.selectedItem].damage, this.inventory[this.selectedItem].knockBack, this.direction);
  4354.                                     if (Main.netMode == 1)
  4355.                                     {
  4356.                                         NetMessage.SendData(24, -1, -1, "", num41, (float)i, 0f, 0f);
  4357.                                     }
  4358.                                     Main.npc[num41].immune[i] = this.itemAnimation;
  4359.                                     this.attackCD = (int)((double)this.itemAnimationMax * 0.33);
  4360.                                 }
  4361.                             }
  4362.                         }
  4363.                         if (this.hostile)
  4364.                         {
  4365.                             for (int num42 = 0; num42 < 8; num42++)
  4366.                             {
  4367.                                 if (num42 != i && Main.player[num42].active && Main.player[num42].hostile && !Main.player[num42].immune && !Main.player[num42].dead && (Main.player[i].team == 0 || Main.player[i].team != Main.player[num42].team))
  4368.                                 {
  4369.                                     Rectangle value2 = new Rectangle((int)Main.player[num42].position.X, (int)Main.player[num42].position.Y, Main.player[num42].width, Main.player[num42].height);
  4370.                                     if (rectangle.Intersects(value2) && Collision.CanHit(this.position, this.width, this.height, Main.player[num42].position, Main.player[num42].width, Main.player[num42].height))
  4371.                                     {
  4372.                                         Main.player[num42].Hurt(this.inventory[this.selectedItem].damage, this.direction, true, false);
  4373.                                         if (Main.netMode != 0)
  4374.                                         {
  4375.                                             NetMessage.SendData(26, -1, -1, "", num42, (float)this.direction, (float)this.inventory[this.selectedItem].damage, 1f);
  4376.                                         }
  4377.                                         this.attackCD = (int)((double)this.itemAnimationMax * 0.33);
  4378.                                     }
  4379.                                 }
  4380.                             }
  4381.                         }
  4382.                     }
  4383.                 }
  4384.             }
  4385.             if (this.itemTime == 0 && this.itemAnimation > 0)
  4386.             {
  4387.                 if (this.inventory[this.selectedItem].healLife > 0)
  4388.                 {
  4389.                     this.statLife += this.inventory[this.selectedItem].healLife;
  4390.                     this.itemTime = this.inventory[this.selectedItem].useTime;
  4391.                     if (Main.myPlayer == this.whoAmi)
  4392.                     {
  4393.                         this.HealEffect(this.inventory[this.selectedItem].healLife);
  4394.                     }
  4395.                 }
  4396.                 if (this.inventory[this.selectedItem].healMana > 0)
  4397.                 {
  4398.                     this.statMana += this.inventory[this.selectedItem].healMana;
  4399.                     this.itemTime = this.inventory[this.selectedItem].useTime;
  4400.                     if (Main.myPlayer == this.whoAmi)
  4401.                     {
  4402.                         this.ManaEffect(this.inventory[this.selectedItem].healMana);
  4403.                     }
  4404.                 }
  4405.             }
  4406.             if (this.itemTime == 0 && this.itemAnimation > 0 && (this.inventory[this.selectedItem].type == 43 || this.inventory[this.selectedItem].type == 70))
  4407.             {
  4408.                 this.itemTime = this.inventory[this.selectedItem].useTime;
  4409.                 bool flag6 = false;
  4410.                 int num43 = 4;
  4411.                 if (this.inventory[this.selectedItem].type == 43)
  4412.                 {
  4413.                     num43 = 4;
  4414.                 }
  4415.                 else
  4416.                 {
  4417.                     if (this.inventory[this.selectedItem].type == 70)
  4418.                     {
  4419.                         num43 = 13;
  4420.                     }
  4421.                 }
  4422.                 for (int num44 = 0; num44 < 1000; num44++)
  4423.                 {
  4424.                     if (Main.npc[num44].active && Main.npc[num44].type == num43)
  4425.                     {
  4426.                         flag6 = true;
  4427.                         break;
  4428.                     }
  4429.                 }
  4430.                 if (flag6)
  4431.                 {
  4432.                     if (Main.myPlayer == this.whoAmi)
  4433.                     {
  4434.                         this.Hurt(this.statLife * (this.statDefense + 1), -this.direction, false, false);
  4435.                     }
  4436.                 }
  4437.                 else
  4438.                 {
  4439.                     if (this.inventory[this.selectedItem].type == 43)
  4440.                     {
  4441.                         if (!Main.dayTime)
  4442.                         {
  4443.                             Main.PlaySound(15, (int)this.position.X, (int)this.position.Y, 0);
  4444.                             if (Main.netMode != 1)
  4445.                             {
  4446.                                 NPC.SpawnOnPlayer(i, 4);
  4447.                             }
  4448.                         }
  4449.                     }
  4450.                     else
  4451.                     {
  4452.                         if (this.inventory[this.selectedItem].type == 70 && this.zoneEvil)
  4453.                         {
  4454.                             Main.PlaySound(15, (int)this.position.X, (int)this.position.Y, 0);
  4455.                             if (Main.netMode != 1)
  4456.                             {
  4457.                                 NPC.SpawnOnPlayer(i, 13);
  4458.                             }
  4459.                         }
  4460.                     }
  4461.                 }
  4462.             }
  4463.             if (this.inventory[this.selectedItem].type == 50 && this.itemAnimation > 0)
  4464.             {
  4465.                 if (Main.rand.Next(2) == 0)
  4466.                 {
  4467.                     Vector2 arg_4B43_0 = this.position;
  4468.                     int arg_4B43_1 = this.width;
  4469.                     int arg_4B43_2 = this.height;
  4470.                     int arg_4B43_3 = 15;
  4471.                     float arg_4B43_4 = 0f;
  4472.                     float arg_4B43_5 = 0f;
  4473.                     int arg_4B43_6 = 150;
  4474.                     Color newColor = default(Color);
  4475.                     Dust.NewDust(arg_4B43_0, arg_4B43_1, arg_4B43_2, arg_4B43_3, arg_4B43_4, arg_4B43_5, arg_4B43_6, newColor, 1.1f);
  4476.                 }
  4477.                 if (this.itemTime == 0)
  4478.                 {
  4479.                     this.itemTime = this.inventory[this.selectedItem].useTime;
  4480.                 }
  4481.                 else
  4482.                 {
  4483.                     if (this.itemTime == this.inventory[this.selectedItem].useTime / 2)
  4484.                     {
  4485.                         for (int num45 = 0; num45 < 70; num45++)
  4486.                         {
  4487.                             Vector2 arg_4BDC_0 = this.position;
  4488.                             int arg_4BDC_1 = this.width;
  4489.                             int arg_4BDC_2 = this.height;
  4490.                             int arg_4BDC_3 = 15;
  4491.                             float arg_4BDC_4 = this.velocity.X * 0.5f;
  4492.                             float arg_4BDC_5 = this.velocity.Y * 0.5f;
  4493.                             int arg_4BDC_6 = 150;
  4494.                             Color newColor = default(Color);
  4495.                             Dust.NewDust(arg_4BDC_0, arg_4BDC_1, arg_4BDC_2, arg_4BDC_3, arg_4BDC_4, arg_4BDC_5, arg_4BDC_6, newColor, 1.5f);
  4496.                         }
  4497.                         this.grappling[0] = -1;
  4498.                         this.grapCount = 0;
  4499.                         for (int num46 = 0; num46 < 1000; num46++)
  4500.                         {
  4501.                             if (Main.projectile[num46].active && Main.projectile[num46].owner == i && Main.projectile[num46].aiStyle == 7)
  4502.                             {
  4503.                                 Main.projectile[num46].Kill();
  4504.                             }
  4505.                         }
  4506.                         this.Spawn();
  4507.                         for (int num47 = 0; num47 < 70; num47++)
  4508.                         {
  4509.                             Vector2 arg_4C8B_0 = this.position;
  4510.                             int arg_4C8B_1 = this.width;
  4511.                             int arg_4C8B_2 = this.height;
  4512.                             int arg_4C8B_3 = 15;
  4513.                             float arg_4C8B_4 = 0f;
  4514.                             float arg_4C8B_5 = 0f;
  4515.                             int arg_4C8B_6 = 150;
  4516.                             Color newColor = default(Color);
  4517.                             Dust.NewDust(arg_4C8B_0, arg_4C8B_1, arg_4C8B_2, arg_4C8B_3, arg_4C8B_4, arg_4C8B_5, arg_4C8B_6, newColor, 1.5f);
  4518.                         }
  4519.                     }
  4520.                 }
  4521.             }
  4522.             if (i == Main.myPlayer)
  4523.             {
  4524.                 if (this.itemTime == this.inventory[this.selectedItem].useTime && this.inventory[this.selectedItem].consumable)
  4525.                 {
  4526.                     this.inventory[this.selectedItem].stack--;
  4527.                     if (this.inventory[this.selectedItem].stack <= 0)
  4528.                     {
  4529.                         this.itemTime = this.itemAnimation;
  4530.                     }
  4531.                 }
  4532.                 if (this.inventory[this.selectedItem].stack <= 0 && this.itemAnimation == 0)
  4533.                 {
  4534.                     this.inventory[this.selectedItem] = new Item();
  4535.                 }
  4536.             }
  4537.         }
  4538.         public Color GetImmuneAlpha(Color newColor)
  4539.         {
  4540.             float num = (float)(255 - this.immuneAlpha) / 255f;
  4541.             if (this.shadow > 0f)
  4542.             {
  4543.                 num *= 1f - this.shadow;
  4544.             }
  4545.             int r = (int)((float)newColor.R * num);
  4546.             int g = (int)((float)newColor.G * num);
  4547.             int b = (int)((float)newColor.B * num);
  4548.             int num2 = (int)((float)newColor.A * num);
  4549.             if (num2 < 0)
  4550.             {
  4551.                 num2 = 0;
  4552.             }
  4553.             if (num2 > 255)
  4554.             {
  4555.                 num2 = 255;
  4556.             }
  4557.             return new Color(r, g, b, num2);
  4558.         }
  4559.         public Color GetDeathAlpha(Color newColor)
  4560.         {
  4561.             int r = (int)newColor.R + (int)((double)this.immuneAlpha * 0.9);
  4562.             int g = (int)newColor.G + (int)((double)this.immuneAlpha * 0.5);
  4563.             int b = (int)newColor.B + (int)((double)this.immuneAlpha * 0.5);
  4564.             int num = (int)newColor.A + (int)((double)this.immuneAlpha * 0.4);
  4565.             if (num < 0)
  4566.             {
  4567.                 num = 0;
  4568.             }
  4569.             if (num > 255)
  4570.             {
  4571.                 num = 255;
  4572.             }
  4573.             return new Color(r, g, b, num);
  4574.         }
  4575.         public void DropItems()
  4576.         {
  4577.             for (int i = 0; i < 44; i++)
  4578.             {
  4579.                 if (this.inventory[i].type >= 71 && this.inventory[i].type <= 74)
  4580.                 {
  4581.                     int num = Item.NewItem((int)this.position.X, (int)this.position.Y, this.width, this.height, this.inventory[i].type, 1, false);
  4582.                     int num2 = this.inventory[i].stack / 2;
  4583.                     num2 = this.inventory[i].stack - num2;
  4584.                     this.inventory[i].stack -= num2;
  4585.                     if (this.inventory[i].stack <= 0)
  4586.                     {
  4587.                         this.inventory[i] = new Item();
  4588.                     }
  4589.                     Main.item[num].stack = num2;
  4590.                     Main.item[num].velocity.Y = (float)Main.rand.Next(-20, 1) * 0.2f;
  4591.                     Main.item[num].velocity.X = (float)Main.rand.Next(-20, 21) * 0.2f;
  4592.                     Main.item[num].noGrabDelay = 100;
  4593.                     if (Main.netMode == 1)
  4594.                     {
  4595.                         NetMessage.SendData(21, -1, -1, "", num, 0f, 0f, 0f);
  4596.                     }
  4597.                 }
  4598.             }
  4599.         }
  4600.         public object Clone()
  4601.         {
  4602.             return base.MemberwiseClone();
  4603.         }
  4604.         public object clientClone()
  4605.         {
  4606.             Player player = new Player();
  4607.             player.zoneEvil = this.zoneEvil;
  4608.             player.zoneMeteor = this.zoneMeteor;
  4609.             player.zoneDungeon = this.zoneDungeon;
  4610.             player.zoneJungle = this.zoneJungle;
  4611.             player.direction = this.direction;
  4612.             player.selectedItem = this.selectedItem;
  4613.             player.controlUp = this.controlUp;
  4614.             player.controlDown = this.controlDown;
  4615.             player.controlLeft = this.controlLeft;
  4616.             player.controlRight = this.controlRight;
  4617.             player.controlJump = this.controlJump;
  4618.             player.controlUseItem = this.controlUseItem;
  4619.             player.statLife = this.statLife;
  4620.             player.statLifeMax = this.statLifeMax;
  4621.             player.statMana = this.statMana;
  4622.             player.statManaMax = this.statManaMax;
  4623.             player.position.X = this.position.X;
  4624.             player.chest = this.chest;
  4625.             player.talkNPC = this.talkNPC;
  4626.             for (int i = 0; i < 44; i++)
  4627.             {
  4628.                 player.inventory[i] = (Item)this.inventory[i].Clone();
  4629.                 if (i < 8)
  4630.                 {
  4631.                     player.armor[i] = (Item)this.armor[i].Clone();
  4632.                 }
  4633.             }
  4634.             return player;
  4635.         }
  4636.         private static void EncryptFile(string inputFile, string outputFile)
  4637.         {
  4638.             string s = "h3y_gUyZ";
  4639.             UnicodeEncoding unicodeEncoding = new UnicodeEncoding();
  4640.             byte[] bytes = unicodeEncoding.GetBytes(s);
  4641.             FileStream fileStream = new FileStream(outputFile, FileMode.Create);
  4642.             RijndaelManaged rijndaelManaged = new RijndaelManaged();
  4643.             CryptoStream cryptoStream = new CryptoStream(fileStream, rijndaelManaged.CreateEncryptor(bytes, bytes), CryptoStreamMode.Write);
  4644.             FileStream fileStream2 = new FileStream(inputFile, FileMode.Open);
  4645.             int num;
  4646.             while ((num = fileStream2.ReadByte()) != -1)
  4647.             {
  4648.                 cryptoStream.WriteByte((byte)num);
  4649.             }
  4650.             fileStream2.Close();
  4651.             cryptoStream.Close();
  4652.             fileStream.Close();
  4653.         }
  4654.         private static bool DecryptFile(string inputFile, string outputFile)
  4655.         {
  4656.             string s = "h3y_gUyZ";
  4657.             UnicodeEncoding unicodeEncoding = new UnicodeEncoding();
  4658.             byte[] bytes = unicodeEncoding.GetBytes(s);
  4659.             FileStream fileStream = new FileStream(inputFile, FileMode.Open);
  4660.             RijndaelManaged rijndaelManaged = new RijndaelManaged();
  4661.             CryptoStream cryptoStream = new CryptoStream(fileStream, rijndaelManaged.CreateDecryptor(bytes, bytes), CryptoStreamMode.Read);
  4662.             FileStream fileStream2 = new FileStream(outputFile, FileMode.Create);
  4663.             bool result;
  4664.             try
  4665.             {
  4666.                 int num;
  4667.                 while ((num = cryptoStream.ReadByte()) != -1)
  4668.                 {
  4669.                     fileStream2.WriteByte((byte)num);
  4670.                 }
  4671.                 fileStream2.Close();
  4672.                 cryptoStream.Close();
  4673.                 fileStream.Close();
  4674.             }
  4675.             catch
  4676.             {
  4677.                 fileStream2.Close();
  4678.                 fileStream.Close();
  4679.                 File.Delete(outputFile);
  4680.                 result = true;
  4681.                 return result;
  4682.             }
  4683.             return false;
  4684.             return result;
  4685.         }
  4686.         public static bool CheckSpawn(int x, int y)
  4687.         {
  4688.             if (x < 10 || x > Main.maxTilesX - 10 || y < 10 || y > Main.maxTilesX - 10)
  4689.             {
  4690.                 return false;
  4691.             }
  4692.             if (Main.tile[x, y - 1] == null)
  4693.             {
  4694.                 return false;
  4695.             }
  4696.             if (!Main.tile[x, y - 1].active || Main.tile[x, y - 1].type != 79)
  4697.             {
  4698.                 return false;
  4699.             }
  4700.             for (int i = x - 1; i <= x + 1; i++)
  4701.             {
  4702.                 for (int j = y - 3; j < y; j++)
  4703.                 {
  4704.                     if (Main.tile[i, j] == null)
  4705.                     {
  4706.                         return false;
  4707.                     }
  4708.                     if (Main.tile[i, j].active && Main.tileSolid[(int)Main.tile[i, j].type] && !Main.tileSolidTop[(int)Main.tile[i, j].type])
  4709.                     {
  4710.                         return false;
  4711.                     }
  4712.                 }
  4713.             }
  4714.             return WorldGen.StartRoomCheck(x, y - 1);
  4715.         }
  4716.         public void FindSpawn()
  4717.         {
  4718.             for (int i = 0; i < 200; i++)
  4719.             {
  4720.                 if (this.spN[i] == null)
  4721.                 {
  4722.                     this.SpawnX = -1;
  4723.                     this.SpawnY = -1;
  4724.                     return;
  4725.                 }
  4726.                 if (this.spN[i] == Main.worldName && this.spI[i] == Main.worldID)
  4727.                 {
  4728.                     this.SpawnX = this.spX[i];
  4729.                     this.SpawnY = this.spY[i];
  4730.                     return;
  4731.                 }
  4732.             }
  4733.         }
  4734.         public void ChangeSpawn(int x, int y)
  4735.         {
  4736.             int num = 0;
  4737.             while (num < 200 && this.spN[num] != null)
  4738.             {
  4739.                 if (this.spN[num] == Main.worldName && this.spI[num] == Main.worldID)
  4740.                 {
  4741.                     for (int i = num; i > 0; i--)
  4742.                     {
  4743.                         this.spN[i] = this.spN[i - 1];
  4744.                         this.spI[i] = this.spI[i - 1];
  4745.                         this.spX[i] = this.spX[i - 1];
  4746.                         this.spY[i] = this.spY[i - 1];
  4747.                     }
  4748.                     this.spN[0] = Main.worldName;
  4749.                     this.spI[0] = Main.worldID;
  4750.                     this.spX[0] = x;
  4751.                     this.spY[0] = y;
  4752.                     return;
  4753.                 }
  4754.                 num++;
  4755.             }
  4756.             for (int j = 199; j > 0; j--)
  4757.             {
  4758.                 if (this.spN[j - 1] != null)
  4759.                 {
  4760.                     this.spN[j] = this.spN[j - 1];
  4761.                     this.spI[j] = this.spI[j - 1];
  4762.                     this.spX[j] = this.spX[j - 1];
  4763.                     this.spY[j] = this.spY[j - 1];
  4764.                 }
  4765.             }
  4766.             this.spN[0] = Main.worldName;
  4767.             this.spI[0] = Main.worldID;
  4768.             this.spX[0] = x;
  4769.             this.spY[0] = y;
  4770.         }
  4771.         public static void SavePlayer(Player newPlayer, string playerPath)
  4772.         {
  4773.             try
  4774.             {
  4775.                 Directory.CreateDirectory(Main.SavePath);
  4776.             }
  4777.             catch
  4778.             {
  4779.             }
  4780.             if (playerPath == null)
  4781.             {
  4782.                 return;
  4783.             }
  4784.             string destFileName = playerPath + ".bak";
  4785.             if (File.Exists(playerPath))
  4786.             {
  4787.                 File.Copy(playerPath, destFileName, true);
  4788.             }
  4789.             string text = playerPath + ".dat";
  4790.             using (FileStream fileStream = new FileStream(text, FileMode.Create))
  4791.             {
  4792.                 using (BinaryWriter binaryWriter = new BinaryWriter(fileStream))
  4793.                 {
  4794.                     binaryWriter.Write(Main.curRelease);
  4795.                     binaryWriter.Write(newPlayer.name);
  4796.                     binaryWriter.Write(newPlayer.hair);
  4797.                     binaryWriter.Write(newPlayer.statLife);
  4798.                     binaryWriter.Write(newPlayer.statLifeMax);
  4799.                     binaryWriter.Write(newPlayer.statMana);
  4800.                     binaryWriter.Write(newPlayer.statManaMax);
  4801.                     binaryWriter.Write(newPlayer.hairColor.R);
  4802.                     binaryWriter.Write(newPlayer.hairColor.G);
  4803.                     binaryWriter.Write(newPlayer.hairColor.B);
  4804.                     binaryWriter.Write(newPlayer.skinColor.R);
  4805.                     binaryWriter.Write(newPlayer.skinColor.G);
  4806.                     binaryWriter.Write(newPlayer.skinColor.B);
  4807.                     binaryWriter.Write(newPlayer.eyeColor.R);
  4808.                     binaryWriter.Write(newPlayer.eyeColor.G);
  4809.                     binaryWriter.Write(newPlayer.eyeColor.B);
  4810.                     binaryWriter.Write(newPlayer.shirtColor.R);
  4811.                     binaryWriter.Write(newPlayer.shirtColor.G);
  4812.                     binaryWriter.Write(newPlayer.shirtColor.B);
  4813.                     binaryWriter.Write(newPlayer.underShirtColor.R);
  4814.                     binaryWriter.Write(newPlayer.underShirtColor.G);
  4815.                     binaryWriter.Write(newPlayer.underShirtColor.B);
  4816.                     binaryWriter.Write(newPlayer.pantsColor.R);
  4817.                     binaryWriter.Write(newPlayer.pantsColor.G);
  4818.                     binaryWriter.Write(newPlayer.pantsColor.B);
  4819.                     binaryWriter.Write(newPlayer.shoeColor.R);
  4820.                     binaryWriter.Write(newPlayer.shoeColor.G);
  4821.                     binaryWriter.Write(newPlayer.shoeColor.B);
  4822.                     for (int i = 0; i < 8; i++)
  4823.                     {
  4824.                         if (newPlayer.armor[i].name == null)
  4825.                         {
  4826.                             newPlayer.armor[i].name = "";
  4827.                         }
  4828.                         binaryWriter.Write(newPlayer.armor[i].name);
  4829.                     }
  4830.                     for (int j = 0; j < 44; j++)
  4831.                     {
  4832.                         if (newPlayer.inventory[j].name == null)
  4833.                         {
  4834.                             newPlayer.inventory[j].name = "";
  4835.                         }
  4836.                         binaryWriter.Write(newPlayer.inventory[j].name);
  4837.                         binaryWriter.Write(newPlayer.inventory[j].stack);
  4838.                     }
  4839.                     for (int k = 0; k < Chest.maxItems; k++)
  4840.                     {
  4841.                         if (newPlayer.bank[k].name == null)
  4842.                         {
  4843.                             newPlayer.bank[k].name = "";
  4844.                         }
  4845.                         binaryWriter.Write(newPlayer.bank[k].name);
  4846.                         binaryWriter.Write(newPlayer.bank[k].stack);
  4847.                     }
  4848.                     for (int l = 0; l < 200; l++)
  4849.                     {
  4850.                         if (newPlayer.spN[l] == null)
  4851.                         {
  4852.                             binaryWriter.Write(-1);
  4853.                             break;
  4854.                         }
  4855.                         binaryWriter.Write(newPlayer.spX[l]);
  4856.                         binaryWriter.Write(newPlayer.spY[l]);
  4857.                         binaryWriter.Write(newPlayer.spI[l]);
  4858.                         binaryWriter.Write(newPlayer.spN[l]);
  4859.                     }
  4860.                     binaryWriter.Close();
  4861.                 }
  4862.             }
  4863.             Player.EncryptFile(text, playerPath);
  4864.             File.Delete(text);
  4865.         }
  4866.         public static Player LoadPlayer(string playerPath)
  4867.         {
  4868.             bool flag = false;
  4869.             if (Main.rand == null)
  4870.             {
  4871.                 Main.rand = new Random((int)DateTime.Now.Ticks);
  4872.             }
  4873.             Player player = new Player();
  4874.             Player result;
  4875.             try
  4876.             {
  4877.                 string text = playerPath + ".dat";
  4878.                 flag = Player.DecryptFile(playerPath, text);
  4879.                 if (!flag)
  4880.                 {
  4881.                     using (FileStream fileStream = new FileStream(text, FileMode.Open))
  4882.                     {
  4883.                         using (BinaryReader binaryReader = new BinaryReader(fileStream))
  4884.                         {
  4885.                             binaryReader.ReadInt32();
  4886.                             player.name = binaryReader.ReadString();
  4887.                             player.hair = binaryReader.ReadInt32();
  4888.                             player.statLife = binaryReader.ReadInt32();
  4889.                             player.statLifeMax = binaryReader.ReadInt32();
  4890.                             if (player.statLife > player.statLifeMax)
  4891.                             {
  4892.                                 player.statLife = player.statLifeMax;
  4893.                             }
  4894.                             player.statMana = binaryReader.ReadInt32();
  4895.                             player.statManaMax = binaryReader.ReadInt32();
  4896.                             if (player.statMana > player.statManaMax)
  4897.                             {
  4898.                                 player.statMana = player.statManaMax;
  4899.                             }
  4900.                             player.hairColor.R = binaryReader.ReadByte();
  4901.                             player.hairColor.G = binaryReader.ReadByte();
  4902.                             player.hairColor.B = binaryReader.ReadByte();
  4903.                             player.skinColor.R = binaryReader.ReadByte();
  4904.                             player.skinColor.G = binaryReader.ReadByte();
  4905.                             player.skinColor.B = binaryReader.ReadByte();
  4906.                             player.eyeColor.R = binaryReader.ReadByte();
  4907.                             player.eyeColor.G = binaryReader.ReadByte();
  4908.                             player.eyeColor.B = binaryReader.ReadByte();
  4909.                             player.shirtColor.R = binaryReader.ReadByte();
  4910.                             player.shirtColor.G = binaryReader.ReadByte();
  4911.                             player.shirtColor.B = binaryReader.ReadByte();
  4912.                             player.underShirtColor.R = binaryReader.ReadByte();
  4913.                             player.underShirtColor.G = binaryReader.ReadByte();
  4914.                             player.underShirtColor.B = binaryReader.ReadByte();
  4915.                             player.pantsColor.R = binaryReader.ReadByte();
  4916.                             player.pantsColor.G = binaryReader.ReadByte();
  4917.                             player.pantsColor.B = binaryReader.ReadByte();
  4918.                             player.shoeColor.R = binaryReader.ReadByte();
  4919.                             player.shoeColor.G = binaryReader.ReadByte();
  4920.                             player.shoeColor.B = binaryReader.ReadByte();
  4921.                             for (int i = 0; i < 8; i++)
  4922.                             {
  4923.                                 player.armor[i].SetDefaults(binaryReader.ReadString());
  4924.                             }
  4925.                             for (int j = 0; j < 44; j++)
  4926.                             {
  4927.                                 player.inventory[j].SetDefaults(binaryReader.ReadString());
  4928.                                 player.inventory[j].stack = binaryReader.ReadInt32();
  4929.                             }
  4930.                             for (int k = 0; k < Chest.maxItems; k++)
  4931.                             {
  4932.                                 player.bank[k].SetDefaults(binaryReader.ReadString());
  4933.                                 player.bank[k].stack = binaryReader.ReadInt32();
  4934.                             }
  4935.                             for (int l = 0; l < 200; l++)
  4936.                             {
  4937.                                 int num = binaryReader.ReadInt32();
  4938.                                 if (num == -1)
  4939.                                 {
  4940.                                     break;
  4941.                                 }
  4942.                                 player.spX[l] = num;
  4943.                                 player.spY[l] = binaryReader.ReadInt32();
  4944.                                 player.spI[l] = binaryReader.ReadInt32();
  4945.                                 player.spN[l] = binaryReader.ReadString();
  4946.                             }
  4947.                             binaryReader.Close();
  4948.                         }
  4949.                     }
  4950.                     player.PlayerFrame();
  4951.                     File.Delete(text);
  4952.                     result = player;
  4953.                     return result;
  4954.                 }
  4955.             }
  4956.             catch
  4957.             {
  4958.                 flag = true;
  4959.             }
  4960.             if (!flag)
  4961.             {
  4962.                 return new Player();
  4963.             }
  4964.             string text2 = playerPath + ".bak";
  4965.             if (File.Exists(text2))
  4966.             {
  4967.                 File.Delete(playerPath);
  4968.                 File.Move(text2, playerPath);
  4969.                 return Player.LoadPlayer(playerPath);
  4970.             }
  4971.             return new Player();
  4972.             return result;
  4973.         }
  4974.         public Player()
  4975.         {
  4976.             for (int i = 0; i < 44; i++)
  4977.             {
  4978.                 if (i < 8)
  4979.                 {
  4980.                     this.armor[i] = new Item();
  4981.                     this.armor[i].name = "";
  4982.                 }
  4983.                 this.inventory[i] = new Item();
  4984.                 this.inventory[i].name = "";
  4985.             }
  4986.             for (int j = 0; j < Chest.maxItems; j++)
  4987.             {
  4988.                 this.bank[j] = new Item();
  4989.                 this.bank[j].name = "";
  4990.             }
  4991.             this.grappling[0] = -1;
  4992.             this.inventory[0].SetDefaults("Copper Pickaxe");
  4993.             this.inventory[1].SetDefaults("Copper Axe");
  4994.             for (int k = 0; k < 80; k++)
  4995.             {
  4996.                 this.adjTile[k] = false;
  4997.                 this.oldAdjTile[k] = false;
  4998.             }
  4999.         }
  5000.     }
  5001. }
Advertisement
Add Comment
Please, Sign In to add comment