mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-15 17:05:09 +01:00
Compare commits
10 Commits
v0.3.0
...
fabric-1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c805d03630 | ||
|
|
23ab3ea9f8 | ||
|
|
5ef681693e | ||
|
|
da2c76ed5f | ||
|
|
8c1c00f6e2 | ||
|
|
5183b54285 | ||
|
|
a9190f2a0d | ||
|
|
794586362d | ||
|
|
1bdbde0af6 | ||
|
|
c1815c25d8 |
@@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||
loader_version=0.11.7
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 0.3.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();
|
||||
|
||||
@@ -12,7 +12,7 @@ public class MidnightLibServer implements DedicatedServerModInitializer {
|
||||
public void onInitializeServer() {
|
||||
MidnightConfig.configClass.forEach((modid, config) -> {
|
||||
for (Field field : config.getFields()) {
|
||||
if (field.isAnnotationPresent(MidnightConfig.Entry.class))
|
||||
if (field.isAnnotationPresent(MidnightConfig.Entry.class) && !field.isAnnotationPresent(MidnightConfig.Client.class))
|
||||
new AutoCommand(field, modid).register();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,9 +4,6 @@ import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -19,7 +16,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public class HatLoader {
|
||||
public static final Logger logger = LogManager.getLogger("MidnightLib");
|
||||
public static final System.Logger logger = System.getLogger("MidnightLib");
|
||||
private final static String HATS_URL = "https://raw.githubusercontent.com/TeamMidnightDust/MidnightHats/master/hats.json";
|
||||
public static final Type HAT_TYPE = new TypeToken<Map<UUID, PlayerHatData>>(){}.getType();
|
||||
public static Map<UUID, PlayerHatData> PLAYER_HATS;
|
||||
@@ -31,19 +28,19 @@ public class HatLoader {
|
||||
try (Reader reader = new InputStreamReader(new URL(HATS_URL).openStream())) {
|
||||
return GSON.<Map<UUID, PlayerHatData>>fromJson(reader, HAT_TYPE);
|
||||
} catch (MalformedURLException error) {
|
||||
logger.log(Level.ERROR, "Unable to load player hats because of connection problems: " + error.getMessage());
|
||||
logger.log(System.Logger.Level.ERROR, "Unable to load player hats because of connection problems: " + error.getMessage());
|
||||
} catch (IOException error) {
|
||||
logger.log(Level.ERROR, "Unable to load player hats because of an I/O Exception: " + error.getMessage());
|
||||
logger.log(System.Logger.Level.ERROR, "Unable to load player hats because of an I/O Exception: " + error.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}).thenAcceptAsync(playerData -> {
|
||||
if (playerData != null) {
|
||||
PLAYER_HATS = playerData;
|
||||
logger.log(Level.INFO, "Player hats successfully loaded!");
|
||||
System.out.println("(MidnightLib) Player hats successfully loaded!");
|
||||
} else {
|
||||
PLAYER_HATS = Collections.emptyMap();
|
||||
logger.log(Level.WARN, "A problem with the database occurred, the hats could not be initialized.");
|
||||
logger.log(System.Logger.Level.WARNING, "A problem with the database occurred, the hats could not be initialized.");
|
||||
}
|
||||
}, MinecraftClient.getInstance());
|
||||
}
|
||||
|
||||
@@ -68,15 +68,14 @@ public class WitchHatFeatureRenderer<T extends LivingEntity, M extends EntityMod
|
||||
if (uuid.equals(MOTSCHEN)) {
|
||||
return MOTSCHEN_COLOR;
|
||||
} else if (HatLoader.PLAYER_HATS != null && HatLoader.PLAYER_HATS.containsKey(uuid)) {
|
||||
switch (HatLoader.PLAYER_HATS.get(uuid).getHatType()) {
|
||||
case "adopter": return ADOPTER_COLOR;
|
||||
case "contributer": // old name
|
||||
case "modder": return MODDER_COLOR;
|
||||
case "friend": return FRIEND_COLOR;
|
||||
case "donator": // old name
|
||||
case "donor": return DONOR_COLOR;
|
||||
case "social": return SOCIAL_COLOR;
|
||||
}
|
||||
return switch (HatLoader.PLAYER_HATS.get(uuid).getHatType()) {
|
||||
case "adopter" -> ADOPTER_COLOR;
|
||||
case "contributer", "modder" -> MODDER_COLOR;
|
||||
case "friend" -> FRIEND_COLOR;
|
||||
case "donator", "donor" -> DONOR_COLOR;
|
||||
case "social" -> SOCIAL_COLOR;
|
||||
default -> MidnightColorUtil.hex2Rgb(HatLoader.PLAYER_HATS.get(uuid).getHatType());
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,12 @@ import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Style;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -35,12 +36,13 @@ import java.lang.reflect.Modifier;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** MidnightConfig v2.0.0 by TeamMidnightDust & Motschen
|
||||
/** MidnightConfig v2.1.0 by TeamMidnightDust & Motschen
|
||||
* Single class config library - feel free to copy!
|
||||
*
|
||||
* Based on https://github.com/Minenash/TinyConfig
|
||||
@@ -50,6 +52,7 @@ import java.util.regex.Pattern;
|
||||
public abstract class MidnightConfig {
|
||||
private static final Pattern INTEGER_ONLY = Pattern.compile("(-?[0-9]*)");
|
||||
private static final Pattern DECIMAL_ONLY = Pattern.compile("-?([\\d]+\\.?[\\d]*|[\\d]*\\.?[\\d]+|\\.)");
|
||||
private static final Pattern HEXADECIMAL_ONLY = Pattern.compile("(-?[#0-9a-fA-F]*)");
|
||||
|
||||
private static final List<EntryInfo> entries = new ArrayList<>();
|
||||
|
||||
@@ -66,6 +69,7 @@ public abstract class MidnightConfig {
|
||||
String id;
|
||||
TranslatableText name;
|
||||
int index;
|
||||
ClickableWidget colorButton;
|
||||
}
|
||||
|
||||
public static final Map<String,Class<?>> configClass = new HashMap<>();
|
||||
@@ -79,7 +83,7 @@ public abstract class MidnightConfig {
|
||||
|
||||
for (Field field : config.getFields()) {
|
||||
EntryInfo info = new EntryInfo();
|
||||
if (field.isAnnotationPresent(Entry.class) || field.isAnnotationPresent(Comment.class))
|
||||
if ((field.isAnnotationPresent(Entry.class) || field.isAnnotationPresent(Comment.class)) && !field.isAnnotationPresent(Server.class))
|
||||
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) initClient(modid, field, info);
|
||||
if (field.isAnnotationPresent(Entry.class))
|
||||
try {
|
||||
@@ -108,7 +112,8 @@ public abstract class MidnightConfig {
|
||||
|
||||
if (e != null) {
|
||||
if (!e.name().equals("")) info.name = new TranslatableText(e.name());
|
||||
if (type == int.class) textField(info, Integer::parseInt, INTEGER_ONLY, e.min(), e.max(), true);
|
||||
if (type == int.class) textField(info, Integer::parseInt, INTEGER_ONLY, (int) e.min(), (int) e.max(), true);
|
||||
else if (type == float.class) textField(info, Float::parseFloat, DECIMAL_ONLY, (float) e.min(), (float) e.max(), false);
|
||||
else if (type == double.class) textField(info, Double::parseDouble, DECIMAL_ONLY, e.min(), e.max(), false);
|
||||
else if (type == String.class || type == List.class) {
|
||||
info.max = e.max() == Double.MAX_VALUE ? Integer.MAX_VALUE : (int) e.max();
|
||||
@@ -140,8 +145,6 @@ public abstract class MidnightConfig {
|
||||
|
||||
Number value = 0;
|
||||
boolean inLimits = false;
|
||||
System.out.println(((isNumber ^ s.isEmpty())));
|
||||
System.out.println(!s.equals("-") && !s.equals("."));
|
||||
info.error = null;
|
||||
if (!(isNumber && s.isEmpty()) && !s.equals("-") && !s.equals(".")) {
|
||||
value = f.apply(s);
|
||||
@@ -163,6 +166,13 @@ public abstract class MidnightConfig {
|
||||
((List<String>) info.value).set(info.index, Arrays.stream(info.tempValue.replace("[", "").replace("]", "").split(", ")).toList().get(0));
|
||||
}
|
||||
|
||||
if (info.field.getAnnotation(Entry.class).isColor()) {
|
||||
if (!s.contains("#")) s = '#' + s;
|
||||
if (!HEXADECIMAL_ONLY.matcher(s).matches()) return false;
|
||||
try {
|
||||
info.colorButton.setMessage(new LiteralText("⬛").setStyle(Style.EMPTY.withColor(Color.decode(info.tempValue).getRGB())));
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
@@ -254,7 +264,7 @@ public abstract class MidnightConfig {
|
||||
if (info.widget instanceof Map.Entry) {
|
||||
Map.Entry<ButtonWidget.PressAction, Function<Object, Text>> widget = (Map.Entry<ButtonWidget.PressAction, Function<Object, Text>>) info.widget;
|
||||
if (info.field.getType().isEnum()) widget.setValue(value -> new TranslatableText(translationPrefix + "enum." + info.field.getType().getSimpleName() + "." + info.value.toString()));
|
||||
this.list.addButton(new ButtonWidget(width - 160, 0,150, 20, widget.getValue().apply(info.value), widget.getKey()),resetButton, null,name);
|
||||
this.list.addButton(List.of(new ButtonWidget(width - 160, 0,150, 20, widget.getValue().apply(info.value), widget.getKey()),resetButton), name);
|
||||
} else if (info.field.getType() == List.class) {
|
||||
if (!reload) info.index = 0;
|
||||
TextFieldWidget widget = new TextFieldWidget(textRenderer, width - 160, 0, 150, 20, null);
|
||||
@@ -266,7 +276,6 @@ public abstract class MidnightConfig {
|
||||
resetButton.setWidth(20);
|
||||
resetButton.setMessage(new LiteralText("R").formatted(Formatting.RED));
|
||||
ButtonWidget cycleButton = new ButtonWidget(width - 185, 0, 20, 20, new LiteralText(String.valueOf(info.index)).formatted(Formatting.GOLD), (button -> {
|
||||
LogManager.getLogger("1").info(info.value);
|
||||
((List<String>)info.value).remove("");
|
||||
double scrollAmount = list.getScrollAmount();
|
||||
this.reload = true;
|
||||
@@ -275,16 +284,24 @@ public abstract class MidnightConfig {
|
||||
Objects.requireNonNull(client).setScreen(this);
|
||||
list.setScrollAmount(scrollAmount);
|
||||
}));
|
||||
this.list.addButton(widget, resetButton, cycleButton, name);
|
||||
this.list.addButton(List.of(widget, resetButton, cycleButton), name);
|
||||
} else if (info.widget != null) {
|
||||
TextFieldWidget widget = new TextFieldWidget(textRenderer, width - 160, 0, 150, 20, null);
|
||||
widget.setMaxLength(info.width);
|
||||
widget.setText(info.tempValue);
|
||||
Predicate<String> processor = ((BiFunction<TextFieldWidget, ButtonWidget, Predicate<String>>) info.widget).apply(widget, done);
|
||||
widget.setTextPredicate(processor);
|
||||
this.list.addButton(widget, resetButton, null, name);
|
||||
if (info.field.getAnnotation(Entry.class).isColor()) {
|
||||
resetButton.setWidth(20);
|
||||
resetButton.setMessage(new LiteralText("R").formatted(Formatting.RED));
|
||||
ButtonWidget colorButton = new ButtonWidget(width - 185, 0, 20, 20, new LiteralText("⬛"), (button -> {}));
|
||||
try {colorButton.setMessage(new LiteralText("⬛").setStyle(Style.EMPTY.withColor(Color.decode(info.tempValue).getRGB())));} catch (Exception ignored) {}
|
||||
info.colorButton = colorButton;
|
||||
this.list.addButton(List.of(widget, colorButton, resetButton), name);
|
||||
}
|
||||
else this.list.addButton(List.of(widget, resetButton), name);
|
||||
} else {
|
||||
this.list.addButton(null,null,null,name);
|
||||
this.list.addButton(List.of(),name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -329,15 +346,15 @@ public abstract class MidnightConfig {
|
||||
@Override
|
||||
public int getScrollbarPositionX() { return this.width -7; }
|
||||
|
||||
public void addButton(ClickableWidget button, ClickableWidget resetButton, ClickableWidget indexButton, Text text) {
|
||||
this.addEntry(ButtonEntry.create(button, text, resetButton, indexButton));
|
||||
public void addButton(List<ClickableWidget> buttons, Text text) {
|
||||
this.addEntry(ButtonEntry.create(buttons, text));
|
||||
}
|
||||
@Override
|
||||
public int getRowWidth() { return 10000; }
|
||||
public Optional<ClickableWidget> getHoveredButton(double mouseX, double mouseY) {
|
||||
for (ButtonEntry buttonEntry : this.children()) {
|
||||
if (buttonEntry.button != null && buttonEntry.button.isMouseOver(mouseX, mouseY)) {
|
||||
return Optional.of(buttonEntry.button);
|
||||
if (!buttonEntry.buttons.isEmpty() && buttonEntry.buttons.get(0).isMouseOver(mouseX, mouseY)) {
|
||||
return Optional.of(buttonEntry.buttons.get(0));
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
@@ -345,53 +362,37 @@ public abstract class MidnightConfig {
|
||||
}
|
||||
public static class ButtonEntry extends ElementListWidget.Entry<ButtonEntry> {
|
||||
private static final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
|
||||
public final ClickableWidget button;
|
||||
private final ClickableWidget resetButton;
|
||||
private final ClickableWidget indexButton;
|
||||
public final List<ClickableWidget> buttons;
|
||||
private final Text text;
|
||||
private final List<ClickableWidget> children = new ArrayList<>();
|
||||
public static final Map<ClickableWidget, Text> buttonsWithText = new HashMap<>();
|
||||
|
||||
private ButtonEntry(ClickableWidget button, Text text, ClickableWidget resetButton, ClickableWidget indexButton) {
|
||||
buttonsWithText.put(button,text);
|
||||
this.button = button;
|
||||
this.resetButton = resetButton;
|
||||
private ButtonEntry(List<ClickableWidget> buttons, Text text) {
|
||||
if (!buttons.isEmpty()) buttonsWithText.put(buttons.get(0),text);
|
||||
this.buttons = buttons;
|
||||
this.text = text;
|
||||
this.indexButton = indexButton;
|
||||
if (button != null) children.add(button);
|
||||
if (resetButton != null) children.add(resetButton);
|
||||
if (indexButton != null) children.add(indexButton);
|
||||
children.addAll(buttons);
|
||||
}
|
||||
public static ButtonEntry create(ClickableWidget button, Text text, ClickableWidget resetButton, ClickableWidget indexButton) {
|
||||
return new ButtonEntry(button, text, resetButton, indexButton);
|
||||
public static ButtonEntry create(List<ClickableWidget> buttons, Text text) {
|
||||
return new ButtonEntry(buttons, text);
|
||||
}
|
||||
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
|
||||
if (button != null) {
|
||||
button.y = y;
|
||||
button.render(matrices, mouseX, mouseY, tickDelta);
|
||||
}
|
||||
if (resetButton != null) {
|
||||
resetButton.y = y;
|
||||
resetButton.render(matrices, mouseX, mouseY, tickDelta);
|
||||
}
|
||||
if (indexButton != null) {
|
||||
indexButton.y = y;
|
||||
indexButton.render(matrices, mouseX, mouseY, tickDelta);
|
||||
}
|
||||
if (text != null && (!text.getString().contains("spacer") || button != null))
|
||||
DrawableHelper.drawTextWithShadow(matrices,textRenderer, text,12,y+5,0xFFFFFF);
|
||||
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);
|
||||
}
|
||||
public List<? extends Element> children() {return children;}
|
||||
public List<? extends Selectable> selectableChildren() {return children;}
|
||||
}
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Entry {
|
||||
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Entry {
|
||||
int width() default 100;
|
||||
double min() default Double.MIN_NORMAL;
|
||||
double max() default Double.MAX_VALUE;
|
||||
String name() default "";
|
||||
boolean isColor() default false;
|
||||
}
|
||||
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Client {}
|
||||
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Server {}
|
||||
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Comment {}
|
||||
|
||||
public static class HiddenAnnotationExclusionStrategy implements ExclusionStrategy {
|
||||
@@ -400,4 +401,4 @@ public abstract class MidnightConfig {
|
||||
return fieldAttributes.getAnnotation(Entry.class) == null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,13 +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(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
|
||||
|
||||
@@ -27,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.
|
||||
|
||||
@@ -10,15 +10,14 @@ public class MidnightColorUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* @credit https://stackoverflow.com/questions/4129666/how-to-convert-hex-to-rgb-using-java
|
||||
* @param colorStr e.g. "FFFFFF"
|
||||
* @param colorStr e.g. "FFFFFF" or "#FFFFFF"
|
||||
* @return Color as RGB
|
||||
*/
|
||||
public static Color hex2Rgb(String colorStr) {
|
||||
return new Color(
|
||||
Integer.valueOf( colorStr.substring( 0, 2 ), 16 ),
|
||||
Integer.valueOf( colorStr.substring( 2, 4 ), 16 ),
|
||||
Integer.valueOf( colorStr.substring( 4, 6 ), 16 ));
|
||||
try {
|
||||
return Color.decode("#" + colorStr.replace("#", ""));
|
||||
} catch (Exception ignored) {}
|
||||
return Color.BLACK;
|
||||
}
|
||||
|
||||
public static Color radialRainbow(float saturation, float brightness) {
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package eu.midnightdust.lib.util.render.entity;
|
||||
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.entity.feature.EyesFeatureRenderer;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class EmissiveOverlayRenderer<T extends LivingEntity> extends EyesFeatureRenderer<T, EntityModel<T>> {
|
||||
private final RenderLayer SKIN;
|
||||
|
||||
public EmissiveOverlayRenderer(FeatureRendererContext<T, EntityModel<T>> featureRendererContext, Identifier texture) {
|
||||
super(featureRendererContext);
|
||||
SKIN = RenderLayer.getEyes(texture);
|
||||
}
|
||||
public RenderLayer getEyesTexture() {
|
||||
return SKIN;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 672 B After Width: | Height: | Size: 293 B |
@@ -32,7 +32,7 @@
|
||||
},
|
||||
|
||||
"mixins": [
|
||||
"midnightcore.mixins.json"
|
||||
"midnightlib.mixins.json"
|
||||
],
|
||||
|
||||
"depends": {
|
||||
|
||||
Reference in New Issue
Block a user