Skip to content

These docs were made completely by AI, so they might be right, or wrong, you'll need to test them yourself. This was made for a easier understanding of everything. So use at your own risk. If anything is wrong, please don't hurt to make a PR on the page you have a problem with. ON GITHUB

Game Rules

LCE uses a Console Game Rules system that works completely differently from vanilla Minecraft’s simple key-value game rules. Instead of boolean/integer rules like keepInventory or doDaylightCycle, LCE’s game rules are a data-driven, hierarchical system mainly used for custom game modes (like Battle, Tumble, Glide) and DLC mashup packs.

The game rule system has four main layers:

  1. GameRuleManager: loads, saves, and manages rule definitions from DLC packs
  2. GameRuleDefinition: the static definition/template of a rule (what to do)
  3. GameRule: the runtime state of a rule for a specific player or server
  4. GameRulesInstance: extends GameRule as the top-level container for a player’s or server’s complete rule state

The ConsoleGameRules class lives in ConsoleGameRulesConstants.h and holds two enums plus serialization helpers.

All rule types, from eGameRuleType_Invalid (-1) to eGameRuleType_Count:

Enum ValueIntPurpose
eGameRuleType_Invalid-1Sentinel for unset/unknown rules
eGameRuleType_Root0Top-level rule that defines a game mode; used to generate data for new players
eGameRuleType_LevelGenerationOptions1World generation configuration (seed, flat world, schematics, biomes, features)
eGameRuleType_ApplySchematic2Places a schematic structure in the world (from a .schematic file)
eGameRuleType_GenerateStructure3Procedural structure generation (contains child GenerateBox, PlaceBlock, PlaceContainer, PlaceSpawner rules)
eGameRuleType_GenerateBox4Fills a box region with blocks (edge tile, fill tile, optional air skip)
eGameRuleType_PlaceBlock5Places a single block at a position
eGameRuleType_PlaceContainer6Places a container with items (contains child AddItem rules)
eGameRuleType_PlaceSpawner7Places a mob spawner with a specific entity
eGameRuleType_BiomeOverride8Overrides biome for a region (top tile, biome ID)
eGameRuleType_StartFeature9Triggers a world generation feature
eGameRuleType_AddItem10Adds an item to inventory (contains child AddEnchantment rules)
eGameRuleType_AddEnchantment11Adds an enchantment to an item
eGameRuleType_LevelRules12The ruleset container for a level
eGameRuleType_NamedArea13Defines a named AABB area in the world
eGameRuleType_UseTileRule14Triggers when a player uses a specific tile
eGameRuleType_CollectItemRule15Triggers when a player collects a specific item
eGameRuleType_CompleteAllRule16Composite rule that completes when all children are done
eGameRuleType_UpdatePlayerRule17Modifies player state (health, food, inventory, rotation)
eGameRuleType_Count18Total number of rule types

Rules are configured through attributes loaded from XML/binary data. Each attribute is serialized as eGameRuleType_Count + attrIndex so types and attributes share a single integer space:

AttributeUsed By
descriptionName, promptName, dataTagAll rules (display and identification)
itemId, quantity, auxValue, slotAddItem, CollectItem
enchantmentId, enchantmentLevelAddEnchantment
tileId, useCoordsUseTile
nameNamedArea
food, healthUpdatePlayer
seed, flatworldLevelGenerationOptions
filename, rotApplySchematic
data, block, entity, facingStructure actions
edgeTile, fillTile, skipAirGenerateBox
x, y, z, x0, y0, z0, x1, y1, z1Position/region bounds
chunkX, chunkZChunk coordinates
yRotPlayer rotation
spawnX, spawnY, spawnZSpawn position
orientation, dimensionPlacement options
topTileId, biomeIdBiomeOverride
featureStartFeature

The total attribute count is eGameRuleAttr_Count.

The ConsoleGameRules class provides two static write() methods:

  • write(dos, EGameRuleType): writes the type as an int directly
  • write(dos, EGameRuleAttr): writes eGameRuleType_Count + attrIndex so the reader can tell types and attributes apart in the same stream

The base class for all rule templates. This defines the static structure of a rule.

Fields:

FieldTypePurpose
m_ownerTypeEGameRulesInstanceTypeWhether this rule applies to a player or the server
m_descriptionIdwstringLocalization key for the rule description
m_promptIdwstringLocalization key for the prompt text
m_4JDataValueintExtra data value (4J specific)

Key methods:

MethodPurpose
getActionType()Pure virtual. Returns the EGameRuleType for this definition.
addChild(ruleType)Adds a child rule (for compound rules). Returns the new child definition.
addAttribute(name, value)Sets an attribute from parsed data
populateGameRule(type, rule)Initializes a GameRule instance from this definition
getComplete(rule)Checks if the rule is complete for a given player
setComplete(rule, val)Marks the rule complete or incomplete
onUseTile(rule, tileId, x, y, z)Hook called when a player uses a tile (returns false by default)
onCollectItem(rule, item)Hook called when a player collects an item (returns false by default)
postProcessPlayer(player)Applied to a player after rule initialization (empty by default)
getGoal() / getProgress(rule)For trackable rules: total goal and current progress (both return 0 by default)
getIcon() / getAuxValue()Display icon for the rule (-1 and 0 by default)
write(dos)Serializes the definition to a DataOutputStream
writeAttributes(dos, numAttributes)Writes attribute data
getChildren(vector)Fills a vector with child definitions (empty by default)
enumerate()Returns a flat vector of this definition and all descendants
enumerateMap()Returns a map from each definition to its index

Static methods:

MethodPurpose
generateNewGameRulesInstance(type, rules, connection)Walks the definition tree and creates a populated GameRulesInstance
generateDescriptionString(defType, description, data, dataLength)Builds a description string for network packets

Base class for rules that contain child rules. Manages a m_children vector and passes hooks down to all children.

Extends CompoundGameRuleDefinition. Returns eGameRuleType_CompleteAllRule. This one only completes when all child rules are complete. It broadcasts progress updates through UpdateGameRuleProgressPacket.

Returns eGameRuleType_CollectItemRule. Tracks collection of a specific item. Configured with m_itemId, m_auxValue, and m_quantity. Each time the matching item is collected, the progress goes up.

Returns eGameRuleType_UseTileRule. Triggers when a player interacts with a specific tile (block). Can optionally require specific coordinates through m_useCoords.

Returns eGameRuleType_UpdatePlayerRule. Modifies player state when the rule is processed. Can set m_health, m_food, m_yRot (rotation), and spawn position. Contains child AddItemRuleDefinition entries for inventory setup.

Returns eGameRuleType_AddItem. Defines an item to add to a container or player inventory. Configured with m_itemId, m_quantity, m_auxValue, m_dataTag, and m_slot. Can contain child AddEnchantmentRuleDefinition entries.

In the addChild() method, it only accepts eGameRuleType_AddEnchantment as a child type.

Returns eGameRuleType_AddEnchantment. Configured with m_enchantmentId and m_enchantmentLevel.

Returns eGameRuleType_ApplySchematic. Configured with m_filename (schematic file path) and m_rot (rotation). Used by LevelGenerationOptions to stamp structures into the world during generation.

Returns eGameRuleType_GenerateStructure. A compound rule that accepts four child types:

  • eGameRuleType_GenerateBox for filling regions
  • eGameRuleType_PlaceBlock for individual blocks
  • eGameRuleType_PlaceContainer for containers with items
  • eGameRuleType_PlaceSpawner for mob spawners

The processSchematic() method walks children and executes them against a LevelChunk.

Returns eGameRuleType_PlaceContainer. Accepts eGameRuleType_AddItem as children. Places a container block in the world and fills it with the specified items.

Returns eGameRuleType_BiomeOverride. Configured with m_topTileId and m_biomeId.

Returns eGameRuleType_StartFeature. Configured with m_feature (feature name string).

Returns eGameRuleType_LevelGenerationOptions. Accepts four child types:

  • eGameRuleType_ApplySchematic
  • eGameRuleType_GenerateStructure
  • eGameRuleType_BiomeOverride
  • eGameRuleType_StartFeature

Configured with m_seed and m_flatworld attributes.

Extends CompoundGameRuleDefinition as the root container for a level’s rules. Manages NamedAreaRuleDefinition entries (named AABB regions in the world) and holds a StringTable for localized strings.

Each GameRule instance tracks the runtime state of a definition for a specific connection (player).

State storage: Parameters live in m_parameters, an unordered_map<wstring, ValueType> where ValueType is a union of:

  • __int64, int, char, bool, float, double (primitive values)
  • GameRule* (nested rule pointer, flagged with isPointer = true)

Serialization: write() and read() serialize all parameters to/from a DataOutputStream/DataInputStream. Pointer values are serialized recursively, and primitive values are stored as __int64.

Extends GameRule with an instance type:

TypePurpose
eGameRulesInstanceType_ServerPlayerRules applied per-player
eGameRulesInstanceType_ServerRules applied server-wide

Created through GameRuleDefinition::generateNewGameRulesInstance(), which walks the definition tree and populates parameters.

The central manager that loads and manages all game rule definitions. Lives in the client code under Common/GameRules/.

Fields:

FieldTypePurpose
m_currentLevelGenerationOptionsLevelGenerationOptions*Active world gen options
m_currentGameRuleDefinitionsLevelRuleset*Active level rules
m_levelGeneratorsLevelGeneratorsCollection of all level generation options
m_levelRulesLevelRulesCollection of all level rule definitions

Static data:

  • wchTagNameA[]: Maps EGameRuleType values to XML tag names (e.g., index 0 = "" for Root, index 1 = "MapOptions" for LevelGenerationOptions, etc.)
  • wchAttrNameA[]: Maps EGameRuleAttr values to XML attribute names
  • version_number = 2

Key operations:

MethodPurpose
loadGameRules(DLCPack*)Loads rules from a DLC content pack
loadGameRules(data, size)Loads rules from raw binary data. Returns a LevelGenerationOptions*.
loadGameRules(lgo, data, size)Loads rules into an existing LevelGenerationOptions
saveGameRules(data, size)Serializes current rules to binary via writeRuleFile()
loadDefaultGameRules()Loads the built-in default ruleset
processSchematics(levelChunk)Applies schematic rules to a newly generated chunk
processSchematicsLighting(levelChunk)Applies lighting for schematics
unloadCurrentGameRules()Cleans up and unloads the current ruleset
setLevelGenerationOptions(levelGen)Sets the active world generation options
getGameRuleDefinitions()Returns the current LevelRuleset
getLevelGenerationOptions()Returns the current LevelGenerationOptions*
getLevelGenerators()Returns all available level generators
GetGameRulesString(key)Looks up a localized string from the current ruleset’s string table

Rules are stored in .grf files (GAME_RULE_SAVENAME = "requiredGameRules.grf").

Write process (writeRuleFile()):

  1. Write the version number (short)
  2. Write the total number of tag+attribute strings (eGameRuleType_Count + eGameRuleAttr_Count)
  3. Write all type tag names as UTF strings
  4. Write all attribute names as UTF strings
  5. Write the rule tree

Read process (readRuleFile()):

  1. Read the string table (tag names and attribute names)
  2. Build a tagIdMap mapping integer IDs back to EGameRuleType values
  3. Read rule definitions recursively, creating the right subclass based on the type tag
  4. For eGameRuleType_LevelGenerationOptions, creates a LevelGenerationOptions and adds it to the generators
  5. For eGameRuleType_LevelRules, creates a LevelRuleset

The readAttributes() helper reads key-value pairs for a rule definition. The readChildren() helper recursively reads child rules.

A typical DLC mashup pack’s rule file looks like this (conceptually):

Root
LevelGenerationOptions (seed, flatworld)
ApplySchematic (filename, position, rotation)
GenerateStructure
GenerateBox (region bounds, edge/fill tiles)
PlaceBlock (position, block id)
PlaceContainer (position)
AddItem (item id, quantity, slot)
AddEnchantment (enchantment id, level)
PlaceSpawner (position, entity)
BiomeOverride (region, biome id, top tile)
StartFeature (feature name)
LevelRules
NamedArea (name, AABB bounds)
CompleteAll
CollectItem (item id, quantity)
UseTile (tile id, optional coords)
UpdatePlayer (health, food, rotation, spawn)
AddItem (item id, quantity, slot)
AddEnchantment (enchantment id, level)

The Root rule generates data for new players. LevelGenerationOptions controls how the world is built. LevelRules defines in-game objectives and player setup.

Rule progress updates are sent through UpdateGameRuleProgressPacket (packet ID 158). It contains:

FieldTypePurpose
m_definitionTypeEGameRuleTypeWhich rule type changed (defaults to eGameRuleType_LevelRules in the constructor)
m_messageIdwstringDescription string ID
m_iconintItem icon to display
m_auxValueintItem aux value for icon
m_dataTagintExtra data tag
m_databyteArrayAdditional binary data

This is one of the bigger differences between LCEMP and MC. MC adds a vanilla-style GameRules class alongside the existing console game rules system.

MC has GameRules.h / GameRules.cpp with a proper key-value rule system. Each rule is a GameRule inner class that stores a wstring value and can parse it as boolean (getBoolean()), int (getInt()), or double (getDouble()). The set() method takes a new string value and re-parses all typed representations.

The rule constants are static const int (originally strings in Java, converted to ints by 4J):

Rule ConstantPurpose
RULE_DOFIRETICKWhether fire spreads
RULE_MOBGRIEFINGWhether mobs can modify blocks
RULE_KEEPINVENTORYWhether players keep items on death
RULE_DOMOBSPAWNINGWhether mobs spawn naturally
RULE_DOMOBLOOTWhether mobs drop loot
RULE_DOTILEDROPSWhether blocks drop items when broken
RULE_COMMANDBLOCKOUTPUTWhether command blocks show output
RULE_NATURAL_REGENERATIONWhether players regenerate health naturally
RULE_DAYLIGHTWhether the day/night cycle progresses

The GameRules object is stored on the Level and checked directly by gameplay code (like fire spread checking getBoolean(RULE_DOFIRETICK)).

MC also adds a GameRuleCommand for toggling these rules in-game via the /gamerule command.

LCEMP doesn’t have any of this.

The console game rules system (GameRuleManager / GameRuleDefinition / EGameRuleType stuff documented above) still exists in MC. So MC has both systems running at the same time:

  • Vanilla GameRules: Simple boolean toggles on the Level. Checked directly by gameplay code.
  • Console GameRuleManager: Complex data-driven rules for DLC content packs and custom game modes. Runs through the GameRuleManager.

They don’t interfere with each other. The vanilla rules are also exposed through host options in MC (see below).

The ConsoleGameRulesConstants.h file is identical between LCEMP and MC. The same EGameRuleType and EGameRuleAttr enums, the same tag names, the same binary format. The GameRuleManager read/write code is nearly identical too, just with minor C++ modernization (like static_cast instead of C-style casts).

In MC, the vanilla game rules are exposed to players through eGameHostOption entries in the host settings UI rather than chat commands:

Host OptionMaps to Vanilla Rule
eGameHostOption_FireSpreadsRULE_DOFIRETICK
eGameHostOption_MobGriefingRULE_MOBGRIEFING
eGameHostOption_KeepInventoryRULE_KEEPINVENTORY
eGameHostOption_DoMobSpawningRULE_DOMOBSPAWNING
eGameHostOption_DoMobLootRULE_DOMOBLOOT
eGameHostOption_DoTileDropsRULE_DOTILEDROPS
eGameHostOption_NaturalRegenerationRULE_NATURAL_REGENERATION
eGameHostOption_DoDaylightCycleRULE_DAYLIGHT

LCEMP has eGameHostOption_FireSpreads (which predates the vanilla game rule system, it was a console-original feature) but not the other seven.