BobMe

minecraft lucky blocks

Aug 15th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.71 KB | None | 0 0
  1. let lucky_block = blocks.block(Block.GoldBlock);
  2. let lucky_tool = blocks.item(Item.GoldenAxe);
  3. let amount_of_lucky_choices = 18
  4.  
  5. let lucky_pos: Position = null
  6.  
  7. player.onItemInteracted(lucky_tool, function () {
  8. let pos = positions.add(player.position(), positions.create(0, -1, 0));
  9. if (blocks.testForBlock(Block.GoldBlock, pos) == true) {
  10. player.say("§6§lLucky Block Set!");
  11. lucky_pos = pos
  12. } else {
  13. player.say("§4§lThat is not a Lucky Block!");
  14. lucky_pos = pos
  15. }
  16. })
  17.  
  18. blocks.onBlockBroken(lucky_block, function () {
  19. if (lucky_pos != null && blocks.testForBlock(Block.GoldBlock, lucky_pos) == false) {
  20. player.execute('kill @e [name="Block of Gold"]')
  21. exelucky(Math.randomRange(1, amount_of_lucky_choices), lucky_pos)
  22. lucky_pos = null
  23. }
  24. })
  25.  
  26. function exelucky(num: number, pos: Position) {
  27. if (num == 1) {
  28. let ofpos1 = Math.randomRange(-3, 3)
  29. let ofpos2 = Math.randomRange(-3, 3)
  30. let ofpos3 = Math.randomRange(-3, 3)
  31. lucky_pos = positions.create(ofpos1, 0, ofpos3)
  32. blocks.place(lucky_block, positions.add(pos, lucky_pos))
  33. let choice = Math.randomRange(1, 3)
  34. if (choice == 1) {
  35. player.say("§e§lThat one was defective... Try this one instead.")
  36. } else if (choice == 2) {
  37. player.say("§e§lHey look, it's back!")
  38. } else if (choice == 3) {
  39. player.say("§e§lHm, that's weird it came back?")
  40. }
  41. } else if (num == 2) {
  42. for (let i = 0; i < 3; i++) {
  43. let ofpos1 = Math.randomRange(-3, 3)
  44. let ofpos2 = Math.randomRange(-3, 3)
  45. let ofpos3 = Math.randomRange(-3, 3)
  46. if (blocks.testForBlock(blocks.block(Block.GoldBlock), pos) == false && blocks.testForBlock(blocks.block(Block.Dirt), pos) == false && blocks.testForBlock(blocks.block(Block.Grass), pos) == false) {
  47. blocks.place(lucky_block, positions.add(pos, positions.create(ofpos1, 0, ofpos3)))
  48. } else {
  49. let y = 0
  50. let posl = pos
  51. while (blocks.testForBlock(blocks.block(Block.GoldBlock), posl) == false && blocks.testForBlock(blocks.block(Block.Dirt), posl) == false && blocks.testForBlock(blocks.block(Block.Grass), posl) == false) {
  52. y++;
  53. posl = positions.add(pos, positions.create(0, y, 0))
  54. }
  55. blocks.place(lucky_block, positions.add(pos, positions.create(ofpos1, y, ofpos3)))
  56. }
  57. }
  58. player.say("§a§l3 Lucky Blocks!")
  59. } else if (num == 3) {
  60. player.say("§4§lUh oh! That's creepy!")
  61. for (let i = 0; i < 5; i++) {
  62. mobs.spawn(mobs.monster(MonsterMob.Creeper), positions.create(0, 4, 0))
  63. }
  64. } else if (num == 4) {
  65. player.execute("time set day")
  66. player.say("§a§lTime passed in an instant and morning has begun!")
  67. } else if (num == 5) {
  68. player.execute("time set night")
  69. player.say("§4§lTime passed in an instant and night has fallen.");
  70. } else if (num == 6) {
  71. player.say("§4§lLook up.")
  72. for (let i = 0; i < 5; i++) {
  73. mobs.spawn(mobs.projectile(ProjectileMob.PrimedTnt), positions.create(0, 65, 0))
  74. loops.pause(50)
  75. }
  76. } else if (num == 7) {
  77. player.say("§a§lLucky!")
  78. mobs.spawn(mobs.projectile(ProjectileMob.LightningBolt), pos)
  79. blocks.place(blocks.block(Block.DiamondBlock), pos)
  80. } else if (num == 8) {
  81. let pos = player.position()
  82. blocks.fill(blocks.block(Block.Cobblestone), positions.add(pos, positions.create(-1, 0, -1)), positions.add(pos, positions.create(-1, 0, 1)))
  83. blocks.fill(blocks.block(Block.Cobblestone), positions.add(pos, positions.create(1, 0, -1)), positions.add(pos, positions.create(1, 0, 1)))
  84. blocks.place(blocks.block(Block.Cobblestone), positions.add(pos, positions.create(0, 0, -1)))
  85. blocks.place(blocks.block(Block.Cobblestone), positions.add(pos, positions.create(0, 0, 1)))
  86. blocks.place(blocks.block(Block.Lava), positions.add(pos, positions.create(0, 0, 0)))
  87. player.say("§4§lWhat a heated result!")
  88. } else if (num == 9) {
  89. player.say("§a§lLucky!")
  90. mobs.spawn(mobs.projectile(ProjectileMob.LightningBolt), pos)
  91. blocks.place(blocks.block(Block.EmeraldBlock), pos)
  92. } else if (num == 10) {
  93. blocks.replace(blocks.block(Block.Stone), blocks.block(Block.IronOre), positions.create(-6, -6, -6), positions.create(6, 6, 6))
  94. blocks.replace(blocks.block(Block.Stone), blocks.block(Block.GoldOre), positions.create(-6, -6, -6), positions.create(6, 6, 6))
  95. blocks.replace(blocks.block(Block.Stone), blocks.block(Block.RedstoneOre), positions.create(-6, -6, -6), positions.create(6, 6, 6))
  96. blocks.replace(blocks.block(Block.Stone), blocks.block(Block.LapisOre), positions.create(-6, -6, -6), positions.create(6, 6, 6))
  97. blocks.replace(blocks.block(Block.Stone), blocks.block(Block.DiamondOre), positions.create(-6, -6, -6), positions.create(6, 6, 6))
  98. blocks.replace(blocks.block(Block.Stone), blocks.block(Block.CoalOre), positions.create(-6, -6, -6), positions.create(6, 6, 6))
  99. player.say("§4§lUnlucky! All ores around you have vanished.")
  100. } else if (num == 11) {
  101. blocks.replace(blocks.block(Block.IronBlock), blocks.block(Block.IronOre), positions.create(-10, -10, -10), positions.create(10, 10, 10))
  102. blocks.replace(blocks.block(Block.GoldBlock), blocks.block(Block.GoldOre), positions.create(-10, -10, -10), positions.create(10, 10, 10))
  103. blocks.replace(blocks.block(Block.RedstoneBlock), blocks.block(Block.RedstoneOre), positions.create(-10, -10, -10), positions.create(10, 10, 10))
  104. blocks.replace(blocks.block(Block.LapisLazuliBlock), blocks.block(Block.LapisOre), positions.create(-10, -10, -10), positions.create(10, 10, 10))
  105. blocks.replace(blocks.block(Block.DiamondBlock), blocks.block(Block.DiamondOre), positions.create(-10, -10, -10), positions.create(10, 10, 10))
  106. blocks.replace(blocks.block(Block.CoalBlock), blocks.block(Block.CoalOre), positions.create(-10, -10, -10), positions.create(10, 10, 10))
  107. player.say("§a§lLucky! All ores around you have been upgraded!")
  108. } else if (num == 12) {
  109. player.execute("effect @a blindness 10 255")
  110. player.say("§4§lUh Oh! Everyone has been blinded for 10 seconds!")
  111. } else if (num == 13) {
  112. player.say("§4§lUh oh! That's scary!")
  113. for (let i = 0; i < 6; i++) {
  114. mobs.spawn(mobs.monster(MonsterMob.Enderman), positions.create(0, 3, 0))
  115. }
  116. } else if (num == 14) {
  117. player.execute("xp 5L @a")
  118. player.say("§a§lEveryone just gained 5 braincells!")
  119. } else if (num == 15) {
  120. blocks.fill(blocks.block(Block.Obsidian), positions.add(pos, positions.create(-2, 0, 0)), positions.add(pos, positions.create(-2, 4, 0)))
  121. blocks.fill(blocks.block(Block.Obsidian), positions.add(pos, positions.create(-2, 0, 3)), positions.add(pos, positions.create(-2, 4, 3)))
  122. blocks.fill(blocks.block(Block.Obsidian), positions.add(pos, positions.create(-2, 0, 1)), positions.add(pos, positions.create(-2, 0, 2)))
  123. blocks.fill(blocks.block(Block.Obsidian), positions.add(pos, positions.create(-2, 4, 1)), positions.add(pos, positions.create(-2, 4, 2)))
  124. player.say("§a§lI'll let you do the honors.")
  125. player.execute("give @s flint_and_steel")
  126. } else if (num == 16) {
  127. blocks.fill(blocks.block(Block.IronBars), positions.add(player.position(), positions.create(1, 0, -1)), positions.add(player.position(), positions.create(1, 5, 1)))
  128. blocks.fill(blocks.block(Block.IronBars), positions.add(player.position(), positions.create(-1, 0, -1)), positions.add(player.position(), positions.create(-1, 5, 1)))
  129. blocks.fill(blocks.block(Block.IronBars), positions.add(player.position(), positions.create(0, 0, -1)), positions.add(player.position(), positions.create(0, 5, -1)))
  130. blocks.fill(blocks.block(Block.IronBars), positions.add(player.position(), positions.create(0, 0, 1)), positions.add(player.position(), positions.create(0, 5, 1)))
  131. blocks.fill(blocks.block(Block.Gravel), positions.add(player.position(), positions.create(0, 35, 0)), positions.add(player.position(), positions.create(0, 40, 0)))
  132. player.say("§4§lWatch your head!")
  133. } else if (num == 17) {
  134. player.execute('give @s cooked_beef 16')
  135. player.say("§a§lYou look so starved, have some dinner.")
  136. } else if (num == 18) {
  137. player.execute("tp @s ~ ~50 ~")
  138. player.say("§4§lUh oh, don't break your legs!")
  139. }
  140. }
Add Comment
Please, Sign In to add comment