Skip to content
Lawrence G edited this page May 24, 2016 · 27 revisions

Language - English | Spanish

defineBlock

function Block.defineBlock(blockId, name, [[textureName, offset]], type, transparency, renderType);
  • The parameters blockId, type, renderType accept an integer
  • The parameter textureName accepts a string and offset accepts a float
  • The parameter "name" accepts a string.
  • The parameter transparency accepts a boolean.

Notes:

  • The textures parameter accepts an array of arrays. Make sure to use the right spelling of the texture name. ModPE will give you errors if the texture does not exist. You can create a custom texture by replacing the image that the texture name complies with. Offset is for if there are multiple variants of the same texture. The default value is zero.
  • type is the block that your custom one is based on, so ModPE can decide on which tools are best to break this, for example if the type was the ID for wood, then an axe would be best to break it.

setColor

function Block.setColor(blockId, color);
  • The parameter blockId accepts an integer.
  • The parameter color accepts a hex color code in a string.

Note: If you don't know the hex codes for COLOR then use this website to help you.

setDestroyTime

function Block.setDestroyTime(blockId, time);
  • The parameters blockId, time accepts an integer.

Note: The second parameter (time) is actually the hardness of the block, not the time it takes to destroy the block. This allows different breaking times for different tools.

setLightLevel

function Block.setLightLevel(blockId, lightLevel);
  • The parameters blockId, lightLevel accept integers.

setLightOpacity

function Block.setLightOpacity(blockId, lightOpacity);
  • In blockId you have to put the ID of the block. In lightOpacity, you have to put a low number if you don't want bugs. Example:
Block.setLightOpacity(blockId, 0.000001);

setShape

function Block.setShape(blockId, x1, y1, z1, x2, y2, z2);
  • The parameters blockId, x1, y1, z1, x2, y2, z2 accept an integer.

Notes:

  • x1, y1, z1 are the starting points of the block.
  • x2, y2, z2 are the finishing points of the block.

Example:

  • y1 = 0.5 and y2 = 2 would mean that the block is 1.5 blocks high (2 - 0.5 = 1.5), and that when placed will spawn 0.5 blocks off the ground (like a slab) and will stop at 2 blocks higher than where you placed it.

WARNING: THIS WILL ALSO CHANGE THE SHAPE IN YOUR HOTBAR, SO IF YOU SET IT BIG, IT WON'T FIT IN YOUR HOTBAR BOX! IT MAY ALSO HAVE STRANGE TEXTURES IF IT IS OVER 4 BLOCKS WIDE OR TALL.

Some other functions not listed above

Block.getRenderType(blockId);
Block.setExplosionResistance(blockId, resistance);
Block.setRenderLayer(blockId, renderLayer);
Block.setRenderType(blockId, renderType);

Easy Block Making:

function newBlock(blockId,name,textureName,offset,type,transparency,renderType,destroyTime,lightLevel,color) {
  Block.defineBlock(blockId,name,[[textureName, offset]],type,transparency,renderType);
  Block.setDestroyTime(blockId,destroyTime);
  Block.setLightLevel(blockId, lightLevel);
  Block.setColor(blockId,color);
}

Call newBlock with the parameters:

  • blockId - id of the new block
  • name - name of the new block
  • textureName, offset - texture names and offsets
  • type - type of block
  • transparency - transparency (BOOLEAN)
  • renderType - render type
  • destroyTime - destroy time
  • lightLevel - light level
  • color - Color

This is an easier way to make blocks. Enjoy!

Example Block

Block.defineBlock(200, "Ultimate Block", [["diamond_block", 0]], 7, false); // Defines the block
Block.setDestroyTime(200, -1); // Just like Bedrock, unbreakable except in creative mode
Block.setShape(200, 0, 0.5, 0, 1, 1, 1); // Like a combined upside-down slab and an upright slab on top of it
Block.setLightLevel(200, 15); // Glow in the dark
Block.setLightOpacity(200, .0000001); // Light can't pass through this block!

Texture Names

The link below includes all available texture names for custom blocks!