story.txt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. event.load("block_click");
  2. event.load("inv_click");
  3. event.load("player_move");
  4. event.load("player_pre_respawn");
  5. event.load("player_post_respawn");
  6. quest.setBlockList(list.new());
  7. story_world = world.getStory();
  8. move_id_to_spawn = event.addMoveData(loc.new(story_world, -1501.5, 59, -35.5), loc.new(story_world, -1499, 62.5, -33), 5, -1);
  9. story_respawn = set.new();
  10. age_prop_3 = block.getProperty("age_0_3");
  11. bread_loc = loc.new(story_world, -1568, 67, -66);
  12. transit_loc = loc.new(story_world, -1522, 64, -18);
  13. schiff_spawn = loc.new(story_world, -1636, 63, -999, 50, 0.0001);
  14. bread = read.item("minecraft:bread", 3);
  15. times = map.new();
  16. bread_wait_time = 3; //seconds
  17. transit_inv = inv.new("333333333");
  18. inv.setItem(transit_inv, 0, read.item("minecraft:cake", 1, "§fAdmont"));
  19. inv.setItem(transit_inv, 1, read.item("minecraft:sand", 1, "§fSchiffbruch"));
  20. msg("dev", "§bStory §rloaded.");
  21. @wait
  22. wait();
  23. ignoreGoto(event);
  24. goto("wait");
  25. @block_click
  26. world = loc.getWorld(block_loc);
  27. if(world.getName(world) != "story") {
  28. goto("wait");
  29. }
  30. if(block_type == "minecraft:sweet_berry_bush") {
  31. scheduler.setBlock(5, block_loc, concat("minecraft:sweet_berry_bush[age=3]"), false);
  32. goto("wait");
  33. }
  34. if(hand == "OFF_HAND") {
  35. goto("wait");
  36. }
  37. if(action == "left") {
  38. goto("wait");
  39. }
  40. if(block_type == "minecraft:oak_leaves") {
  41. r = math.random(1, 20);
  42. if(r == 1) {
  43. item.drop(block_loc, read.item("minecraft:apple"));
  44. }
  45. r = math.random(1, 1000);
  46. if(r == 1) {
  47. item.drop(block_loc, read.item("minecraft:golden_apple"));
  48. }
  49. goto("wait");
  50. }
  51. if(block_type == "km:plum_leaves") {
  52. r = math.random(1, 20);
  53. if(r == 1) {
  54. item.drop(block_loc, read.item("km:plum"));
  55. }
  56. goto("wait");
  57. }
  58. if(block_type == "km:apricot_leaves") {
  59. r = math.random(1, 20);
  60. if(r == 1) {
  61. item.drop(block_loc, read.item("km:apricot"));
  62. }
  63. goto("wait");
  64. }
  65. if(block_type == "km:pear_leaves") {
  66. r = math.random(1, 20);
  67. if(r == 1) {
  68. item.drop(block_loc, read.item("km:pear"));
  69. }
  70. goto("wait");
  71. }
  72. if(block_loc == transit_loc) {
  73. inv.open(transit_inv, player, "Überfahrt");
  74. goto("wait");
  75. }
  76. if(block_loc == bread_loc) {
  77. player_uuid = player.getUuid(player);
  78. now_time = time.getMillis();
  79. time = map.getOrDefault(times, player_uuid, 0);
  80. diff_time = (now_time - time) / 1000;
  81. if(diff_time > bread_wait_time) {
  82. map.add(times, player_uuid, now_time);
  83. player.giveItem(player, bread);
  84. } else {
  85. msg.prefix(player, "§6FoodGiver", concat("Please wait for ", text.number(math.round(bread_wait_time - diff_time)), " seconds."));
  86. }
  87. }
  88. goto("wait");
  89. @inv_click
  90. if(inv_name == "Überfahrt") {
  91. if(item.getType(item) == "minecraft:air") {
  92. goto("wait");
  93. }
  94. if(inv_slot == 0) {
  95. entity.teleport(player, world.getStorySpawn());
  96. } elseif(inv_slot == 1) {
  97. entity.teleport(player, schiff_spawn);
  98. }
  99. inv.close(player);
  100. }
  101. goto("wait");
  102. @player_move
  103. if(id == move_id_to_spawn) {
  104. player.setBackPosLoc(player, world.getStorySpawn());
  105. player.teleport(player, world.getServerSpawn(), false);
  106. }
  107. goto("wait");
  108. @player_pre_respawn
  109. if(loc.isInStoryWorld(entity.getLocation(player))) {
  110. set.add(story_respawn, player.getUuid(player));
  111. }
  112. goto("wait");
  113. @player_post_respawn
  114. player_uuid = player.getUuid(player);
  115. if(set.contains(story_respawn, player_uuid)) {
  116. set.remove(story_respawn, player_uuid);
  117. entity.teleport(player, world.getStorySpawn());
  118. }
  119. goto("wait");