GithubHelp home page GithubHelp logo

mightypirates / markdownmanual Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 3.0 561 KB

Library Minecraft mod for adding in-game documentation.

Home Page: https://www.curseforge.com/minecraft/mc-mods/markdownmanual

License: Other

Java 100.00%
minecraft mod forge library fabric neoforge

markdownmanual's Introduction

MarkdownManual

MarkdownManual is a library mod for Minecraft that allows painless definition of in-game manuals backed by Markdown documents.

License / Use in Modpacks

This mod is licensed under the MIT license. All assets are public domain, unless otherwise stated; all are free to be distributed as long as the license / source credits are kept. This means you can use this mod in any mod pack as you please. I'd be happy to hear about you using it, though, just out of curiosity.

Usage

In general, please refer to the API, everything you need to know should be explained in the Javadoc of the API classes and interfaces.

Defining a new manual

To define a new manual, create an instance of Manual and register it with the manual registry. For convenience, the location of this registry is available in the Constants class.

final DeferredRegister<ManualModel> MANUALS = DeferredRegister.create("your_mod_id", Constants.MANUAL_REGISTRY);
final RegistrySupplier<ManualModel> MANUAL = MANUALS.register("your_manual", Manual::new);

To get content into the newly created manual, you'll want to add a DocumentProvider. A simple setup just needs to add single NamespaceDocumentProvider for the current mod, e.g.:

final DeferredRegister<DocumentProvider> DOCUMENT_PROVIDERS = DeferredRegister.create("your_mod_id", Constants.DOCUMENT_PROVIDER_REGISTRY);
final RegistrySupplier<DocumentProvider> DOCUMENT_PROVIDER = MANUALS.register("your_document_provider", () ->
    new NamespaceDocumentProvider("your_mod_id", "doc"));

Where doc is a path in your mod's assets, in this case your directory structure would be like this:

your_mod_dev_dir
|-+ src
  |-+ main
    | ...
  |-+ resources
    |-+ assets
      |-+ your_mod_id
        |-+ doc
          |-+ en_us
            |-  index.md
            | ...

Usually you'll then also want to add an item representing this manual in the game. For a simple setup, subclass the AbstractManualItem and return the ManualModel created above in getManualModel. This will provide you with a default UI, as well. To customize the UI, see below.

Defining content

The contents of manuals are regular Markdown pages. Manual rendering only supports a basic subset of markdown, including header scaling, italic, bold, monospace and lists.

It also supports links to other manual pages and has basic support for image rendering. They must explicitly use the texture protocol. Rendering blocks and items is also possible using the block and item protocols.

Examples:

![Image tooltip](texture:example.png)
![Tooltip for furnace block](block:minecraft:furnace)
![Tooltip for TIS-3D casing item](item:tis3d:casing)

Mods may also add additional custom content rendering. For example, you could add a content renderer that renders recipes, if you were so inclined.

Extending an existing manual

To extend an existing manual, register providers that match the manual to extend. For example, implement a DocumentProvider and override the matches(ManualModel) method to return true for the manual to add content for. By default, providers will only match manuals defined in the same namespace as themselves, i.e., defined by the same mod, as this is usually the desired behavior.

Adding tabs

To add additional entry points next to the manual (tabs), follow the same basic procedure as when extending a manual with any other provider. Simply register a new Tab implementation with the tab registry.

Changing the manual UI

When using the AbstractManualItem or using the ShowManualScreenEvent the built-in manual screen implementation is used. This implementation can be styled using implementations of the ManualStyle and ManualScreenStyle interfaces. These allow changing textures used in the screen (background, tab, scroll bar) as well as changing content rendering parameters such as fonts, text color and so on.

To use a completely customized manual screen, you'll want to override AbstractManualItem.showManualScreen() or use a custom item. In this case you'll need to query content from the ManualModel and use the Document class directly. See the implementation of the default ManualScreen for details on its usage.

Gradle

To add a dependency to this mod for use in your mod, add the following to your build.gradle:

repositories {
    exclusiveContent {
        forRepository { maven("https://cursemaven.com") }
        filter { includeGroup("curse.maven") }
    }
}
dependencies {
    // Forge via ForgeGradle
    implementation(fg.deobf("curse.maven:markdownmanual-502485:4713960"))
    // Fabric via Loom
    modImplementation("curse.maven:markdownmanual-502485:4713962")
}

markdownmanual's People

Contributors

esotericist avatar fnuecke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

markdownmanual's Issues

Readme is outdated

This mod seams very useful, but the Readme is outdated (it is 2 years old, so it makes sense). It is filled with broken links and contains code with classes which doesn't exist anymore. It would be appreciated if someone can update it or provide a simple example.

Sort order does not appear to impact tab order

Minecraft version: 1.18.2
Markdown Manual version: 1.2.1+59006bb

I would expect that overriding sortOrder for an instance of Tab would have any impact on its ordering on the left hand side of the manual, however despite overriding it to 0, 1, -1, Integer.MAX_VALUE, and Integer.MIN_VALUE, the tab I am adding to the TIS-3D Reference Manual always appears on the top instead of the bottom.

Support for Markdown tables

In my testing I've discovered that Markdown Manual does not render markdown tables. This feature would be very useful.

fabric version is literally just not working

unsure if its a fabric or fabric api version compatibility problem or whatever but having tested on both 1.19.2 and 1.20.1, it consistently crashes and going by a reply bumping a closed issue, this has been the case since at least december 2023

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.