Repository navigation
FTB Quests Integration
OnTime can read quest and reward state from FTB Quests. The integration is optional — when FTB Quests is not installed, all FTB-related features become no-ops and never throw.
There is no compileOnly build dependency. The entire integration is reflective, looked up at runtime via dev.ftb.mods.ftbquests.api.FTBQuestsAPI.
OnTime exposes FTB Quests state in two places:
- Triggers (event-driven, polled once per second). See Triggers#ftb-quests-events.
- Time-value expressions (used to compute durations from quest state). See Expressions#variables--functions.
Both are gated on the same detection logic: if the mod is not present, triggers never fire and expression functions return 0.
On first call, FTBQuestsIntegration.isInstalled() runs Class.forName("dev.ftb.mods.ftbquests.api.FTBQuestsAPI"). The result is cached in a volatile Boolean.
When detection succeeds, the next call to tryInit() resolves the following methods reflectively:
| Class | Method |
|---|---|
FTBQuestsAPI |
api() (static) → API instance |
| API instance |
getQuestFile(boolean) → BaseQuestFile
|
BaseQuestFile |
get(long) → QuestObject
|
BaseQuestFile |
getReward(long) → Reward
|
BaseQuestFile |
getNullableTeamData(UUID) → TeamData
|
TeamData |
isCompleted(QuestObject) → boolean |
TeamData |
isRewardClaimed(UUID, Reward) → boolean |
tryInit() is idempotent — it bails out fast once the methods are resolved. If init fails (e.g., FTB Quests is in the middle of loading), it stays in a "deferred" state and retries on the next call.
FTB Quests identifies every quest and reward by a hex-encoded long (1–16 hex chars, no 0x prefix).
- In-game tooltip. Hover over a quest in the editor, the ID appears at the bottom of the tooltip.
-
config/ftbquests/quests/files. Each.snbtfile has anid:line containing the hex. -
/ftbquestscommands. The mod provides admin commands to dump IDs (depends on FTB Quests version).
OnTime parses hex IDs with Long.parseUnsignedLong(hex, 16). Invalid input returns false (for triggers/conditions) or 0 (for expressions) — no error is shown to the user. Make sure the ID is correct before relying on it.
When you set an FTB trigger:
/timer trigger first_quest ftb_quest 1A2B3C start
OnTime polls every player on the server once per second:
for each player:
if isCompleted(quest, player.team):
fire trigger
mark this (timer, trigger) as already fired
break
The "already fired" record is per-timer, not per-player. A quest only triggers a timer once per server session — if the player completed the quest before the server restart, OnTime fires on the first poll after the restart, then suppresses further fires for that timer until you change or clear the trigger.
This avoids the edge case where a start trigger keeps starting the same timer in a loop, since the quest's "completed" state is sticky.
The time-value evaluator (used by /timer expr ...) exposes:
| Function | Returns |
|---|---|
ftb_quest_completed(<hex_id>) |
1 if any online player has completed the quest, else 0
|
ftb_reward_claimed(<hex_id>) |
1 if any online player has claimed the reward, else 0
|
These are scanned at command execution time only — the result is baked into the timer's duration when the command runs. Subsequent changes in quest state don't affect a timer that's already created.
The condition DSL (used by
/timer condition ... if) does not include FTB functions — for that use case, set up an FTB trigger instead. Triggers are event-driven (fire as soon as the quest is completed), conditions are polled (lag of up to one tick).
/timer create warmup 0 5 0
/timer trigger warmup ftb_quest 1A2B3C start
This needs scripting on top — there's no built-in "count claimed rewards" function. The two ftb_* functions in expressions are boolean (0 or 1) per ID. For aggregate counts, drive the timer's duration via a scoreboard or your own mod's logic.
/timer create boss_attempt 0 30 0 false say Boss attempt timed out!
/timer trigger boss_attempt ftb_quest DEADBEEF finish
On successful detection:
[OnTime/FTBQuests] FTB Quests detected
[OnTime/FTBQuests] Reflection initialized successfully
If reflection fails (rare, only if FTB Quests changes its API surface):
[OnTime/FTBQuests] Init deferred: <reason>
OnTime will retry on the next tryInit() call. The mod never crashes because of FTB Quests — every reflective call is guarded.
- The integration relies on FTB Quests'
apipackage, which is the stable surface. It does not break with most FTB Quests updates. - Every poll iterates all online players. With very large player counts (hundreds), the polling cost adds up — keep the number of FTB-triggered timers reasonable.
-
getNullableTeamData(UUID)returns the team for a player. Solo-mode worlds are handled the same way. - The "already fired" cache is in-memory only; it does not persist across server restarts.