接口 ICustomIngredient
- 所有已知实现类:
BlockTagIngredient
,CompoundIngredient
,CustomDisplayIngredient
,DataComponentIngredient
,DifferenceIngredient
,IntersectionIngredient
,TestEnabledIngredient
public interface ICustomIngredient
Interface that modders can implement to create new behaviors for
Ingredient
s.
This is not directly implemented on vanilla Ingredient
s, but conversions are possible:
toVanilla()
converts a custom ingredient to a vanillaIngredient
.Ingredient.getCustomIngredient()
retrieves the custom ingredient inside a vanillaIngredient
.
Implementations of this interface must implement Object.equals(java.lang.Object)
and Object.hashCode()
to ensure that the ingredient also supports them.
-
方法概要
修饰符和类型方法说明default SlotDisplay
display()
Returns the display for this ingredient.getType()
返回 the type of this ingredient。boolean
isSimple()
Returns whether this ingredient always requires direct stack testing.items()
返回 the list of items that this ingredient accepts。boolean
Checks if a stack matches this ingredient.default Ingredient
返回 a newIngredient
behaving as defined by this custom ingredient。
-
方法详细资料
-
test
Checks if a stack matches this ingredient. The stack must not be modified in any way.- 参数:
stack
- the stack to test- 返回:
true
if the stack matches this ingredient,false
otherwise
-
items
返回 the list of items that this ingredient accepts。The following guidelines should be followed for good compatibility:
- At least one item must be returned for the ingredient not to be considered empty. Empty ingredients invalidate the entire recipe.
- The ingredient should return all
Item
s it might possible accept. This allows mods that inspect the ingredient to figure out which stacks it might accept. - Returned items might not always be accepted by the ingredient, as an ingredient might still perform additional NBT-dependent tests.
- An exception is ingredients that are simple,
for which
testing a stack
is equivalent to testing if the item is in the returned list.
Note: no caching needs to be done by the implementation, this is already handled by the ingredient itself.
- 返回:
- the list of items that this ingredient accepts
-
isSimple
boolean isSimple()Returns whether this ingredient always requires direct stack testing.- 返回:
true
if this ingredient ignores NBT data when matching stacks,false
otherwise- 另请参阅:
-
getType
IngredientType<?> getType()返回 the type of this ingredient。The type must be registered to
NeoForgeRegistries.INGREDIENT_TYPES
.- 返回:
- the type of this ingredient
-
display
Returns the display for this ingredient.The display is synced to the client, and is also used to retrieve the
ItemStack
s that are shown to the client.- Implementation Note:
- The default implementation just constructs a list of stacks from
items()
. This is generally suitable forsimple
ingredients. Non-simple ingredients can either override this method to provide a more customized display, or let data pack writers useCustomDisplayIngredient
to override the display of an ingredient.
-
toVanilla
返回 a newIngredient
behaving as defined by this custom ingredient。- 返回:
- a new
Ingredient
behaving as defined by this custom ingredient
-