Skip to main content
Version: 6.0.x

CraftTweaker

The CraftTweaker side of the scripting bridge. → Scripting Overview covers what a script can and cannot do, and the before/after-6.0.0 table. → Scripting: KubeJS is the JavaScript equivalent, with the same capabilities.

import mods.historystages.HistoryStages;

// Reading
HistoryStages.isUnlocked("bronze");
HistoryStages.isUnlockedFor(player, "tutorial");
HistoryStages.stages();
HistoryStages.unlockedStages();
HistoryStages.categories();

// Changing
HistoryStages.unlock("bronze");
HistoryStages.lock("bronze");
HistoryStages.unlockFor(player, "tutorial");
HistoryStages.lockFor(player, "tutorial");

// Asking whether something is gated — the player is optional, the namespace is too
HistoryStages.isLocked("items", "minecraft:diamond", player);
HistoryStages.isLocked("recipes", "crafttweaker:my_recipe");
HistoryStages.missingStages("historystages:items", "minecraft:diamond", player);

On the player

player.hasStage("bronze");

Asks both scopes, which is what "does this player have this stage" usually means. If you are coming from GameStages, this is the call you already know.

Reacting to stage changes

import mods.historystages.HistoryStages;

HistoryStages.onStageUnlocked(event => {
println("Stage unlocked: " + event.stage + " — " + event.displayName);
});

HistoryStages.onStageLocked(event => { … });

HistoryStages.onIndividualStageUnlocked(event => {
// event.player may be null when that player is offline
println(event.stage + " for " + event.player.name);
});

HistoryStages.onIndividualStageLocked(event => { … });

Listeners are dropped and re-registered on every /reload, so a reloaded script is subscribed once rather than twice.

Something wrong or missing here? Ask on Discord · Open an issue