/** Updates Client side signs */
  public void handleUpdateSign(Packet130UpdateSign par1Packet130UpdateSign) {
    WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension);

    if (worldserver.blockExists(
        par1Packet130UpdateSign.xPosition,
        par1Packet130UpdateSign.yPosition,
        par1Packet130UpdateSign.zPosition)) {
      TileEntity tileentity =
          worldserver.getBlockTileEntity(
              par1Packet130UpdateSign.xPosition,
              par1Packet130UpdateSign.yPosition,
              par1Packet130UpdateSign.zPosition);

      if (tileentity instanceof TileEntitySign) {
        TileEntitySign tileentitysign = (TileEntitySign) tileentity;

        if (!tileentitysign.isEditable()) {
          mcServer.logWarningMessage(
              (new StringBuilder())
                  .append("Player ")
                  .append(playerEntity.username)
                  .append(" just tried to change non-editable sign")
                  .toString());
          return;
        }
      }

      for (int i = 0; i < 4; i++) {
        boolean flag = true;

        if (par1Packet130UpdateSign.signLines[i].length() > 15) {
          flag = false;
        } else {
          for (int l = 0; l < par1Packet130UpdateSign.signLines[i].length(); l++) {
            if (ChatAllowedCharacters.allowedCharacters.indexOf(
                    par1Packet130UpdateSign.signLines[i].charAt(l))
                < 0) {
              flag = false;
            }
          }
        }

        if (!flag) {
          par1Packet130UpdateSign.signLines[i] = "!?";
        }
      }

      if (tileentity instanceof TileEntitySign) {
        int j = par1Packet130UpdateSign.xPosition;
        int k = par1Packet130UpdateSign.yPosition;
        int i1 = par1Packet130UpdateSign.zPosition;
        TileEntitySign tileentitysign1 = (TileEntitySign) tileentity;
        System.arraycopy(par1Packet130UpdateSign.signLines, 0, tileentitysign1.signText, 0, 4);
        tileentitysign1.onInventoryChanged();
        worldserver.markBlockNeedsUpdate(j, k, i1);
      }
    }
  }
  public void handleUseEntity(Packet7UseEntity par1Packet7UseEntity) {
    WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension);
    Entity entity = worldserver.getEntityByID(par1Packet7UseEntity.targetEntity);

    if (entity != null) {
      boolean flag = playerEntity.canEntityBeSeen(entity);
      double d = 36D;

      if (!flag) {
        d = 9D;
      }

      if (playerEntity.getDistanceSqToEntity(entity) < d) {
        if (par1Packet7UseEntity.isLeftClick == 0) {
          playerEntity.interactWith(entity);
        } else if (par1Packet7UseEntity.isLeftClick == 1) {
          playerEntity.attackTargetEntityWithCurrentItem(entity);
        }
      }
    }
  }
  public void handleBlockDig(Packet14BlockDig par1Packet14BlockDig) {
    WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension);

    if (par1Packet14BlockDig.status == 4) {
      playerEntity.dropOneItem();
      return;
    }

    if (par1Packet14BlockDig.status == 5) {
      playerEntity.stopUsingItem();
      return;
    }

    boolean flag =
        worldserver.actionsAllowed =
            worldserver.provider.worldType != 0
                || mcServer.getConfigurationManager().areCommandsAllowed(playerEntity.username)
                || mcServer.isSinglePlayer();
    boolean flag1 = false;

    if (par1Packet14BlockDig.status == 0) {
      flag1 = true;
    }

    if (par1Packet14BlockDig.status == 2) {
      flag1 = true;
    }

    int i = par1Packet14BlockDig.xPosition;
    int j = par1Packet14BlockDig.yPosition;
    int k = par1Packet14BlockDig.zPosition;

    if (flag1) {
      double d = playerEntity.posX - ((double) i + 0.5D);
      double d1 = (playerEntity.posY - ((double) j + 0.5D)) + 1.5D;
      double d3 = playerEntity.posZ - ((double) k + 0.5D);
      double d5 = d * d + d1 * d1 + d3 * d3;

      if (d5 > 36D) {
        return;
      }

      if (j >= mcServer.getBuildLimit()) {
        return;
      }
    }

    ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint();
    int l = MathHelper.abs_int(i - chunkcoordinates.posX);
    int i1 = MathHelper.abs_int(k - chunkcoordinates.posZ);

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

    if (par1Packet14BlockDig.status == 0) {
      if (i1 > 16 || flag) {
        playerEntity.theItemInWorldManager.onBlockClicked(i, j, k, par1Packet14BlockDig.face);
      } else {
        playerEntity.serverForThisPlayer.sendPacketToPlayer(
            new Packet53BlockChange(i, j, k, worldserver));
      }
    } else if (par1Packet14BlockDig.status == 2) {
      playerEntity.theItemInWorldManager.uncheckedTryHarvestBlock(i, j, k);

      if (worldserver.getBlockId(i, j, k) != 0) {
        playerEntity.serverForThisPlayer.sendPacketToPlayer(
            new Packet53BlockChange(i, j, k, worldserver));
      }
    } else if (par1Packet14BlockDig.status == 1) {
      playerEntity.theItemInWorldManager.destroyBlockInWorldPartially(i, j, k);

      if (worldserver.getBlockId(i, j, k) != 0) {
        playerEntity.serverForThisPlayer.sendPacketToPlayer(
            new Packet53BlockChange(i, j, k, worldserver));
      }
    } else if (par1Packet14BlockDig.status == 3) {
      double d2 = playerEntity.posX - ((double) i + 0.5D);
      double d4 = playerEntity.posY - ((double) j + 0.5D);
      double d6 = playerEntity.posZ - ((double) k + 0.5D);
      double d7 = d2 * d2 + d4 * d4 + d6 * d6;

      if (d7 < 256D) {
        playerEntity.serverForThisPlayer.sendPacketToPlayer(
            new Packet53BlockChange(i, j, k, worldserver));
      }
    }

    worldserver.actionsAllowed = false;
  }
  public void handlePlace(Packet15Place par1Packet15Place) {
    WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension);
    ItemStack itemstack = playerEntity.inventory.getCurrentItem();
    boolean flag = false;
    int i = par1Packet15Place.getXPosition();
    int j = par1Packet15Place.getYPosition();
    int k = par1Packet15Place.getZPosition();
    int l = par1Packet15Place.getDirection();
    boolean flag1 =
        worldserver.actionsAllowed =
            worldserver.provider.worldType != 0
                || mcServer.getConfigurationManager().areCommandsAllowed(playerEntity.username)
                || mcServer.isSinglePlayer();

    if (par1Packet15Place.getDirection() == 255) {
      if (itemstack == null) {
        return;
      }

      playerEntity.theItemInWorldManager.tryUseItem(playerEntity, worldserver, itemstack);
    } else if (par1Packet15Place.getYPosition() < mcServer.getBuildLimit() - 1
        || par1Packet15Place.getDirection() != 1
            && par1Packet15Place.getYPosition() < mcServer.getBuildLimit()) {
      ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint();
      int i1 = MathHelper.abs_int(i - chunkcoordinates.posX);
      int j1 = MathHelper.abs_int(k - chunkcoordinates.posZ);

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

      if (field_72587_r
          && playerEntity.getDistanceSq((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D)
              < 64D
          && (j1 > 16 || flag1)) {
        playerEntity.theItemInWorldManager.activateBlockOrUseItem(
            playerEntity,
            worldserver,
            itemstack,
            i,
            j,
            k,
            l,
            par1Packet15Place.getXOffset(),
            par1Packet15Place.getYOffset(),
            par1Packet15Place.getZOffset());
      }

      flag = true;
    } else {
      playerEntity.serverForThisPlayer.sendPacketToPlayer(
          new Packet3Chat(
              (new StringBuilder())
                  .append("\2477Height limit for building is ")
                  .append(mcServer.getBuildLimit())
                  .toString()));
      flag = true;
    }

    if (flag) {
      playerEntity.serverForThisPlayer.sendPacketToPlayer(
          new Packet53BlockChange(i, j, k, worldserver));

      if (l == 0) {
        j--;
      }

      if (l == 1) {
        j++;
      }

      if (l == 2) {
        k--;
      }

      if (l == 3) {
        k++;
      }

      if (l == 4) {
        i--;
      }

      if (l == 5) {
        i++;
      }

      playerEntity.serverForThisPlayer.sendPacketToPlayer(
          new Packet53BlockChange(i, j, k, worldserver));
    }

    itemstack = playerEntity.inventory.getCurrentItem();

    if (itemstack != null && itemstack.stackSize == 0) {
      playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = null;
      itemstack = null;
    }

    if (itemstack == null || itemstack.getMaxItemUseDuration() == 0) {
      playerEntity.playerInventoryBeingManipulated = true;
      playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] =
          ItemStack.copyItemStack(
              playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem]);
      Slot slot =
          playerEntity.craftingInventory.getSlotFromInventory(
              playerEntity.inventory, playerEntity.inventory.currentItem);
      playerEntity.craftingInventory.updateCraftingResults();
      playerEntity.playerInventoryBeingManipulated = false;

      if (!ItemStack.areItemStacksEqual(
          playerEntity.inventory.getCurrentItem(), par1Packet15Place.getItemStack())) {
        sendPacketToPlayer(
            new Packet103SetSlot(
                playerEntity.craftingInventory.windowId,
                slot.slotNumber,
                playerEntity.inventory.getCurrentItem()));
      }
    }

    worldserver.actionsAllowed = false;
  }
  public void handleFlying(Packet10Flying par1Packet10Flying) {
    WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension);
    field_72584_h = true;

    if (playerEntity.playerHasConqueredTheEnd) {
      return;
    }

    if (!field_72587_r) {
      double d = par1Packet10Flying.yPosition - lastPosY;

      if (par1Packet10Flying.xPosition == lastPosX
          && d * d < 0.01D
          && par1Packet10Flying.zPosition == lastPosZ) {
        field_72587_r = true;
      }
    }

    if (field_72587_r) {
      if (playerEntity.ridingEntity != null) {
        float f = playerEntity.rotationYaw;
        float f1 = playerEntity.rotationPitch;
        playerEntity.ridingEntity.updateRiderPosition();
        double d2 = playerEntity.posX;
        double d4 = playerEntity.posY;
        double d6 = playerEntity.posZ;
        double d8 = 0.0D;
        double d9 = 0.0D;

        if (par1Packet10Flying.rotating) {
          f = par1Packet10Flying.yaw;
          f1 = par1Packet10Flying.pitch;
        }

        if (par1Packet10Flying.moving
            && par1Packet10Flying.yPosition == -999D
            && par1Packet10Flying.stance == -999D) {
          if (par1Packet10Flying.xPosition > 1.0D || par1Packet10Flying.zPosition > 1.0D) {
            System.err.println(
                (new StringBuilder())
                    .append(playerEntity.username)
                    .append(" was caught trying to crash the server with an invalid position.")
                    .toString());
            kickPlayerFromServer("Nope!");
            return;
          }

          d8 = par1Packet10Flying.xPosition;
          d9 = par1Packet10Flying.zPosition;
        }

        playerEntity.onGround = par1Packet10Flying.onGround;
        playerEntity.onUpdateEntity();
        playerEntity.moveEntity(d8, 0.0D, d9);
        playerEntity.setPositionAndRotation(d2, d4, d6, f, f1);
        playerEntity.motionX = d8;
        playerEntity.motionZ = d9;

        if (playerEntity.ridingEntity != null) {
          worldserver.uncheckedUpdateEntity(playerEntity.ridingEntity, true);
        }

        if (playerEntity.ridingEntity != null) {
          playerEntity.ridingEntity.updateRiderPosition();
        }

        mcServer.getConfigurationManager().func_72358_d(playerEntity);
        lastPosX = playerEntity.posX;
        lastPosY = playerEntity.posY;
        lastPosZ = playerEntity.posZ;
        worldserver.updateEntity(playerEntity);
        return;
      }

      if (playerEntity.isPlayerSleeping()) {
        playerEntity.onUpdateEntity();
        playerEntity.setPositionAndRotation(
            lastPosX, lastPosY, lastPosZ, playerEntity.rotationYaw, playerEntity.rotationPitch);
        worldserver.updateEntity(playerEntity);
        return;
      }

      double d1 = playerEntity.posY;
      lastPosX = playerEntity.posX;
      lastPosY = playerEntity.posY;
      lastPosZ = playerEntity.posZ;
      double d3 = playerEntity.posX;
      double d5 = playerEntity.posY;
      double d7 = playerEntity.posZ;
      float f2 = playerEntity.rotationYaw;
      float f3 = playerEntity.rotationPitch;

      if (par1Packet10Flying.moving
          && par1Packet10Flying.yPosition == -999D
          && par1Packet10Flying.stance == -999D) {
        par1Packet10Flying.moving = false;
      }

      if (par1Packet10Flying.moving) {
        d3 = par1Packet10Flying.xPosition;
        d5 = par1Packet10Flying.yPosition;
        d7 = par1Packet10Flying.zPosition;
        double d10 = par1Packet10Flying.stance - par1Packet10Flying.yPosition;

        if (!playerEntity.isPlayerSleeping()
            && (d10 > 1.6499999999999999D || d10 < 0.10000000000000001D)) {
          kickPlayerFromServer("Illegal stance");
          logger.warning(
              (new StringBuilder())
                  .append(playerEntity.username)
                  .append(" had an illegal stance: ")
                  .append(d10)
                  .toString());
          return;
        }

        if (Math.abs(par1Packet10Flying.xPosition) > 32000000D
            || Math.abs(par1Packet10Flying.zPosition) > 32000000D) {
          kickPlayerFromServer("Illegal position");
          return;
        }
      }

      if (par1Packet10Flying.rotating) {
        f2 = par1Packet10Flying.yaw;
        f3 = par1Packet10Flying.pitch;
      }

      playerEntity.onUpdateEntity();
      playerEntity.ySize = 0.0F;
      playerEntity.setPositionAndRotation(lastPosX, lastPosY, lastPosZ, f2, f3);

      if (!field_72587_r) {
        return;
      }

      double d11 = d3 - playerEntity.posX;
      double d12 = d5 - playerEntity.posY;
      double d13 = d7 - playerEntity.posZ;
      double d14 = Math.min(Math.abs(d11), Math.abs(playerEntity.motionX));
      double d15 = Math.min(Math.abs(d12), Math.abs(playerEntity.motionY));
      double d16 = Math.min(Math.abs(d13), Math.abs(playerEntity.motionZ));
      double d17 = d14 * d14 + d15 * d15 + d16 * d16;

      if (d17 > 100D
          && (!mcServer.isSinglePlayer()
              || !mcServer.getServerOwner().equals(playerEntity.username))) {
        logger.warning(
            (new StringBuilder())
                .append(playerEntity.username)
                .append(" moved too quickly! ")
                .append(d11)
                .append(",")
                .append(d12)
                .append(",")
                .append(d13)
                .append(" (")
                .append(d14)
                .append(", ")
                .append(d15)
                .append(", ")
                .append(d16)
                .append(")")
                .toString());
        setPlayerLocation(
            lastPosX, lastPosY, lastPosZ, playerEntity.rotationYaw, playerEntity.rotationPitch);
        return;
      }

      float f4 = 0.0625F;
      boolean flag =
          worldserver
              .getCollidingBoundingBoxes(
                  playerEntity, playerEntity.boundingBox.copy().contract(f4, f4, f4))
              .isEmpty();

      if (playerEntity.onGround && !par1Packet10Flying.onGround && d12 > 0.0D) {
        playerEntity.addExhaustion(0.2F);
      }

      playerEntity.moveEntity(d11, d12, d13);
      playerEntity.onGround = par1Packet10Flying.onGround;
      playerEntity.addMovementStat(d11, d12, d13);
      double d18 = d12;
      d11 = d3 - playerEntity.posX;
      d12 = d5 - playerEntity.posY;

      if (d12 > -0.5D || d12 < 0.5D) {
        d12 = 0.0D;
      }

      d13 = d7 - playerEntity.posZ;
      d17 = d11 * d11 + d12 * d12 + d13 * d13;
      boolean flag1 = false;

      if (d17 > 0.0625D
          && !playerEntity.isPlayerSleeping()
          && !playerEntity.theItemInWorldManager.isCreative()) {
        flag1 = true;
        logger.warning(
            (new StringBuilder())
                .append(playerEntity.username)
                .append(" moved wrongly!")
                .toString());
      }

      playerEntity.setPositionAndRotation(d3, d5, d7, f2, f3);
      boolean flag2 =
          worldserver
              .getCollidingBoundingBoxes(
                  playerEntity, playerEntity.boundingBox.copy().contract(f4, f4, f4))
              .isEmpty();

      if (flag && (flag1 || !flag2) && !playerEntity.isPlayerSleeping()) {
        setPlayerLocation(lastPosX, lastPosY, lastPosZ, f2, f3);
        return;
      }

      AxisAlignedBB axisalignedbb =
          playerEntity
              .boundingBox
              .copy()
              .expand(f4, f4, f4)
              .addCoord(0.0D, -0.55000000000000004D, 0.0D);

      if (!mcServer.isFlightAllowed()
          && !playerEntity.theItemInWorldManager.isCreative()
          && !worldserver.isAABBNonEmpty(axisalignedbb)) {
        if (d18 >= -0.03125D) {
          ticksForFloatKick++;

          if (ticksForFloatKick > 80) {
            logger.warning(
                (new StringBuilder())
                    .append(playerEntity.username)
                    .append(" was kicked for floating too long!")
                    .toString());
            kickPlayerFromServer("Flying is not enabled on this server");
            return;
          }
        }
      } else {
        ticksForFloatKick = 0;
      }

      playerEntity.onGround = par1Packet10Flying.onGround;
      mcServer.getConfigurationManager().func_72358_d(playerEntity);
      playerEntity.updateFlyingState(playerEntity.posY - d1, par1Packet10Flying.onGround);
    }
  }