sammelfieber.txt 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. carved_pumpkin = read.item("carved_pumpkin");
  2. leaves_tag = block.getTag("minecraft:leaves");
  3. double_block_half_property = block.getProperty("double_block_half");
  4. gosub("setstart");
  5. step = 1;
  6. gamename = "§aSammelfieber";
  7. no_core_reset = true;
  8. templist = list.new();
  9. list.add(templist, items1);
  10. list.add(templist, items2);
  11. list.add(templist, items3);
  12. list.add(templist, items4);
  13. for(h = 0; h < list.getSize(templist); h++) {
  14. list = list.getIndex(templist, h);
  15. for(i = 0; i < list.getSize(list); i++) {
  16. item_type = list.getIndex(list, i);
  17. item = read.item(item_type);
  18. if(item == null) {
  19. minigame.speakAll(item_type);
  20. minigame.speakAll("False Item found. Game termed. Inform marvinius.");
  21. term();
  22. }
  23. }
  24. }
  25. goto("simplelobby");
  26. @specificLobbyHandling
  27. if(event == "player_join") {
  28. if(init_signs == null) {
  29. block.setSign(sign_min_loc, 2, text.number(min));
  30. block.setSign(sign_amount_loc, 2, text.number(amount_nextitems));
  31. init_signs = true;
  32. }
  33. return;
  34. }
  35. if(event == "block_click") {
  36. if(hand == "offhand") {
  37. return;
  38. }
  39. if(block_loc == plus_min_loc) {
  40. if(min < max_mins) {
  41. min++;
  42. }
  43. block.setSign(sign_min_loc, 2, text.number(min));
  44. return;
  45. }
  46. if(block_loc == minus_min_loc) {
  47. if(min > 1) {
  48. min--;
  49. }
  50. block.setSign(sign_min_loc, 2, text.number(min));
  51. return;
  52. }
  53. if(block_loc == plus_amount_loc) {
  54. if(amount_nextitems < max_nextitems) {
  55. amount_nextitems++;
  56. }
  57. block.setSign(sign_amount_loc, 2, text.number(amount_nextitems));
  58. return;
  59. }
  60. if(block_loc == minus_amount_loc) {
  61. if(amount_nextitems > 1) {
  62. amount_nextitems--;
  63. }
  64. block.setSign(sign_amount_loc, 2, text.number(amount_nextitems));
  65. return;
  66. }
  67. }
  68. return;
  69. @finalstart
  70. player_list = minigame.getPlayers(script_id);
  71. minigame.speakAll(gamename, "The game has started.");
  72. whole_secs = min * 60 + sec;
  73. time_phase_1 = whole_secs / 4 * 3;
  74. time_phase_2 = whole_secs / 4 * 2;
  75. time_phase_3 = whole_secs / 4;
  76. timer_string = concat("§bTimer: §r", text.number(min), " min 0", text.number(sec), " s");
  77. iter = list.iterator(player_list);
  78. while(hasNext(iter)) {
  79. player = player.get(next(iter));
  80. entity.teleport(player, spawn_loc);
  81. player.setGamemode(player, "survival");
  82. player.setFly(player, false);
  83. entity.cleareffects(player);
  84. living.setHealth(player, 20);
  85. player.setHunger(player, 20);
  86. player.setSaturation(player, 5);
  87. player.clearInventory(player);
  88. display.reset(player);
  89. display.add(player, 1, gamename);
  90. display.add(player, 2, timer_string);
  91. display.add(player, 3, "§bFound Items: §r0");
  92. display.add(player, 4, "§bNext Items:");
  93. entity.addEffect(player, "speed", min * 60 * 20, 1);
  94. }
  95. event.load("bucket_use");
  96. event.load("player_pickup");
  97. event.load("craft");
  98. farmtypes = list.new();
  99. list.add(farmtypes, "minecraft:carrots");
  100. list.add(farmtypes, "minecraft:melon_stem");
  101. list.add(farmtypes, "minecraft:potatoes");
  102. list.add(farmtypes, "minecraft:wheat");
  103. player_blocks = set.new();
  104. set.add(player_blocks, "minecraft:crafting_table");
  105. set.add(player_blocks, "minecraft:furnace");
  106. set.add(player_blocks, "minecraft:chest");
  107. nextitems = list.new();
  108. founditems = list.new();
  109. player_blocks_placed = set.new();
  110. resetlist_type = list.new();
  111. resetlist_loc = list.new();
  112. resetlistdouble_type = list.new();
  113. resetlistdouble_loc = list.new();
  114. resetlistdouble_loc2 = list.new();
  115. sgoto(1, "tick");
  116. for(h = 0; h < amount_nextitems; h++) {
  117. gosub("newitem");
  118. }
  119. minigame.speakAll(gamename, "Collect as many shown items as you can.");
  120. minigame.speakAll(gamename, "Drop and collect not counted items again.");
  121. @wait
  122. wait();
  123. if(player.hasMinigameId(player, script_id)) {
  124. ignoreGoto(event);
  125. }
  126. goto("wait");
  127. @block_click
  128. if(action == "right") {
  129. if(set.contains(player_blocks, block_type)) {
  130. goto("wait");
  131. }
  132. if(hand == "MAIN_HAND") {
  133. hand = "hand";
  134. } else {
  135. hand = "offhand";
  136. }
  137. item_type = item.getType(living.getEquip(player, hand));
  138. if(set.contains(player_blocks, item_type)) {
  139. goto("wait");
  140. }
  141. cancel = true;
  142. if(block_type == "minecraft:pumpkin" && item_type == "minecraft:shears") {
  143. item.drop(block_loc, carved_pumpkin);
  144. }
  145. }
  146. goto("wait");
  147. @living_pre_hurt
  148. if(isPlayer(living_entity)) {
  149. cancel = true;
  150. }
  151. goto("wait");
  152. @block_break
  153. cancel = false;
  154. if(set.contains(player_blocks, block_type)) {
  155. goto("wait");
  156. }
  157. if(block.hasTag(leaves_tag, block.get(block_loc))) {
  158. split_list = text.split("_", block_type);
  159. drop_type = concat(text.concatList(split_list, "_", 0, list.getSize(split_list) - 2), "_sapling");
  160. item.drop(block_loc, read.item(drop_type));
  161. }
  162. state = block.property.getValue(block_loc, double_block_half_property);
  163. if(state != null) {
  164. if(state == "lower") {
  165. loc = block_loc;
  166. loc2 = loc.mod(block_loc, 0, 1, 0);
  167. } else {
  168. loc = loc.mod(block_loc, 0, -1, 0);
  169. loc2 = block_loc;
  170. }
  171. list.add(resetlistdouble_type, block_type);
  172. list.add(resetlistdouble_loc, loc);
  173. list.add(resetlistdouble_loc2, loc2);
  174. sgoto(1, "doubleresetblock");
  175. goto("wait");
  176. }
  177. if(block_type == "minecraft:vine") {
  178. cancel = true;
  179. goto("wait");
  180. }
  181. if(block_type == "minecraft:sugar_cane") {
  182. cancel = true;
  183. item.drop(block_loc, read.item("sugar_cane"));
  184. goto("wait");
  185. }
  186. if(block_type == "minecraft:farmland") {
  187. cancel = true;
  188. goto("wait");
  189. }
  190. list.add(resetlist_type, block_type);
  191. list.add(resetlist_loc, block_loc);
  192. sgoto(1, "resetblock");
  193. goto("wait");
  194. @bucket_use
  195. cancel = true;
  196. goto("wait");
  197. @block_place
  198. cancel = true;
  199. if(set.contains(player_blocks, block_type)) {
  200. cancel = false;
  201. set.add(player_blocks_placed, block_loc);
  202. }
  203. goto("wait");
  204. @doubleresetblock
  205. btype = list.getIndex(resetlistdouble_type, 0);
  206. loc = list.getIndex(resetlistdouble_loc, 0);
  207. loc2 = list.getIndex(resetlistdouble_loc2, 0);
  208. list.removeIndex(resetlistdouble_type, 0);
  209. list.removeIndex(resetlistdouble_loc, 0);
  210. list.removeIndex(resetlistdouble_loc2, 0);
  211. block.set(loc, concat(btype, "[half=lower]"));
  212. block.set(loc2, concat(btype, "[half=upper]"));
  213. goto("wait");
  214. @resetblock
  215. btype = list.getIndex(resetlist_type, 0);
  216. bloc = list.getIndex(resetlist_loc, 0);
  217. list.removeIndex(resetlist_type, 0);
  218. list.removeIndex(resetlist_loc, 0);
  219. if(list.contains(farmtypes, btype)) {
  220. block.set(bloc, concat(btype, "[age=7]"));
  221. } else {
  222. block.set(bloc, btype);
  223. }
  224. goto("wait");
  225. @tick
  226. if(sec == 0) {
  227. sec = 59;
  228. min--;
  229. if(min == -1) {
  230. goto("endgame");
  231. }
  232. } else {
  233. sec--;
  234. if(sec < 10) {
  235. minigame.displayAll(2, concat("§bTimer: §r", text.number(min), " min 0", text.number(sec), " s"));
  236. } else {
  237. minigame.displayAll(2, concat("§bTimer: §r", text.number(min), " min ", text.number(sec), " s"));
  238. }
  239. if(min == 0) {
  240. if(sec == 30) {
  241. minigame.speakAll(gamename, "30 seconds left!");
  242. } elseif(sec == 10) {
  243. minigame.speakAll(gamename, "10 seconds left!");
  244. } elseif(sec == 5) {
  245. minigame.speakAll(gamename, "5 seconds left!");
  246. }
  247. }
  248. }
  249. sgoto(20, "tick");
  250. goto("wait");
  251. @player_pickup
  252. @craft
  253. itype = item.getType(item);
  254. if(list.contains(nextitems, itype)) {
  255. list.add(founditems, itype);
  256. list.remove(nextitems, itype);
  257. minigame.displayAll(3, concat("§bFound Items: §r", text.number(list.getSize(founditems))));
  258. gosub("newitem");
  259. }
  260. goto("wait");
  261. @newitem
  262. atm_time = min * 60 + sec;
  263. if(atm_time < time_phase_1) {
  264. if(step == 1) {
  265. for(i = 0; i < list.getSize(items2); i++) {
  266. list.add(items1, list.getIndex(items2, i));
  267. }
  268. step = 2;
  269. }
  270. if(atm_time < time_phase_2) {
  271. if(step == 2) {
  272. for(i = 0; i < list.getSize(items3); i++) {
  273. list.add(items1, list.getIndex(items3, i));
  274. }
  275. step = 3;
  276. }
  277. if(atm_time < time_phase_3) {
  278. if(step == 3) {
  279. for(i = 0; i < list.getSize(items4); i++) {
  280. list.add(items1, list.getIndex(items4, i));
  281. }
  282. step = 4;
  283. }
  284. }
  285. }
  286. }
  287. items1_size = list.getSize(items1);
  288. if(items1_size == 0) {
  289. return;
  290. }
  291. randomitemstring = list.getIndex(items1, math.random(0, items1_size - 1));
  292. list.remove(items1, randomitemstring);
  293. list.add(nextitems, randomitemstring);
  294. for(i = 0; i < list.getSize(nextitems); i++) {
  295. type = list.getIndex(nextitems, i);
  296. minigame.displayAll(5 + i, text.replace(type, "minecraft:", ""));
  297. }
  298. return;
  299. @player_logout
  300. @player_giveup
  301. script = script.getFromId(script_id);
  302. minigame.kickplayer(script, player);
  303. if(list.getSize(player_list) == 0) {
  304. goto("endcore");
  305. }
  306. goto("wait");
  307. @endgame
  308. yetfound = list.getSize(founditems);
  309. script = script.getFromId(script_id);
  310. iter = list.iterator(player_list);
  311. while(hasNext(iter)) {
  312. player = player.get(next(iter));
  313. minigame.statsHeader(player, $gamename, "§e");
  314. minigame.statsLine(player, "§e", "Found Items", text.number(yetfound));
  315. }
  316. @endcore
  317. iter = set.iterator(player_blocks_placed);
  318. while(hasNext(iter)) {
  319. block.set(next(iter), "minecraft:air");
  320. }
  321. entity.removeAll("net.minecraft.entity.item.ItemEntity", middleloc, radius);
  322. minigame.kickAllPlayers(script);
  323. minigame.term(script, gamesignloc);
  324. term();