Ejemplo n.º 1
0
  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;
  }
Ejemplo n.º 2
0
  public void handlePlace(Packet15Place par1Packet15Place) {
    WorldServer var2 = this.mcServer.getWorldManager(this.playerEntity.dimension);
    ItemStack var3 = this.playerEntity.inventory.getCurrentItem();
    boolean var4 = false;
    int var5 = par1Packet15Place.getXPosition();
    int var6 = par1Packet15Place.getYPosition();
    int var7 = par1Packet15Place.getZPosition();
    int var8 = par1Packet15Place.getDirection();
    boolean var9 =
        var2.disableSpawnProtection =
            var2.provider.worldType != 0
                || this.mcServer.getConfigurationManager().isOp(this.playerEntity.username)
                || this.mcServer.isSinglePlayer();

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

      this.playerEntity.theItemInWorldManager.tryUseItem(this.playerEntity, var2, var3);
    } else if (par1Packet15Place.getYPosition() >= this.mcServer.getBuildLimit() - 1
        && (par1Packet15Place.getDirection() == 1
            || par1Packet15Place.getYPosition() >= this.mcServer.getBuildLimit())) {
      this.playerEntity.playerNetServerHandler.sendPacket(
          new Packet3Chat("\u00a77Height limit for building is " + this.mcServer.getBuildLimit()));
      var4 = true;
    } else {
      ChunkCoordinates var10 = var2.getSpawnPoint();
      int var11 = MathHelper.abs(var5 - var10.posX);
      int var12 = MathHelper.abs(var7 - var10.posZ);

      if (var11 > var12) {
        var12 = var11;
      }

      if (this.hasMoved
          && this.playerEntity.getDistanceSq(
                  (double) var5 + 0.5D, (double) var6 + 0.5D, (double) var7 + 0.5D)
              < 64.0D
          && (var12 > 16 || var9)) {
        this.playerEntity.theItemInWorldManager.activateBlockOrUseItem(
            this.playerEntity,
            var2,
            var3,
            var5,
            var6,
            var7,
            var8,
            par1Packet15Place.getXOffset(),
            par1Packet15Place.getYOffset(),
            par1Packet15Place.getZOffset());
      }

      var4 = true;
    }

    if (var4) {
      this.playerEntity.playerNetServerHandler.sendPacket(
          new Packet53BlockChange(var5, var6, var7, var2));

      if (var8 == 0) {
        --var6;
      }

      if (var8 == 1) {
        ++var6;
      }

      if (var8 == 2) {
        --var7;
      }

      if (var8 == 3) {
        ++var7;
      }

      if (var8 == 4) {
        --var5;
      }

      if (var8 == 5) {
        ++var5;
      }

      this.playerEntity.playerNetServerHandler.sendPacket(
          new Packet53BlockChange(var5, var6, var7, var2));
    }

    var3 = this.playerEntity.inventory.getCurrentItem();

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

    if (var3 == null || var3.getMaxItemUseDuration() == 0) {
      this.playerEntity.isChangingQuantityOnly = true;
      this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem] =
          ItemStack.copyItemStack(
              this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem]);
      Slot var13 =
          this.playerEntity.craftingInventory.func_75147_a(
              this.playerEntity.inventory, this.playerEntity.inventory.currentItem);
      this.playerEntity.craftingInventory.updateCraftingResults();
      this.playerEntity.isChangingQuantityOnly = false;

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

    var2.disableSpawnProtection = false;
  }