import {
	world,
	system,
	Player
} from '@minecraft/server';

var potnskillet_showed = false;
var keg_showed = false;
var jar_showed = false;
var bowl_showed = false;

function getRandomInt(min, max) {
	min = Math.ceil(min);
	max = Math.floor(max);
	return Math.floor(Math.random() * (max - min + 1)) + min;
}

function printEveryMinute() {
	try {
		if (system.currentTick % 1200 === 0) {
			var rand_num = getRandomInt(0, 65);
			if (rand_num === 0) {
				world.sendMessage(' Recipes will be hidden until an ingredient item is in the player\'s inventory.');
			}
			if (rand_num === 1) {
				world.sendMessage(' The gray italic text below the item\'s name tells you what to do with it.');
			}
			if (rand_num === 2) {
				world.sendMessage(' Do not forget to drink water regularly, otherwise you will gradually lose health to death.');
			}
			if (rand_num === 3) {
				world.sendMessage(' This is a 60-second guide text.');
			}
			if (rand_num === 4) {
				world.sendMessage(' The overworld, chests, and trading are where you may find some of the new crops.');
			}
			if (rand_num === 5) {
				world.sendMessage(' Note that pots without italic text below their names don\'t need a Cobblestone Stove.');
			}
			if (rand_num === 6) {
				world.sendMessage(' There are up to 16 apron types based on color.');
			}
			if (rand_num === 7) {
				world.sendMessage(' Rice is a special crop, it requires a different type of farmland than other crops.');
			}
			if (rand_num === 8) {
				world.sendMessage(' Dishes\' Recipe Reveal mode will show the recipe for the finished dishes.');
			}
			if (rand_num === 9) {
				world.sendMessage(' There is a 10%% change, Cooking Pot and Skillet will not be dropped when food is obtained.');
			}
			if (rand_num === 10) {
				world.sendMessage(' If the pot or skillet needs an item to be obtained, do not try to destroy it once it is done.');
			}
			if (rand_num === 11) {
				world.sendMessage(' The rate at which you lose water is based on the biome you are in.');
			}
			if (rand_num === 12) {
				world.sendMessage(' Pizza is a special item when it requires you to cut it into slices before eating.');
			}
			if (rand_num === 13) {
				world.sendMessage(' Wild rice can be found in rivers.');
			}
			if (rand_num === 14) {
				world.sendMessage(' Try juicing some fruits and vegetables.');
			}
			if (rand_num === 15) {
				world.sendMessage(' You can drink the Water Jar up to 3 times, restoring a total of 18 Water.');
			}
			if (rand_num === 16) {
				world.sendMessage(' Be careful of the rain when drying Wet Rice Flour Bowl.');
			}
			if (rand_num === 17) {
				world.sendMessage(' Apples can be seen beneath the leaves of the Oak tree.');
			}
			if (rand_num === 18) {
				world.sendMessage(' Corn is a unique crop because its seeds must be dried before any further processing.');
			}
			if (rand_num === 19) {
				world.sendMessage(' Did you know you can get Witch\'s hat? But with a drop rate of 14.29%%.');
			}
			if (rand_num === 20) {
				world.sendMessage(' You can only place Wet Rice Flour Bowl in the sun. Do not attempt to place it at night or indoors.');
			}
			if (rand_num === 21) {
				world.sendMessage(' If you don\'t obtain Dried Rice Flour Bowl in time, it will still become Wet Rice Flour Bowl in the rain.');
			}
			if (rand_num === 22) {
				world.sendMessage(' Perhaps you know well... Butterfly in this Addon can do nothing but fly.');
			}
			if (rand_num === 23) {
				world.sendMessage(' The recipes for the dishes in this Addon are based on the author\'s research from website pages.');
			}
			if (rand_num === 24) {
				world.sendMessage(' You can find Butterfly in open biomes.');
			}
			if (rand_num === 25) {
				world.sendMessage(' Miss Wayfarer only trades items necessary for her expedition.');
			}
			if (rand_num === 26) {
				world.sendMessage(' Coffee Bean and Fresh Tea Leaves are items that can only be found at Miss Wayfarer.');
			}
			if (rand_num === 27) {
				world.sendMessage(' Kill pigs to get Pork Bone.');
			}
			if (rand_num === 28) {
				world.sendMessage(' Look at the clock icon to the right of certain item names to determine the waiting time required.');
			}
			if (rand_num === 29) {
				world.sendMessage(' Be careful when eating some items as they can drain your Thirst Bar.');
			}
			if (rand_num === 30) {
				world.sendMessage(' Spot something you think is a bug? Send it along with a screenshot to §lkresnbev@gmail.com§r.');
			}
			if (rand_num === 31) {
				world.sendMessage(' You can literally delete anything by holding it and clicking on Trash Can.');
			}
			if (rand_num === 32) {
				world.sendMessage(' Pure white butterflies spawn exclusively in cold biomes, whereas pure pink butterflies appear solely in the Cherry Grove.');
			}
			if (rand_num === 33) {
				world.sendMessage(' The quantity of grass and flowers generated is significantly greater.');
			}
			if (rand_num === 34) {
				world.sendMessage(' Spice Bundle can only be obtained by trading with Butchers.');
			}
			if (rand_num === 35) {
				world.sendMessage(' Pay attention to tall cacti, as they may have fruits on them.');
			}
			if (rand_num === 36) {
				world.sendMessage(' Pay attention when crossing the Desert or entering Nether, as it can dehydrate you very quickly.');
			}
			if (rand_num === 37) {
				world.sendMessage(' Cold biomes generally make you thirst slower but walk slower.');
			}
			if (rand_num === 38) {
				world.sendMessage(' Try boiling the eggs instead of throwing them.');
			}
			if (rand_num === 39) {
				world.sendMessage(' There are 7 different butterfly colors. Have you seen them all?');
			}
			if (rand_num === 40) {
				world.sendMessage(' Smash a few Oxeye Daisy flowers and you will have a 0.64%% chance of receiving Oxeye Daisy Hat.');
			}
			if (rand_num === 41) {
				world.sendMessage(' Chickens have a 3.03%% chance of dropping Chicken Hat after death.');
			}
			if (rand_num === 42) {
				world.sendMessage(' Piece of Cloth and Wools can be crafted into various types of clothing.');
			}
			if (rand_num === 43) {
				world.sendMessage(' Wild grape bushes only grow in forest biomes.');
			}
			if (rand_num === 44) {
				world.sendMessage(' Wild tomato plants grow in plains and forests.');
			}
			if (rand_num === 45) {
				world.sendMessage(' Wild cucumber plants can be found climbing dead bushes in the plains and hills.');
			}
			if (rand_num === 46) {
				world.sendMessage(' Mustard plants with yellow flowers can be found scattered in meadows or flower forests.');
			}
			if (rand_num === 47) {
				world.sendMessage(' Bad news, we have popcorn but no movies.');
			}
			if (rand_num === 48) {
				world.sendMessage(' Before you can craft clothing, you will need to buy a certain book from Shepherds.');
			}
			if (rand_num === 49) {
				world.sendMessage(' From a vegetable, you can choose how to cut it, such as slicing, mincing, dicing, and so on.');
			}
			if (rand_num === 50) {
				world.sendMessage(' Read the README.txt inside the Addon\'s folder for some more information.');
			}
			if (rand_num === 51) {
				world.sendMessage(' Sunflower oil bottle or condiment bottles have many stages and can be used many times.');
			}
			if (rand_num === 52) {
				world.sendMessage(' Drinking too much alcoholic drinks can lead to nausea.');
			}
			if (rand_num === 53) {
				world.sendMessage(' Each alcoholic drink has a different level of warming and varying duration of nausea.');
			}
			if (rand_num === 54) {
				world.sendMessage(' Staying in cold biomes slows you down and makes you cold. Therefore, having some alcoholic drinks is important.');
			}
			if (rand_num === 55) {
				world.sendMessage(' Alcoholic drinks keep you warmer but make you weaker.');
			}
			if (rand_num === 56) {
				world.sendMessage(' You can buy Sunflower Oil Bottle at Farmers.');
			}
			if (rand_num === 57) {
				world.sendMessage(' Entering cold biomes at night is dangerous.');
			}
			if (rand_num === 58) {
				world.sendMessage(' Look for the green star on pots, skillets, wooden kegs, or jars to check if they are done.');
			}
			if (rand_num === 59) {
				world.sendMessage(' Items with a skull symbol next to their name are dangerous to consume.');
			}
			if (rand_num === 60) {
				world.sendMessage(' A Sunflower Oil Bottle requires 72 sunflowers to craft.');
			}
			if (rand_num === 61) {
				world.sendMessage(' Don\'t kill butterflies. They waste energy and drop nothing, unless for practice fighting skills.');
			}
			if (rand_num === 62) {
				world.sendMessage(' There is a special book helps you craft clothing but can only be traded to Master-level Shepherds.');
			}
			if (rand_num === 63) {
				world.sendMessage(' This is beta.1 version.');
			}
			if (rand_num === 64) {
				world.sendMessage(' New dishes will be added in future versions.');
			}
			if (rand_num === 65) {
				world.sendMessage(' The beta versions may differ slightly from the official version.');
			}
		}
	} catch (e) {
		console.warn('Error: ' + e);
	}

	system.run(printEveryMinute);
}
printEveryMinute();

world.beforeEvents.itemUseOn.subscribe(event => {
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_fresh_spaghetti_and_water" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_eggs_and_water" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_chicken_and_water" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_raw_rice_noodles_and_water" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_pho_broth_ingredients" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_chocolate_bar_ingredients" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_corns_and_water" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_fish_sauce" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_flan_ingredients" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_ketcup_ingredients" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_milk_tea_ingredients" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_popcorn_ingredients" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_raw_vietnamese_sausage_and_water" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_sweet_berries_jam_ingredients" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_vegetable_soup_ingredients" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_pork_bone_broth_ingredients" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_water" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:cooking_pot_of_white_rice_and_water" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:skillet_of_breaded_chicken_thighs" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:skillet_of_crushed_tomatoes" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:skillet_of_fried_rice_ingredients" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:skillet_of_garlic_butter_fried_corn_ingredients" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:skillet_of_minced_beef" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:skillet_of_pancake_batter" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:skillet_of_potato_sliced_strips" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:skillet_of_raw_doughnut" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:skillet_of_sugar" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:skillet_of_uncooked_corn_dogs" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:skillet_of_raw_beef_and_egg" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:skillet_of_salt_cured_meats_and_egg" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:skillet_of_one_egg" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:skillet_of_two_eggs" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:skillet_of_three_eggs" && potnskillet_showed === false) {
		system.run(() => {
			potnskillet_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' After cooking, click on the pot or the skillet to obtain or view the required item.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:bucket_of_beer_ingredients" && keg_showed === false) {
		system.run(() => {
			keg_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' When ready, click on the keg with a glass bottle to obtain the drink.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:bucket_of_cider_ingredients" && keg_showed === false) {
		system.run(() => {
			keg_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' When ready, click on the keg with a glass bottle to obtain the drink.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:bucket_of_mead_ingredients" && keg_showed === false) {
		system.run(() => {
			keg_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' When ready, click on the keg with a glass bottle to obtain the drink.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:bucket_of_wine_ingredient" && keg_showed === false) {
		system.run(() => {
			keg_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' When ready, click on the keg with a glass bottle to obtain the drink.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:wet_rice_flour_bowl" && bowl_showed === false) {
		system.run(() => {
			bowl_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' Once dry, click on it to obtain. Be mindful of the rain.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:just_made_fish_sauce_jar" && jar_showed === false) {
		system.run(() => {
			jar_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' Once fermented, click on it to obtain.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:recently_pickled_carrot_and_daikon_jar" && jar_showed === false) {
		system.run(() => {
			jar_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' Once fermented, click on it to obtain.')
		})
	}
	if (event.itemStack.typeId === "gourmet_dreams:recently_pickled_cucumber_jar" && jar_showed === false) {
		system.run(() => {
			jar_showed = true;
			const PLAYER = event.source;
			PLAYER.sendMessage(' Once fermented, click on it to obtain.')
		})
	}
})