Download Nodeflow — Minecraft Mods — MetaMods
Nodeflow

Nodeflow

Active

Downloads

0

Last update

4 months ago

Versions

1.20.2 — 1.21.6
Client
Fabric
Quilt
Libraries

Nodeflow

Nodeflow is a library for creating graph-based programming interfaces in Minecraft that works on the Fabric modloader.

Getting Started

To connect the library, add a dependency via JitPack. You can also use Maven from Modrinth, but in this case you may need to additionally add a dependency on Mixin Extras.

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.mattidragon:nodeflow:$nodeflow_version'
}

The first step is to create a GraphEnvironment. Most mods will only need one such environment, but if the set of available nodes changes, you can create a new one as needed.

public static final GraphEnvironment ENVIRONMENT = GraphEnvironment.builder()
        // Adds context needed for nodes to execute. Remains unchanged during each evaluation
        .addContextTypes(ContextType.SERVER_WORLD, ContextType.BLOCK_POS, ContextType.SERVER)
        // Data types that are allowed to be used. Needed for nodes that can work with any data type to know which ones are allowed
        .addDataTypes(DataType.BOOLEAN, DataType.NUMBER, DataType.STRING)
        // Adds groups of nodes. Also used for grouping in the editor
        .addNodeGroups(new TagNodeGroup(NodeGroup.MATH), new TagNodeGroup(NodeGroup.ADVANCED_MATH), new TagNodeGroup(NodeGroup.LOGIC), new TagNodeGroup(ModNodeTypes.REDSTONE_GROUP))
        // Adds individual nodes. They will be placed in the "miscellaneous" group
        .addNodeTypes(NodeType.TIME)
        .build();

Using this environment, you can create an EditorScreen, although the base class is usually not used directly.

If you use a block entity to store code, it can implement the GraphProvidingBlockEntity interface in addition to extending BlockEntity. This interface already implements ExtendedScreenHandlerFactory, so all you need to do is open the screen from the block entity. Nodeflow will automatically handle graph synchronization when changes occur.

If the graph is not stored in a block, you can create a subclass of EditorScreen and handle synchronization yourself (or not do it if the work is entirely client-side).

Detailed documentation and a wiki may appear in the future.

Project members
MattiDragon

MattiDragon

Developer

Created: 5 Oct 2023

ID: 5308