# After starting the program get the player's coordinates which will be used in the entire project # We will only update the Z coordinate of the player to be able to correctly add stages position=player.position() x=position.get_value(Axis.X) y=position.get_value(Axis.Y) z=position.get_value(Axis.Z) #function creating the first fragment of the course def course(): #create the shape of the course from bedrock blocks.fill(BEDROCK, world(x-10,y-1,z-2),world(x+10,y+10,z+35),FillOperation.HOLLOW) #the line lauching stage 1 blocks.fill(SEA_LANTERN, world(x-9,y-1,z+3),world(x+9,y-1,z+5)) #gameplay.set_game_mode(SURVIVAL, mobs.target(NEAREST_PLAYER)) player.on_chat("start", course) def stage1(z): player.say("STAGE 1!!!!") #clearing the horizontal block line to protect player from loading the level multiple times blocks.fill(BEDROCK, world(x-10, y-1, z-5), world(x+10, y-1, z+5)) #adding a barrier behind the player blocks.fill(BEDROCK, world(x-10, y, z-3), world(x+10, y+10, z-1)) #line for loading the next level blocks.fill(GOLD_BLOCK, world(x-9,y-1,z+25),world(x+9,y-1,z+27)) #obstacles for stage 1 blocks.fill(IRON_BARS, world(x-9,y-1,z+3),world(x+9,y-1,z+20)) blocks.fill(LAVA, world(x-9,y-2,z+3),world(x+9,y-2,z+20)) while True: if blocks.test_for_block(IRON_BARS, pos(0, -1, 0)): mobs.give(mobs.target(NEAREST_PLAYER), DIAMOND_AXE, 1) for i in range(8): mobs.spawn(CREEPER, randpos(world(x-8,y+1,z+3),world(x+8,y+1,z+20))) break #pocetak definicije stage-a def stage2(z): player.say("STAGE 2!!!!") #create an arena blocks.fill(BEDROCK, world(x-10,y-1,z-2),world(x+10,y+10,z+30),FillOperation.HOLLOW) #clearing the horizontal block line to protect player from loading the level multiple times blocks.fill(BEDROCK, world(x-10, y-1, z-5), world(x+10, y-1, z+5)) #adding a barrier behind the player blocks.fill(BEDROCK, world(x-10, y, z-3), world(x+10, y+10, z-1)) #line for loading the next level blocks.fill(GLASS, world(x-9,y-1,z+25),world(x+9,y-1,z+27)) mobs.apply_effect(NIGHT_VISION, mobs.target(NEAREST_PLAYER)) #kraj definicije stage-a for i in range(15): mobs.spawn(ZOMBIE, randpos(world(x-8, y+3, z+3), world(x+10, y+3, z+20))) #pocetak definicije stage-a def stage3(z): player.say("STAGE 3!!!!") #create an arena blocks.fill(BEDROCK, world(x-10,y-1,z-2),world(x+10,y+10,z+30),FillOperation.HOLLOW) #clearing the horizontal block line to protect player from loading the level multiple times blocks.fill(BEDROCK, world(x-10, y-1, z-5), world(x+10, y-1, z+5)) #adding a barrier behind the player blocks.fill(BEDROCK, world(x-10, y, z-3), world(x+10, y+10, z-1)) #line for loading the next level blocks.fill(COBBLESTONE, world(x-9,y-1,z+25),world(x+9,y-1,z+27)) mobs.apply_effect(NIGHT_VISION, mobs.target(NEAREST_PLAYER)) #kraj definicije stage-a blocks.fill(DIAMOND_BLOCK, world(x-9,y-1,z+3),world(x+9,y-1,z+20)) while True: if blocks.test_for_block(DIAMOND_BLOCK, pos(0, -1, 0)): for i in range(10): mobs.spawn(PRIMED_TNT, randpos(world(x-8,y+3,z+3),world(x+8,y+3,z+20))) break #pocetak definicije stage-a def stage4(z): player.say("STAGE 4!!!!") #create an arena blocks.fill(BEDROCK, world(x-10,y-1,z-2),world(x+10,y+10,z+30),FillOperation.HOLLOW) #clearing the horizontal block line to protect player from loading the level multiple times blocks.fill(BEDROCK, world(x-10, y-1, z-5), world(x+10, y-1, z+5)) #adding a barrier behind the player blocks.fill(BEDROCK, world(x-10, y, z-3), world(x+10, y+10, z-1)) #line for loading the next level blocks.fill(GRANITE, world(x-9,y-1,z+25),world(x+9,y-1,z+27)) mobs.apply_effect(NIGHT_VISION, mobs.target(NEAREST_PLAYER)) #kraj definicije stage-a for i in range(11): blocks.place(LAVA, randpos(world(x-9,y+1,z+5), world(x+9,y+1,z+20))) #pocetak definicije stage-a def stage5(z): player.say("STAGE 5!!!!") #create an arena blocks.fill(BEDROCK, world(x-10,y-1,z-2),world(x+10,y+10,z+30),FillOperation.HOLLOW) #clearing the horizontal block line to protect player from loading the level multiple times blocks.fill(BEDROCK, world(x-10, y-1, z-5), world(x+10, y-1, z+5)) #adding a barrier behind the player blocks.fill(BEDROCK, world(x-10, y, z-3), world(x+10, y+10, z-1)) #line for loading the next level blocks.fill(REDSTONE_BLOCK, world(x-9,y-1,z+25),world(x+9,y-1,z+27)) mobs.apply_effect(NIGHT_VISION, mobs.target(NEAREST_PLAYER)) #kraj definicije stage-a blocks.fill(AIR, world(x-9,y,z+3),world(x+9,y-4,z+20)) blocks.fill(LAPIS_LAZULI_BLOCK, world(x-9,y-1,z+2),world(x+9,y-1,z+2)) blocks.fill(LAPIS_LAZULI_BLOCK, world(x-9,y-1,z+7),world(x+9,y-1,z+7)) blocks.fill(LAPIS_LAZULI_BLOCK, world(x-9,y-1,z+15),world(x+9,y-1,z+15)) blocks.place(GLOWSTONE, world(x, y, z+28)) while blocks.test_for_block(REDSTONE_BLOCK, pos(0, -1, 0))==False: if blocks.test_for_block(LAPIS_LAZULI_BLOCK, pos(0, -1, 0)): mobs.apply_effect(LEVITATION, mobs.target(NEAREST_PLAYER), 2, 1) def afterDestroying(): player.teleport(pos(0, 0, 10)) #code responsible to loading levels while True: #Checking the block under the player if blocks.test_for_block(SEA_LANTERN, pos(0, -1, 0)): #getting the current position and passing it to the function position = player.position() z = position.get_value(Axis.Z) stage1(z) loops.pause(3000) elif blocks.test_for_block(GOLD_BLOCK, pos(0, -1, 0)): #getting the current position and passing it to the function position = player.position() z = position.get_value(Axis.Z) stage2(z) loops.pause(3000) elif blocks.test_for_block(GLASS, pos(0, -1, 0)): #getting the current position and passing it to the function position = player.position() z = position.get_value(Axis.Z) stage3(z) loops.pause(3000) elif blocks.test_for_block(COBBLESTONE, pos(0, -1, 0)): #getting the current position and passing it to the function position = player.position() z = position.get_value(Axis.Z) stage4(z) loops.pause(3000) elif blocks.test_for_block(GRANITE, pos(0, -1, 0)): #getting the current position and passing it to the function position = player.position() z = position.get_value(Axis.Z) stage5(z) loops.pause(3000) blocks.on_block_broken(GLOWSTONE, afterDestroying)