BeaconInventory
com.jsmacrosce.jsmacros.client.api.classes.inventory.BeaconInventory
Handle for an open beacon screen.
selectFirstEffect(String) and selectSecondEffect(String) change the client-side selection; applyEffects() sends the selected pair and closes the screen.
A beacon has four effect tiers: speed and haste; resistance and jump boost; strength; then regeneration. Its level determines which tiers these methods can search.
Effects use registry ids, and either selection can be unset (null).
js
const inv = Player.openInventory();
if (inv instanceof Inventories.Beacon) {
Chat.log(`beacon level ${inv.getLevel()}`);
inv.selectFirstEffect("minecraft:haste");
inv.selectSecondEffect("minecraft:jump_boost");
Chat.log(`primary ${inv.getFirstEffect()}, secondary ${inv.getSecondEffect()}`);
}Available in scripts as Inventories.Beacon.
Methods
applyEffects
Sends the selected effects and closes the container if the payment slot is occupied; otherwise it sends nothing. It does not check the beacon level.
Returns:
true if the effects were sent and the screen closed, false if the payment slot was emptygetFirstEffect
Returns the client's selected primary effect as a registry id; selecting an effect does not send it until applyEffects() is called.
Returns: the selected primary effect's registry id, or
null when none is selectedgetLevel
Returns the beacon level from the menu's synced data; the level governs which effect tiers the selection methods search.
Returns: the synced beacon level
getSecondEffect
Returns the client's selected secondary effect as a registry id; selecting an effect does not send it until applyEffects() is called.
Returns: the selected secondary effect's registry id, or
null when none is selectedselectFirstEffect
Selects a matching primary effect from tiers up to level 2. This changes only the client-side selection; applyEffects() sends it.
Parameters:
id: the registry id of the effect to highlight, such as"minecraft:haste"
Returns:
true if the effect was found and highlighted, false otherwiseselectSecondEffect
Selects a matching secondary effect when the level is at least 3. Below level 3 it returns
false without changing the selection. Matching the current primary sets the secondary to that same effect; otherwise a match sets both selections to it. Changes remain client-side until applyEffects(). At level 4, selecting regeneration while a primary is already set instead replaces the primary, leaves the secondary unchanged, and returns false. A level above 4 can cause an IndexOutOfBoundsException while searching.Parameters:
id: the registry id of the effect to highlight, such as"minecraft:resistance"
Returns:
true if the effect was found and highlighted, false otherwise