mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-15 09:05:08 +01:00
Compare commits
2 Commits
aea8559831
...
9fe2ab78c6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9fe2ab78c6 | ||
|
|
19981cc3b5 |
@@ -42,7 +42,7 @@ allprojects {
|
||||
// for more information about repositories.
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = "UTF-8"
|
||||
options.release = 17
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ architectury {
|
||||
dependencies {
|
||||
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
|
||||
// Do NOT use other classes from fabric loader
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
// implementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
modImplementation "net.fabricmc:fabric-loader:0.16.13" //FIXME: Using the same floader version doesn't let you access it..? architectury moment
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.client.gui.screen.option.OptionsScreen;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@@ -17,7 +18,9 @@ import java.util.Objects;
|
||||
|
||||
@Mixin(OptionsScreen.class)
|
||||
public class MixinOptionsScreen extends Screen {
|
||||
@Unique
|
||||
private static final Identifier MIDNIGHTLIB_ICON_TEXTURE = new Identifier("midnightlib","textures/gui/midnightlib_button.png");
|
||||
|
||||
protected MixinOptionsScreen(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@@ -15,4 +15,4 @@ maven_group=eu.midnightdust
|
||||
fabric_loader_version=0.16.14
|
||||
fabric_api_version=0.92.6+1.20.1
|
||||
|
||||
mod_menu_version = 7.2.2
|
||||
mod_menu_version=7.2.2
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.tooltip.Tooltip;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
import net.minecraft.client.gui.widget.TextIconButtonWidget;
|
||||
import net.minecraft.client.gui.widget.IconButtonWidget;
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.text.MutableText;
|
||||
@@ -26,10 +26,13 @@ public class MidnightLibExtras {
|
||||
|
||||
public static void add(KeyBinding binding, MidnightConfig.MidnightConfigListWidget list, MidnightConfig.MidnightConfigScreen screen) {
|
||||
KeybindButton editButton = new KeybindButton(screen.width - 185, 0, 150, 20, binding);
|
||||
TextIconButtonWidget resetButton = TextIconButtonWidget.builder(Text.translatable("controls.reset"), (button -> {
|
||||
binding.setBoundKey(binding.getDefaultKey());
|
||||
screen.updateList();
|
||||
}), true).texture(Identifier.of("midnightlib","icon/reset"), 12, 12).dimension(20, 20).build();
|
||||
IconButtonWidget resetButton = IconButtonWidget.builder(
|
||||
Text.translatable("controls.reset"),
|
||||
Identifier.of("midnightlib", "icon/reset"),
|
||||
(button -> {
|
||||
binding.setBoundKey(binding.getDefaultKey());
|
||||
screen.updateList();
|
||||
})).textureSize(12, 12).iconSize(20, 20).build();
|
||||
resetButton.setPosition(screen.width - 205 + 150 + 25, 0);
|
||||
editButton.resetButton = resetButton;
|
||||
editButton.updateMessage(false);
|
||||
@@ -40,6 +43,7 @@ public class MidnightLibExtras {
|
||||
|
||||
private final KeyBinding binding;
|
||||
private @Nullable ClickableWidget resetButton;
|
||||
|
||||
public KeybindButton(int x, int y, int width, int height, KeyBinding binding) {
|
||||
super(x, y, width, height, binding.getBoundKeyLocalizedText(), (button) -> {
|
||||
((KeybindButton) button).updateMessage(true);
|
||||
@@ -48,6 +52,7 @@ public class MidnightLibExtras {
|
||||
this.binding = binding;
|
||||
updateMessage(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||
if (focusedButton == this) {
|
||||
@@ -67,12 +72,13 @@ public class MidnightLibExtras {
|
||||
public void updateMessage(boolean focused) {
|
||||
boolean hasConflicts = false;
|
||||
MutableText conflictingBindings = Text.empty();
|
||||
if (focused) this.setMessage(Text.literal("> ").append(this.binding.getBoundKeyLocalizedText().copy().formatted(Formatting.WHITE, Formatting.UNDERLINE)).append(" <").formatted(Formatting.YELLOW));
|
||||
if (focused)
|
||||
this.setMessage(Text.literal("> ").append(this.binding.getBoundKeyLocalizedText().copy().formatted(Formatting.WHITE, Formatting.UNDERLINE)).append(" <").formatted(Formatting.YELLOW));
|
||||
else {
|
||||
this.setMessage(this.binding.getBoundKeyLocalizedText());
|
||||
|
||||
if (!this.binding.isUnbound()) {
|
||||
for(KeyBinding keyBinding : MinecraftClient.getInstance().options.allKeys) {
|
||||
for (KeyBinding keyBinding : MinecraftClient.getInstance().options.allKeys) {
|
||||
if (keyBinding != this.binding && this.binding.equals(keyBinding)) {
|
||||
if (hasConflicts) conflictingBindings.append(", ");
|
||||
|
||||
|
||||
@@ -34,7 +34,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) 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, idMode = 0) public static Identifier id = Identifier.ofVanilla("diamond"); // Example for an identifier with matching items displayed next to it!
|
||||
@Entry(category = TEXT, idMode = 0) public static Identifier id = new Identifier("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
|
||||
public enum ModPlatform { // Enums allow the user to cycle through predefined options
|
||||
QUILT, FABRIC, FORGE, NEOFORGE, VANILLA
|
||||
@@ -52,7 +52,7 @@ public class MidnightConfigExample extends MidnightConfig {
|
||||
// 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, 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<Identifier> idList = Lists.newArrayList(Identifier.ofVanilla("dirt")); // A list of block identifiers
|
||||
@Entry(category = LISTS, name = "I am an identifier list!", idMode = 1) public static List<Identifier> idList = Lists.newArrayList(new Identifier("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 a float list!") public static List<Float> floatList = Lists.newArrayList(4.1f, -1.3f, -1f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user