Пример #1
0
  private IInventory l() {
    int i = BlockHopper.b(this.p());

    return getInventoryAt(
        this.getWorld(),
        (double) (this.x + Facing.b[i]),
        (double) (this.y + Facing.c[i]),
        (double) (this.z + Facing.d[i]));
  }
Пример #2
0
  // alkazia
  private boolean k() {
    IInventory iinventory = this.l();

    if (iinventory == null) {
      return false;
    } else {
      for (int i = 0; i < this.getSize(); ++i) {
        if (this.getItem(i) != null) {
          ItemStack itemstack = this.getItem(i).cloneItemStack();
          // CraftBukkit start - Call event when pushing items into other inventories
          CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, 1));

          Inventory destinationInventory;
          // Have to special case large chests as they work oddly
          if (iinventory instanceof InventoryLargeChest) {
            destinationInventory =
                new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest(
                    (InventoryLargeChest) iinventory);
          } else if (isIronChest) {
            destinationInventory = null;
          } else {
            destinationInventory = iinventory.getOwner().getInventory();
          }

          InventoryMoveItemEvent event =
              new InventoryMoveItemEvent(
                  this.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
          this.getWorld().getServer().getPluginManager().callEvent(event);
          if (event.isCancelled()) {
            this.setItem(i, itemstack);
            this.c(world.spigotConfig.hopperTransfer); // Spigot
            return false;
          }
          ItemStack itemstack1 =
              addItem(
                  iinventory,
                  CraftItemStack.asNMSCopy(event.getItem()),
                  Facing.OPPOSITE_FACING[BlockHopper.b(this.p())]);

          if (itemstack1 == null || itemstack1.count == 0) {
            if (event.getItem().equals(oitemstack)) {
              iinventory.update();
            } else {
              this.setItem(i, itemstack);
            }
            // CraftBukkit end
            return true;
          }

          this.setItem(i, itemstack);
        }
      }

      return false;
    }
  }
Пример #3
0
 // Spigot start
 // Helper method for scheduleTicks. If the hopper at x0, y0, z0 is pointed
 // at this tile entity, then make it active.
 private void scheduleTick(int x0, int y0, int z0) {
   TileEntity tileEntity = world.getTileEntity(x0, y0, z0);
   if (tileEntity instanceof TileEntityHopper && tileEntity.world != null) {
     // i is the metadeta assoiated with the direction the hopper faces.
     int i = BlockHopper.b(tileEntity.p());
     // Facing class provides arrays for direction offset.
     if (tileEntity.x + Facing.b[i] == x
         && tileEntity.y + Facing.c[i] == y
         && tileEntity.z + Facing.d[i] == z) {
       ((TileEntityHopper) tileEntity).makeTick();
     }
   }
 }
Пример #4
0
  public boolean i() {
    if (this.world != null && !this.world.isStatic) {
      if (!this.j() && BlockHopper.c(this.p())) {
        boolean flag = this.k();

        flag = suckInItems(this) || flag;
        if (flag) {
          this.c(world.spigotConfig.hopperTransfer); // Spigot
          this.update();
          return true;
        }
      }
      // Spigot start
      if (!this.j()) {
        this.c(world.spigotConfig.hopperCheck);
      }
      // Spigot end
      return false;
    } else {
      return false;
    }
  }