GameMode enum (Adventure, Creative) and a GameModeType asset system that defines permissions and interactions for each mode. If your mod changes behavior based on the current game mode - disabling PvP in Creative, unlocking build tools, restricting commands - you need to verify that mode detection and mode switching work correctly.
The ChangeGameModeEvent fires when a player’s mode changes. Mods that react to mode switches (enabling fly in Creative, locking inventory in Adventure) should capture this event and verify the new mode value.
Complete Example Suite
GameMode Enum
| Value | Description |
|---|---|
GameMode.Adventure | Standard gameplay with survival mechanics |
GameMode.Creative | Unrestricted building and flying |
GameModeType Asset
GameModeType is the content asset tied to each GameMode. It defines what the mode allows:
| Method | Returns | Description |
|---|---|---|
fromGameMode(GameMode) | GameModeType | Resolve the asset for a mode |
getPermissionGroups() | String[] | Permission groups active in this mode |
getInteractionsOnEnter() | String | Interactions triggered when entering the mode |
ChangeGameModeEvent
Fires when a player’s game mode changes. Key methods:| Method | Returns | Description |
|---|---|---|
getGameMode() | GameMode | The new game mode being switched to |
setGameMode(GameMode) | void | Override the target mode |
setCancelled(boolean) | void | Cancel the mode switch |
isCancelled() | boolean | Check if the switch was cancelled |
When to Test Game Modes
- Mode-gated features - your mod enables/disables systems per mode
- Permission checks - Creative players get different permissions than Adventure
- Event listeners - your mod reacts to ChangeGameModeEvent
- UI changes - different HUD elements per mode
Isolation Recommendation
Game mode tests are read-only enum and asset lookups.IsolationStrategy.NONE is sufficient unless you are modifying player state:
Next Steps
- Players - mock player creation and game mode assignment
- Events - event capture and cancellation patterns
- Permissions - permission checks per game mode