SciCraft/client_pack/kubejs/server_scripts/05_protocol_tome.js
MiTHRAL ae0ede6c28
All checks were successful
Build & Release Pack / build (push) Successful in 1m46s
SCICRAFT — The Dark Photon Protocol v1.0.0
NeoForge 1.21.1 (21.1.248) packwiz pack: client + server packs, story
system (KubeJS/FTB Quests), patched World Portal & Create Ore Excavation,
performance presets, and ops tooling. Clean-history import for v1.0.0.
2026-08-24 14:27:31 -04:00

31 lines
1.1 KiB
JavaScript

// SCICRAFT — The Dark Photon Protocol
// Protocol Tome: starter item that makes the FTB Quests guidance unmissable.
// - Given to each player once on first login.
// - Right-clicking it opens the FTB Quests book on the client.
const TOME_SC = {
item: 'scicraft:protocol_tome',
channel: 'scicraft:open_quests',
give_flag: 'scicraft_got_tome'
}
// Give the Tome once per player on first login.
PlayerEvents.loggedIn(event => {
const player = event.player
if (player.persistentData.contains(TOME_SC.give_flag)) return
player.persistentData.putBoolean(TOME_SC.give_flag, true)
// Give on the next tick so the player is fully in-world first.
event.server.scheduleInTicks(10, () => {
if (!player.isOnline()) return
player.give(Item.of(TOME_SC.item))
player.tell(Text.translate('scicraft.phrases.tome_given'))
})
})
// Right-clicking the Tome asks the client to open the FTB Quests book.
ItemEvents.rightClicked(event => {
if (event.item.id !== TOME_SC.item) return
if (event.player.crouching) return
event.player.sendData(TOME_SC.channel, {})
event.cancel()
})