Home Commands Examples Getting Started With Scripts Global Keywords

LootContextBuilder

Creates a new LootContext using a builder style pattern.

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.

script.zs
import crafttweaker.api.loot.LootContextBuilder;

Static Methods

Return Type: LootContextBuilder

script.zs
LootContextBuilder.copy(context as LootContext) as LootContextBuilder
ParameterType
Parameter
context
Type
LootContext

Creates a new builder with the given level.

Returns: A new builder.
Return Type: LootContextBuilder

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

Methods

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

script.zs
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

Gets the level that this builder uses.

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

script.zs
// LootContextBuilder.getLevel() as ServerLevel
new LootContextBuilder(level).getLevel();

Supplies a seed to be passed into a new Random.

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

script.zs
// 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

Properties

NameTypeHas GetterHas SetterDescription
Name
level
Type
ServerLevel
Has Getter
true
Has Setter
false
Description
Gets the level that this builder uses.