forked from CoderDojoTC/python-minecraft
-
Notifications
You must be signed in to change notification settings - Fork 1
/
danielbates_minecraft_basic.py
executable file
·114 lines (103 loc) · 2.07 KB
/
danielbates_minecraft_basic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# Don't execute this directory -- this is a support script for danielbates_setblockdemo.py
import sys
# Add some common locations where the main API might be. Feel free to add/change
# these to suit you.
sys.path.append("mcpi")
sys.path.append("api/python/mcpi")
sys.path.append("mcpi/api/python/mcpi")
# Attempt to import Mojang's API.
try:
import connection
import minecraft
except ImportError:
print "Unable to find Minecraft API. Please place minecraft_basic.py in the mcpi directory."
exit()
_server = None
_blockedit = None
_playeredit = None
def connect(ip="127.0.0.1", port=4711):
global _server, _blockedit, _playeredit
try:
_server = connection.Connection(ip, port)
_blockedit = minecraft.Minecraft(_server)
_playeredit = _blockedit.player
except Exception:
print "Unable to connect to Minecraft server at {0}:{1}".format(ip,port)
return
print "Connected to Minecraft server at {0}:{1}".format(ip,port)
def setblock(x,y,z,*typedata):
_blockedit.setBlock(x,y,z,typedata)
def getblock(x,y,z):
return _blockedit.getBlock(x,y,z)
def moveplayer(x,y,z):
_playeredit.setPos(x,y,z)
AIR = 0
STONE = 1
GRASS = 2
DIRT = 3
COBBLESTONE = 4
WOOD_PLANK = 5
SAPLING = 6
BEDROCK = 7
WATER_FLOWING = 8
WATER = 9
LAVA_FLOWING = 10
LAVA = 11
SAND = 12
GRAVEL = 13
GOLD_ORE = 14
IRON_ORE = 15
COAL_ORE = 16
WOOD = 17
LEAVES = 18
GLASS = 20
LAPIS_ORE = 21
LAPIS = 22
SANDSTONE = 24
BED = 26
COBWEB = 30
TALL_GRASS = 31
WOOL = 35
FLOWER_YELLOW = 37
FLOWER_RED = 38
MUSHROOM_BROWN = 39
MUSHROOM_RED = 40
GOLD = 41
IRON = 42
STONE_SLAB_DOUBLE = 43
STONE_SLAB = 44
BRICK = 45
TNT = 46
BOOKSHELF = 47
MOSSY_STONE = 48
TORCH = 50
FIRE = 51
WOOD_STAIRS = 53
CHEST = 54
DIAMOND_ORE = 56
DIAMOND = 57
CRAFTING_TABLE = 58
FARMLAND = 60
FURNACE = 61
FURNACE_ACTIVE = 62
WOOD_DOOR = 64
LADDER = 65
COBBLESTONE_STAIRS = 67
IRON_DOOR = 71
REDSTONE_ORE = 73
SNOW_COVER = 78
ICE = 79
SNOW = 80
CACTUS = 81
CLAY = 82
SUGAR_CANE = 83
FENCE = 85
GLOWSTONE = 89
INVISIBLE_BEDROCK = 95
STONE_BRICK = 98
GLASS_PANE = 102
MELON = 103
FENCE_GATE = 107
GLOWING_OBSIDIAN = 246
NETHER_REACTOR_CORE = 247
UPDATE_GAME_BLOCK = 249