Home Commands Examples Getting Started With Scripts Global Keywords
BracketDumpers BracketHandlers BracketValidators ResourceLocationBracketHandler

LootContextBuilder

Importing the class

If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.

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

Description

Creates a new LootContext using a builder style pattern.

Members

static copy(context as LootContext) as Builder
script.zs
// Builder.copy(context as LootContext) as Builder;
LootContextBuilder.copy(myLootContext);

Parameters:

context Type: LootContext

Return Type: LootContextBuilder

static create(params as LootParams) as Builder
Creates a new builder with the given level.

Returns: A new builder.

script.zs
// Builder.create(params as LootParams) as Builder;
LootContextBuilder.create(myLootParams);

Parameters:

params Type: LootParams - The params the loot will be rolled with.

Return Type: LootContextBuilder

create(key as ResourceLocation = null) as LootContext
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

script.zs
// Builder.create(key as ResourceLocation = null) as LootContext;
myBuilder.create(myResourceLocation);

Parameters:

key (optional) Type: ResourceLocation - An optional random key used when no seed is provided.

Default Value: null

Return Type: LootContext

Getter
Gets the level that this builder uses.
script.zs
// Builder.level as ServerLevel
myBuilder.level

Return Type: ServerLevel

level() as ServerLevel
Gets the level that this builder uses.

Returns: The level that this builder uses.

script.zs
// Builder.level() as ServerLevel;
myBuilder.level();

Return Type: ServerLevel

withOptionalRandomSeed(seed as long = 0) as Builder
Supplies a seed to be passed into a new Random.

Returns: This builder for chaining purposes.

script.zs
// Builder.withOptionalRandomSeed(seed as long = 0) as Builder;
myBuilder.withOptionalRandomSeed(1);

Parameters:

seed (optional) Type: long - The optional seed to use, defaults to 0.

Default Value: 0

Return Type: LootContextBuilder