mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-16 17:25:09 +01:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6e1a5e558 | ||
|
|
191120393c | ||
|
|
1be14dc3ac |
@@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
loader_version=0.14.6
|
loader_version=0.14.6
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 0.5.0
|
mod_version = 0.5.2
|
||||||
maven_group = eu.midnightdust
|
maven_group = eu.midnightdust
|
||||||
archives_base_name = midnightlib
|
archives_base_name = midnightlib
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,18 @@ import net.fabricmc.api.ClientModInitializer;
|
|||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||||
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
|
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MidnightLibClient implements ClientModInitializer {
|
public class MidnightLibClient implements ClientModInitializer {
|
||||||
|
public static List<String> hiddenMods = new ArrayList<>();
|
||||||
|
|
||||||
public static final String MOD_ID = "midnightlib";
|
public static final String MOD_ID = "midnightlib";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
MidnightConfig.init("midnightlib", MidnightLibConfig.class);
|
MidnightConfig.init("midnightlib", MidnightLibConfig.class);
|
||||||
|
hiddenMods.add("puzzle");
|
||||||
|
|
||||||
EntityModelLayerRegistry.registerModelLayer(WitchHatFeatureRenderer.WITCH_HAT_MODEL_LAYER, WitchHatFeatureRenderer::getTexturedModelData);
|
EntityModelLayerRegistry.registerModelLayer(WitchHatFeatureRenderer.WITCH_HAT_MODEL_LAYER, WitchHatFeatureRenderer::getTexturedModelData);
|
||||||
if (MidnightLibConfig.special_hats) HatLoader.init();
|
if (MidnightLibConfig.special_hats) HatLoader.init();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package eu.midnightdust.core;
|
package eu.midnightdust.core;
|
||||||
|
|
||||||
|
import eu.midnightdust.core.config.MidnightLibConfig;
|
||||||
import eu.midnightdust.lib.config.AutoCommand;
|
import eu.midnightdust.lib.config.AutoCommand;
|
||||||
import eu.midnightdust.lib.config.MidnightConfig;
|
import eu.midnightdust.lib.config.MidnightConfig;
|
||||||
import net.fabricmc.api.DedicatedServerModInitializer;
|
import net.fabricmc.api.DedicatedServerModInitializer;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package eu.midnightdust.core.screen;
|
package eu.midnightdust.core.screen;
|
||||||
|
|
||||||
|
import eu.midnightdust.core.MidnightLibClient;
|
||||||
|
import eu.midnightdust.core.config.MidnightLibConfig;
|
||||||
import eu.midnightdust.lib.config.MidnightConfig;
|
import eu.midnightdust.lib.config.MidnightConfig;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
@@ -31,9 +33,12 @@ public class MidnightConfigOverviewScreen extends Screen {
|
|||||||
this.list = new MidnightOverviewListWidget(this.client, this.width, this.height, 32, this.height - 32, 25);
|
this.list = new MidnightOverviewListWidget(this.client, this.width, this.height, 32, this.height - 32, 25);
|
||||||
if (this.client != null && this.client.world != null) this.list.setRenderBackground(false);
|
if (this.client != null && this.client.world != null) this.list.setRenderBackground(false);
|
||||||
this.addSelectableChild(this.list);
|
this.addSelectableChild(this.list);
|
||||||
MidnightConfig.configClass.forEach((modid, configClass) ->
|
MidnightConfig.configClass.forEach((modid, configClass) -> {
|
||||||
|
if (!MidnightLibClient.hiddenMods.contains(modid)) {
|
||||||
list.addButton(new ButtonWidget(this.width / 2 - 100, this.height - 28, 200, 20, Text.translatable(modid +".midnightconfig.title"), (button) ->
|
list.addButton(new ButtonWidget(this.width / 2 - 100, this.height - 28, 200, 20, Text.translatable(modid +".midnightconfig.title"), (button) ->
|
||||||
Objects.requireNonNull(client).setScreen(MidnightConfig.getScreen(this,modid)))));
|
Objects.requireNonNull(client).setScreen(MidnightConfig.getScreen(this,modid))));
|
||||||
|
}
|
||||||
|
});
|
||||||
super.init();
|
super.init();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,14 +2,13 @@ package eu.midnightdust.lib.config;
|
|||||||
|
|
||||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||||
|
import eu.midnightdust.core.MidnightLibClient;
|
||||||
import eu.midnightdust.core.config.MidnightLibConfig;
|
import eu.midnightdust.core.config.MidnightLibConfig;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class AutoModMenu implements ModMenuApi {
|
public class AutoModMenu implements ModMenuApi {
|
||||||
protected static List<String> hiddenMods = List.of();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||||
@@ -20,13 +19,10 @@ public class AutoModMenu implements ModMenuApi {
|
|||||||
public Map<String, ConfigScreenFactory<?>> getProvidedConfigScreenFactories() {
|
public Map<String, ConfigScreenFactory<?>> getProvidedConfigScreenFactories() {
|
||||||
HashMap<String, ConfigScreenFactory<?>> map = new HashMap<>();
|
HashMap<String, ConfigScreenFactory<?>> map = new HashMap<>();
|
||||||
MidnightConfig.configClass.forEach((modid, cClass) -> {
|
MidnightConfig.configClass.forEach((modid, cClass) -> {
|
||||||
if (!hiddenMods.contains(modid))
|
if (!MidnightLibClient.hiddenMods.contains(modid))
|
||||||
map.put(modid, parent -> MidnightConfig.getScreen(parent, modid));
|
map.put(modid, parent -> MidnightConfig.getScreen(parent, modid));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
public static void hideFromModMenu(String hiddenMod) {
|
|
||||||
hiddenMods.add(hiddenMod);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package eu.midnightdust.lib.config;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** MidnightConfig documentation & examples:
|
||||||
|
* Thanks for choosing MidnightConfig - the fancy, tiny and lightweight config library.
|
||||||
|
* If you want to use the lib in your mod, here are some examples and hints:
|
||||||
|
* Every option in a MidnightConfig class has to be public and static, so we can access it from other classes.
|
||||||
|
* The config class also has to extend MidnightConfig*/
|
||||||
|
|
||||||
|
public class MidnightConfigExample extends MidnightConfig {
|
||||||
|
|
||||||
|
@Comment public static Comment text1; // Comments are rendered like an option without a button and are excluded from the config file
|
||||||
|
@Entry public static int fabric = 16777215; // Example for a int option
|
||||||
|
@Entry public static double world = 1.4D; // Example for a double option
|
||||||
|
@Entry public static boolean showInfo = true; // Example for a boolean option
|
||||||
|
@Entry public static String name = "Hello World!"; // Example for a string option
|
||||||
|
@Entry public static TestEnum testEnum = TestEnum.FABRIC; // Example for a enum option
|
||||||
|
public enum TestEnum { // Enums allow the user to cycle through predefined options
|
||||||
|
QUILT, FABRIC
|
||||||
|
}
|
||||||
|
@Entry(min=69,max=420) public static int hello = 420; // - The entered number has to be larger than 69 and smaller than 420
|
||||||
|
@Entry(width = 7, min = 7, isColor = true, name = "I am a color!") public static String titleColor = "#ffffff"; // The isColor property adds a preview box for a hexadecimal color
|
||||||
|
@Entry(name = "I am an array list!") public static List<String> arrayList = List.of("String1", "String2"); // Array String Lists are also supported
|
||||||
|
// The name field can be used to specify a custom translation string or plain text
|
||||||
|
|
||||||
|
public static int imposter = 16777215; // - Entries without an @Entry or @Comment annotation are ignored
|
||||||
|
|
||||||
|
/*
|
||||||
|
The .json language file for your config class could look similar to this:
|
||||||
|
{
|
||||||
|
"modid.midnightconfig.title":"I am a title", // "*.midnightconfig.title" defines the title of the screen
|
||||||
|
"modid.midnightconfig.text1":"I am a comment *u*", // Translation for the comment "text1" defined in the example config
|
||||||
|
"modid.midnightconfig.name":"I am a string!", // Translation for the field "name" defined in the example config
|
||||||
|
|
||||||
|
"modid.midnightconfig.name.tooltip":"uwu \n I am a new line",
|
||||||
|
// When hovering over the option "showInfo",
|
||||||
|
// this text will appear as a tooltip.
|
||||||
|
// "\n" inserts a line break.
|
||||||
|
|
||||||
|
"modid.midnightconfig.fabric":"I am an int",
|
||||||
|
"modid.midnightconfig.world":"I am a double",
|
||||||
|
"modid.midnightconfig.showInfo":"I am a boolean",
|
||||||
|
"modid.midnightconfig.hello":"I am a limited int!",
|
||||||
|
"modid.midnightconfig.testEnum":"I am an enum!",
|
||||||
|
"modid.midnightconfig.enum.TestEnum.FABRIC":"Fancy",
|
||||||
|
"modid.midnightconfig.enum.TestEnum.QUILT":"Fabulous"
|
||||||
|
}
|
||||||
|
To initialize the config you have to call "MidnightConfig.init("modid", MidnightConfigExample.class)" in your ModInitializer
|
||||||
|
|
||||||
|
To get an instance of the config screen you have to call "MidnightConfig.getScreen(parent, "modid");"
|
||||||
|
|
||||||
|
The code in your ModMenu integration class would look something like this:
|
||||||
|
@Override
|
||||||
|
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||||
|
return parent -> MidnightConfig.getScreen(parent, "modid");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user