Skip to content

API reference / @jsprismarine/script-host / host/worldsystem/gameRules

host/worldsystem/gameRules ​

Type Aliases ​

ScriptGameRule ​

ScriptGameRule = { default: boolean; type: "boolean"; } | { default: number; max?: number; type: "integer"; } | { default: ScriptPlayerWaypointsMode; type: "mode"; }

Defined in: script-host/src/host/worldsystem/gameRules.ts:15

One rule: its default, and for a number, the bounds a write is kept within.


ScriptGameRuleName ​

ScriptGameRuleName = keyof typeof SCRIPT_GAME_RULES

Defined in: script-host/src/host/worldsystem/gameRules.ts:68

A rule's Script API name.


ScriptGameRuleValue ​

ScriptGameRuleValue = boolean | number | ScriptPlayerWaypointsMode

Defined in: script-host/src/host/worldsystem/gameRules.ts:12

A game rule's value as a script reads it.


ScriptPlayerWaypointsMode ​

ScriptPlayerWaypointsMode = "Everyone" | "Off"

Defined in: script-host/src/host/worldsystem/gameRules.ts:9

Whether a script's playerWaypoints shows every player on the locator bar.

Variables ​

SCRIPT_GAME_RULES ​

const SCRIPT_GAME_RULES: object

Defined in: script-host/src/host/worldsystem/gameRules.ts:24

Every rule GameRules has, by its Script API name.

Type Declaration ​

commandBlockOutput ​

readonly commandBlockOutput: object = on

commandBlockOutput.default ​

readonly default: true = true

commandBlockOutput.type ​

readonly type: "boolean" = 'boolean'

commandBlocksEnabled ​

readonly commandBlocksEnabled: object = on

commandBlocksEnabled.default ​

readonly default: true = true

commandBlocksEnabled.type ​

readonly type: "boolean" = 'boolean'

doDayLightCycle ​

readonly doDayLightCycle: object = on

doDayLightCycle.default ​

readonly default: true = true

doDayLightCycle.type ​

readonly type: "boolean" = 'boolean'

doEntityDrops ​

readonly doEntityDrops: object = on

doEntityDrops.default ​

readonly default: true = true

doEntityDrops.type ​

readonly type: "boolean" = 'boolean'

doFireTick ​

readonly doFireTick: object = on

doFireTick.default ​

readonly default: true = true

doFireTick.type ​

readonly type: "boolean" = 'boolean'

doImmediateRespawn ​

readonly doImmediateRespawn: object = off

doImmediateRespawn.default ​

readonly default: false = false

doImmediateRespawn.type ​

readonly type: "boolean" = 'boolean'

doInsomnia ​

readonly doInsomnia: object = on

doInsomnia.default ​

readonly default: true = true

doInsomnia.type ​

readonly type: "boolean" = 'boolean'

doLimitedCrafting ​

readonly doLimitedCrafting: object = off

doLimitedCrafting.default ​

readonly default: false = false

doLimitedCrafting.type ​

readonly type: "boolean" = 'boolean'

doMobLoot ​

readonly doMobLoot: object = on

doMobLoot.default ​

readonly default: true = true

doMobLoot.type ​

readonly type: "boolean" = 'boolean'

doMobSpawning ​

readonly doMobSpawning: object = on

doMobSpawning.default ​

readonly default: true = true

doMobSpawning.type ​

readonly type: "boolean" = 'boolean'

doTileDrops ​

readonly doTileDrops: object = on

doTileDrops.default ​

readonly default: true = true

doTileDrops.type ​

readonly type: "boolean" = 'boolean'

doWeatherCycle ​

readonly doWeatherCycle: object = on

doWeatherCycle.default ​

readonly default: true = true

doWeatherCycle.type ​

readonly type: "boolean" = 'boolean'

drowningDamage ​

readonly drowningDamage: object = on

drowningDamage.default ​

readonly default: true = true

drowningDamage.type ​

readonly type: "boolean" = 'boolean'

fallDamage ​

readonly fallDamage: object = on

fallDamage.default ​

readonly default: true = true

fallDamage.type ​

readonly type: "boolean" = 'boolean'

fireDamage ​

readonly fireDamage: object = on

fireDamage.default ​

readonly default: true = true

fireDamage.type ​

readonly type: "boolean" = 'boolean'

freezeDamage ​

readonly freezeDamage: object = on

freezeDamage.default ​

readonly default: true = true

freezeDamage.type ​

readonly type: "boolean" = 'boolean'

functionCommandLimit ​

readonly functionCommandLimit: object

functionCommandLimit.default ​

readonly default: 10000 = 10_000

functionCommandLimit.max ​

readonly max: 10000 = 10_000

functionCommandLimit.type ​

readonly type: "integer" = 'integer'

keepInventory ​

readonly keepInventory: object = off

keepInventory.default ​

readonly default: false = false

keepInventory.type ​

readonly type: "boolean" = 'boolean'

maxCommandChainLength ​

readonly maxCommandChainLength: object

maxCommandChainLength.default ​

readonly default: 65535 = 65_535

maxCommandChainLength.type ​

readonly type: "integer" = 'integer'

mobGriefing ​

readonly mobGriefing: object = on

mobGriefing.default ​

readonly default: true = true

mobGriefing.type ​

readonly type: "boolean" = 'boolean'

naturalRegeneration ​

readonly naturalRegeneration: object = on

naturalRegeneration.default ​

readonly default: true = true

naturalRegeneration.type ​

readonly type: "boolean" = 'boolean'

playersSleepingPercentage ​

readonly playersSleepingPercentage: object

playersSleepingPercentage.default ​

readonly default: 100 = 100

playersSleepingPercentage.type ​

readonly type: "integer" = 'integer'

playerWaypoints ​

readonly playerWaypoints: object

playerWaypoints.default ​

readonly default: "Everyone" = 'Everyone'

playerWaypoints.type ​

readonly type: "mode" = 'mode'

projectilesCanBreakBlocks ​

readonly projectilesCanBreakBlocks: object = on

projectilesCanBreakBlocks.default ​

readonly default: true = true

projectilesCanBreakBlocks.type ​

readonly type: "boolean" = 'boolean'

pvp ​

readonly pvp: object = on

pvp.default ​

readonly default: true = true

pvp.type ​

readonly type: "boolean" = 'boolean'

randomTickSpeed ​

readonly randomTickSpeed: object

randomTickSpeed.default ​

readonly default: 1 = 1

randomTickSpeed.type ​

readonly type: "integer" = 'integer'

recipesUnlock ​

readonly recipesUnlock: object = on

recipesUnlock.default ​

readonly default: true = true

recipesUnlock.type ​

readonly type: "boolean" = 'boolean'

respawnBlocksExplode ​

readonly respawnBlocksExplode: object = on

respawnBlocksExplode.default ​

readonly default: true = true

respawnBlocksExplode.type ​

readonly type: "boolean" = 'boolean'

sendCommandFeedback ​

readonly sendCommandFeedback: object = on

sendCommandFeedback.default ​

readonly default: true = true

sendCommandFeedback.type ​

readonly type: "boolean" = 'boolean'

showBorderEffect ​

readonly showBorderEffect: object = on

showBorderEffect.default ​

readonly default: true = true

showBorderEffect.type ​

readonly type: "boolean" = 'boolean'

showCoordinates ​

readonly showCoordinates: object = off

showCoordinates.default ​

readonly default: false = false

showCoordinates.type ​

readonly type: "boolean" = 'boolean'

showDaysPlayed ​

readonly showDaysPlayed: object = off

showDaysPlayed.default ​

readonly default: false = false

showDaysPlayed.type ​

readonly type: "boolean" = 'boolean'

showDeathMessages ​

readonly showDeathMessages: object = on

showDeathMessages.default ​

readonly default: true = true

showDeathMessages.type ​

readonly type: "boolean" = 'boolean'

showRecipeMessages ​

readonly showRecipeMessages: object = on

showRecipeMessages.default ​

readonly default: true = true

showRecipeMessages.type ​

readonly type: "boolean" = 'boolean'

showTags ​

readonly showTags: object = on

showTags.default ​

readonly default: true = true

showTags.type ​

readonly type: "boolean" = 'boolean'

spawnRadius ​

readonly spawnRadius: object

spawnRadius.default ​

readonly default: 0 = 0

spawnRadius.type ​

readonly type: "integer" = 'integer'

tntExplodes ​

readonly tntExplodes: object = on

tntExplodes.default ​

readonly default: true = true

tntExplodes.type ​

readonly type: "boolean" = 'boolean'

tntExplosionDropDecay ​

readonly tntExplosionDropDecay: object = on

tntExplosionDropDecay.default ​

readonly default: true = true

tntExplosionDropDecay.type ​

readonly type: "boolean" = 'boolean'

Functions ​

gameRuleWrite() ​

gameRuleWrite(name, value): ScriptGameRuleValue | undefined

Defined in: script-host/src/host/worldsystem/gameRules.ts:78

The value a write leaves a rule at, or undefined for one BDS ignores: a negative number, as randomTickSpeed = -1 was, keeps the value the rule had. A number drops its fraction and is kept within the rule's maximum.

Parameters ​

name ​

"commandBlockOutput" | "commandBlocksEnabled" | "doDayLightCycle" | "doEntityDrops" | "doFireTick" | "doImmediateRespawn" | "doInsomnia" | "doLimitedCrafting" | "doMobLoot" | "doMobSpawning" | "doTileDrops" | "doWeatherCycle" | "drowningDamage" | "fallDamage" | "fireDamage" | "freezeDamage" | "functionCommandLimit" | "keepInventory" | "maxCommandChainLength" | "mobGriefing" | "naturalRegeneration" | "playerWaypoints" | "playersSleepingPercentage" | "projectilesCanBreakBlocks" | "pvp" | "randomTickSpeed" | "recipesUnlock" | "respawnBlocksExplode" | "sendCommandFeedback" | "showBorderEffect" | "showCoordinates" | "showDaysPlayed" | "showDeathMessages" | "showRecipeMessages" | "showTags" | "spawnRadius" | "tntExplodes" | "tntExplosionDropDecay"

value ​

ScriptGameRuleValue

Returns ​

ScriptGameRuleValue | undefined


isScriptGameRule() ​

isScriptGameRule(name): name is "commandBlockOutput" | "commandBlocksEnabled" | "doDayLightCycle" | "doEntityDrops" | "doFireTick" | "doImmediateRespawn" | "doInsomnia" | "doLimitedCrafting" | "doMobLoot" | "doMobSpawning" | "doTileDrops" | "doWeatherCycle" | "drowningDamage" | "fallDamage" | "fireDamage" | "freezeDamage" | "functionCommandLimit" | "keepInventory" | "maxCommandChainLength" | "mobGriefing" | "naturalRegeneration" | "playerWaypoints" | "playersSleepingPercentage" | "projectilesCanBreakBlocks" | "pvp" | "randomTickSpeed" | "recipesUnlock" | "respawnBlocksExplode" | "sendCommandFeedback" | "showBorderEffect" | "showCoordinates" | "showDaysPlayed" | "showDeathMessages" | "showRecipeMessages" | "showTags" | "spawnRadius" | "tntExplodes" | "tntExplosionDropDecay"

Defined in: script-host/src/host/worldsystem/gameRules.ts:71

Whether a name is one of SCRIPT_GAME_RULES.

Parameters ​

name ​

string

Returns ​

name is "commandBlockOutput" | "commandBlocksEnabled" | "doDayLightCycle" | "doEntityDrops" | "doFireTick" | "doImmediateRespawn" | "doInsomnia" | "doLimitedCrafting" | "doMobLoot" | "doMobSpawning" | "doTileDrops" | "doWeatherCycle" | "drowningDamage" | "fallDamage" | "fireDamage" | "freezeDamage" | "functionCommandLimit" | "keepInventory" | "maxCommandChainLength" | "mobGriefing" | "naturalRegeneration" | "playerWaypoints" | "playersSleepingPercentage" | "projectilesCanBreakBlocks" | "pvp" | "randomTickSpeed" | "recipesUnlock" | "respawnBlocksExplode" | "sendCommandFeedback" | "showBorderEffect" | "showCoordinates" | "showDaysPlayed" | "showDeathMessages" | "showRecipeMessages" | "showTags" | "spawnRadius" | "tntExplodes" | "tntExplosionDropDecay"