Skip to content
mikalightsmith edited this page Jul 9, 2021 · 4 revisions

This is how to use pycklecraft.

Python basics


Get a connection

import sys
import pycklecraft

mc = pycklecraft.PicklecraftClient('flarion.local', verbose=True)


Get all players

players = mc.players

Get specific player

player = mc.player('jeremylightsmith')
=> {"rotation"=>[-4.4999704, -351.89972], "name"=>"jeremylightsmith", "id"=>1121, "position"=>[100.50084227348208, 68.0, -128.58622119695713]}

To get position information for that player:

=> [100.50084227348208, 68.0, -128.58622119695713]

=> 100

=> 68

=> -128


Place a block

To place a glass block at x,y,z of 200, 300, -500:

mc.place_block('glass', [200, 300, -500])

the 'type' will be one of Block Types (look at the names that start with "minecraft:")

Place many blocks

To fill all the space from one point to another with water:

mc.place_blocks('water', [200, 300, -500], [300, 100, -600])

Place blocks in a line

Given a position and rotation, you can place a line of blocks:

mc.place_blocks_in_line('iron_ore', [100, 200, 300], 194.55, 5)

To place 20 blocks in the direction a player is looking:

mc.place_blocks_in_line('iron_ore', player.position, player.rotation[1], 20)

Get blocks

Get a list of all blocks between points:

mc.get_blocks([100, 150, 100], [110, 150, 120])
=> [
 {'type': 'minecraft:dirt'},
 {'type': 'minecraft:grass_block', 'properties': {'snowy': 'false'}},
 {'type': 'minecraft:air'},
 {'type': 'minecraft:dirt'},
 {'type': 'minecraft:diamond_block'},


Spawn an entity

To place a spider at x,y,z of 200, 300, -500:

mc.spawn_entity('spider', [200, 300, -500])

the first argument will be one of Entity Types (look at the names that start with "minecraft:" - not all of them work for some reason)

Get nearby entities

To get entities within 20 blocks of the player with name 'jeremylightsmith',

entities = mc.nearby_entities('jeremylightsmith', 20)

=> [
  {"rotation"=>[0.0, 144.65784], "name"=>"Skeleton", "id"=>1547, "position"=>[102.94159925548978, 52.0, -116.88061295634945]}, 
  {"rotation"=>[0.0, 269.92163], "name"=>"Zombie", "id"=>1417, "position"=>[112.88471024118915, 71.0, -126.49907592295955]}


Listen for a command

def ice(player, command):
    print("command:", command)

Listen for player movement

def on_player_move(event):
    player = event.player
    print(, " moved to ", player.position)


Set day time

Set time of day with:


Valid values are: day, night, noon, midnight

Lift boot

If you are playing with the "boot" enabled, you won't be able to kill mobs, break blocks, or pickup items. You can lift this "boot" for 30 seconds by calling:



Place a block above a player's head

player = mc.player('jeremylightsmith')
mc.place_block('glass', player.x, player.y + 2, player.z)