Home Getting Started With Scripts Using this wiki Commands CTGUI Global functions Bracket Handlers

IBlockDefinition

The IBlockDefinition objects provide additional information on blocks.

Importing the package

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.
import crafttweaker.block.IBlockDefinition;

Calling an IBlockDefinition object

  • Using the definition ZenGetter on an IBlock object.

Calling an IBlockDefinition List

  • Using game.blocks to get a list of all block definition in the game.

ZenGetters/ZenSetters

ZenGetterZenSetterWhat does it doType
ZenGetter
canSpawnInBlock
ZenSetter
What does it do
Returns true if an entity can spawn in this block
Type
bool
ZenGetter
creativeTab
ZenSetter
creativeTab
What does it do
Type
ICreativeTab
ZenGetter
defaultState
ZenSetter
What does it do
Type
IBlockState
ZenGetter
ZenSetter
defaultSlipperiness
What does it do
Type
float
ZenGetter
id
ZenSetter
What does it do
Returns the block ID
Type
string
ZenGetter
displayName
ZenSetter
What does it do
Returns the block’s DisplayName
Type
string
ZenGetter
hardness
ZenSetter
hardness
What does it do
Type
int
ZenGetter
harvestLevel
ZenSetter
What does it do
Returns the block’s harvest level
Type
int
ZenGetter
harvestTool
ZenSetter
What does it do
Returns the block’s harvest tool
Type
string
ZenGetter
lightOpacity
ZenSetter
lightOpacity
What does it do
Type
int
ZenGetter
lightLevel
ZenSetter
lightLevel
What does it do
Type
int
ZenGetter
resistance
ZenSetter
resistance
What does it do
Type
int
ZenGetter
unlocalizedName
ZenSetter
What does it do
Returns the block’s unlocalized Name
Type
string
ZenGetter
tickRandomly
ZenSetter
tickRandomly
What does it do
Type
bool

ZenMethods

Set Block unbreakable

Uses no paramaeters.
Returns nothing.
Does the same as hardness = -1;

script.zs
defObj.setUnbreakable();

Get tickrate in a specific world

Uses an IWorld object.
Returns an int.

script.zs
defObj.getTickRate(IWorld world);

Check if the block can be placed on another block

Uses an IWorld object, an IBlockPos object and, depending on the method used, also an IFacing object.
Returns a bool.

script.zs
defObj.canPlaceBlockOnSide(IWorld world, IBlockPos pos, IFacing facing);
defObj.canPlaceBlockAt(IWorld world, IBlockPos pos);

Get the block’s slipperiness

Uses an IBlockState, an IBlockAccess object, an IBlockPos and an optional IEntity object.
Returns a float.

script.zs
defObj.getSlipperiness(IBlockState state, IBlockAccess access, IBlockPos pos, @Optional IEntity entity);

Set the block’s harvest level

Uses a string, an int and an optional IBlockState.
if the IBlockState argument is ignored, it will set harvest level to all block states in the block definition.
Returns void (nothing).

script.zs
defObj.setHarvestLevel(string toolclass, int level, @Optional IBlockState state);

Get harvest level of block state

returns an int.

script.zs
defObj.getHarvestLevel(IBlockState state);

Get harvest tool of block state

returns a string.

script.zs
defObj.getHarvestTool(IBlockState state);

Get light opacity of block state

returns a float.

script.zs
defObj.getLightOpacity(IBlockState state);
defObj.getLightOpacity(IBlockState state, IWorld world, IBlockPos pos);

Get light level of block state

returns a float.

script.zs
defObj.getLightLevel(IBlockState state);
defObj.getLightLevel(IBlockState state, IWorld world, IBlockPos pos);

Get explosion resistance of block position and explosion

returns a float.

script.zs
defObj.getResistance(IWorld world, IBlockPos pos, IEntity entity, IExplosion explosion);

Get a block state by metadata

Uses an int.
Returns an IBlockState.

script.zs
defObj.getStateFromMeta(int meta);

Block effective for the tool

Uses a string and an IBlockState.
Returns a bool.

script.zs
defObj.isToolEffective(String type, IBlockState state);