Skip to content

Commit 8ab33f0

Browse files
committed
block.SIGN()
1 parent baec83f commit 8ab33f0

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

mcpipy/maze.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def getVisited(pos):
7676
walls = generateMaze(xSize,ySize)
7777
pos = mc.player.getTilePos()
7878

79+
pos.x += 1
7980
my = pos.y
8081

8182
for x in range(xSize):
@@ -96,12 +97,7 @@ def set(d1,d2):
9697

9798
mc.setBlock(pos.x-1,pos.y,pos.z,block.AIR)
9899
mc.setBlock(pos.x-1,pos.y+1,pos.z,block.AIR)
99-
mc.setBlock(pos.x+2*(xSize-1),pos.y-1,pos.z+2*(ySize-1),block.GOLD_BLOCK)
100100
mc.setBlock(pos.x+2*(xSize-1)+1,pos.y-1,pos.z+2*(ySize-1),block.GOLD_BLOCK)
101101

102-
def makeSign(line1="",line2="",line3="",line4=""):
103-
return Block(63, 15, '{Text4:"{\\"text\\":\\"%s\\"}",Text3:"{\\"text\\":\\"%s\\"}",Text2:"{\\"text\\":\\"%s\\"}",id:"minecraft:sign",Text1:"{\\"text\\":\\"%s\\"}"}'
104-
% (line4,line3,line2,line1))
105-
106-
mc.setBlockWithNBT(pos.x+2*(xSize-1)+1,pos.y,pos.z+2*(ySize-1),makeSign('EXIT'))
102+
mc.setBlockWithNBT(pos.x+2*(xSize-1)+1,pos.y,pos.z+2*(ySize-1),block.SIGN('EXIT',headingAngle=270))
107103
mc.setBlock(pos.x+2*(xSize-1)+1,pos.y+1,pos.z+2*(ySize-1),block.AIR)

mcpipy/mcpi/block.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,15 @@ def byName(name, default=None):
456456
STAIRS_SPRUCE = Block(134)
457457
STAIRS_BIRCH = Block(135)
458458
STAIRS_JUNGLE = Block(136)
459+
def SIGN(line1="",line2="",line3="",line4="",headingAngle=0):
460+
"""
461+
headingAngle = 0 North, 90 East, 180 South, 270 West, with 4 bit resolution
462+
"""
463+
dir = int( ( (headingAngle + 180) % 360 * 16 + 180 ) / 360 )
464+
def c(text):
465+
return text.replace('\\','\\\\\\\\').replace('"', '\\\\\\"')
466+
return Block(63, dir, '{id:"minecraft:sign",Text1:"{\\"text\\":\\"%s\\"}",Text2:"{\\"text\\":\\"%s\\"}",Text3:"{\\"text\\":\\"%s\\"}",Text4:"{\\"text\\":\\"%s\\"}"}' %
467+
(c(line1),c(line2),c(line3),c(line4)))
459468

460469
# for 1.12
461470
GLAZED_TERRACOTTA_WHITE = Block(235)

mcpipy/sign.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from mine import *
22
mc = Minecraft()
3-
mc.conn.send("world.setBlocks",0,0,0,5,5,5,Block(63, 15, '{Text4:"{\\"text\\":\\"\\"}",Text3:"{\\"text\\":\\"\\"}",Text2:"{\\"text\\":\\"\\"}",id:"minecraft:sign",Text1:"{\\"text\\":\\"hello\\"}"}'))
3+
mc.setBlockWithNBT(mc.player.getTilePos(),block.SIGN("Hello,","World",headingAngle=180))

0 commit comments

Comments
 (0)