mralasic

Untitled

Jun 18th, 2022 (edited)
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.61 KB | None | 0 0
  1. #MINECRAFT
  2.  
  3. # Get player's coordinates. Use x, y and z variables to do the exercises.
  4. position=player.position()
  5. x=position.get_value(Axis.X)
  6. y=position.get_value(Axis.Y)
  7. z=position.get_value(Axis.Z)
  8.  
  9. # Exercise 1
  10. # Create an underwaterWorld function which will be called by using the "aquaman" command in chat.
  11. # After calling the function, the player should be locked in a huge water container made of GLASS and filled with WATER.
  12. # Use the blocks.fill() function.
  13.  
  14. def underwaterWorld():
  15.    
  16.     #Creating a glass structure
  17.     blocks.fill(GLASS, world(x-10,y-10,z-10),world(x+10,y+10,z+10))
  18.     #puouring water
  19.     blocks.fill(WATER, world(x-9,y-9,z-9),world(x+9,y+9,z+9))
  20.     drowned(10)
  21.     inventory()
  22.     coral()
  23.    
  24. player.on_chat("aquaman",underwaterWorld)
  25.  
  26.  
  27. # Exercise 2
  28. # Create a drowned function with numberOfDrowned parameter and call it in the underwaterWorld function.
  29. # When calling the function we should specify the number of drowned we want to spawn.
  30. # We will use the parameter in a for loop in a range() function.
  31. def drowned(numberOfDrowned):
  32.     for i in range(numberOfDrowned):
  33.         mobs.spawn(DROWNED, randpos(world(x-9,y-9,z-9),world(x+9,y+9,z+9)))
  34.  
  35.  
  36. # Exercise 3
  37. # Create an inventory function which will add a trident when calling the underwaterWorld function.
  38. # The trident is great for fighting underwater
  39. # Add spells which will improve the weapon
  40. # Unbreaking level 3 - increases durability of the weapon.
  41. # Channeling level 1 - During the storm, when hitting a mob, a lightning will hit them too.
  42. # Riptide level 3 - during rain, using the trident will get us fast transport.
  43. # Loyalty level 3 - the trident will come back to the player after they throw it.
  44. # Use functions like mobs.give() and mobs.enchant().
  45. # You can add other items useful in underwater combat.
  46. def inventory():
  47.     mobs.give(mobs.target(NEAREST_PLAYER), TRIDENT, 1)
  48.     mobs.enchant(mobs.target(NEAREST_PLAYER), "Unbreaking", 3)
  49.     mobs.enchant(mobs.target(NEAREST_PLAYER), "Channeling", 1)
  50.     mobs.enchant(mobs.target(NEAREST_PLAYER), "Loyalty", 3)
  51.  
  52.  
  53. # Exercise 4
  54. # Create a coral function and call it in the underwaterWorld after creating the water container.
  55. # Use blocks.place and randpos() to place different corals in random places. Use for loop, too.
  56. # Coral names: TUBE_CORAL, BRAIN_CORAL, BUBBLE_CORAL, FIRE_CORAL, BUBBLE_CORAL_FAN
  57.  
  58. # You  can use an array to do this exercise
  59. # In the coral function create a coralArray array and add different corals to it.
  60. # Using two for loops, get corals from the array and place them in random places.
  61. def coral():
  62.     coralArray = [TUBE_CORAL, BRAIN_CORAL, BUBBLE_CORAL, FIRE_CORAL, BUBBLE_CORAL_FAN]
  63.     for i in range(len(coralArray)):
  64.         for j in range(10):
  65.             blocks.place(coralArray[i], randpos(world(x-9,y-9,z-9),world(x+9,y-9,z+9)))
  66.  
  67.  
  68.  
  69. # Exercise 5
  70. # The function changing the game mode
  71. # Create a gameMode function with the mode parameter. The function will be called in chat by writing 't' and giving a parameter 0 or 1.
  72. # When we put 0, the game should be in survival mode and the player should get breathing underwater effect.
  73. # When we put 1, the game should be switched to creative mode.
  74. # Use if elif conditional statements.
  75. # The name of the effect is WATER_BREATHING. Use it in the mobs.apply_effect function.
  76.  
  77. def gameMode(mode):
  78.     if mode == 0:
  79.         gameplay.set_game_mode(SURVIVAL, mobs.target(NEAREST_PLAYER))
  80.         mobs.apply_effect(WATER_BREATHING, mobs.target(NEAREST_PLAYER))
  81.     elif mode == 1:
  82.         gameplay.set_game_mode(CREATIVE, mobs.target(NEAREST_PLAYER))
  83.  
  84.  
  85. player.on_chat("m", gameMode)
  86.  
Add Comment
Please, Sign In to add comment