Add Some API Calls

This commit is contained in:
TheBrokenRail 2025-03-03 14:37:36 -05:00
parent fade578125
commit 1f12d55e22
2 changed files with 14 additions and 0 deletions

View File

@ -163,6 +163,12 @@ By default, MCPI-Reborn runs in a "compatibility mode." This makes it completely
* `world.getSign(x,y,z)`
* Description: Retrieve the text of the given sign.
* Output: List of `{line}`
* `world.getSeed()`
* Description: Retrieve the seed of the loaded world.
* Output: `seed`
* `world.getGameMode()`
* Description: Retrieve the game-mode of the loaded world.
* Output: `game_mode`
* `entity.getType(entity_id)`
* Description: Check the type of the given entity. For special entities like players, this will be `0`.
* Output: `entity_type_id`

View File

@ -511,10 +511,18 @@ sign->lines[i] = api_get_input(line_##i); \
return CommandServer::Fail;
}
return api_join_outputs({std::to_string(entity->x), std::to_string(entity->y - entity->height_offset), std::to_string(entity->z)}, arg_separator);
} else if (cmd == "world.getSeed") {
// Get Seed
return std::to_string(server->minecraft->level->data.seed) + '\n';
} else if (cmd == "world.getGameMode") {
// Get Game Mode
return std::to_string(server->minecraft->isCreativeMode()) + '\n';
} else if (cmd == "reborn.disableCompatMode") {
// Disable Compatibility Mode
api_compat_mode = false;
return std::string(reborn_get_version()) + '\n';
} else if (cmd == "reborn.enableCompatMode") {
// Re-Enable Compatibility Mode
api_compat_mode = true;
return CommandServer::NullString;
} else {