コード例 #1
0
  public void c(OEntityPlayerMP var1) {
    this.sendPacketToAll((new OPacket201PlayerInfo(var1.v, true, 1000)));
    this.b.add(var1);
    OWorldServer var2 =
        (OWorldServer)
            ((CanaryDimension) var1.getDimension().getWorld().getDimension(Type.fromId(var1.w)))
                .getHandle();
    var1.bi = var2; // re-set world
    var2.G.c((int) var1.bm >> 4, (int) var1.bo >> 4);

    while (var2.a(var1, var1.bw).size() != 0) {
      var1.c(var1.bm, var1.bn + 1.0D, var1.bo);
    }

    var2.b(var1);
    // CanaryMod
    var1.getDimension().getPlayerManager().addPlayer(var1.getPlayer());
    this.u();

    for (int var3 = 0; var3 < this.b.size(); ++var3) {
      OEntityPlayerMP var4 = (OEntityPlayerMP) this.b.get(var3);
      var1.a.b((new OPacket201PlayerInfo(var4.v, true, var4.i)));
    }
    Canary.hooks().callHook(new LoginHook(var1.getPlayer()));
    var1.getPlayer().refreshCreativeMode();
  }
コード例 #2
0
  // Respawn player
  public OEntityPlayerMP a(OEntityPlayerMP var1, int var2, boolean var3, Location spawnLocation) {
    var1.getDimension().getEntityTracker().untrackPlayerSymmetrics(var1.getPlayer());
    var1.getDimension().getEntityTracker().untrackEntity(var1.getCanaryEntity());
    var1.getDimension().getPlayerManager().removePlayer(var1.getPlayer());
    this.b.remove(var1);
    var1.getDimension()
        .removePlayerFromWorld(var1.getPlayer()); // This calls the despawn method in world!

    OChunkCoordinates var4 = var1.ab();
    var1.w = var2; // Set new dimension
    CanaryWorld cworld = (CanaryWorld) var1.getDimension().getWorld();
    CanaryDimension dim = (CanaryDimension) cworld.getDimension(Type.fromId(var2));
    OEntityPlayerMP var5 =
        new OEntityPlayerMP(
            this.c, dim.getHandle(), var1.v, new OItemInWorldManager(dim.getHandle()));
    var5.w = var2;
    if (var3) {
      // copy player
      var5.c((OEntityPlayer) var1);
    }

    var5.bd = var1.bd;
    // Set NetServerHandler
    var5.a = var1.a;
    var5.setServerHandler(var5.a.getCanaryNetServerHandler());
    var5.a.setUser(var5.getPlayer());

    OWorldServer var6 = (OWorldServer) dim.getHandle();
    var5.c.a(var1.c.a());
    var5.c.b(var6.s().getGameMode());
    if (var4 != null) {
      OChunkCoordinates var7 =
          OEntityPlayer.a(((CanaryDimension) var1.getDimension()).getHandle(), var4);
      if (var7 != null) {
        var5.c((var7.a + 0.5F), (var7.b + 0.1F), (var7.c + 0.5F), 0.0F, 0.0F);
        var5.a(var4);
      } else {
        var5.a.b((new OPacket70Bed(0, 0)));
      }
    }

    // CanaryMod set player location and angle if a spawn location is defined
    if (spawnLocation != null) {
      var5.c(
          spawnLocation.getX(),
          spawnLocation.getY(),
          spawnLocation.getZ(),
          spawnLocation.getRotation(),
          spawnLocation.getPitch());
    }

    var6.G.c((int) var5.bm >> 4, (int) var5.bo >> 4);

    while (var6.a(var5, var5.bw).size()
        != 0) { // This is the checks for canSpawnHere  should we do something with this so players
      // don't end up on roofs?
      var5.c(var5.bm, var5.bn + 1.0D, var5.bo);
    }

    // respawn packet
    var5.a.b(
        (new OPacket9Respawn(
            var5.w, (byte) var5.bi.q, var5.bi.s().getWorldType(), var5.bi.y(), var5.c.a())));
    // teleport to spawn location
    var5.a.a(
        var5.bm,
        var5.bn,
        var5.bo,
        var5.bs,
        var5.bt,
        var5.w,
        var5.bi.getCanaryDimension().getName());
    // something
    this.a(var5, var6);
    var5.getDimension().getPlayerManager().addPlayer((Player) var5.getPlayer());
    var5.getDimension()
        .addPlayerToWorld(var5.getPlayer()); // This also calls the spawn method in world!
    this.b.add(var5);
    var5.x();
    var5.E();
    return var5;
  }