Home Migration Guide Getting Started With Scripts Commands Examples
Generic JSON Recipes

BlockBuilder

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. So you need to have this mod installed if you want to use this feature.

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

Implemented Interfaces

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

Constructors

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.

script.zs
new BlockBuilder(material as MCMaterial) as BlockBuilder
new BlockBuilder(<blockmaterial:earth>);
ParameterTypeDescriptionOptionalDefaultValue
Parameter
material
Type
MCMaterial
Description
The material this block will have
Optional
true
DefaultValue
blockmaterial:iron

Methods

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

script.zs
// BlockBuilder.notSolid() as BlockBuilder
myBlockBuilder.notSolid();

Sets that the block is opaque, like vanilla glass.

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

script.zs
// BlockBuilder.opaque() as BlockBuilder
myBlockBuilder.opaque();

Sets that the block needs a tool to harvest.

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

script.zs
// BlockBuilder.setRequiresTool() as BlockBuilder
myBlockBuilder.setRequiresTool();

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

script.zs
// BlockBuilder.withHardnessAndResistance(hardnessAndResistance as float) as BlockBuilder
myBlockBuilder.withHardnessAndResistance(0.5f);
ParameterTypeDescription
Parameter
hardnessAndResistance
Type
float
Description
The value to set for hardness and for resistance.

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

script.zs
// BlockBuilder.withHardnessAndResistance(hardnessIn as float, resistanceIn as float) as BlockBuilder
myBlockBuilder.withHardnessAndResistance(0.5f, 0.5f);
ParameterTypeDescription
Parameter
hardnessIn
Type
float
Description
The value to set for hardness
Parameter
resistanceIn
Type
float
Description
The value to set for resistance.

Sets the mining level required to mine this block

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

script.zs
// BlockBuilder.withHarvestLevel(harvestLevel as int) as BlockBuilder
myBlockBuilder.withHarvestLevel(3);
ParameterTypeDescription
Parameter
harvestLevel
Type
int
Description
The harvest level requried

Sets the tool required to harvest this block

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

script.zs
// BlockBuilder.withHarvestTool(harvestTool as ToolType) as BlockBuilder
myBlockBuilder.withHarvestTool(<tooltype:shovel>);
ParameterTypeDescription
Parameter
harvestTool
Type
ToolType
Description
The tool type

Sets the item group in which this block will appear

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

script.zs
// BlockBuilder.withItemGroup(group as ItemGroup) as BlockBuilder
myBlockBuilder.withItemGroup(<itemgroup:building_blocks>);
ParameterTypeDescription
Parameter
group
Type
ItemGroup
Description
The group to set

Sets the jump factor.

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

script.zs
// BlockBuilder.withJumpFactor(jumpFactorIn as float) as BlockBuilder
myBlockBuilder.withJumpFactor(2.5f);
ParameterTypeDescription
Parameter
jumpFactorIn
Type
float
Description
The value to set

Sets the block’s light value.

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

script.zs
// BlockBuilder.withLightValue(lightValueIn as int) as BlockBuilder
myBlockBuilder.withLightValue(15);
ParameterTypeDescription
Parameter
lightValueIn
Type
int
Description
The light level to set

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

script.zs
// BlockBuilder.withLootFrom(blockIn as MCBlock) as BlockBuilder
myBlockBuilder.withLootFrom(<block:minecraft:diamond>);
ParameterTypeDescription
Parameter
blockIn
Type
MCBlock
Description
The block whose loot table should be applied

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

script.zs
// BlockBuilder.withMaxStackSize(size as int) as BlockBuilder
myBlockBuilder.withMaxStackSize(16);
ParameterTypeDescription
Parameter
size
Type
int
Description
The size to set.

Allows you to set the rarity of this block.

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

script.zs
// BlockBuilder.withRarity(rarity as string) as BlockBuilder
myBlockBuilder.withRarity("UNCOMMON");
ParameterTypeDescription
Parameter
rarity
Type
string
Description
The rarity

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

script.zs
// BlockBuilder.withRenderType(renderType as BlockRenderType) as BlockBuilder
myBlockBuilder.withRenderType(BlockRenderType.TRANSLUCENT);
ParameterTypeDescription
Parameter
renderType
Type
BlockRenderType
Description
No Description Provided

Sets the slipperiness.

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

script.zs
// BlockBuilder.withSlipperiness(slipperinessIn as float) as BlockBuilder
myBlockBuilder.withSlipperiness(0.5f);
ParameterTypeDescription
Parameter
slipperinessIn
Type
float
Description
The value to set

Sets the speed factor.

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

script.zs
// BlockBuilder.withSpeedFactor(speedFactorIn as float) as BlockBuilder
myBlockBuilder.withSpeedFactor(2.5f);
ParameterTypeDescription
Parameter
speedFactorIn
Type
float
Description
The value to set

Sets that the block should be ticked randomly.

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

script.zs
// BlockBuilder.withTickRandomly() as BlockBuilder
myBlockBuilder.withTickRandomly();

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

script.zs
BlockBuilder.withType<T : BlockTypeBuilder>() as T
ParameterTypeDescription
Parameter
T
Type
BlockTypeBuilder
Description
The Type of block that this should become

Sets that the block has variable opacity.

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

script.zs
// BlockBuilder.withVariableOpacity() as BlockBuilder
myBlockBuilder.withVariableOpacity();

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

script.zs
// BlockBuilder.withoutDrops() as BlockBuilder
myBlockBuilder.withoutDrops();

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

script.zs
// BlockBuilder.withoutMovementBlocking() as BlockBuilder
myBlockBuilder.withoutMovementBlocking();