mcpp
C++ Minecraft Library
mcpp::MinecraftConnection Class Reference

#include <mcpp.h>

Public Member Functions

 MinecraftConnection (const std::string &address="localhost", int port=4711)
 Represents the main endpoint for interaction with the minecraft world. More...
 
void postToChat (const std::string &message)
 Sends a message to the in-game chat, does not require a joined player. More...
 
void doCommand (const std::string &command)
 Performs an in-game minecraft command. Players have to exist on the server and should be server operators (default with ELCI) More...
 
void setPlayerPosition (const Coordinate &pos)
 Sets player pos (block pos of lower half of playermodel) to specified Coordinate. More...
 
Coordinate getPlayerPosition ()
 Returns a coordinate representing player position (block pos of lower half of playermodel) More...
 
void setPlayerTilePosition (const Coordinate &tile)
 Sets player position to be one above specified tile (i.e. tile = block player is standing on) More...
 
Coordinate getPlayerTilePosition ()
 Returns the coordinate location of the block the player is standing on. More...
 
void setBlock (const Coordinate &loc, const BlockType &blockType)
 Sets block at Coordinate loc to the BlockType specified by blockType. More...
 
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 by the Coordinate loc1 and loc2. More...
 
BlockType getBlock (const Coordinate &loc)
 Returns BlockType object from the specified Coordinate loc with modifier. More...
 
Chunk getBlocks (const Coordinate &loc1, const Coordinate &loc2)
 Returns a 3D vector of the BlockTypes of the requested cuboid with modifiers. More...
 
int getHeight (int x, int z)
 Returns the height of the specific provided x and y coordinate. More...
 
const HeightMap getHeights (const Coordinate &loc1, const Coordinate &loc2)
 Provides a scaled option of the getHeight call to allow for considerable performance gains. More...
 

Constructor & Destructor Documentation

◆ MinecraftConnection()

mcpp::MinecraftConnection::MinecraftConnection ( const std::string &  address = "localhost",
int  port = 4711 
)
explicit

Represents the main endpoint for interaction with the minecraft world.

Parameters
addressString address in IPV4 format, defaults to "localhost"
portInteger port to run on, defaults to 4711 as that is the port for ELCI

Member Function Documentation

◆ doCommand()

void mcpp::MinecraftConnection::doCommand ( const std::string &  command)

Performs an in-game minecraft command. Players have to exist on the server and should be server operators (default with ELCI)

Parameters
commandCommand string in the in-game format (e.g. "time set day")

◆ getBlock()

BlockType mcpp::MinecraftConnection::getBlock ( const Coordinate loc)

Returns BlockType object from the specified Coordinate loc with modifier.

Parameters
loc
Returns
BlockType of the requested block

◆ getBlocks()

Chunk mcpp::MinecraftConnection::getBlocks ( const Coordinate loc1,
const Coordinate loc2 
)

Returns a 3D vector of the BlockTypes of the requested cuboid with modifiers.

Parameters
loc11st corner of the cuboid
loc22nd corner of the cuboid
Returns
Chunk containing the blocks in the specified area.

◆ getHeight()

int mcpp::MinecraftConnection::getHeight ( int  x,
int  z 
)

Returns the height of the specific provided x and y coordinate.

IMPORTANT: DO NOT USE FOR LARGE AREAS, IT WILL BE VERY SLOW USE getHeights() INSTEAD

Gets the y-value of the highest non-air block at the specified (x, z) coordinate.

Parameters
x
z
Returns
Returns the integer y-height at the requested coordinate.

◆ getHeights()

const HeightMap mcpp::MinecraftConnection::getHeights ( const Coordinate loc1,
const Coordinate loc2 
)

Provides a scaled option of the getHeight call to allow for considerable performance gains.

USE THIS instead of getHeight in a for loop.
Parameters
loc1
loc2
Returns
Returns a vector of integers representing the 2D area of heights.

◆ getPlayerPosition()

Coordinate mcpp::MinecraftConnection::getPlayerPosition ( )

Returns a coordinate representing player position (block pos of lower half of playermodel)

Returns
Coordinate of location

◆ getPlayerTilePosition()

Coordinate mcpp::MinecraftConnection::getPlayerTilePosition ( )

Returns the coordinate location of the block the player is standing on.

Returns
Coordinate of location

◆ postToChat()

void mcpp::MinecraftConnection::postToChat ( const std::string &  message)

Sends a message to the in-game chat, does not require a joined player.

Parameters
message

◆ setBlock()

void mcpp::MinecraftConnection::setBlock ( const Coordinate loc,
const BlockType blockType 
)

Sets block at Coordinate loc to the BlockType specified by blockType.

Parameters
loc
blockType

◆ setBlocks()

void mcpp::MinecraftConnection::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 by the Coordinate loc1 and loc2.

Parameters
loc1
loc2
blockType

◆ setPlayerPosition()

void mcpp::MinecraftConnection::setPlayerPosition ( const Coordinate pos)

Sets player pos (block pos of lower half of playermodel) to specified Coordinate.

Parameters
posCoordinate to set

◆ setPlayerTilePosition()

void mcpp::MinecraftConnection::setPlayerTilePosition ( const Coordinate tile)

Sets player position to be one above specified tile (i.e. tile = block player is standing on)

Parameters
tileCoordinate to set

The documentation for this class was generated from the following file: