API reference / @jsprismarine/prismarine / world/GameRuleManager
world/GameRuleManager
Classes
Type Aliases
GameRuleChangeListener
GameRuleChangeListener = (
name,value,editable) =>void
Defined in: packages/prismarine/src/world/GameRuleManager.ts:66
Called after GameRuleManager.setGameRule stores a change, with the name spelled as the wire wants it. Not called for the defaults a manager starts with.
Parameters
name
string
value
boolean | number
editable
boolean
Returns
void
GameRuleEntry
GameRuleEntry = [
value:boolean|number,editable:boolean]
Defined in: packages/prismarine/src/world/GameRuleManager.ts:60
What a rule holds: its value, and whether a player may change it from the settings screen.
Variables
GameRules
constGameRules:object
Defined in: packages/prismarine/src/world/GameRuleManager.ts:19
The rules every world registers, spelled the way the client spells them.
The client matches a rule by exact string, so these are the camelCase names protocol 2193's pinned Bedrock Dedicated Server sends in StartGamePacket (doDayLightCycle with a capital L, pvp all lowercase). They used to be all lowercase, and a client given showcoordinates had no rule by that name to turn on.
Lookups through GameRuleManager ignore case, so DoDayLightCycle, dodaylightcycle and the constant here all name the same rule.
Type Declaration
CommandBlockOutput
readonlyCommandBlockOutput:"commandBlockOutput"='commandBlockOutput'
CommandBlocksEnabled
readonlyCommandBlocksEnabled:"commandBlocksEnabled"='commandBlocksEnabled'
DoDayLightCycle
readonlyDoDayLightCycle:"doDayLightCycle"='doDayLightCycle'
DoEntityDrops
readonlyDoEntityDrops:"doEntityDrops"='doEntityDrops'
DoFireTick
readonlyDoFireTick:"doFireTick"='doFireTick'
DoImmediateRespawn
readonlyDoImmediateRespawn:"doImmediateRespawn"='doImmediateRespawn'
DoInsomnia
readonlyDoInsomnia:"doInsomnia"='doInsomnia'
DoLimitedCrafting
readonlyDoLimitedCrafting:"doLimitedCrafting"='doLimitedCrafting'
DoMobLoot
readonlyDoMobLoot:"doMobLoot"='doMobLoot'
DoMobSpawning
readonlyDoMobSpawning:"doMobSpawning"='doMobSpawning'
DoTileDrops
readonlyDoTileDrops:"doTileDrops"='doTileDrops'
DoWeatherCycle
readonlyDoWeatherCycle:"doWeatherCycle"='doWeatherCycle'
DrowningDamage
readonlyDrowningDamage:"drowningDamage"='drowningDamage'
FallDamage
readonlyFallDamage:"fallDamage"='fallDamage'
FireDamage
readonlyFireDamage:"fireDamage"='fireDamage'
FreezeDamage
readonlyFreezeDamage:"freezeDamage"='freezeDamage'
FunctionCommandLimit
readonlyFunctionCommandLimit:"functionCommandLimit"='functionCommandLimit'
KeepInventory
readonlyKeepInventory:"keepInventory"='keepInventory'
MaxCommandChainLength
readonlyMaxCommandChainLength:"maxCommandChainLength"='maxCommandChainLength'
MobGriefing
readonlyMobGriefing:"mobGriefing"='mobGriefing'
NaturalRegeneration
readonlyNaturalRegeneration:"naturalRegeneration"='naturalRegeneration'
PlayersSleepingPercentage
readonlyPlayersSleepingPercentage:"playersSleepingPercentage"='playersSleepingPercentage'
ProjectilesCanBreakBlocks
readonlyProjectilesCanBreakBlocks:"projectilesCanBreakBlocks"='projectilesCanBreakBlocks'
PVP
readonlyPVP:"pvp"='pvp'
RandomTickSpeed
readonlyRandomTickSpeed:"randomTickSpeed"='randomTickSpeed'
RecipesUnlock
readonlyRecipesUnlock:"recipesUnlock"='recipesUnlock'
RespawnBlocksExplode
readonlyRespawnBlocksExplode:"respawnBlocksExplode"='respawnBlocksExplode'
sendCommandFeedback
readonlysendCommandFeedback:"sendCommandFeedback"='sendCommandFeedback'
ShowBorderEffect
readonlyShowBorderEffect:"showBorderEffect"='showBorderEffect'
ShowCoordinates
readonlyShowCoordinates:"showCoordinates"='showCoordinates'
ShowDaysPlayed
readonlyShowDaysPlayed:"showDaysPlayed"='showDaysPlayed'
ShowDeathMessages
readonlyShowDeathMessages:"showDeathMessages"='showDeathMessages'
ShowRecipeMessages
readonlyShowRecipeMessages:"showRecipeMessages"='showRecipeMessages'
ShowTags
readonlyShowTags:"showTags"='showTags'
SpawnRadius
readonlySpawnRadius:"spawnRadius"='spawnRadius'
TNTExplodes
readonlyTNTExplodes:"tntExplodes"='tntExplodes'
TNTExplosionDropDecay
readonlyTNTExplosionDropDecay:"tntExplosionDropDecay"='tntExplosionDropDecay'
Functions
defaultGameRule()
defaultGameRule(
name):number|boolean|undefined
Defined in: packages/prismarine/src/world/GameRuleManager.ts:138
The value every world starts a rule at, found by any spelling of its name.
Parameters
name
string
Returns
number | boolean | undefined
The default, or undefined for a rule no world registers.
isJavaOnlyGameRule()
isJavaOnlyGameRule(
name):boolean
Defined in: packages/prismarine/src/world/GameRuleManager.ts:131
Whether a rule is one a Bedrock client has no counterpart for.
Parameters
name
string
The rule's name as the manager stores it, in any casing.
Returns
boolean
toNetworkGameRule()
toNetworkGameRule(
name,value,editable):GameRuleFields
Defined in: packages/prismarine/src/world/GameRuleManager.ts:153
Shapes one stored rule as the protocol's GameRule.
A boolean travels as the boolean alternative, a whole number as a signed int32 and anything else as a float. The integer used to go out through writeUnsignedIntLE, which threw on a negative value; the docs type it int32.
Parameters
name
string
The rule's name, spelled as the wire wants it.
value
number | boolean
The rule's value.
editable
boolean
Whether a player may change it from the settings screen.