mcpp
C++ Minecraft Library
Loading...
Searching...
No Matches
mcpp.h
Go to the documentation of this file.
1#pragma once
2
3#include "block.h"
4#include "chunk.h"
5#include "coordinate.h"
6#include "heightmap.h"
7
8#include <memory>
9
22namespace mcpp {
23// Forward declare to avoid polluting namespace
24class SocketConnection;
25
26const uint16_t MCPP_PORT = 4711;
27
29private:
31 std::unique_ptr<SocketConnection> _conn;
32
33public:
42 explicit MinecraftConnection(const std::string& address = "localhost", uint16_t port = MCPP_PORT);
43
44 // Declared here, defaulted in mcpp.cpp to allow for forward declare of
45 // SocketConnection
47
48 // NOLINTBEGIN(readability-identifier-naming)
55 void postToChat(const std::string& message);
56
63 void doCommand(const std::string& command);
64
71 void setPlayerPosition(const Coordinate& pos);
72
79 [[nodiscard]] Coordinate getPlayerPosition() const;
80
88
95 [[nodiscard]] Coordinate getPlayerTilePosition() const;
96
104 void setBlock(const Coordinate& loc, const BlockType& block_type);
105
114 void setBlocks(const Coordinate& loc1, const Coordinate& loc2, const BlockType& block_type);
115
123 [[nodiscard]] BlockType
124 getBlock(const Coordinate& loc) const; // NOLINT(readability-identifier-naming)
125
134 [[nodiscard]] Chunk getBlocks(const Coordinate& loc1, const Coordinate& loc2) const;
135
148 [[nodiscard]] int32_t getHeight(Coordinate2D loc) const;
149
164
175 [[nodiscard]] HeightMap getHeights(const Coordinate2D& loc1, const Coordinate2D& loc2) const;
176
177 // NOLINTEND(readability-identifier-naming)
178};
179} // namespace mcpp
BlockType class.
Definition block.h:11
Definition mcpp.h:28
void setPlayerTilePosition(const Coordinate &tile)
Sets player position to be one above specified tile (i.e. tile = block player is standing on)
void setPlayerPosition(const Coordinate &pos)
Sets player pos (block pos of lower half of playermodel) to specified Coordinate.
int32_t getHeight(Coordinate2D loc) const
Returns the height of the specific provided 2D coordinate.
Coordinate getPlayerTilePosition() const
Returns the coordinate location of the block the player is standing on.
BlockType getBlock(const Coordinate &loc) const
Returns BlockType object from the specified Coordinate loc with modifier.
Chunk getBlocks(const Coordinate &loc1, const Coordinate &loc2) const
Returns a 3D vector of the BlockTypes of the requested cuboid with modifiers.
Coordinate getPlayerPosition() const
Returns a coordinate representing player position (block pos of lower half of playermodel)
void doCommand(const std::string &command)
Performs an in-game minecraft command. Players have to exist on the server and should be server opera...
void setBlock(const Coordinate &loc, const BlockType &block_type)
Sets block at Coordinate loc to the BlockType specified by blockType.
void postToChat(const std::string &message)
Sends a message to the in-game chat, does not require a joined player.
Coordinate fillHeight(Coordinate2D loc) const
Returns the coordinate with the x, z, and in-world height of the specific provided 2D coordinate.
HeightMap getHeights(const Coordinate2D &loc1, const Coordinate2D &loc2) const
Provides a scaled option of the getHeight call to allow for considerable performance gains.
void setBlocks(const Coordinate &loc1, const Coordinate &loc2, const BlockType &block_type)
Sets a cuboid of blocks to the specified BlockType blockType, with the corners of the cuboid provided...
MinecraftConnection(const std::string &address="localhost", uint16_t port=MCPP_PORT)
Represents the main endpoint for interaction with the minecraft world.
Coordinate class.
Namespace containing all the the mcpp library classes.
Definition block.h:10
const uint16_t MCPP_PORT
Definition mcpp.h:26
Definition chunk.h:13
Height-agnostic coordinate class.
Definition coordinate.h:107
Definition coordinate.h:17
Definition heightmap.h:13