public static Optional<ItemStack> convertToDustIfPossible(final ItemStack stack) { String oreName = OreDictionaryHelper.getOreName(stack); if (oreName == null) return Optional.of(stack); if (oreName.startsWith("ingot")) oreName = StringUtils.replaceOnce(oreName, "ingot", "dust"); else if (oreName.startsWith("plank")) oreName = StringUtils.replaceOnce(oreName, "plank", "dust"); else return Optional.of(stack); return getItemStack(oreName); }
public static Optional<ItemStack> getPreferredStack(final ItemStack stack) { final String oreName = OreDictionaryHelper.getOreName(stack); if (oreName == null || oreName.isEmpty() || "Unknown".compareToIgnoreCase(oreName) == 0) return Optional.of(stack); Optional<ItemStack> newStack = getItemStack(oreName); if (newStack.isPresent()) { final ItemStack result = newStack.get(); result.stackSize = stack.stackSize; newStack = Optional.of(result); } return newStack; }