endstone/map

Classes

NameDescription
MapCanvasRepresents a canvas for drawing to a map.
MapCursorRepresents a cursor on a map.
MapRendererRepresents a renderer for a map.
MapViewRepresents a map item.

classMapCanvas

Defined in <endstone/map/map_canvas.h>

Represents a canvas for drawing to a map.

Note

Each canvas is associated with a specific MapRenderer and represents that renderer's layer on the map.

Methods

NameDescription
~MapCanvas
getMapViewGet the map this canvas is attached to.
getCursorsGet the cursors associated with this canvas.
setCursorsSet the cursors associated with this canvas.
setPixelColorDraw a pixel to the canvas.
getPixelColorGet a pixel from the canvas.
getBasePixelColorGet a pixel from the layers below this canvas.
setPixelDraw a pixel to the canvas.
getPixelGet a pixel from the canvas.
getBasePixelGet a pixel from the layers below this canvas.
drawImageDraw an image to the map. The image will be clipped if necessary.

meth~MapCanvasvirtual

~MapCanvas() =default

methgetMapViewabstractconst

MapView& getMapView() const =0

Get the map this canvas is attached to.

Returns

TypeDescription
MapView&The MapView this canvas is attached to.

methgetCursorsabstractconst

std::vector<MapCursor> getCursors() const =0

Get the cursors associated with this canvas.

Returns

TypeDescription
std::vector<MapCursor>The MapCursorCollection associated with this canvas.

methsetCursorsabstract

void setCursors(const std::vector<MapCursor>& cursors) =0

Set the cursors associated with this canvas.

Parameters

NameTypeDescription
cursorsconst std::vector<MapCursor>&The MapCursorCollection to associate with this canvas.

methsetPixelColorabstract

void setPixelColor(int x, int y, Color color) =0

Draw a pixel to the canvas.

Parameters

NameTypeDescription
xintThe x coordinate, from 0 to 127.
yintThe y coordinate, from 0 to 127.
colorColorThe color

methgetPixelColorabstractconst

Color getPixelColor(int x, int y) const =0

Get a pixel from the canvas.

Parameters

NameTypeDescription
xintThe x coordinate, from 0 to 127.
yintThe y coordinate, from 0 to 127.

Returns

TypeDescription
ColorThe color

methgetBasePixelColorabstractconst

Color getBasePixelColor(int x, int y) const =0

Get a pixel from the layers below this canvas.

Parameters

NameTypeDescription
xintThe x coordinate, from 0 to 127.
yintThe y coordinate, from 0 to 127.

Returns

TypeDescription
ColorThe color

methsetPixelabstract

void setPixel(int x, int y, std::uint32_t color) =0

Draw a pixel to the canvas.

Parameters

NameTypeDescription
xintThe x coordinate, from 0 to 127.
yintThe y coordinate, from 0 to 127.
colorstd::uint32_tThe color.

methgetPixelabstractconst

std::uint32_t getPixel(int x, int y) const =0

Get a pixel from the canvas.

Parameters

NameTypeDescription
xintThe x coordinate, from 0 to 127.
yintThe y coordinate, from 0 to 127.

Returns

TypeDescription
std::uint32_tThe color.

methgetBasePixelabstractconst

std::uint32_t getBasePixel(int x, int y) const =0

Get a pixel from the layers below this canvas.

Parameters

NameTypeDescription
xintThe x coordinate, from 0 to 127.
yintThe y coordinate, from 0 to 127.

Returns

TypeDescription
std::uint32_tThe color.

methdrawImageabstract

void drawImage(int x, int y, const Image& image) =0

Draw an image to the map. The image will be clipped if necessary.

Parameters

NameTypeDescription
xintThe x coordinate of the image.
yintThe y coordinate of the image.
imageconst Image&The Image to draw.

classMapCursor

Defined in <endstone/map/map_cursor.h>

Represents a cursor on a map.

Enums

NameDescription
TypeRepresents the standard types of map cursors.

Methods

NameDescription
MapCursorInitialize the map cursor.
getXGet the X position of this cursor.
getYGet the Y position of this cursor.
getDirectionGet the direction of this cursor.
getTypeGet the type of this cursor.
isVisibleGet the visibility status of this cursor.
setXSet the X position of this cursor.
setYSet the Y position of this cursor.
setDirectionSet the direction of this cursor.
setTypeSet the type of this cursor.
setVisible
getCaptionGets the caption on this cursor.
setCaptionSets the caption on this cursor.

enumType

Type

Represents the standard types of map cursors.

Values

NameValueDescription
Player0
Frame1
RedMarker2
BlueMarker3
TargetX4
TargetPoint5
PlayerOffMap6
SignMarker7
PinkMarker8
OrangeMarker9
YellowMarker10
CyanMarker11
GreenPoint12
PlayerOffLimits13
Mansion14
Monument15
VillageDesert17
VillagePlains18
VillageSavanna19
VillageSnowy20
VillageTaiga21
JungleTemple22
SwampHut23
TrialChambers24

methMapCursor

MapCursor(std::int8_t x, std::int8_t y, std::int8_t direction, Type type, bool visible, std::string caption = "")

Initialize the map cursor.

Parameters

NameTypeDescription
xstd::int8_tThe x coordinate, from -128 to 127.
ystd::int8_tThe y coordinate, from -128 to 127.
directionstd::int8_tThe facing of the cursor, from 0 to 15.
typeTypeThe type (color/style) of the map cursor.
visibleboolWhether the cursor is visible by default.
captionstd::stringcursor caption

methgetXconst

std::int8_t getX() const

Get the X position of this cursor.

Returns

TypeDescription
std::int8_tThe X coordinate.

methgetYconst

std::int8_t getY() const

Get the Y position of this cursor.

Returns

TypeDescription
std::int8_tThe Y coordinate.

methgetDirectionconst

std::int8_t getDirection() const

Get the direction of this cursor.

Returns

TypeDescription
std::int8_tThe facing of the cursor, from 0 to 15.

methgetTypeconst

Type getType() const

Get the type of this cursor.

Returns

TypeDescription
TypeThe type (color/style) of the map cursor.

methisVisibleconst

bool isVisible() const

Get the visibility status of this cursor.

Returns

TypeDescription
boolTrue if visible, false otherwise.

methsetX

void setX(const std::int8_t x)

Set the X position of this cursor.

Parameters

NameTypeDescription
xconst std::int8_tThe X coordinate.

methsetY

void setY(const std::int8_t y)

Set the Y position of this cursor.

Parameters

NameTypeDescription
yconst std::int8_tThe Y coordinate.

methsetDirection

void setDirection(std::int8_t direction)

Set the direction of this cursor.

Parameters

NameTypeDescription
directionstd::int8_tThe facing of the cursor, from 0 to 15.

methsetType

void setType(Type type)

Set the type of this cursor.

Parameters

NameTypeDescription
typeTypeThe type (color/style) of the map cursor.

methsetVisible

void setVisible(bool visible)

Set the visibility status of this cursor.

Parameters

NameTypeDescription
visibleboolTrue if visible.

methgetCaptionconst

std::string getCaption() const

Gets the caption on this cursor.

Returns

TypeDescription
std::stringcaption

methsetCaption

void setCaption(std::string caption)

Sets the caption on this cursor.

Parameters

NameTypeDescription
captionstd::stringnew caption

classMapRenderer

Defined in <endstone/map/map_renderer.h>

Represents a renderer for a map.

Methods

NameDescription
MapRendererInitialize the map renderer base with the given contextual status.
~MapRenderer
isContextualGet whether the renderer is contextual, i.e. has different canvases for different players.
initializeInitialize this MapRenderer for the given map.
renderRender to the given map.

methMapRendererexplicit

MapRenderer(const bool is_contextual = false)

Initialize the map renderer base with the given contextual status.

Parameters

NameTypeDescription
is_contextualconst boolWhether the renderer is contextual. See isContextual().

meth~MapRenderervirtual

~MapRenderer() =default

methisContextualconst

bool isContextual() const

Get whether the renderer is contextual, i.e. has different canvases for different players.

Returns

TypeDescription
booltrue if contextual, false otherwise.

methinitializevirtual

void initialize(MapView& map)

Initialize this MapRenderer for the given map.

Parameters

NameTypeDescription
mapMapView&The MapView being initialized.

methrenderabstract

void render(MapView& map, MapCanvas& canvas, Player& player) =0

Render to the given map.

Parameters

NameTypeDescription
mapMapView&The MapView being rendered to.
canvasMapCanvas&The canvas to use for rendering.
playerPlayer&The player who triggered the rendering.

classMapView

Defined in <endstone/map/map_view.h>

Represents a map item.

Enums

NameDescription
ScaleAn enum representing all possible scales a map can be set to.

Methods

NameDescription
~MapView
getIdGet the ID of this map item for use with MapMeta.
isVirtualCheck whether this map is virtual.
getScaleGet the scale of this map.
setScaleSet the scale of this map.
getCenterXGet the center X position of this map.
getCenterZGet the center Z position of this map.
setCenterXSet the center X position of this map.
setCenterZSet the center Z position of this map.
getDimensionGet the dimension that this map is associated with.
setDimensionSet the dimension that this map is associated with.
getRenderersGet a list of MapRenderers currently in effect.
addRendererAdd a renderer to this map.
removeRendererRemove a renderer from this map.
isUnlimitedTrackingWhether the map will show a smaller position cursor (true), or no position cursor (false) when cursor is outside of map's range.
setUnlimitedTrackingWhether the map will show a smaller position cursor (true), or no position cursor (false) when cursor is outside of map's range.
isLockedGets whether the map is locked or not. A locked map may not be explored further.
setLockedSets whether the map is locked or not. A locked map may not be explored further.

enumScale

uint8_t Scale

An enum representing all possible scales a map can be set to.

Values

NameValueDescription
Closest0
Close1
Normal2
Far3
Farthest4

meth~MapViewvirtual

~MapView() =default

methgetIdabstractconst

std::int64_t getId() const =0

Get the ID of this map item for use with MapMeta.

Returns

TypeDescription
std::int64_tThe unique ID of the map.

methisVirtualabstractconst

bool isVirtual() const =0

Check whether this map is virtual.

A map is virtual if its lowermost MapRenderer is plugin-provided.

Returns

TypeDescription
boolTrue if the map is virtual.

methgetScaleabstractconst

Scale getScale() const =0

Get the scale of this map.

Returns

TypeDescription
ScaleThe scale of the map.

methsetScaleabstract

void setScale(Scale scale) =0

Set the scale of this map.

Parameters

NameTypeDescription
scaleScaleThe scale to set.

methgetCenterXabstractconst

int getCenterX() const =0

Get the center X position of this map.

Returns

TypeDescription
intThe center X position.

methgetCenterZabstractconst

int getCenterZ() const =0

Get the center Z position of this map.

Returns

TypeDescription
intThe center Z position.

methsetCenterXabstract

void setCenterX(int x) =0

Set the center X position of this map.

Parameters

NameTypeDescription
xintThe center X position.

methsetCenterZabstract

void setCenterZ(int z) =0

Set the center Z position of this map.

Parameters

NameTypeDescription
zintThe center Z position.

methgetDimensionabstractconst

Dimension* getDimension() const =0

Get the dimension that this map is associated with.

Returns

TypeDescription
Dimension*Pointer to the World this map is associated with, or nullptr.

methsetDimensionabstract

void setDimension(const Dimension& dimension) =0

Set the dimension that this map is associated with.

Parameters

NameTypeDescription
dimensionconst Dimension&The Dimension to associate this map with.

methgetRenderersabstractconst

std::vector<std::shared_ptr<MapRenderer>> getRenderers() const =0

Get a list of MapRenderers currently in effect.

Returns

TypeDescription
std::vector<std::shared_ptr<MapRenderer>>A list of references to each MapRenderer.

methaddRendererabstract

void addRenderer(std::shared_ptr<MapRenderer> renderer) =0

Add a renderer to this map.

Parameters

NameTypeDescription
rendererstd::shared_ptr<MapRenderer>The MapRenderer to add.

methremoveRendererabstract

bool removeRenderer(const std::shared_ptr<MapRenderer>& renderer) =0

Remove a renderer from this map.

Parameters

NameTypeDescription
rendererconst std::shared_ptr<MapRenderer>&The MapRenderer to remove.

Returns

TypeDescription
boolTrue if the renderer was successfully removed.

methisUnlimitedTrackingabstractconst

bool isUnlimitedTracking() const =0

Whether the map will show a smaller position cursor (true), or no position cursor (false) when cursor is outside of map's range.

Returns

TypeDescription
boolTrue if unlimited tracking is enabled.

methsetUnlimitedTrackingabstract

void setUnlimitedTracking(bool unlimited) =0

Whether the map will show a smaller position cursor (true), or no position cursor (false) when cursor is outside of map's range.

Parameters

NameTypeDescription
unlimitedboolTrue to enable unlimited tracking.

methisLockedabstractconst

bool isLocked() const =0

Gets whether the map is locked or not. A locked map may not be explored further.

Returns

TypeDescription
boolTrue if the map is locked.

methsetLockedabstract

void setLocked(bool locked) =0

Sets whether the map is locked or not. A locked map may not be explored further.

Parameters

NameTypeDescription
lockedboolTrue to lock the map.

On this page