MJUtils

Quick rating

MJUtils

No reviews yet

Mod-lib for MJaroslav's mods.

No Theme
No Genre
API/Library
Mod Loaders
Forge
Minecraft

Community voices

Reviews

Versions
Loading versions…
Match includes

Click once to include, again to exclude, again to clear

Rating Any
Any 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
Min
Max
Play Status
Reviews
Time Played
hrs+
Verified developers only
Has developer response
List view
Grid view
Compact view
Sort by
Date
Rating
Helpful
Unhelpful
Edited
Sort ascending
Delete this review?

This removes your review from the project. You can write a new review after.

Review submitted for moderation

Your review has been sent to moderators, who will check that it meets our guidelines before it appears publicly.

No reviews yet. Be the first to review this project!

Get it on

Available Platforms

About

Project Details

Type
Mod
Latest Version
MJUtils 1.6.1
Authors

For authors

Embed Badge

If you're the author of this project, you can embed a live badge anywhere that supports HTML or Markdown. It updates automatically whenever ratings change.

Custom banner text
ModDex rating badge preview

Use HTML for any page that supports it, or Markdown for README files and Markdown-based descriptions.

Identifiers

Platform IDs

CurseForge ID

Resources

External Links

Source Issues Wiki Discord

About

Description

MJUtils

A set of tools to simplify writing mods. It contains a modular system for initialization of mods and a system of configurations by annotations.

The source code contains the documentation.

If you are using ResearchItemCopy, you must add the following dependency: "required-after:Thaumcraft;".

You can send a pull request if you find grammar errors.

 

Modular system examples

Add module and configuration handlers to the main mod class:

package your.path;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLConstructionEvent;
import mjaroslav.mcmods.mjutils.module.ModuleSystem;
import mjaroslav.mcmods.mjutils.module.AnnotationBasedConfiguration;

@Mod(modid = "your_modid", version = "0.0.0", name = "Module example mod")
public class ModExample {
    // Handler for annotation configurations.
    private static AnnotationBasedConfiguration config;
    // Handler for work with modules.
    private static ModuleSystem modSys;
    
    @EventHandler
    public void construct(FMLConstructionEvent event) {
        // The second argument is logger.
        config = new AnnotationBasedConfiguration("your_modid", null);
        // The third argument is a proxy.
        modSys = new ModuleSystem(MODID, config, null);
        // Find all modules and create their instances..
        modSys.initSystem(event);
    }
    
    // DON'F FORGET CALL ALL INITIALIZATION METHODS:
    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {
        modSys.preInit(event);
    }
    
    @EventHandler
    public void init(FMLInitializationEvent event) {
        modSys.init(event);
    }
    
    @EventHandler
    public void postInit(FMLPostInitializationEvent event) {
        modSys.postInit(event);
    }
}

 Now you can create simple module:

package your.path;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;
//import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import mjaroslav.mcmods.mjutils.module.Modular;
import mjaroslav.mcmods.mjutils.module.Module;

// All classes with Module annotation must implement the Modular
// interface.
@Module("your_modid")
public class ModuleExample implements Modular {
    @Override
    public void preInit(FMLPreInitializationEvent event) {
        System.out.println("Hi! I'm in pre init!");
    }
    
//    All interface methods that can be neglected contain the default
//    implementation: you can inherit them only when necessary.
//    
//    @Override
//    public void init(FMLInitializationEvent event) {
//        System.out.println("I'm ignored :c");
//    }
    
    @Override
    public void postInit(FMLPostInitializationEvent event) {
        System.out.println("Hi! I'm in post init!");
    }
}

 An example of creating an annotation configuration:

package your.path;

import mjaroslav.mcmods.mjutils.module.ConfigurationCategory;
import mjaroslav.mcmods.mjutils.module.ConfigurationProperty;

@ConfigurationCategory(modID = "your_modid", name = ConfigurationCategory.GENERAL_NAME,
        comment = ConfigurationCategory.GENERAL_COMMENT)
public class CategoryGeneral {
    @ConfigurationCategory(name = "subcategory")
    public static class SubCategory {
        @ConfigurationProperty(defaultBoolean = true)
        public static boolean test;

        @ConfigurationProperty(name = "test2", defaultInt = 1)
        public static int test1;
    }
    
    @ConfigurationProperty(defaultDouble = Math.E)
    public static double e;
}

 Use the documentation to find out more info about library usages.

Screenshots

Gallery

This project has no gallery images yet.

Versions

Files

Relations

Project Relations

More like this

Similar Mods

Suggestions use data such as tags, dependencies, dependents, descriptions, titles, and more to rank how much they overlap with this mod.

On ModDex

Community snapshot

0
Ratings
0
Followers
0
In stacks

By the numbers

Statistics

~55,000
Downloads
Last Updated
Created
Last synced
When ModDex last fetched this project from CurseForge or Modrinth. Every project is re-checked on a schedule, and any project that ships a new file is synced automatically within hours of the release.
New file updates sync automatically
How syncing works