The blockbuilder is used to... build blocks (you totally didn't see that one coming, right... right?).
Once you created it you can set various properties which will be outlined by the separate methods.

You can also change the block's type to create a more specialized form of block (e.g. stairs or Blocks that can be rotated in the same way logs can). To tell CoT that you want the block to appear ingame you need to call this#build(String) and specify a valid resource location path.

This class was added by a mod with mod-id contenttweaker. 因此,如果要使用此功能,则需要安装此mod。

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 mods.contenttweaker.block.BlockBuilder;

已实现的接口

Link to 已实现的接口

BlockBuilder implements the following interfaces. That means all methods defined in these interfaces are also available in BlockBuilder

Constructor #构造函数

Link to constructor-构造函数

Creates a new BlockBuilder.
Remember that this will not create a new block in the game, you need to call this#build(String) for that.

ZenScript
Copy
new BlockBuilder(material as MCMaterial) as BlockBuilder
new BlockBuilder(<blockmaterial:earth>);
参数类型描述可选DefaultValue
参数
material
类型
MCMaterial #MC材料
描述
The material this block will have
可选
true
DefaultValue
blockmaterial:iron

Name: notSolid

Instructs CoT that this block is not solid.

This is required if your model is not a full block (16x16x16). It is also required if your model is see-through (like glass). Set this if your block creates some X-Ray effects when it's placed.

Returns: This builder, used for chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.notSolid() as BlockBuilder

myBlockBuilder.notSolid();

Name: opaque

Sets that the block is opaque, like vanilla glass.

Returns: The builder, used for method chaining.
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.opaque() as BlockBuilder

myBlockBuilder.opaque();

Name: setRequiresTool

Sets that the block needs a tool to harvest.

Returns: This builder, used for method chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.setRequiresTool() as BlockBuilder

myBlockBuilder.setRequiresTool();

Link to withHardnessAndResistance

Name: withHardnessAndResistance

Sets the block's hardness and resistance levels. Unlike the other method, this one only accepts one parameter and will use that value for both properties.

Returns: This builder, used for method chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withHardnessAndResistance(hardnessAndResistance as float) as BlockBuilder

myBlockBuilder.withHardnessAndResistance(0.5f);
参数类型描述
参数
hardnessAndResistance
类型
float
描述
The value to set for hardness and for resistance.

Link to withHardnessAndResistance

Name: withHardnessAndResistance

Sets the block's hardness and resistance levels. Unlike the other method, this one allows you to set each property one to a separate value.

Returns: This builder, used for method chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withHardnessAndResistance(hardnessIn as float, resistanceIn as float) as BlockBuilder

myBlockBuilder.withHardnessAndResistance(0.5f, 0.5f);
参数类型描述
参数
hardnessIn
类型
float
描述
The value to set for hardness
参数
resistanceIn
类型
float
描述
The value to set for resistance.

Link to withHarvestLevel

Name: withHarvestLevel

Sets the mining level required to mine this block

Returns: This builder, used for method chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withHarvestLevel(harvestLevel as int) as BlockBuilder

myBlockBuilder.withHarvestLevel(3);
参数类型描述
参数
harvestLevel
类型
int
描述
The harvest level requried

Name: withHarvestTool

Sets the tool required to harvest this block

Returns: This builder, used for method chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withHarvestTool(harvestTool as ToolType) as BlockBuilder

myBlockBuilder.withHarvestTool(<tooltype:shovel>);
参数类型描述
参数
harvestTool
类型
ToolType
描述
The tool type

Name: withItemGroup

Sets the item group in which this block will appear

Returns: This builder, used for method chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withItemGroup(group as ItemGroup) as BlockBuilder

myBlockBuilder.withItemGroup(<itemgroup:building_blocks>);
参数类型描述
参数
group
类型
ItemGroup
描述
The group to set

Name: withJumpFactor

Sets the jump factor.

Returns: This builder, used for method chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withJumpFactor(jumpFactorIn as float) as BlockBuilder

myBlockBuilder.withJumpFactor(2.5f);
参数类型描述
参数
jumpFactorIn
类型
float
描述
The value to set

Name: withLightValue

Sets the block's light value.

Returns: This builder, used for method chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withLightValue(lightValueIn as int) as BlockBuilder

myBlockBuilder.withLightValue(15);
参数类型描述
参数
lightValueIn
类型
int
描述
The light level to set

Name: withLootFrom

Will instruct CoT to override this block's loot table with the one of the block Provided. Currently this will still create a loot table entry, though it will be ignored by the game.

Returns: This builder, used for method chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withLootFrom(blockIn as MCBlock) as BlockBuilder

myBlockBuilder.withLootFrom(<block:minecraft:diamond>);
参数类型描述
参数
blockIn
类型
MCBlock #MC方块
描述
The block whose loot table should be applied

Link to withMaxStackSize

Name: withMaxStackSize

Sets the maximum Stack size that this block can have when in your inventory. Will be 64 if unchanged.

Returns: This builder, used for chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withMaxStackSize(size as int) as BlockBuilder

myBlockBuilder.withMaxStackSize(16);
参数类型描述
参数
size #大小
类型
int
描述
The size to set.

Name: withRarity

Allows you to set the rarity of this block.

Returns: This builder, used for method chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withRarity(rarity as string) as BlockBuilder

myBlockBuilder.withRarity("UNCOMMON");
参数类型描述
参数
rarity
类型
string
描述
The rarity

Name: withRenderType

Sets the block's render type. Will also set the block as this#notSolid() if the argument is not solid

Returns: This builder, used for method chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withRenderType(renderType as BlockRenderType) as BlockBuilder

myBlockBuilder.withRenderType(BlockRenderType.TRANSLUCENT);
参数类型描述
参数
renderType
类型
BlockRenderType
描述
No Description Provided

Link to withSlipperiness

Name: withSlipperiness

Sets the slipperiness.

Returns: This builder, used for method chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withSlipperiness(slipperinessIn as float) as BlockBuilder

myBlockBuilder.withSlipperiness(0.5f);
参数类型描述
参数
slipperinessIn
类型
float
描述
The value to set

Name: withSpeedFactor

Sets the speed factor.

Returns: This builder, used for method chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withSpeedFactor(speedFactorIn as float) as BlockBuilder

myBlockBuilder.withSpeedFactor(2.5f);
参数类型描述
参数
speedFactorIn
类型
float
描述
The value to set

Link to withTickRandomly

Name: withTickRandomly

Sets that the block should be ticked randomly.

Returns: The builder, used for method chaining.
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withTickRandomly() as BlockBuilder

myBlockBuilder.withTickRandomly();

Name: withType

Sets the specific type of this block. After this method is called the builder's context will switch to the more provided type builder. That means that the methods of this builder will no longer be available, so any properties you wish to set should be set before you call this method.

Returns: A builder with the given block.
Return Type: T

ZenScript
Copy
BlockBuilder.withType<T : BlockTypeBuilder>() as T
参数类型描述
参数
T
类型
BlockTypeBuilder
描述
The Type of block that this should become

Link to withVariableOpacity

Name: withVariableOpacity

Sets that the block has variable opacity.

Returns: The builder, used for method chaining.
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withVariableOpacity() as BlockBuilder

myBlockBuilder.withVariableOpacity();

Name: withoutDrops

Will instruct CoT that this block will not have any loot entries. Currently this will still create a loot table entry, though it will be ignored by the game.

Returns: This builder, used for method chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withoutDrops() as BlockBuilder

myBlockBuilder.withoutDrops();

Link to withoutMovementBlocking

Name: withoutMovementBlocking

Instructs CoT that this block will does not block movement. Will also set the block as this#notSolid()

Returns: This builder, used for chaining
Return Type: BlockBuilder

ZenScript
Copy
// BlockBuilder.withoutMovementBlocking() as BlockBuilder

myBlockBuilder.withoutMovementBlocking();