IBlockDefinition

Link to iblockdefinition

The IBlockDefinition objects provide additional information on blocks.

Dieses Paket importieren

Link to dieses-paket-importieren

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

Link to calling-an-iblockdefinition-object

  • Using the definition ZenGetter on an IBlock object.

Calling an IBlockDefinition List

Link to calling-an-iblockdefinition-list

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

ZenGetter/ZenSetter

Link to zengetterzensetter

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

Set Block unbreakable

Link to set-block-unbreakable

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

ZenScript
Copy
defObj.setUnbreakable();

Get tickrate in a specific world

Link to get-tickrate-in-a-specific-world

Uses an IWorld object.
Returns an int.

ZenScript
Copy
defObj.getTickRate(IWorld world);

Check if the block can be placed on another block

Link to 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.

ZenScript
Copy
defObj.canPlaceBlockOnSide(IWorld world, IBlockPos pos, IFacing facing);
defObj.canPlaceBlockAt(IWorld world, IBlockPos pos);

Get the block's slipperiness

Link to get-the-blocks-slipperiness

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

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

Set the block's harvest level

Link to set-the-blocks-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).

ZenScript
Copy
defObj.setHarvestLevel(string toolclass, int level, @Optional IBlockState state);

Get harvest level of block state

Link to get-harvest-level-of-block-state

returns an int.

ZenScript
Copy
defObj.getHarvestLevel(IBlockState state);

Get harvest tool of block state

Link to get-harvest-tool-of-block-state

returns a string.

ZenScript
Copy
defObj.getHarvestTool(IBlockState state);

Get light opacity of block state

Link to get-light-opacity-of-block-state

returns a float.

ZenScript
Copy
defObj.getLightOpacity(IBlockState state);
defObj.getLightOpacity(IBlockState state, IWorld world, IBlockPos pos);

Get light level of block state

Link to get-light-level-of-block-state

returns a float.

ZenScript
Copy
defObj.getLightLevel(IBlockState state);
defObj.getLightLevel(IBlockState state, IWorld world, IBlockPos pos);

Get explosion resistance of block position and explosion

Link to get-explosion-resistance-of-block-position-and-explosion

returns a float.

ZenScript
Copy
defObj.getResistance(IWorld world, IBlockPos pos, IEntity entity, IExplosion explosion);

Get a block state by metadata

Link to get-a-block-state-by-metadata

Uses an int.
Returns an IBlockState.

ZenScript
Copy
defObj.getStateFromMeta(int meta);

Block effective for the tool

Link to block-effective-for-the-tool

Uses a string and an IBlockState.
Returns a bool.

ZenScript
Copy
defObj.isToolEffective(String type, IBlockState state);