当前位置: 首页>>代码示例>>Python>>正文


Python Minecraft.create方法代码示例

本文整理汇总了Python中mcpi.minecraft.Minecraft.create方法的典型用法代码示例。如果您正苦于以下问题:Python Minecraft.create方法的具体用法?Python Minecraft.create怎么用?Python Minecraft.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mcpi.minecraft.Minecraft的用法示例。


在下文中一共展示了Minecraft.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: instruct

# 需要导入模块: from mcpi.minecraft import Minecraft [as 别名]
# 或者: from mcpi.minecraft.Minecraft import create [as 别名]
def instruct():

	from mcpi.minecraft import Minecraft
	mc = Minecraft.create()

	import time

	time.sleep(5)

	mc.postToChat("Strike the green block to begin")
	time.sleep(1)
	mc.postToChat(" ")
	time.sleep(1)
	mc.postToChat("Find all the treasure as quickly as possible")
	time.sleep(1)
	mc.postToChat(" ")
	time.sleep(1)
	mc.postToChat("The strike the red block to stop the clock")
	time.sleep(1)
	mc.postToChat(" ")
	time.sleep(1)
	mc.postToChat("Treasure to find: " + str(len(treasure)))
	mc.postToChat(" ")

	mc.setBlock(-5, -10, 8, 35,5)		# green start block
	mc.setBlock(-5, -10, 12, 35,14)		# red finish block
	mc.setBlocks(-5, -10, 6,  -5, -6,  6, 89)
	mc.setBlocks(-5, -10, 14, -5, -6, 14, 89)
	mc.setBlocks(-5,  -6,  6, -5, -6, 14, 89)
开发者ID:joolsbamford,项目名称:pisync,代码行数:31,代码来源:rjamgame.py

示例2: blocky

# 需要导入模块: from mcpi.minecraft import Minecraft [as 别名]
# 或者: from mcpi.minecraft.Minecraft import create [as 别名]
def blocky():
	
	from mcpi.minecraft import Minecraft
	mc = Minecraft.create()
	
	import time

	mc.postToChat("Blocks to find: " + str(len(treasure)))
	time.sleep(1)
	mc.postToChat("Go!!!!!!")
	
	
	while True:
		blockHits = mc.events.pollBlockHits()
		if blockHits:
				for blockHit in blockHits:
					x,y,z = blockHit.pos.x, blockHit.pos.y, blockHit.pos.z		# x,y,z = right click hit
										
				if [x,y,z] in treasure:
					treasure.remove([x,y,z])
					mc.setBlock(x, y, z, 0)
					
					if len(treasure) > 0:
						mc.postToChat("Blocks to find: " + str(len(treasure)))
					else:
						mc.postToChat("You have found all the treasure - find the exit")
开发者ID:joolsbamford,项目名称:pisync,代码行数:28,代码来源:housebuild_notimer.py

示例3: instruct

# 需要导入模块: from mcpi.minecraft import Minecraft [as 别名]
# 或者: from mcpi.minecraft.Minecraft import create [as 别名]
def instruct(): ### next enter name and write time to txt file to keep hire score table
	
	from mcpi.minecraft import Minecraft
	mc = Minecraft.create()
	
	import time
	
	time.sleep(5)
	
	mc.postToChat("Strike the green block to begin")
	time.sleep(1)
	mc.postToChat(" ")
	time.sleep(1)
	mc.postToChat("Find all the treasure as quickly as possible")
	time.sleep(1)
	mc.postToChat(" ")
	time.sleep(1)
	mc.postToChat("The strike the red block to stop the clock")
	time.sleep(1)
	mc.postToChat(" ")
	time.sleep(1)
	mc.postToChat("Treasure to find: " + str(len(treasure)))
	mc.postToChat(" ")
	
	mc.setBlock(-5, -10, 8, 35,5)		# green start block
	mc.setBlock(-5, -10, 12, 35,14)		# red finish block
开发者ID:joolsbamford,项目名称:pisync,代码行数:28,代码来源:houseBuild.py

示例4:

# 需要导入模块: from mcpi.minecraft import Minecraft [as 别名]
# 或者: from mcpi.minecraft.Minecraft import create [as 别名]
from mcpi.minecraft import Minecraft
import time
import random
mc = Minecraft.create()

while True:
    chat = ["Message 1", "Message 2", "Message 3"]
    thing = random.randint (0,2)
    mc.postToChat (chat[thing])
    time.sleep(3)
开发者ID:chriswilde,项目名称:Minecraft-Pi,代码行数:12,代码来源:Hack_02_Random_Messages.py

示例5: __init__

# 需要导入模块: from mcpi.minecraft import Minecraft [as 别名]
# 或者: from mcpi.minecraft.Minecraft import create [as 别名]
 def __init__(self, attribs):
     self.server_address = attribs["server_address"]
     self.server_port = attribs.get("server_port", 4711)
     self.coords_x = attribs["coords_x"]
     self.coords_y = attribs["coords_y"]
     self.coords_z = attribs["coords_z"]
     self.world_connection = Minecraft.create(self.server_address, self.server_port)
开发者ID:jrmhaig,项目名称:rube-mc-pi,代码行数:9,代码来源:minecraft.py

示例6: cube

# 需要导入模块: from mcpi.minecraft import Minecraft [as 别名]
# 或者: from mcpi.minecraft.Minecraft import create [as 别名]
def cube(size=5, typeId=1):
    "_mcp: create a cube"
    mc = Minecraft.create()
    pos = mc.player.getTilePos()
    s = int(size)
    t = int(typeId)
    mc.setBlocks(pos.x + 1, pos.y, pos.z,
        pos.x + s, pos.y + s - 1, pos.z + s - 1, t)
开发者ID:wensheng,项目名称:JuicyRaspberryPie,代码行数:10,代码来源:examples.py

示例7: __init__

# 需要导入模块: from mcpi.minecraft import Minecraft [as 别名]
# 或者: from mcpi.minecraft.Minecraft import create [as 别名]
 def __init__(self): #??? Uses mc instance.
     # create minecraft object
     print ("\nFUNCTION: MinecraftGenerator __init__")
     print ("Opening connection to Minecraft Pi")
     try:
         self.mc=Minecraft.create()
     except:
         #print("There was an error connecting to Minecraft.")
         sys.exit("There was an error connecting to Minecraft.")
开发者ID:sbyrne1,项目名称:Python-Minecraft,代码行数:11,代码来源:MinecraftGenerator.py

示例8: __init__

# 需要导入模块: from mcpi.minecraft import Minecraft [as 别名]
# 或者: from mcpi.minecraft.Minecraft import create [as 别名]
    def __init__(self, pos, width, height, length):
        self.mc = Minecraft.create()
        
        self.pos = pos
        self.width = width
        self.height = height
        self.length = length

        self._draw()
开发者ID:NP-Games,项目名称:minecraft-starwars,代码行数:11,代码来源:trench.py

示例9: flatten

# 需要导入模块: from mcpi.minecraft import Minecraft [as 别名]
# 或者: from mcpi.minecraft.Minecraft import create [as 别名]
def flatten(size=50):
    """_mcp: flatten world around me.
    change one layer of blocks below me to sandstone,
    clear everything above.
    """
    mc = Minecraft.create()
    pos = mc.player.getTilePos()
    s = int(size)
    mc.setBlocks(pos.x - s, pos.y - 1, pos.z - s,
        pos.x + s, pos.y - 1, pos.z + s, 24)
    mc.setBlocks(pos.x - s, pos.y, pos.z - s,
        pos.x + s, pos.y + 64, pos.z + s, 0)
开发者ID:wensheng,项目名称:JuicyRaspberryPie,代码行数:14,代码来源:examples.py

示例10: hunt

# 需要导入模块: from mcpi.minecraft import Minecraft [as 别名]
# 或者: from mcpi.minecraft.Minecraft import create [as 别名]
def hunt():
	
	from mcpi.minecraft import Minecraft
	mc = Minecraft.create()
	
	import time
		
	timer = 0
	
	while True:		
	
		blockHits = mc.events.pollBlockHits()
		if blockHits:
			
			for blockHit in blockHits:
				x,y,z = blockHit.pos.x, blockHit.pos.y, blockHit.pos.z		# x,y,z = right click hit
				
			if [x,y,z] == [-5, -10, 8] and mc.getBlock(-5, -10, 8) == 35:	#check for green block strike
				mc.setBlock(-5, -10, 8, 0)									#red block still in place
				mc.postToChat("Go!!!!!!")
				mc.postToChat(" ")
				
				
			if [x,y,z] == [-5, -10, 12] and mc.getBlock(-5, -10, 12) == 35 and mc.getBlock(-5, -10, 8) == 0 and len(treasure) == 0:
				mc.setBlock(-5, -10, 12, 0)
				mc.postToChat("Mission Complete!!!!")					#if red block hit and green hit and no treasure left
				mc.postToChat(" ")
				mc.postToChat("Your score is " + str(5000 - timer))
				break
				
				
			if mc.getBlock(-5, -10, 8) == 0:
									
				if [x,y,z] in treasure:
					treasure.remove([x,y,z])
					mc.setBlock(x, y, z, 0)
					
					if len(treasure) > 0:
						mc.postToChat("Blocks to find: " + str(len(treasure)))
						
					elif len(treasure) == 0:
						mc.postToChat("You have found all the treaure")
						mc.postToChat(" ")
						mc.postToChat("Head for the exit!!")
						
										
		if mc.getBlock(-5, -10, 8) == 0 and mc.getBlock(-5, -10, 12) == 35:
			timer +=1
			time.sleep(0.05)
开发者ID:joolsbamford,项目名称:pisync,代码行数:51,代码来源:houseBuild.py

示例11: falling_block

# 需要导入模块: from mcpi.minecraft import Minecraft [as 别名]
# 或者: from mcpi.minecraft.Minecraft import create [as 别名]
def falling_block():
    """_mcp
    A gold block is falling from the sky
    """
    mc = Minecraft.create()
    pos = mc.player.getTilePos()
    y = pos.y + 40
    for i in range(40):
        time.sleep(0.5)
        # if the block below is anything other than air
        # stop falling
        if mc.getBlock(pos.x, y-i-1, pos.z) != 0:
            break
        mc.setBlock(pos.x, y-i, pos.z, 0)
        mc.setBlock(pos.x, y-i-1, pos.z, 41)
开发者ID:wensheng,项目名称:JuicyRaspberryPie,代码行数:17,代码来源:examples.py

示例12: rainbow

# 需要导入模块: from mcpi.minecraft import Minecraft [as 别名]
# 或者: from mcpi.minecraft.Minecraft import create [as 别名]
def rainbow():
    """_mcp
    create a rainbow.
    The code is from:
    http://dev.bukkit.org/bukkit-plugins/raspberryjuice/
    """
    mc = Minecraft.create()
    pos = mc.player.getTilePos()
    colors = [14, 1, 4, 5, 3, 11, 10]
    height = 60
    mc.setBlocks(pos.x-64,0,0,pos.x+64,height + len(colors),0,0)
    for x in range(0, 128):
        for colourindex in range(0, len(colors)):
            y = sin((x / 128.0) * pi) * height + colourindex
            mc.setBlock(pos.x+x - 64, pos.y+y, pos.z,
                35, colors[len(colors) - 1 - colourindex])
开发者ID:wensheng,项目名称:JuicyRaspberryPie,代码行数:18,代码来源:examples.py

示例13: Image

# 需要导入模块: from mcpi.minecraft import Minecraft [as 别名]
# 或者: from mcpi.minecraft.Minecraft import create [as 别名]
def Image(ImageName,X0,Y0,Z0):
    from PIL import Image
    import math
    mc = Minecraft.create()
    white = [221,221,221,0]#rgb, id
    orange = [219,125,62,1]#rgb, id
    magneta = [179,80,188,2]#rgb, id
    lightBlue = [107,138,201,3]#rgb, id
    yellow = [177,166,39,4]#rgb, id
    lime = [65,174,56,5]#rgb, id
    pink = [208,132,153,6]#rgb, id
    gray = [64,64,64,7]#rgb, id
    lightGray = [154,161,161,8]#rgb, id
    cyan = [46,110,137,9]#rgb, id
    purple = [126,61,181,10]#rgb, id
    blue = [46,56,141,11]#rgb, id
    brown = [79,50,31,12]#rgb, id
    green = [53,70,27,13]#rgb, id
    red = [150,52,48,14]#rgb, id
    black = [25,22,22,15]#rgb, id
    colors = [white,orange,magneta,lightBlue,yellow,lime,pink,gray,lightGray,cyan,purple,blue,brown,green,red,black]
    #enter your data here:
    img = Image.open(ImageName)#image
    #place
    if img.width*img.height > 500*500:
        mc.postToChat("the Image is too big!")
    else:
        data = img.load()
        x = 0
        while x < img.width:
            y = 0
            while y < img.height:
                res = 255*3
                pixel = data[x,y]
                for color in colors:
                    r = pixel[0]-color[0]
                    g = pixel[1]-color[1]
                    b = pixel[2]-color[2]
                    if math.fabs(r)+math.fabs(g)+math.fabs(b) < res:
                        res = math.fabs(r)+math.fabs(g)+math.fabs(b)
                        block = 35,color[3]
                mc.setBlock(X0+x,Y0,Z0+y,block)
                y = y + 1
            mc.postToChat(str(int(x / img.width * 100))+"%")
            x = x + 1
        mc.postToChat("done.")
开发者ID:matkavt,项目名称:python-minecraft-lib,代码行数:48,代码来源:obj.py

示例14: banner

# 需要导入模块: from mcpi.minecraft import Minecraft [as 别名]
# 或者: from mcpi.minecraft.Minecraft import create [as 别名]
def banner(txt, size=24, type1=41, type2=0):
    """_mcp
    Display a word banner made of blocks
    must have word2banner.py and word2banner.ini in the 
    same directory.
    see word2banner at github.com/wensheng/word2banner
    """
    mc = Minecraft.create()
    pos = mc.player.getTilePos()
    import pplugins.word2banner
    size = int(size)
    type1 = int(type1)
    type2 = int(type2)
    w2b = pplugins.word2banner.word2banner(txt, 1, size)
    y = pos.y + size
    for r in w2b:
        z = pos.z + 1
        for c in r:
            if c:
                mc.setBlock(pos.x, y, z, type1)
            else:
                mc.setBlock(pos.x, y, z, type2)
            z += 1
        y -= 1
开发者ID:wensheng,项目名称:JuicyRaspberryPie,代码行数:26,代码来源:examples.py

示例15: buttonyellowpressed

# 需要导入模块: from mcpi.minecraft import Minecraft [as 别名]
# 或者: from mcpi.minecraft.Minecraft import create [as 别名]
def buttonyellowpressed(channel, event):
	mcy = Minecraft.create()
	blockinyellowcol = mcy.getBlock(pos.x, pos.y, pos.z + 10)
	if blockinyellowcol == block.WOOL.id:
		mc.postToChat("You're doing great!")
		mcy.setBlock(pos.x, pos.y, pos.z + 10,block.WOOL.id,0)
开发者ID:csprimary,项目名称:raspi,代码行数:8,代码来源:dance1.py


注:本文中的mcpi.minecraft.Minecraft.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。