forked from mikemccllstr/mikemccllstr-python-minecraft
-
Notifications
You must be signed in to change notification settings - Fork 2
/
obsidz_teleport.py
executable file
·86 lines (71 loc) · 2.71 KB
/
obsidz_teleport.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
#!/usr/bin/env python
import mcpi.minecraft as minecraft
import mcpi.block as block
import time
import server
#Author: Obsidz
#
#Description: This is a teleport pad script.
# To create a pad, place a nether reactor core onto a location and ring with cobbledtone blocks
# To add to locations list walk over it
#
#Notes: Pads added to list by walking over them
# Pads not removed if destroyed but can be teleported to but not from
# You cannot teleport to the same pad without modifying script
# Pads need to be added each time the script is run
# modified version - as shared on mcpipy.com
# original post @ http://www.minecraftforum.net/topic/1691618-teleportation-python-script/
LPLoc = list()
Pads = 0
Cpad = 0
# If you are running this script with the bukkit mod, then use a diamond block as the magic center block for teleporting
# comment/uncomment below as appropriate
magic_block = block.DIAMOND_BLOCK.id # for bukkit server
#magic_block = block.NETHER_REACTOR_CORE.id # for raspberry pi
def isLaunchPad(): #checks if the the location below the player is a teleporting pad
loc = mc.player.getPos()
if ((mc.getBlock(loc.x,loc.y-1,loc.z) == magic_block) and
(mc.getBlock(loc.x-1,loc.y-1,loc.z-1) == block.COBBLESTONE.id) and
(mc.getBlock(loc.x-1,loc.y-1,loc.z) == block.COBBLESTONE.id) and
(mc.getBlock(loc.x-1,loc.y-1,loc.z+1) == block.COBBLESTONE.id) and
(mc.getBlock(loc.x,loc.y-1,loc.z+1) == block.COBBLESTONE.id) and
(mc.getBlock(loc.x,loc.y-1,loc.z-1) == block.COBBLESTONE.id) and
(mc.getBlock(loc.x+1,loc.y-1,loc.z-1) == block.COBBLESTONE.id) and
(mc.getBlock(loc.x+1,loc.y-1,loc.z) == block.COBBLESTONE.id) and
(mc.getBlock(loc.x+1,loc.y-1,loc.z+1) == block.COBBLESTONE.id)):
addLPLoc(loc)
return True
else:
return False
def addLPLoc(Vec3): #Loggs the location of the pad for future use
global Pads
global LPLoc
inList = False
if Pads > 0:
for loc in LPLoc:
if (loc.x == Vec3.x and loc.y == Vec3.y and loc.z == Vec3.z):
inList = True
if not inList:
LPLoc.append(Vec3)
mc.postToChat("I'll remember this pad location!")
Pads = len(LPLoc)
def locCheck(): #Checks that you are not teleporting to the same pad
global Cpad
global LPLoc
loc = mc.player.getPos()
if (loc.x == LPLoc[Cpad].x and loc.y == LPLoc[Cpad].y and loc.z == LPLoc[Cpad].z):
Cpad = Cpad + 1
def TPChar(): #sends the character to the next pad
global Pads
global Cpad
global LPLoc
if Pads > 1:
mc.player.setPos(LPLoc[Cpad].x,LPLoc[Cpad].y + 1,LPLoc[Cpad].z)
Cpad = ( Cpad + 1) % Pads
time.sleep(3.0)
if __name__ == "__main__": # The script
mc = minecraft.Minecraft.create(server.address)
while True:
if isLaunchPad():
TPChar()
time.sleep(0.1)