neuralgia/kubejs/server_scripts/ftb_quests/CustomQuests.js
Pyritie 189f5aebce
Alpha Release: additions 0.9.0 (#880)
Signed-off-by: Pyritie <pyritie@gmail.com>
Signed-off-by: TomPlop <tomdidome@gmail.com>
Signed-off-by: Adora <adoradyne.58@gmail.com>
Signed-off-by: MetenBouldry <94766011+MetenBouldry@users.noreply.github.com>
Signed-off-by: CaitlynMC <135169224+CaitlynMC@users.noreply.github.com>
Signed-off-by: SverhRazum-Nah <leon.trol@mail.ru>
Signed-off-by: Redeix <59435925+Redeix@users.noreply.github.com>
Signed-off-by: Xikaro <55663835+Xikaro@users.noreply.github.com>
Co-authored-by: Xikaro <os.valerievich@ya.ru>
Co-authored-by: Nebby <78170922+Nebby1999@users.noreply.github.com>
Co-authored-by: Redeix <brayden.j.m.ford@gmail.com>
Co-authored-by: TomPlop <tomdidome@gmail.com>
Co-authored-by: aidie8 <aidenvanzuilen@gmail.com>
Co-authored-by: Xikaro <55663835+Xikaro@users.noreply.github.com>
Co-authored-by: Zleub <debray.arnaud@gmail.com>
Co-authored-by: Adora <adoradyne.58@gmail.com>
Co-authored-by: Curtis Merrill <curtis.r.merrill@gmail.com>
Co-authored-by: julia <97713533+juliakity@users.noreply.github.com>
Co-authored-by: GamerDadDave <gamerdaddave@gmail.com>
Co-authored-by: MetenBouldry <94766011+MetenBouldry@users.noreply.github.com>
Co-authored-by: CaitlynMC <135169224+CaitlynMC@users.noreply.github.com>
Co-authored-by: SverhRazum-Nah <leon.trol@mail.ru>
Co-authored-by: Redeix <59435925+Redeix@users.noreply.github.com>
Co-authored-by: Nebby1999 <nebby131999@gmail.com>
2025-04-18 14:49:56 +05:00

41 lines
No EOL
1.6 KiB
JavaScript

// Handles the quest for drinking water. The drinking water quest checks if the player has this stage.
ItemEvents.firstRightClicked(evt =>
{
const FORGE_CAPS = "ForgeCaps";
const TFC_PLAYERDATA = "tfc:player_data";
const FOOD = "food";
const THIRST = "thirst";
const PREVIOUS_THIRST = "previous_thirst";
const STAGE = "tfg.stages.quests.drank_fresh_water_with_hand";
const {player, level} = evt;
if(evt.target.block == null)
return;
//We reach for the "food" compound tag, that contains the tfc thirst.
let forgecaps = player.nbt.getCompound(FORGE_CAPS);
let tfc_playerdata = forgecaps.getCompound(TFC_PLAYERDATA);
let food = tfc_playerdata.getCompound(FOOD);
let thirstValue = food.getFloat(THIRST);
//Do we already keep track of the previous thirst value? if not, put it and then return.
let customData = getTFGPersistentDataRoot(player);
let containsPreviousThirst = customData.contains(PREVIOUS_THIRST);
if(!containsPreviousThirst)
{
customData.putFloat(PREVIOUS_THIRST, thirstValue);
return;
}
let previousThirstValue = customData.getFloat(PREVIOUS_THIRST);
//As long as our new thirst is greater than our previous, it means we hydrated ourselves. OFC we need to make sure the block clicked was potable.
let blockID = evt.target.block.id;
let isFreshWater = blockID == "minecraft:water" || blockID == "tfc:fluid/river_water";
if(isFreshWater && thirstValue > previousThirstValue && !player.stages.has(STAGE))
{
player.stages.add(STAGE);
}
//Put it back in.
customData.putFloat(PREVIOUS_THIRST, thirstValue);
})