mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-15 17:05:09 +01:00
Merge pull request #1 from x-random-forks/architectury-1.20.1
This commit is contained in:
@@ -42,7 +42,7 @@ allprojects {
|
|||||||
// for more information about repositories.
|
// for more information about repositories.
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
options.release = 17
|
options.release = 17
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ architectury {
|
|||||||
dependencies {
|
dependencies {
|
||||||
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin 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
|
// 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 {
|
publishing {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.minecraft.client.gui.screen.option.OptionsScreen;
|
|||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
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.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
@@ -17,7 +18,9 @@ import java.util.Objects;
|
|||||||
|
|
||||||
@Mixin(OptionsScreen.class)
|
@Mixin(OptionsScreen.class)
|
||||||
public class MixinOptionsScreen extends Screen {
|
public class MixinOptionsScreen extends Screen {
|
||||||
|
@Unique
|
||||||
private static final Identifier MIDNIGHTLIB_ICON_TEXTURE = new Identifier("midnightlib","textures/gui/midnightlib_button.png");
|
private static final Identifier MIDNIGHTLIB_ICON_TEXTURE = new Identifier("midnightlib","textures/gui/midnightlib_button.png");
|
||||||
|
|
||||||
protected MixinOptionsScreen(Text title) {
|
protected MixinOptionsScreen(Text title) {
|
||||||
super(title);
|
super(title);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,4 +15,4 @@ maven_group=eu.midnightdust
|
|||||||
fabric_loader_version=0.16.14
|
fabric_loader_version=0.16.14
|
||||||
fabric_api_version=0.92.6+1.20.1
|
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.tooltip.Tooltip;
|
||||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
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.option.KeyBinding;
|
||||||
import net.minecraft.client.util.InputUtil;
|
import net.minecraft.client.util.InputUtil;
|
||||||
import net.minecraft.text.MutableText;
|
import net.minecraft.text.MutableText;
|
||||||
@@ -26,10 +26,13 @@ public class MidnightLibExtras {
|
|||||||
|
|
||||||
public static void add(KeyBinding binding, MidnightConfig.MidnightConfigListWidget list, MidnightConfig.MidnightConfigScreen screen) {
|
public static void add(KeyBinding binding, MidnightConfig.MidnightConfigListWidget list, MidnightConfig.MidnightConfigScreen screen) {
|
||||||
KeybindButton editButton = new KeybindButton(screen.width - 185, 0, 150, 20, binding);
|
KeybindButton editButton = new KeybindButton(screen.width - 185, 0, 150, 20, binding);
|
||||||
TextIconButtonWidget resetButton = TextIconButtonWidget.builder(Text.translatable("controls.reset"), (button -> {
|
IconButtonWidget resetButton = IconButtonWidget.builder(
|
||||||
binding.setBoundKey(binding.getDefaultKey());
|
Text.translatable("controls.reset"),
|
||||||
screen.updateList();
|
Identifier.of("midnightlib", "icon/reset"),
|
||||||
}), true).texture(Identifier.of("midnightlib","icon/reset"), 12, 12).dimension(20, 20).build();
|
(button -> {
|
||||||
|
binding.setBoundKey(binding.getDefaultKey());
|
||||||
|
screen.updateList();
|
||||||
|
})).textureSize(12, 12).iconSize(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);
|
||||||
@@ -40,6 +43,7 @@ public class MidnightLibExtras {
|
|||||||
|
|
||||||
private final KeyBinding binding;
|
private final KeyBinding binding;
|
||||||
private @Nullable ClickableWidget resetButton;
|
private @Nullable ClickableWidget resetButton;
|
||||||
|
|
||||||
public KeybindButton(int x, int y, int width, int height, KeyBinding binding) {
|
public KeybindButton(int x, int y, int width, int height, KeyBinding binding) {
|
||||||
super(x, y, width, height, binding.getBoundKeyLocalizedText(), (button) -> {
|
super(x, y, width, height, binding.getBoundKeyLocalizedText(), (button) -> {
|
||||||
((KeybindButton) button).updateMessage(true);
|
((KeybindButton) button).updateMessage(true);
|
||||||
@@ -48,6 +52,7 @@ public class MidnightLibExtras {
|
|||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
updateMessage(false);
|
updateMessage(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||||
if (focusedButton == this) {
|
if (focusedButton == this) {
|
||||||
@@ -67,12 +72,13 @@ public class MidnightLibExtras {
|
|||||||
public void updateMessage(boolean focused) {
|
public void updateMessage(boolean focused) {
|
||||||
boolean hasConflicts = false;
|
boolean hasConflicts = false;
|
||||||
MutableText conflictingBindings = Text.empty();
|
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 {
|
else {
|
||||||
this.setMessage(this.binding.getBoundKeyLocalizedText());
|
this.setMessage(this.binding.getBoundKeyLocalizedText());
|
||||||
|
|
||||||
if (!this.binding.isUnbound()) {
|
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 (keyBinding != this.binding && this.binding.equals(keyBinding)) {
|
||||||
if (hasConflicts) conflictingBindings.append(", ");
|
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, 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 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
|
@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
|
||||||
@@ -52,7 +52,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<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 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);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user