mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-15 17:05:09 +01:00
Compare commits
4 Commits
v0.4.0
...
fabric-1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c805d03630 | ||
|
|
23ab3ea9f8 | ||
|
|
5ef681693e | ||
|
|
da2c76ed5f |
@@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||
loader_version=0.11.7
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 0.4.0
|
||||
mod_version = 0.4.4
|
||||
maven_group = eu.midnightdust
|
||||
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.rendering.v1.EntityModelLayerRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MidnightLibClient implements ClientModInitializer {
|
||||
public static List<String> hiddenMods = new ArrayList<>();
|
||||
|
||||
public static final String MOD_ID = "midnightlib";
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
MidnightConfig.init("midnightlib", MidnightLibConfig.class);
|
||||
if (hiddenMods.contains("puzzle")) hiddenMods.add("puzzle");
|
||||
|
||||
EntityModelLayerRegistry.registerModelLayer(WitchHatFeatureRenderer.WITCH_HAT_MODEL_LAYER, WitchHatFeatureRenderer::getTexturedModelData);
|
||||
if (MidnightLibConfig.special_hats) HatLoader.init();
|
||||
|
||||
@@ -25,7 +25,7 @@ public class MixinOptionsScreen extends Screen {
|
||||
|
||||
@Inject(at = @At("HEAD"),method = "init")
|
||||
private void midnightlib$init(CallbackInfo ci) {
|
||||
if (MidnightLibConfig.config_screen_list.equals(MidnightLibConfig.ConfigButton.TRUE) || MidnightLibConfig.config_screen_list.equals(MidnightLibConfig.ConfigButton.MODMENU) && FabricLoader.getInstance().isModLoaded("modmenu"))
|
||||
this.addDrawableChild(new TexturedOverlayButtonWidget(this.width / 2 + 158, this.height / 6 - 12, 20, 20, 0, 0, 20, MIDNIGHTLIB_ICON_TEXTURE, 32, 64, (buttonWidget) -> Objects.requireNonNull(client).setScreen(new MidnightConfigOverviewScreen(this)), new TranslatableText("midnightlib.overview.title")));
|
||||
if (MidnightLibConfig.config_screen_list.equals(MidnightLibConfig.ConfigButton.TRUE) || (MidnightLibConfig.config_screen_list.equals(MidnightLibConfig.ConfigButton.MODMENU) && !FabricLoader.getInstance().isModLoaded("modmenu")))
|
||||
this.addDrawableChild(new TexturedOverlayButtonWidget(this.width / 2 + 158, this.height / 6 - 12, 20, 20, 0, 0, 20, MIDNIGHTLIB_ICON_TEXTURE, 32, 64, (buttonWidget) -> Objects.requireNonNull(client).setScreen(new MidnightConfigOverviewScreen(this)), new TranslatableText("midnightlib.overview.title")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package eu.midnightdust.core.screen;
|
||||
|
||||
import eu.midnightdust.core.MidnightLibClient;
|
||||
import eu.midnightdust.lib.config.MidnightConfig;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
@@ -31,9 +32,12 @@ public class MidnightConfigOverviewScreen extends Screen {
|
||||
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);
|
||||
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, new TranslatableText(modid +".midnightconfig.title"), (button) ->
|
||||
Objects.requireNonNull(client).setScreen(MidnightConfig.getScreen(this,modid)))));
|
||||
Objects.requireNonNull(client).setScreen(MidnightConfig.getScreen(this,modid))));
|
||||
}
|
||||
});
|
||||
super.init();
|
||||
}
|
||||
@Override
|
||||
|
||||
@@ -2,12 +2,14 @@ package eu.midnightdust.lib.config;
|
||||
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import eu.midnightdust.core.MidnightLibClient;
|
||||
import eu.midnightdust.core.config.MidnightLibConfig;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AutoModMenu implements ModMenuApi {
|
||||
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
return parent -> MidnightLibConfig.getScreen(parent,"midnightlib");
|
||||
@@ -16,7 +18,11 @@ public class AutoModMenu implements ModMenuApi {
|
||||
@Override
|
||||
public Map<String, ConfigScreenFactory<?>> getProvidedConfigScreenFactories() {
|
||||
HashMap<String, ConfigScreenFactory<?>> map = new HashMap<>();
|
||||
MidnightConfig.configClass.forEach((modid, cClass) -> map.put(modid, parent -> MidnightConfig.getScreen(parent, modid)));
|
||||
MidnightConfig.configClass.forEach((modid, cClass) -> {
|
||||
if (!MidnightLibClient.hiddenMods.contains(modid))
|
||||
map.put(modid, parent -> MidnightConfig.getScreen(parent, modid));
|
||||
}
|
||||
);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ public abstract class MidnightConfig {
|
||||
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
|
||||
buttons.forEach(b -> { b.y = y; b.render(matrices, mouseX, mouseY, tickDelta); });
|
||||
if (text != null && (!text.getString().contains("spacer") || !buttons.isEmpty()))
|
||||
DrawableHelper.drawTextWithShadow(matrices,textRenderer, text,12,y+5,0xFFFFFF);
|
||||
DrawableHelper.drawTextWithShadow(matrices,textRenderer, text,12,y+5,0xFFFFFF);
|
||||
}
|
||||
public List<? extends Element> children() {return children;}
|
||||
public List<? extends Selectable> selectableChildren() {return children;}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
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:
|
||||
@@ -12,14 +14,15 @@ public class MidnightConfigExample extends MidnightConfig {
|
||||
@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 = "Hi"; // Example for a string 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 static enum TestEnum { // Enums allow the user to cycle through predefined options
|
||||
public enum TestEnum { // Enums allow the user to cycle through predefined options
|
||||
QUILT, FABRIC
|
||||
}
|
||||
@Entry(min=10,max=30) public static int hello = 15675965; // - The entered number has to be larger than 10 and smaller than 30
|
||||
@Entry(width = 7, min = 7, isColor = true) public static String titleColor = "#ffffff"; // The isColor property adds a preview box for a hexadecimal color
|
||||
@Entry public static List<String> blurExclusions = Mod.defaultExclusions; // Array String Lists are also supported
|
||||
@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
|
||||
|
||||
@@ -28,9 +31,9 @@ public class MidnightConfigExample extends MidnightConfig {
|
||||
{
|
||||
"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":"Pet Name", // Translation for the field "name" 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":"Name your Pet! \n I am a new line uwu",
|
||||
"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.
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
},
|
||||
|
||||
"mixins": [
|
||||
"midnightcore.mixins.json"
|
||||
"midnightlib.mixins.json"
|
||||
],
|
||||
|
||||
"depends": {
|
||||
|
||||
Reference in New Issue
Block a user