public final class ManualAPI
extends java.lang.Object
It allows opening the manual at a desired specific page, as well as registering custom tabs and content callback handlers.
Note: this is a client side only API. It will do nothing on dedicated servers (i.e. API.manual will be null).
| Modifier and Type | Method and Description |
|---|---|
static void |
addProvider(ContentProvider provider)
Register a content provider.
|
static void |
addProvider(PathProvider provider)
Register a path provider.
|
static void |
addProvider(java.lang.String prefix,
ImageProvider provider)
Register an image provider.
|
static void |
addTab(TabIconRenderer renderer,
java.lang.String tooltip,
java.lang.String path)
Register a tab to be displayed next to the manual.
|
static java.lang.Iterable<java.lang.String> |
contentFor(java.lang.String path)
Get the content of the documentation page at the specified location.
|
static ImageRenderer |
imageFor(java.lang.String path)
Get the image renderer for the specified image path.
|
static void |
navigate(java.lang.String path)
Navigate to a page in the manual.
|
static void |
openFor(net.minecraft.entity.player.PlayerEntity player)
Open the manual for the specified player.
|
static java.lang.String |
pathFor(net.minecraft.item.ItemStack stack)
Look up the documentation path for the specified item stack.
|
static java.lang.String |
pathFor(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos)
Look up the documentation for the specified block in the world.
|
static void |
reset()
Reset the history of the manual.
|
public static void addTab(TabIconRenderer renderer, java.lang.String tooltip, java.lang.String path)
These are intended to link to index pages, and for the time being there a relatively low number of tabs that can be displayed, so I'd ask you to only register as many tabs as actually, technically *needed*. Which will usually be one, for your main index page.
renderer - the renderer used to render the icon on your tab.tooltip - the unlocalized tooltip of the tab, or null.path - the path to the page to open when the tab is clicked.public static void addProvider(PathProvider provider)
Path providers are used to find documentation entries for item stacks and blocks in the world.
provider - the provider to register.public static void addProvider(ContentProvider provider)
Content providers are used to resolve paths to page content, if the standard system (using Minecraft's resource loading facilities) fails.
This can be useful for providing dynamic content, for example.
provider - the provider to register.public static void addProvider(java.lang.String prefix,
ImageProvider provider)
Image providers are used to render custom content in a page. These are selected via the standard image tag of Markdown, based on the prefix of the image URL, i.e.  will select the image provider registered for the prefix prefix, and pass to it the argument data, then use the returned renderer to draw an element in the place of the tag. The provided prefix is expected to be without the colon (:).
Custom providers are only selected if a prefix is matched, otherwise it'll treat it as a relative path to an image to load via Minecraft's resource providing facilities, and display that.
prefix - the prefix on which to use the provider.provider - the provider to register.@Nullable public static ImageRenderer imageFor(java.lang.String path)
This will look for ImageProviders registered for a prefix in the
specified path. If there is no match, or the matched content provider
does not provide a renderer, this will return null.
path - the path to the image to get the renderer for.@Nullable public static java.lang.String pathFor(net.minecraft.item.ItemStack stack)
stack - the stack to find the documentation path for.@Nullable
public static java.lang.String pathFor(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos)
world - the world containing the block.pos - the position of the block.@Nullable public static java.lang.Iterable<java.lang.String> contentFor(java.lang.String path)
path - the path of the page to get the content of.public static void openFor(net.minecraft.entity.player.PlayerEntity player)
If you wish to display a specific page, call navigate(String)
after this function returns, with the path to the page to show.
player - the player to open the manual for.public static void reset()
public static void navigate(java.lang.String path)
path - the path to navigate to.