mcpp
C++ Minecraft Library
mcpp.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "block.h"
4 #include "connection.h"
5 #include "util.h"
6 #include <memory>
7 #include <string_view>
8 #include <vector>
9 
22 namespace mcpp {
24  private:
26  std::unique_ptr<SocketConnection> conn;
27 
28  public:
37  explicit MinecraftConnection(const std::string& address = "localhost",
38  int port = 4711);
39 
46  void postToChat(const std::string& message);
47 
54  void doCommand(const std::string& command);
55 
62  void setPlayerPosition(const Coordinate& pos);
63 
71 
78  void setPlayerTilePosition(const Coordinate& tile);
79 
87 
95  void setBlock(const Coordinate& loc, const BlockType& blockType);
96 
105  void setBlocks(const Coordinate& loc1, const Coordinate& loc2,
106  const BlockType& blockType);
107 
116 
125  Chunk getBlocks(const Coordinate& loc1, const Coordinate& loc2);
126 
140  int getHeight(int x, int z);
141 
152  const HeightMap getHeights(const Coordinate& loc1, const Coordinate& loc2);
153 };
154 } // namespace mcpp
BlockType class.
Definition: block.h:10
Definition: mcpp.h:23
void setPlayerTilePosition(const Coordinate &tile)
Sets player position to be one above specified tile (i.e. tile = block player is standing on)
void setBlocks(const Coordinate &loc1, const Coordinate &loc2, const BlockType &blockType)
Sets a cuboid of blocks to the specified BlockType blockType, with the corners of the cuboid provided...
Coordinate getPlayerTilePosition()
Returns the coordinate location of the block the player is standing on.
void setPlayerPosition(const Coordinate &pos)
Sets player pos (block pos of lower half of playermodel) to specified Coordinate.
void setBlock(const Coordinate &loc, const BlockType &blockType)
Sets block at Coordinate loc to the BlockType specified by blockType.
const HeightMap getHeights(const Coordinate &loc1, const Coordinate &loc2)
Provides a scaled option of the getHeight call to allow for considerable performance gains.
BlockType getBlock(const Coordinate &loc)
Returns BlockType object from the specified Coordinate loc with modifier.
Coordinate getPlayerPosition()
Returns a coordinate representing player position (block pos of lower half of playermodel)
int getHeight(int x, int z)
Returns the height of the specific provided x and y coordinate.
void doCommand(const std::string &command)
Performs an in-game minecraft command. Players have to exist on the server and should be server opera...
Chunk getBlocks(const Coordinate &loc1, const Coordinate &loc2)
Returns a 3D vector of the BlockTypes of the requested cuboid with modifiers.
MinecraftConnection(const std::string &address="localhost", int port=4711)
Represents the main endpoint for interaction with the minecraft world.
void postToChat(const std::string &message)
Sends a message to the in-game chat, does not require a joined player.
SocketConnection class.
Namespace containing all the the mcpp library classes.
Definition: block.h:9
Definition: util.h:96
Definition: util.h:18
Definition: util.h:255
Coordinate class.