All checks were successful
Build & Release Pack / build (push) Successful in 1m46s
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.
31 lines
1.1 KiB
JavaScript
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()
|
|
})
|