Add RecipeChoice.ExactChoice API for NBT matches on ingredients

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2019-01-02 15:56:17 +11:00
parent e943059623
commit e4de4d51ee

View File

@ -108,4 +108,44 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
return "MaterialChoice{" + "choices=" + choices + '}';
}
}
/**
* Represents a choice that will be valid only if a stack is exactly matched
* (aside from stack size).
* <br>
* <b>Not valid for shapeless recipes</b>
*
* @deprecated draft API
*/
@Deprecated
public static class ExactChoice implements RecipeChoice {
private ItemStack stack;
public ExactChoice(ItemStack stack) {
Preconditions.checkArgument(stack != null, "stack");
this.stack = stack;
}
@Override
public ItemStack getItemStack() {
return stack;
}
@Override
public ExactChoice clone() {
try {
ExactChoice clone = (ExactChoice) super.clone();
clone.stack = stack.clone();
return clone;
} catch (CloneNotSupportedException ex) {
throw new AssertionError(ex);
}
}
@Override
public boolean test(ItemStack t) {
return stack.equals(t);
}
}
}