story.txt 3.3 KB

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