sammelfieber.txt 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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(2, "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(event == "living_pre_hurt") {
  124. if(!isPlayer(living_entity)) {
  125. goto("wait");
  126. }
  127. player = living_entity;
  128. }
  129. if(player.hasMinigameId(player, script_id)) {
  130. ignoreGoto(event);
  131. }
  132. goto("wait");
  133. @block_click
  134. if(action == "right") {
  135. if(set.contains(player_blocks, block_type)) {
  136. goto("wait");
  137. }
  138. if(hand == "MAIN_HAND") {
  139. hand = "hand";
  140. } else {
  141. hand = "offhand";
  142. }
  143. item_type = item.getType(living.getEquip(player, hand));
  144. if(set.contains(player_blocks, item_type)) {
  145. goto("wait");
  146. }
  147. cancel = true;
  148. if(block_type == "minecraft:pumpkin" && item_type == "minecraft:shears") {
  149. item.drop(block_loc, carved_pumpkin);
  150. }
  151. }
  152. goto("wait");
  153. @living_pre_hurt
  154. cancel = true;
  155. goto("wait");
  156. @block_break
  157. cancel = false;
  158. if(set.contains(player_blocks, block_type)) {
  159. goto("wait");
  160. }
  161. if(block.hasTag(leaves_tag, block.get(block_loc))) {
  162. split_list = text.split("_", block_type);
  163. drop_type = concat(text.concatList(split_list, "_", 0, list.getSize(split_list) - 2), "_sapling");
  164. item.drop(block_loc, read.item(drop_type));
  165. }
  166. state = block.property.getValue(block_loc, double_block_half_property);
  167. if(state != null) {
  168. if(state == "lower") {
  169. loc = block_loc;
  170. loc2 = loc.mod(block_loc, 0, 1, 0);
  171. } else {
  172. loc = loc.mod(block_loc, 0, -1, 0);
  173. loc2 = block_loc;
  174. }
  175. list.add(resetlistdouble_type, block_type);
  176. list.add(resetlistdouble_loc, loc);
  177. list.add(resetlistdouble_loc2, loc2);
  178. sgoto(2, "doubleresetblock");
  179. goto("wait");
  180. }
  181. if(block_type == "minecraft:vine") {
  182. cancel = true;
  183. goto("wait");
  184. }
  185. if(block_type == "minecraft:sugar_cane") {
  186. cancel = true;
  187. item.drop(block_loc, read.item("sugar_cane"));
  188. goto("wait");
  189. }
  190. if(block_type == "minecraft:farmland") {
  191. cancel = true;
  192. goto("wait");
  193. }
  194. list.add(resetlist_type, block_type);
  195. list.add(resetlist_loc, block_loc);
  196. sgoto(2, "resetblock");
  197. goto("wait");
  198. @bucket_use
  199. cancel = true;
  200. goto("wait");
  201. @block_place
  202. cancel = true;
  203. if(set.contains(player_blocks, block_type)) {
  204. cancel = false;
  205. set.add(player_blocks_placed, block_loc);
  206. }
  207. goto("wait");
  208. @doubleresetblock
  209. btype = list.getIndex(resetlistdouble_type, 0);
  210. loc = list.getIndex(resetlistdouble_loc, 0);
  211. loc2 = list.getIndex(resetlistdouble_loc2, 0);
  212. list.removeIndex(resetlistdouble_type, 0);
  213. list.removeIndex(resetlistdouble_loc, 0);
  214. list.removeIndex(resetlistdouble_loc2, 0);
  215. block.set(loc, concat(btype, "[half=lower]"));
  216. block.set(loc2, concat(btype, "[half=upper]"));
  217. goto("wait");
  218. @resetblock
  219. btype = list.getIndex(resetlist_type, 0);
  220. bloc = list.getIndex(resetlist_loc, 0);
  221. list.removeIndex(resetlist_type, 0);
  222. list.removeIndex(resetlist_loc, 0);
  223. if(list.contains(farmtypes, btype)) {
  224. block.set(bloc, concat(btype, "[age=7]"));
  225. } else {
  226. block.set(bloc, btype);
  227. }
  228. goto("wait");
  229. @tick
  230. if(sec == 0) {
  231. sec = 59;
  232. min--;
  233. if(min == -1) {
  234. goto("endgame");
  235. }
  236. } else {
  237. sec--;
  238. if(sec < 10) {
  239. minigame.displayAll(2, concat("§bTimer: §r", text.number(min), " min 0", text.number(sec), " s"));
  240. } else {
  241. minigame.displayAll(2, concat("§bTimer: §r", text.number(min), " min ", text.number(sec), " s"));
  242. }
  243. if(min == 0) {
  244. if(sec == 30) {
  245. minigame.speakAll(gamename, "30 seconds left!");
  246. } elseif(sec == 10) {
  247. minigame.speakAll(gamename, "10 seconds left!");
  248. } elseif(sec == 5) {
  249. minigame.speakAll(gamename, "5 seconds left!");
  250. }
  251. }
  252. }
  253. sgoto(20, "tick");
  254. goto("wait");
  255. @player_pickup
  256. @craft
  257. itype = item.getType(item);
  258. if(list.contains(nextitems, itype)) {
  259. list.add(founditems, itype);
  260. list.remove(nextitems, itype);
  261. minigame.displayAll(3, concat("§bFound Items: §r", text.number(list.getSize(founditems))));
  262. gosub("newitem");
  263. }
  264. goto("wait");
  265. @newitem
  266. atm_time = min * 60 + sec;
  267. if(atm_time < time_phase_1) {
  268. if(step == 1) {
  269. for(i = 0; i < list.getSize(items2); i++) {
  270. list.add(items1, list.getIndex(items2, i));
  271. }
  272. step = 2;
  273. }
  274. if(atm_time < time_phase_2) {
  275. if(step == 2) {
  276. for(i = 0; i < list.getSize(items3); i++) {
  277. list.add(items1, list.getIndex(items3, i));
  278. }
  279. step = 3;
  280. }
  281. if(atm_time < time_phase_3) {
  282. if(step == 3) {
  283. for(i = 0; i < list.getSize(items4); i++) {
  284. list.add(items1, list.getIndex(items4, i));
  285. }
  286. step = 4;
  287. }
  288. }
  289. }
  290. }
  291. items1_size = list.getSize(items1);
  292. if(items1_size == 0) {
  293. return;
  294. }
  295. randomitemstring = list.getIndex(items1, math.random(0, items1_size - 1));
  296. list.remove(items1, randomitemstring);
  297. list.add(nextitems, randomitemstring);
  298. for(i = 0; i < list.getSize(nextitems); i++) {
  299. type = list.getIndex(nextitems, i);
  300. minigame.displayAll(5 + i, text.replace(type, "minecraft:", ""));
  301. }
  302. return;
  303. @player_logout
  304. @player_giveup
  305. script = script.getFromId(script_id);
  306. minigame.kickplayer(script, player);
  307. if(list.getSize(player_list) == 0) {
  308. goto("endcore");
  309. }
  310. goto("wait");
  311. @endgame
  312. yetfound = list.getSize(founditems);
  313. script = script.getFromId(script_id);
  314. iter = list.iterator(player_list);
  315. while(hasNext(iter)) {
  316. player = player.get(next(iter));
  317. minigame.statsHeader(player, $gamename, "§e");
  318. minigame.statsLine(player, "§e", "Found Items", text.number(yetfound));
  319. }
  320. @endcore
  321. iter = set.iterator(player_blocks_placed);
  322. while(hasNext(iter)) {
  323. block.set(next(iter), "minecraft:air");
  324. }
  325. entity.removeAll("net.minecraft.entity.item.ItemEntity", middleloc, radius);
  326. minigame.kickAllPlayers(script);
  327. minigame.term(script, gamesignloc);
  328. term();