Skip to content

Commit

Permalink
block.SIGN()
Browse files Browse the repository at this point in the history
  • Loading branch information
arpruss committed May 6, 2018
1 parent baec83f commit 8ab33f0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 2 additions & 6 deletions mcpipy/maze.py
Expand Up @@ -76,6 +76,7 @@ def getVisited(pos):
walls = generateMaze(xSize,ySize)
pos = mc.player.getTilePos()

pos.x += 1
my = pos.y

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

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

def makeSign(line1="",line2="",line3="",line4=""):
return Block(63, 15, '{Text4:"{\\"text\\":\\"%s\\"}",Text3:"{\\"text\\":\\"%s\\"}",Text2:"{\\"text\\":\\"%s\\"}",id:"minecraft:sign",Text1:"{\\"text\\":\\"%s\\"}"}'
% (line4,line3,line2,line1))

mc.setBlockWithNBT(pos.x+2*(xSize-1)+1,pos.y,pos.z+2*(ySize-1),makeSign('EXIT'))
mc.setBlockWithNBT(pos.x+2*(xSize-1)+1,pos.y,pos.z+2*(ySize-1),block.SIGN('EXIT',headingAngle=270))
mc.setBlock(pos.x+2*(xSize-1)+1,pos.y+1,pos.z+2*(ySize-1),block.AIR)
9 changes: 9 additions & 0 deletions mcpipy/mcpi/block.py
Expand Up @@ -456,6 +456,15 @@ def byName(name, default=None):
STAIRS_SPRUCE = Block(134)
STAIRS_BIRCH = Block(135)
STAIRS_JUNGLE = Block(136)
def SIGN(line1="",line2="",line3="",line4="",headingAngle=0):
"""
headingAngle = 0 North, 90 East, 180 South, 270 West, with 4 bit resolution
"""
dir = int( ( (headingAngle + 180) % 360 * 16 + 180 ) / 360 )
def c(text):
return text.replace('\\','\\\\\\\\').replace('"', '\\\\\\"')
return Block(63, dir, '{id:"minecraft:sign",Text1:"{\\"text\\":\\"%s\\"}",Text2:"{\\"text\\":\\"%s\\"}",Text3:"{\\"text\\":\\"%s\\"}",Text4:"{\\"text\\":\\"%s\\"}"}' %
(c(line1),c(line2),c(line3),c(line4)))

# for 1.12
GLAZED_TERRACOTTA_WHITE = Block(235)
Expand Down
2 changes: 1 addition & 1 deletion mcpipy/sign.py
@@ -1,3 +1,3 @@
from mine import *
mc = Minecraft()
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\\"}"}'))
mc.setBlockWithNBT(mc.player.getTilePos(),block.SIGN("Hello,","World",headingAngle=180))

0 comments on commit 8ab33f0

Please sign in to comment.