Compare commits

..

11 Commits
v1.6.0 ... 1.18

Author SHA1 Message Date
Martin Prokoph
3a70ab1961 Merge pull request #87 from spudpiggy/patch-1
fix some assets
2022-09-20 14:26:24 +00:00
spudpiggy
1722c2ccaa fix en lang file + fix packs 2022-08-10 12:27:00 +01:00
spudpiggy
46dafc3e71 Reword description of bedrock resource pack 2022-08-10 12:19:33 +01:00
Motschen
99298b2bc4 Fix 1.18 2022-08-03 12:42:23 +02:00
Martin Prokoph
070083ab6e Merge pull request #82 from TeamMidnightDust/1.18-temp
Backport 1.5.0 to 1.18
2022-08-03 10:25:51 +00:00
Martin Prokoph
4d74892e53 Merge branch '1.18' into 1.18-temp 2022-08-03 10:25:21 +00:00
Motschen
e8cfee7de5 Clearly differenciate the 1.18 version 2022-07-06 14:24:44 +02:00
Martin Prokoph
06c589e7f8 Merge pull request #63 from TeamMidnightDust/1.19
Backport MidnightControls 1.4.1 to 1.18.2
2022-07-06 12:22:42 +00:00
Motschen
a71dcb9765 Update gradle.properties 2022-07-06 14:21:45 +02:00
Motschen
281b266b18 Backport 1.4.0 to 1.18
Will release this tomorrow, it's pretty late for me now.
2022-07-05 22:06:12 +02:00
Martin Prokoph
8d4f8822d3 Merge pull request #60 from TeamMidnightDust/1.19
Bring all recent changes and additions to 1.18
2022-07-05 19:41:42 +00:00
47 changed files with 461 additions and 711 deletions

View File

@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'java-library'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '7.0.0'
@@ -73,7 +73,6 @@ repositories {
}
maven { url "https://maven.terraformersmc.com/releases/" }
maven { url 'https://maven.kosmx.dev' }
maven { url 'https://maven.isxander.dev/releases' }
maven { url 'https://maven.shedaniel.me/' }
maven { url 'https://jitpack.io' }
maven { url "https://api.modrinth.com/maven" }
@@ -116,12 +115,6 @@ dependencies {
modImplementation("maven.modrinth:emi:${project.emi_version}")
modImplementation "maven.modrinth:emotecraft:${project.emotecraft_version}"
modImplementation "io.github.kosmx:bendy-lib:${project.bendylib_version}"
modImplementation "dev.isxander:yet-another-config-lib:${project.yacl_version}"
modImplementation "maven.modrinth:inventory-tabs-updated:${project.inventorytabs_version}"
// Required for Inventory Tabs
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.clothconfig_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}"
include "maven.modrinth:midnightlib:${project.midnightlib_version}"

View File

@@ -3,30 +3,27 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.9
loader_version=0.14.9
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.3
loader_version=0.14.8
# Mod Properties
mod_version = 1.6.0
mod_version = 1.5.0
maven_group = eu.midnightdust
archives_base_name = midnightcontrols
modrinth_id=bXX9h73M
# 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.60.0+1.19.2
sodium_version=mc1.19.2-0.4.4
spruceui_version=4.0.0+1.19
midnightlib_version=0.6.1
modmenu_version=4.0.6
emotecraft_version=2.1.3-SNAPSHOT-build.29-MC1.19-fabric
fabric_version=0.57.0+1.18.2
sodium_version=mc1.18.2-0.4.1
spruceui_version=3.3.2+1.17
midnightlib_version=0.4.4
modmenu_version=2.0.2
emotecraft_version=2.1-MC1.18.1-fabric
bendylib_version=2.0.+
emi_version=0.4.0+1.19
libgui_version=6.0.0+1.19
inventorytabs_version=inventorytabs-0.9.beta-1.19.x
clothconfig_version=7.0.72
yacl_version=0.1.2
libgui_version=5.4.2+1.18.2
emi_version=0.2.0+1.18.2
# Ok Zoomer and LibZoomer are temporarily disabled for the time being, as we are currently using Reflection at runtime instead in OkZoomerCompat due to there being two major, completely incompatible API versions.
# ok_zoomer_version=5.0.0-beta.3+1.17.1

View File

@@ -9,7 +9,6 @@
package eu.midnightdust.midnightcontrols;
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
import eu.midnightdust.midnightcontrols.event.PlayerChangeControlsModeCallback;
import io.netty.buffer.Unpooled;
import net.fabricmc.api.ModInitializer;

View File

@@ -10,6 +10,7 @@
package eu.midnightdust.midnightcontrols.client;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.aperlambda.lambdacommon.utils.Nameable;
import org.jetbrains.annotations.NotNull;
@@ -39,7 +40,7 @@ public enum ControllerType implements Nameable {
ControllerType(int id) {
this.id = id;
this.text = Text.translatable("midnightcontrols.controller_type." + this.getName());
this.text = new TranslatableText("midnightcontrols.controller_type." + this.getName());
}
ControllerType(int id, @NotNull Text text) {

View File

@@ -10,6 +10,7 @@
package eu.midnightdust.midnightcontrols.client;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.aperlambda.lambdacommon.utils.Nameable;
import org.jetbrains.annotations.NotNull;
@@ -30,7 +31,7 @@ public enum HudSide implements Nameable {
private final Text text;
HudSide() {
this.text = Text.translatable(this.getTranslationKey());
this.text = new TranslatableText(this.getTranslationKey());
}
/**

View File

@@ -20,10 +20,9 @@ import eu.midnightdust.midnightcontrols.client.controller.ButtonCategory;
import eu.midnightdust.midnightcontrols.client.controller.Controller;
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
import eu.midnightdust.midnightcontrols.client.gui.MidnightControlsHud;
import eu.midnightdust.midnightcontrols.client.gui.RingScreen;
import eu.midnightdust.midnightcontrols.client.gui.TouchscreenOverlay;
import eu.midnightdust.midnightcontrols.client.mixin.KeyBindingRegistryImplAccessor;
import eu.midnightdust.midnightcontrols.client.ring.ButtonBindingRingAction;
import eu.midnightdust.midnightcontrols.client.ring.KeyBindingRingAction;
import eu.midnightdust.midnightcontrols.client.ring.MidnightRing;
import dev.lambdaurora.spruceui.hud.HudManager;
import net.fabricmc.api.ClientModInitializer;
@@ -39,14 +38,14 @@ import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.toast.SystemToast;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.glfw.GLFW;
import java.io.File;
import java.util.Timer;
import java.util.TimerTask;
/**
* Represents the midnightcontrols client mod.
@@ -86,9 +85,10 @@ public class MidnightControlsClient extends MidnightControls implements ClientMo
KeyBindingHelper.registerKeyBinding(BINDING_LOOK_RIGHT);
KeyBindingHelper.registerKeyBinding(BINDING_LOOK_DOWN);
KeyBindingHelper.registerKeyBinding(BINDING_LOOK_LEFT);
KeyBindingHelper.registerKeyBinding(BINDING_RING);
//KeyBindingHelper.registerKeyBinding(BINDING_RING);
this.ring.registerAction("buttonbinding", ButtonBindingRingAction.FACTORY);
this.ring.registerAction("keybinding", KeyBindingRingAction.FACTORY);
this.ring.load();
ClientPlayNetworking.registerGlobalReceiver(CONTROLS_MODE_CHANNEL, (client, handler, buf, responseSender) ->
responseSender.sendPacket(CONTROLS_MODE_CHANNEL, this.makeControlsModeBuffer(MidnightControlsConfig.controlsMode)));
@@ -125,14 +125,6 @@ public class MidnightControlsClient extends MidnightControls implements ClientMo
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("midnightcontrols","bedrock"), modContainer, ResourcePackActivationType.NORMAL);
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("midnightcontrols","legacy"), modContainer, ResourcePackActivationType.NORMAL);
});
int delay = 0; // delay for 0 sec.
int period = 1; // repeat every 0.001 sec. (100 times a second)
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
input.updateCamera(MinecraftClient.getInstance());
}
}, delay, period);
}
/**
@@ -146,10 +138,10 @@ public class MidnightControlsClient extends MidnightControls implements ClientMo
GLFW.glfwSetJoystickCallback((jid, event) -> {
if (event == GLFW.GLFW_CONNECTED) {
var controller = Controller.byId(jid);
client.getToastManager().add(new SystemToast(SystemToast.Type.TUTORIAL_HINT, Text.translatable("midnightcontrols.controller.connected", jid),
Text.literal(controller.getName())));
client.getToastManager().add(new SystemToast(SystemToast.Type.TUTORIAL_HINT, new TranslatableText("midnightcontrols.controller.connected", jid),
new LiteralText(controller.getName())));
} else if (event == GLFW.GLFW_DISCONNECTED) {
client.getToastManager().add(new SystemToast(SystemToast.Type.TUTORIAL_HINT, Text.translatable("midnightcontrols.controller.disconnected", jid),
client.getToastManager().add(new SystemToast(SystemToast.Type.TUTORIAL_HINT, new TranslatableText("midnightcontrols.controller.disconnected", jid),
null));
}
@@ -199,20 +191,19 @@ public class MidnightControlsClient extends MidnightControls implements ClientMo
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && (client.isWindowFocused() || MidnightControlsConfig.unfocusedInput))
this.input.tickController(client);
if (BINDING_RING.wasPressed()) {
ring.loadFromUnbound();
client.setScreen(new RingScreen());
}
// if (BINDING_RING.wasPressed()) {
// client.setScreen(new RingScreen());
// }
if (client.world != null && MidnightControlsConfig.enableHints && !MidnightControlsConfig.autoSwitchMode && MidnightControlsConfig.controlsMode == ControlsMode.DEFAULT && MidnightControlsConfig.getController().isGamepad()) {
client.getToastManager().add(SystemToast.create(client, SystemToast.Type.PERIODIC_NOTIFICATION, Text.translatable("midnightcontrols.controller.tutorial.title"),
Text.translatable("midnightcontrols.controller.tutorial.description", Text.translatable("options.title"), Text.translatable("controls.title"),
Text.translatable("midnightcontrols.menu.title.controller"))));
client.getToastManager().add(SystemToast.create(client, SystemToast.Type.PERIODIC_NOTIFICATION, new TranslatableText("midnightcontrols.controller.tutorial.title"),
new TranslatableText("midnightcontrols.controller.tutorial.description", new TranslatableText("options.title"), new TranslatableText("controls.title"),
new TranslatableText("midnightcontrols.menu.title.controller"))));
MidnightControlsConfig.enableHints = false;
MidnightControlsConfig.save();
}
}
public void onRender(MinecraftClient client) {
//this.input.onRender(client);
this.input.onRender(client);
}
/**

View File

@@ -31,7 +31,6 @@ import static org.lwjgl.glfw.GLFW.*;
*/
public class MidnightControlsConfig extends MidnightConfig {
public static boolean isEditing = false;
@Hidden @Entry public static int configVersion = 1;
// General
@Entry(name = "midnightcontrols.menu.controls_mode") public static ControlsMode controlsMode = ControlsMode.DEFAULT;
@Entry(name = "midnightcontrols.menu.auto_switch_mode") public static boolean autoSwitchMode = true;
@@ -48,13 +47,12 @@ public class MidnightControlsConfig extends MidnightConfig {
@Entry(name = "midnightcontrols.menu.reacharound.horizontal") public static boolean horizontalReacharound = false; // Disabled by default as this behaviour can be considered cheating on multiplayer servers.
@Entry(name = "midnightcontrols.menu.reacharound.vertical") public static boolean verticalReacharound = false; // Disabled by default as this behaviour can be considered cheating on multiplayer servers.
@Entry(name = "Reacharound Outline") public static boolean shouldRenderReacharoundOutline = true;
@Entry(name = "Reacharound Outline Color (WIP)", isColor = true) public static String reacharoundOutlineColorHex = "#ffffff";
@Entry(name = "Reacharound Outline Alpha", min = 0, max = 255) public static int reacharoundOutlineColorAlpha = 102;
@Entry(name = "Reacharound Outline Color") public static int[] reacharoundOutlineColor = new int[]{255, 255, 255, 102};
@Entry(name = "midnightcontrols.menu.right_dead_zone") public static double rightDeadZone = 0.25;
@Entry(name = "midnightcontrols.menu.left_dead_zone") public static double leftDeadZone = 0.25;
@Entry(name = "midnightcontrols.menu.invert_right_y_axis") public static boolean invertRightYAxis = false;
@Entry(name = "midnightcontrols.menu.invert_right_x_axis") public static boolean invertRightXAxis = false;
@Entry(name = "midnightcontrols.menu.rotation_speed") public static double rotationSpeed = 40.0; //used for x-axis, name kept for compatability
@Entry(name = "midnightcontrols.menu.rotation_speed") public static double rotationSpeed = 40.0; //used for x axis, name kept for compatability
@Entry(name = "midnightcontrols.menu.y_axis_rotation_speed") public static double yAxisRotationSpeed = rotationSpeed;
@Entry(name = "midnightcontrols.menu.mouse_speed") public static double mouseSpeed = 25.0;
@Entry(name = "midnightcontrols.menu.unfocused_input") public static boolean unfocusedInput = false;
@@ -66,16 +64,15 @@ public class MidnightControlsConfig extends MidnightConfig {
@Entry(name = "Mouse screens") public static List<String> mouseScreens = Lists.newArrayList("me.jellysquid.mods.sodium.client.gui",
"net.coderbot.iris.gui", "net.minecraft.client.gui.screen.advancement", "net.minecraft.client.gui.screen.pack.PackScreen", "net.minecraft.class_5375",
"net.minecraft.class_457", "net.minecraft.class_408", "me.flashyreese.mods.reeses_sodium_options.client.gui", "dev.emi.emi.screen",
"hardcorequesting.client.interfaces.GuiQuestBook", "hardcorequesting.client.interfaces.GuiReward", "hardcorequesting.client.interfaces.EditTrackerScreen");
"hardcorequesting.client.interfaces.GuiQuestBook", "hardcorequesting.client.interfaces.GuiReward", "hardcorequesting.client.interfaces.EditTrackerScreen",
"io.github.kosmx.emotes.arch.gui.screen.ingame.FastChosseScreen");
@Entry(name = "Keybindings") public static Map<String, String> BINDINGS = new HashMap<>();
private static final Pattern BUTTON_BINDING_PATTERN = Pattern.compile("(-?\\d+)\\+?");
@Entry(name = "Max analog values") public static double[] maxAnalogValues = new double[]{1, 1, 1, 1};
@Entry(name = "Trigger button fix") public static boolean triggerFix = true;
@Entry(name = "Enable Hints") public static boolean enableHints = true;
@Entry(name = "Enable Shortcut in Controls Options") public static boolean shortcutInControls = true;
@Entry(name = "Ring Bindings (WIP)") public static List<String> ringBindings = new ArrayList<>();
@Entry(name = "Ignored Unbound Keys") public static List<String> ignoredUnboundKeys = Lists.newArrayList("inventorytabs.key.next_tab");
@Entry(name = "Command Keybinds") public static List<String> commandKeybinds = Lists.newArrayList();
/**
* Loads the configuration
@@ -85,6 +82,7 @@ public class MidnightControlsConfig extends MidnightConfig {
MidnightControlsClient.get().log("Configuration loaded.");
// Controller controls.
InputManager.loadButtonBindings();
//this.mod.ring.load(this.config);
}
/**
@@ -288,8 +286,7 @@ public class MidnightControlsConfig extends MidnightConfig {
horizontalReacharound = false;
verticalReacharound = false;
shouldRenderReacharoundOutline = true;
reacharoundOutlineColorHex = "#ffffff";
reacharoundOutlineColorAlpha = 102;
reacharoundOutlineColor = new int[]{255, 255, 255, 102};
rightDeadZone = 0.25;
leftDeadZone = 0.25;
invertRightYAxis = false;
@@ -306,11 +303,6 @@ public class MidnightControlsConfig extends MidnightConfig {
mouseScreens = Lists.newArrayList("me.jellysquid.mods.sodium.client.gui", "net.coderbot.iris.gui", "net.minecraft.client.gui.screen.advancement", "net.minecraft.client.gui.screen.pack.PackScreen", "net.minecraft.class_5375", "net.minecraft.class_457", "net.minecraft.class_408", "me.flashyreese.mods.reeses_sodium_options.client.gui", "dev.emi.emi.screen");
BINDINGS = new HashMap<>();
maxAnalogValues = new double[]{1, 1, 1, 1};
triggerFix = true;
enableHints = true;
shortcutInControls = true;
ringBindings = new ArrayList<>();
ignoredUnboundKeys = Lists.newArrayList("inventorytabs.key.next_tab");
}
/**
@@ -325,8 +317,8 @@ public class MidnightControlsConfig extends MidnightConfig {
else if (controller.contains("steam deck")) return ControllerType.STEAM_DECK;
else if (controller.contains("steam")) return ControllerType.STEAM_CONTROLLER;
else if (controller.contains("dualsense")) return ControllerType.DUALSENSE;
else if (controller.contains("dualshock") || controller.contains("ps4") || controller.contains("sony")) return ControllerType.DUALSHOCK;
else if (controller.contains("switch") || controller.contains("joy-con") || controller.contains("wii") || controller.contains("nintendo")) return ControllerType.SWITCH;
else if (controller.contains("dualshock") || controller.contains("ps4")) return ControllerType.DUALSHOCK;
else if (controller.contains("switch") || controller.contains("joy-con")) return ControllerType.SWITCH;
else if (controller.contains("ouya")) return ControllerType.OUYA;
else return ControllerType.DEFAULT;
}

View File

@@ -13,18 +13,15 @@ import com.google.common.collect.ImmutableSet;
import dev.lambdaurora.spruceui.widget.AbstractSpruceWidget;
import dev.lambdaurora.spruceui.widget.container.SpruceEntryListWidget;
import eu.midnightdust.midnightcontrols.MidnightControls;
import eu.midnightdust.midnightcontrols.client.compat.EmotecraftCompat;
import eu.midnightdust.midnightcontrols.client.compat.LibGuiCompat;
import eu.midnightdust.midnightcontrols.client.compat.MidnightControlsCompat;
import eu.midnightdust.midnightcontrols.client.compat.SodiumCompat;
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
import eu.midnightdust.midnightcontrols.client.controller.Controller;
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
import eu.midnightdust.midnightcontrols.client.gui.RingScreen;
import eu.midnightdust.midnightcontrols.client.gui.TouchscreenOverlay;
import eu.midnightdust.midnightcontrols.client.gui.widget.ControllerControlsWidget;
import eu.midnightdust.midnightcontrols.client.mixin.*;
import eu.midnightdust.midnightcontrols.client.ring.RingPage;
import eu.midnightdust.midnightcontrols.client.util.HandledScreenAccessor;
import eu.midnightdust.midnightcontrols.client.util.MouseAccessor;
import dev.lambdaurora.spruceui.navigation.NavigationDirection;
@@ -44,13 +41,11 @@ import net.minecraft.client.gui.screen.advancement.AdvancementsScreen;
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.screen.ingame.MerchantScreen;
import net.minecraft.client.gui.screen.ingame.StonecutterScreen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget;
import net.minecraft.client.gui.screen.world.WorldListWidget;
import net.minecraft.client.gui.widget.*;
import net.minecraft.screen.slot.Slot;
import net.minecraft.text.TranslatableTextContent;
import net.minecraft.util.math.MathHelper;
import org.aperlambda.lambdacommon.utils.Pair;
import org.jetbrains.annotations.NotNull;
@@ -176,11 +171,11 @@ public class MidnightInput {
}
/**
* This method is called to update the camera
* This method is called when Minecraft renders.
*
* @param client the client instance
*/
public void updateCamera(@NotNull MinecraftClient client) {
public void onRender(@NotNull MinecraftClient client) {
if (!(client.currentScreen == null || client.currentScreen instanceof TouchscreenOverlay))
return;
@@ -189,29 +184,16 @@ public class MidnightInput {
return;
if (this.targetYaw != 0.f || this.targetPitch != 0.f) {
float rotationYaw = (float) (client.player.prevYaw + (this.targetYaw * 0.175));
float rotationPitch = (float) (client.player.prevPitch + (this.targetPitch * 0.175));
client.player.prevYaw = rotationYaw;
client.player.prevPitch = MathHelper.clamp(rotationPitch, -90.f, 90.f);
float rotationYaw = (float) (player.prevYaw + (this.targetYaw / 0.10) * client.getTickDelta());
float rotationPitch = (float) (player.prevPitch + (this.targetPitch / 0.10) * client.getTickDelta());
client.player.setYaw(rotationYaw);
client.player.setPitch(MathHelper.clamp(rotationPitch, -90.f, 90.f));
if (client.player.isRiding() && client.player.getVehicle() != null) {
client.player.getVehicle().onPassengerLookAround(client.player);
}
client.getTutorialManager().onUpdateMouse(this.targetPitch, this.targetYaw);
MidnightControlsCompat.HANDLERS.forEach(handler -> handler.handleCamera(client, targetYaw, targetPitch));
this.onRender(client);
}
}
/**
* This method is deprecated and will be removed in future versions
* It is just kept, because the current version of 'Do a Barrel Roll' mixins into this method
*
* @param client the client instance
*/
@Deprecated
public void onRender(@NotNull MinecraftClient client) {
}
/**
* This method is called when a Screen is opened.
@@ -275,30 +257,7 @@ public class MidnightInput {
value *= -1.0F;
int state = value > MidnightControlsConfig.rightDeadZone ? 1 : (value < -MidnightControlsConfig.rightDeadZone ? 2 : 0);
if (!(client.currentScreen instanceof RingScreen || (MidnightControlsCompat.isEmotecraftPresent() && EmotecraftCompat.isEmotecraftScreen(client.currentScreen)))) this.handleAxe(client, axis, value, absValue, state);
}
if (client.currentScreen instanceof RingScreen || (MidnightControlsCompat.isEmotecraftPresent() && EmotecraftCompat.isEmotecraftScreen(client.currentScreen))) {
float x = Math.abs(buffer.get(GLFW_GAMEPAD_AXIS_LEFT_X)) > MidnightControlsConfig.leftDeadZone ? buffer.get(GLFW_GAMEPAD_AXIS_LEFT_X) : 0;
float y = Math.abs(buffer.get(GLFW_GAMEPAD_AXIS_LEFT_Y)) > MidnightControlsConfig.leftDeadZone ? buffer.get(GLFW_GAMEPAD_AXIS_LEFT_Y) : 0;
if (x == 0 && y == 0) {
x = Math.abs(buffer.get(GLFW_GAMEPAD_AXIS_RIGHT_X)) > MidnightControlsConfig.rightDeadZone ? buffer.get(GLFW_GAMEPAD_AXIS_RIGHT_X) : 0;
y = Math.abs(buffer.get(GLFW_GAMEPAD_AXIS_RIGHT_Y)) > MidnightControlsConfig.rightDeadZone ? buffer.get(GLFW_GAMEPAD_AXIS_RIGHT_Y) : 0;
}
int index = -1;
if (x < 0) {
if (y < 0) index = 0;
if (y == 0) index = 3;
if (y > 0) index = 5;
} else if (x == 0) {
if (y < 0) index = 1;
if (y > 0) index = 6;
} else if (x > 0) {
if (y < 0) index = 2;
if (y == 0) index = 4;
if (y > 0) index = 7;
}
if (client.currentScreen instanceof RingScreen && index > -1) RingPage.selected = index;
if (MidnightControlsCompat.isEmotecraftPresent() && EmotecraftCompat.isEmotecraftScreen(client.currentScreen)) EmotecraftCompat.handleEmoteSelector(index);
this.handleAxe(client, axis, value, absValue, state);
}
}
@@ -345,6 +304,15 @@ public class MidnightInput {
else if (FabricLoader.getInstance().isModLoaded("libgui")) LibGuiCompat.handlePress(client.currentScreen);
}
}
if (button == GLFW.GLFW_GAMEPAD_BUTTON_B) {
if (client.currentScreen != null && client.currentScreen.getClass() != TitleScreen.class) {
if (!MidnightControlsCompat.handleMenuBack(client, client.currentScreen))
if (!this.tryGoBack(client.currentScreen))
client.currentScreen.close();
return;
}
}
}
if (button == GLFW.GLFW_GAMEPAD_BUTTON_A && client.currentScreen != null && !isScreenInteractive(client.currentScreen)
@@ -378,17 +346,14 @@ public class MidnightInput {
*/
public boolean tryGoBack(@NotNull Screen screen) {
var set = ImmutableSet.of("gui.back", "gui.done", "gui.cancel", "gui.toTitle", "gui.toMenu");
return screen.children().stream().filter(element -> element instanceof PressableWidget)
.map(element -> (PressableWidget) element)
.filter(element -> element.getMessage() != null && element.getMessage().getContent() != null)
.filter(element -> element.getMessage() != null)
.anyMatch(element -> {
if (element.getMessage().getContent() instanceof TranslatableTextContent translatableText) {
if (set.stream().anyMatch(key -> translatableText.getKey().equals(key))) {
if (set.stream().anyMatch(key -> element.getMessage().toString().equals(key))) {
element.onPress();
return true;
}
}
return false;
});
}
@@ -495,14 +460,6 @@ public class MidnightInput {
}
return;
}
} else if (client.currentScreen instanceof StonecutterScreen stonecutterScreen) {
if (axis == GLFW_GAMEPAD_AXIS_RIGHT_Y) {
// @TODO allow rebinding to left stick
if (absValue >= deadZone) {
stonecutterScreen.mouseScrolled(0.0, 0.0, -(value * 1.5f));
}
return;
}
} else if (client.currentScreen instanceof AdvancementsScreen advancementsScreen) {
if (axis == GLFW_GAMEPAD_AXIS_RIGHT_X || axis == GLFW_GAMEPAD_AXIS_RIGHT_Y) {
var accessor = (AdvancementsScreenAccessor) advancementsScreen;
@@ -515,25 +472,21 @@ public class MidnightInput {
} else if (client.currentScreen != null) {
if (axis == GLFW_GAMEPAD_AXIS_RIGHT_Y && absValue >= deadZone) {
float finalValue = value;
if (client.currentScreen.children().stream().filter(element -> element instanceof SpruceEntryListWidget)
client.currentScreen.children().stream().filter(element -> element instanceof SpruceEntryListWidget)
.map(element -> (SpruceEntryListWidget<?>) element)
.filter(AbstractSpruceWidget::isFocusedOrHovered)
.noneMatch(element -> {
.anyMatch(element -> {
MidnightControls.get().log(String.valueOf(finalValue));
element.mouseScrolled(0.0, 0.0, -finalValue);
return true;
})
&&
});
client.currentScreen.children().stream().filter(element -> element instanceof EntryListWidget)
.map(element -> (EntryListWidget<?>) element)
.filter(element -> element.getType().isFocused())
.noneMatch(element -> {
.anyMatch(element -> {
element.mouseScrolled(0.0, 0.0, -finalValue);
return true;
}))
{
client.currentScreen.mouseScrolled(0.0, 0.0, -(value * 1.5f));
}
});
return;
}
}
@@ -618,7 +571,7 @@ public class MidnightInput {
labelWidget.onPress();
return true;
} else if (focused instanceof WorldListWidget list) {
list.getSelectedAsOptional().ifPresent(WorldListWidget.WorldEntry::play);
list.getSelectedAsOptional().ifPresent(WorldListWidget.Entry::play);
return true;
} else if (focused instanceof MultiplayerServerListWidget list) {
var entry = list.getSelectedOrNull();

View File

@@ -10,6 +10,7 @@
package eu.midnightdust.midnightcontrols.client;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.aperlambda.lambdacommon.utils.Nameable;
import org.jetbrains.annotations.NotNull;
@@ -33,7 +34,7 @@ public enum VirtualMouseSkin implements Nameable {
VirtualMouseSkin(String name) {
this.name = name;
this.text = Text.translatable(this.getTranslationKey());
this.text = new TranslatableText(this.getTranslationKey());
}
/**

View File

@@ -33,13 +33,6 @@ public interface CompatHandler {
*/
void handle(@NotNull MidnightControlsClient mod);
/**
* Handles custom camera updates
*
* @param client the Minecraft client instance
*/
default void handleCamera(@NotNull MinecraftClient client, double targetYaw, double targetPitch) {};
/**
* Returns whether the mouse is required on the specified screen.
*

View File

@@ -1,6 +1,5 @@
package eu.midnightdust.midnightcontrols.client.compat;
import dev.emi.emi.EmiConfig;
import dev.emi.emi.screen.EmiScreen;
import dev.emi.emi.screen.EmiScreenManager;
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
@@ -14,7 +13,7 @@ import org.lwjgl.glfw.GLFW;
public class EMICompat implements CompatHandler {
public static boolean handleTabs(boolean direction) {
if (isEMIEnabled() && MidnightControlsClient.get().input.actionGuiCooldown == 0 && EmiScreenManager.searchLeft != null && EmiScreenManager.searchRight != null) {
if (MidnightControlsClient.get().input.actionGuiCooldown == 0 &&EmiScreenManager.searchLeft != null && EmiScreenManager.searchRight != null) {
if (direction) EmiScreenManager.searchRight.onPress();
else EmiScreenManager.searchLeft.onPress();
MidnightControlsClient.get().input.actionGuiCooldown = 5;
@@ -39,10 +38,4 @@ public class EMICompat implements CompatHandler {
.filter(((client, buttonBinding) -> client.currentScreen instanceof HandledScreen<?> || client.currentScreen instanceof EmiScreen))
.register();
}
public static boolean isEMIEnabled() {
return EmiConfig.enabled;
}
public static boolean isSearchBarCentered() {
return EmiConfig.centerSearchBar;
}
}

View File

@@ -1,29 +0,0 @@
package eu.midnightdust.midnightcontrols.client.compat;
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
import io.github.kosmx.emotes.arch.gui.screen.ingame.FastChosseScreen;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
public class EmotecraftCompat {
public static boolean isEmotecraftScreen(Screen screen) {
return screen instanceof FastChosseScreen;
}
public static void handleEmoteSelector(int index) {
MinecraftClient client = MinecraftClient.getInstance();
if (client.currentScreen instanceof FastChosseScreen) {
int x = client.getWindow().getWidth() / 2;
int y = client.getWindow().getHeight() / 2;
if (index == 0) InputManager.queueMousePosition(x-200, y-200);
if (index == 1) InputManager.queueMousePosition(x, y-200);
if (index == 2) InputManager.queueMousePosition(x+200, y-200);
if (index == 3) InputManager.queueMousePosition(x-200, y);
if (index == 4) InputManager.queueMousePosition(x+200, y);
if (index == 5) InputManager.queueMousePosition(x-200, y+200);
if (index == 6) InputManager.queueMousePosition(x, y+200);
if (index == 7) InputManager.queueMousePosition(x+200, y+200);
InputManager.INPUT_MANAGER.updateMousePosition(client);
}
}
}

View File

@@ -1,33 +0,0 @@
package eu.midnightdust.midnightcontrols.client.compat;
import com.kqp.inventorytabs.tabs.TabManager;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
public class InventoryTabsCompat {
public static void handleInventoryTabs(Screen screen, boolean next) {
if (screen instanceof HandledScreen<?> && !(screen instanceof CreativeInventoryScreen)) {
TabManager tabManager = TabManager.getInstance();
int tabIndex = tabManager.tabs.indexOf(tabManager.currentTab);
if (next) {
if (tabIndex < tabManager.tabs.size() - 1) tabManager.onTabClick(tabManager.tabs.get(tabIndex + 1));
else tabManager.onTabClick(tabManager.tabs.get(0));
} else {
if (tabIndex > 0) tabManager.onTabClick(tabManager.tabs.get(tabIndex - 1));
else tabManager.onTabClick(tabManager.tabs.get(tabManager.tabs.size() - 1));
}
}
}
public static void handleInventoryPage(Screen screen, boolean next) {
if (screen instanceof HandledScreen<?> && !(screen instanceof CreativeInventoryScreen)) {
TabManager tabManager = TabManager.getInstance();
if (next) {
if (tabManager.canGoForwardAPage()) tabManager.setCurrentPage(tabManager.currentPage + 1);
} else {
if (tabManager.canGoBackAPage()) tabManager.setCurrentPage(tabManager.currentPage - 1);
}
}
}
}

View File

@@ -167,20 +167,4 @@ public class MidnightControlsCompat {
public static boolean isEMIPresent() {
return FabricLoader.getInstance().isModLoaded("emi");
}
/**
* Returns whether InventoryTabs is present.
*
* @return true if InventoryTabs is present, else false
*/
public static boolean isInventoryTabsPresent() {
return FabricLoader.getInstance().isModLoaded("inventorytabs");
}
/**
* Returns whether Emotecraft is present.
*
* @return true if Emotecraft is present, else false
*/
public static boolean isEmotecraftPresent() {
return FabricLoader.getInstance().isModLoaded("emotecraft");
}
}

View File

@@ -10,13 +10,12 @@
package eu.midnightdust.midnightcontrols.client.controller;
import eu.midnightdust.midnightcontrols.client.ButtonState;
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
import eu.midnightdust.midnightcontrols.client.gui.RingScreen;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.GameOptions;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import org.aperlambda.lambdacommon.utils.function.PairPredicate;
import org.aperlambda.lambdacommon.utils.function.Predicates;
@@ -46,15 +45,6 @@ public class ButtonBinding {
public static final ButtonBinding BACK = new Builder("back").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_LEFT_Y, false))
.action(MovementHandler.HANDLER).onlyInGame().register();
public static final ButtonBinding CHAT = new Builder("chat").buttons(GLFW_GAMEPAD_BUTTON_DPAD_RIGHT).onlyInGame().cooldown().register();
public static final ButtonBinding CONTROLS_RING = new Builder("controls_ring").buttons(GLFW_GAMEPAD_BUTTON_GUIDE).onlyInGame().cooldown()
.action((client, button1, value, action) -> {
if (action.isPressed()) {
MidnightControlsClient.get().ring.loadFromUnbound();
client.setScreen(new RingScreen());
}
if (action.isUnpressed() && client.currentScreen != null) client.currentScreen.close();
return true;
}).register();
public static final ButtonBinding DROP_ITEM = new Builder("drop_item").buttons(GLFW_GAMEPAD_BUTTON_B).onlyInGame().cooldown().register();
public static final ButtonBinding FORWARD = new Builder("forward").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_LEFT_Y, true))
.action(MovementHandler.HANDLER).onlyInGame().register();
@@ -63,8 +53,6 @@ public class ButtonBinding {
public static final ButtonBinding HOTBAR_RIGHT = new Builder("hotbar_right").buttons(GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER)
.action(InputHandlers.handleHotbar(true)).onlyInGame().cooldown().register();
public static final ButtonBinding INVENTORY = new Builder("inventory").buttons(GLFW_GAMEPAD_BUTTON_Y).onlyInGame().cooldown().register();
public static final ButtonBinding EXIT = new Builder("exit").buttons(GLFW_GAMEPAD_BUTTON_B).filter((client, buttonBinding) -> client.currentScreen != null && buttonBinding.cooldown == 0 && INVENTORY.cooldown == 0)
.action(InputHandlers.handleExit()).cooldown().register();
public static final ButtonBinding JUMP = new Builder("jump").buttons(GLFW_GAMEPAD_BUTTON_A).onlyInGame().register();
public static final ButtonBinding LEFT = new Builder("left").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_LEFT_X, false))
.action(MovementHandler.HANDLER).onlyInGame().register();
@@ -86,6 +74,7 @@ public class ButtonBinding {
.action(InputHandlers.handleInventorySlotPad(2)).onlyInInventory().cooldown().register();
public static final ButtonBinding SLOT_UP = new Builder("slot_up").buttons(GLFW_GAMEPAD_BUTTON_DPAD_UP)
.action(InputHandlers.handleInventorySlotPad(0)).onlyInInventory().cooldown().register();
public static final ButtonBinding SMOOTH_CAMERA = new Builder("toggle_smooth_camera").onlyInGame().cooldown().register();
public static final ButtonBinding SNEAK = new Builder("sneak").buttons(GLFW_GAMEPAD_BUTTON_RIGHT_THUMB)
.actions(InputHandlers::handleToggleSneak).onlyInGame().cooldown().register();
public static final ButtonBinding SPRINT = new Builder("sprint").buttons(GLFW_GAMEPAD_BUTTON_LEFT_THUMB).onlyInGame().register();
@@ -95,9 +84,9 @@ public class ButtonBinding {
public static final ButtonBinding TAB_RIGHT = new Builder("tab_next").buttons(GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER)
.action(InputHandlers.handleHotbar(true)).filter(Predicates.or(InputHandlers::inInventory, InputHandlers::inAdvancements).or((client, binding) -> client.currentScreen != null && client.currentScreen.getClass().toString().contains("sodium"))).cooldown().register();
public static final ButtonBinding PAGE_LEFT = new Builder("page_back").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_LEFT_TRIGGER, true))
.action(InputHandlers.handlePage(false)).filter(InputHandlers::inInventory).cooldown(30).register();
.action(InputHandlers.handlePage(false)).filter(InputHandlers::inInventory).cooldown().register();
public static final ButtonBinding PAGE_RIGHT = new Builder("page_next").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER, true))
.action(InputHandlers.handlePage(true)).filter(InputHandlers::inInventory).cooldown(30).register();
.action(InputHandlers.handlePage(true)).filter(InputHandlers::inInventory).cooldown().register();
public static final ButtonBinding TAKE = new Builder("take").buttons(GLFW_GAMEPAD_BUTTON_X)
.action(InputHandlers.handleActions()).filter(InputHandlers::inInventory).cooldown().register();
public static final ButtonBinding TAKE_ALL = new Builder("take_all").buttons(GLFW_GAMEPAD_BUTTON_A)
@@ -115,34 +104,21 @@ public class ButtonBinding {
protected PairPredicate<MinecraftClient, ButtonBinding> filter;
private final List<PressAction> actions = new ArrayList<>(Collections.singletonList(PressAction.DEFAULT_ACTION));
private boolean hasCooldown;
private int cooldownLength = 5;
private int cooldown = 0;
boolean pressed = false;
public ButtonBinding(String key, int[] defaultButton, List<PressAction> actions, PairPredicate<MinecraftClient, ButtonBinding> filter, boolean hasCooldown) {
this.setButton(this.defaultButton = defaultButton);
this.key = key;
this.text = Text.translatable(this.key);
this.text = new TranslatableText(this.key);
this.filter = filter;
this.actions.addAll(actions);
this.hasCooldown = hasCooldown;
}
public ButtonBinding(String key, int[] defaultButton, List<PressAction> actions, PairPredicate<MinecraftClient, ButtonBinding> filter, boolean hasCooldown, int cooldownLength) {
this.setButton(this.defaultButton = defaultButton);
this.key = key;
this.text = Text.translatable(this.key);
this.filter = filter;
this.actions.addAll(actions);
this.hasCooldown = hasCooldown;
this.cooldownLength = cooldownLength;
}
public ButtonBinding(String key, int[] defaultButton, boolean hasCooldown) {
this(key, defaultButton, Collections.emptyList(), Predicates.pairAlwaysTrue(), hasCooldown);
}
public ButtonBinding(String key, int[] defaultButton, boolean hasCooldown, int cooldownLength) {
this(key, defaultButton, Collections.emptyList(), Predicates.pairAlwaysTrue(), hasCooldown, cooldownLength);
}
/**
* Returns the button bound.
@@ -259,7 +235,7 @@ public class ButtonBinding {
if (state == ButtonState.REPEAT && this.hasCooldown && this.cooldown != 0)
return;
if (this.hasCooldown && state.isPressed()) {
this.cooldown = cooldownLength;
this.cooldown = 5;
}
for (int i = this.actions.size() - 1; i >= 0; i--) {
if (this.actions.get(i).press(client, this, value, state))
@@ -345,6 +321,7 @@ public class ButtonBinding {
PLAYER_LIST.mcKeyBinding = options.playerListKey;
RIGHT.mcKeyBinding = options.rightKey;
SCREENSHOT.mcKeyBinding = options.screenshotKey;
SMOOTH_CAMERA.mcKeyBinding = options.smoothCameraKey;
SNEAK.mcKeyBinding = options.sneakKey;
SPRINT.mcKeyBinding = options.sprintKey;
SWAP_HANDS.mcKeyBinding = options.swapHandsKey;
@@ -360,37 +337,37 @@ public class ButtonBinding {
*/
public static @NotNull Text getLocalizedButtonName(int button) {
return switch (button % 500) {
case -1 -> Text.translatable("key.keyboard.unknown");
case GLFW_GAMEPAD_BUTTON_A -> Text.translatable("midnightcontrols.button.a");
case GLFW_GAMEPAD_BUTTON_B -> Text.translatable("midnightcontrols.button.b");
case GLFW_GAMEPAD_BUTTON_X -> Text.translatable("midnightcontrols.button.x");
case GLFW_GAMEPAD_BUTTON_Y -> Text.translatable("midnightcontrols.button.y");
case GLFW_GAMEPAD_BUTTON_LEFT_BUMPER -> Text.translatable("midnightcontrols.button.left_bumper");
case GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER -> Text.translatable("midnightcontrols.button.right_bumper");
case GLFW_GAMEPAD_BUTTON_BACK -> Text.translatable("midnightcontrols.button.back");
case GLFW_GAMEPAD_BUTTON_START -> Text.translatable("midnightcontrols.button.start");
case GLFW_GAMEPAD_BUTTON_GUIDE -> Text.translatable("midnightcontrols.button.guide");
case GLFW_GAMEPAD_BUTTON_LEFT_THUMB -> Text.translatable("midnightcontrols.button.left_thumb");
case GLFW_GAMEPAD_BUTTON_RIGHT_THUMB -> Text.translatable("midnightcontrols.button.right_thumb");
case GLFW_GAMEPAD_BUTTON_DPAD_UP -> Text.translatable("midnightcontrols.button.dpad_up");
case GLFW_GAMEPAD_BUTTON_DPAD_RIGHT -> Text.translatable("midnightcontrols.button.dpad_right");
case GLFW_GAMEPAD_BUTTON_DPAD_DOWN -> Text.translatable("midnightcontrols.button.dpad_down");
case GLFW_GAMEPAD_BUTTON_DPAD_LEFT -> Text.translatable("midnightcontrols.button.dpad_left");
case 100 -> Text.translatable("midnightcontrols.axis.left_x+");
case 101 -> Text.translatable("midnightcontrols.axis.left_y+");
case 102 -> Text.translatable("midnightcontrols.axis.right_x+");
case 103 -> Text.translatable("midnightcontrols.axis.right_y+");
case 104 -> Text.translatable("midnightcontrols.axis.left_trigger");
case 105 -> Text.translatable("midnightcontrols.axis.right_trigger");
case 200 -> Text.translatable("midnightcontrols.axis.left_x-");
case 201 -> Text.translatable("midnightcontrols.axis.left_y-");
case 202 -> Text.translatable("midnightcontrols.axis.right_x-");
case 203 -> Text.translatable("midnightcontrols.axis.right_y-");
case 15 -> Text.translatable("midnightcontrols.button.l4");
case 16 -> Text.translatable("midnightcontrols.button.l5");
case 17 -> Text.translatable("midnightcontrols.button.r4");
case 18 -> Text.translatable("midnightcontrols.button.r5");
default -> Text.translatable("midnightcontrols.button.unknown", button);
case -1 -> new TranslatableText("key.keyboard.unknown");
case GLFW_GAMEPAD_BUTTON_A -> new TranslatableText("midnightcontrols.button.a");
case GLFW_GAMEPAD_BUTTON_B -> new TranslatableText("midnightcontrols.button.b");
case GLFW_GAMEPAD_BUTTON_X -> new TranslatableText("midnightcontrols.button.x");
case GLFW_GAMEPAD_BUTTON_Y -> new TranslatableText("midnightcontrols.button.y");
case GLFW_GAMEPAD_BUTTON_LEFT_BUMPER -> new TranslatableText("midnightcontrols.button.left_bumper");
case GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER -> new TranslatableText("midnightcontrols.button.right_bumper");
case GLFW_GAMEPAD_BUTTON_BACK -> new TranslatableText("midnightcontrols.button.back");
case GLFW_GAMEPAD_BUTTON_START -> new TranslatableText("midnightcontrols.button.start");
case GLFW_GAMEPAD_BUTTON_GUIDE -> new TranslatableText("midnightcontrols.button.guide");
case GLFW_GAMEPAD_BUTTON_LEFT_THUMB -> new TranslatableText("midnightcontrols.button.left_thumb");
case GLFW_GAMEPAD_BUTTON_RIGHT_THUMB -> new TranslatableText("midnightcontrols.button.right_thumb");
case GLFW_GAMEPAD_BUTTON_DPAD_UP -> new TranslatableText("midnightcontrols.button.dpad_up");
case GLFW_GAMEPAD_BUTTON_DPAD_RIGHT -> new TranslatableText("midnightcontrols.button.dpad_right");
case GLFW_GAMEPAD_BUTTON_DPAD_DOWN -> new TranslatableText("midnightcontrols.button.dpad_down");
case GLFW_GAMEPAD_BUTTON_DPAD_LEFT -> new TranslatableText("midnightcontrols.button.dpad_left");
case 100 -> new TranslatableText("midnightcontrols.axis.left_x+");
case 101 -> new TranslatableText("midnightcontrols.axis.left_y+");
case 102 -> new TranslatableText("midnightcontrols.axis.right_x+");
case 103 -> new TranslatableText("midnightcontrols.axis.right_y+");
case 104 -> new TranslatableText("midnightcontrols.axis.left_trigger");
case 105 -> new TranslatableText("midnightcontrols.axis.right_trigger");
case 200 -> new TranslatableText("midnightcontrols.axis.left_x-");
case 201 -> new TranslatableText("midnightcontrols.axis.left_y-");
case 202 -> new TranslatableText("midnightcontrols.axis.right_x-");
case 203 -> new TranslatableText("midnightcontrols.axis.right_y-");
case 15 -> new TranslatableText("midnightcontrols.button.l4");
case 16 -> new TranslatableText("midnightcontrols.button.l5");
case 17 -> new TranslatableText("midnightcontrols.button.r4");
case 18 -> new TranslatableText("midnightcontrols.button.r5");
default -> new TranslatableText("midnightcontrols.button.unknown", button);
};
}
@@ -409,7 +386,6 @@ public class ButtonBinding {
ButtonBinding.USE
));
INVENTORY_CATEGORY = InputManager.registerDefaultCategory("key.categories.inventory", category -> category.registerAllBindings(
ButtonBinding.EXIT,
ButtonBinding.DROP_ITEM,
ButtonBinding.HOTBAR_LEFT,
ButtonBinding.HOTBAR_RIGHT,
@@ -434,8 +410,7 @@ public class ButtonBinding {
ButtonBinding.TOGGLE_PERSPECTIVE,
ButtonBinding.PAUSE_GAME,
//SMOOTH_CAMERA,
ButtonBinding.DEBUG_SCREEN,
ButtonBinding.CONTROLS_RING
ButtonBinding.DEBUG_SCREEN
));
}
@@ -464,7 +439,6 @@ public class ButtonBinding {
private final List<PressAction> actions = new ArrayList<>();
private PairPredicate<MinecraftClient, ButtonBinding> filter = Predicates.pairAlwaysTrue();
private boolean cooldown = false;
private int cooldownLength = 5;
private ButtonCategory category = null;
private KeyBinding mcBinding = null;
@@ -567,17 +541,6 @@ public class ButtonBinding {
this.cooldown = cooldown;
return this;
}
/**
* Sets the cooldown enabled with a custom duration for {@link ButtonBinding}.
*
* @param cooldownLength duration of {@link ButtonBinding} cooldown
* @return the builder instance
*/
public Builder cooldown(int cooldownLength) {
this.cooldownLength = cooldownLength;
this.cooldown = true;
return this;
}
/**
* Puts a cooldown on the {@link ButtonBinding}.
@@ -617,7 +580,7 @@ public class ButtonBinding {
* @return the built {@link ButtonBinding}
*/
public ButtonBinding build() {
var binding = new ButtonBinding(this.key, this.buttons, this.actions, this.filter, this.cooldown, this.cooldownLength);
var binding = new ButtonBinding(this.key, this.buttons, this.actions, this.filter, this.cooldown);
if (this.category != null)
this.category.registerBinding(binding);
if (this.mcBinding != null)

View File

@@ -15,7 +15,9 @@ import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.toast.SystemToast;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.aperlambda.lambdacommon.utils.Nameable;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.glfw.GLFW;
@@ -177,7 +179,7 @@ public record Controller(int id) implements Nameable {
var client = MinecraftClient.getInstance();
if (client != null) {
client.getToastManager().add(SystemToast.create(client, SystemToast.Type.TUTORIAL_HINT,
Text.translatable("midnightcontrols.controller.mappings.error"), Text.literal(string)));
new TranslatableText("midnightcontrols.controller.mappings.error"), new LiteralText(string)));
MidnightControls.get().log(I18n.translate("midnightcontrols.controller.mappings.error")+string);
}
}

View File

@@ -9,27 +9,31 @@
package eu.midnightdust.midnightcontrols.client.controller;
import com.google.common.collect.ImmutableSet;
import eu.midnightdust.midnightcontrols.client.ButtonState;
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
import eu.midnightdust.midnightcontrols.client.MidnightInput;
import eu.midnightdust.midnightcontrols.client.compat.InventoryTabsCompat;
import eu.midnightdust.midnightcontrols.client.compat.EMICompat;
import eu.midnightdust.midnightcontrols.client.compat.MidnightControlsCompat;
import eu.midnightdust.midnightcontrols.client.compat.SodiumCompat;
import eu.midnightdust.midnightcontrols.client.gui.RingScreen;
import eu.midnightdust.midnightcontrols.client.mixin.AdvancementsScreenAccessor;
import eu.midnightdust.midnightcontrols.client.mixin.CreativeInventoryScreenAccessor;
import eu.midnightdust.midnightcontrols.client.mixin.RecipeBookWidgetAccessor;
import eu.midnightdust.midnightcontrols.client.util.HandledScreenAccessor;
import eu.midnightdust.midnightcontrols.client.util.MouseAccessor;
import net.fabricmc.fabric.impl.item.group.CreativeGuiExtensions;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.gui.hud.DebugHud;
import net.minecraft.client.gui.screen.advancement.AdvancementsScreen;
import net.minecraft.client.gui.screen.ingame.*;
import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget;
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.client.gui.widget.PressableWidget;
import net.minecraft.client.util.ScreenshotRecorder;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.Items;
import net.minecraft.screen.slot.Slot;
import net.minecraft.screen.slot.SlotActionType;
import org.aperlambda.lambdacommon.utils.Pair;
@@ -63,12 +67,10 @@ public class InputHandlers {
// When ingame
if (client.currentScreen == null && client.player != null) {
if (next)
client.player.getInventory().scrollInHotbar(-1.0);
client.player.getInventory().selectedSlot = client.player.getInventory().selectedSlot == 8 ? 0 : client.player.getInventory().selectedSlot + 1;
else
client.player.getInventory().scrollInHotbar(1.0);
client.player.getInventory().selectedSlot = client.player.getInventory().selectedSlot == 0 ? 8 : client.player.getInventory().selectedSlot - 1;
return true;
} else if (client.currentScreen instanceof RingScreen) {
MidnightControlsClient.get().ring.cyclePage(next);
} else if (client.currentScreen instanceof CreativeInventoryScreenAccessor inventory) {
int currentTab = CreativeInventoryScreenAccessor.getSelectedTab();
int nextTab = currentTab + (next ? 1 : -1);
@@ -78,27 +80,21 @@ public class InputHandlers {
nextTab = 0;
inventory.midnightcontrols$setSelectedTab(ItemGroup.GROUPS[nextTab]);
return true;
} else if (client.currentScreen instanceof InventoryScreen || client.currentScreen instanceof CraftingScreen || client.currentScreen instanceof AbstractFurnaceScreen<?>) {
RecipeBookWidget recipeBook;
if (client.currentScreen instanceof InventoryScreen inventoryScreen) recipeBook = inventoryScreen.getRecipeBookWidget();
else if (client.currentScreen instanceof CraftingScreen craftingScreen) recipeBook = craftingScreen.getRecipeBookWidget();
else recipeBook = ((AbstractFurnaceScreen<?>)client.currentScreen).getRecipeBookWidget();
var recipeBookAccessor = (RecipeBookWidgetAccessor) recipeBook;
var tabs = recipeBookAccessor.getTabButtons();
var currentTab = recipeBookAccessor.getCurrentTab();
if (currentTab == null || !recipeBook.isOpen()) {
if (MidnightControlsCompat.isInventoryTabsPresent()) InventoryTabsCompat.handleInventoryTabs(client.currentScreen, next);
} else if (client.currentScreen instanceof InventoryScreen inventoryScreen) {
var recipeBook = (RecipeBookWidgetAccessor) inventoryScreen.getRecipeBookWidget();
var tabs = recipeBook.getTabButtons();
var currentTab = recipeBook.getCurrentTab();
if (currentTab == null)
return false;
}
int nextTab = tabs.indexOf(currentTab) + (next ? 1 : -1);
if (nextTab < 0)
nextTab = tabs.size() - 1;
else if (nextTab >= tabs.size())
nextTab = 0;
currentTab.setToggled(false);
recipeBookAccessor.setCurrentTab(currentTab = tabs.get(nextTab));
recipeBook.setCurrentTab(currentTab = tabs.get(nextTab));
currentTab.setToggled(true);
recipeBookAccessor.midnightcontrols$refreshResults(true);
recipeBook.midnightcontrols$refreshResults(true);
return true;
} else if (client.currentScreen instanceof AdvancementsScreenAccessor screen) {
var tabs = screen.getTabs().values().stream().distinct().collect(Collectors.toList());
@@ -117,10 +113,7 @@ public class InputHandlers {
}
}
return true;
} else {
if (FabricLoader.getInstance().isModLoaded("sodium")) SodiumCompat.handleTabs(client.currentScreen, next);
}
if (MidnightControlsCompat.isInventoryTabsPresent()) InventoryTabsCompat.handleInventoryTabs(client.currentScreen, next);
} else if (FabricLoader.getInstance().isModLoaded("sodium")) SodiumCompat.handleTabs(client.currentScreen, next);
return false;
};
}
@@ -132,7 +125,7 @@ public class InputHandlers {
if (next) {
return client.currentScreen.children().stream().filter(element -> element instanceof PressableWidget)
.map(element -> (PressableWidget) element)
.filter(element -> element.getMessage() != null && element.getMessage().getContent() != null)
.filter(element -> element.getMessage() != null)
.anyMatch(element -> {
if (element.getMessage().getString().equals(">")) {
element.onPress();
@@ -143,7 +136,7 @@ public class InputHandlers {
} else {
return client.currentScreen.children().stream().filter(element -> element instanceof PressableWidget)
.map(element -> (PressableWidget) element)
.filter(element -> element.getMessage() != null && element.getMessage().getContent() != null)
.filter(element -> element.getMessage() != null)
.anyMatch(element -> {
if (element.getMessage().getString().equals("<")) {
element.onPress();
@@ -154,18 +147,6 @@ public class InputHandlers {
}
} catch (Exception ignored) {}
}
if (MidnightControlsCompat.isInventoryTabsPresent()) InventoryTabsCompat.handleInventoryPage(client.currentScreen, next);
return false;
};
}
public static PressAction handleExit() {
return (client, button, value, action) -> {
if (client.currentScreen != null && client.currentScreen.getClass() != TitleScreen.class) {
if (!MidnightControlsCompat.handleMenuBack(client, client.currentScreen))
if (!MidnightControlsClient.get().input.tryGoBack(client.currentScreen))
client.currentScreen.close();
return true;
}
return false;
};
}
@@ -224,7 +205,7 @@ public class InputHandlers {
public static boolean handlePauseGame(@NotNull MinecraftClient client, @NotNull ButtonBinding binding, float value, @NotNull ButtonState action) {
if (action == ButtonState.PRESS) {
// If in game, then pause the game.
if (client.currentScreen == null || client.currentScreen instanceof RingScreen)
if (client.currentScreen == null)
client.openPauseMenu(false);
else if (client.currentScreen instanceof HandledScreen && client.player != null) // If the current screen is a container then close it.
client.player.closeHandledScreen();
@@ -251,12 +232,12 @@ public class InputHandlers {
public static boolean handleToggleSneak(@NotNull MinecraftClient client, @NotNull ButtonBinding button, float value, @NotNull ButtonState action) {
button.asKeyBinding().ifPresent(binding -> {
boolean sneakToggled = client.options.getSneakToggled().getValue();
boolean sneakToggled = client.options.sneakToggled;
if (client.player.getAbilities().flying && sneakToggled)
client.options.getSneakToggled().setValue(false);
client.options.sneakToggled = false;
binding.setPressed(button.pressed);
if (client.player.getAbilities().flying && sneakToggled)
client.options.getSneakToggled().setValue(true);
client.options.sneakToggled = true;
});
return true;
}
@@ -347,7 +328,7 @@ public class InputHandlers {
* @return true if the client is in game, else false
*/
public static boolean inGame(@NotNull MinecraftClient client, @NotNull ButtonBinding binding) {
return (client.currentScreen == null && MidnightControlsClient.get().input.screenCloseCooldown <= 0) || client.currentScreen instanceof RingScreen;
return client.currentScreen == null && MidnightControlsClient.get().input.screenCloseCooldown <= 0;
}
/**

View File

@@ -17,7 +17,6 @@ import it.unimi.dsi.fastutil.ints.*;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.InputUtil;
import net.minecraft.util.math.MathHelper;
import org.aperlambda.lambdacommon.Identifier;
@@ -129,29 +128,6 @@ public class InputManager {
public static boolean hasBinding(@NotNull Identifier identifier) {
return hasBinding(identifier.getNamespace() + "." + identifier.getName());
}
private static ButtonBinding tempBinding;
/**
* Returns the binding matching the given string.
*
* @param name the name of the binding to get
* @return true if the binding is registered, else false
*/
public static ButtonBinding getBinding(@NotNull String name) {
if (BINDINGS.parallelStream().map(ButtonBinding::getName).anyMatch(binding -> binding.equalsIgnoreCase(name)))
BINDINGS.forEach(binding -> {
if (binding.getName().equalsIgnoreCase(name)) InputManager.tempBinding = binding;
});
return tempBinding;
}
private static List<ButtonBinding> unboundBindings;
public static List<ButtonBinding> getUnboundBindings() {
unboundBindings = new ArrayList<>();
BINDINGS.forEach(binding -> {
if (binding.isNotBound() && !MidnightControlsConfig.ignoredUnboundKeys.contains(binding.getTranslationKey())) unboundBindings.add(binding);
});
unboundBindings.sort(Comparator.comparing(s -> I18n.translate(s.getTranslationKey())));
return unboundBindings;
}
/**
* Registers a button binding.

View File

@@ -91,7 +91,7 @@ public final class MovementHandler implements PressAction {
// Slowing down if sneaking or crawling.
if (client.player.shouldSlowDown()) {
this.movementForward *= MathHelper.clamp(0.3F + EnchantmentHelper.getSwiftSneakSpeedBoost(client.player), 0.0F, 1.0F);
this.movementForward *= MathHelper.clamp(0.3F, 0.0F, 1.0F);
}
} else {
// Handle sideways movement.
@@ -101,7 +101,7 @@ public final class MovementHandler implements PressAction {
// Slowing down if sneaking or crawling.
if (client.player.shouldSlowDown()) {
this.movementSideways *= MathHelper.clamp(0.3F + EnchantmentHelper.getSwiftSneakSpeedBoost(client.player), 0.0F, 1.0F);
this.movementSideways *= MathHelper.clamp(0.3F, 0.0F, 1.0F);
}
}

View File

@@ -16,7 +16,9 @@ import dev.lambdaurora.spruceui.option.SpruceOption;
import dev.lambdaurora.spruceui.widget.container.SpruceContainerWidget;
import dev.lambdaurora.spruceui.widget.text.SpruceTextAreaWidget;
import net.minecraft.client.toast.SystemToast;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import java.io.FileWriter;
import java.io.IOException;
@@ -64,7 +66,7 @@ public class MappingsStringInputWidget extends SpruceContainerWidget {
} catch (IOException e) {
if (this.client != null)
this.client.getToastManager().add(SystemToast.create(this.client, SystemToast.Type.TUTORIAL_HINT,
Text.translatable("midnightcontrols.controller.mappings.error.write"), Text.empty()));
new TranslatableText("midnightcontrols.controller.mappings.error.write"), Text.of("")));
e.printStackTrace();
}
}
@@ -89,7 +91,7 @@ public class MappingsStringInputWidget extends SpruceContainerWidget {
}
int textFieldWidth = (int) (this.width * (5.0 / 6.0));
this.textArea = new SpruceTextAreaWidget(Position.of(this, this.width / 2 - textFieldWidth / 2, 0), textFieldWidth, this.height - 50, Text.literal(mappings));
this.textArea = new SpruceTextAreaWidget(Position.of(this, this.width / 2 - textFieldWidth / 2, 0), textFieldWidth, this.height - 50, new LiteralText(mappings));
this.textArea.setText(mappings);
// Display as many lines as possible
this.textArea.setDisplayedLines(this.textArea.getInnerHeight() / this.client.textRenderer.fontHeight);

View File

@@ -14,6 +14,7 @@ import eu.midnightdust.midnightcontrols.MidnightControlsConstants;
import eu.midnightdust.midnightcontrols.client.HudSide;
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
import eu.midnightdust.midnightcontrols.client.MidnightInput;
import eu.midnightdust.midnightcontrols.client.compat.MidnightControlsCompat;
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
import dev.lambdaurora.spruceui.hud.Hud;
@@ -52,7 +53,7 @@ public class MidnightControlsHud extends Hud {
private String attackAction = "";
private String placeAction = "";
private int ticksDisplayedCrosshair = 0;
private static boolean isCrammed = false;
private static float scale = 1f;
public MidnightControlsHud(@NotNull MidnightControlsClient mod) {
super(new Identifier(MidnightControlsConstants.NAMESPACE, "hud/button_indicator"));
@@ -71,23 +72,26 @@ public class MidnightControlsHud extends Hud {
this.dropItemButtonWidth = MidnightControlsRenderer.getBindingIconWidth(ButtonBinding.DROP_ITEM);
this.attackButtonWidth = MidnightControlsRenderer.getBindingIconWidth(ButtonBinding.ATTACK);
this.useButtonWidth = MidnightControlsRenderer.getBindingIconWidth(ButtonBinding.USE);
if (client.options.guiScale >= 4) {
scale = 0.75f;
} else scale = 1f;
}
/**
* Renders the MidnightControls HUD.
* Renders the midnightcontrols' HUD.
*/
@Override
public void render(MatrixStack matrices, float tickDelta) {
if (this.client == null) return;
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && this.client.currentScreen == null) {
isCrammed = client.getWindow().getScaledWidth() < 560;
int y = bottom(2);
matrices.push();
this.renderFirstIcons(matrices, MidnightControlsConfig.hudSide == HudSide.LEFT ? 2 : client.getWindow().getScaledWidth() - 2, y);
this.renderSecondIcons(matrices, MidnightControlsConfig.hudSide == HudSide.RIGHT ? 2 : client.getWindow().getScaledWidth() - 2, y);
this.renderFirstSection(matrices, MidnightControlsConfig.hudSide == HudSide.LEFT ? 2 : client.getWindow().getScaledWidth() - 2, y);
this.renderSecondSection(matrices, MidnightControlsConfig.hudSide == HudSide.RIGHT ? 2 : client.getWindow().getScaledWidth() - 2, y);
if (scale != 1f) matrices.scale(scale,scale,scale);
this.renderFirstIcons(matrices, MidnightControlsConfig.hudSide == HudSide.LEFT ? 2 : (int) ((client.getWindow().getScaledWidth() - 2) * (1 / scale)), y);
this.renderSecondIcons(matrices, MidnightControlsConfig.hudSide == HudSide.RIGHT ? 2 : (int) ((client.getWindow().getScaledWidth() - 2) * (1 / scale)), y);
this.renderFirstSection(matrices, MidnightControlsConfig.hudSide == HudSide.LEFT ? 2 : (int) ((client.getWindow().getScaledWidth() - 2) * (1 / scale)), y);
this.renderSecondSection(matrices, MidnightControlsConfig.hudSide == HudSide.RIGHT ? 2 : (int) ((client.getWindow().getScaledWidth() - 2) * (1 / scale)), y);
matrices.pop();
}
@@ -108,61 +112,53 @@ public class MidnightControlsHud extends Hud {
public void renderFirstIcons(MatrixStack matrices, int x, int y) {
int offset = 2 + this.inventoryWidth + this.inventoryButtonWidth + 4;
int currentX = MidnightControlsConfig.hudSide == HudSide.LEFT ? x : x - this.inventoryButtonWidth;
if (!ButtonBinding.INVENTORY.isNotBound()) this.drawButton(matrices, currentX, y, ButtonBinding.INVENTORY, true);
if (isCrammed) {
offset = 0;
y -= 20;
}
if (!ButtonBinding.SWAP_HANDS.isNotBound()) this.drawButton(matrices, currentX += (MidnightControlsConfig.hudSide == HudSide.LEFT ? offset : -offset), y, ButtonBinding.SWAP_HANDS, true);
this.drawButton(matrices, currentX, y, ButtonBinding.INVENTORY, true);
this.drawButton(matrices, currentX += (MidnightControlsConfig.hudSide == HudSide.LEFT ? offset : -offset), y, ButtonBinding.SWAP_HANDS, true);
offset = 2 + this.swapHandsWidth + this.dropItemButtonWidth + 4;
if (this.client.options.getShowSubtitles().getValue() && MidnightControlsConfig.hudSide == HudSide.RIGHT) {
if (this.client.options.showSubtitles && MidnightControlsConfig.hudSide == HudSide.RIGHT) {
currentX += -offset;
} else {
currentX = MidnightControlsConfig.hudSide == HudSide.LEFT ? x : x - this.dropItemButtonWidth;
y -= 20;
y -= 24;
}
if (!ButtonBinding.DROP_ITEM.isNotBound()) this.drawButton(matrices, currentX, y, ButtonBinding.DROP_ITEM, !this.client.player.getMainHandStack().isEmpty());
this.drawButton(matrices, currentX, y, ButtonBinding.DROP_ITEM, !this.client.player.getMainHandStack().isEmpty());
}
public void renderSecondIcons(MatrixStack matrices, int x, int y) {
int offset;
int currentX = x;
if (!this.placeAction.isEmpty() && (!ButtonBinding.USE.isNotBound()) ) {
if (!this.placeAction.isEmpty()) {
if (MidnightControlsConfig.hudSide == HudSide.LEFT)
currentX -= this.useButtonWidth;
this.drawButton(matrices, currentX, y, ButtonBinding.USE, true);
offset = 2 + this.useWidth + 4;
if (this.client.options.getShowSubtitles().getValue() && MidnightControlsConfig.hudSide == HudSide.LEFT) {
if (this.client.options.showSubtitles && MidnightControlsConfig.hudSide == HudSide.LEFT) {
currentX -= offset;
} else {
currentX = x;
y -= 20;
y -= 24;
}
}
if (MidnightControlsConfig.hudSide == HudSide.LEFT)
currentX -= this.attackButtonWidth;
if (!ButtonBinding.ATTACK.isNotBound()) this.drawButton(matrices, currentX, y, ButtonBinding.ATTACK, this.attackWidth != 0);
this.drawButton(matrices, currentX, y, ButtonBinding.ATTACK, this.attackWidth != 0);
}
public void renderFirstSection(MatrixStack matrices, int x, int y) {
int currentX = MidnightControlsConfig.hudSide == HudSide.LEFT ? x + this.inventoryButtonWidth + 2 : x - this.inventoryButtonWidth - 2 - this.inventoryWidth;
if (!ButtonBinding.INVENTORY.isNotBound()) this.drawTip(matrices, currentX, y, ButtonBinding.INVENTORY, true);
this.drawTip(matrices, currentX, y, ButtonBinding.INVENTORY, true);
currentX += MidnightControlsConfig.hudSide == HudSide.LEFT ? this.inventoryWidth + 4 + this.swapHandsButtonWidth + 2
: -this.swapHandsWidth - 2 - this.swapHandsButtonWidth - 4;
if (isCrammed) {
currentX = MidnightControlsConfig.hudSide == HudSide.LEFT ? x + this.inventoryButtonWidth + 2 : x - this.inventoryButtonWidth - 2 - this.inventoryWidth;
y -= 20;
}
if (!ButtonBinding.SWAP_HANDS.isNotBound()) this.drawTip(matrices, currentX, y, ButtonBinding.SWAP_HANDS, true);
if (this.client.options.getShowSubtitles().getValue() && MidnightControlsConfig.hudSide == HudSide.RIGHT) {
this.drawTip(matrices, currentX, y, ButtonBinding.SWAP_HANDS, true);
if (this.client.options.showSubtitles && MidnightControlsConfig.hudSide == HudSide.RIGHT) {
currentX += -this.dropItemWidth - 2 - this.dropItemButtonWidth - 4;
} else {
y -= 20;
y -= 24;
currentX = MidnightControlsConfig.hudSide == HudSide.LEFT ? x + this.dropItemButtonWidth + 2 : x - this.dropItemButtonWidth - 2 - this.dropItemWidth;
}
if (!ButtonBinding.DROP_ITEM.isNotBound()) this.drawTip(matrices, currentX, y, ButtonBinding.DROP_ITEM, !this.client.player.getMainHandStack().isEmpty());
this.drawTip(matrices, currentX, y, ButtonBinding.DROP_ITEM, !this.client.player.getMainHandStack().isEmpty());
}
public void renderSecondSection(MatrixStack matrices, int x, int y) {
@@ -173,17 +169,17 @@ public class MidnightControlsHud extends Hud {
this.drawTip(matrices, currentX, y, this.placeAction, true);
if (this.client.options.getShowSubtitles().getValue() && MidnightControlsConfig.hudSide == HudSide.LEFT) {
if (this.client.options.showSubtitles && MidnightControlsConfig.hudSide == HudSide.LEFT) {
currentX -= 4;
} else {
currentX = x;
y -= 20;
y -= 24;
}
}
currentX += MidnightControlsConfig.hudSide == HudSide.RIGHT ? this.attackButtonWidth + 2 : -this.attackButtonWidth - 2 - this.attackWidth;
if (!ButtonBinding.ATTACK.isNotBound()) this.drawTip(matrices, currentX, y, this.attackAction, this.attackWidth != 0);
this.drawTip(matrices, currentX, y, this.attackAction, this.attackWidth != 0);
}
@Override
@@ -259,7 +255,7 @@ public class MidnightControlsHud extends Hud {
}
private int bottom(int y) {
return (this.client.getWindow().getScaledHeight() - y - MidnightControlsRenderer.ICON_SIZE);
return (int) ((this.client.getWindow().getScaledHeight() * (1/scale)) - y - MidnightControlsRenderer.ICON_SIZE);
}
private int width(@NotNull ButtonBinding binding) {

View File

@@ -34,8 +34,10 @@ import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.render.*;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Util;
import net.minecraft.util.math.Matrix4f;
@@ -47,7 +49,7 @@ import java.awt.*;
* Represents the midnightcontrols settings screen.
*/
public class MidnightControlsSettingsScreen extends SpruceScreen {
private static final Text SDL2_GAMEPAD_TOOL = Text.literal("SDL2 Gamepad Tool").formatted(Formatting.GREEN);
private static final Text SDL2_GAMEPAD_TOOL = new LiteralText("SDL2 Gamepad Tool").formatted(Formatting.GREEN);
public static final String GAMEPAD_TOOL_URL = "https://generalarcade.com/gamepadtool/";
final MidnightControlsClient mod = MidnightControlsClient.get();
private final Screen parent;
@@ -88,11 +90,11 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
var controller = MidnightControlsConfig.getController();
var controllerName = controller.getName();
if (!controller.isConnected())
return option.getDisplayText(Text.literal(controllerName).formatted(Formatting.RED));
return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.RED));
else if (!controller.isGamepad())
return option.getDisplayText(Text.literal(controllerName).formatted(Formatting.GOLD));
return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.GOLD));
else
return option.getDisplayText(Text.literal(controllerName));
return option.getDisplayText(new LiteralText(controllerName));
}, null);
private final SpruceOption secondControllerOption = new SpruceCyclingOption("midnightcontrols.menu.controller2",
amount -> {
@@ -106,13 +108,13 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
option -> MidnightControlsConfig.getSecondController().map(controller -> {
var controllerName = controller.getName();
if (!controller.isConnected())
return option.getDisplayText(Text.literal(controllerName).formatted(Formatting.RED));
return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.RED));
else if (!controller.isGamepad())
return option.getDisplayText(Text.literal(controllerName).formatted(Formatting.GOLD));
return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.GOLD));
else
return option.getDisplayText(Text.literal(controllerName));
}).orElse(option.getDisplayText(SpruceTexts.OPTIONS_OFF.copyContentOnly().formatted(Formatting.RED))),
Text.translatable("midnightcontrols.tooltip.controller2"));
return option.getDisplayText(new LiteralText(controllerName));
}).orElse(option.getDisplayText(SpruceTexts.OPTIONS_OFF.copy().formatted(Formatting.RED))),
new TranslatableText("midnightcontrols.tooltip.controller2"));
private final SpruceOption unfocusedInputOption;
private final SpruceOption invertsRightXAxis;
private final SpruceOption invertsRightYAxis;
@@ -129,13 +131,13 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
return new SpruceDoubleOption(key, .25f, 1.f, 0.05f,
() -> MidnightControlsConfig.getAxisMaxValue(axis),
newValue -> MidnightControlsConfig.setAxisMaxValue(axis, newValue),
option -> option.getDisplayText(Text.literal(String.format("%.2f", option.get()))),
Text.translatable(key.replace("menu", "tooltip"))
option -> option.getDisplayText(new LiteralText(String.format("%.2f", option.get()))),
new TranslatableText(key.replace("menu", "tooltip"))
);
}
private final MutableText controllerMappingsUrlText = Text.literal("(")
.append(Text.literal(GAMEPAD_TOOL_URL).formatted(Formatting.GOLD))
private final MutableText controllerMappingsUrlText = new LiteralText("(")
.append(new LiteralText(GAMEPAD_TOOL_URL).formatted(Formatting.GOLD))
.append("),");
private static int searchNextAvailableController(int newId, boolean allowNone) {
@@ -153,7 +155,7 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
}
public MidnightControlsSettingsScreen(Screen parent, boolean hideControls) {
super(Text.translatable("midnightcontrols.title.settings"));
super(new TranslatableText("midnightcontrols.title.settings"));
MidnightControlsConfig.isEditing = true;
this.parent = parent;
// General options
@@ -166,22 +168,22 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
if (this.client.player != null) {
ClientPlayNetworking.getSender().sendPacket(MidnightControls.CONTROLS_MODE_CHANNEL, this.mod.makeControlsModeBuffer(next));
}
}, option -> option.getDisplayText(Text.translatable(MidnightControlsConfig.controlsMode.getTranslationKey())),
Text.translatable("midnightcontrols.tooltip.controls_mode"));
}, option -> option.getDisplayText(new TranslatableText(MidnightControlsConfig.controlsMode.getTranslationKey())),
new TranslatableText("midnightcontrols.tooltip.controls_mode"));
this.autoSwitchModeOption = new SpruceToggleBooleanOption("midnightcontrols.menu.auto_switch_mode", () -> MidnightControlsConfig.autoSwitchMode,
value -> MidnightControlsConfig.autoSwitchMode = value, Text.translatable("midnightcontrols.tooltip.auto_switch_mode"));
value -> MidnightControlsConfig.autoSwitchMode = value, new TranslatableText("midnightcontrols.tooltip.auto_switch_mode"));
this.rotationSpeedOption = new SpruceDoubleOption("midnightcontrols.menu.rotation_speed", 0.0, 100.0, .5f,
() -> MidnightControlsConfig.rotationSpeed,
value -> MidnightControlsConfig.rotationSpeed = value, option -> option.getDisplayText(Text.literal(String.valueOf(option.get()))),
Text.translatable("midnightcontrols.tooltip.rotation_speed"));
value -> MidnightControlsConfig.rotationSpeed = value, option -> option.getDisplayText(new LiteralText(String.valueOf(option.get()))),
new TranslatableText("midnightcontrols.tooltip.rotation_speed"));
this.yAxisRotationSpeedOption = new SpruceDoubleOption("midnightcontrols.menu.y_axis_rotation_speed", 0.0, 100.0, .5f,
() -> MidnightControlsConfig.yAxisRotationSpeed,
value -> MidnightControlsConfig.yAxisRotationSpeed = value, option -> option.getDisplayText(Text.literal(String.valueOf(option.get()))),
Text.translatable("midnightcontrols.tooltip.y_axis_rotation_speed"));
value -> MidnightControlsConfig.yAxisRotationSpeed = value, option -> option.getDisplayText(new LiteralText(String.valueOf(option.get()))),
new TranslatableText("midnightcontrols.tooltip.y_axis_rotation_speed"));
this.mouseSpeedOption = new SpruceDoubleOption("midnightcontrols.menu.mouse_speed", 0.0, 150.0, .5f,
() -> MidnightControlsConfig.mouseSpeed,
value -> MidnightControlsConfig.mouseSpeed = value, option -> option.getDisplayText(Text.literal(String.valueOf(option.get()))),
Text.translatable("midnightcontrols.tooltip.mouse_speed"));
value -> MidnightControlsConfig.mouseSpeed = value, option -> option.getDisplayText(new LiteralText(String.valueOf(option.get()))),
new TranslatableText("midnightcontrols.tooltip.mouse_speed"));
this.resetOption = SpruceSimpleActionOption.reset(btn -> {
// TODO
MidnightControlsConfig.reset();
@@ -191,60 +193,60 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
// Gameplay options
this.analogMovementOption = new SpruceToggleBooleanOption("midnightcontrols.menu.analog_movement",
() -> MidnightControlsConfig.analogMovement, value -> MidnightControlsConfig.analogMovement = value,
Text.translatable("midnightcontrols.tooltip.analog_movement"));
new TranslatableText("midnightcontrols.tooltip.analog_movement"));
this.doubleTapToSprintOption = new SpruceToggleBooleanOption("midnightcontrols.menu.double_tap_to_sprint",
() -> MidnightControlsConfig.doubleTapToSprint, value -> MidnightControlsConfig.doubleTapToSprint = value,
Text.translatable("midnightcontrols.tooltip.double_tap_to_sprint"));
new TranslatableText("midnightcontrols.tooltip.double_tap_to_sprint"));
this.autoJumpOption = new SpruceToggleBooleanOption("options.autoJump",
() -> this.client.options.getAutoJump().getValue(),
newValue -> this.client.options.getAutoJump().setValue(newValue),
() -> this.client.options.autoJump,
newValue -> this.client.options.autoJump = newValue,
null);
this.fastBlockPlacingOption = new SpruceToggleBooleanOption("midnightcontrols.menu.fast_block_placing", () -> MidnightControlsConfig.fastBlockPlacing,
value -> MidnightControlsConfig.fastBlockPlacing = value, Text.translatable("midnightcontrols.tooltip.fast_block_placing"));
value -> MidnightControlsConfig.fastBlockPlacing = value, new TranslatableText("midnightcontrols.tooltip.fast_block_placing"));
this.frontBlockPlacingOption = new SpruceToggleBooleanOption("midnightcontrols.menu.reacharound.horizontal", () -> MidnightControlsConfig.horizontalReacharound,
value -> MidnightControlsConfig.horizontalReacharound = value, Text.translatable("midnightcontrols.tooltip.reacharound.horizontal"));
value -> MidnightControlsConfig.horizontalReacharound = value, new TranslatableText("midnightcontrols.tooltip.reacharound.horizontal"));
this.verticalReacharoundOption = new SpruceToggleBooleanOption("midnightcontrols.menu.reacharound.vertical", () -> MidnightControlsConfig.verticalReacharound,
value -> MidnightControlsConfig.verticalReacharound = value, Text.translatable("midnightcontrols.tooltip.reacharound.vertical"));
value -> MidnightControlsConfig.verticalReacharound = value, new TranslatableText("midnightcontrols.tooltip.reacharound.vertical"));
this.flyDriftingOption = new SpruceToggleBooleanOption("midnightcontrols.menu.fly_drifting", () -> MidnightControlsConfig.flyDrifting,
value -> MidnightControlsConfig.flyDrifting = value, Text.translatable("midnightcontrols.tooltip.fly_drifting"));
value -> MidnightControlsConfig.flyDrifting = value, new TranslatableText("midnightcontrols.tooltip.fly_drifting"));
this.flyVerticalDriftingOption = new SpruceToggleBooleanOption("midnightcontrols.menu.fly_drifting_vertical", () -> MidnightControlsConfig.verticalFlyDrifting,
value -> MidnightControlsConfig.verticalFlyDrifting = value, Text.translatable("midnightcontrols.tooltip.fly_drifting_vertical"));
value -> MidnightControlsConfig.verticalFlyDrifting = value, new TranslatableText("midnightcontrols.tooltip.fly_drifting_vertical"));
// Appearance options
this.controllerTypeOption = new SpruceCyclingOption("midnightcontrols.menu.controller_type",
amount -> MidnightControlsConfig.controllerType = MidnightControlsConfig.controllerType.next(),
option -> option.getDisplayText(MidnightControlsConfig.controllerType.getTranslatedText()),
Text.translatable("midnightcontrols.tooltip.controller_type"));
new TranslatableText("midnightcontrols.tooltip.controller_type"));
this.virtualMouseSkinOption = new SpruceCyclingOption("midnightcontrols.menu.virtual_mouse.skin",
amount -> MidnightControlsConfig.virtualMouseSkin = MidnightControlsConfig.virtualMouseSkin.next(),
option -> option.getDisplayText(MidnightControlsConfig.virtualMouseSkin.getTranslatedText()),
null);
this.hudEnableOption = new SpruceToggleBooleanOption("midnightcontrols.menu.hud_enable", () -> MidnightControlsConfig.hudEnable,
this.mod::setHudEnabled, Text.translatable("midnightcontrols.tooltip.hud_enable"));
this.mod::setHudEnabled, new TranslatableText("midnightcontrols.tooltip.hud_enable"));
this.hudSideOption = new SpruceCyclingOption("midnightcontrols.menu.hud_side",
amount -> MidnightControlsConfig.hudSide = MidnightControlsConfig.hudSide.next(),
option -> option.getDisplayText(MidnightControlsConfig.hudSide.getTranslatedText()),
Text.translatable("midnightcontrols.tooltip.hud_side"));
new TranslatableText("midnightcontrols.tooltip.hud_side"));
// Controller options
this.rightDeadZoneOption = new SpruceDoubleOption("midnightcontrols.menu.right_dead_zone", 0.05, 1.0, .05f,
() -> MidnightControlsConfig.rightDeadZone,
value -> MidnightControlsConfig.rightDeadZone = value, option -> {
var value = String.valueOf(option.get());
return option.getDisplayText(Text.literal(value.substring(0, Math.min(value.length(), 5))));
}, Text.translatable("midnightcontrols.tooltip.right_dead_zone"));
return option.getDisplayText(new LiteralText(value.substring(0, Math.min(value.length(), 5))));
}, new TranslatableText("midnightcontrols.tooltip.right_dead_zone"));
this.leftDeadZoneOption = new SpruceDoubleOption("midnightcontrols.menu.left_dead_zone", 0.05, 1.0, .05f,
() -> MidnightControlsConfig.leftDeadZone,
value -> MidnightControlsConfig.leftDeadZone = value, option -> {
var value = String.valueOf(option.get());
return option.getDisplayText(Text.literal(value.substring(0, Math.min(value.length(), 5))));
}, Text.translatable("midnightcontrols.tooltip.left_dead_zone"));
return option.getDisplayText(new LiteralText(value.substring(0, Math.min(value.length(), 5))));
}, new TranslatableText("midnightcontrols.tooltip.left_dead_zone"));
this.invertsRightXAxis = new SpruceToggleBooleanOption("midnightcontrols.menu.invert_right_x_axis", () -> MidnightControlsConfig.invertRightXAxis,
value -> MidnightControlsConfig.invertRightXAxis = value, null);
this.invertsRightYAxis = new SpruceToggleBooleanOption("midnightcontrols.menu.invert_right_y_axis", () -> MidnightControlsConfig.invertRightYAxis,
value -> MidnightControlsConfig.invertRightYAxis = value, null);
this.unfocusedInputOption = new SpruceToggleBooleanOption("midnightcontrols.menu.unfocused_input", () -> MidnightControlsConfig.unfocusedInput,
value -> MidnightControlsConfig.unfocusedInput = value, Text.translatable("midnightcontrols.tooltip.unfocused_input"));
value -> MidnightControlsConfig.unfocusedInput = value, new TranslatableText("midnightcontrols.tooltip.unfocused_input"));
this.virtualMouseOption = new SpruceToggleBooleanOption("midnightcontrols.menu.virtual_mouse", () -> MidnightControlsConfig.virtualMouse,
value -> MidnightControlsConfig.virtualMouse = value, Text.translatable("midnightcontrols.tooltip.virtual_mouse"));
value -> MidnightControlsConfig.virtualMouse = value, new TranslatableText("midnightcontrols.tooltip.virtual_mouse"));
}
@Override
@@ -283,22 +285,22 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
tabs.getList().setBackground(new MidnightControlsBackground());
this.addDrawableChild(tabs);
tabs.addSeparatorEntry(Text.translatable("midnightcontrols.menu.separator.general"));
tabs.addTabEntry(Text.translatable("midnightcontrols.menu.title.general"), null,
tabs.addSeparatorEntry(new TranslatableText("midnightcontrols.menu.separator.general"));
tabs.addTabEntry(new TranslatableText("midnightcontrols.menu.title.general"), null,
this::buildGeneralTab);
tabs.addTabEntry(Text.translatable("midnightcontrols.menu.title.gameplay"), null,
tabs.addTabEntry(new TranslatableText("midnightcontrols.menu.title.gameplay"), null,
this::buildGameplayTab);
tabs.addTabEntry(Text.translatable("midnightcontrols.menu.title.visual"), null,
tabs.addTabEntry(new TranslatableText("midnightcontrols.menu.title.visual"), null,
this::buildVisualTab);
tabs.addSeparatorEntry(Text.translatable("options.controls"));
tabs.addTabEntry(Text.translatable("midnightcontrols.menu.title.controller_controls"), null,
tabs.addSeparatorEntry(new TranslatableText("options.controls"));
tabs.addTabEntry(new TranslatableText("midnightcontrols.menu.title.controller_controls"), null,
this::buildControllerControlsTab);
tabs.addSeparatorEntry(Text.translatable("midnightcontrols.menu.separator.controller"));
tabs.addTabEntry(Text.translatable("midnightcontrols.menu.title.controller"), null,
tabs.addSeparatorEntry(new TranslatableText("midnightcontrols.menu.separator.controller"));
tabs.addTabEntry(new TranslatableText("midnightcontrols.menu.title.controller"), null,
this::buildControllerTab);
tabs.addTabEntry(Text.translatable("midnightcontrols.menu.title.mappings.string"), null,
tabs.addTabEntry(new TranslatableText("midnightcontrols.menu.title.mappings.string"), null,
this::buildMappingsStringEditorTab);
}
@@ -347,17 +349,17 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
var root = new SpruceContainerWidget(Position.origin(), width, height);
var aboutMappings1 = new SpruceLabelWidget(Position.of(0, 2),
Text.translatable("midnightcontrols.controller.mappings.1", SDL2_GAMEPAD_TOOL),
new TranslatableText("midnightcontrols.controller.mappings.1", SDL2_GAMEPAD_TOOL),
width, true);
var gamepadToolUrlLabel = new SpruceLabelWidget(Position.of(0, aboutMappings1.getHeight() + 4),
this.controllerMappingsUrlText, width,
label -> Util.getOperatingSystem().open(GAMEPAD_TOOL_URL), true);
gamepadToolUrlLabel.setTooltip(Text.translatable("chat.link.open"));
gamepadToolUrlLabel.setTooltip(new TranslatableText("chat.link.open"));
var aboutMappings3 = new SpruceLabelWidget(Position.of(0,
aboutMappings1.getHeight() + gamepadToolUrlLabel.getHeight() + 6),
Text.translatable("midnightcontrols.controller.mappings.3", Formatting.GREEN.toString(), Formatting.RESET.toString()),
new TranslatableText("midnightcontrols.controller.mappings.3", Formatting.GREEN.toString(), Formatting.RESET.toString()),
width, true);
int listHeight = height - 8 - aboutMappings1.getHeight() - aboutMappings3.getHeight() - gamepadToolUrlLabel.getHeight();
@@ -422,7 +424,8 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
bufferBuilder.vertex(matrix, (float)x2, (float)y2, 0.0F).color(r, g, b, t).next();
bufferBuilder.vertex(matrix, (float)x2, (float)y1, 0.0F).color(r, g, b, t).next();
bufferBuilder.vertex(matrix, (float)x1, (float)y1, 0.0F).color(r, g, b, t).next();
BufferRenderer.drawWithShader(bufferBuilder.end());
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
RenderSystem.enableTexture();
RenderSystem.disableBlend();
matrixStack.pop();

View File

@@ -15,6 +15,7 @@ import dev.lambdaurora.spruceui.widget.SpruceButtonWidget;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.toast.SystemToast;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.jetbrains.annotations.Nullable;
import java.util.function.Consumer;
@@ -34,7 +35,7 @@ public class ReloadControllerMappingsOption {
if (client.currentScreen instanceof MidnightControlsSettingsScreen)
client.currentScreen.init(client, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
client.getToastManager().add(SystemToast.create(client, SystemToast.Type.TUTORIAL_HINT,
Text.translatable("midnightcontrols.controller.mappings.updated"), Text.empty()));
}, Text.translatable("midnightcontrols.tooltip.reload_controller_mappings"));
new TranslatableText("midnightcontrols.controller.mappings.updated"), Text.of("")));
}, new TranslatableText("midnightcontrols.tooltip.reload_controller_mappings"));
}
}

View File

@@ -10,12 +10,10 @@
package eu.midnightdust.midnightcontrols.client.gui;
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
import eu.midnightdust.midnightcontrols.client.ring.MidnightRing;
import eu.midnightdust.midnightcontrols.client.ring.RingButtonMode;
import eu.midnightdust.midnightcontrols.client.ring.RingPage;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
/**
@@ -29,19 +27,10 @@ public class RingScreen extends Screen {
protected final MidnightControlsClient mod;
public RingScreen() {
super(Text.literal("midnightcontrols.menu.title.ring"));
super(new LiteralText("midnightcontrols.menu.title.ring"));
this.mod = MidnightControlsClient.get();
}
@Override
protected void init() {
super.init();
if (mod.ring.getMaxPages() > 1) {
this.addDrawableChild(new ButtonWidget(5, 5, 20, 20, Text.of(""), button -> this.mod.ring.cyclePage(false)));
this.addDrawableChild(new ButtonWidget(width - 25, 5, 20, 20, Text.of(""), button -> this.mod.ring.cyclePage(true)));
}
}
@Override
public boolean shouldPause() {
return false;
@@ -52,36 +41,13 @@ public class RingScreen extends Screen {
super.render(matrices, mouseX, mouseY, delta);
RingPage page = this.mod.ring.getCurrentPage();
page.render(matrices, this.textRenderer, this.width, this.height, mouseX, mouseY, delta);
}
@Override
public void close() {
super.close();
assert client != null;
client.currentScreen = null;
RingPage page = this.mod.ring.getCurrentPage();
if (RingPage.selected >= 0 && page.actions[RingPage.selected] != null)
page.actions[RingPage.selected].activate(RingButtonMode.PRESS);
RingPage.selected = -1;
this.removed();
}
@Override
public boolean changeFocus(boolean lookForwards) {
if (lookForwards) {
if (RingPage.selected < 7) ++RingPage.selected;
else RingPage.selected = -1;
}
else {
if (RingPage.selected > -1) --RingPage.selected;
else RingPage.selected = 7;
}
return true;
}
@Override
public boolean mouseReleased(double mouseX, double mouseY, int button) {
if (mod.ring.getCurrentPage().onClick(width, height, (int) mouseX, (int) mouseY)) {
if (mod.ring.getCurrentPage().onClick(client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight(), (int) mouseX, (int) mouseY)) {
this.close();
return true;
}

View File

@@ -22,6 +22,7 @@ import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.client.gui.widget.TexturedButtonWidget;
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Arm;
import net.minecraft.util.Identifier;
@@ -51,7 +52,7 @@ public class TouchscreenOverlay extends Screen {
private SilentTexturedButtonWidget endSneakButton;
public TouchscreenOverlay(@NotNull MidnightControlsClient mod) {
super(Text.literal("Touchscreen overlay"));
super(new LiteralText("Touchscreen overlay"));
this.mod = mod;
this.passEvents = true;
}
@@ -155,13 +156,13 @@ public class TouchscreenOverlay extends Screen {
int scaledWidth = this.client.getWindow().getScaledWidth();
int scaledHeight = this.client.getWindow().getScaledHeight();
this.addDrawableChild(new TexturedButtonWidget(scaledWidth / 2 - 20, 0, 20, 20, 0, 106, 20, new Identifier("textures/gui/widgets.png"), 256, 256,
btn -> this.client.setScreen(new ChatScreen("")), Text.empty()));
btn -> this.client.setScreen(new ChatScreen("")), Text.of("")));
this.addDrawableChild(new TexturedButtonWidget(scaledWidth / 2, 0, 20, 20, 0, 0, 20, WIDGETS_LOCATION, 256, 256,
btn -> this.pauseGame(false)));
// Inventory buttons.
int inventoryButtonX = scaledWidth / 2;
int inventoryButtonY = scaledHeight - 16 - 5;
if (this.client.options.getMainArm().getValue() == Arm.LEFT) {
if (this.client.options.mainArm == Arm.LEFT) {
inventoryButtonX = inventoryButtonX - 91 - 24;
} else {
inventoryButtonX = inventoryButtonX + 91 + 4;
@@ -187,7 +188,7 @@ public class TouchscreenOverlay extends Screen {
sneakButtonX = scaledWidth - 10 - 40 - 5;
}
// Swap items hand.
this.addDrawableChild(new SilentTexturedButtonWidget(Position.of(swapHandsX, sneakButtonY), 20, 20, Text.empty(),
this.addDrawableChild(new SilentTexturedButtonWidget(Position.of(swapHandsX, sneakButtonY), 20, 20, Text.of(""),
button -> {
if (button.isActive()) {
if (!this.client.player.isSpectator()) {
@@ -196,23 +197,23 @@ public class TouchscreenOverlay extends Screen {
}
},0, 160, 20, WIDGETS_LOCATION));
// Drop
this.addDrawableChild(new SilentTexturedButtonWidget(Position.of(swapHandsX, sneakButtonY + 5 + 20), 20, 20, Text.empty(), btn ->
this.addDrawableChild(new SilentTexturedButtonWidget(Position.of(swapHandsX, sneakButtonY + 5 + 20), 20, 20, Text.of(""), btn ->
((KeyBindingAccessor) this.client.options.dropKey).midnightcontrols$handlePressState(btn.isActive()), 0, 160, 20, WIDGETS_LOCATION));
// Jump keys
this.addDrawableChild(this.jumpButton = new SilentTexturedButtonWidget(Position.of(jumpButtonX, sneakButtonY), 20, 20, Text.empty(), this::handleJump, 0, 40, 20, WIDGETS_LOCATION));
this.addDrawableChild(this.flyButton = new SilentTexturedButtonWidget(Position.of(jumpButtonX, sneakButtonY), 20, 20, Text.empty(),btn -> {
this.addDrawableChild(this.jumpButton = new SilentTexturedButtonWidget(Position.of(jumpButtonX, sneakButtonY), 20, 20, Text.of(""), this::handleJump, 0, 40, 20, WIDGETS_LOCATION));
this.addDrawableChild(this.flyButton = new SilentTexturedButtonWidget(Position.of(jumpButtonX, sneakButtonY), 20, 20, Text.of(""),btn -> {
if (this.flyButtonEnableTicks == 0) this.client.player.getAbilities().flying = false;
}, 20, 40, 20, WIDGETS_LOCATION)
);
this.addDrawableChild(this.flyUpButton = new SilentTexturedButtonWidget(Position.of(jumpButtonX, sneakButtonY - 5 - 20), 20, 20,Text.empty(),
this.addDrawableChild(this.flyUpButton = new SilentTexturedButtonWidget(Position.of(jumpButtonX, sneakButtonY - 5 - 20), 20, 20,Text.of(""),
this::handleJump, 40, 40, 20, WIDGETS_LOCATION
));
this.addDrawableChild(this.flyDownButton = new SilentTexturedButtonWidget(Position.of(jumpButtonX, sneakButtonY + 20 + 5), 20, 20, Text.empty(),
this.addDrawableChild(this.flyDownButton = new SilentTexturedButtonWidget(Position.of(jumpButtonX, sneakButtonY + 20 + 5), 20, 20, Text.of(""),
btn -> ((KeyBindingAccessor) this.client.options.sneakKey).midnightcontrols$handlePressState(btn.isActive()), 60, 40, 20, WIDGETS_LOCATION
));
this.updateJumpButtons();
// Movements keys
this.addDrawableChild((this.startSneakButton = new SilentTexturedButtonWidget(Position.of(sneakButtonX, sneakButtonY), 20, 20, Text.empty(), btn -> {
this.addDrawableChild((this.startSneakButton = new SilentTexturedButtonWidget(Position.of(sneakButtonX, sneakButtonY), 20, 20, Text.of(""), btn -> {
if (btn.isActive()) {
((KeyBindingAccessor) this.client.options.sneakKey).midnightcontrols$handlePressState(true);
this.startSneakButton.setVisible(false);
@@ -220,7 +221,7 @@ public class TouchscreenOverlay extends Screen {
}
}, 0, 120, 20, WIDGETS_LOCATION))
);
this.addDrawableChild((this.endSneakButton = new SilentTexturedButtonWidget(Position.of(sneakButtonX, sneakButtonY), 20, 20, Text.empty(), btn -> {
this.addDrawableChild((this.endSneakButton = new SilentTexturedButtonWidget(Position.of(sneakButtonX, sneakButtonY), 20, 20, Text.of(""), btn -> {
if (btn.isActive()) {
((KeyBindingAccessor) this.client.options.sneakKey).midnightcontrols$handlePressState(false);
this.endSneakButton.setVisible(false);
@@ -228,34 +229,34 @@ public class TouchscreenOverlay extends Screen {
}
}, 20, 120, 20, WIDGETS_LOCATION)));
this.endSneakButton.setVisible(false);
this.addDrawableChild(this.forwardLeftButton = new SilentTexturedButtonWidget(Position.of(sneakButtonX - 20 - 5, sneakButtonY - 5 - 20), 20, 20, Text.empty(), btn -> {
this.addDrawableChild(this.forwardLeftButton = new SilentTexturedButtonWidget(Position.of(sneakButtonX - 20 - 5, sneakButtonY - 5 - 20), 20, 20, Text.of(""), btn -> {
((KeyBindingAccessor) this.client.options.forwardKey).midnightcontrols$handlePressState(btn.isActive());
((KeyBindingAccessor) this.client.options.leftKey).midnightcontrols$handlePressState(btn.isActive());
this.updateForwardButtonsState(btn.isActive());
}, 80, 80, 20, WIDGETS_LOCATION
));
this.forwardLeftButton.setVisible(false);
this.addDrawableChild(new SilentTexturedButtonWidget(Position.of(sneakButtonX, sneakButtonY - 5 - 20), 20, 20, Text.empty(), btn -> {
this.addDrawableChild(new SilentTexturedButtonWidget(Position.of(sneakButtonX, sneakButtonY - 5 - 20), 20, 20, Text.of(""), btn -> {
((KeyBindingAccessor) this.client.options.forwardKey).midnightcontrols$handlePressState(btn.isActive());
this.updateForwardButtonsState(btn.isActive());
this.forwardLeftButton.setVisible(true);
this.forwardRightButton.setVisible(true);
}, 0, 80, 20, WIDGETS_LOCATION
));
this.addDrawableChild(this.forwardRightButton = new SilentTexturedButtonWidget(Position.of(sneakButtonX + 20 + 5, sneakButtonY - 5 - 20), 20, 20, Text.empty(), btn -> {
this.addDrawableChild(this.forwardRightButton = new SilentTexturedButtonWidget(Position.of(sneakButtonX + 20 + 5, sneakButtonY - 5 - 20), 20, 20, Text.of(""), btn -> {
((KeyBindingAccessor) this.client.options.forwardKey).midnightcontrols$handlePressState(btn.isActive());
((KeyBindingAccessor) this.client.options.rightKey).midnightcontrols$handlePressState(btn.isActive());
this.updateForwardButtonsState(btn.isActive());
}, 100, 80, 20, WIDGETS_LOCATION
));
this.forwardRightButton.setVisible(true);
this.addDrawableChild(new SilentTexturedButtonWidget(Position.of(sneakButtonX + 20 + 5, sneakButtonY), 20, 20, Text.empty(),
this.addDrawableChild(new SilentTexturedButtonWidget(Position.of(sneakButtonX + 20 + 5, sneakButtonY), 20, 20, Text.of(""),
btn -> ((KeyBindingAccessor) this.client.options.rightKey).midnightcontrols$handlePressState(btn.isActive()), 20, 80, 20, WIDGETS_LOCATION
));
this.addDrawableChild(new SilentTexturedButtonWidget(Position.of(sneakButtonX, sneakButtonY + 20 + 5), 20, 20, Text.empty(),
this.addDrawableChild(new SilentTexturedButtonWidget(Position.of(sneakButtonX, sneakButtonY + 20 + 5), 20, 20, Text.of(""),
btn -> ((KeyBindingAccessor) this.client.options.backKey).midnightcontrols$handlePressState(btn.isActive()), 40, 80, 20, WIDGETS_LOCATION
));
this.addDrawableChild(new SilentTexturedButtonWidget(Position.of(sneakButtonX - 20 - 5, sneakButtonY), 20, 20, Text.empty(),
this.addDrawableChild(new SilentTexturedButtonWidget(Position.of(sneakButtonX - 20 - 5, sneakButtonY), 20, 20, Text.of(""),
btn -> ((KeyBindingAccessor) this.client.options.leftKey).midnightcontrols$handlePressState(btn.isActive()), 60, 80, 20, WIDGETS_LOCATION
));
}

View File

@@ -16,6 +16,7 @@ import dev.lambdaurora.spruceui.SpruceTexts;
import dev.lambdaurora.spruceui.widget.AbstractSpruceIconButtonWidget;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import org.jetbrains.annotations.NotNull;
@@ -34,13 +35,13 @@ public class ControllerButtonWidget extends AbstractSpruceIconButtonWidget {
public void update() {
int length = binding.getButton().length;
this.setMessage(this.binding.isNotBound() ? SpruceTexts.NOT_BOUND.copy() :
(length > 0 ? ButtonBinding.getLocalizedButtonName(binding.getButton()[0]) : Text.literal("<>")));
(length > 0 ? ButtonBinding.getLocalizedButtonName(binding.getButton()[0]) : new LiteralText("<>")));
}
@Override
public Text getMessage() {
if (this.binding.getButton().length > 1)
return Text.empty();
return Text.of("");
return super.getMessage();
}

View File

@@ -21,6 +21,7 @@ import eu.midnightdust.midnightcontrols.client.gui.MidnightControlsSettingsScree
import net.minecraft.client.gui.screen.option.ControlsOptionsScreen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.aperlambda.lambdacommon.utils.function.Predicates;
import java.util.ArrayList;
@@ -47,7 +48,7 @@ public class ControllerControlsWidget extends SpruceContainerWidget {
protected void init() {
this.addChild(new SpruceButtonWidget(Position.of(this, this.width / 2 - 155, 18), 310, 20,
Text.translatable("midnightcontrols.menu.keyboard_controls"),
new TranslatableText("midnightcontrols.menu.keyboard_controls"),
btn -> this.client.setScreen(new ControlsOptionsScreen(null, this.client.options))));
this.bindingsListWidget = new ControlsListWidget(Position.of(this, 0, 43), this.width, this.height - 43 - 35, this);
this.bindingsListWidget.setBackground(new MidnightControlsSettingsScreen.MidnightControlsBackground(130));
@@ -59,7 +60,7 @@ public class ControllerControlsWidget extends SpruceContainerWidget {
@Override
public void renderWidget(MatrixStack matrices, int mouseX, int mouseY, float delta) {
drawCenteredText(matrices, this.client.textRenderer, Text.translatable("midnightcontrols.menu.title.controller_controls"),
drawCenteredText(matrices, this.client.textRenderer, new TranslatableText("midnightcontrols.menu.title.controller_controls"),
this.getX() + this.width / 2, this.getY() + 4, 16777215);
this.resetButton.setActive(InputManager.streamBindings().anyMatch(Predicates.not(ButtonBinding::isDefault)));
super.renderWidget(matrices, mouseX, mouseY, delta);

View File

@@ -27,7 +27,9 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -91,17 +93,17 @@ public class ControlsListWidget extends SpruceEntryListWidget<ControlsListWidget
MidnightControlsClient.get().input.beginControlsInput(gui);
}) {
protected Text getNarrationMessage() {
return binding.isNotBound() ? Text.translatable("narrator.controls.unbound", bindingName)
: Text.translatable("narrator.controls.bound", bindingName, super.getNarrationMessage());
return binding.isNotBound() ? new TranslatableText("narrator.controls.unbound", bindingName)
: new TranslatableText("narrator.controls.bound", bindingName, super.getNarrationMessage());
}
};
this.children.add(editButton);
this.resetButton = new SpruceButtonWidget(Position.of(this,
this.editButton.getPosition().getRelativeX() + this.editButton.getWidth() + 2, 0),
44, 20, Text.translatable("controls.reset"),
44, 20, new TranslatableText("controls.reset"),
btn -> MidnightControlsConfig.setButtonBinding(binding, binding.getDefaultButton())) {
protected Text getNarrationMessage() {
return Text.translatable("narrator.controls.reset", bindingName);
return new TranslatableText("narrator.controls.reset", bindingName);
}
};
this.children.add(this.resetButton);
@@ -114,7 +116,7 @@ public class ControlsListWidget extends SpruceEntryListWidget<ControlsListWidget
MidnightControlsClient.get().input.beginControlsInput(null);
}) {
protected Text getNarrationMessage() {
return Text.translatable("midnightcontrols.narrator.unbound", bindingName);
return new TranslatableText("midnightcontrols.narrator.unbound", bindingName);
}
};
this.children.add(this.unbindButton);
@@ -241,9 +243,9 @@ public class ControlsListWidget extends SpruceEntryListWidget<ControlsListWidget
this.editButton.update();
if (focused) {
var text = Text.literal("> ").formatted(Formatting.WHITE);
var text = new LiteralText("> ").formatted(Formatting.WHITE);
text.append(this.editButton.getMessage().copy().formatted(Formatting.YELLOW));
this.editButton.setMessage(text.append(Text.literal(" <").formatted(Formatting.WHITE)));
this.editButton.setMessage(text.append(new LiteralText(" <").formatted(Formatting.WHITE)));
} else if (!this.binding.isNotBound() && InputManager.hasDuplicatedBindings(this.binding)) {
var text = this.editButton.getMessage().copy();
this.editButton.setMessage(text.formatted(Formatting.RED));
@@ -262,7 +264,7 @@ public class ControlsListWidget extends SpruceEntryListWidget<ControlsListWidget
protected CategoryEntry(ControlsListWidget parent, ButtonCategory category) {
super(parent);
this.separatorWidget = new SpruceSeparatorWidget(Position.of(this, 2, 0), this.getWidth() - 4,
Text.literal(category.getTranslatedName())) {
new LiteralText(category.getTranslatedName())) {
@Override
public int getWidth() {
return CategoryEntry.this.getWidth() - 4;

View File

@@ -11,7 +11,6 @@ package eu.midnightdust.midnightcontrols.client.mixin;
import com.mojang.authlib.GameProfile;
import eu.midnightdust.midnightcontrols.MidnightControls;
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
import eu.midnightdust.midnightcontrols.client.controller.MovementHandler;
import net.minecraft.client.MinecraftClient;
@@ -20,15 +19,12 @@ import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.MovementType;
import net.minecraft.network.encryption.PlayerPublicKey;
import net.minecraft.util.math.Vec3d;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/**
@@ -38,8 +34,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity {
private boolean midnightcontrols$driftingPrevented = false;
public ClientPlayerEntityMixin(ClientWorld world, GameProfile profile, @Nullable PlayerPublicKey publicKey) {
super(world, profile, publicKey);
public ClientPlayerEntityMixin(ClientWorld world, GameProfile profile) {
super(world, profile);
}
@Shadow
@@ -76,7 +72,7 @@ public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity
}
}
@Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick(ZF)V", shift = At.Shift.AFTER))
@Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick(Z)V", shift = At.Shift.AFTER))
public void onInputUpdate(CallbackInfo ci) {
MovementHandler.HANDLER.applyMovement((ClientPlayerEntity) (Object) this);
}

View File

@@ -18,6 +18,7 @@ import net.minecraft.client.gui.screen.option.GameOptionsScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.option.GameOptions;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
@@ -39,7 +40,7 @@ public abstract class ControlsOptionsScreenMixin extends GameOptionsScreen {
if (showAlternativeButton) {
this.addDrawableChild(new TexturedOverlayButtonWidget(this.width / 2 + 158, this.height / 6 - 12, 20, 20,0,0,20, new Identifier("midnightcontrols", "textures/gui/midnightcontrols_button.png"), 32, 64, (button) -> {
this.client.setScreen(new MidnightControlsSettingsScreen(this, false));
}, Text.translatable("midnightcontrols.menu.title.controller")));
}, new TranslatableText("midnightcontrols.menu.title.controller")));
}
}
@Inject(method = "init", at = @At(value = "INVOKE", ordinal = 4, shift = At.Shift.AFTER, target = "Lnet/minecraft/client/gui/screen/option/ControlsOptionsScreen;addDrawableChild(Lnet/minecraft/client/gui/Element;)Lnet/minecraft/client/gui/Element;"))
@@ -48,7 +49,7 @@ public abstract class ControlsOptionsScreenMixin extends GameOptionsScreen {
int i = this.width / 2 - 155;
int j = i + 160;
int k = this.height / 6 - 12 + 48;
this.addDrawableChild(new ButtonWidget(j, k, 150, 20, Text.translatable("midnightcontrols.menu.title.controller").append("..."), (button) -> {
this.addDrawableChild(new ButtonWidget(j, k, 150, 20, new TranslatableText("midnightcontrols.menu.title.controller").append("..."), (button) -> {
this.client.setScreen(new MidnightControlsSettingsScreen(this, false));
}));
}

View File

@@ -10,8 +10,7 @@
package eu.midnightdust.midnightcontrols.client.mixin;
import net.minecraft.client.option.GameOptions;
import net.minecraft.client.option.SimpleOption;
import org.spongepowered.asm.mixin.Final;
import net.minecraft.client.option.Option;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -26,11 +25,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(GameOptions.class)
public abstract class GameOptionsMixin {
@Shadow public abstract SimpleOption<Boolean> getAutoJump();
@Shadow public boolean autoJump;
@Inject(method = "load", at = @At("HEAD"))
public void onInit(CallbackInfo ci) {
// Set default value of the Auto-Jump option to false.
getAutoJump().setValue(false);
autoJump = false;
}
}

View File

@@ -12,7 +12,6 @@ package eu.midnightdust.midnightcontrols.client.mixin;
import eu.midnightdust.midnightcontrols.ControlsMode;
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
import eu.midnightdust.midnightcontrols.client.MidnightInput;
import eu.midnightdust.midnightcontrols.client.compat.EMICompat;
import eu.midnightdust.midnightcontrols.client.compat.MidnightControlsCompat;
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
import eu.midnightdust.midnightcontrols.client.gui.MidnightControlsRenderer;
@@ -23,6 +22,7 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.slot.Slot;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW;
import org.spongepowered.asm.mixin.Mixin;
@@ -38,6 +38,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
*/
@Mixin(HandledScreen.class)
public abstract class HandledScreenMixin implements HandledScreenAccessor {
@Unique private static float scale = 1f;
@Accessor("x")
public abstract int getX();
@@ -56,26 +58,30 @@ public abstract class HandledScreenMixin implements HandledScreenAccessor {
@Inject(method = "render", at = @At("RETURN"))
public void onRender(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && MidnightControlsConfig.hudEnable) {
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER) {
var client = MinecraftClient.getInstance();
if (client.options.guiScale >= 4) {
scale = 0.75f;
} else scale = 1f;
matrices.push();
int x = 2, y = client.getWindow().getScaledHeight() - 2 - MidnightControlsRenderer.ICON_SIZE;
if (MidnightControlsCompat.isEMIPresent() && EMICompat.isEMIEnabled()) {
x += 42;
if (scale != 1f) matrices.scale(scale,scale,scale);
int x = 2, y = (int) (client.getWindow().getScaledHeight() * (1 / scale) - 2 - MidnightControlsRenderer.ICON_SIZE);
if (MidnightControlsCompat.isEMIPresent()) {
x += 40 * (1 / scale);
}
if (!ButtonBinding.TAKE_ALL.isNotBound()) x = MidnightControlsRenderer.drawButtonTip(matrices, x, y, ButtonBinding.TAKE_ALL,true, client) + 2;
if (!ButtonBinding.EXIT.isNotBound()) x = MidnightControlsRenderer.drawButtonTip(matrices, x, y, ButtonBinding.EXIT, true, client) + 2;
x = MidnightControlsRenderer.drawButtonTip(matrices, x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_A}, "midnightcontrols.action.pickup_all", true, client) + 2;
x = MidnightControlsRenderer.drawButtonTip(matrices, x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_B}, "midnightcontrols.action.exit", true, client) + 2;
if (MidnightControlsCompat.isReiPresent()) {
x = 2;
y -= 24;
}
if (MidnightControlsCompat.isEMIPresent() && EMICompat.isEMIEnabled() && EMICompat.isSearchBarCentered()) {
x = client.getWindow().getScaledWidth() - 55 - client.textRenderer.getWidth(Text.translatable("midnightcontrols.action.pickup"))
- client.textRenderer.getWidth(Text.translatable("midnightcontrols.action.quick_move"))
- MidnightControlsRenderer.getBindingIconWidth(ButtonBinding.TAKE) - MidnightControlsRenderer.getBindingIconWidth(ButtonBinding.QUICK_MOVE);
if (MidnightControlsCompat.isEMIPresent()) {
x = (int) (client.getWindow().getScaledWidth() * (1 / scale) - 55 - client.textRenderer.getWidth(new TranslatableText("midnightcontrols.action.pickup"))
* (1 / scale) - client.textRenderer.getWidth(new TranslatableText("midnightcontrols.action.quick_move"))
- MidnightControlsRenderer.getBindingIconWidth(ButtonBinding.TAKE) - MidnightControlsRenderer.getBindingIconWidth(ButtonBinding.QUICK_MOVE));
}
if (!ButtonBinding.TAKE.isNotBound()) x = MidnightControlsRenderer.drawButtonTip(matrices, x, y, ButtonBinding.TAKE, true, client);
if (!ButtonBinding.QUICK_MOVE.isNotBound()) MidnightControlsRenderer.drawButtonTip(matrices, x, y, ButtonBinding.QUICK_MOVE, true, client);
x = MidnightControlsRenderer.drawButtonTip(matrices, x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_X}, "midnightcontrols.action.pickup", true, client);
MidnightControlsRenderer.drawButtonTip(matrices, x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_Y}, "midnightcontrols.action.quick_move", true, client);
matrices.pop();
}
}

View File

@@ -61,6 +61,7 @@ public abstract class MinecraftClientMixin {
@Shadow
private int itemUseCooldown;
@Shadow @Nullable public ClientWorld world;
private BlockPos midnightcontrols$lastTargetPos;
private Vec3d midnightcontrols$lastPos;
private Direction midnightcontrols$lastTargetSide;
@@ -100,19 +101,37 @@ public abstract class MinecraftClientMixin {
this.midnightcontrols$lastTargetSide = side;
}
// Removed front placing sprinting as way too cheaty.
// else if (this.player.isSprinting()) {
// hitResult = MidnightControlsClient.get().reacharound.getLastReacharoundResult();
// if (hitResult != null) {
// if (cooldown > 0)
// this.itemUseCooldown = 0;
// }
// }
else if (this.player.isSprinting()) {
hitResult = MidnightControlsClient.get().reacharound.getLastReacharoundResult();
if (hitResult != null) {
if (cooldown > 0)
this.itemUseCooldown = 0;
}
}
this.midnightcontrols$lastPos = this.player.getPos();
}
// Applied multiple times for smooth camera turning even on low FPS
@Inject(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;startTick()V", shift = At.Shift.BEFORE))
private void onPrePreRender(CallbackInfo ci) {
MidnightControlsClient.get().onRender((MinecraftClient) (Object) (this));
}
@Inject(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Recorder;startTick()V", shift = At.Shift.AFTER))
private void onPreRender(CallbackInfo ci) {
MidnightControlsClient.get().onRender((MinecraftClient) (Object) (this));
}
@Inject(method = "render", at = @At("HEAD"))
private void onRender(CallbackInfo ci) {
MidnightControlsClient.get().onRender((MinecraftClient) (Object) (this));
}
@Inject(method = "render", at = @At("TAIL"))
private void onPostRender(CallbackInfo ci) {
MidnightControlsClient.get().onRender((MinecraftClient) (Object) (this));
}
@Inject(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;endTick()V", shift = At.Shift.AFTER))
private void onPostPostRender(CallbackInfo ci) {
MidnightControlsClient.get().onRender((MinecraftClient) (Object) (this));
}
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/GameRenderer;render(FJZ)V", shift = At.Shift.AFTER))
private void renderVirtualCursor(boolean fullRender, CallbackInfo ci) {
MidnightControlsRenderer.renderVirtualCursor(new MatrixStack(), (MinecraftClient) (Object) this);
@@ -132,7 +151,7 @@ public abstract class MinecraftClientMixin {
hitResult = mod.reacharound.withSideForReacharound(hitResult, stackInHand);
int previousStackCount = stackInHand.getCount();
var result = this.interactionManager.interactBlock(this.player, hand, hitResult);
var result = this.interactionManager.interactBlock(this.player, world, hand, hitResult);
if (result.isAccepted()) {
if (result.shouldSwingHand()) {
this.player.swingHand(hand);

View File

@@ -9,8 +9,6 @@
package eu.midnightdust.midnightcontrols.client.mixin;
import com.mojang.blaze3d.systems.RenderSystem;
import eu.midnightdust.lib.util.MidnightColorUtil;
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
import net.minecraft.block.ShapeContext;
@@ -32,8 +30,6 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.awt.*;
/**
* Represents a mixin to WorldRenderer.
* <p>
@@ -53,7 +49,7 @@ public abstract class WorldRendererMixin {
private BufferBuilderStorage bufferBuilders;
@Shadow
public static void drawShapeOutline(MatrixStack matrixStack, VertexConsumer vertexConsumer, VoxelShape voxelShape, double d, double e, double f, float g, float h, float i, float j) {
private static void drawShapeOutline(MatrixStack matrixStack, VertexConsumer vertexConsumer, VoxelShape voxelShape, double d, double e, double f, float g, float h, float i, float j) {
}
@Inject(
@@ -90,20 +86,12 @@ public abstract class WorldRendererMixin {
var pos = camera.getPos();
var outlineShape = placementState.getOutlineShape(this.client.world, blockPos, ShapeContext.of(camera.getFocusedEntity()));
Color rgb = MidnightColorUtil.hex2Rgb(MidnightControlsConfig.reacharoundOutlineColorHex);
if (MidnightControlsConfig.reacharoundOutlineColorHex.isEmpty()) rgb = MidnightColorUtil.radialRainbow(1,1);
int[] color = MidnightControlsConfig.reacharoundOutlineColor;
RenderSystem.defaultBlendFunc();
RenderSystem.disableTexture();
RenderSystem.disableBlend();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
RenderSystem.setShaderColor(rgb.getRed(), rgb.getGreen(), rgb.getBlue(), MidnightControlsConfig.reacharoundOutlineColorAlpha);
matrices.push();
var vertexConsumer = this.bufferBuilders.getOutlineVertexConsumers().getBuffer(RenderLayer.getLines());
var vertexConsumer = this.bufferBuilders.getEntityVertexConsumers().getBuffer(RenderLayer.getLines());
drawShapeOutline(matrices, vertexConsumer, outlineShape,
(double) blockPos.getX() - pos.getX(), (double) blockPos.getY() - pos.getY(), (double) blockPos.getZ() - pos.getZ(),
rgb.getRed() / 255.f, rgb.getGreen() / 255.f, rgb.getBlue() / 255.f, MidnightControlsConfig.reacharoundOutlineColorAlpha / 255.f);
matrices.pop();
color[0] / 255.f, color[1] / 255.f, color[2] / 255.f, color[3] / 255.f);
}
}
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright © 2021 LambdAurora <aurora42lambda@gmail.com>
*
* This file is part of midnightcontrols.
*
* Licensed under the MIT license. For more information,
* see the LICENSE file.
*/
package eu.midnightdust.midnightcontrols.client.ring;
import com.electronwill.nightconfig.core.Config;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.util.math.MatrixStack;
import org.jetbrains.annotations.NotNull;
public class DummyRingAction extends RingAction {
public DummyRingAction(@NotNull Config config) {
super(config);
}
@Override
public @NotNull String getName() {
return "dummy";
}
@Override
public void onAction(@NotNull RingButtonMode mode) {
}
@Override
public void drawIcon(@NotNull MatrixStack matrices, @NotNull TextRenderer textRenderer, int x, int y, boolean hovered) {
drawCenteredText(matrices, textRenderer, this.getName(), x + 25, y + 25 - textRenderer.fontHeight / 2, 0xffffff);
}
}

View File

@@ -10,29 +10,24 @@
package eu.midnightdust.midnightcontrols.client.ring;
import com.electronwill.nightconfig.core.Config;
import eu.midnightdust.midnightcontrols.client.ButtonState;
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
import eu.midnightdust.midnightcontrols.client.util.KeyBindingAccessor;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.option.StickyKeyBinding;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.OrderedText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.function.Supplier;
public class ButtonBindingRingAction extends RingAction {
public class KeyBindingRingAction extends RingAction {
public static final Factory FACTORY = new Factory();
public final ButtonBinding binding;
public final KeyBinding binding;
public ButtonBindingRingAction(@NotNull ButtonBinding binding) {
super();
public KeyBindingRingAction(@NotNull Config config, @NotNull KeyBinding binding) {
super(config);
this.binding = binding;
}
@@ -43,19 +38,19 @@ public class ButtonBindingRingAction extends RingAction {
@Override
public void onAction(@NotNull RingButtonMode mode) {
binding.handle(MinecraftClient.getInstance(), 1.0f, ButtonState.PRESS);
if (binding.asKeyBinding().isPresent()) {
binding.asKeyBinding().get().setPressed(true);
((KeyBindingAccessor)binding.asKeyBinding().get()).midnightcontrols$press();
KeyBindingAccessor accessor = (KeyBindingAccessor) this.binding;
switch (mode) {
case PRESS, HOLD -> accessor.midnightcontrols$handlePressState(this.activated);
case TOGGLE -> {
accessor.midnightcontrols$handlePressState(!this.binding.isPressed());
this.activated = !this.binding.isPressed();
}
}
}
@Override
public void drawIcon(@NotNull MatrixStack matrices, @NotNull TextRenderer textRenderer, int x, int y, boolean hovered) {
List<OrderedText> lines = textRenderer.wrapLines(Text.translatable(this.getName()), MidnightRing.ELEMENT_SIZE);
for (int i = 0; i < lines.size(); ++i) {
drawCenteredTextWithShadow(matrices, textRenderer, lines.get(i), x + MidnightRing.ELEMENT_SIZE / 2, y + MidnightRing.ELEMENT_SIZE / 2 - textRenderer.fontHeight / 2 * (lines.size()-1) - textRenderer.fontHeight / 2 + textRenderer.fontHeight * i, 0xffffff);
}
drawCenteredText(matrices, textRenderer, new TranslatableText(this.getName()), x + 25, y + 25 - textRenderer.fontHeight / 2, 0xffffff);
}
protected static class Factory implements RingAction.Factory {

View File

@@ -9,12 +9,10 @@
package eu.midnightdust.midnightcontrols.client.ring;
import com.electronwill.nightconfig.core.Config;
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.util.math.MathHelper;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@@ -30,7 +28,7 @@ import java.util.Map;
* @since 1.4.0
*/
public final class MidnightRing {
public static final int ELEMENT_SIZE = 75;
public static final int ELEMENT_SIZE = 50;
private final Map<String, RingAction.Factory> actionFactories = new Object2ObjectOpenHashMap<>();
private final List<RingPage> pages = new ArrayList<>(Collections.singletonList(RingPage.DEFAULT));
@@ -43,7 +41,7 @@ public final class MidnightRing {
public void registerAction(@NotNull String name, @NotNull RingAction.Factory factory) {
if (this.actionFactories.containsKey(name)) {
this.mod.warn("Tried to register a ring action twice: \"" + name + "\".");
this.mod.warn("Tried to register twice a ring action: \"" + name + "\".");
return;
}
this.actionFactories.put(name, factory);
@@ -52,55 +50,18 @@ public final class MidnightRing {
/**
* Loads the ring from configuration.
*/
public void loadFromConfig() {
List<String> configBindings = MidnightControlsConfig.ringBindings;
if (configBindings != null) {
public void load() {
List<Config> configPages = null;
if (configPages != null) {
this.pages.clear();
int bindingIndex = 0;
for (int i = 0; i < MathHelper.ceil(configBindings.size() / 8f); ++i) {
this.pages.add(new RingPage(i+1 + " / " + MathHelper.ceil(configBindings.size() / 8f)));
}
for (String binding : configBindings) {
ButtonBinding buttonBinding = InputManager.getBinding(binding);
if (buttonBinding != null) {
RingPage page = this.pages.get(MathHelper.fastFloor(bindingIndex / 8f));
page.actions[bindingIndex - 8 * (MathHelper.fastFloor(bindingIndex / 8f))] = (new ButtonBindingRingAction(buttonBinding));
++bindingIndex;
}
for (var configPage : configPages) {
RingPage.parseRingPage(configPage).ifPresent(this.pages::add);
}
}
if (this.pages.isEmpty()) {
this.pages.add(RingPage.DEFAULT);
}
}
/**
* Loads the ring from all unbound keys.
*/
public void loadFromUnbound() {
List<ButtonBinding> unboundBindings = InputManager.getUnboundBindings();
if (unboundBindings != null) {
this.pages.clear();
int bindingIndex = 0;
for (int i = 0; i < MathHelper.ceil(unboundBindings.size() / 8f); ++i) {
this.pages.add(new RingPage(i+1 + " / " + MathHelper.ceil(unboundBindings.size() / 8f)));
}
for (ButtonBinding buttonBinding : unboundBindings) {
if (buttonBinding != null) {
RingPage page = this.pages.get(MathHelper.fastFloor(bindingIndex / 8f));
page.actions[bindingIndex - 8 * (MathHelper.fastFloor(bindingIndex / 8f))] = (new ButtonBindingRingAction(buttonBinding));
++bindingIndex;
}
}
}
if (this.pages.isEmpty()) {
this.pages.add(RingPage.DEFAULT);
}
}
public int getMaxPages() {
return this.pages.size();
}
public @NotNull RingPage getCurrentPage() {
if (this.currentPage >= this.pages.size())
@@ -109,13 +70,4 @@ public final class MidnightRing {
this.currentPage = 0;
return this.pages.get(this.currentPage);
}
public void cyclePage(boolean forwards) {
if (forwards) {
if (currentPage < pages.size()-1) ++currentPage;
else currentPage = 0;
} else {
if (currentPage > 0) --currentPage;
else currentPage = pages.size();
}
}
}

View File

@@ -15,6 +15,7 @@ import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.aperlambda.lambdacommon.utils.Nameable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -29,9 +30,11 @@ import java.util.function.Supplier;
* @since 1.4.0
*/
public abstract class RingAction extends DrawableHelper implements Nameable {
protected Config config;
protected boolean activated = false;
public RingAction() {
public RingAction(@NotNull Config config) {
this.config = config;
}
/**
@@ -40,7 +43,7 @@ public abstract class RingAction extends DrawableHelper implements Nameable {
* @return the text name
*/
public Text getTextName() {
return Text.translatable(this.getName());
return new TranslatableText(this.getName());
}
/**
@@ -60,8 +63,8 @@ public abstract class RingAction extends DrawableHelper implements Nameable {
public abstract void onAction(@NotNull RingButtonMode mode);
public void render(@NotNull MatrixStack matrices, @NotNull TextRenderer textRenderer, int x, int y, boolean hovered, int index) {
fill(matrices, x, y, x + MidnightRing.ELEMENT_SIZE, y + MidnightRing.ELEMENT_SIZE, hovered || RingPage.selected == index ? 0xbb777777 : 0xbb000000);
public void render(@NotNull MatrixStack matrices, @NotNull TextRenderer textRenderer, int x, int y, boolean hovered) {
fill(matrices, x, y, x + MidnightRing.ELEMENT_SIZE, y + MidnightRing.ELEMENT_SIZE, hovered ? 0xbb777777 : 0xbb000000);
drawIcon(matrices, textRenderer, x, y, hovered);
}

View File

@@ -10,6 +10,7 @@
package eu.midnightdust.midnightcontrols.client.ring;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.aperlambda.lambdacommon.utils.Nameable;
import org.jetbrains.annotations.NotNull;
@@ -30,7 +31,7 @@ public enum RingButtonMode implements Nameable {
RingButtonMode(@NotNull String name) {
this.name = name;
this.text = Text.translatable(this.getTranslationKey());
this.text = new TranslatableText(this.getTranslationKey());
}
/**

View File

@@ -11,8 +11,6 @@ package eu.midnightdust.midnightcontrols.client.ring;
import com.electronwill.nightconfig.core.Config;
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawableHelper;
@@ -35,14 +33,18 @@ public class RingPage extends DrawableHelper {
public static final RingPage DEFAULT = new RingPage("Default");
public final String name;
public static int selected = -1;
public RingAction[] actions = new RingAction[8];
private RingAction[] actions = new RingAction[8];
public RingPage(@NotNull String name) {
this.name = name;
for (int i = 0; i < 8; i++) {
this.actions[i] = null;
}
this.actions[0] = new DummyRingAction(null);
this.actions[1] = new KeyBindingRingAction(null, MidnightControlsClient.BINDING_LOOK_UP);
this.actions[2] = new KeyBindingRingAction(null, MidnightControlsClient.BINDING_LOOK_LEFT);
this.actions[3] = new KeyBindingRingAction(null, MidnightControlsClient.BINDING_LOOK_RIGHT);
this.actions[4] = new KeyBindingRingAction(null, MidnightControlsClient.BINDING_LOOK_DOWN);
}
/**
@@ -58,7 +60,6 @@ public class RingPage extends DrawableHelper {
public void render(@NotNull MatrixStack matrices, @NotNull TextRenderer textRenderer, int width, int height, int mouseX, int mouseY, float tickDelta) {
int centerX = width / 2;
int centerY = height / 2;
if (MidnightControlsClient.get().ring.getMaxPages() > 1) drawCenteredText(matrices, textRenderer, name, centerX, 5, 0xffffff);
int offset = MidnightRing.ELEMENT_SIZE + (MidnightRing.ELEMENT_SIZE / 2) + 5;
@@ -67,29 +68,29 @@ public class RingPage extends DrawableHelper {
for (int i = 0; i < 3; i++) {
var ringAction = this.actions[i];
if (ringAction != null)
ringAction.render(matrices, textRenderer, x, y, isHovered(x, y, mouseX, mouseY), i);
x += MidnightRing.ELEMENT_SIZE + 5;
ringAction.render(matrices, textRenderer, x, y, isHovered(x, y, mouseX, mouseY));
x += 55;
}
y += MidnightRing.ELEMENT_SIZE + 5;
y += 55;
x = centerX - offset;
for (int i = 3; i < 5; i++) {
var ringAction = this.actions[i];
if (ringAction != null)
ringAction.render(matrices, textRenderer, x, y, isHovered(x, y, mouseX, mouseY), i);
x += (MidnightRing.ELEMENT_SIZE + 5) * 2;
ringAction.render(matrices, textRenderer, x, y, isHovered(x, y, mouseX, mouseY));
x += 55 * 2;
}
y += MidnightRing.ELEMENT_SIZE + 5;
y += 55;
x = centerX - offset;
for (int i = 5; i < 8; i++) {
var ringAction = this.actions[i];
if (ringAction != null)
ringAction.render(matrices, textRenderer, x, y, isHovered(x, y, mouseX, mouseY), i);
x += MidnightRing.ELEMENT_SIZE + 5;
ringAction.render(matrices, textRenderer, x, y, isHovered(x, y, mouseX, mouseY));
x += 55;
}
}
private static boolean isHovered(int x, int y, int mouseX, int mouseY) {
return mouseX >= x && mouseY >= y && mouseX <= x + MidnightRing.ELEMENT_SIZE && mouseY <= y + MidnightRing.ELEMENT_SIZE && selected < 0;
return mouseX >= x && mouseY >= y && mouseX <= x + MidnightRing.ELEMENT_SIZE && mouseY <= y + MidnightRing.ELEMENT_SIZE;
}
/**
* Renders the ring page.
@@ -113,9 +114,9 @@ public class RingPage extends DrawableHelper {
ringAction.activate(RingButtonMode.PRESS);
return true;
}
x += MidnightRing.ELEMENT_SIZE + 5;
x += 55;
}
y += MidnightRing.ELEMENT_SIZE + 5;
y += 55;
x = centerX - offset;
for (int i = 3; i < 5; i++) {
var ringAction = this.actions[i];
@@ -123,9 +124,9 @@ public class RingPage extends DrawableHelper {
ringAction.activate(RingButtonMode.PRESS);
return true;
}
x += (MidnightRing.ELEMENT_SIZE + 5) * 2;
x += 55 * 2;
}
y += MidnightRing.ELEMENT_SIZE + 5;
y += 55;
x = centerX - offset;
for (int i = 5; i < 8; i++) {
var ringAction = this.actions[i];
@@ -133,8 +134,27 @@ public class RingPage extends DrawableHelper {
ringAction.activate(RingButtonMode.PRESS);
return true;
}
x += MidnightRing.ELEMENT_SIZE + 5;
x += 55;
}
return false;
}
/**
* Tries to parse a ring page configuration.
*
* @param config the configuration
* @return an optional ring page
*/
public static @NotNull Optional<RingPage> parseRingPage(@NotNull Config config) {
String name = config.get("name");
if (name == null)
return Optional.empty();
var page = new RingPage(name);
List<Config> actionConfigs = config.get("actions");
return Optional.of(page);
}
}

View File

@@ -4,11 +4,10 @@
"key.midnightcontrols.look_left": "Nach links schauen",
"key.midnightcontrols.look_right": "Nach rechts schauen",
"key.midnightcontrols.look_up": "Nach oben schauen",
"key.midnightcontrols.ring": "Öffne Ring mit ungebundenen Aktionen",
"key.midnightcontrols.ring": "Zeige Steuerungsring",
"midnightcontrols.action.attack": "Angreifen",
"midnightcontrols.action.back": "Zurück",
"midnightcontrols.action.chat": "Chat öffnen",
"midnightcontrols.action.controls_ring": "Öffne Ring mit ungebundenen Aktionen",
"midnightcontrols.action.drop_item": "Item droppen",
"midnightcontrols.action.exit": "Schließen",
"midnightcontrols.action.forward": "Vorwärts",
@@ -41,6 +40,8 @@
"midnightcontrols.action.zoom_in": "Zoom erhöhen",
"midnightcontrols.action.zoom_out": "Zoom verringern",
"midnightcontrols.action.zoom_reset": "Zoom zurücksetzen",
"midnightcontrols.action.key.emotecraft.fastchoose": "Emote Schnellauswahl",
"midnightcontrols.action.key.emotecraft.stop": "Emote stoppen",
"midnightcontrols.button.left_bumper": "Linke Schultertaste",
"midnightcontrols.button.right_bumper": "Rechte Schultertaste",
"midnightcontrols.button.back": "Zurück",
@@ -77,11 +78,16 @@
"midnightcontrols.controller.mappings.error.write": "Fehler beim Schreiben der Controller Mappings.",
"midnightcontrols.controller.mappings.updated": "Mappings aktualisiert!",
"midnightcontrols.controller_type.default": "Standard",
"midnightcontrols.controller_type.dualshock": "DualShock",
"midnightcontrols.controller_type.switch": "Switch",
"midnightcontrols.controller_type.xbox": "Xbox",
"midnightcontrols.controller_type.steam": "Steam",
"midnightcontrols.controller_type.ouya": "OUYA",
"midnightcontrols.controls_mode.default": "Tastatur/Maus",
"midnightcontrols.controls_mode.controller": "Controller",
"midnightcontrols.controls_mode.touchscreen": "Touchscreen (In Arbeit)",
"midnightcontrols.hud_side.left": "Links",
"midnightcontrols.hud_side.right": "Rechts",
"midnightcontrols.hud_side.left": "links",
"midnightcontrols.hud_side.right": "rechts",
"midnightcontrols.menu.analog_movement": "Analoge Bewegung",
"midnightcontrols.menu.auto_switch_mode": "Automatischer Wechsel",
"midnightcontrols.menu.controller": "Controller",
@@ -97,7 +103,7 @@
"midnightcontrols.menu.invert_right_x_axis": "X rechts umkehren",
"midnightcontrols.menu.invert_right_y_axis": "Y rechts umkehren",
"midnightcontrols.menu.keyboard_controls": "Tastatureinstellungen...",
"midnightcontrols.menu.left_dead_zone": "Tote Zone des linken Sticks",
"midnightcontrols.menu.left_dead_zone": "Linke tote Zone",
"midnightcontrols.menu.mappings.open_input_str": "Öffne den Controller-Mapping Editor",
"midnightcontrols.menu.max_left_x_value": "Maximalwert Linke X-Achse",
"midnightcontrols.menu.max_left_y_value": "Maximalwert Linke Y-Achse",
@@ -107,14 +113,14 @@
"midnightcontrols.menu.reacharound.horizontal": "Vorderes Blockplatzieren",
"midnightcontrols.menu.reacharound.vertical": "Vertikales Umgreifen",
"midnightcontrols.menu.reload_controller_mappings": "Controller-Mappings neuladen",
"midnightcontrols.menu.right_dead_zone": "Tote Zone des rechten Sticks",
"midnightcontrols.menu.right_dead_zone": "Rechte tote Zone",
"midnightcontrols.menu.rotation_speed": "Rotationsgeschwindigkeit (X-Achse)",
"midnightcontrols.menu.y_axis_rotation_speed": "Rotationsgeschwindigkeit (Y-Achse)",
"midnightcontrols.menu.separator.controller": "Controller",
"midnightcontrols.menu.separator.general": "Generell",
"midnightcontrols.menu.title": "MidnightControls - Einstellungen",
"midnightcontrols.menu.title.controller": "Controlleroptionen",
"midnightcontrols.menu.title.controller_controls": "Controller Aktionen",
"midnightcontrols.menu.title.controller_controls": "Controller Steuerung",
"midnightcontrols.menu.title.gameplay": "Gameplay Optionen",
"midnightcontrols.menu.title.general": "Generelle Optionen",
"midnightcontrols.menu.title.hud": "HUD Optionen",

View File

@@ -4,14 +4,13 @@
"key.midnightcontrols.look_left": "Look left",
"key.midnightcontrols.look_right": "Look right",
"key.midnightcontrols.look_up": "Look up",
"key.midnightcontrols.ring": "Open Unbound Keybind Ring",
"key.midnightcontrols.ring": "Show radial menu",
"midnightcontrols.action.attack": "Attack",
"midnightcontrols.action.back": "Back",
"midnightcontrols.action.chat": "Open Chat",
"midnightcontrols.action.controls_ring": "Open Unbound Keybind Ring",
"midnightcontrols.action.debug_screen": "Open Debug HUD (F3)",
"midnightcontrols.action.drop_item": "Drop Item",
"midnightcontrols.action.exit": "Exit Screen",
"midnightcontrols.action.exit": "Exit",
"midnightcontrols.action.forward": "Forward",
"midnightcontrols.action.hit": "Hit",
"midnightcontrols.action.hotbar_left": "Hotbar left",
@@ -81,7 +80,7 @@
"midnightcontrols.axis.right_x-": "Right X-",
"midnightcontrols.axis.right_y-": "Right Y-",
"midnightcontrols.button.unknown": "Unknown (%d)",
"midnightcontrols.controller.tutorial.title": "Play the game with a Controller!",
"midnightcontrols.controller.tutorial.title": "Play the game with a controller!",
"midnightcontrols.controller.tutorial.description": "Go to %s -> %s -> %s",
"midnightcontrols.controller.connected": "Controller %d connected.",
"midnightcontrols.controller.disconnected": "Controller %d disconnected.",
@@ -91,9 +90,9 @@
"midnightcontrols.controller.mappings.error.write": "Error while writing mappings to file.",
"midnightcontrols.controller.mappings.updated": "Updated mappings!",
"midnightcontrols.controller_type.default": "Default",
"midnightcontrols.controller_type.dualshock": "DualShock",
"midnightcontrols.controller_type.dualshock": "DualShock 4",
"midnightcontrols.controller_type.dualsense": "DualSense",
"midnightcontrols.controller_type.switch": "Switch/Wii Controller",
"midnightcontrols.controller_type.switch": "Switch (Pro) Controller",
"midnightcontrols.controller_type.xbox": "Xbox One/Series Controller",
"midnightcontrols.controller_type.xbox_360": "Xbox 360 Controller",
"midnightcontrols.controller_type.steam_controller": "Steam Controller",
@@ -136,7 +135,7 @@
"midnightcontrols.menu.separator.general": "General",
"midnightcontrols.menu.title": "MidnightControls - Settings",
"midnightcontrols.menu.title.controller": "Controller Options",
"midnightcontrols.menu.title.controller_controls": "Controller Bindings",
"midnightcontrols.menu.title.controller_controls": "Controls",
"midnightcontrols.menu.title.gameplay": "Gameplay Options",
"midnightcontrols.menu.title.general": "General Options",
"midnightcontrols.menu.title.hud": "HUD Options",
@@ -171,7 +170,7 @@
"midnightcontrols.tooltip.rotation_speed": "The camera's X Axis rotation speed in controller mode.",
"midnightcontrols.tooltip.y_axis_rotation_speed": "The camera's Y Axis rotation speed in controller mode.",
"midnightcontrols.tooltip.unfocused_input": "Allows controller input when the window is not focused.",
"midnightcontrols.tooltip.virtual_mouse": "Enables the virtual mouse, which is useful during splitscreen.",
"midnightcontrols.tooltip.virtual_mouse": "Enables the virtual mouse which is useful ie during splitscreen.",
"midnightcontrols.virtual_mouse.skin.default_light": "Default Light",
"midnightcontrols.virtual_mouse.skin.default_dark": "Default Dark",
"midnightcontrols.virtual_mouse.skin.second_light": "Second Light",

View File

@@ -64,8 +64,6 @@
"midnightcontrols.axis.right_x-": "Parem X-",
"midnightcontrols.axis.right_y-": "Parem Y-",
"midnightcontrols.button.unknown": "Teadmata (%d)",
"midnightcontrols.controller.tutorial.title": "Mängi mängu oma juhtpuldiga!",
"midnightcontrols.controller.tutorial.description": "Mine %s -> %s -> %s",
"midnightcontrols.controller.connected": "Mängupult %d ühendatud.",
"midnightcontrols.controller.disconnected": "Mängupult %d lahti ühendatud.",
"midnightcontrols.controller.mappings.1": "Mängupuldi vastenduste seadistamiseks palun kasuta %s",
@@ -77,7 +75,7 @@
"midnightcontrols.controls_mode.default": "klaviatuur/hiir",
"midnightcontrols.controls_mode.controller": "mängupult",
"midnightcontrols.controls_mode.touchscreen": "puuteekraan (arenduses)",
"midnightcontrols.controls_mode.touchscreen": "puuteekraan",
"midnightcontrols.hud_side.left": "vasak",
"midnightcontrols.hud_side.right": "parem",
"midnightcontrols.menu.analog_movement": "Analoogliikumine",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@@ -1,6 +1,6 @@
{
"pack": {
"pack_format": 9,
"pack_format": 8,
"description": "Makes controller tooltips use similar icons to Bedrock Edition"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -1,6 +1,6 @@
{
"pack": {
"pack_format": 9,
"description": "Makes controller icons look similar to Legacy Console Edit."
"pack_format": 8,
"description": "Makes controller tooltips use similar icons to Legacy Console Edition"
}
}