return new Vector(r,r,r);
}
}
public static void collectItem(AbstractIC ic, Vector offset, ItemStack... items) {
Sign sign = BukkitUtil.toSign(ic.getSign());
Block backB = ic.getBackBlock();
BlockFace back = SignUtil.getBack(sign.getBlock());
Block pipe = backB.getRelative(back);
// Handle the event
PipeRequestEvent event = new PipeRequestEvent(pipe, new ArrayList<ItemStack>(Arrays.asList(items)), backB);
Bukkit.getPluginManager().callEvent(event);
if (!event.isValid()) return;
Collection<ItemStack> results = event.getItems();
// If there is a chest add the results to the chest
Block invHolder = backB.getRelative(offset.getBlockX(), offset.getBlockY(), offset.getBlockZ());
if (InventoryUtil.doesBlockHaveInventory(invHolder)) {
InventoryHolder c = (InventoryHolder) invHolder.getState();
results = c.getInventory().addItem(results.toArray(new ItemStack[results.size()])).values();
}
// Drop whatever results were not added to the chest
for (ItemStack item : results) {
backB.getWorld().dropItemNaturally(sign.getLocation().add(0.5, 0, 0.5), item);
}
}