int z = b.getZ();
Block bl = BukkitUtil.toSign(getSign()).getBlock().getWorld().getBlockAt(x, y, z);
ItemStack stack = null;
Inventory inv = null;
if (bl.getType() == Material.CHEST) {
Chest c = (Chest) bl.getState();
for (ItemStack it : c.getInventory().getContents()) {
if (ItemUtil.isStackValid(it)) {
if(item == null || ItemUtil.areItemsIdentical(it, item)) {
stack = it;
inv = c.getInventory();
break;
}
}
}
} else if (bl.getType() == Material.FURNACE || bl.getType() == Material.BURNING_FURNACE) {
Furnace c = (Furnace) bl.getState();
stack = c.getInventory().getResult();
inv = c.getInventory();
} else if (bl.getType() == Material.BREWING_STAND) {
BrewingStand c = (BrewingStand) bl.getState();
for (ItemStack it : c.getInventory().getContents()) {
if (ItemUtil.isStackValid(it)) {
if (ItemUtil.areItemsIdentical(it, c.getInventory().getIngredient())) {
continue;
}
if(item == null || ItemUtil.areItemsIdentical(it, item)) {
stack = it;
inv = c.getInventory();
break;
}
}
}
} else if (bl.getType() == Material.DISPENSER) {
Dispenser c = (Dispenser) bl.getState();
for (ItemStack it : c.getInventory().getContents()) {
if (ItemUtil.isStackValid(it)) {
if(item == null || ItemUtil.areItemsIdentical(it, item)) {
stack = it;
inv = c.getInventory();
break;
}
}
}
}