ItemStack removable = //стак который нужно удалить;
int total = //сколько нужно удалить;
for (ItemStack stack : player.getInventory().getContents()) {
if (stack == null || stack.getType() == Material.AIR) continue;
if (stack.isSimilar(removable)) {
if (total - stack.getAmount() < 0) {
int remove = stack.getAmount() - total;
stack.setAmount(remove);
total -= remove;
} else {
stack.setAmount(0);
total -= 64;
}
}
}