diff --git a/CHANGELOG.md b/CHANGELOG.md index b301915..a1c0aec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,4 +73,19 @@ This update also has a backport 1.14.4 version ([#9](https://github.com/LambdAur - Added more API for compatibility handlers. - Improved reacharound API. - Improved [REI](https://www.curseforge.com/minecraft/mc-mods/roughly-enough-items) compatibility. - \ No newline at end of file + +## v1.4.0 + + - Added analog movements ([#10](https://github.com/LambdAurora/LambdaControls/issues/10)). + - Improved Ok Zoomer compability. + - Updated [SpruceUI](https://github.com/LambdAurora/SpruceUI) to 1.5.8 to ensure 1.16.2 compability. + - Internal changes: + - Added analog input value to button bindings. + - Replace lot of strings with Texts. + - Improved block outline rendering injection. + - Shadow library jars instead of Jar-in-Jar. + - Fixed crash in inventory ([#16](https://github.com/LambdAurora/LambdaControls/issues/16)) + - WIP: + - Started to work on action ring. + - Will allow for better compability with other mods. + - Might be interesting for keyboard users too. diff --git a/README.md b/README.md index 4e6a4a9..9035bbe 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,15 @@ ![Version](https://img.shields.io/github/v/tag/LambdAurora/LambdaControls?label=version&style=flat-square) [![CurseForge](http://cf.way2muchnoise.eu/title/354231.svg)](https://www.curseforge.com/minecraft/mc-mods/lambdacontrols) -A Fabric Minecraft mod which adds better controls like controller support. +A Fabric Minecraft mod which adds better controls, reach-around and controller support. ## What's this mod? +This mod adds better controls, reach-around features, etc. + Haven't you dreamed to travel in your modded Minecraft world with your controller? Yes? Then this mod is made for you! -This mod adds a controller support (and an experimental touchscreen support). +This mod also adds controller support. ## ✅ Features: @@ -21,7 +23,7 @@ This mod adds a controller support (and an experimental touchscreen support). - Touchscreen support (very experimental and buggy). - Keyboard controls to look around. - Toggleable on screen button indicator (like in Bedrock Edition). - - Vertical reacharound. + - Vertical reach-around. - Many Bedrock Edition features: - Toggleable fly drifting - Front block placing (be careful with this one) diff --git a/build.gradle b/build.gradle index 960a8f5..3a61131 100644 --- a/build.gradle +++ b/build.gradle @@ -20,14 +20,6 @@ allprojects { options.encoding = "UTF-8" } - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this task, sources will not be generated. - task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" - from sourceSets.main.allSource - } - publishing { repositories { mavenLocal() diff --git a/core/build.gradle b/core/build.gradle index 18a4eca..316166e 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -15,6 +15,8 @@ dependencies { java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 + + withSourcesJar() } publishing { diff --git a/fabric/build.gradle b/fabric/build.gradle index c3fe3fb..3276186 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,3 +1,5 @@ +import net.fabricmc.loom.task.RemapJarTask + plugins { id 'fabric-loom' version '0.4-SNAPSHOT' id 'java-library' @@ -38,28 +40,27 @@ dependencies { //to change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}" - modCompile "net.fabricmc:fabric-loader:${project.loader_version}" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" // Fabric API. This is technically optional, but you probably want it anyway. - modApi "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modCompile "io.github.prospector:modmenu:${project.modmenu_version}" - modCompile "com.github.lambdaurora:spruceui:${project.spruceui_version}" + modImplementation "io.github.prospector:modmenu:${project.modmenu_version}" + modImplementation "com.github.lambdaurora:spruceui:${project.spruceui_version}" include "com.github.lambdaurora:spruceui:${project.spruceui_version}" // Compatibility mods - modCompile "io.github.joaoh1:okzoomer:4.0.0-alpha.3.1.16.pre5" - modCompile "me.shedaniel:RoughlyEnoughItems:4.5.5" + modImplementation "io.github.joaoh1:okzoomer:4.0.0-alpha.4.1.16.1" + modImplementation "me.shedaniel:RoughlyEnoughItems:4.5.5" api project(":core") shadow project(":core") - include "org.jetbrains:annotations:17.0.0" - include("org.aperlambda:lambdajcommon:1.8.0") { + shadow("org.aperlambda:lambdajcommon:1.8.0") { exclude group: 'com.google.code.gson' exclude group: 'com.google.guava' } - include "com.electronwill.night-config:core:3.5.3" - include "com.electronwill.night-config:toml:3.5.3" + shadow "com.electronwill.night-config:core:3.5.3" + shadow "com.electronwill.night-config:toml:3.5.3" } processResources { @@ -78,6 +79,8 @@ processResources { java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 + + withSourcesJar() } jar { @@ -92,6 +95,26 @@ jar { } } +task shadowJar(type: Jar) { + archiveClassifier.set("dev") + + from sourceSets.main.output + + from { + configurations.shadow.collect { + it.isDirectory() ? it : zipTree(it) + } + } +} + +task shadowRemapJar(type: RemapJarTask) { + dependsOn shadowJar + + input = file("${project.buildDir}/libs/$archivesBaseName-$version-dev.jar") + archiveName = "${archivesBaseName}-${version}.jar" + addNestedDependencies = true +} + // configure the maven publication publishing { publications { @@ -107,5 +130,6 @@ publishing { } } +shadowJar.dependsOn(":core:jar") build.dependsOn(":core:build") publish.dependsOn(":core:publish") diff --git a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/ControllerType.java b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/ControllerType.java index d0aa396..be024c2 100644 --- a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/ControllerType.java +++ b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/ControllerType.java @@ -9,7 +9,8 @@ package me.lambdaurora.lambdacontrols.client; -import net.minecraft.client.resource.language.I18n; +import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import org.aperlambda.lambdacommon.utils.Nameable; import org.jetbrains.annotations.NotNull; @@ -20,7 +21,7 @@ import java.util.Optional; * Represents a controller type. * * @author LambdAurora - * @version 1.0.0 + * @version 1.4.0 * @since 1.0.0 */ public enum ControllerType implements Nameable @@ -32,11 +33,13 @@ public enum ControllerType implements Nameable STEAM(4), OUYA(5); - private final int id; + private final int id; + private final Text text; ControllerType(int id) { this.id = id; + this.text = new TranslatableText(this.getTranslationKey()); } /** @@ -54,7 +57,7 @@ public enum ControllerType implements Nameable * * @return The next available controller type. */ - public ControllerType next() + public @NotNull ControllerType next() { ControllerType[] v = values(); if (v.length == this.ordinal() + 1) @@ -63,13 +66,23 @@ public enum ControllerType implements Nameable } /** - * Gets the translated name of this controller type. + * Returns the translation key of this controller type. * - * @return The translated name of this controller type. + * @return The translation key. */ - public String getTranslatedName() + public @NotNull String getTranslationKey() { - return I18n.translate("lambdacontrols.controller_type." + this.getName()); + return "lambdacontrols.controller_type." + this.getName(); + } + + /** + * Gets the translated text of this controller type. + * + * @return The translated text of this controller type. + */ + public @NotNull Text getTranslatedText() + { + return this.text; } @Override @@ -84,7 +97,7 @@ public enum ControllerType implements Nameable * @param id The identifier of the controller type. * @return The controller type if found, else empty. */ - public static Optional byId(@NotNull String id) + public static @NotNull Optional byId(@NotNull String id) { return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst(); } diff --git a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/HudSide.java b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/HudSide.java index 7252e81..e179e44 100644 --- a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/HudSide.java +++ b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/HudSide.java @@ -10,6 +10,8 @@ package me.lambdaurora.lambdacontrols.client; import net.minecraft.client.resource.language.I18n; +import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import org.aperlambda.lambdacommon.utils.Nameable; import org.jetbrains.annotations.NotNull; @@ -20,7 +22,7 @@ import java.util.Optional; * Represents the hud side which is the side where the movements buttons are. * * @author LambdAurora - * @version 1.0.0 + * @version 1.4.0 * @since 1.0.0 */ public enum HudSide implements Nameable @@ -28,12 +30,19 @@ public enum HudSide implements Nameable LEFT, RIGHT; + private final Text text; + + HudSide() + { + this.text = new TranslatableText(this.getTranslationKey()); + } + /** * Returns the next side available. * * @return The next available side. */ - public HudSide next() + public @NotNull HudSide next() { HudSide[] v = values(); if (v.length == this.ordinal() + 1) @@ -42,13 +51,23 @@ public enum HudSide implements Nameable } /** - * Gets the translated name of this hud side. + * Returns the translation key of this hud side. * - * @return The translated name of this hud side. + * @return The translation key of this hude side. */ - public String getTranslatedName() + public @NotNull String getTranslationKey() { - return I18n.translate("lambdacontrols.hud_side." + this.getName()); + return "lambdacontrols.hud_side." + this.getName(); + } + + /** + * Gets the translated text of this hud side. + * + * @return The translated text of this hud side. + */ + public @NotNull Text getTranslatedText() + { + return this.text; } @Override @@ -63,7 +82,7 @@ public enum HudSide implements Nameable * @param id The identifier of the hud side. * @return The hud side if found, else empty. */ - public static Optional byId(@NotNull String id) + public static @NotNull Optional byId(@NotNull String id) { return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst(); } diff --git a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/VirtualMouseSkin.java b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/VirtualMouseSkin.java index 6739188..6e65284 100644 --- a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/VirtualMouseSkin.java +++ b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/VirtualMouseSkin.java @@ -9,7 +9,8 @@ package me.lambdaurora.lambdacontrols.client; -import net.minecraft.client.resource.language.I18n; +import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import org.aperlambda.lambdacommon.utils.Nameable; import org.jetbrains.annotations.NotNull; @@ -19,7 +20,7 @@ import java.util.Optional; /** * Represents the virtual mouse skins. * - * @version 1.2.0 + * @version 1.4.0 * @since 1.2.0 */ public enum VirtualMouseSkin implements Nameable @@ -29,11 +30,13 @@ public enum VirtualMouseSkin implements Nameable SECOND_LIGHT("second_light"), SECOND_DARK("second_dark"); - private String name; + private final String name; + private final Text text; VirtualMouseSkin(String name) { this.name = name; + this.text = new TranslatableText(this.getTranslationKey()); } /** @@ -41,7 +44,7 @@ public enum VirtualMouseSkin implements Nameable * * @return The next available virtual mouse skin. */ - public VirtualMouseSkin next() + public @NotNull VirtualMouseSkin next() { VirtualMouseSkin[] v = values(); if (v.length == this.ordinal() + 1) @@ -50,13 +53,23 @@ public enum VirtualMouseSkin implements Nameable } /** - * Gets the translated name of this controller type. + * Returns the translation key of this virtual mouse skin. * - * @return The translated name of this controller type. + * @return The virtual mouse skin's translation key. */ - public String getTranslatedName() + public @NotNull String getTranslationKey() { - return I18n.translate("lambdacontrols.virtual_mouse.skin." + this.getName()); + return "lambdacontrols.virtual_mouse.skin." + this.getName(); + } + + /** + * Gets the translated text of this virtual mouse skin. + * + * @return The translated text of this virtual mouse skin. + */ + public @NotNull Text getTranslatedText() + { + return this.text; } @Override @@ -66,12 +79,12 @@ public enum VirtualMouseSkin implements Nameable } /** - * Gets the controller type from its identifier. + * Gets the virtual mouse skin from its identifier. * - * @param id The identifier of the controller type. - * @return The controller type if found, else empty. + * @param id The identifier of the virtual mouse skin. + * @return The virtual mouse skin if found, else empty. */ - public static Optional byId(@NotNull String id) + public static @NotNull Optional byId(@NotNull String id) { return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst(); } diff --git a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/LambdaControlsCompat.java b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/LambdaControlsCompat.java index 4bb011d..3beb93c 100644 --- a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/LambdaControlsCompat.java +++ b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/LambdaControlsCompat.java @@ -41,7 +41,7 @@ public class LambdaControlsCompat */ public static void init(@NotNull LambdaControlsClient mod) { - if (FabricLoader.getInstance().isModLoaded("okzoomer") && LambdaReflection.doesClassExist(OkZoomerCompat.OKZOOMER_CLASS_PATH)) { + if (FabricLoader.getInstance().isModLoaded("okzoomer")) { mod.log("Adding okzoomer compatibility..."); HANDLERS.add(new OkZoomerCompat()); } diff --git a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/OkZoomerCompat.java b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/OkZoomerCompat.java index 75b7ec4..a540531 100644 --- a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/OkZoomerCompat.java +++ b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/OkZoomerCompat.java @@ -10,8 +10,10 @@ package me.lambdaurora.lambdacontrols.client.compat; import io.github.joaoh1.okzoomer.client.OkZoomerClientMod; +import io.github.joaoh1.okzoomer.main.OkZoomerMod; import me.lambdaurora.lambdacontrols.client.LambdaControlsClient; import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding; +import org.aperlambda.lambdacommon.Identifier; import org.jetbrains.annotations.NotNull; import org.lwjgl.glfw.GLFW; @@ -37,6 +39,25 @@ public class OkZoomerCompat implements CompatHandler .linkKeybind(OkZoomerClientMod.zoomKeyBinding) .register(); - // @TODO Zoom in and out + new ButtonBinding.Builder("zoom.in") + .buttons(GLFW.GLFW_GAMEPAD_BUTTON_DPAD_UP, ButtonBinding.axisAsButton(GLFW.GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER, true)) + .onlyInGame() + .cooldown(true) + .category(ButtonBinding.MISC_CATEGORY) + .linkKeybind(OkZoomerClientMod.increaseZoomKeyBinding) + .register(); + new ButtonBinding.Builder("zoom.out") + .buttons(GLFW.GLFW_GAMEPAD_BUTTON_DPAD_UP, ButtonBinding.axisAsButton(GLFW.GLFW_GAMEPAD_AXIS_LEFT_TRIGGER, true)) + .onlyInGame() + .cooldown(true) + .category(ButtonBinding.MISC_CATEGORY) + .linkKeybind(OkZoomerClientMod.decreaseZoomKeyBinding) + .register(); + new ButtonBinding.Builder("zoom.reset") + .onlyInGame() + .cooldown(true) + .category(ButtonBinding.MISC_CATEGORY) + .linkKeybind(OkZoomerClientMod.resetZoomKeyBinding) + .register(); } } diff --git a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/mixin/RecipeViewingScreenAccessor.java b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/mixin/RecipeViewingScreenAccessor.java index b4e3ad6..97e5090 100644 --- a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/mixin/RecipeViewingScreenAccessor.java +++ b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/mixin/RecipeViewingScreenAccessor.java @@ -21,7 +21,7 @@ import org.spongepowered.asm.mixin.gen.Accessor; * @version 1.3.0 * @since 1.2.0 */ -@Mixin(RecipeViewingScreen.class) +@Mixin(value = RecipeViewingScreen.class, remap = false) public interface RecipeViewingScreenAccessor { @Accessor("categoryBack") diff --git a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/mixin/VillagerRecipeViewingScreenAccessor.java b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/mixin/VillagerRecipeViewingScreenAccessor.java index e7cdc2e..39e6968 100644 --- a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/mixin/VillagerRecipeViewingScreenAccessor.java +++ b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/compat/mixin/VillagerRecipeViewingScreenAccessor.java @@ -24,7 +24,7 @@ import java.util.List; * @version 1.2.0 * @since 1.2.0 */ -@Mixin(VillagerRecipeViewingScreen.class) +@Mixin(value = VillagerRecipeViewingScreen.class, remap = false) public interface VillagerRecipeViewingScreenAccessor { @Accessor("categories") diff --git a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/gui/ControllerControlsScreen.java b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/gui/ControllerControlsScreen.java index 02d47f4..01a11e7 100644 --- a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/gui/ControllerControlsScreen.java +++ b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/gui/ControllerControlsScreen.java @@ -13,6 +13,7 @@ import me.lambdaurora.lambdacontrols.client.LambdaControlsClient; import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding; import me.lambdaurora.lambdacontrols.client.controller.InputManager; import me.lambdaurora.spruceui.SpruceButtonWidget; +import me.lambdaurora.spruceui.SpruceTexts; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.options.ControlsOptionsScreen; import net.minecraft.client.gui.widget.ButtonWidget; @@ -61,7 +62,7 @@ public class ControllerControlsScreen extends Screen btn -> this.client.openScreen(new ControlsOptionsScreen(this, this.client.options)))); if (!this.hideSettings) this.addButton(new SpruceButtonWidget(this.width / 2 - 155 + 160, 18, 150, 20, - new TranslatableText("menu.options"), + SpruceTexts.MENU_OPTIONS, btn -> this.client.openScreen(new LambdaControlsSettingsScreen(this, true)))); this.bindingsListWidget = new ControlsListWidget(this, this.client); this.children.add(this.bindingsListWidget); @@ -69,7 +70,7 @@ public class ControllerControlsScreen extends Screen new TranslatableText("controls.resetAll"), btn -> InputManager.streamBindings().forEach(binding -> this.mod.config.setButtonBinding(binding, binding.getDefaultButton())))); this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, 20, - new TranslatableText("gui.done"), + SpruceTexts.GUI_DONE, btn -> this.client.openScreen(this.parent))); } diff --git a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/gui/ControlsListWidget.java b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/gui/ControlsListWidget.java index d48afe4..6fcc4e1 100644 --- a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/gui/ControlsListWidget.java +++ b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/gui/ControlsListWidget.java @@ -12,6 +12,7 @@ package me.lambdaurora.lambdacontrols.client.gui; import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding; import me.lambdaurora.lambdacontrols.client.controller.ButtonCategory; import me.lambdaurora.lambdacontrols.client.controller.InputManager; +import me.lambdaurora.spruceui.SpruceTexts; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -105,7 +106,7 @@ public class ControlsListWidget extends ElementListWidget { gui.mod.config.setButtonBinding(binding, UNBOUND); gui.focusedBinding = null; diff --git a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/gui/LambdaControlsSettingsScreen.java b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/gui/LambdaControlsSettingsScreen.java index c600f24..ed51b14 100644 --- a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/gui/LambdaControlsSettingsScreen.java +++ b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/gui/LambdaControlsSettingsScreen.java @@ -15,6 +15,7 @@ import me.lambdaurora.lambdacontrols.client.LambdaControlsClient; import me.lambdaurora.lambdacontrols.client.controller.Controller; import me.lambdaurora.spruceui.SpruceButtonWidget; import me.lambdaurora.spruceui.SpruceLabelWidget; +import me.lambdaurora.spruceui.SpruceTexts; import me.lambdaurora.spruceui.Tooltip; import me.lambdaurora.spruceui.option.*; import net.fabricmc.fabric.api.network.ClientSidePacketRegistry; @@ -87,14 +88,14 @@ public class LambdaControlsSettingsScreen extends Screen synchronized (this.mod.config) { this.mod.config.setRotationSpeed(newValue); } - }, option -> option.getDisplayPrefix().append(String.valueOf(option.get())), + }, option -> option.getDisplayText(new LiteralText(String.valueOf(option.get()))), new TranslatableText("lambdacontrols.tooltip.rotation_speed")); this.mouseSpeedOption = new SpruceDoubleOption("lambdacontrols.menu.mouse_speed", 0.0, 150.0, 0.5F, this.mod.config::getMouseSpeed, newValue -> { synchronized (this.mod.config) { this.mod.config.setMouseSpeed(newValue); } - }, option -> option.getDisplayPrefix().append(String.valueOf(option.get())), + }, option -> option.getDisplayText(new LiteralText(String.valueOf(option.get()))), new TranslatableText("lambdacontrols.tooltip.mouse_speed")); this.resetOption = new SpruceResetOption(btn -> { this.mod.config.reset(); @@ -123,11 +124,11 @@ public class LambdaControlsSettingsScreen extends Screen }, option -> { String controllerName = this.mod.config.getController().getName(); if (!this.mod.config.getController().isConnected()) - return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.RED)); + return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.RED)); else if (!this.mod.config.getController().isGamepad()) - return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.GOLD)); + return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.GOLD)); else - return option.getDisplayPrefix().append(controllerName); + return option.getDisplayText(new LiteralText(controllerName)); }, null); this.secondControllerOption = new SpruceCyclingOption("lambdacontrols.menu.controller2", amount -> { @@ -139,16 +140,16 @@ public class LambdaControlsSettingsScreen extends Screen }, option -> this.mod.config.getSecondController().map(controller -> { String controllerName = controller.getName(); if (!controller.isConnected()) - return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.RED)); + return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.RED)); else if (!controller.isGamepad()) - return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.GOLD)); + return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.GOLD)); else - return option.getDisplayPrefix().append(controllerName); - }).orElse(option.getDisplayPrefix().append(new TranslatableText("options.off").formatted(Formatting.RED))), + return option.getDisplayText(new LiteralText(controllerName)); + }).orElse(option.getDisplayText(SpruceTexts.OPTIONS_OFF.shallowCopy().formatted(Formatting.RED))), new TranslatableText("lambdacontrols.tooltip.controller2")); this.controllerTypeOption = new SpruceCyclingOption("lambdacontrols.menu.controller_type", amount -> this.mod.config.setControllerType(this.mod.config.getControllerType().next()), - option -> option.getDisplayPrefix().append(this.mod.config.getControllerType().getTranslatedName()), + option -> option.getDisplayText(this.mod.config.getControllerType().getTranslatedText()), new TranslatableText("lambdacontrols.tooltip.controller_type")); this.deadZoneOption = new SpruceDoubleOption("lambdacontrols.menu.dead_zone", 0.05, 1.0, 0.05F, this.mod.config::getDeadZone, newValue -> { @@ -157,7 +158,7 @@ public class LambdaControlsSettingsScreen extends Screen } }, option -> { String value = String.valueOf(option.get()); - return option.getDisplayPrefix().append(value.substring(0, Math.min(value.length(), 5))); + return option.getDisplayText(new LiteralText(value.substring(0, Math.min(value.length(), 5)))); }, new TranslatableText("lambdacontrols.tooltip.dead_zone")); this.invertsRightXAxis = new SpruceBooleanOption("lambdacontrols.menu.invert_right_x_axis", this.mod.config::doesInvertRightXAxis, newValue -> { @@ -177,14 +178,14 @@ public class LambdaControlsSettingsScreen extends Screen this.mod.config::setVirtualMouse, new TranslatableText("lambdacontrols.tooltip.virtual_mouse"), true); this.virtualMouseSkinOption = new SpruceCyclingOption("lambdacontrols.menu.virtual_mouse.skin", amount -> this.mod.config.setVirtualMouseSkin(this.mod.config.getVirtualMouseSkin().next()), - option -> option.getDisplayPrefix().append(this.mod.config.getVirtualMouseSkin().getTranslatedName()), + option -> option.getDisplayText(this.mod.config.getVirtualMouseSkin().getTranslatedText()), null); // HUD options this.hudEnableOption = new SpruceBooleanOption("lambdacontrols.menu.hud_enable", this.mod.config::isHudEnabled, this.mod::setHudEnabled, new TranslatableText("lambdacontrols.tooltip.hud_enable"), true); this.hudSideOption = new SpruceCyclingOption("lambdacontrols.menu.hud_side", amount -> this.mod.config.setHudSide(this.mod.config.getHudSide().next()), - option -> option.getDisplayPrefix().append(this.mod.config.getHudSide().getTranslatedName()), + option -> option.getDisplayText(this.mod.config.getHudSide().getTranslatedText()), new TranslatableText("lambdacontrols.tooltip.hud_side")); } @@ -266,7 +267,7 @@ public class LambdaControlsSettingsScreen extends Screen this.children.add(this.gamepadToolUrlLabel); this.addButton(this.resetOption.createButton(this.client.options, this.width / 2 - 155, this.height - 29, 150)); - this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, buttonHeight, new TranslatableText("gui.done"), + this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, buttonHeight, SpruceTexts.GUI_DONE, (buttonWidget) -> this.client.openScreen(this.parent))); } diff --git a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/ring/RingButtonMode.java b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/ring/RingButtonMode.java index 3e45703..44759a7 100644 --- a/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/ring/RingButtonMode.java +++ b/fabric/src/main/java/me/lambdaurora/lambdacontrols/client/ring/RingButtonMode.java @@ -9,7 +9,8 @@ package me.lambdaurora.lambdacontrols.client.ring; -import net.minecraft.client.resource.language.I18n; +import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import org.aperlambda.lambdacommon.utils.Nameable; import org.jetbrains.annotations.NotNull; @@ -26,11 +27,13 @@ public enum RingButtonMode implements Nameable HOLD("hold"), TOGGLE("toggle"); - private String name; + private final String name; + private final Text text; RingButtonMode(@NotNull String name) { this.name = name; + this.text = new TranslatableText(this.getTranslationKey()); } /** @@ -38,7 +41,7 @@ public enum RingButtonMode implements Nameable * * @return The next ring button mode. */ - public RingButtonMode next() + public @NotNull RingButtonMode next() { RingButtonMode[] v = values(); if (v.length == this.ordinal() + 1) @@ -46,14 +49,24 @@ public enum RingButtonMode implements Nameable return v[this.ordinal() + 1]; } + /** + * Returns the translation key of this ring button mode. + * + * @return The translation key of this ring button mode. + */ + public @NotNull String getTranslationKey() + { + return "lambdacontrols.ring.button_mode." + this.getName(); + } + /** * Gets the translated name of this ring button mode. * * @return The translated name of this ring button mode. */ - public String getTranslatedName() + public @NotNull Text getTranslatedText() { - return I18n.translate("lambdacontrols.ring.button_mode." + this.getName()); + return this.text; } @Override diff --git a/fabric/src/main/resources/assets/lambdacontrols/lang/en_us.json b/fabric/src/main/resources/assets/lambdacontrols/lang/en_us.json index e99b5d0..526457a 100644 --- a/fabric/src/main/resources/assets/lambdacontrols/lang/en_us.json +++ b/fabric/src/main/resources/assets/lambdacontrols/lang/en_us.json @@ -31,6 +31,9 @@ "lambdacontrols.action.toggle_smooth_camera": "Toggle Cinematic Camera", "lambdacontrols.action.use": "Use", "lambdacontrols.action.zoom": "Zoom", + "lambdacontrols.action.zoom.in": "Increase Zoom", + "lambdacontrols.action.zoom.out": "Decrease Zoom", + "lambdacontrols.action.zoom.reset": "Reset Zoom", "lambdacontrols.button.a": "A", "lambdacontrols.button.b": "B", "lambdacontrols.button.x": "X", @@ -98,7 +101,6 @@ "lambdacontrols.menu.title.gameplay": "Gameplay Options", "lambdacontrols.menu.title.general": "General Options", "lambdacontrols.menu.title.hud": "HUD Options", - "lambdacontrols.menu.unbound": "Unbound", "lambdacontrols.menu.unfocused_input": "Unfocused Input", "lambdacontrols.menu.virtual_mouse": "Virtual Mouse", "lambdacontrols.menu.virtual_mouse.skin": "Virtual Mouse Skin", diff --git a/fabric/src/main/resources/assets/lambdacontrols/lang/fr_ca.json b/fabric/src/main/resources/assets/lambdacontrols/lang/fr_ca.json index d2fcf0a..1ac3331 100644 --- a/fabric/src/main/resources/assets/lambdacontrols/lang/fr_ca.json +++ b/fabric/src/main/resources/assets/lambdacontrols/lang/fr_ca.json @@ -97,7 +97,6 @@ "lambdacontrols.menu.title.gameplay": "Options de Gameplay", "lambdacontrols.menu.title.general": "Options générales", "lambdacontrols.menu.title.hud": "Options du HUD", - "lambdacontrols.menu.unbound": "Délier", "lambdacontrols.menu.unfocused_input": "Entrée en fond", "lambdacontrols.menu.virtual_mouse": "Souris virtuelle", "lambdacontrols.menu.virtual_mouse.skin": "Apparence souris virtuelle", diff --git a/fabric/src/main/resources/assets/lambdacontrols/lang/fr_fr.json b/fabric/src/main/resources/assets/lambdacontrols/lang/fr_fr.json index d2fcf0a..1ac3331 100644 --- a/fabric/src/main/resources/assets/lambdacontrols/lang/fr_fr.json +++ b/fabric/src/main/resources/assets/lambdacontrols/lang/fr_fr.json @@ -97,7 +97,6 @@ "lambdacontrols.menu.title.gameplay": "Options de Gameplay", "lambdacontrols.menu.title.general": "Options générales", "lambdacontrols.menu.title.hud": "Options du HUD", - "lambdacontrols.menu.unbound": "Délier", "lambdacontrols.menu.unfocused_input": "Entrée en fond", "lambdacontrols.menu.virtual_mouse": "Souris virtuelle", "lambdacontrols.menu.virtual_mouse.skin": "Apparence souris virtuelle", diff --git a/gradle.properties b/gradle.properties index 378f447..d41b814 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use minecraft_version=1.16.1 - yarn_mappings=1.16.1+build.18:v2 - loader_version=0.8.8+build.202 + yarn_mappings=1.16.1+build.21:v2 + loader_version=0.9.0+build.204 # Mod Properties mod_version = 1.4.0 @@ -14,6 +14,6 @@ org.gradle.jvmargs=-Xmx1G # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.14.0+build.371-1.16 - spruceui_version=1.5.2 + fabric_version=0.15.0+build.379-1.16.1 + spruceui_version=1.5.9 modmenu_version=1.12.2+build.17 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf..62d4c05 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 03d4db9..622ab64 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Mon Oct 28 18:23:18 CET 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip diff --git a/gradlew b/gradlew index 8e25e6c..fbd7c51 100644 --- a/gradlew +++ b/gradlew @@ -82,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -125,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -154,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -175,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 9618d8d..a9f778a 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,100 +1,104 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega