Skip to content

Map

endstone.map

Classes relating to plugin handling of map displays.

Classes:

Name Description
MapCanvas

Represents a canvas for drawing to a map.

MapCursor

Represents a cursor on a map.

MapRenderer

Represents a renderer for a map.

MapView

Represents a map item.

MapCanvas

Represents a canvas for drawing to a map.

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

Methods:

Name Description
draw_image

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

get_pixel

Get a pixel from the canvas.

get_pixel_color

Get a pixel from the canvas.

set_pixel

Draw a pixel to the canvas.

set_pixel_color

Draw a pixel to the canvas.

Attributes:

Name Type Description
cursors list[MapCursor]

The cursors associated with this canvas.

map_view MapView

The MapView this canvas is attached to.

cursors property writable

cursors: list[MapCursor]

The cursors associated with this canvas.

map_view property

map_view: MapView

The MapView this canvas is attached to.

draw_image

draw_image(x: int, y: int, image: ndarray[uint8]) -> None

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

Parameters:

Name Type Description Default
x int

The x coordinate of the image.

required
y int

The y coordinate of the image.

required
image ndarray[uint8]

The Image to draw.

required

get_pixel

get_pixel(x: int, y: int) -> int

Get a pixel from the canvas.

Parameters:

Name Type Description Default
x int

The x coordinate, from 0 to 127.

required
y int

The y coordinate, from 0 to 127.

required

Returns:

Type Description
int

The color.

get_pixel_color

get_pixel_color(x: int, y: int) -> tuple[int, ...]

Get a pixel from the canvas.

Parameters:

Name Type Description Default
x int

The x coordinate, from 0 to 127.

required
y int

The y coordinate, from 0 to 127.

required

Returns:

Type Description
tuple[int, ...]

The color.

set_pixel

set_pixel(x: int, y: int, color: int) -> None

Draw a pixel to the canvas.

Parameters:

Name Type Description Default
x int

The x coordinate, from 0 to 127.

required
y int

The y coordinate, from 0 to 127.

required
color int

The color.

required

set_pixel_color

set_pixel_color(
    x: int, y: int, color: tuple[int, ...]
) -> None

Draw a pixel to the canvas.

Parameters:

Name Type Description Default
x int

The x coordinate, from 0 to 127.

required
y int

The y coordinate, from 0 to 127.

required
color tuple[int, ...]

The color.

required

MapCursor

MapCursor(
    x: int,
    y: int,
    direction: int,
    type: Type,
    visible: bool,
    caption: str = "",
)

Represents a cursor on a map.

Classes:

Name Description
Type

Represents the standard types of map cursors.

Attributes:

Name Type Description
caption str

The caption on this cursor.

direction int

The facing of the cursor, from 0 to 15.

is_visible bool

The visibility status of this cursor.

type Type

The type (color/style) of this map cursor.

x int

The X position of this cursor.

y int

The Y position of this cursor.

caption property writable

caption: str

The caption on this cursor.

direction property writable

direction: int

The facing of the cursor, from 0 to 15.

is_visible property writable

is_visible: bool

The visibility status of this cursor.

type property writable

type: Type

The type (color/style) of this map cursor.

x property writable

x: int

The X position of this cursor.

y property writable

y: int

The Y position of this cursor.

Type

Bases: Enum

Represents the standard types of map cursors.

Attributes:

Name Type Description
BLUE_MARKER
CYAN_MARKER
FRAME
GREEN_POINT
JUNGLE_TEMPLE
MANSION
MONUMENT
ORANGE_MARKER
PINK_MARKER
PLAYER
PLAYER_OFF_LIMITS
PLAYER_OFF_MAP
RED_MARKER
SIGN_MARKER
SWAMP_HUT
TARGET_POINT
TARGET_X
TRIAL_CHAMBERS
VILLAGE_DESERT
VILLAGE_PLAINS
VILLAGE_SAVANNA
VILLAGE_SNOWY
VILLAGE_TAIGA
YELLOW_MARKER
BLUE_MARKER class-attribute instance-attribute
BLUE_MARKER = 3
CYAN_MARKER class-attribute instance-attribute
CYAN_MARKER = 11
FRAME class-attribute instance-attribute
FRAME = 1
GREEN_POINT class-attribute instance-attribute
GREEN_POINT = 12
JUNGLE_TEMPLE class-attribute instance-attribute
JUNGLE_TEMPLE = 22
MANSION class-attribute instance-attribute
MANSION = 14
MONUMENT class-attribute instance-attribute
MONUMENT = 15
ORANGE_MARKER class-attribute instance-attribute
ORANGE_MARKER = 9
PINK_MARKER class-attribute instance-attribute
PINK_MARKER = 8
PLAYER class-attribute instance-attribute
PLAYER = 0
PLAYER_OFF_LIMITS class-attribute instance-attribute
PLAYER_OFF_LIMITS = 13
PLAYER_OFF_MAP class-attribute instance-attribute
PLAYER_OFF_MAP = 6
RED_MARKER class-attribute instance-attribute
RED_MARKER = 2
SIGN_MARKER class-attribute instance-attribute
SIGN_MARKER = 7
SWAMP_HUT class-attribute instance-attribute
SWAMP_HUT = 23
TARGET_POINT class-attribute instance-attribute
TARGET_POINT = 5
TARGET_X class-attribute instance-attribute
TARGET_X = 4
TRIAL_CHAMBERS class-attribute instance-attribute
TRIAL_CHAMBERS = 24
VILLAGE_DESERT class-attribute instance-attribute
VILLAGE_DESERT = 17
VILLAGE_PLAINS class-attribute instance-attribute
VILLAGE_PLAINS = 18
VILLAGE_SAVANNA class-attribute instance-attribute
VILLAGE_SAVANNA = 19
VILLAGE_SNOWY class-attribute instance-attribute
VILLAGE_SNOWY = 20
VILLAGE_TAIGA class-attribute instance-attribute
VILLAGE_TAIGA = 21
YELLOW_MARKER class-attribute instance-attribute
YELLOW_MARKER = 10

MapRenderer

MapRenderer(is_contextual: bool = False)

Represents a renderer for a map.

Initialize the map renderer base with the given contextual status.

Methods:

Name Description
initialize

Initialize this MapRenderer for the given map.

render

Render to the given map.

initialize

initialize(view: MapView) -> None

Initialize this MapRenderer for the given map.

Parameters:

Name Type Description Default
view MapView

The MapView being initialized.

required

render

render(
    view: MapView, canvas: MapCanvas, player: Player
) -> None

Render to the given map.

Parameters:

Name Type Description Default
view MapView

The MapView being rendered to.

required
canvas MapCanvas

The canvas to use for rendering.

required
player Player

The player who triggered the rendering.

required

MapView

Represents a map item.

Classes:

Name Description
Scale

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

Methods:

Name Description
add_renderer

Add a renderer to this map.

remove_renderer

Remove a renderer from this map.

Attributes:

Name Type Description
CLOSE
CLOSEST
FAR
FARTHEST
NORMAL
center_x int

The center X position of this map.

center_z int

The center Z position of this map.

dimension Dimension

The dimension that this map is associated with.

id int

The unique ID of this map item for use with MapMeta.

is_unlimited_tracking bool

Whether the map will show a smaller position cursor (True), or no position cursor (False) when cursor is

is_virtual bool

Whether this map is virtual.

locked bool

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

renderers list[MapRenderer]

A list of MapRenderers currently in effect.

scale Scale

The scale of this map.

CLOSE class-attribute instance-attribute

CLOSE = CLOSE

CLOSEST class-attribute instance-attribute

CLOSEST = CLOSEST

FAR class-attribute instance-attribute

FAR = FAR

FARTHEST class-attribute instance-attribute

FARTHEST = FARTHEST

NORMAL class-attribute instance-attribute

NORMAL = NORMAL

center_x property writable

center_x: int

The center X position of this map.

center_z property writable

center_z: int

The center Z position of this map.

dimension property writable

dimension: Dimension

The dimension that this map is associated with.

id property

id: int

The unique ID of this map item for use with MapMeta.

is_unlimited_tracking property writable

is_unlimited_tracking: bool

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

is_virtual property

is_virtual: bool

Whether this map is virtual.

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

locked property writable

locked: bool

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

renderers property

renderers: list[MapRenderer]

A list of MapRenderers currently in effect.

scale property writable

scale: Scale

The scale of this map.

Scale

Bases: IntEnum

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

Attributes:

Name Type Description
CLOSE
CLOSEST
FAR
FARTHEST
NORMAL
CLOSE class-attribute instance-attribute
CLOSE = 1
CLOSEST class-attribute instance-attribute
CLOSEST = 0
FAR class-attribute instance-attribute
FAR = 3
FARTHEST class-attribute instance-attribute
FARTHEST = 4
NORMAL class-attribute instance-attribute
NORMAL = 2

add_renderer

add_renderer(renderer: MapRenderer) -> None

Add a renderer to this map.

Parameters:

Name Type Description Default
renderer MapRenderer

The MapRenderer to add.

required

remove_renderer

remove_renderer(renderer: MapRenderer) -> bool

Remove a renderer from this map.

Parameters:

Name Type Description Default
renderer MapRenderer

The MapRenderer to remove.

required

Returns:

Type Description
bool

True if the renderer was successfully removed.