MCPcopy Create free account
hub / github.com/EndstoneMC/endstone / init_map

Function init_map

src/endstone/python/map.cpp:36–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34};
35
36void init_map(py::module_ &m)
37{
38 auto cursor = py::class_<MapCursor>(m, "MapCursor", "Represents a cursor on a map.");
39
40 py::native_enum<MapCursor::Type>(cursor, "Type", "enum.Enum", "Represents the standard types of map cursors.")
41 .value("PLAYER", MapCursor::Type::Player)
42 .value("FRAME", MapCursor::Type::Frame)
43 .value("RED_MARKER", MapCursor::Type::RedMarker)
44 .value("BLUE_MARKER", MapCursor::Type::BlueMarker)
45 .value("TARGET_X", MapCursor::Type::TargetX)
46 .value("TARGET_POINT", MapCursor::Type::TargetPoint)
47 .value("PLAYER_OFF_MAP", MapCursor::Type::PlayerOffMap)
48 .value("SIGN_MARKER", MapCursor::Type::SignMarker)
49 .value("PINK_MARKER", MapCursor::Type::PinkMarker)
50 .value("ORANGE_MARKER", MapCursor::Type::OrangeMarker)
51 .value("YELLOW_MARKER", MapCursor::Type::YellowMarker)
52 .value("CYAN_MARKER", MapCursor::Type::CyanMarker)
53 .value("GREEN_POINT", MapCursor::Type::GreenPoint)
54 .value("PLAYER_OFF_LIMITS", MapCursor::Type::PlayerOffLimits)
55 .value("MANSION", MapCursor::Type::Mansion)
56 .value("MONUMENT", MapCursor::Type::Monument)
57 .value("VILLAGE_DESERT", MapCursor::Type::VillageDesert)
58 .value("VILLAGE_PLAINS", MapCursor::Type::VillagePlains)
59 .value("VILLAGE_SAVANNA", MapCursor::Type::VillageSavanna)
60 .value("VILLAGE_SNOWY", MapCursor::Type::VillageSnowy)
61 .value("VILLAGE_TAIGA", MapCursor::Type::VillageTaiga)
62 .value("JUNGLE_TEMPLE", MapCursor::Type::JungleTemple)
63 .value("SWAMP_HUT", MapCursor::Type::SwampHut)
64 .value("TRIAL_CHAMBERS", MapCursor::Type::TrialChambers)
65 .finalize();
66
67 cursor
68 .def(py::init<std::int8_t, std::int8_t, std::int8_t, MapCursor::Type, bool, std::string>(), py::arg("x"),
69 py::arg("y"), py::arg("direction"), py::arg("type"), py::arg("visible"), py::arg("caption") = "")
70 .def_property("x", &MapCursor::getX, &MapCursor::setX, "Get or set the X position of this cursor.")
71 .def_property("y", &MapCursor::getY, &MapCursor::setY, "Get or set the Y position of this cursor.")
72 .def_property("direction", &MapCursor::getDirection, &MapCursor::setDirection,
73 "Get or set the direction of this cursor")
74 .def_property("type", &MapCursor::getType, &MapCursor::setType, "Get or set the type of this cursor.")
75 .def_property("is_visible", &MapCursor::isVisible, &MapCursor::setVisible,
76 "Get or set the visibility statis of this cursor.")
77 .def_property("caption", &MapCursor::getCaption, &MapCursor::setCaption,
78 "Get or set the caption on this cursor.");
79
80 auto view = py::class_<MapView>(m, "MapView", "Represents a map item.");
81
82 py::class_<MapCanvas>(m, "MapCanvas",
83 "Represents a canvas for drawing to a map. Each canvas is associated with a specific "
84 "MapRenderer and represents that renderer's layer on the map.")
85 .def_property_readonly("map_view", &MapCanvas::getMapView, "Get the map this canvas is attached to.",
86 py::return_value_policy::reference)
87 .def_property("cursors", &MapCanvas::getCursors, &MapCanvas::setCursors,
88 "Get the cursorS associated with this canvas.")
89 .def("set_pixel_color", &MapCanvas::setPixelColor, py::arg("x"), py::arg("y"), py::arg("color"),
90 "Draw a pixel to the canvas.")
91 .def("get_pixel_color", &MapCanvas::getPixelColor, py::arg("x"), py::arg("y"), "Get a pixel from the canvas.")
92 .def("set_pixel", &MapCanvas::setPixel, py::arg("x"), py::arg("y"), py::arg("color"),
93 "Draw a pixel to the canvas.")

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls 1

valueMethod · 0.80

Tested by

no test coverage detected