-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathm2.9.py
27 lines (21 loc) · 771 Bytes
/
m2.9.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
from mcpi_e.minecraft import Minecraft
from mcpi_e import block
serverAddress = "localhost" # change to your minecraft server
playerName = "stoneskin2020"
pythonApiPort = 4711
mc = Minecraft.create(serverAddress,pythonApiPort,playerName)
pos = mc.player.getPos()
x = pos.x
y = pos.y
z = pos.z
blockTypeId=mc.getBlock(x,y,z)
if(blockTypeId==block.WATER.id):
mc.postToChat("["+playerName+"]: I am swimming!")
elif(blockTypeId==block.AIR.id):
mc.postToChat("["+playerName+"]: I am flying!")
else:
mc.postToChat("[{}]: I am on block {}".format(playerName,blockTypeId))
if(blockTypeId ==block.DIRT.id or blockTypeId == block.GRASS.id):
mc.postToChat("I am on the ground.")
if(blockTypeId <0 and blockTypeId >252):
print("It's not a valid blockId")