mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-20 22:42:10 +01:00
Add RecipeChoice.ExactChoice API for NBT matches on ingredients
By: md_5 <git@md-5.net>
This commit is contained in:
parent
e943059623
commit
e4de4d51ee
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user