cleanGameRules
Configures the game rules and environment settings for a World to align with a controlled or static gameplay setup.
This method adjusts several game rules to disable features such as day-night cycling, fire spread, mob behavior, and weather changes. It also enables KEEP_INVENTORY, sets the time to 0, enforces peaceful difficulty, and clears weather effects to create a more predictable or controlled world state.
The following properties are managed:
Game rules such as mob spawning, fire spread, daylight cycle, and more are turned off.
Inventory preservation is enabled (
KEEP_INVENTORYset totrue).The world's time is reset to 0, ensuring consistent lighting.
Difficulty is set to
PEACEFUL, preventing hostile mobs from spawning naturally.Weather effects are disabled by clearing weather duration.
Cleans and configures game rules for a specified world to ensure a controlled gameplay setup.
This method ensures the specified world aligns with predefined game rules and environment settings by invoking cleanGameRules on the world. If the world does not exist, an exception is thrown.
Parameters
The name of the world whose game rules are being cleaned and configured. If the world doesn't exist, a runtime exception is thrown.