function stage.increase(player) { $stage++; quest.display(player, $quest_name, $stage, $all_stages); sound = sound.get("minecraft:entity.experience_orb.pickup"); category = sound.getCategory("MASTER"); sound.spawnForPlayer(player, sound, category); } function quest.start(player, path) { modTimer(-45); script = script.start(path, "utils/u_quest", "utils/u_general", "utils/u_questerror"); if(script == null) { msg.dev("quest not started"); return; } quest.addPlayer(script, player); script.setVar(script, "player", player); script.setVar(script, "script", script); script.callEvent("quest_start", script); inv.close(player); } function player.unlockedLumberjack(player_or_id) { config = playerdata.getSurvival(player_or_id); return config.getBool(config, "skillshop.lumberjack", false); } function player.unlockLumberjack(player_or_id) { config = playerdata.getSurvival(player_or_id); config.set(config, "skillshop.lumberjack", true); config.saveAsync(config); } function player.unlockedMage(player_or_id) { config = playerdata.getSurvival(player_or_id); return config.getBool(config, "skillshop.mage", false); } function player.unlockMage(player_or_id) { config = playerdata.getSurvival(player_or_id); config.set(config, "skillshop.mage", true); config.saveAsync(config); } function player.getShipProgress(player_or_id) { config = playerdata.getSurvival(player_or_id); return config.getDouble(config, "ship.progress", 0); } function player.setShipProgress(player_or_id, progress) { config = playerdata.getSurvival(player_or_id); old_progress = config.getDouble(config, "ship.progress", 0); if(progress > old_progress) { config.set(config, "ship.progress", progress); config.saveAsync(config); } } function citizen.giveItem(citizen_name, player, needed_type_or_tag, needed_amount) { if(needed_amount == 0) { return -1; } item = living.getHand(player); if(item == null) { return needed_amount; } item_type = item.getType(item); citizen_name = string.concat("§d", citizen_name); needed = false; tag_check = false; if(isMaterial(needed_type_or_tag)) { if(item_type == needed_type_or_tag) { needed = true; } } else { if(item.hasTag(item, needed_type_or_tag)) { needed = true; tag_check = true; } } if(needed) { amount_not_removed = player.removeItem(player, item.new(item_type, needed_amount)); if(amount_not_removed == 0) { return 0; } player.removeItem(player, item.new(item_type, amount_not_removed)); rest_item_amount = needed_amount - amount_not_removed; rest_item = item.new(item_type, rest_item_amount); rest_item = player.removeItemNbt(player, rest_item); rest_item_amount = item.getAmount(rest_item); if(rest_item_amount > 0) { if(tag_check) { rest_item = player.removeItemTag(player, needed_type_or_tag, rest_item_amount); rest_item_amount = item.getAmount(rest_item); if(rest_item_amount > 0) { msg.prefix(player, citizen_name, string.concat("I need ", string.number(rest_item_amount), " more of these please.")); } } else { msg.prefix(player, citizen_name, string.concat("I need ", string.number(rest_item_amount), " more of these please.")); } } return rest_item_amount; } msg.prefix(player, citizen_name, "I do not need this."); return needed_amount; } /* stable(stable_mid_loc, stable_spawn_loc_list) while there aren't enough, spawns animals */ function stable(stable_mid_loc, stable_spawn_loc_list){ living_list = living.near(stable_mid_loc, 10); list_iterator = iterator(living_list); cow_count = 0; pig_count = 0; sheep_count = 0; while(hasnext(list_iterator)){ living_entity_type = entity.getType(next(list_iterator)); if(living_entity_type == "cow"){ cow_count++; }elseif(living_entity_type == "pig"){ pig_count++; }elseif(living_entity_type == "sheep"){ sheep_count++; } } while(cow_count < 4){//cow_max spawned_entity = entity.spawn(loc.mod(list.getIndex(stable_spawn_loc_list, math.random(0, $spawn_list_size)), 0.5, 0, 0.5), "COW"); cow_count++; } while(pig_count < 3){//pig_max spawned_entity = entity.spawn(loc.mod(list.getIndex(stable_spawn_loc_list, math.random(0, $spawn_list_size)), 0.5, 0, 0.5), "PIG"); pig_count++; } while(sheep_count < 5){//sheep_max spawned_entity = entity.spawn(loc.mod(list.getIndex(stable_spawn_loc_list, math.random(0, $spawn_list_size)), 0.5, 0, 0.5), "SHEEP"); sheep_count++; } } /* stable.getSpawn_locs(loc) returns list with all spawn_locations for animals in given surrounding stable */ function stable.getSpawn_locs(loc){ stable_spawn_loc_list = list.new(); list.add(stable_spawn_loc_list, loc.mod(loc, 0.5, 1, 0.5)); $stable_temp_list = list.new(); $stable_temp_list2 = list.new(); list.add($stable_temp_list, loc); while(list.getSize($stable_temp_list) != 0){ block_loc = list.getIndex($stable_temp_list, 0); list.removeIndex($stable_temp_list, 0); distance = loc.distance(block_loc, loc); if(distance < 25){ temp_block = stable.addLoc_if(loc.mod(block_loc,1,0,0)); if(temp_block != null){ list.add(stable_spawn_loc_list, temp_block); } temp_block = stable.addLoc_if(loc.mod(block_loc,-1,0,0)); if(temp_block != null){ list.add(stable_spawn_loc_list, temp_block); } temp_block = stable.addLoc_if(loc.mod(block_loc,0,0,1)); if(temp_block != null){ list.add(stable_spawn_loc_list, temp_block); } temp_block = stable.addLoc_if(loc.mod(block_loc,0,0,-1)); if(temp_block != null){ list.add(stable_spawn_loc_list, temp_block); } temp_block = stable.addLoc_if(loc.mod(block_loc,1,1,0)); if(temp_block != null){ list.add(stable_spawn_loc_list, temp_block); } temp_block = stable.addLoc_if(loc.mod(block_loc,-1,1,0)); if(temp_block != null){ list.add(stable_spawn_loc_list, temp_block); } temp_block = stable.addLoc_if(loc.mod(block_loc,0,1,1)); if(temp_block != null){ list.add(stable_spawn_loc_list, temp_block); } temp_block = stable.addLoc_if(loc.mod(block_loc,0,1,-1)); if(temp_block != null){ list.add(stable_spawn_loc_list, temp_block); } temp_block = stable.addLoc_if(loc.mod(block_loc,1,-1,0)); if(temp_block != null){ list.add(stable_spawn_loc_list, temp_block); } temp_block = stable.addLoc_if(loc.mod(block_loc,-1,-1,0)); if(temp_block != null){ list.add(stable_spawn_loc_list, temp_block); } temp_block = stable.addLoc_if(loc.mod(block_loc,0,-1,1)); if(temp_block != null){ list.add(stable_spawn_loc_list, temp_block); } temp_block = stable.addLoc_if(loc.mod(block_loc,0,-1,-1)); if(temp_block != null){ list.add(stable_spawn_loc_list, temp_block); } } } return stable_spawn_loc_list; } function stable.addLoc_if(temp_loc){ if(!list.contains($stable_temp_list2, temp_loc)){ temp_block = block.get(temp_loc); temp_block2 = loc.mod(temp_loc, 0, 1, 0); temp_type1 = block.getType(temp_block); temp_type2 = block.getType(block.get(temp_block2)); temp_type3 = block.getType(block.get(loc.mod(temp_block2, 0, 1, 0))); if(temp_type1 == $grass_block_material && temp_type2 == $air_material && temp_type3 == $air_material){ list.add($stable_temp_list, temp_loc); list.add($stable_temp_list2, temp_loc); return temp_block2; } } }