Compare commits

..

4 Commits

Author SHA1 Message Date
Martin Prokoph
2b70a553a1 release: v1.9.2 2025-12-11 01:12:23 +01:00
Martin Prokoph
8e6c76d804 port: MC 1.21.11(-rc2) 2025-12-07 20:11:35 +01:00
Martin Prokoph
6c732783c7 fix: crash when loading existing NeoForge configs
- Closes #120, #119
2025-11-23 21:10:22 +01:00
Martin Prokoph
1ea57b1a23 release: MidnightLib 1.9.0
here we go!
2025-11-23 13:47:17 +01:00
21 changed files with 201 additions and 80 deletions

View File

@@ -0,0 +1,15 @@
## MidnightLib v1.9.2
- Add support for using `StringRepresentable` to translate enums
## MidnightLib v1.9.1
- Fix crash when loading existing main config on NeoForge
# MidnightLib v1.9.0
- Setup a **multiversion** build environment
- MidnightLib will now always be up-to-date on all relevant versions of Minecraft
(Fabric/Forge 1.20.1; Fabric/NeoForge 1.21.1, 1.21.5, 1.21.8, 1.21.10)
- Measures were taken to ensure this doesn't break mods targeting old MidnightLib versions.
In case you still find a broken mod, please [report it](https://github.com/TeamMidnightDust/MidnightLib/issues/new/choose) and tag the issue with `1.9.0`.
- New logo! This offers improved visibility on light themes and a more modern, fresh look.
- Added JavaDocs to improve the developer experience.
- To be able to view them, adjust your midnightlib gradle dependency by following the [wiki](https://midnightdust.eu/wiki/midnightlib).
- Reduced jar size now under 60KB again for Fabric builds :)
- Migrate to Mojang mappings in preparation for upcoming non-obfuscated releases

View File

@@ -62,12 +62,15 @@ publishMods {
file = project.tasks.remapJar.get().archiveFile file = project.tasks.remapJar.get().archiveFile
dryRun = modrinthToken == null || curseforgeToken == null dryRun = modrinthToken == null || curseforgeToken == null
displayName = "${mod.name} ${loader.replaceFirstChar { it.uppercase() }} ${property("mod.mc_title")}-${mod.version}" displayName = "${mod.name} ${mod.version} - ${loader.replaceFirstChar { it.uppercase() }} ${property("mod.mc_title")}"
version = mod.version version = "${mod.version}+${property("mod.mc_title")}-${loader}"
changelog = rootProject.file("CHANGELOG.md").readText() changelog = rootProject.file("CHANGELOG.md").readText()
type = BETA type = STABLE
modLoaders.add(loader) modLoaders.add(loader)
if (loader == "fabric") {
modLoaders.add("quilt")
}
val targets = property("mod.mc_targets").toString().split(' ') val targets = property("mod.mc_targets").toString().split(' ')
modrinth { modrinth {
@@ -76,7 +79,6 @@ publishMods {
targets.forEach(minecraftVersions::add) targets.forEach(minecraftVersions::add)
if (loader == "fabric") { if (loader == "fabric") {
requires("fabric-api") requires("fabric-api")
optional("modmenu")
} }
} }
@@ -86,39 +88,25 @@ publishMods {
targets.forEach(minecraftVersions::add) targets.forEach(minecraftVersions::add)
if (loader == "fabric") { if (loader == "fabric") {
requires("fabric-api") requires("fabric-api")
optional("modmenu")
} }
} }
github { // github {
accessToken = githubToken // accessToken = githubToken
repository = "TeamMidnightDust/MidnightLib" // repository = "TeamMidnightDust/MidnightLib"
commitish = "multiversion" // This is the branch the release tag will be created from // commitish = "multiversion" // This is the branch the release tag will be created from
tagName = "v" + properties["mod.version"]
// Allow the release to be initially created without any files.
allowEmptyFiles = true
}
}
//publishing {
// publications {
// create<MavenPublication>("mavenJava") {
// pom {
// groupId = "eu.midnightdust"
// artifactId = "midnightlib"
// version = project.version
// //
// from(components["java"]) // tagName = "v" + properties["mod.version"]
// } //
// } // // Allow the release to be initially created without any files.
// allowEmptyFiles = true
// } // }
//} }
publishing { publishing {
repositories { repositories {
maven { maven {
name = "MidnightDust" name = "MidnightDust"
url = uri("https://maven.midnightdust.eu/snapshots") url = uri("https://maven.midnightdust.eu/releases")
credentials(PasswordCredentials::class) credentials(PasswordCredentials::class)
} }
} }
@@ -217,4 +205,12 @@ stonecutter {
constants { constants {
arrayOf("fabric", "neoforge", "forge").forEach { it -> put(it, loader == it) } arrayOf("fabric", "neoforge", "forge").forEach { it -> put(it, loader == it) }
} }
replacements.string {
direction = eval(current.version, ">=1.21.11-rc2")
replace("ResourceLocation", "Identifier")
}
replacements.string {
direction = eval(current.version, ">=1.21.11-rc2")
replace("net.minecraft.Util", "net.minecraft.util.Util")
}
} }

View File

@@ -7,7 +7,7 @@ org.gradle.parallel=false
#org.gradle.configureondemand=true #org.gradle.configureondemand=true
# Mod properties # Mod properties
mod.version=1.9.0-beta.3 mod.version=1.9.2
mod.group=eu.midnightdust mod.group=eu.midnightdust
mod.id=midnightlib mod.id=midnightlib
mod.name=MidnightLib mod.name=MidnightLib
@@ -21,7 +21,7 @@ mod.mc_title=[VERSIONED]
mod.mc_targets=[VERSIONED] mod.mc_targets=[VERSIONED]
# Mod setup # Mod setup
deps.fabric_loader=0.17.3 deps.fabric_loader=0.18.1
deps.fabric_version=[VERSIONED] deps.fabric_version=[VERSIONED]
deps.forge_loader=[VERSIONED] deps.forge_loader=[VERSIONED]

View File

@@ -22,10 +22,10 @@ stonecutter {
for (version in versions) vers("$version-$loader", version) for (version in versions) vers("$version-$loader", version)
} }
//i would recommend to use neoforge for mc > 1.20.1, i haven't tested template for forge on versions higher than that //i would recommend to use neoforge for mc > 1.20.1, i haven't tested template for forge on versions higher than that
mc("fabric","1.20.1", "1.21.1", "1.21.5", "1.21.8", "1.21.10") mc("fabric","1.20.1", "1.21.1", "1.21.5", "1.21.8", "1.21.10", "1.21.11")
mc("forge","1.20.1") mc("forge","1.20.1")
//WARNING: neoforge uses mods.toml instead of neoforge.mods.toml for versions 1.20.4 (?) and earlier //WARNING: neoforge uses mods.toml instead of neoforge.mods.toml for versions 1.20.4 (?) and earlier
mc("neoforge", "1.21.1", "1.21.5", "1.21.8", "1.21.10") mc("neoforge", "1.21.1", "1.21.5", "1.21.8", "1.21.10", "1.21.11")
} }
create(rootProject) create(rootProject)
} }

View File

@@ -7,7 +7,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.swing.UIManager; import javax.swing.UIManager;
import net.minecraft.Util; import net.minecraft.util.Util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View File

@@ -4,20 +4,15 @@ import eu.midnightdust.lib.config.MidnightConfig;
import eu.midnightdust.lib.util.PlatformFunctions; import eu.midnightdust.lib.util.PlatformFunctions;
public class MidnightLibConfig extends MidnightConfig { public class MidnightLibConfig extends MidnightConfig {
//? if fabric { public static final boolean HAS_MODMENU = PlatformFunctions.isModLoaded("modmenu") || "neoforge".equals(PlatformFunctions.getPlatformName());
@Entry public static ConfigButton config_screen_list = PlatformFunctions.isModLoaded("modmenu") ? ConfigButton.MODMENU : ConfigButton.TRUE;
public static boolean shouldShowButton() { @Entry public static ConfigButton config_screen_list = HAS_MODMENU ? ConfigButton.MODMENU : ConfigButton.TRUE;
return config_screen_list.equals(ConfigButton.TRUE) || (config_screen_list.equals(ConfigButton.MODMENU) && !PlatformFunctions.isModLoaded("modmenu"));
}
//?} else {
/*@Entry public static ConfigButton config_screen_list = ConfigButton.FALSE;
public static boolean shouldShowButton() {
return config_screen_list.equals(ConfigButton.TRUE);
}
*///?}
public enum ConfigButton { public enum ConfigButton {
TRUE, FALSE /*? if fabric {*/, MODMENU /*?}*/ TRUE, FALSE, MODMENU
}
public static boolean shouldShowButton() {
return config_screen_list.equals(ConfigButton.TRUE) || (config_screen_list.equals(ConfigButton.MODMENU) && !HAS_MODMENU);
} }
} }

View File

@@ -12,7 +12,7 @@ import java.util.Objects;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.Identifier;
//? if >= 1.21 { //? if >= 1.21 {
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
@@ -35,7 +35,7 @@ public abstract class MixinOptionsScreen extends Screen {
@Shadow @Final private HeaderAndFooterLayout layout; @Shadow @Final private HeaderAndFooterLayout layout;
@Unique SpriteIconButton midnightlib$button = SpriteIconButton.builder(Component.translatable("midnightlib.overview.title"), ( @Unique SpriteIconButton midnightlib$button = SpriteIconButton.builder(Component.translatable("midnightlib.overview.title"), (
buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(new MidnightConfigOverviewScreen(this)), true) buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(new MidnightConfigOverviewScreen(this)), true)
.sprite(ResourceLocation.fromNamespaceAndPath(MOD_ID,"icon/"+MOD_ID), 16, 16).size(20, 20).build(); .sprite(Identifier.fromNamespaceAndPath(MOD_ID,"icon/"+MOD_ID), 16, 16).size(20, 20).build();
@Inject(at = @At("HEAD"), method = "init") @Inject(at = @At("HEAD"), method = "init")
public void midnightlib$onInit(CallbackInfo ci) { public void midnightlib$onInit(CallbackInfo ci) {
@@ -55,7 +55,7 @@ public abstract class MixinOptionsScreen extends Screen {
midnightlib$button.setPosition(layout.getWidth() / 2 + 158, layout.getY() + layout.getFooterHeight() - 4); midnightlib$button.setPosition(layout.getWidth() / 2 + 158, layout.getY() + layout.getFooterHeight() - 4);
} }
//?} else { //?} else {
/*@Unique TextAndImageButton midnightlib$button = TextAndImageButton.builder(Component.translatable("midnightlib.overview.title"), new ResourceLocation("midnightlib", "icon/midnightlib.png"), /*@Unique TextAndImageButton midnightlib$button = TextAndImageButton.builder(Component.translatable("midnightlib.overview.title"), new Identifier("midnightlib", "icon/midnightlib.png"),
button -> Objects.requireNonNull(minecraft).setScreen(new MidnightConfigOverviewScreen(this))).textureSize(16, 16).usedTextureSize(16, 16).offset(0, 2).build(); button -> Objects.requireNonNull(minecraft).setScreen(new MidnightConfigOverviewScreen(this))).textureSize(16, 16).usedTextureSize(16, 16).offset(0, 2).build();
@Inject(at = @At("HEAD"), method = "init") @Inject(at = @At("HEAD"), method = "init")

View File

@@ -15,6 +15,9 @@ import net.minecraft.network.chat.Component;
//? fabric //? fabric
import net.fabricmc.api.DedicatedServerModInitializer; import net.fabricmc.api.DedicatedServerModInitializer;
//? if >= 1.21.11
import net.minecraft.server.permissions.*;
public class AutoCommand /*? fabric {*/ implements DedicatedServerModInitializer /*?}*/ { public class AutoCommand /*? fabric {*/ implements DedicatedServerModInitializer /*?}*/ {
final static String VALUE = "value"; final static String VALUE = "value";
Field field; Field field;
@@ -41,7 +44,8 @@ public class AutoCommand /*? fabric {*/ implements DedicatedServerModInitializer
.then(Commands.argument(VALUE, getArgType()).executes(ctx -> setValueFromArg(ctx, action)))); .then(Commands.argument(VALUE, getArgType()).executes(ctx -> setValueFromArg(ctx, action))));
} else command = command.then(Commands.argument(VALUE, getArgType()).executes(ctx -> setValueFromArg(ctx, ""))); } else command = command.then(Commands.argument(VALUE, getArgType()).executes(ctx -> setValueFromArg(ctx, "")));
PlatformFunctions.registerCommand(Commands.literal("midnightconfig").requires(source -> source.hasPermission(2)).then(Commands.literal(modid).then(command))); PlatformFunctions.registerCommand(Commands.literal("midnightconfig").requires(source ->
source/*? if >= 1.21.11 {*/.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.GAMEMASTERS))/*?} else {*/ /*.hasPermission(2) *//*?}*/).then(Commands.literal(modid).then(command)));
} }
public ArgumentType<?> getArgType() { public ArgumentType<?> getArgType() {

View File

@@ -15,7 +15,7 @@ import net.minecraft.client.gui.narration.NarratableEntry;
import net.minecraft.client.gui.screens.ConfirmLinkScreen; import net.minecraft.client.gui.screens.ConfirmLinkScreen;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.Identifier;
//? if >= 1.21.9 { //? if >= 1.21.9 {
import net.minecraft.client.input.MouseButtonEvent; import net.minecraft.client.input.MouseButtonEvent;
//?} //?}
@@ -64,8 +64,8 @@ public class ButtonEntry extends ContainerObjectSelectionList.Entry<ButtonEntry>
Optional.ofNullable(this.buttons.get(0)).ifPresent(widget -> { Optional.ofNullable(this.buttons.get(0)).ifPresent(widget -> {
int idMode = this.info.entry.idMode(); int idMode = this.info.entry.idMode();
if (idMode != -1) context.renderItem(idMode == 0 ? if (idMode != -1) context.renderItem(idMode == 0 ?
BuiltInRegistries.ITEM./*? if >= 1.21.4 {*/ getValue /*?} else {*/ /*get *//*?}*/(ResourceLocation.tryParse(this.info.tempValue)).getDefaultInstance() BuiltInRegistries.ITEM./*? if >= 1.21.4 {*/ getValue /*?} else {*/ /*get *//*?}*/(Identifier.tryParse(this.info.tempValue)).getDefaultInstance()
: BuiltInRegistries.BLOCK./*? if >= 1.21.4 {*/ getValue /*?} else {*/ /*get *//*?}*/(ResourceLocation.tryParse(this.info.tempValue)).asItem().getDefaultInstance(), : BuiltInRegistries.BLOCK./*? if >= 1.21.4 {*/ getValue /*?} else {*/ /*get *//*?}*/(Identifier.tryParse(this.info.tempValue)).asItem().getDefaultInstance(),
widget.getX() + widget.getWidth() - 18, y + 2); widget.getX() + widget.getWidth() - 18, y + 2);
}); });
} }

View File

@@ -10,7 +10,7 @@ import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.resources.language.I18n; import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style; import net.minecraft.network.chat.Style;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.Identifier;
import net.minecraft.util.*; import net.minecraft.util.*;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -50,14 +50,14 @@ public abstract class MidnightConfig {
public boolean shouldSkipClass(Class<?> clazz) { return false; } public boolean shouldSkipClass(Class<?> clazz) { return false; }
public boolean shouldSkipField(FieldAttributes fieldAttributes) { return fieldAttributes.getAnnotation(Entry.class) == null; } public boolean shouldSkipField(FieldAttributes fieldAttributes) { return fieldAttributes.getAnnotation(Entry.class) == null; }
}) })
.registerTypeAdapter(ResourceLocation.class, .registerTypeAdapter(Identifier.class,
//? if >= 1.21.4 { //? if >= 1.21.4 {
new TypeAdapter<ResourceLocation>() { new TypeAdapter<Identifier>() {
public void write(JsonWriter out, ResourceLocation id) throws IOException { out.value(id.toString()); } public void write(JsonWriter out, Identifier id) throws IOException { out.value(id.toString()); }
public ResourceLocation read(JsonReader in) throws IOException { return ResourceLocation.parse(in.nextString()); } public Identifier read(JsonReader in) throws IOException { return Identifier.parse(in.nextString()); }
} }
//?} else { //?} else {
/*new ResourceLocation.Serializer() /*new Identifier.Serializer()
*///?} *///?}
).setPrettyPrinting().create(); ).setPrettyPrinting().create();
@@ -114,7 +114,7 @@ public abstract class MidnightConfig {
if (info.dataType == int.class) textField(info, Integer::parseInt, INTEGER_ONLY, (int) e.min(), (int) e.max(), true); if (info.dataType == int.class) textField(info, Integer::parseInt, INTEGER_ONLY, (int) e.min(), (int) e.max(), true);
else if (info.dataType == float.class) textField(info, Float::parseFloat, DECIMAL_ONLY, (float) e.min(), (float) e.max(), false); else if (info.dataType == float.class) textField(info, Float::parseFloat, DECIMAL_ONLY, (float) e.min(), (float) e.max(), false);
else if (info.dataType == double.class) textField(info, Double::parseDouble, DECIMAL_ONLY, e.min(), e.max(), false); else if (info.dataType == double.class) textField(info, Double::parseDouble, DECIMAL_ONLY, e.min(), e.max(), false);
else if (info.dataType == String.class || info.dataType == ResourceLocation.class) textField(info, String::length, null, Math.min(e.min(), 0), Math.max(e.max(), 1), true); else if (info.dataType == String.class || info.dataType == Identifier.class) textField(info, String::length, null, Math.min(e.min(), 0), Math.max(e.max(), 1), true);
else if (info.dataType == boolean.class) { else if (info.dataType == boolean.class) {
Function<Object, Component> func = value -> Component.translatable((Boolean) value ? "gui.yes" : "gui.no").withStyle((Boolean) value ? ChatFormatting.GREEN : ChatFormatting.RED); Function<Object, Component> func = value -> Component.translatable((Boolean) value ? "gui.yes" : "gui.no").withStyle((Boolean) value ? ChatFormatting.GREEN : ChatFormatting.RED);
info.function = new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(button -> { info.function = new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(button -> {
@@ -158,7 +158,7 @@ public abstract class MidnightConfig {
info.function = (BiFunction<EditBox, Button, Predicate<String>>) (t, b) -> s -> { info.function = (BiFunction<EditBox, Button, Predicate<String>>) (t, b) -> s -> {
s = s.trim(); s = s.trim();
if (!(s.isEmpty() || !isNumber || pattern.matcher(s).matches()) || if (!(s.isEmpty() || !isNumber || pattern.matcher(s).matches()) ||
(info.dataType == ResourceLocation.class && ResourceLocation.read(s)./*? if >= 1.21 {*/isError() /*?} else {*/ /*error().isPresent() *//*?}*/)) return false; (info.dataType == Identifier.class && Identifier.read(s)./*? if >= 1.21 {*/isError() /*?} else {*/ /*error().isPresent() *//*?}*/)) return false;
Number value = 0; boolean inLimits = false; info.error = null; Number value = 0; boolean inLimits = false; info.error = null;
if (!(isNumber && s.isEmpty()) && !s.equals("-") && !s.equals(".")) { if (!(isNumber && s.isEmpty()) && !s.equals("-") && !s.equals(".")) {
@@ -176,8 +176,8 @@ public abstract class MidnightConfig {
b.active = entries.values().stream().allMatch(e -> e.inLimits); b.active = entries.values().stream().allMatch(e -> e.inLimits);
if (inLimits) { if (inLimits) {
if (info.dataType == ResourceLocation.class) if (info.dataType == Identifier.class)
info.setValue(ResourceLocation.tryParse(s)); info.setValue(Identifier.tryParse(s));
else info.setValue(isNumber ? value : s); else info.setValue(isNumber ? value : s);
} }
@@ -197,7 +197,9 @@ public abstract class MidnightConfig {
* @param info the associated {@link EntryInfo} object * @param info the associated {@link EntryInfo} object
* */ * */
protected Component getEnumTranslatableText(Object value, EntryInfo info) { protected Component getEnumTranslatableText(Object value, EntryInfo info) {
if (value instanceof OptionEnum translatableOption) return translatableOption.getCaption(); if (value instanceof StringRepresentable option) return Component.translatable(option.getSerializedName());
//? if < 1.21.11
/*if (value instanceof OptionEnum option) return option.getCaption();*/
assert info.dataType != null; assert info.dataType != null;
String translationKey = "%s.midnightconfig.enum.%s.%s".formatted(modid, info.dataType.getSimpleName(), info.toTemporaryValue()); String translationKey = "%s.midnightconfig.enum.%s.%s".formatted(modid, info.dataType.getSimpleName(), info.toTemporaryValue());
@@ -310,7 +312,7 @@ public abstract class MidnightConfig {
/** /**
* Entry Annotation<br> * Entry Annotation<br>
* - <b>width</b>: The maximum character length of the {@link String}, {@link ResourceLocation} or String/Identifier {@link List<>} field<br> * - <b>width</b>: The maximum character length of the {@link String}, {@link Identifier} or String/Identifier {@link List<>} field<br>
* - <b>min</b>: The minimum value of the <code>int</code>, <code>float</code> or <code>double</code> field<br> * - <b>min</b>: The minimum value of the <code>int</code>, <code>float</code> or <code>double</code> field<br>
* - <b>max</b>: The maximum value of the <code>int</code>, <code>float</code> or <code>double</code> field<br> * - <b>max</b>: The maximum value of the <code>int</code>, <code>float</code> or <code>double</code> field<br>
* - <b>name</b>: Will be used instead of the default translation key, if not empty<br> * - <b>name</b>: Will be used instead of the default translation key, if not empty<br>

View File

@@ -2,7 +2,7 @@ package eu.midnightdust.lib.config;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.Util; import net.minecraft.util.Util;
import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.*; import net.minecraft.client.gui.components.*;
import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.Button;
@@ -16,7 +16,7 @@ import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style; import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.contents.TranslatableContents; import net.minecraft.network.chat.contents.TranslatableContents;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.Identifier;
import javax.swing.*; import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.*; import java.awt.*;
@@ -170,7 +170,7 @@ public class MidnightConfigScreen extends Screen {
//? if >= 1.21 { //? if >= 1.21 {
SpriteIconButton resetButton = SpriteIconButton.builder(Component.translatable("controls.reset"), SpriteIconButton resetButton = SpriteIconButton.builder(Component.translatable("controls.reset"),
//?} else { //?} else {
/*TextAndImageButton resetButton = TextAndImageButton.builder(Component.translatable("controls.reset"), new ResourceLocation("midnightlib", "icon/reset.png"), /*TextAndImageButton resetButton = TextAndImageButton.builder(Component.translatable("controls.reset"), new Identifier("midnightlib", "icon/reset.png"),
*///?} *///?}
(button -> { (button -> {
info.value = info.defaultValue; info.value = info.defaultValue;
@@ -179,7 +179,7 @@ public class MidnightConfigScreen extends Screen {
updateList(); updateList();
}) })
//? if >= 1.21 { //? if >= 1.21 {
, true).sprite(ResourceLocation.fromNamespaceAndPath("midnightlib", "icon/reset"), 12, 12).size(20, 20).build(); , true).sprite(Identifier.fromNamespaceAndPath("midnightlib", "icon/reset"), 12, 12).size(20, 20).build();
//?} else { //?} else {
/*).textureSize(12, 12).usedTextureSize(12, 12).offset(0, 4).build(); /*).textureSize(12, 12).usedTextureSize(12, 12).offset(0, 4).build();
resetButton.setWidth(20); resetButton.setWidth(20);
@@ -239,7 +239,7 @@ public class MidnightConfigScreen extends Screen {
//? if >= 1.21 { //? if >= 1.21 {
SpriteIconButton.builder(Component.empty(), SpriteIconButton.builder(Component.empty(),
//?} else { //?} else {
/*TextAndImageButton.builder(Component.empty(), new ResourceLocation("midnightlib", "icon/explorer.png"), /*TextAndImageButton.builder(Component.empty(), new Identifier("midnightlib", "icon/explorer.png"),
*///?} *///?}
button -> new Thread(() -> { button -> new Thread(() -> {
JFileChooser fileChooser = new JFileChooser(info.tempValue); JFileChooser fileChooser = new JFileChooser(info.tempValue);
@@ -255,7 +255,7 @@ public class MidnightConfigScreen extends Screen {
} }
}).start() }).start()
//? if >= 1.21 { //? if >= 1.21 {
, true).sprite(ResourceLocation.fromNamespaceAndPath("midnightlib", "icon/explorer"), 12, 12).size(20, 20) , true).sprite(Identifier.fromNamespaceAndPath("midnightlib", "icon/explorer"), 12, 12).size(20, 20)
//?} else { //?} else {
/*).textureSize(12, 12).usedTextureSize(12, 12).offset(0, 4) /*).textureSize(12, 12).usedTextureSize(12, 12).offset(0, 4)
*///?} *///?}

View File

@@ -16,7 +16,7 @@ import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.client.input.KeyEvent; import net.minecraft.client.input.KeyEvent;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.Identifier;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
@@ -33,7 +33,7 @@ public class MidnightLibExtras {
SpriteIconButton resetButton = SpriteIconButton.builder(Component.translatable("controls.reset"), (button -> { SpriteIconButton resetButton = SpriteIconButton.builder(Component.translatable("controls.reset"), (button -> {
binding.setKey(binding.getDefaultKey()); binding.setKey(binding.getDefaultKey());
screen.updateList(); screen.updateList();
}), true).sprite(ResourceLocation.fromNamespaceAndPath("midnightlib","icon/reset"), 12, 12).size(20, 20).build(); }), true).sprite(Identifier.fromNamespaceAndPath("midnightlib","icon/reset"), 12, 12).size(20, 20).build();
resetButton.setPosition(screen.width - 205 + 150 + 25, 0); resetButton.setPosition(screen.width - 205 + 150 + 25, 0);
editButton.resetButton = resetButton; editButton.resetButton = resetButton;
editButton.updateMessage(false); editButton.updateMessage(false);

View File

@@ -10,7 +10,7 @@ import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.Identifier;
import net.minecraft.util.OptionEnum; import net.minecraft.util.OptionEnum;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -38,7 +38,7 @@ public class MidnightConfigExample extends MidnightConfig {
@Entry(category = TEXT, name="I am a (non-primitive) Boolean") public static Boolean nonPrimitive = true; // Example for a non-primative boolean option @Entry(category = TEXT, name="I am a (non-primitive) Boolean") public static Boolean nonPrimitive = true; // Example for a non-primative boolean option
@Entry(category = TEXT) public static String name = "Hello World!"; // Example for a string option, which is in a category! @Entry(category = TEXT) public static String name = "Hello World!"; // Example for a string option, which is in a category!
@Entry(category = TEXT, width = 7, min = 7, isColor = true, name = "I am a color!") public static String titleColor = "#ffffff"; // The isColor property adds a color chooser for a hexadecimal color @Entry(category = TEXT, width = 7, min = 7, isColor = true, name = "I am a color!") public static String titleColor = "#ffffff"; // The isColor property adds a color chooser for a hexadecimal color
@Entry(category = TEXT, idMode = 0) public static ResourceLocation id = ResourceLocation.withDefaultNamespace("diamond"); // Example for an identifier with matching items displayed next to it! @Entry(category = TEXT, idMode = 0) public static Identifier id = Identifier.withDefaultNamespace("diamond"); // Example for an identifier with matching items displayed next to it!
@Entry(category = TEXT) public static ModPlatform modPlatform = ModPlatform.FABRIC; // Example for an enum option @Entry(category = TEXT) public static ModPlatform modPlatform = ModPlatform.FABRIC; // Example for an enum option
public enum ModPlatform { // Enums allow the user to cycle through predefined options public enum ModPlatform { // Enums allow the user to cycle through predefined options
QUILT, FABRIC, FORGE, NEOFORGE, VANILLA QUILT, FABRIC, FORGE, NEOFORGE, VANILLA
@@ -56,7 +56,7 @@ public class MidnightConfigExample extends MidnightConfig {
// The name field can be used to specify a custom translation string or plain text // The name field can be used to specify a custom translation string or plain text
@Entry(category = LISTS, name = "I am a string list!") public static List<String> stringList = Lists.newArrayList("String1", "String2"); // Array String Lists are also supported @Entry(category = LISTS, name = "I am a string list!") public static List<String> stringList = Lists.newArrayList("String1", "String2"); // Array String Lists are also supported
@Entry(category = LISTS, isColor = true, name = "I am a color list!") public static List<String> colorList = Lists.newArrayList("#ac5f99", "#11aa44"); // Lists also support colors @Entry(category = LISTS, isColor = true, name = "I am a color list!") public static List<String> colorList = Lists.newArrayList("#ac5f99", "#11aa44"); // Lists also support colors
@Entry(category = LISTS, name = "I am an identifier list!", idMode = 1) public static List<ResourceLocation> idList = Lists.newArrayList(ResourceLocation.withDefaultNamespace("dirt")); // A list of block identifiers @Entry(category = LISTS, name = "I am an identifier list!", idMode = 1) public static List<Identifier> idList = Lists.newArrayList(Identifier.withDefaultNamespace("dirt")); // A list of block identifiers
@Entry(category = LISTS, name = "I am an integer list!") public static List<Integer> intList = Lists.newArrayList(69, 420); @Entry(category = LISTS, name = "I am an integer list!") public static List<Integer> intList = Lists.newArrayList(69, 420);
@Entry(category = LISTS, name = "I am a float list!") public static List<Float> floatList = Lists.newArrayList(4.1f, -1.3f, -1f); @Entry(category = LISTS, name = "I am a float list!") public static List<Float> floatList = Lists.newArrayList(4.1f, -1.3f, -1f);

View File

@@ -5,7 +5,7 @@ plugins {
id("com.github.johnrengelman.shadow") version "8.1.1" apply false id("com.github.johnrengelman.shadow") version "8.1.1" apply false
id("me.modmuss50.mod-publish-plugin") version "0.8.4" apply false id("me.modmuss50.mod-publish-plugin") version "0.8.4" apply false
} }
stonecutter active "1.21.10-fabric" /* [SC] DO NOT EDIT */ stonecutter active "1.21.11-fabric" /* [SC] DO NOT EDIT */
// See https://stonecutter.kikugie.dev/wiki/config/params // See https://stonecutter.kikugie.dev/wiki/config/params
stonecutter parameters { stonecutter parameters {

View File

@@ -1,5 +1,5 @@
mod.mc_dep_fabric=>=1.21.9 mod.mc_dep_fabric=>=1.21.9 <=1.21.10
mod.mc_dep_forgelike=[1.21.9,) mod.mc_dep_forgelike=[1.21.9,1.21.10]
mod.mc_title=1.21.10 mod.mc_title=1.21.10
mod.mc_targets=1.21.9 1.21.10 mod.mc_targets=1.21.9 1.21.10

View File

@@ -1,5 +1,5 @@
mod.mc_dep_fabric=>=1.21.9 mod.mc_dep_fabric=>=1.21.9 <= 1.21.10
mod.mc_dep_forgelike=[1.21.9,) mod.mc_dep_forgelike=[1.21.9,1.21.10]
mod.mc_title=1.21.10 mod.mc_title=1.21.10
mod.mc_targets=1.21.9 1.21.10 mod.mc_targets=1.21.9 1.21.10

View File

@@ -0,0 +1,12 @@
mod.mc_dep_fabric=>=1.21.11
mod.mc_dep_forgelike=[1.21.11,)
mod.mc_title=1.21.11
mod.mc_targets=1.21.11
deps.forge_loader=0
deps.neoforge_loader=21.11.3-beta
deps.fabric_version=0.139.4+1.21.11
deps.modmenu_version=17.0.0-alpha.1
loom.platform=fabric

View File

@@ -0,0 +1,54 @@
{
"schemaVersion": 1,
"id": "${id}",
"version": "${version}",
"name": "${name}",
"description": "Lightweight config library with config screens and commands.",
"authors": [
"Motschen"
],
"contributors": [
"maloryware",
"Jaffe2718"
],
"contact": {
"homepage": "https://www.midnightdust.eu/",
"sources": "https://github.com/TeamMidnightDust/MidnightLib",
"issues": "https://github.com/TeamMidnightDust/MidnightLib/issues"
},
"license": "MIT",
"icon": "assets/midnightlib/icon.png",
"environment": "*",
"entrypoints": {
"server": [
"eu.midnightdust.lib.config.AutoCommand"
],
"client": [
"eu.midnightdust.core.MidnightLib"
],
"modmenu": [
"eu.midnightdust.core.MidnightLib\$ModMenuInit"
]
},
"depends": {
"fabric-resource-loader-v0": "*",
"minecraft": "${minecraft}"
},
"mixins": [
"midnightlib.mixins.json"
],
"custom": {
"modmenu": {
"links": {
"modmenu.discord": "http://discord.midnightdust.eu/",
"modmenu.website": "https://midnightdust.eu/midnightlib",
"midnightlib.wiki": "https://midnightdust.eu/wiki/midnightlib"
},
"badges": [ "library" ]
}
}
}

View File

@@ -0,0 +1,12 @@
mod.mc_dep_fabric=>=1.21.11
mod.mc_dep_forgelike=[1.21.11,)
mod.mc_title=1.21.11
mod.mc_targets=1.21.11
deps.forge_loader=0
deps.neoforge_loader=21.11.3-beta
deps.fabric_version=0.139.4+1.21.11
deps.modmenu_version=17.0.0-alpha.1
loom.platform=neoforge

View File

@@ -0,0 +1,31 @@
modLoader = "javafml"
loaderVersion = "[2,)"
#issueTrackerURL = ""
license = "MIT License"
[[mods]]
modId = "midnightlib"
version = "${version}"
displayName = "${name}"
logoFile = "midnightlib.png"
authors = "TeamMidnightDust, Motschen"
description = '''
Lightweight config library with config screens and commands.
'''
[[mixins]]
config = "midnightlib.mixins.json"
[[dependencies.midnightlib]]
modId = "neoforge"
mandatory = true
versionRange = "[20.5,)"
ordering = "NONE"
side = "BOTH"
[[dependencies.midnightlib]]
modId = "minecraft"
mandatory = true
versionRange = "${minecraft}"
ordering = "NONE"
side = "BOTH"

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B