Skip to content

GameRules 5.47.0 ​

final class · pocketmine\world\GameRules · source

The game rules a world supports (Bedrock names and defaults), see World::getGameRule() and /gamerule. Each world saves its rules in its level.dat (Bedrock worlds), like the vanilla game.

The rules only set the default outcome: events (PlayerDeathEvent, EntityDamageEvent, BlockBreakEvent, EntityExplodeEvent...) are still called, so plugins can change the result.

Constants ​

COMMAND_BLOCKS_ENABLED ​

php
public const COMMAND_BLOCKS_ENABLED = "commandblocksenabled"

COMMAND_BLOCK_OUTPUT ​

php
public const COMMAND_BLOCK_OUTPUT = "commandblockoutput"

DO_DAYLIGHT_CYCLE ​

php
public const DO_DAYLIGHT_CYCLE = "dodaylightcycle"

DO_ENTITY_DROPS ​

php
public const DO_ENTITY_DROPS = "doentitydrops"

DO_FIRE_TICK ​

php
public const DO_FIRE_TICK = "dofiretick"

DO_IMMEDIATE_RESPAWN ​

php
public const DO_IMMEDIATE_RESPAWN = "doimmediaterespawn"

DO_INSOMNIA ​

php
public const DO_INSOMNIA = "doinsomnia"

DO_LIMITED_CRAFTING ​

php
public const DO_LIMITED_CRAFTING = "dolimitedcrafting"

DO_MOB_LOOT ​

php
public const DO_MOB_LOOT = "domobloot"

DO_MOB_SPAWNING ​

php
public const DO_MOB_SPAWNING = "domobspawning"

DO_PATROL_SPAWNING ​

php
public const DO_PATROL_SPAWNING = "dopatrolspawning"

DO_TILE_DROPS ​

php
public const DO_TILE_DROPS = "dotiledrops"

DO_TRADER_SPAWNING ​

php
public const DO_TRADER_SPAWNING = "dotraderspawning"

DO_WEATHER_CYCLE ​

php
public const DO_WEATHER_CYCLE = "doweathercycle"

DROWNING_DAMAGE ​

php
public const DROWNING_DAMAGE = "drowningdamage"

FALL_DAMAGE ​

php
public const FALL_DAMAGE = "falldamage"

FIRE_DAMAGE ​

php
public const FIRE_DAMAGE = "firedamage"

FREEZE_DAMAGE ​

php
public const FREEZE_DAMAGE = "freezedamage"

FUNCTION_COMMAND_LIMIT ​

php
public const FUNCTION_COMMAND_LIMIT = "functioncommandlimit"

KEEP_INVENTORY ​

php
public const KEEP_INVENTORY = "keepinventory"

LOCATOR_BAR ​

php
public const LOCATOR_BAR = "locatorbar"

MAX_COMMAND_CHAIN_LENGTH ​

php
public const MAX_COMMAND_CHAIN_LENGTH = "maxcommandchainlength"

MOB_GRIEFING ​

php
public const MOB_GRIEFING = "mobgriefing"

NATURAL_REGENERATION ​

php
public const NATURAL_REGENERATION = "naturalregeneration"

PLAYERS_SLEEPING_PERCENTAGE ​

php
public const PLAYERS_SLEEPING_PERCENTAGE = "playerssleepingpercentage"

PROJECTILES_CAN_BREAK_BLOCKS ​

php
public const PROJECTILES_CAN_BREAK_BLOCKS = "projectilescanbreakblocks"

PVP ​

php
public const PVP = "pvp"

RANDOM_TICK_SPEED ​

php
public const RANDOM_TICK_SPEED = "randomtickspeed"

RECIPES_UNLOCK ​

php
public const RECIPES_UNLOCK = "recipesunlock"

RESPAWN_BLOCKS_EXPLODE ​

php
public const RESPAWN_BLOCKS_EXPLODE = "respawnblocksexplode"

SEND_COMMAND_FEEDBACK ​

php
public const SEND_COMMAND_FEEDBACK = "sendcommandfeedback"

SHOW_BORDER_EFFECT ​

php
public const SHOW_BORDER_EFFECT = "showbordereffect"

SHOW_COORDINATES ​

php
public const SHOW_COORDINATES = "showcoordinates"

SHOW_DAYS_PLAYED ​

php
public const SHOW_DAYS_PLAYED = "showdaysplayed"

SHOW_DEATH_MESSAGES ​

php
public const SHOW_DEATH_MESSAGES = "showdeathmessages"

SHOW_RECIPE_MESSAGES ​

php
public const SHOW_RECIPE_MESSAGES = "showrecipemessages"

SHOW_TAGS ​

php
public const SHOW_TAGS = "showtags"

SPAWN_RADIUS ​

php
public const SPAWN_RADIUS = "spawnradius"

TNT_EXPLODES ​

php
public const TNT_EXPLODES = "tntexplodes"

TNT_EXPLOSION_DROP_DECAY ​

php
public const TNT_EXPLOSION_DROP_DECAY = "tntexplosiondropdecay"

Methods ​

allowsEntityDrops() ​

php
public static function allowsEntityDrops(\pocketmine\world\World $world) : bool

Whether non-living entities (boats, minecarts, armor stands, paintings, leash knots) drop their item when they are broken (doentitydrops).

allowsExplosionGriefing() ​

php
public static function allowsExplosionGriefing(\pocketmine\world\World $world, object $cause) : bool

Whether an explosion caused by this entity may destroy blocks (mobgriefing; TNT and TNT minecarts are not mobs: vanilla tnt_minecart.json has no destroy_affected_by_griefing).

allowsMobGriefing() ​

php
public static function allowsMobGriefing(\pocketmine\world\World $world) : bool

Whether mobs may change blocks (sheep eating grass, villagers farming, ravagers breaking leaves, snow golem trails...) and pick up items (mobgriefing).

allowsPlayerDamage() ​

php
public static function allowsPlayerDamage(\pocketmine\world\World $world, \pocketmine\event\entity\EntityDamageEvent $source) : bool

Whether the world's rules let this damage happen to a player (falldamage, firedamage, drowningdamage, freezedamage, pvp). Only players are protected, like in vanilla.

allowsProjectileBlockBreaking() ​

php
public static function allowsProjectileBlockBreaking(\pocketmine\world\World $world) : bool

Whether projectiles may break the blocks they hit (decorated pots, chorus flowers, pointed dripstone...) (projectilescanbreakblocks).

allowsRespawnBlockExplosions() ​

php
public static function allowsRespawnBlockExplosions(\pocketmine\world\World $world) : bool

Whether beds used outside the Overworld and respawn anchors used outside the Nether explode (respawnblocksexplode). When they don't, using them just fails.

getDefault() ​

php
public static function getDefault(string $name) : bool|int

getNames() ​

php
public static function getNames() : array

isBool() ​

php
public static function isBool(string $name) : bool

isSentToClients() ​

php
public static function isSentToClients(string $name) : bool

normalizeName() ​

php
public static function normalizeName(string $name) : ?string

Returns the rule's name in lowercase if the rule exists (names are case-insensitive), null otherwise.

validate() ​

php
public static function validate(string $name, mixed $value) : bool|int|null

Returns the value if it has the rule's type, null otherwise (e.g. a corrupted level.dat entry).

VanillaMine is a fork of PocketMine-MP. Not affiliated with the PMMP team or Mojang.