public final class ManualDefinitionImpl extends java.lang.Object implements ManualDefinition
| Modifier and Type | Class and Description |
|---|---|
static class |
ManualDefinitionImpl.History |
static class |
ManualDefinitionImpl.Tab |
| Modifier and Type | Field and Description |
|---|---|
static ManualDefinitionImpl |
INSTANCE |
| Constructor and Description |
|---|
ManualDefinitionImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
addDefaultProviders()
Adds the default providers listed in the documentation.
|
void |
addProvider(ContentProvider provider)
Register a content provider.
|
void |
addProvider(PathProvider provider)
Register a path provider.
|
void |
addProvider(java.lang.String prefix,
ImageProvider provider)
Register an image provider.
|
void |
addTab(TabIconRenderer renderer,
java.lang.String tooltip,
java.lang.String path)
Register a tab to be displayed next to the manual.
|
java.lang.Iterable<java.lang.String> |
contentFor(java.lang.String path)
Get the content of the documentation page at the specified location.
|
int |
getHistorySize() |
java.util.List<ManualDefinitionImpl.Tab> |
getTabs() |
ImageRenderer |
imageFor(java.lang.String href)
Get the image renderer for the specified image path.
|
static java.lang.String |
makeRelative(java.lang.String path,
java.lang.String base)
Makes the specified path relative to the specified base path.
|
void |
navigate(java.lang.String path)
Navigate to a page in the manual.
|
void |
openFor(net.minecraft.entity.player.EntityPlayer player)
Open the manual for the specified player.
|
java.lang.String |
pathFor(net.minecraft.item.ItemStack stack)
Look up the documentation path for the specified item stack.
|
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.
|
int |
peekOffset()
Looks at the history path stack and returns the scroll offset of the
top entry.
|
java.lang.String |
peekPath()
Looks at the path at the top of this stack without removing it
from the stack.
|
void |
popPath()
Removes the path at the top of the stack
|
void |
pushPath(java.lang.String path)
Add a path to the history stack.
|
void |
reset()
Reset the history of the manual.
|
void |
setDefaultPage(java.lang.String defaultPage)
When created, the default page is `%LANGUAGE%/index.md`, use this to change that.
|
void |
setOffset(int offset)
Sets the scroll offset of the page on top of the history stack.
|
public static final ManualDefinitionImpl INSTANCE
public void addTab(TabIconRenderer renderer, @Nullable java.lang.String tooltip, java.lang.String path)
ManualDefinitionThese 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.
addTab in interface ManualDefinitionrenderer - 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 void addProvider(PathProvider provider)
ManualDefinitionPath providers are used to find documentation entries for item stacks and blocks in the world.
addProvider in interface ManualDefinitionprovider - the provider to register.public void addProvider(ContentProvider provider)
ManualDefinitionContent 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.
addProvider in interface ManualDefinitionprovider - the provider to register.public void addProvider(java.lang.String prefix,
ImageProvider provider)
ManualDefinitionImage 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.
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.
addProvider in interface ManualDefinitionprefix - the prefix on which to use the provider.provider - the provider to register.public void addDefaultProviders()
ManualDefinitionaddDefaultProviders in interface ManualDefinition@Nullable public java.lang.String pathFor(net.minecraft.item.ItemStack stack)
ManualDefinitionpathFor in interface ManualDefinitionstack - the stack to find the documentation path for.@Nullable
public java.lang.String pathFor(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos)
ManualDefinitionpathFor in interface ManualDefinitionworld - the world containing the block.pos - the position of the block.@Nullable public java.lang.Iterable<java.lang.String> contentFor(java.lang.String path)
ManualDefinitionThe provided path may contain the special variable %LANGUAGE%, which will be resolved to the currently set language, falling back to en_US.
contentFor in interface ManualDefinitionpath - the path of the page to get the content of.@Nullable public ImageRenderer imageFor(java.lang.String href)
ManualDefinition
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.
imageFor in interface ManualDefinitionhref - the path to the image to get the renderer for.public void openFor(net.minecraft.entity.player.EntityPlayer player)
ManualDefinition
If you wish to display a specific page, call ManualDefinition.navigate(String)
after this function returns, with the path to the page to show.
openFor in interface ManualDefinitionplayer - the player to open the manual for.public void reset()
ManualDefinitionreset in interface ManualDefinitionpublic void navigate(java.lang.String path)
ManualDefinitionnavigate in interface ManualDefinitionpath - the path to navigate to.public static java.lang.String makeRelative(java.lang.String path,
java.lang.String base)
path - the path to make relative.base - the path to make it relative to.public void setDefaultPage(java.lang.String defaultPage)
ManualDefinitionsetDefaultPage in interface ManualDefinitiondefaultPage - the new default page location.public int getHistorySize()
getHistorySize in interface ManualDefinitionpublic void pushPath(java.lang.String path)
ManualDefinitionpushPath in interface ManualDefinitionpath - the path to addpublic java.lang.String peekPath()
ManualDefinitionpeekPath in interface ManualDefinitionpublic int peekOffset()
ManualDefinitionpeekOffset in interface ManualDefinitionpublic void setOffset(int offset)
ManualDefinitionsetOffset in interface ManualDefinitionoffset - the scroll offset to set.public void popPath()
ManualDefinitionpopPath in interface ManualDefinitionpublic java.util.List<ManualDefinitionImpl.Tab> getTabs()