Minecraft Block APIs

Minecraft and Ready Set STEM provide a number of APIs that allow us to manipulate blocks in various ways. We'll be using many of these APIs in upcoming projects, but in the meantime, we want to provide a general overview of the block functions, how they work and what arguments are required to make use of these functions.

Each block in the Minecraft world has a "type" (what the block is made out of) and each type of block can have additional characteristics associated with it (the block "data"). For example, blocks with the type "WOOD" can also have data associated with them that indicate the wood block is made from "Oak," or "Birch" or "Spruce."

Note that in Minecraft, everything is made of blocks, including the air. The blocks that make up the air in Minecraft function exactly the same as all other blocks, but have the specific type of "AIR." If you want to "remove" a block from Minecraft, you can change it's type to AIR.

The following sections list the most commonly used block-related functions provided in the Ready Set STEM API.

getBlock()

The getBlock() function takes the location of a block (in X, Y, Z coordinates) and returns the type of block at that location.

For example, to get the block type for the block at the location 0, 0, 0:

See below for the different types of blocks supported in the Minecraft Pi edition.

getBlockWithData()

The getBlockWithData() function takes the location of a block (in X, Y, Z coordinates) and returns the type of block at that location, along with other characteristics of the block.

For example, to get the block type and data for the block at the location 0, 0, 0:

See below for the different types of block data supported in the Minecraft Pi edition.

setBlock()

The setBlock() function takes a location (and optionally a set of data) and places a block with that data type at the location.

For example, to place a wood block made of Oak at location 0, 0, 0:

setBlocks()

The setBlocks() function takes two locations (and optionally a set of data) and places a cuboid (three dimensional rectangular) set of blocks with that data type at all the points between those locations.

For example, to place a set of 125 wood blocks made of Oak in a cuboid with one corner located at 0, 0, 0 and the farthest corner located at 5, 5, 5:

getHeight()

The getHeight() function takes a two-dimensional x, z location and returns the height of the highest block at that location.

For example, to find the height of the highest non-air block at the location 0, 0:

Usable Blocks

Block Types

Here is a table of all block types available in the Minecraft Pi Edition:

Block Type

Value

block.AIR

0

block.STONE

1

block.GRASS

2

block.DIRT

3

block.COBBLESTONE

4

block.WOOD_PLANKS

5

block.SAPLING

6

block.BEDROCK

7

block.WATER_FLOWING

8

block.WATER

8

block.WATER_STATIONARY

9

block.LAVA_FLOWING

10

block.LAVA

10

block.LAVA_STATIONARY

11

block.SAND

12

block.GRAVEL

13

block.GOLD_ORE

14

block.IRON_ORE

15

block.COAL_ORE

16

block.WOOD

17

block.LEAVES

18

block.GLASS

20

block.LAPIS_LAZULI_ORE

21

block.LAPIS_LAZULI_BLOCK

22

block.SANDSTONE

24

block.BED

26

block.COBWEB

30

block.GRASS_TALL

31

block.WOOL

35

block.FLOWER_YELLOW

37

block.FLOWER_CYAN

38

block.MUSHROOM_BROWN

39

block.MUSHROOM_RED

40

block.GOLD_BLOCK

41

block.IRON_BLOCK

42

block.STONE_SLAB_DOUBLE

43

block.STONE_SLAB

44

block.BRICK_BLOCK

45

block.TNT

46

block.BOOKSHELF

47

block.MOSS_STONE

48

block.OBSIDIAN

49

block.TORCH

50

block.FIRE

51

block.STAIRS_WOOD

53

block.CHEST

54

block.DIAMOND_ORE

56

block.DIAMOND_BLOCK

57

block.CRAFTING_TABLE

58

block.FARMLAND

60

block.FURNACE_INACTIVE

61

block.FURNACE_ACTIVE

62

block.DOOR_WOOD

64

block.LADDER

65

block.STAIRS_COBBLESTONE

67

block.DOOR_IRON

71

block.REDSTONE_ORE

73

block.SNOW

78

block.ICE

79

block.SNOW_BLOCK

80

block.CACTUS

81

block.CLAY

82

block.SUGAR_CANE

83

block.FENCE

85

block.GLOWSTONE_BLOCK

89

block.BEDROCK_INVISIBLE

95

block.STONE_BRICK

98

block.GLASS_PANE

102

block.MELON

103

block.FENCE_GATE

107

block.GLOWING_OBSIDIAN

246

block.NETHER_REACTOR_CORE

247

Block Data

Here is a list of all block data types available in the Minecraft Pi Edition. The block data types are only applicable to certain block types:

WOOL:

Block Data Value

Description

0

White

1

Orange

2

Magenta

3

Light Blue

4

Yellow

5

Lime

6

Pink

7

Grey

8

Light gray

9

Cyan

10

Purple

11

Blue

12

Brown

13

Green

14

Red

15

Black

WOOD:

Block Data Value

Description

0

Oak (up/down)

1

Spruce (up/down)

2

Birch (up/down)

SAPLING:

Block Data Value

Description

0

Oak

1

Spruce

2

Birch

GRASS_TALL:

Block Data Value

Description

0

Shrub

1

Grass

2

Fern

TORCH:

Block Data Value

Description

1

Pointing east

2

Pointing west

3

Pointing south

4

Pointing north

5

Facing up

STONE_BRICK:

Block Data Value

Description

0

Stone brick

1

Mossy stone brick

2

Cracked stone brick

3

Chiseled stone brick

STONE_SLAB / STONE_SLAB_DOUBLE:

Block Data Value

Description

0

Stone

1

Sandstone

2

Wooden

3

Cobblestone

4

Brick

5

Stone Brick

TNT:

Block Data Value

Description

0

Inactive

1

Ready to explode

LEAVES:

Block Data Value

Description

1

Oak leaves

2

Spruce leaves

3

Birch leaves

SANDSTONE:

Block Data Value

Description

0

Sandstone

1

Chiseled sandstone

2

Smooth sandstone

STAIRS_COBBLESTONE, STAIRS_WOOD:

Block Data Value

Description

0

Ascending east

1

Ascending west

2

Ascending south

3

Ascending north

4

Ascending east (upside down)

5

Ascending west (upside down)

6

Ascending south (upside down)

7

Ascending north (upside down)

LADDERS, CHESTS, FURNACES, FENCE_GATE:

Block Data Value

Description

2

Facing north

3

Facing south

4

Facing west

5

Facing east

WATER_STATIONARY, LAVA_STATIONARY:

Block Data Value

Description

0-7

Level of the water, 0 being the highest, 7 the lowest

NETHER_REACTOR_CORE:

Block Data Value

Description

0

Unused

1

Active

2

Stopped / used up