@EventHandler
 public void onInteract(PlayerInteractEvent pie) {
   if (pie.getAction().equals(Action.RIGHT_CLICK_BLOCK)
       || pie.getAction().equals(Action.RIGHT_CLICK_AIR)) {
     Player player = pie.getPlayer();
     World world = player.getWorld();
     if (player.getInventory().getItemInHand() != null) {
       ItemStack item = player.getInventory().getItemInHand();
       if (item.getType().equals(Material.DOUBLE_PLANT)) {
         pie.setCancelled(true);
         Item bomb = world.dropItem(player.getEyeLocation(), new ItemStack(Material.GOLD_BLOCK));
         bomb.setPickupDelay(Integer.MAX_VALUE);
         bomb.setVelocity(player.getLocation().getDirection().multiply(0.5));
         double radius = 1.5;
         for (double i = 0; i <= 20D; i += 0.1) {
           Item coin = world.dropItem(bomb.getLocation(), new ItemStack(Material.DOUBLE_PLANT));
           double x = Math.sin(radius * i);
           double z = Math.cos(radius * i);
           Bukkit.getScheduler()
               .scheduleSyncDelayedTask(
                   Factions.instance,
                   new Runnable() {
                     public void run() {}
                   },
                   1);
         }
       }
     }
   }
 }
    public ItemProjectile(Player caster, float power) {
      this.caster = caster;
      this.power = power;
      Location location = caster.getEyeLocation().add(0, yOffset, 0);
      location.setPitch(0f);
      if (vertSpeedUsed) {
        vel = caster.getLocation().getDirection().setY(0).multiply(speed).setY(vertSpeed);
      } else {
        vel = caster.getLocation().getDirection().multiply(speed);
      }
      entity = caster.getWorld().dropItem(location, item.clone());
      MagicSpells.getVolatileCodeHandler().setGravity(entity, projectileHasGravity);
      playSpellEffects(EffectPosition.PROJECTILE, entity);
      playTrackingLinePatterns(
          EffectPosition.DYNAMIC_CASTER_PROJECTILE_LINE,
          caster.getLocation(),
          entity.getLocation(),
          caster,
          entity);
      entity.teleport(location);
      entity.setPickupDelay(1000000);
      entity.setVelocity(vel);

      taskId = MagicSpells.scheduleRepeatingTask(this, 3, 3);
    }
 @Override
 void onUpdate() {
   final Item ITEM =
       ent.getWorld()
           .dropItem(
               ((Sheep) ent).getEyeLocation(),
               ItemFactory.create(
                   Material.WOOL, (byte) r.nextInt(017), UUID.randomUUID().toString()));
   ITEM.setPickupDelay(30000);
   ITEM.setVelocity(
       new Vector(r.nextDouble() - 0.5, r.nextDouble() / 2.0 + 0.3, r.nextDouble() - 0.5)
           .multiply(0.4));
   items.add(ITEM);
   Bukkit.getScheduler()
       .runTaskLater(
           Core.getPlugin(),
           new Runnable() {
             @Override
             public void run() {
               ITEM.remove();
               items.remove(ITEM);
             }
           },
           5);
 }
 @Override
 public void run() {
   for (Entity e : entity.getNearbyEntities(hitRadius, hitRadius + 0.5, hitRadius)) {
     if (e instanceof LivingEntity && validTargetList.canTarget(caster, (LivingEntity) e)) {
       SpellTargetEvent event =
           new SpellTargetEvent(ItemProjectileSpell.this, caster, (LivingEntity) e, power);
       Bukkit.getPluginManager().callEvent(event);
       if (!event.isCancelled()) {
         if (spellOnHitEntity != null) {
           spellOnHitEntity.castAtEntity(caster, (LivingEntity) e, event.getPower());
         }
         stop();
         return;
       }
     }
   }
   if (entity.isOnGround()) {
     groundCount++;
   } else {
     groundCount = 0;
   }
   if (groundCount >= 2) {
     if (spellOnHitGround != null) {
       spellOnHitGround.castAtLocation(caster, entity.getLocation(), power);
     }
     stop();
   }
 }
  public void drop(Location loc) {
    PartyRoom.debug(
        owner.getName()
            + " got OwnedItemStack of type "
            + item.getType()
            + ":"
            + item.getDurability()
            + " at "
            + Utilities.LocToString(loc));

    final Item itemEntity = loc.getWorld().dropItem(loc, item);
    itemEntity.setMetadata("owner", new FixedMetadataValue(PartyRoom.getPlugin(), owner.getName()));
    new BukkitRunnable() {
      int cycle = 0;

      public void run() {
        if (itemEntity.isDead() || itemEntity == null) {
          itemEntity.removeMetadata("owner", PartyRoom.getPlugin());
          this.cancel();
          return;
        }
        if (cycle > 60) {
          itemEntity.removeMetadata("owner", PartyRoom.getPlugin());
          this.cancel();
          return;
        }
        cycle++;
      }
    }.runTaskTimer(PartyRoom.getPlugin(), 20L, 20L);
  }
  /**
   * Called when a player attempts to pickup an item
   *
   * @param event Relevant event details
   */
  @Override
  public void onPlayerPickupItem(PlayerPickupItemEvent event) {

    if (event.isCancelled()) {
      return;
    }

    GlobalConfiguration cfg = plugin.getGlobalConfiguration();
    WorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName());

    if (wcfg.getBlacklist() != null) {
      Item ci = event.getItem();

      if (!wcfg.getBlacklist()
          .check(
              new ItemAcquireBlacklistEvent(
                  BukkitPlayer.wrapPlayer(plugin, event.getPlayer()),
                  toVector(ci.getLocation()),
                  ci.getItemStack().getTypeId()),
              false,
              false)) {
        event.setCancelled(true);
        return;
      }
    }
  }
示例#7
0
 public void pickupItem(Item item) {
   ((CraftServer) DeityNPCMain.plugin.getServer())
       .getServer()
       .getTracker(((CraftWorld) this.getWorld()).getHandle().dimension)
       .a(entity, new Packet22Collect(item.getEntityId(), this.getEntityId()));
   item.remove();
 }
  /** ItemDespawnEvent */
  public static ItemDespawnEvent callItemDespawnEvent(EntityItem entityitem) {
    org.bukkit.entity.Item entity = (org.bukkit.entity.Item) getBukkitEntity(entityitem);

    ItemDespawnEvent event = new ItemDespawnEvent(entity, entity.getLocation());

    ((BukkitServer) entity.getServer()).getPluginManager().callEvent(event);
    return event;
  }
示例#9
0
  private void tossItem(ItemStack dropItem) {
    Location loc = player.getLocation();
    loc.setY(loc.getY() + 1);

    Item item = loc.getWorld().dropItem(loc, dropItem);
    Vector v = loc.getDirection().multiply(0.2);
    v.setY(0.2);
    item.setVelocity(v);
  }
示例#10
0
  @Override
  @SuppressWarnings("deprecation")
  public void onDropItem(LWCDropItemEvent event) {
    Player bPlayer = event.getPlayer();
    Item item = event.getEvent().getItemDrop();
    ItemStack itemStack = item.getItemStack();

    LWCPlayer player = lwc.wrapPlayer(bPlayer);
    int protectionId = getPlayerDropTransferTarget(player);

    if (protectionId == -1) {
      return;
    }

    if (!isPlayerDropTransferring(player)) {
      return;
    }

    Protection protection = lwc.getPhysicalDatabase().loadProtection(protectionId);

    if (protection == null) {
      lwc.sendLocale(player, "lwc.nolongerexists");
      player.disableMode(player.getMode("dropTransfer"));
      return;
    }

    // load the world and the inventory
    World world = player.getServer().getWorld(protection.getWorld());

    if (world == null) {
      lwc.sendLocale(player, "lwc.invalidworld");
      player.disableMode(player.getMode("dropTransfer"));
      return;
    }

    // Don't allow them to transfer items across worlds
    if (bPlayer.getWorld() != world
        && !lwc.getConfiguration().getBoolean("modes.droptransfer.crossWorld", false)) {
      lwc.sendLocale(player, "lwc.dropxfer.acrossworlds");
      player.disableMode(player.getMode("dropTransfer"));
      return;
    }

    Block block = world.getBlockAt(protection.getX(), protection.getY(), protection.getZ());
    Map<Integer, ItemStack> remaining = lwc.depositItems(block, itemStack);

    if (remaining.size() > 0) {
      lwc.sendLocale(player, "lwc.dropxfer.chestfull");

      for (ItemStack temp : remaining.values()) {
        bPlayer.getInventory().addItem(temp);
      }
    }

    bPlayer.updateInventory(); // if they're in the chest and dropping items, this is required
    item.remove();
  }
 public void onPlayerPickupItem(PlayerPickupItemEvent event) {
   SpoutPlayer sPlayer = SpoutManager.getPlayer(event.getPlayer());
   Item item = event.getItem();
   String music = plugin.config.getString("effect." + item.getItemStack().getType().name(), "");
   if (music == "") {
     music = plugin.config.getString("effect.DEFAULT", "");
   }
   if (music != "") {
     SpoutManager.getSoundManager().playCustomSoundEffect(plugin, sPlayer, music, true);
   }
 }
示例#12
0
  /**
   * Get item results from Fishing.
   *
   * @param player The player that was fishing
   * @param event The event to modify
   */
  private static void getFishingResults(Player player, PlayerFishEvent event) {
    PlayerProfile PP = Users.getProfile(player);
    List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
    Item theCatch = (Item) event.getCaught();

    switch (getFishingLootTier(PP)) {
      case 1:
        rewards = LoadTreasures.fishingRewardsTier1;
        break;

      case 2:
        rewards = LoadTreasures.fishingRewardsTier2;
        break;

      case 3:
        rewards = LoadTreasures.fishingRewardsTier3;
        break;

      case 4:
        rewards = LoadTreasures.fishingRewardsTier4;
        break;

      case 5:
        rewards = LoadTreasures.fishingRewardsTier5;
        break;

      default:
        break;
    }

    if (LoadProperties.fishingDrops) {
      FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));

      if (random.nextDouble() * 100 <= treasure.getDropChance()) {
        Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp());
        theCatch.setItemStack(treasure.getDrop());
      }
    } else {
      theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
    }

    short maxDurability = theCatch.getItemStack().getType().getMaxDurability();

    if (maxDurability > 0) {
      theCatch
          .getItemStack()
          .setDurability(
              (short) (random.nextInt(maxDurability))); // Change durability to random value
    }

    m.mcDropItem(player.getLocation(), new ItemStack(Material.RAW_FISH)); // Always drop a fish
    PP.addXP(SkillType.FISHING, LoadProperties.mfishing);
    Skills.XpCheckSkill(SkillType.FISHING, player);
  }
示例#13
0
 public Item makeDisplay() {
   HyperEconomy he = hc.getEconomyManager().getEconomy("default");
   Location l = new Location(w, x, y + 1, z);
   ItemStack dropstack = he.getHyperItem(name).getItemStack();
   dropstack.setDurability((short) he.getHyperItem(name).getDurability());
   this.item = w.dropItem(l, dropstack);
   this.entityId = item.getEntityId();
   item.setVelocity(new Vector(0, 0, 0));
   item.setMetadata("HyperConomy", new FixedMetadataValue(hc, "item_display"));
   return item;
 }
示例#14
0
文件: BTest.java 项目: Rayzr522/Quake
  @Override
  public void call(Event event) {

    PlayerDropItemEvent e = (PlayerDropItemEvent) event;

    if (e.getItemDrop().getItemStack().getType() == Material.SULPHUR) {

      Item item = e.getItemDrop();

      item.getWorld().createExplosion(item.getLocation(), 10f, false);
    }
  }
 @EventHandler(ignoreCancelled = true)
 public void onPickupItem(PlayerPickupItemEvent event) {
   Item item = event.getItem();
   ProjectileInfo info = itemProjectiles.get(item);
   if (info != null) {
     event.setCancelled(true);
     projectileHitEntity(item, event.getPlayer(), info);
     item.remove();
     itemProjectiles.remove(item);
     info.monitor.stop();
   }
 }
 @Override
 void onInteractRightClick() {
   getPlayer().playSound(getPlayer().getLocation(), Sound.EXPLODE, 1, 1);
   Item item =
       getPlayer()
           .getWorld()
           .dropItem(
               getPlayer().getEyeLocation(),
               ItemFactory.create(Material.MELON_BLOCK, (byte) 0x0, UUID.randomUUID().toString()));
   item.setPickupDelay(0);
   item.setVelocity(getPlayer().getEyeLocation().getDirection().multiply(1.3d));
   melonBlocks.add(item);
 }
示例#17
0
 public void clearNearbyItems() {
   if (item == null) {
     return;
   }
   List<Entity> nearbyEntities = item.getNearbyEntities(7, 7, 7);
   for (Entity entity : nearbyEntities) {
     if (entity instanceof Item) {
       Item nearbyItem = (Item) entity;
       boolean display = false;
       for (MetadataValue cmeta : nearbyItem.getMetadata("HyperConomy")) {
         if (cmeta.asString().equalsIgnoreCase("item_display")) {
           display = true;
           break;
         }
       }
       if (!nearbyItem.equals(item) && !display) {
         if (nearbyItem.getItemStack().getType() == item.getItemStack().getType()) {
           HyperItemStack near = new HyperItemStack(nearbyItem.getItemStack());
           HyperItemStack displayItem = new HyperItemStack(item.getItemStack());
           if (near.getDamageValue() == displayItem.getDamageValue()) {
             entity.remove();
           }
         }
       }
     }
   }
 }
  @EventHandler
  public void onPlayerMonkeyBomb(PlayerInteractEvent event) {
    if (!(event.getAction().equals(Action.RIGHT_CLICK_AIR))
        || !(event.getAction().equals(Action.RIGHT_CLICK_AIR))) {
      return;
    }
    if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
      if (event.getClickedBlock().getType().equals(Material.SIGN)
          || event.getClickedBlock().getType().equals(Material.SIGN_POST)
          || event.getClickedBlock().getType().equals(Material.WALL_SIGN)) {
        return;
      }
    }
    final Player player = event.getPlayer();
    if (plugin.manager.isPlayerInGame(player)) {
      Game game = plugin.manager.getGame(player);
      if (!(game.mode == ArenaStatus.INGAME)) {
        return;
      }
      if (player.getItemInHand().getType().equals(Material.MAGMA_CREAM)) {
        player.getInventory().removeItem(new ItemStack(Material.MAGMA_CREAM, 1));
        final Item item =
            player
                .getWorld()
                .dropItemNaturally(player.getEyeLocation(), new ItemStack(Material.MAGMA_CREAM));
        // Location Iloc = item.getLocation();
        item.setVelocity(player.getLocation().getDirection().multiply(1));
        item.setPickupDelay(1000);
        /*for(Entity e: game.spawnManager.mobs)
        {

        }*/
        Bukkit.getScheduler()
            .scheduleSyncDelayedTask(
                plugin,
                new Runnable() {
                  @Override
                  public void run() {
                    Location loc = item.getLocation();
                    player
                        .getWorld()
                        .createExplosion(loc.getX(), loc.getY(), loc.getZ(), 4.0F, false, false);
                    item.remove();
                  }
                },
                140);
      }
    }
  }
  @EventHandler(priority = EventPriority.LOWEST)
  public void onItemDrop(PlayerDropItemEvent event) {
    if (event.isCancelled()) return;

    final Player player = event.getPlayer();
    final Item item = event.getItemDrop();

    if (item == null) return;
    if (player.getWorld() != plugin.getIslandWorld()) return;
    if (player.isOp()) return;
    if (player.hasPermission("islandworld.bypass.island")) return;

    if (!(plugin.canBuildOnLocation(player, item.getLocation()))) event.setCancelled(true);

    plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled());
  }
示例#20
0
  void removeItems(Material material, org.bukkit.Location location, float maximumDistance) {
    // find items to remove
    List<Item> itemsToRemove = new ArrayList<Item>();
    for (Item item : location.getWorld().getEntitiesByClass(Item.class)) {
      ItemStack stack = item.getItemStack();
      if (stack.getType() == material) {
        if (item.getLocation().distance(location) <= maximumDistance) {
          itemsToRemove.add(item);
        }
      }
    }

    // remove items
    for (Item item : itemsToRemove) {
      item.remove();
    }
  }
 @Override
 public void run() {
   Vector v = item.getVelocity();
   if (Math.abs(v.getY()) < .01 || (Math.abs(v.getX()) < .01 && Math.abs(v.getZ()) < .01)) {
     ProjectileInfo info = itemProjectiles.get(item);
     if (info != null) {
       projectileHitLocation(item, info);
       stop();
     }
   }
   if (effectInterval > 0 && count % effectInterval == 0) {
     playSpellEffects(EffectPosition.SPECIAL, item.getLocation());
   }
   if (++count > 300) {
     stop();
   }
 }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerPickupItemEvent(PlayerPickupItemEvent event) {
    if (event.isCancelled()) return;

    final Player player = event.getPlayer();
    final Item item = event.getItem();

    if (player.getWorld() != plugin.getIslandWorld()) return;
    if (player.isOp()) return;
    if (player.hasPermission("islandworld.bypass.island")) return;

    if (item != null
        && !(plugin.getConfig().getBoolean("flags.item-pickup", false)
            || plugin.canBuildOnLocation(player, item.getLocation()))) event.setCancelled(true);

    plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled());
  }
示例#23
0
  /**
   * Process results from Fishing.
   *
   * @param event The event to modify
   */
  public static void processResults(PlayerFishEvent event) {
    Player player = event.getPlayer();
    PlayerProfile PP = Users.getProfile(player);

    getFishingResults(player, event);
    Item theCatch = (Item) event.getCaught();

    if (theCatch.getItemStack().getType() != Material.RAW_FISH) {
      final int ENCHANTMENT_CHANCE = 10;
      boolean enchanted = false;
      ItemStack fishingResults = theCatch.getItemStack();

      player.sendMessage(mcLocale.getString("Fishing.ItemFound"));
      if (ItemChecks.isArmor(fishingResults) || ItemChecks.isTool(fishingResults)) {
        if (random.nextInt(100) <= ENCHANTMENT_CHANCE) {
          for (Enchantment newEnchant : Enchantment.values()) {
            if (newEnchant.canEnchantItem(fishingResults)) {
              Map<Enchantment, Integer> resultEnchantments = fishingResults.getEnchantments();

              for (Enchantment oldEnchant : resultEnchantments.keySet()) {
                if (oldEnchant.conflictsWith(newEnchant)) {
                  return;
                }
              }

              /* Actual chance to have an enchantment is related to your fishing skill */
              if (random.nextInt(15) < Fishing.getFishingLootTier(PP)) {
                enchanted = true;
                int randomEnchantLevel = random.nextInt(newEnchant.getMaxLevel()) + 1;

                if (randomEnchantLevel < newEnchant.getStartLevel()) {
                  randomEnchantLevel = newEnchant.getStartLevel();
                }

                fishingResults.addEnchantment(newEnchant, randomEnchantLevel);
              }
            }
          }
        }
      }

      if (enchanted) {
        player.sendMessage(mcLocale.getString("Fishing.MagicFound"));
      }
    }
  }
示例#24
0
 public static void attemptSecond(Player p) {
   if (cooldown2.containsKey(p.getName())) {
     p.sendMessage(
         ChatColor.RED
             + "Cooldown: "
             + ChatColor.YELLOW
             + cooldown2.get(p.getName())
             + ChatColor.RED
             + ".");
     return;
   }
   cooldown2.put(p.getName(), 2.0);
   Item i =
       p.getWorld().dropItem(p.getLocation().clone().add(0, 1.8, 0), new ItemStack(Material.TNT));
   i.setPickupDelay(1000);
   i.setVelocity(p.getLocation().getDirection().multiply(0.7));
   Game.playSound(Sound.FIZZ, p.getLocation(), 0.6f, 0.3f);
   tnts.add(i.getUniqueId());
 }
示例#25
0
  @EventHandler
  public void onChunkUnload(ChunkUnloadEvent event) {
    ArrayList<Item> items = new ArrayList<Item>();

    for (Entity entity : event.getChunk().getEntities()) {
      if (entity instanceof Item) {
        items.add((Item) entity);
      }
    }

    for (ItemStack itemStack : plugin.items.keySet()) {
      for (Item item : items) {
        if (item.getItemStack().equals(itemStack)) {
          event.setCancelled(true);
          return;
        }
      }
    }
  }
示例#26
0
  public static void itemToRemove(
      Location l, Material tipo, byte id, long tempoToRemove, boolean randomVector, Vector vector) {
    final ItemStack item = new ItemStack(tipo, 1, id);

    final Item drop = l.getWorld().dropItem(l, item);
    drop.setPickupDelay(Integer.MAX_VALUE);
    if (randomVector) {
      drop.setVelocity(vector);
    }
    Bukkit.getScheduler()
        .scheduleSyncDelayedTask(
            plugin,
            new Runnable() {

              @Override
              public void run() {
                drop.remove();
              }
            },
            tempoToRemove * 20);
  }
示例#27
0
  /** Called if the chunk is unloaded, the plugin is unloaded, etc. */
  public void onRemove() {
    if (mHoveringItem != null) {
      mHoveringItem.remove();
      mHoveringItem = null;
    }

    if (mEventListener != null) {
      mEventListener = null;
    }

    mIsLoaded = false;
  }
示例#28
0
  /** Called when loading data. If overriding, remember to call this version */
  public void readFromNBT(NBTTagCompound root) {
    mLocation =
        new Location(
            Bukkit.getWorld(root.getString("World")),
            root.getDouble("X"),
            root.getDouble("Y"),
            root.getDouble("Z"));

    mHoverItemTemplate = Util.readItemStackFromNBT(root);

    // Check for existing item
    Collection<Item> items = mLocation.getWorld().getEntitiesByClass(Item.class);
    Location loc = mLocation.clone().add(0, 1, 0);

    for (Item item : items) {
      if (item.getItemStack().equals(mHoverItemTemplate)
          && item.getLocation().distanceSquared(loc) < 1D
          && !item.isDead()) {
        SkyQuestPlugin.instance.getLogger().fine("Attaching old item");
        // Reattach the item
        mHoveringItem = item;
        break;
      }
    }
    // Spawn a new item if needed
    if (mHoveringItem == null) {
      SkyQuestPlugin.instance.getLogger().fine("Spawning new item");
      mHoveringItem =
          mLocation.getWorld().dropItem(mLocation.clone().add(0.5, 1, 0.5), mHoverItemTemplate);
      mHoveringItem.setVelocity(new Vector(0, 0, 0));
    }

    // Register the event listener
    mEventListener = new PedestalListener();
    SkyQuestPlugin.instance
        .getServer()
        .getPluginManager()
        .registerEvents(mEventListener, SkyQuestPlugin.instance);
  }
示例#29
0
  protected PedestalBase(ItemStack pedistalType, ItemStack hoverItem, Location pedestalLocation) {
    mIsLoaded = true;
    mLocation = pedestalLocation.clone();
    mLocation
        .getBlock()
        .setTypeIdAndData(pedistalType.getTypeId(), pedistalType.getData().getData(), true);

    mHoverItemTemplate = hoverItem.clone();

    // Check for existing item
    Collection<Item> items = mLocation.getWorld().getEntitiesByClass(Item.class);
    Location loc = mLocation.clone().add(0, 1, 0);

    for (Item item : items) {
      if (item.getItemStack().equals(hoverItem)
          && item.getLocation().distanceSquared(loc) < 1D
          && !item.isDead()) {
        // Reattach the item
        mHoveringItem = item;
        SkyQuestPlugin.instance.getLogger().fine("Attaching old item");
        break;
      }
    }
    // Spawn a new item if needed
    if (mHoveringItem == null) {
      SkyQuestPlugin.instance.getLogger().fine("Spawning new item");
      mHoveringItem =
          mLocation.getWorld().dropItem(mLocation.clone().add(0.5, 1, 0.5), mHoverItemTemplate);
      mHoveringItem.setVelocity(new Vector(0, 0, 0));
    }

    // Register the event listener
    mEventListener = new PedestalListener();
    SkyQuestPlugin.instance
        .getServer()
        .getPluginManager()
        .registerEvents(mEventListener, SkyQuestPlugin.instance);
  }
示例#30
0
  public boolean collect() {

    boolean collected = false;

    for (Entity entity : LocationUtil.getNearbyEntities(centre, radius)) {
      if (entity.isValid() && entity instanceof Item) {
        if (LocationUtil.isWithinRadius(centre, entity.getLocation(), radius)) {

          stackCheck:
          {
            ItemStack stack = ((Item) entity).getItemStack();

            if (!ItemUtil.isStackValid(stack)) return false;

            for (ItemStack filter : filters) {

              if (!ItemUtil.isStackValid(filter)) continue;

              if (include && !ItemUtil.areItemsIdentical(filter, stack)) break stackCheck;
              else if (!include && ItemUtil.areItemsIdentical(filter, stack)) break stackCheck;
            }

            BlockFace back = SignUtil.getBack(BukkitUtil.toSign(getSign()).getBlock());
            Block pipe = getBackBlock().getRelative(back);

            Pipes pipes = Pipes.Factory.setupPipes(pipe, getBackBlock(), stack);

            if (pipes != null && pipes.getItems().isEmpty()) return true;

            // Add the items to a container, and destroy them.
            List<ItemStack> leftovers =
                InventoryUtil.addItemsToInventory((InventoryHolder) chest.getState(), stack);
            if (leftovers.isEmpty()) {
              entity.remove();
              return true;
            } else {
              if (ItemUtil.areItemsIdentical(leftovers.get(0), stack)
                  && leftovers.get(0).getAmount() != stack.getAmount()) {
                ((Item) entity).setItemStack(leftovers.get(0));
                return true;
              }
            }
          }
        }
      }
    }

    return collected;
  }