public void TeleportationPotion()
{
bool flag1 = false;
int num1 = 0;
int num2 = 0;
int num3 = 0;
int Width = this.width;
Vector2 Position = new Vector2((float)num2, (float)num3) * 16f + new Vector2((float)(-Width / 2 + 8), (float)-this.height);
while (!flag1 && num1 < 1000)
{
++num1;
int index1 = 100 + Main.rand.Next(Main.maxTilesX - 200);
int index2 = 100 + Main.rand.Next(Main.maxTilesY - 200);
Position = new Vector2((float)index1, (float)index2) * 16f + new Vector2((float)(-Width / 2 + 8), (float)-this.height);
if (!Collision.SolidCollision(Position, Width, this.height))
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
if (((int)Main.tile[index1, index2].wall != 87 || (double)index2 <= Main.worldSurface || NPC.downedPlantBoss) && (!Main.wallDungeon[(int)Main.tile[index1, index2].wall] || (double)index2 <= Main.worldSurface || NPC.downedBoss3))
{
int num4 = 0;
while (num4 < 100)
{
if (Main.tile[index1, index2 + num4] == null)
Main.tile[index1, index2 + num4] = new Tile();
Tile tile = Main.tile[index1, index2 + num4];
Position = new Vector2((float)index1, (float)(index2 + num4)) * 16f + new Vector2((float)(-Width / 2 + 8), (float)-this.height);
Vector4 vector4 = Collision.SlopeCollision(Position, this.velocity, Width, this.height, this.gravDir, false);
bool flag2 = !Collision.SolidCollision(Position, Width, this.height);
if ((double)vector4.Z == (double)this.velocity.X)
{
double num5 = (double)this.velocity.Y;
}
if (flag2)
++num4;
else if (!tile.active() || tile.inActive() || !Main.tileSolid[(int)tile.type])
++num4;
else
break;
}
if (!Collision.LavaCollision(Position, Width, this.height) && (double)Collision.HurtTiles(Position, this.velocity, Width, this.height, false).Y <= 0.0)
{
Collision.SlopeCollision(Position, this.velocity, Width, this.height, this.gravDir, false);
if (Collision.SolidCollision(Position, Width, this.height) && num4 < 99)
{
Vector2 Velocity1 = Vector2.UnitX * 16f;
if (!(Collision.TileCollision(Position - Velocity1, Velocity1, this.width, this.height, false, false, (int)this.gravDir) != Velocity1))
{
Vector2 Velocity2 = -Vector2.UnitX * 16f;
if (!(Collision.TileCollision(Position - Velocity2, Velocity2, this.width, this.height, false, false, (int)this.gravDir) != Velocity2))
{
Vector2 Velocity3 = Vector2.UnitY * 16f;
if (!(Collision.TileCollision(Position - Velocity3, Velocity3, this.width, this.height, false, false, (int)this.gravDir) != Velocity3))
{
Vector2 Velocity4 = -Vector2.UnitY * 16f;
if (!(Collision.TileCollision(Position - Velocity4, Velocity4, this.width, this.height, false, false, (int)this.gravDir) != Velocity4))
{
flag1 = true;
int num5 = index2 + num4;
break;
}
}
}
}
}
}
}
}
}
if (!flag1)
return;
Vector2 newPos = Position;
this.Teleport(newPos, 2, 0);
this.velocity = Vector2.Zero;
if (Main.netMode != 2)
return;
RemoteClient.CheckSection(this.whoAmI, this.position, 1);
NetMessage.SendData(65, -1, -1, "", 0, (float)this.whoAmI, newPos.X, newPos.Y, 3, 0, 0);
}