LootConditionBuilder
Link to lootconditionbuilder
Manages the creation of one or multiple ILootConditions using the builders provided by ILootConditionTypeBuilder.
Each instance of this class may handle the presence of more than one conditions. On the other hand, some builders may require the presence of at most one condition. Refer to their documentation for more information.
This builder does not force any particular interpretation in case of multiple conditions being added: they may be merged together via 'AND', 'OR', or not merged together at all. It is up to the user of the builder to decide how the merges should happen.
Importare la Classe
Link to importare-la-classe
It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.
ZenScript Copyimport crafttweaker.api.loot.conditions.LootConditionBuilder;
Static Methods
Link to static-methods
Name: create
Creates a new empty LootConditionBuilder.
Returns: The newly created instance.
Return Type: LootConditionBuilder
ZenScript Copy// LootConditionBuilder.create() as LootConditionBuilder
LootConditionBuilder.create();
Name: createForSingle
Creates a new LootConditionBuilder and automatically adds a single condition of the specified type.
This is merely a helper method to avoid multiple method calls and chains when the user needs to create a builder
but only wants to add a single condition to it. It is effectively a call to create
followed by one
to add
.
Returns: The newly created builder, already containing the created condition.
Return Type: LootConditionBuilder
ZenScript CopyLootConditionBuilder.createForSingle<T : ILootConditionTypeBuilder>(lender as Consumer<T>) as LootConditionBuilder
Parametro | Tipo | Descrizione |
---|---|---|
Parametro lender | Tipo Consumer<T> | Descrizione A consumer that allows configuration of the given condition. |
Parametro T | Tipo ILootConditionTypeBuilder | Descrizione The known type of the condition itself. |
Name: createInAnd
Creates a new LootConditionBuilder containing an And.
This ensures that, no matter what the underlying implementation may assume, the various conditions will be
treated as part of an 'And' condition. Refer to And for more information.
Returns: The newly created instance, containing the 'And' condition.
Return Type: LootConditionBuilder
ZenScript CopyLootConditionBuilder.createInAnd(lender as Consumer<And>) as LootConditionBuilder
Parametro | Tipo | Descrizione |
---|---|---|
Parametro lender | Tipo Consumer<And> | Descrizione A consumer used to configure an And condition builder. |
Name: createInOr
Creates a new LootConditionBuilder containing an Or.
This ensures that, no matter what the underlying implementation may assume, the various conditions will be
treated as part of an 'Or' condition. Refer to Or for more information.
Returns: The newly created instance, containing the 'Or' condition.
Return Type: LootConditionBuilder
ZenScript CopyLootConditionBuilder.createInOr(lender as Consumer<Or>) as LootConditionBuilder
Parametro | Tipo | Descrizione |
---|---|---|
Parametro lender | Tipo Consumer<Or> | Descrizione A consumer used to configure an Or condition builder. |
Name: makeJson
Creates an ILootCondition of the given type
parsing the given json
.
The JSON must respect the constraints specified in the documentation of the Json
loot condition.
If no valid condition is found, or the JSON is invalid, an error gets thrown.
Returns: An ILootCondition instance built according to the given data, if possible.
Return Type: ILootCondition
ZenScript CopyLootConditionBuilder.makeJson(type as MCResourceLocation, data as IData) as ILootCondition
Parametro | Tipo | Descrizione |
---|---|---|
Parametro type | Tipo MCResourceLocation | Descrizione A MCResourceLocation identifying the type of the loot condition to create. |
Parametro data | Tipo IData | Descrizione The JSON data, according to the given constraints. |
Name: makeJson
Creates an ILootCondition of the given type
parsing the given json
.
The name is treated as a MCResourceLocation, lacking the type safety of the bracket handler. For this
reason, it's suggested to prefer the method with a MCResourceLocation as parameter.
The JSON must respect the constraints specified in the documentation of the Json
loot condition.
If no valid condition is found, or the JSON is invalid, an error gets thrown.
Returns: An ILootCondition instance built according to the given data, if possible.
Return Type: ILootCondition
ZenScript CopyLootConditionBuilder.makeJson(type as string, data as IData) as ILootCondition
Parametro | Tipo | Descrizione |
---|---|---|
Parametro type | Tipo string | Descrizione A string in resource location format identifying the type of the loot condition to create. |
Parametro data | Tipo IData | Descrizione The JSON data, according to the given constraints. |
Name: makeSingle
Creates a new ILootCondition of the given type, according to the parameters specified in the
lender
.
In other words, a new ILootCondition is created based on the chosen ILootConditionTypeBuilder.
This is particularly useful if the creation of a single loot condition is required and the user wants to use one
of the already existing builders.
Returns: The condition created by the builder itself.
Return Type: ILootCondition
ZenScript CopyLootConditionBuilder.makeSingle<T : ILootConditionTypeBuilder>(lender as Consumer<T>) as ILootCondition
Parametro | Tipo | Descrizione |
---|---|---|
Parametro lender | Tipo Consumer<T> | Descrizione A consumer that allows configuration of the given condition. |
Parametro T | Tipo ILootConditionTypeBuilder | Descrizione The known type of the condition itself. |
Metodi
Link to metodi
Name: add
Adds a new condition of the given type to the ones of this builder.
The condition is built according to the defaults of the ILootConditionTypeBuilder specified. It is thus assumed that the default values lead to a well-formed and correct loot condition. If such isn't the case, then the method may behave erratically or throw an exception: refer to the two parameter version of add
for the method that allows configuration.
Returns: This builder for chaining.
Return Type: LootConditionBuilder
ZenScript CopyLootConditionBuilder.add<T : ILootConditionTypeBuilder>() as LootConditionBuilder
Parametro | Tipo | Descrizione |
---|---|---|
Parametro T | Tipo ILootConditionTypeBuilder | Descrizione The known type of the condition itself. |
Name: add
Adds a new condition of the given type and configuration to the ones of this builder.
The condition is built according to the specified ILootConditionTypeBuilder and configured according to the details given in lender
. If the default configuration is satisfying, then the single parameter version of add
may also be used.
Returns: This builder for chaining.
Return Type: LootConditionBuilder
ZenScript CopyLootConditionBuilder.add<T : ILootConditionTypeBuilder>(lender as Consumer<T>) as LootConditionBuilder
Parametro | Tipo | Descrizione |
---|---|---|
Parametro lender | Tipo Consumer<T> | Descrizione A consumer that allows configuration of the given condition. |
Parametro T | Tipo ILootConditionTypeBuilder | Descrizione The known type of the condition itself. |
Name: build
Builds the current builder, returning all its contents as an array of ILootConditions.
The builder may then be re-used for additional purposes, though this is not suggested.
Returns: The current set of built conditions.
Return Type: ILootCondition[]
ZenScript Copy// LootConditionBuilder.build() as ILootCondition[]
myLootConditionBuilder.build();