LootContextBuilder

Link to lootcontextbuilder

Creates a new LootContext using a builder style pattern.

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
Copy
import crafttweaker.api.loot.LootContextBuilder;

Name: copy

Return Type: LootContextBuilder

ZenScript
Copy
LootContextBuilder.copy(context as LootContext) as LootContextBuilder
ParametroTipo
Parametro
contesto
Tipo
LootContext

Name: create

Creates a new builder with the given level.

Returns: A new builder.
Return Type: LootContextBuilder

ZenScript
Copy
LootContextBuilder.create(level as ServerLevel) as LootContextBuilder
ParametroTipoDescrizione
Parametro
level
Tipo
ServerLevel
Descrizione
The level the loot will be rolled in.

Name: create

Creates a new LootContext with the given LootContextParamSet.

The given LootContextParamSet is used to determine what values are required for the context to be used.

Returns: a new LootContext
Return Type: LootContext

ZenScript
Copy
// LootContextBuilder.create(contextParamSet as LootContextParamSet) as LootContext

new LootContextBuilder(level).create(LootContextParamSets.gift());
ParametroTipoDescrizione
Parametro
contextParamSet
Tipo
LootContextParamSet
Descrizione
The LootContextParamSet to use.

Name: getLevel

Gets the level that this builder uses.

Returns: The level that this builder uses.
Return Type: ServerLevel

ZenScript
Copy
// LootContextBuilder.getLevel() as ServerLevel

new LootContextBuilder(level).getLevel();

Link to getOptionalParameter

Name: getOptionalParameter

Gets the provided value of the optional parameter.

Returns: The value if found, null otherwise.
Return Type: @org.openzen.zencode.java.ZenCodeType.Nullable T

ZenScript
Copy
LootContextBuilder.getOptionalParameter<T : Object>(contextParam as LootContextParam<T>) as @org.openzen.zencode.java.ZenCodeType.Nullable T
ParametroTipoDescrizione
Parametro
contextParam
Tipo
LootContextParam<T>
Descrizione
The LootContextParam<T> to get the value of.
Parametro
T
Tipo
Object
Descrizione
The type that the LootContextParam<T> uses

Name: getParameter

Gets the provided value of the parameter.

Returns: The found value.
Return Type: T

ZenScript
Copy
LootContextBuilder.getParameter<T : Object>(contextParam as LootContextParam<T>) as T
ParametroTipoDescrizione
Parametro
contextParam
Tipo
LootContextParam<T>
Descrizione
The LootContextParam<T> to get the value of.
Parametro
T
Tipo
Object
Descrizione
The type that the LootContextParam<T> uses

Name: withLuck

Provides the given luck value to the context.

Returns: This builder for chaining purposes.
Return Type: LootContextBuilder

ZenScript
Copy
// LootContextBuilder.withLuck(luck as float) as LootContextBuilder

new LootContextBuilder(level).withLuck(0.5);
ParametroTipoDescrizione
Parametro
luck
Tipo
float
Descrizione
The luck value to use.

Link to withOptionalParameter

Name: withOptionalParameter

Provides an optional parameter to this builder.

Returns: This builder for chaining purposes.
Return Type: LootContextBuilder

ZenScript
Copy
LootContextBuilder.withOptionalParameter<T : Object>(contextParam as LootContextParam<T>, actor as @org.openzen.zencode.java.ZenCodeType.Nullable T) as LootContextBuilder
ParametroTipoDescrizione
Parametro
contextParam
Tipo
LootContextParam<T>
Descrizione
The param to add.
Parametro
actor
Tipo
@org.openzen.zencode.java.ZenCodeType.Nullable T
Descrizione
The optional actor used by the param.
Parametro
T
Tipo
Object
Descrizione
The type of actor that the param uses.

Link to withOptionalRandomSeed

Name: withOptionalRandomSeed

Supplies a seed to be passed into a new Random.

Returns: This builder for chaining purposes.
Return Type: LootContextBuilder

ZenScript
Copy
// LootContextBuilder.withOptionalRandomSeed(seed as long) as LootContextBuilder

new LootContextBuilder(level).withOptionalRandomSeed(0);
ParametroTipoDescrizione
Parametro
seed
Tipo
long
Descrizione
The seed to use.

Link to withOptionalRandomSeed

Name: withOptionalRandomSeed

Supplies either a seed to be passed into a new Random or if the seed is 0 use the given Random

Returns: This builder for chaining purposes.
Return Type: LootContextBuilder

ZenScript
Copy
// LootContextBuilder.withOptionalRandomSeed(seed as long, random as RandomSource) as LootContextBuilder

new LootContextBuilder(level).withOptionalRandomSeed(1, level.random);
ParametroTipoDescrizione
Parametro
seed
Tipo
long
Descrizione
The seed to use.
Parametro
random
Tipo
RandomSource
Descrizione
The random source to provide.

Name: withParameter

Provides a parameter to this builder.

Returns: This builder for chaining purposes.
Return Type: LootContextBuilder

ZenScript
Copy
LootContextBuilder.withParameter<T : Object>(contextParam as LootContextParam<T>, actor as T) as LootContextBuilder
ParametroTipoDescrizione
Parametro
contextParam
Tipo
LootContextParam<T>
Descrizione
The param to add.
Parametro
actor
Tipo
T
Descrizione
The actor used by the param.
Parametro
T
Tipo
Object
Descrizione
The type of actor that the param uses.

Name: withRandom

Supplies a Random source to the built context.

Returns: This builder for chaining purposes.
Return Type: LootContextBuilder

ZenScript
Copy
// LootContextBuilder.withRandom(random as RandomSource) as LootContextBuilder

new LootContextBuilder(level).withRandom(level.random);
ParametroTipoDescrizione
Parametro
random
Tipo
RandomSource
Descrizione
The random source to provide.
NomeTipoHa GetterHa SetterDescrizione
Nome
level
Tipo
ServerLevel
Ha Getter
Ha Setter
no
Descrizione
Gets the level that this builder uses.