/**
   * Send player to another dimension. Was a(OEntityPlayerMP var1, int var2) before
   *
   * @param var1 Player
   * @param var2 Dimension ID
   * @param createPortal true if a portal needs to be created
   */
  public void switchDimension(OEntityPlayerMP var1, int var2, boolean createPortal) {
    int var3 = var1.w; // current dimension
    OWorldServer var4 = (OWorldServer) ((CanaryDimension) var1.getDimension()).getHandle();

    var1.w = var2; // set new dimension
    OWorldServer var5 =
        (OWorldServer)
            ((CanaryDimension)
                    this.c
                        .getWorldManager()
                        .getDimension(var1.bi.getCanaryDimension().getName(), var1.w))
                .getHandle();
    var1.a.b(
        (new OPacket9Respawn(
            var1.w, (byte) var1.bi.q, var5.s().getWorldType(), var5.y(), var1.c.a())));
    //        var4.f(var1);

    var1.bE = false;
    double var6 = var1.bm;
    double var8 = var1.bo;
    double var10 = 8.0D;
    if (var1.w == -1) {
      var6 /= var10;
      var8 /= var10;
      var1.c(var6, var1.bn, var8, var1.bs, var1.bt);
      if (var1.aE()) {
        var4.a(var1, false);
      }
    } else if (var1.w == 0) {
      var6 *= var10;
      var8 *= var10;
      var1.c(var6, var1.bn, var8, var1.bs, var1.bt);
      if (var1.aE()) {
        var4.a(var1, false);
      }
    } else {
      OChunkCoordinates var12 = var5.d();
      var6 = var12.a;
      var1.bn = var12.b;
      var8 = var12.c;
      var1.c(var6, var1.bn, var8, 90.0F, 0.0F);
      if (var1.aE()) {
        var4.a(var1, false);
      }
    }

    if (var3 != 1 && var1.aE()) {
      var5.b(var1);
      var1.c(var6, var1.bn, var8, var1.bs, var1.bt);
      var5.a(var1, false);
      // CanaryMod - don't create portal if we are not using a portal to teleport.
      if (createPortal) {
        var5.G.a = true;
        (new OTeleporter()).a(var5, var1);
        var5.G.a = false;
      }
    }

    this.a(var1);
    var1.a.a(
        var1.bm,
        var1.bn,
        var1.bo,
        var1.bs,
        var1.bt,
        var1.w,
        var1.bi.getCanaryDimension().getName());
    var1.a(var5);
    var1.c.a(var5);
    this.a(var1, var5);
    this.f(var1);
  }