LootContextBuilder
Link to lootcontextbuilder
Creates a new LootContext using a builder style pattern.
导入类
Link to 导入类
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.LootContextBuilder;
Static Methods
Link to static-methods
Name: copy
Return Type: LootContextBuilder
ZenScript CopyLootContextBuilder.copy(context as LootContext) as LootContextBuilder
参数 | 类型 |
---|---|
参数 上下文: | 类型 LootContext |
Name: create
Creates a new builder with the given level.
Returns: A new builder.
Return Type: LootContextBuilder
ZenScript CopyLootContextBuilder.create(level as ServerLevel) as LootContextBuilder
参数 | 类型 | 描述 |
---|---|---|
参数 level | 类型 ServerLevel | 描述 The level the loot will be rolled in. |
使用方式
Link to 使用方式
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());
参数 | 类型 | 描述 |
---|---|---|
参数 contextParamSet | 类型 LootContextParamSet | 描述 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();
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 CopyLootContextBuilder.getOptionalParameter<T : Object>(contextParam as LootContextParam<T>) as @org.openzen.zencode.java.ZenCodeType.Nullable T
参数 | 类型 | 描述 |
---|---|---|
参数 contextParam | 类型 LootContextParam<T> | 描述 The LootContextParam<T> to get the value of. |
参数 T | 类型 Object | 描述 The type that the LootContextParam<T> uses |
Name: getParameter
Gets the provided value of the parameter.
Returns: The found value.
Return Type: T
ZenScript CopyLootContextBuilder.getParameter<T : Object>(contextParam as LootContextParam<T>) as T
参数 | 类型 | 描述 |
---|---|---|
参数 contextParam | 类型 LootContextParam<T> | 描述 The LootContextParam<T> to get the value of. |
参数 T | 类型 Object | 描述 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);
参数 | 类型 | 描述 |
---|---|---|
参数 luck | 类型 float | 描述 The luck value to use. |
Name: withOptionalParameter
Provides an optional parameter to this builder.
Returns: This builder for chaining purposes.
Return Type: LootContextBuilder
ZenScript CopyLootContextBuilder.withOptionalParameter<T : Object>(contextParam as LootContextParam<T>, actor as @org.openzen.zencode.java.ZenCodeType.Nullable T) as LootContextBuilder
参数 | 类型 | 描述 |
---|---|---|
参数 contextParam | 类型 LootContextParam<T> | 描述 The param to add. |
参数 actor | 类型 @org.openzen.zencode.java.ZenCodeType.Nullable T | 描述 The optional actor used by the param. |
参数 T | 类型 Object | 描述 The type of actor that the param uses. |
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);
参数 | 类型 | 描述 |
---|---|---|
参数 seed | 类型 long | 描述 The seed to use. |
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 Random) as LootContextBuilder
new LootContextBuilder(level).withOptionalRandomSeed(1, level.random);
参数 | 类型 | 描述 |
---|---|---|
参数 seed | 类型 long | 描述 The seed to use. |
参数 random | 类型 Random | 描述 The random source to provide. |
Name: withParameter
Provides a parameter to this builder.
Returns: This builder for chaining purposes.
Return Type: LootContextBuilder
ZenScript CopyLootContextBuilder.withParameter<T : Object>(contextParam as LootContextParam<T>, actor as T) as LootContextBuilder
参数 | 类型 | 描述 |
---|---|---|
参数 contextParam | 类型 LootContextParam<T> | 描述 The param to add. |
参数 actor | 类型 T | 描述 The actor used by the param. |
参数 T | 类型 Object | 描述 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 Random) as LootContextBuilder
new LootContextBuilder(level).withRandom(level.random);
参数 | 类型 | 描述 |
---|---|---|
参数 random | 类型 Random | 描述 The random source to provide. |
名称 | 类型 | 可获得 | 可设置 | 描述 |
---|---|---|---|---|
名称 level | 类型 ServerLevel | 可获得 true | 可设置 false | 描述 Gets the level that this builder uses. |