-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmcpi_superpowers.py
executable file
·76 lines (54 loc) · 2.31 KB
/
mcpi_superpowers.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
"""
This file gives you super powers in game!
They can be activated by:
- right clicking a block with a sword
- shooting an arrow
- typing specific messages into chat
"""
# These two lines are because of the folder the demos are located in, and aren't normally necessary
import os.path, sys
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))
import mcpi.minecraft as minecraft
import time
# Connect to minecraft server 127.0.0.1 as player 'steve'
mc = minecraft.Minecraft.create(address="127.0.0.1", name="steve")
while True:
for blockhit in mc.player.pollProjectileHits():
# When I shoot an arrow, teleport me to where the arrow lands
pos = blockhit.pos
mc.player.setPos(pos.x, pos.y, pos.z)
for blockhit in mc.player.pollBlockHits():
# When I right click a block with my sword, clear out space
pos = blockhit.pos
mc.setBlocks(pos.x+2, pos.y+2, pos.z+2, pos.x-2, pos.y-2, pos.z-2, 0)
for chatpost in mc.player.pollChatPosts():
if chatpost.message.lower() == "shield":
# Surround myself in bedrock. After 4 seconds, change it to glass.
mc.postToChat("Shield activated!")
pos = mc.player.getTilePos()
mc.player.setPos(pos.x, pos.y, pos.z) #Put player on center of block
x = pos.x-1
y = pos.y-1
z = pos.z-1
x2 = x + 2
y2 = y + 3
z2 = z + 2
bedrock_block_id = 7
mc.setBlocks(x, y, z, x2, y2, z2, bedrock_block_id)
air_block_id = 0
mc.setBlocks(x+1, y+1, z+1, x2-1, y2-1, z2-1, air_block_id)
time.sleep(4)
bedrock_block_id = 20
mc.setBlocks(x, y, z, x2, y2, z2, bedrock_block_id)
air_block_id = 0
mc.setBlocks(x+1, y+1, z+1, x2-1, y2-1, z2-1, air_block_id)
elif chatpost.message.lower() == "imonfire":
# Pour water over me, then replace water with air to cleanup after self.
mc.postToChat("Pouring water over you!")
pos = mc.player.getPos()
water_block_id = 8
mc.setBlock(pos.x, pos.y+3, pos.z, water_block_id)
time.sleep(3)
air_block_id = 0
mc.setBlock(pos.x, pos.y+3, pos.z, air_block_id)
time.sleep(.1)