#Load the picraft API from picraft import World, Block, Vector world = World() #Say hello world.say("Hello, World!")
from __future__ import unicode_literals import time from picraft import World, Vector, Block from collections import deque world = World(ignore_errors=True) world.say('Auto-bridge active') try: bridge = deque() last_pos = None while True: this_pos = world.player.pos if last_pos is not None: # Has the player moved more than 0.1 units in a horizontal direction? movement = (this_pos - last_pos).replace(y=0.0) if movement.magnitude > 0.1: # Find the next tile they're going to step on next_pos = (this_pos + movement.unit).floor() - Vector(y=1) if world.blocks[next_pos] == Block('air'): with world.connection.batch_start(): bridge.append(next_pos) world.blocks[next_pos] = Block('diamond_block') while len(bridge) > 10: world.blocks[bridge.popleft()] = Block('air') last_pos = this_pos time.sleep(0.01) except KeyboardInterrupt: world.say('Auto-bridge deactivated') with world.connection.batch_start(): while bridge:
from time import sleep from picraft import World world = World() while True: for event in world.events.poll(): world.say('Player %d hit face %s of block at %d,%d,%d' % (event.player.player_id, event.face, event.pos.x, event.pos.y, event.pos.z)) sleep(0.1)
import time from picraft import World, Vector, Block world = World() world.say("connected") def stairs_to_heaven(): pos = world.player.tile_pos #print(world.player.direction) if world.blocks[pos + Vector(x=1)].id == 0: world.blocks[pos + Vector(x=1)] = Block('stone') while True: time.sleep(0.05) stairs_to_heaven()
from __future__ import unicode_literals import time from picraft import World, Vector, Block from collections import deque world = World(ignore_errors=True) world.say("Auto-bridge active") try: bridge = deque() last_pos = None while True: this_pos = world.player.pos if last_pos is not None: # Has the player moved more than 0.1 units in a horizontal direction? movement = (this_pos - last_pos).replace(y=0.0) if movement.magnitude > 0.1: # Find the next tile they're going to step on next_pos = (this_pos + movement.unit).floor() - Vector(y=1) if world.blocks[next_pos] == Block("air"): with world.connection.batch_start(): bridge.append(next_pos) world.blocks[next_pos] = Block("diamond_block") while len(bridge) > 10: world.blocks[bridge.popleft()] = Block("air") last_pos = this_pos time.sleep(0.01) except KeyboardInterrupt: world.say("Auto-bridge deactivated") with world.connection.batch_start(): while bridge:
### Determine how to know if a host player exists player_pos = w.player.tile_pos if(low_corner.x < player_pos.x and low_corner.z < player_pos.z and high_corner.x > player_pos.x and high_corner.z > player_pos.z ): render(blocks) if(state == "HIDDEN"): print("[%s,%s] [%s,%s]" % (ran_x, ran_z, player_pos.x, player_pos.z )) if(player_pos.x == ran_x and player_pos.z == ran_z): w.say("Congratulations! Enjoy. Come back soon!") gift = choice([ "diamond_block", "iron_block", "emerald_block", "redstone_block", "lapis_block", "gold_block", "coal_block"]) w.blocks[player_pos - Y] = Block(gift) erase(blocks) state = "ASK" sleep(10) elif(time() - hide_time > 15): gift = choice(["melon_block","coal_block"]) w.blocks[player_pos - Y] = Block(gift)
#!/usr/bin/env python from __future__ import unicode_literals import time from picraft import World, Vector, Block from collections import deque world = World(ignore_errors=True) world.say('Auto-bridge active') try: bridge = deque() last_pos = None while True: this_pos = world.player.pos if last_pos is not None: # Has the player moved more than 0.1 units in a horizontal direction? movement = (this_pos - last_pos).replace(y=0.0) if movement.magnitude > 0.1: # Find the next tile they're going to step on next_pos = (this_pos + movement.unit).floor() - Vector(y=1) if world.blocks[next_pos] == Block('air'): with world.connection.batch_start(): bridge.append(next_pos) world.blocks[next_pos] = Block('diamond_block') while len(bridge) > 10: world.blocks[bridge.popleft()] = Block('air') last_pos = this_pos time.sleep(0.01) except KeyboardInterrupt: world.say('Auto-bridge deactivated')
from time import sleep from picraft import World world = World() while True: for event in world.events.poll(): world.say('Player %d hit face %s of block at %d,%d,%d' % ( event.player.player_id, event.face, event.pos.x, event.pos.y, event.pos.z)) sleep(0.1)
#Load the picraft API from picraft import World, Block, Vector #Connect API to the world world = World() ############ Write your program below ############# world.say("Hello, World!")