diff --git a/README.md b/README.md index 4f9b11a..a144b6b 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ running the [ELCI](https://github.com/rozukke/ELCI) plugin and using C++. It was This library is based on [mcpi](https://github.com/martinohanlon/mcpi), which is a Python library with similar functionality. In addition to C++ support, this library implements several new commands supported by [ELCI](https://github.com/rozukke/ELCI): -- `getBlocks` to get a cuboid of blocks with modifiers in a performant manner, -- `getHeights` to get a 2D area of heights in a performant manner, -- `doCommand` to perform an in-game minecraft command which allows for additional functionality. +- `get_blocks` to get a cuboid of blocks with modifiers in a performant manner, +- `get_heights` to get a 2D area of heights in a performant manner, +- `do_command` to perform an in-game minecraft command which allows for additional functionality. This C++ version was created for the Royal Melbourne Institute of Technology (RMIT) to supplement the **COSC2084** (Programming Studio 2) course. diff --git a/example/game-of-life/game_of_life.cpp b/example/game-of-life/game_of_life.cpp index f66793a..39f542e 100644 --- a/example/game-of-life/game_of_life.cpp +++ b/example/game-of-life/game_of_life.cpp @@ -56,7 +56,7 @@ int main(int argc, char* argv[]) { } Life::Life(int width, int depth) : width(width), depth(depth), isRunning(false), delay(250) { - buildPosition = mc.getPlayerPosition(); + buildPosition = mc.get_player_position(); buildPosition.y -= 5; buildPosition.x -= width / 2; buildPosition.z -= depth / 2; @@ -75,15 +75,15 @@ Life::Life(int width, int depth) : width(width), depth(depth), isRunning(false), } } - mc.doCommand("clear @p"); - mc.doCommand("give @p minecraft:white_concrete"); - mc.doCommand("give @p minecraft:black_concrete"); - mc.doCommand("give @p minecraft:green_concrete"); - mc.doCommand("give @p minecraft:red_concrete"); - mc.doCommand("give @p minecraft:yellow_concrete"); - mc.doCommand("give @p minecraft:blue_concrete"); - mc.doCommand("give @p minecraft:pink_concrete"); - mc.doCommand("give @p minecraft:barrier"); + mc.do_command("clear @p"); + mc.do_command("give @p minecraft:white_concrete"); + mc.do_command("give @p minecraft:black_concrete"); + mc.do_command("give @p minecraft:green_concrete"); + mc.do_command("give @p minecraft:red_concrete"); + mc.do_command("give @p minecraft:yellow_concrete"); + mc.do_command("give @p minecraft:blue_concrete"); + mc.do_command("give @p minecraft:pink_concrete"); + mc.do_command("give @p minecraft:barrier"); } Life::~Life() { @@ -95,7 +95,7 @@ Life::~Life() { void Life::Update() { // check for actions - mcpp::Chunk chunk = mc.getBlocks(upperBuildPosition, upperBounds); + mcpp::Chunk chunk = mc.get_blocks(upperBuildPosition, upperBounds); for (int x = 0; x < width; x++) { for (int z = 0; z < depth; z++) { mcpp::BlockType block = chunk.get(x, 0, z); @@ -103,39 +103,39 @@ void Life::Update() { mcpp::Coordinate position(upperBuildPosition.x + x, upperBuildPosition.y, upperBuildPosition.z + z); if (block != mcpp::Blocks::AIR) { - mc.setBlock(position, mcpp::Blocks::AIR); + mc.set_block(position, mcpp::Blocks::AIR); } if (block == PLAY_BLOCK) { Play(); - mc.postToChat("Playing"); + mc.post_to_chat("Playing"); } else if (block == PAUSE_BLOCK) { Pause(); - mc.postToChat("Pausing"); + mc.post_to_chat("Pausing"); } else if (block == ALIVE_BLOCK) { game[x][z] = 1; } else if (block == DEAD_BLOCK) { game[x][z] = 0; } else if (block == SPEED_BLOCK) { delay = std::max(delay / 2, 1); - mc.postToChat("Speeding up"); + mc.post_to_chat("Speeding up"); } else if (block == SLOW_BLOCK) { delay *= 2; - mc.postToChat("Slowing down"); + mc.post_to_chat("Slowing down"); } else if (block == RANDOM_BLOCK) { for (int x = 0; x < width; x++) { for (int z = 0; z < depth; z++) { game[x][z] = rand() % 2; } } - mc.postToChat("Randomizing"); + mc.post_to_chat("Randomizing"); } else if (block == CLEAR_BLOCK) { for (int x = 0; x < width; x++) { for (int z = 0; z < depth; z++) { game[x][z] = 0; } } - mc.postToChat("Clearing"); + mc.post_to_chat("Clearing"); } } } @@ -172,12 +172,12 @@ void Life::Update() { } // draw - mc.setBlocks(buildPosition, bounds, DEAD_BLOCK); + mc.set_blocks(buildPosition, bounds, DEAD_BLOCK); for (int x = 0; x < width; x++) { for (int z = 0; z < depth; z++) { mcpp::Coordinate position(buildPosition.x + x, buildPosition.y, buildPosition.z + z); if (game[x][z] == 1) { - mc.setBlock(position, ALIVE_BLOCK); + mc.set_block(position, ALIVE_BLOCK); } } } diff --git a/example/hello_minecraft.cpp b/example/hello_minecraft.cpp index 19fcb0b..63a38c0 100644 --- a/example/hello_minecraft.cpp +++ b/example/hello_minecraft.cpp @@ -6,5 +6,5 @@ int main() { MinecraftConnection mc; // Post chat to Minecraft - mc.postToChat("Hello, Minecraft!"); + mc.post_to_chat("Hello, Minecraft!"); } diff --git a/example/minesweeper/minesweeper.cpp b/example/minesweeper/minesweeper.cpp index e43ff06..2ae1653 100644 --- a/example/minesweeper/minesweeper.cpp +++ b/example/minesweeper/minesweeper.cpp @@ -63,14 +63,14 @@ bool Minesweeper::GameLoop() { usleep(5000); } Reveal(); - mc.postToChat("Play Again??"); - mc.postToChat("Place another mine to generate a new board!"); - mc.postToChat("Otherwise leave the area or place a barrier to end."); + mc.post_to_chat("Play Again??"); + mc.post_to_chat("Place another mine to generate a new board!"); + mc.post_to_chat("Otherwise leave the area or place a barrier to end."); bool finish = true; while (finish) { usleep(50000); - mcpp::Chunk choices = mc.getBlocks(cornerOrigin, cornerOpposite); + mcpp::Chunk choices = mc.get_blocks(cornerOrigin, cornerOpposite); for (int x = 0; x < X_SIZE; x++) { for (int z = 0; z < Z_SIZE; z++) { printer.x = origin.x + x; @@ -79,23 +79,23 @@ bool Minesweeper::GameLoop() { if (choices.get(x, 0, z) == clear) { printer.y++; - mc.setBlock(printer, air); - mc.postToChat("Replaying"); + mc.set_block(printer, air); + mc.post_to_chat("Replaying"); GenerateBoard(); GameLoop(); finish = false; } else if (choices.get(x, 0, z) == quit) { printer.y++; - mc.setBlock(printer, air); - mc.postToChat("Quitting"); + mc.set_block(printer, air); + mc.post_to_chat("Quitting"); finish = false; } } } - mcpp::Coordinate playerpos = mc.getPlayerPosition(); + mcpp::Coordinate playerpos = mc.get_player_position(); if (fabs(playerpos.x - origin.x) - X_SIZE > 10 || fabs(playerpos.z - origin.z) - Z_SIZE > 10) { - mc.postToChat("Left player area. Quitting."); + mc.post_to_chat("Left player area. Quitting."); finish = false; } } @@ -126,20 +126,20 @@ Minesweeper::Minesweeper() { mcpp::Blocks::BLACK_WOOL}; // Gives player items to play - mc.doCommand("gamerule sendCommandFeedback false"); - mc.doCommand("clear @p"); - mc.doCommand("give @p tnt"); - mc.doCommand("give @p sea_lantern"); - mc.doCommand("give @p barrier"); - mc.doCommand("gamerule sendCommandFeedback true"); + mc.do_command("gamerule sendCommandFeedback false"); + mc.do_command("clear @p"); + mc.do_command("give @p tnt"); + mc.do_command("give @p sea_lantern"); + mc.do_command("give @p barrier"); + mc.do_command("gamerule sendCommandFeedback true"); // Lets player know how to play - mc.postToChat("The TNT/Mine clears the spot below"); - mc.postToChat("The Sea_Lantern/Flag flags the spot below"); - mc.postToChat("The barrier exits the game"); - mc.postToChat("To play, place blocks above the board"); + mc.post_to_chat("The TNT/Mine clears the spot below"); + mc.post_to_chat("The Sea_Lantern/Flag flags the spot below"); + mc.post_to_chat("The barrier exits the game"); + mc.post_to_chat("To play, place blocks above the board"); // Builds board - origin = mc.getPlayerTilePosition(); + origin = mc.get_player_tile_position(); GenerateBoard(); // Prints the legend @@ -147,32 +147,32 @@ Minesweeper::Minesweeper() { printer.z--; printer.y++; for (int i = 0; i <= 9; i++) { - mc.setBlock(printer, blocks[i]); + mc.set_block(printer, blocks[i]); printer.x++; } - mc.setBlock(printer, flag); + mc.set_block(printer, flag); printer.y++; - mc.setBlock(printer, badflag); + mc.set_block(printer, badflag); printer.x--; - mc.setBlock(printer, goodmine); + mc.set_block(printer, goodmine); printer.y++; - mc.setBlock(printer, badmine); + mc.set_block(printer, badmine); // Sets the display origins and keys displayclearsorigin = origin; displayclearsorigin.z--; displayclearsorigin.y += 3; - mc.setBlock(displayclearsorigin, uncleared); + mc.set_block(displayclearsorigin, uncleared); displayclearsorigin.x++; displayflagsorigin = displayclearsorigin; displayflagsorigin.x += 4; - mc.setBlock(displayflagsorigin, flag); + mc.set_block(displayflagsorigin, flag); displayflagsorigin.x++; } bool Minesweeper::Playing() { - mcpp::Chunk choices = mc.getBlocks(cornerOrigin, cornerOpposite); + mcpp::Chunk choices = mc.get_blocks(cornerOrigin, cornerOpposite); for (int x = 0; x < X_SIZE; x++) { for (int z = 0; z < Z_SIZE; z++) { printer.x = origin.x + x; @@ -186,14 +186,14 @@ bool Minesweeper::Playing() { } else if (choices.get(x, 0, z) == quit) { playing = false; printer.y++; - mc.setBlock(printer, air); - mc.postToChat("Quitting"); + mc.set_block(printer, air); + mc.post_to_chat("Quitting"); } } } if (clearstowin == 0) { - mc.postToChat("YOU WIN!!"); + mc.post_to_chat("YOU WIN!!"); playing = false; } @@ -204,21 +204,21 @@ void Minesweeper::Flag(int x, int z) { if (field[x][z][1] == 0) { field[x][z][1] = 1; flagsleft--; - mc.setBlock(printer, flag); + mc.set_block(printer, flag); } else if (field[x][z][1] == 1) { field[x][z][1] = 0; flagsleft++; - mc.setBlock(printer, uncleared); + mc.set_block(printer, uncleared); } printer.y++; - mc.setBlock(printer, air); + mc.set_block(printer, air); } void Minesweeper::Clear(int x, int z) { if (field[x][z][1] == 0) { - mc.setBlock(printer, blocks[field[x][z][0]]); + mc.set_block(printer, blocks[field[x][z][0]]); if (field[x][z][0] == 9) { // If a mine, you loose if (firstclick) { @@ -226,7 +226,7 @@ void Minesweeper::Clear(int x, int z) { FirstClickProtection(x, z); Clear(x, z); } else { - mc.postToChat("GAMEOVER!"); + mc.post_to_chat("GAMEOVER!"); playing = false; } } else if (field[x][z][0] == 0) { // If zero add location to a stack @@ -242,7 +242,7 @@ void Minesweeper::Clear(int x, int z) { } printer.y++; // removes block above the board - mc.setBlock(printer, air); + mc.set_block(printer, air); } void Minesweeper::ZeroClear(int x, int z) { @@ -263,7 +263,7 @@ void Minesweeper::ZeroClear(int x, int z) { printer.x = origin.x + xC + xo; printer.z = origin.z + zC + zo; - mc.setBlock(printer, blocks[field[xC + xo][zC + zo][0]]); + mc.set_block(printer, blocks[field[xC + xo][zC + zo][0]]); if (field[xC + xo][zC + zo][1] != 2) { clearstowin--; @@ -283,14 +283,14 @@ void Minesweeper::Reveal() { for (int z = 0; z < Z_SIZE; z++) { // shows what you did correctly and if (field[x][z][0] == 9) { // incorrectly if (field[x][z][1] == 1) { - mc.setBlock(printer, goodmine); + mc.set_block(printer, goodmine); } else if (field[x][z][1] == 0) { - mc.setBlock(printer, clear); + mc.set_block(printer, clear); } else { - mc.setBlock(printer, badmine); + mc.set_block(printer, badmine); } } else if (field[x][z][1] == 1) { - mc.setBlock(printer, badflag); + mc.set_block(printer, badflag); } printer.z++; } @@ -300,7 +300,7 @@ void Minesweeper::Reveal() { } void Minesweeper::FirstClickProtection(int x, int z) { - mc.postToChat("Saved, Would have been a mine"); + mc.post_to_chat("Saved, Would have been a mine"); field[x][z][0] = 1; for (int xo = -1; xo <= 1; xo++) { @@ -319,44 +319,44 @@ void Minesweeper::FirstClickProtection(int x, int z) { void Minesweeper::UpdateDisplays() { printer = displayclearsorigin; printer.x += 3; - mc.setBlocks(printer, displayclearsorigin, air); + mc.set_blocks(printer, displayclearsorigin, air); printer.x -= 3; if (clearstowin >= 1000) { - mc.setBlock(printer, numbers[clearstowin / 1000]); + mc.set_block(printer, numbers[clearstowin / 1000]); printer.x++; } if (clearstowin >= 100) { - mc.setBlock(printer, numbers[(clearstowin % 1000) / 100]); + mc.set_block(printer, numbers[(clearstowin % 1000) / 100]); printer.x++; } if (clearstowin >= 10) { - mc.setBlock(printer, numbers[(clearstowin % 100) / 10]); + mc.set_block(printer, numbers[(clearstowin % 100) / 10]); printer.x++; } if (clearstowin >= 1) { - mc.setBlock(printer, numbers[clearstowin % 10]); + mc.set_block(printer, numbers[clearstowin % 10]); printer.x++; } printer = displayflagsorigin; printer.x += 2; - mc.setBlocks(printer, displayflagsorigin, air); + mc.set_blocks(printer, displayflagsorigin, air); printer.x -= 2; if (flagsleft >= 1000) { - mc.setBlock(printer, numbers[flagsleft / 1000]); + mc.set_block(printer, numbers[flagsleft / 1000]); printer.x++; } if (flagsleft >= 100) { - mc.setBlock(printer, numbers[(flagsleft % 1000) / 100]); + mc.set_block(printer, numbers[(flagsleft % 1000) / 100]); printer.x++; } if (flagsleft >= 10) { - mc.setBlock(printer, numbers[(flagsleft % 100) / 10]); + mc.set_block(printer, numbers[(flagsleft % 100) / 10]); printer.x++; } if (flagsleft >= 1) { - mc.setBlock(printer, numbers[flagsleft % 10]); + mc.set_block(printer, numbers[flagsleft % 10]); printer.x++; } } @@ -394,7 +394,7 @@ void Minesweeper::GenerateBoard() { cornerOpposite = origin; cornerOpposite.x += X_SIZE - 1; cornerOpposite.z += Z_SIZE - 1; - mc.setBlocks(cornerOrigin, cornerOpposite, uncleared); + mc.set_blocks(cornerOrigin, cornerOpposite, uncleared); // Moves corners up for later use in grabbing game area; cornerOpposite.y++; diff --git a/example/model-generation/obj-mc.cpp b/example/model-generation/obj-mc.cpp index a25c852..d28f6f5 100644 --- a/example/model-generation/obj-mc.cpp +++ b/example/model-generation/obj-mc.cpp @@ -55,7 +55,7 @@ int main(int argc, char* argv[]) { mcpp::MinecraftConnection mc; Model* model = new Model(filename); - model->SetPosition(mc.getPlayerPosition()); + model->SetPosition(mc.get_player_position()); model->Scale(scale); model->BuildModel(mc); // Fills the model model->BuildPointCloud(mc); // Places blocks at vertices @@ -120,7 +120,7 @@ void Model::BuildPointCloud(mcpp::MinecraftConnection& mc) { for (const Vec3& vertex : _vertices) { mcpp::Coordinate blockPosition = mcpp::Coordinate(_position.x + vertex.x, _position.y + vertex.y, _position.z + vertex.z); - mc.setBlock(blockPosition, mcpp::Blocks::GRAY_WOOL); + mc.set_block(blockPosition, mcpp::Blocks::GRAY_WOOL); } } @@ -147,7 +147,7 @@ void Model::BuildModel(mcpp::MinecraftConnection& mc) { if (IsWithin(position)) { mcpp::Coordinate blockPosition = mcpp::Coordinate(_position.x + x, _position.y + y, _position.z + z); - mc.setBlock(blockPosition, mcpp::Blocks::GRAY_CONCRETE); + mc.set_block(blockPosition, mcpp::Blocks::GRAY_CONCRETE); } } } diff --git a/example/pyramid.cpp b/example/pyramid.cpp index b25c609..9e9249c 100644 --- a/example/pyramid.cpp +++ b/example/pyramid.cpp @@ -10,11 +10,11 @@ mcpp::MinecraftConnection mc; void make_ring(mcpp::Coordinate base_pt, int side_len) { // Flat plane - mc.setBlocks(base_pt, base_pt + mcpp::Coordinate(side_len, 0, side_len), mcpp::Blocks::SANDSTONE); + mc.set_blocks(base_pt, base_pt + mcpp::Coordinate(side_len, 0, side_len), mcpp::Blocks::SANDSTONE); // Air inside to make border base_pt = base_pt + mcpp::Coordinate(1, 0, 1); - mc.setBlocks(base_pt, base_pt + mcpp::Coordinate(side_len - 2, 0, side_len - 2), + mc.set_blocks(base_pt, base_pt + mcpp::Coordinate(side_len - 2, 0, side_len - 2), mcpp::Blocks::AIR); } @@ -23,7 +23,7 @@ int main() { // Get heights of build area mcpp::HeightMap heights = - mc.getHeights(ORIGIN, ORIGIN + mcpp::Coordinate(pyramid_base_len, 0, pyramid_base_len)); + mc.get_heights(ORIGIN, ORIGIN + mcpp::Coordinate(pyramid_base_len, 0, pyramid_base_len)); // Use minimum height of the area as the lowest point on the pyramid int min_height = *std::min_element(heights.begin(), heights.end()); diff --git a/example/video-generation/video-mc.cpp b/example/video-generation/video-mc.cpp index 822b5c0..106ae73 100644 --- a/example/video-generation/video-mc.cpp +++ b/example/video-generation/video-mc.cpp @@ -159,7 +159,7 @@ void Video::Play(mcpp::MinecraftConnection& mc) { _optionColors.push_back(Pixel{228, 236, 253}); // LIGHT BLUE WOOL _optionColors.push_back(Pixel{160, 167, 167}); // LIGHT GRAY WOOL - _position = mc.getPlayerPosition(); + _position = mc.get_player_position(); _position.y += (_height / _scaleFactor) / 2; _position.z -= std::max((_width / _scaleFactor) / 2, (_height / _scaleFactor) / 2); _position.x += std::min((_width / _scaleFactor) / 2, 16); @@ -190,7 +190,7 @@ void Video::DisplayFrame(size_t index, mcpp::MinecraftConnection& mc) { pixelPosition.z += (i % _width) / _scaleFactor; pixelPosition.y -= (i / _width) / _scaleFactor; - mc.setBlock(pixelPosition, blockType); + mc.set_block(pixelPosition, blockType); } } } diff --git a/include/mcpp/block.h b/include/mcpp/block.h index 747ae11..dc9ce79 100644 --- a/include/mcpp/block.h +++ b/include/mcpp/block.h @@ -14,7 +14,7 @@ class BlockType { uint8_t mod; // NOLINT // NOLINTNEXTLINE - constexpr BlockType(uint8_t id = 0, uint8_t mod = 0) : id(id), mod(mod){}; + constexpr BlockType(uint8_t id = 0, uint8_t mod = 0) : id(id), mod(mod) {}; /** * @brief Equality comparison operator. diff --git a/include/mcpp/mcpp.h b/include/mcpp/mcpp.h index 528e92c..bfa3793 100644 --- a/include/mcpp/mcpp.h +++ b/include/mcpp/mcpp.h @@ -52,7 +52,7 @@ class MinecraftConnection { * * @param message */ - void postToChat(const std::string& message); + void post_to_chat(const std::string& message); /** * @brief Performs an in-game minecraft command. Players have to exist on @@ -60,7 +60,7 @@ class MinecraftConnection { * * @param command Command string in the in-game format (e.g. "time set day") */ - void doCommand(const std::string& command); + void do_command(const std::string& command); /** * @brief Sets player pos (block pos of lower half of playermodel) to @@ -68,7 +68,7 @@ class MinecraftConnection { * * @param pos Coordinate to set */ - void setPlayerPosition(const Coordinate& pos); + void set_player_position(const Coordinate& pos); /** * @brief Returns a coordinate representing player position (block pos of @@ -76,7 +76,7 @@ class MinecraftConnection { * * @return Coordinate of location */ - [[nodiscard]] Coordinate getPlayerPosition() const; + [[nodiscard]] Coordinate get_player_position() const; /** * @brief Sets player position to be one above specified tile (i.e. tile = @@ -84,7 +84,7 @@ class MinecraftConnection { * * @param tile Coordinate to set */ - void setPlayerTilePosition(const Coordinate& tile); + void set_player_tile_position(const Coordinate& tile); /** * @brief Returns the coordinate location of the block the player is @@ -92,7 +92,7 @@ class MinecraftConnection { * * @return Coordinate of location */ - [[nodiscard]] Coordinate getPlayerTilePosition() const; + [[nodiscard]] Coordinate get_player_tile_position() const; /** * @brief Sets block at Coordinate loc to the BlockType specified by @@ -101,7 +101,7 @@ class MinecraftConnection { * @param loc * @param blockType */ - void setBlock(const Coordinate& loc, const BlockType& block_type); + void set_block(const Coordinate& loc, const BlockType& block_type); /** * @brief Sets a cuboid of blocks to the specified BlockType blockType, with @@ -111,7 +111,7 @@ class MinecraftConnection { * @param loc2 * @param blockType */ - void setBlocks(const Coordinate& loc1, const Coordinate& loc2, const BlockType& block_type); + void set_blocks(const Coordinate& loc1, const Coordinate& loc2, const BlockType& block_type); /** * @brief Returns BlockType object from the specified Coordinate loc with @@ -121,7 +121,7 @@ class MinecraftConnection { * @return BlockType of the requested block */ [[nodiscard]] BlockType - getBlock(const Coordinate& loc) const; // NOLINT(readability-identifier-naming) + get_block(const Coordinate& loc) const; // NOLINT(readability-identifier-naming) /** * @brief Returns a 3D vector of the BlockTypes of the requested cuboid with @@ -131,14 +131,14 @@ class MinecraftConnection { * @param loc2 2nd corner of the cuboid * @return Chunk containing the blocks in the specified area. */ - [[nodiscard]] Chunk getBlocks(const Coordinate& loc1, const Coordinate& loc2) const; + [[nodiscard]] Chunk get_blocks(const Coordinate& loc1, const Coordinate& loc2) const; /** * @brief Returns the height of the specific provided x and z coordinate * * ***IMPORTANT:*** * DO NOT USE FOR LARGE AREAS, IT WILL BE VERY SLOW - * USE getHeights() INSTEAD + * USE get_heights() INSTEAD * * Gets the y-value of the highest non-air block at the specified (x, z) * coordinate. @@ -146,19 +146,19 @@ class MinecraftConnection { * @param z * @return Returns the integer y-height at the requested coordinate. */ - [[nodiscard]] int32_t getHeight(int x, int z) const; + [[nodiscard]] int32_t get_height(int x, int z) const; /** - * @brief Provides a scaled option of the getHeight call to allow for + * @brief Provides a scaled option of the get_height call to allow for * considerable performance gains. * - * \par USE THIS instead of getHeight in a for loop. + * \par USE THIS instead of get_height in a for loop. * * @param loc1 * @param loc2 * @return Returns a vector of integers representing the 2D area of heights. */ - [[nodiscard]] HeightMap getHeights(const Coordinate& loc1, const Coordinate& loc2) const; + [[nodiscard]] HeightMap get_heights(const Coordinate& loc1, const Coordinate& loc2) const; // NOLINTEND(readability-identifier-naming) }; diff --git a/src/mcpp.cpp b/src/mcpp.cpp index 786d078..165c7cd 100644 --- a/src/mcpp.cpp +++ b/src/mcpp.cpp @@ -16,52 +16,52 @@ MinecraftConnection::MinecraftConnection(const std::string& address, uint16_t po MinecraftConnection::~MinecraftConnection() = default; -void MinecraftConnection::postToChat(const std::string& message) { +void MinecraftConnection::post_to_chat(const std::string& message) { _conn->send_command("chat.post", message); } -void MinecraftConnection::doCommand(const std::string& command) { +void MinecraftConnection::do_command(const std::string& command) { _conn->send_command("player.doCommand", command); } -void MinecraftConnection::setPlayerPosition(const Coordinate& pos) { +void MinecraftConnection::set_player_position(const Coordinate& pos) { _conn->send_command("player.setPos", pos.x, pos.y, pos.z); } -Coordinate MinecraftConnection::getPlayerPosition() const { +Coordinate MinecraftConnection::get_player_position() const { std::string response = _conn->send_receive_command("player.getPos", ""); std::vector parsed; split_response(response, parsed); return {parsed[0], parsed[1], parsed[2]}; } -void MinecraftConnection::setPlayerTilePosition(const Coordinate& tile) { +void MinecraftConnection::set_player_tile_position(const Coordinate& tile) { Coordinate new_tile = tile; new_tile.y++; - setPlayerPosition(new_tile); + set_player_position(new_tile); } -Coordinate MinecraftConnection::getPlayerTilePosition() const { - Coordinate player_tile = getPlayerPosition(); +Coordinate MinecraftConnection::get_player_tile_position() const { + Coordinate player_tile = get_player_position(); player_tile.y--; return player_tile; } -void MinecraftConnection::setBlock(const Coordinate& loc, const BlockType& block_type) { +void MinecraftConnection::set_block(const Coordinate& loc, const BlockType& block_type) { // Static cast required because of stupid ss default of uint8_t as char _conn->send_command("world.setBlock", loc.x, loc.y, loc.z, static_cast(block_type.id), static_cast(block_type.mod)); } -void MinecraftConnection::setBlocks(const Coordinate& loc1, const Coordinate& loc2, - const BlockType& block_type) { +void MinecraftConnection::set_blocks(const Coordinate& loc1, const Coordinate& loc2, + const BlockType& block_type) { auto [x1, y1, z1] = loc1; auto [x2, y2, z2] = loc2; _conn->send_command("world.setBlocks", x1, y1, z1, x2, y2, z2, static_cast(block_type.id), static_cast(block_type.mod)); } -BlockType MinecraftConnection::getBlock(const Coordinate& loc) const { +BlockType MinecraftConnection::get_block(const Coordinate& loc) const { std::string return_str = _conn->send_receive_command("world.getBlockWithData", loc.x, loc.y, loc.z); std::vector parsed; @@ -71,7 +71,7 @@ BlockType MinecraftConnection::getBlock(const Coordinate& loc) const { return {parsed[0], parsed[1]}; } -Chunk MinecraftConnection::getBlocks(const Coordinate& loc1, const Coordinate& loc2) const { +Chunk MinecraftConnection::get_blocks(const Coordinate& loc1, const Coordinate& loc2) const { std::string response = _conn->send_receive_command("world.getBlocksWithData", loc1.x, loc1.y, loc1.z, loc2.x, loc2.y, loc2.z); @@ -103,12 +103,12 @@ Chunk MinecraftConnection::getBlocks(const Coordinate& loc1, const Coordinate& l return Chunk{loc1, loc2, result}; } -int MinecraftConnection::getHeight(int x, int z) const { +int MinecraftConnection::get_height(int x, int z) const { std::string response = _conn->send_receive_command("world.getHeight", x, z); return stoi(response); } -HeightMap MinecraftConnection::getHeights(const Coordinate& loc1, const Coordinate& loc2) const { +HeightMap MinecraftConnection::get_heights(const Coordinate& loc1, const Coordinate& loc2) const { std::string response = _conn->send_receive_command("world.getHeights", loc1.x, loc1.z, loc2.x, loc2.z); diff --git a/test/minecraft_tests.cpp b/test/minecraft_tests.cpp index cd3ce46..e494059 100644 --- a/test/minecraft_tests.cpp +++ b/test/minecraft_tests.cpp @@ -72,17 +72,17 @@ TEST_CASE("Socket connection test") { // int x1 = 0, y1 = 0, z1 = 0; // int x2 = 31, y2 = 100, z2 = 31; // - // tcp_conn.sendCommand("world.setBlocks", x1, y1, z1, x2, y2, z2, + // tcp_conn.sendCommand("world.set_blocks", x1, y1, z1, x2, y2, z2, // Blocks::DIRT.id, Blocks::DIRT.mod); // std::string result = - // tcp_conn.sendReceiveCommand("world.getHeights", x1, z1, x2, z2); + // tcp_conn.sendReceiveCommand("world.get_heights", x1, z1, x2, z2); // int real_size = result.size(); // // // -1 because newline is removed // CHECK_EQ(real_size, expected_size - 1); // // // Cleanup - // tcp_conn.sendCommand("world.setBlocks", x1, y1, z1, x2, y2, z2, + // tcp_conn.sendCommand("world.set_blocks", x1, y1, z1, x2, y2, z2, // Blocks::AIR.id, Blocks::AIR.mod); // } @@ -94,42 +94,42 @@ TEST_CASE("Socket connection test") { TEST_CASE("Test the main mcpp class") { Coordinate test_loc(100, 100, 100); - SUBCASE("postToChat") { mc.postToChat("test string"); } + SUBCASE("post_to_chat") { mc.post_to_chat("test string"); } - SUBCASE("setBlock") { mc.setBlock(test_loc, BlockType(50)); } + SUBCASE("set_block") { mc.set_block(test_loc, BlockType(50)); } - SUBCASE("getBlock") { - mc.setBlock(test_loc, BlockType(34)); - CHECK_EQ(mc.getBlock(test_loc), BlockType(34)); + SUBCASE("get_block") { + mc.set_block(test_loc, BlockType(34)); + CHECK_EQ(mc.get_block(test_loc), BlockType(34)); } // Using values from the Blocks struct in block.h beyond this point - SUBCASE("getBlock with mod") { - mc.setBlock(test_loc, BlockType(5, 5)); - CHECK_EQ(mc.getBlock(test_loc), BlockType(5, 5)); + SUBCASE("get_block with mod") { + mc.set_block(test_loc, BlockType(5, 5)); + CHECK_EQ(mc.get_block(test_loc), BlockType(5, 5)); - mc.setBlock(test_loc, Blocks::LIGHT_BLUE_CONCRETE); - CHECK_EQ(mc.getBlock(test_loc), Blocks::LIGHT_BLUE_CONCRETE); + mc.set_block(test_loc, Blocks::LIGHT_BLUE_CONCRETE); + CHECK_EQ(mc.get_block(test_loc), Blocks::LIGHT_BLUE_CONCRETE); } - SUBCASE("getHeight") { + SUBCASE("get_height") { Coordinate heightTestLoc(300, 200, 300); - mc.setBlock(heightTestLoc, Blocks::DIRT); - auto height = mc.getHeight(heightTestLoc.x, heightTestLoc.z); + mc.set_block(heightTestLoc, Blocks::DIRT); + auto height = mc.get_height(heightTestLoc.x, heightTestLoc.z); CHECK_EQ(height, heightTestLoc.y); // Clean up - mc.setBlock(heightTestLoc, Blocks::AIR); + mc.set_block(heightTestLoc, Blocks::AIR); } - SUBCASE("setBlocks") { + SUBCASE("set_blocks") { Coordinate loc1{100, 100, 100}; Coordinate loc2{110, 110, 110}; - mc.setBlocks(loc1, loc2, Blocks::STONE); + mc.set_blocks(loc1, loc2, Blocks::STONE); } } -TEST_CASE("getBlocks and Chunk operations") { +TEST_CASE("get_blocks and Chunk operations") { // Setup Coordinate test_loc(100, 100, 100); @@ -137,23 +137,23 @@ TEST_CASE("getBlocks and Chunk operations") { Coordinate loc2{110, 111, 112}; // Reset blocks that existed before - mc.setBlocks(loc1, loc2, Blocks::AIR); - mc.setBlocks(loc1, loc2, Blocks::BRICKS); - mc.setBlock(loc1, Blocks::GOLD_BLOCK); - mc.setBlock(loc2, Blocks::DIAMOND_BLOCK); - mc.setBlock(loc1 + Coordinate{1, 2, 3}, Blocks::IRON_BLOCK); - Chunk res = mc.getBlocks(loc1, loc2); - const Chunk res_const = mc.getBlocks(loc1, loc2); + mc.set_blocks(loc1, loc2, Blocks::AIR); + mc.set_blocks(loc1, loc2, Blocks::BRICKS); + mc.set_block(loc1, Blocks::GOLD_BLOCK); + mc.set_block(loc2, Blocks::DIAMOND_BLOCK); + mc.set_block(loc1 + Coordinate{1, 2, 3}, Blocks::IRON_BLOCK); + Chunk res = mc.get_blocks(loc1, loc2); + const Chunk res_const = mc.get_blocks(loc1, loc2); SUBCASE("getters") { - Chunk data = mc.getBlocks(loc1, loc2); + Chunk data = mc.get_blocks(loc1, loc2); CHECK_EQ(data.base_pt(), loc1); CHECK_EQ(data.x_len(), 11); CHECK_EQ(data.y_len(), 12); CHECK_EQ(data.z_len(), 13); - data = mc.getBlocks(loc2, loc1); + data = mc.get_blocks(loc2, loc1); CHECK_EQ(data.base_pt(), loc1); CHECK_EQ(data.x_len(), 11); @@ -222,14 +222,14 @@ TEST_CASE("getBlocks and Chunk operations") { SUBCASE("Constructors & assignment") { // Copy assignment - mc.setBlock({10, 10, 10}, Blocks::BLUE_CONCRETE); - auto chunk = mc.getBlocks({10, 10, 10}, {20, 20, 20}); + mc.set_block({10, 10, 10}, Blocks::BLUE_CONCRETE); + auto chunk = mc.get_blocks({10, 10, 10}, {20, 20, 20}); Chunk chunk_copy = chunk; // Contains BLUE CHECK_EQ(chunk.get(0, 0, 0), chunk_copy.get(0, 0, 0)); // Reassignment - mc.setBlock({10, 10, 10}, Blocks::RED_CONCRETE); - chunk = mc.getBlocks({10, 10, 10}, {20, 20, 20}); // Now contains RED + mc.set_block({10, 10, 10}, Blocks::RED_CONCRETE); + chunk = mc.get_blocks({10, 10, 10}, {20, 20, 20}); // Now contains RED CHECK_NE(chunk.get(0, 0, 0), chunk_copy.get(0, 0, 0)); // Move assignment @@ -238,8 +238,8 @@ TEST_CASE("getBlocks and Chunk operations") { // Copy constructor auto chunk_copy2 = Chunk(chunk); // Contains BLUE - mc.setBlock({10, 10, 10}, Blocks::WHITE_CONCRETE); - chunk = mc.getBlocks({10, 10, 10}, {20, 20, 20}); // Now contains WHITE + mc.set_block({10, 10, 10}, Blocks::WHITE_CONCRETE); + chunk = mc.get_blocks({10, 10, 10}, {20, 20, 20}); // Now contains WHITE CHECK_NE(chunk_copy2.get(0, 0, 0), Blocks::WHITE_CONCRETE); // Move constructor @@ -247,33 +247,33 @@ TEST_CASE("getBlocks and Chunk operations") { CHECK_EQ(chunk.get(0, 0, 0), Blocks::BLUE_CONCRETE); } - mc.setBlock(test_loc, BlockType(0)); + mc.set_block(test_loc, BlockType(0)); } TEST_CASE("Test blocks struct") { Coordinate testLoc; - mc.setBlock(testLoc, Blocks::AIR); - CHECK_EQ(mc.getBlock(testLoc), Blocks::AIR); - mc.setBlock(testLoc, Blocks::STONE); - CHECK_EQ(mc.getBlock(testLoc), Blocks::STONE); + mc.set_block(testLoc, Blocks::AIR); + CHECK_EQ(mc.get_block(testLoc), Blocks::AIR); + mc.set_block(testLoc, Blocks::STONE); + CHECK_EQ(mc.get_block(testLoc), Blocks::STONE); } TEST_CASE("HeightMap functionality") { // 319 is the build limit in 1.19 - mc.setBlocks(Coordinate{200, 300, 200}, Coordinate{210, 319, 210}, Blocks::AIR); - mc.setBlocks(Coordinate{200, 300, 200}, Coordinate{210, 300, 210}, Blocks::STONE); - mc.setBlock(Coordinate{200, 301, 200}, Blocks::STONE); - mc.setBlock(Coordinate{210, 301, 210}, Blocks::STONE); - mc.setBlock(Coordinate{201, 301, 202}, Blocks::STONE); + mc.set_blocks(Coordinate{200, 300, 200}, Coordinate{210, 319, 210}, Blocks::AIR); + mc.set_blocks(Coordinate{200, 300, 200}, Coordinate{210, 300, 210}, Blocks::STONE); + mc.set_block(Coordinate{200, 301, 200}, Blocks::STONE); + mc.set_block(Coordinate{210, 301, 210}, Blocks::STONE); + mc.set_block(Coordinate{201, 301, 202}, Blocks::STONE); SUBCASE("getters") { - HeightMap data = mc.getHeights(Coordinate{200, 0, 200}, Coordinate{210, 0, 210}); + HeightMap data = mc.get_heights(Coordinate{200, 0, 200}, Coordinate{210, 0, 210}); CHECK_EQ(data.base_pt(), Coordinate{200, 0, 200}); CHECK_EQ(data.x_len(), 11); CHECK_EQ(data.z_len(), 11); - data = mc.getHeights(Coordinate{210, 300, 210}, Coordinate{200, 310, 200}); + data = mc.get_heights(Coordinate{210, 300, 210}, Coordinate{200, 310, 200}); CHECK_EQ(data.base_pt(), Coordinate{200, 0, 200}); CHECK_EQ(data.x_len(), 11); @@ -281,7 +281,7 @@ TEST_CASE("HeightMap functionality") { } SUBCASE("get") { - HeightMap data = mc.getHeights(Coordinate{200, 0, 200}, Coordinate{210, 0, 210}); + HeightMap data = mc.get_heights(Coordinate{200, 0, 200}, Coordinate{210, 0, 210}); CHECK_EQ(data.get(0, 0), 301); CHECK_EQ(data.get(1, 1), 300); CHECK_EQ(data.get(10, 10), 301); @@ -289,7 +289,7 @@ TEST_CASE("HeightMap functionality") { } SUBCASE("get_worldspace") { - HeightMap data = mc.getHeights(Coordinate{200, 0, 200}, Coordinate{210, 0, 210}); + HeightMap data = mc.get_heights(Coordinate{200, 0, 200}, Coordinate{210, 0, 210}); CHECK_EQ(data.get_worldspace(Coordinate{200, 0, 200}), 301); CHECK_EQ(data.get_worldspace(Coordinate{201, 0, 201}), 300); CHECK_EQ(data.get_worldspace(Coordinate{210, 0, 210}), 301); @@ -297,7 +297,7 @@ TEST_CASE("HeightMap functionality") { } SUBCASE("fill_coord") { - HeightMap data = mc.getHeights(Coordinate{200, 0, 200}, Coordinate{210, 0, 210}); + HeightMap data = mc.get_heights(Coordinate{200, 0, 200}, Coordinate{210, 0, 210}); Coordinate to_fill{200, 0, 200}; data.fill_coord(to_fill); @@ -305,7 +305,7 @@ TEST_CASE("HeightMap functionality") { } SUBCASE("Bounds checking") { - HeightMap data = mc.getHeights(Coordinate{200, 0, 200}, Coordinate{210, 0, 210}); + HeightMap data = mc.get_heights(Coordinate{200, 0, 200}, Coordinate{210, 0, 210}); CHECK_THROWS(data.get(-1, 0)); CHECK_THROWS(data.get(0, -1)); CHECK_THROWS(data.get(11, 0)); @@ -321,13 +321,13 @@ TEST_CASE("HeightMap functionality") { } SUBCASE("Negative coord") { - mc.setBlocks(Coordinate{-200, 300, -200}, Coordinate{-210, 319, -210}, Blocks::AIR); - mc.setBlocks(Coordinate{-200, 300, -200}, Coordinate{-210, 300, -210}, Blocks::STONE); - mc.setBlock(Coordinate{-200, 301, -200}, Blocks::STONE); - mc.setBlock(Coordinate{-210, 301, -210}, Blocks::STONE); - mc.setBlock(Coordinate{-201, 301, -202}, Blocks::STONE); + mc.set_blocks(Coordinate{-200, 300, -200}, Coordinate{-210, 319, -210}, Blocks::AIR); + mc.set_blocks(Coordinate{-200, 300, -200}, Coordinate{-210, 300, -210}, Blocks::STONE); + mc.set_block(Coordinate{-200, 301, -200}, Blocks::STONE); + mc.set_block(Coordinate{-210, 301, -210}, Blocks::STONE); + mc.set_block(Coordinate{-201, 301, -202}, Blocks::STONE); - HeightMap data = mc.getHeights(Coordinate{-200, 0, -200}, Coordinate{-210, 0, -210}); + HeightMap data = mc.get_heights(Coordinate{-200, 0, -200}, Coordinate{-210, 0, -210}); CHECK_EQ(data.get_worldspace(Coordinate{-200, 0, -200}), 301); CHECK_EQ(data.get_worldspace(Coordinate{-201, 0, -201}), 300); CHECK_EQ(data.get_worldspace(Coordinate{-210, 0, -210}), 301); @@ -335,13 +335,13 @@ TEST_CASE("HeightMap functionality") { } SUBCASE("Iterator") { - mc.setBlocks(Coordinate{-200, 300, -200}, Coordinate{-210, 319, -210}, Blocks::AIR); - mc.setBlocks(Coordinate{-200, 300, -200}, Coordinate{-210, 300, -210}, Blocks::STONE); - mc.setBlock(Coordinate{-200, 301, -200}, Blocks::STONE); - mc.setBlock(Coordinate{-210, 301, -210}, Blocks::STONE); - mc.setBlock(Coordinate{-201, 301, -202}, Blocks::STONE); + mc.set_blocks(Coordinate{-200, 300, -200}, Coordinate{-210, 319, -210}, Blocks::AIR); + mc.set_blocks(Coordinate{-200, 300, -200}, Coordinate{-210, 300, -210}, Blocks::STONE); + mc.set_block(Coordinate{-200, 301, -200}, Blocks::STONE); + mc.set_block(Coordinate{-210, 301, -210}, Blocks::STONE); + mc.set_block(Coordinate{-201, 301, -202}, Blocks::STONE); - HeightMap data = mc.getHeights(Coordinate{-200, 0, -200}, Coordinate{-210, 0, -210}); + HeightMap data = mc.get_heights(Coordinate{-200, 0, -200}, Coordinate{-210, 0, -210}); std::vector expected_heights; for (int i = 0; i < data.x_len(); i++) { @@ -358,13 +358,13 @@ TEST_CASE("HeightMap functionality") { } SUBCASE("Const iterator") { - mc.setBlocks(Coordinate{-200, 300, -200}, Coordinate{-210, 319, -210}, Blocks::AIR); - mc.setBlocks(Coordinate{-200, 300, -200}, Coordinate{-210, 300, -210}, Blocks::STONE); - mc.setBlock(Coordinate{-200, 301, -200}, Blocks::STONE); - mc.setBlock(Coordinate{-210, 301, -210}, Blocks::STONE); - mc.setBlock(Coordinate{-201, 301, -202}, Blocks::STONE); + mc.set_blocks(Coordinate{-200, 300, -200}, Coordinate{-210, 319, -210}, Blocks::AIR); + mc.set_blocks(Coordinate{-200, 300, -200}, Coordinate{-210, 300, -210}, Blocks::STONE); + mc.set_block(Coordinate{-200, 301, -200}, Blocks::STONE); + mc.set_block(Coordinate{-210, 301, -210}, Blocks::STONE); + mc.set_block(Coordinate{-201, 301, -202}, Blocks::STONE); - const HeightMap data = mc.getHeights(Coordinate{-200, 0, -200}, Coordinate{-210, 0, -210}); + const HeightMap data = mc.get_heights(Coordinate{-200, 0, -200}, Coordinate{-210, 0, -210}); std::vector expected_heights; for (int i = 0; i < data.x_len(); i++) { @@ -382,16 +382,16 @@ TEST_CASE("HeightMap functionality") { SUBCASE("Constructors & assignment") { // Copy assignment - mc.setBlocks({10, 310, 10}, {20, 320, 20}, Blocks::AIR); - mc.setBlocks({10, 310, 10}, {20, 310, 20}, Blocks::STONE); - auto map = mc.getHeights({10, 10, 10}, {20, 20, 20}); + mc.set_blocks({10, 310, 10}, {20, 320, 20}, Blocks::AIR); + mc.set_blocks({10, 310, 10}, {20, 310, 20}, Blocks::STONE); + auto map = mc.get_heights({10, 10, 10}, {20, 20, 20}); HeightMap map_copy = map; // Contains 310 CHECK_EQ(map.get(0, 0), map_copy.get(0, 0)); CHECK_EQ(map.get(0, 0), 310); // Reassignment - mc.setBlock({10, 311, 10}, Blocks::STONE); - map = mc.getHeights({10, 10, 10}, {20, 20, 20}); // Now contains 311 + mc.set_block({10, 311, 10}, Blocks::STONE); + map = mc.get_heights({10, 10, 10}, {20, 20, 20}); // Now contains 311 CHECK_NE(map.get(0, 0), map_copy.get(0, 0)); CHECK_EQ(map.get(0, 0), 311); @@ -401,8 +401,8 @@ TEST_CASE("HeightMap functionality") { // Copy constructor auto map_copy2 = HeightMap(map); // Contains 310 - mc.setBlock({10, 312, 10}, Blocks::STONE); - map = mc.getHeights({10, 10, 10}, {20, 20, 20}); // Now contains 312 + mc.set_block({10, 312, 10}, Blocks::STONE); + map = mc.get_heights({10, 10, 10}, {20, 20, 20}); // Now contains 312 CHECK_NE(map_copy2.get(0, 0), 312); CHECK_EQ(map.get(0, 0), 312); @@ -410,11 +410,11 @@ TEST_CASE("HeightMap functionality") { map = HeightMap(std::move(map_copy2)); // Now contains 310 CHECK_EQ(map.get(0, 0), 310); - mc.setBlocks({10, 310, 10}, {20, 320, 20}, Blocks::AIR); + mc.set_blocks({10, 310, 10}, {20, 320, 20}, Blocks::AIR); } // Clean up - mc.setBlocks(Coordinate{200, 300, 200}, Coordinate{210, 301, 210}, Blocks::AIR); + mc.set_blocks(Coordinate{200, 300, 200}, Coordinate{210, 301, 210}, Blocks::AIR); } // Requires player joined to server, will throw serverside if player is not @@ -423,43 +423,43 @@ TEST_CASE("HeightMap functionality") { TEST_CASE("Player operations") { Coordinate test_loc{110, 110, 110}; - mc.setBlock(test_loc, Blocks::DIRT); + mc.set_block(test_loc, Blocks::DIRT); - SUBCASE("Execute command") { mc.doCommand("time set noon"); } + SUBCASE("Execute command") { mc.do_command("time set noon"); } - SUBCASE("Set position") { mc.setPlayerPosition(test_loc + Coordinate(0, 1, 0)); } + SUBCASE("Set position") { mc.set_player_position(test_loc + Coordinate(0, 1, 0)); } SUBCASE("Get position") { - mc.setPlayerPosition(Coordinate(0, 0, 0)); - mc.setPlayerPosition(test_loc + Coordinate(0, 1, 0)); - Coordinate player_loc = mc.getPlayerPosition(); + mc.set_player_position(Coordinate(0, 0, 0)); + mc.set_player_position(test_loc + Coordinate(0, 1, 0)); + Coordinate player_loc = mc.get_player_position(); CHECK((player_loc == (test_loc + Coordinate(0, 1, 0)))); } SUBCASE("Check correct flooring") { Coordinate negative_loc(-2, 100, -2); - mc.doCommand("tp -2 100 -2"); - CHECK_EQ(mc.getPlayerPosition(), negative_loc); + mc.do_command("tp -2 100 -2"); + CHECK_EQ(mc.get_player_position(), negative_loc); } - SUBCASE("setPlayerTilePosition and getPlayerTilePosition") { - mc.setPlayerPosition(Coordinate(0, 0, 0)); + SUBCASE("set_player_tile_position and get_player_tile_position") { + mc.set_player_position(Coordinate(0, 0, 0)); - mc.setPlayerTilePosition(test_loc); + mc.set_player_tile_position(test_loc); - Coordinate result = mc.getPlayerTilePosition(); + Coordinate result = mc.get_player_tile_position(); Coordinate expected = test_loc; CHECK_EQ(result, expected); - Coordinate p_result = mc.getPlayerPosition(); + Coordinate p_result = mc.get_player_position(); Coordinate p_expected = test_loc + Coordinate(0, 1, 0); CHECK_EQ(p_result, p_expected); } // Cleanup - mc.setBlock(test_loc, Blocks::AIR); + mc.set_block(test_loc, Blocks::AIR); } #endif