for(World w : Bukkit.getWorlds()) {
for(Entity e : w.getEntities()) {
if(e instanceof Item) {
Item i = (Item) e;
Location l = i.getLocation();
for (int x = 20 * -1; x <= 20; x++) {
for (int y = 20 * -1; y <= 20; y++) {
for (int z = 20 * -1; z <= 20; z++) {
Block b = l.getWorld().getBlockAt(l.getBlockX() + x, l.getBlockY() + y,
l.getBlockZ() + z);
if(b.getType() != Material.AIR && b.getTypeId() != 0) {
if(i.getItemStack().getType() == Material.CACTUS) {
if(b.getType() == Material.HOPPER) {
Hopper h = (Hopper) b.getState();
if(h.getInventory().firstEmpty() != -1) {
h.getInventory().addItem(i.getItemStack());
i.remove();
return;
}
}
}
}
}
}
}
}
}
}
Há um tempo atrás o @@MrPowerGamerBR estava "tentando" fazer quando um cacto crescesse, o item iria direto para o baú.
Com esse sistema o cacto ira procurar em um raio de 20 blocos, um funil, se acha o item e diretamente depositado para o cacto.
Simples, e facil.