Beispiel #1
0
  public void a(Packet14BlockDig packet14blockdig) {
    // CraftBukkit start
    if (this.player.dead) {
      return;
    }
    // CraftBukkit end

    WorldServer worldserver = this.minecraftServer.a(this.player.dimension);

    if (packet14blockdig.e == 4) {
      this.player.E();
    } else {
      boolean flag =
          worldserver.weirdIsOpCache =
              worldserver.worldProvider.dimension != 0
                  || this.minecraftServer.serverConfigurationManager.isOp(this.player.name);
      boolean flag1 = false;

      if (packet14blockdig.e == 0) {
        flag1 = true;
      }

      if (packet14blockdig.e == 2) {
        flag1 = true;
      }

      int i = packet14blockdig.a;
      int j = packet14blockdig.b;
      int k = packet14blockdig.c;

      if (flag1) {
        double d0 = this.player.locX - ((double) i + 0.5D);
        double d1 = this.player.locY - ((double) j + 0.5D);
        double d2 = this.player.locZ - ((double) k + 0.5D);
        double d3 = d0 * d0 + d1 * d1 + d2 * d2;

        if (d3 > 36.0D) {
          return;
        }
      }

      ChunkCoordinates chunkcoordinates = worldserver.getSpawn();
      int l = (int) MathHelper.abs((float) (i - chunkcoordinates.x));
      int i1 = (int) MathHelper.abs((float) (k - chunkcoordinates.z));

      if (l > i1) {
        i1 = l;
      }

      if (packet14blockdig.e == 0) {
        // CraftBukkit
        if (i1 < this.minecraftServer.spawnProtection && !flag) {
          this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver));
        } else {
          // CraftBukkit - add face argument
          this.player.itemInWorldManager.dig(i, j, k, packet14blockdig.face);
        }
      } else if (packet14blockdig.e == 2) {
        this.player.itemInWorldManager.a(i, j, k);
        if (worldserver.getTypeId(i, j, k) != 0) {
          this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver));
        }
      } else if (packet14blockdig.e == 3) {
        double d4 = this.player.locX - ((double) i + 0.5D);
        double d5 = this.player.locY - ((double) j + 0.5D);
        double d6 = this.player.locZ - ((double) k + 0.5D);
        double d7 = d4 * d4 + d5 * d5 + d6 * d6;

        if (d7 < 256.0D) {
          this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver));
        }
      }

      worldserver.weirdIsOpCache = false;
    }
  }