Skip to content

Commit

Permalink
Merge pull request #34 from Jinxto/fix/get-set-tile-pos
Browse files Browse the repository at this point in the history
Fix get/set(PlayerTilePosition) offset by 1
  • Loading branch information
rozukke authored Jun 12, 2024
2 parents 2356611 + 8b939a3 commit 48daadf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/mcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ Coordinate MinecraftConnection::getPlayerPosition() {
}

void MinecraftConnection::setPlayerTilePosition(const Coordinate& tile) {
conn->sendCommand("player.setTile", tile.x, tile.y, tile.z);
Coordinate newTile = tile;
newTile.y++;
setPlayerPosition(newTile);
}

Coordinate MinecraftConnection::getPlayerTilePosition() {
std::string returnString = conn->sendReceiveCommand("player.getTile", "");
std::vector<int> parsedInts;
splitCommaStringToInts(returnString, parsedInts);
return Coordinate(parsedInts[0], parsedInts[1], parsedInts[2]);
Coordinate playerTile = getPlayerPosition();
playerTile.y--;
return playerTile;
}

void MinecraftConnection::setBlock(const Coordinate& loc,
Expand Down

0 comments on commit 48daadf

Please sign in to comment.