-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This wiki is work in-progress, for now follow the steps below and use the javadoc provided with the mod sources to use the API.
In your mod initializer add:
MapMarker myMapMarkerType = PinLib.createDynamicMapMarker(new Identifier("<MODID>", "myMapMarker"));
You could use PinLib.createStaticMapMarker(...)
if you wish to create a static map marker (doesn't automatically update if the player destroys/renames the block).
0.1.3 and below (Deprecated since 0.2.0)
Implement IMapMarkedBlock
in your Block
class and override
method getCustomMarker()
to return your custom map marker type (make sure to store it in a static field).
Use PinLib.registerMapMarkedBlock(...)
method to register your block as a map marked block.
PinLib.registerMapMarkedBlock(
BLOCK,
() -> myMapMarkerType, // You could use PinLib.getDefaultMarker()
(world, pos) -> 0xFFFFFFFFL, // Icon color, ARGB format.
(world, pos) -> 0xFFFFFFFFL, // Text color.
// Use net.minecraft.util.math.ColorHelper.Argb.getArgb(alpha, red, green, blue) to get a long number from 4 argb values.
(world, pos) -> Text.literal("Hello world!").setStyle(Style.Empty) // Or null.
// setStyle() is used because the game loads an empty style from NBT data after saving and loading
// a map marker even if there was no style, forcing the map marker to update even when it shouldn't.
);
MAKE SURE to register your block before registering it as a map marked block, otherwise it will register the provided methods for air block since it's the default entry in minecraft's block registery.
world
and pos
parameters can be used to get the BlockState
of your block
if you want the map marker to display differently based on a block's state.
The above only applies automatically on a dynamic map marker if the state changes,
static map markers never change unless explicitly specified.