LootContextBuilder

Link to lootcontextbuilder

Creates a new LootContext using a builder style pattern.

Importing the class

Link to importing-the-class

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
ParameterType
Parameter
context
Type
LootContext

Name: create

Creates a new builder with the given level.

Returns: A new builder.
Return Type: LootContextBuilder

ZenScript
Copy
LootContextBuilder.create(params as LootParams) as LootContextBuilder
ParameterTypeDescription
Parameter
params
Type
LootParams
Description
The params the loot will be rolled with.

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(key as ResourceLocation) as LootContext
ParameterTypeDescriptionOptional
Parameter
key
Type
ResourceLocation
Description
An optional random key used when no seed is provided.
Optional
true

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 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(1);
ParameterTypeDescriptionOptionalDefault Value
Parameter
seed
Type
long
Description
The optional seed to use, defaults to 0.
Optional
true
Default Value
0
NameTypeHas GetterHas SetterDescription
Name
level
Type
ServerLevel
Has Getter
true
Has Setter
false
Description
Gets the level that this builder uses.