mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-13 07:15:10 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c53575d17 | ||
|
|
24f7054eff | ||
|
|
4669e446dc | ||
|
|
e676a37c7f |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,11 +1,13 @@
|
||||
#
|
||||
# LambdAurora's ignore file
|
||||
#
|
||||
# v0.12
|
||||
# v0.13
|
||||
|
||||
# JetBrains
|
||||
.idea/
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
## Intellij IDEA
|
||||
out/
|
||||
## CLion
|
||||
|
||||
@@ -21,12 +21,14 @@ This mod adds a controller support (and an experimental touchscreen support).
|
||||
- Touchscreen support (very experimental and buggy).
|
||||
- Keyboard controls to look around.
|
||||
- Toggleable on screen button indicator (like in Bedrock Edition).
|
||||
- Vertical reacharound.
|
||||
- Many Bedrock Edition features:
|
||||
- Toggleable fly drifting
|
||||
- Front block placing (be careful with this one)
|
||||
- New controls settings!
|
||||
- Many options in config to change to your liking.
|
||||
- Many controllers supported and in a simply way your own controller mappings.
|
||||
- An easy API for developers to add their own button bindings.
|
||||
|
||||
## 🎮 Supported Controllers:
|
||||
|
||||
|
||||
14
build.gradle
14
build.gradle
@@ -27,6 +27,20 @@ allprojects {
|
||||
classifier = "sources"
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
name = "GithubPackages"
|
||||
url = uri("https://maven.pkg.github.com/LambdAurora/LambdaControls")
|
||||
credentials {
|
||||
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
|
||||
password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
archivesBaseName = project.archives_base_name + "-core"
|
||||
@@ -15,3 +16,17 @@ java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
// add all the jars that should be included when publishing to maven
|
||||
artifact(jar) {
|
||||
builtBy jar
|
||||
}
|
||||
artifact(sourcesJar) {
|
||||
builtBy sourcesJar
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,14 +21,15 @@ import java.util.Optional;
|
||||
* Represents a feature.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.2.0
|
||||
* @version 1.3.2
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class LambdaControlsFeature implements Nameable
|
||||
{
|
||||
private static final List<LambdaControlsFeature> FEATURES = new ArrayList<>();
|
||||
public static final LambdaControlsFeature FRONT_BLOCK_PLACING = new LambdaControlsFeature("front_block_placing", true, false);
|
||||
public static final LambdaControlsFeature FAST_BLOCK_PLACING = new LambdaControlsFeature("fast_block_placing", true, true);
|
||||
private static final List<LambdaControlsFeature> FEATURES = new ArrayList<>();
|
||||
public static final LambdaControlsFeature FAST_BLOCK_PLACING = new LambdaControlsFeature("fast_block_placing", true, true);
|
||||
public static final LambdaControlsFeature FRONT_BLOCK_PLACING = new LambdaControlsFeature("front_block_placing", true, false);
|
||||
public static final LambdaControlsFeature VERTICAL_REACHAROUND = new LambdaControlsFeature("vertical_reacharound", true, false);
|
||||
|
||||
private final String key;
|
||||
private final boolean defaultAllowed;
|
||||
@@ -155,7 +156,8 @@ public class LambdaControlsFeature implements Nameable
|
||||
}
|
||||
|
||||
static {
|
||||
FEATURES.add(FRONT_BLOCK_PLACING);
|
||||
FEATURES.add(FAST_BLOCK_PLACING);
|
||||
FEATURES.add(FRONT_BLOCK_PLACING);
|
||||
FEATURES.add(VERTICAL_REACHAROUND);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ plugins {
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
version = "${project.mod_version}+${project.minecraft_version}"
|
||||
archivesBaseName = project.archives_base_name + "-fabric"
|
||||
|
||||
minecraft {
|
||||
@@ -47,8 +48,8 @@ dependencies {
|
||||
include "com.github.lambdaurora:spruceui:${project.spruceui_version}"
|
||||
|
||||
// Compatibility mods
|
||||
modCompile "io.github.joaoh1:okzoomer:2.1.0-beta.2"
|
||||
modCompile "me.shedaniel:RoughlyEnoughItems:3.4.5"
|
||||
modCompile "io.github.joaoh1:okzoomer:4.0.0-alpha.3.1.16.pre5"
|
||||
modCompile "me.shedaniel:RoughlyEnoughItems:4.5.5"
|
||||
|
||||
api project(":core")
|
||||
shadow project(":core")
|
||||
@@ -91,4 +92,20 @@ jar {
|
||||
}
|
||||
}
|
||||
|
||||
// configure the maven publication
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
// add all the jars that should be included when publishing to maven
|
||||
artifact(remapJar) {
|
||||
builtBy remapJar
|
||||
}
|
||||
artifact(sourcesJar) {
|
||||
builtBy remapSourcesJar
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn(":core:build")
|
||||
publish.dependsOn(":core:publish")
|
||||
|
||||
@@ -15,8 +15,9 @@ import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -28,7 +29,7 @@ import java.util.Optional;
|
||||
* Represents the LambdaControls mod.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.1.0
|
||||
* @version 1.3.0
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LambdaControls implements ModInitializer
|
||||
@@ -38,6 +39,8 @@ public class LambdaControls implements ModInitializer
|
||||
public static final Identifier FEATURE_CHANNEL = new Identifier(LambdaControlsConstants.FEATURE_CHANNEL.toString());
|
||||
public static final Identifier HELLO_CHANNEL = new Identifier(LambdaControlsConstants.HELLO_CHANNEL.toString());
|
||||
|
||||
public static final TranslatableText NOT_BOUND_TEXT = new TranslatableText("lambdacontrols.not_bound");
|
||||
|
||||
public final Logger logger = LogManager.getLogger("LambdaControls");
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,16 +16,17 @@ import me.lambdaurora.lambdacontrols.LambdaControlsFeature;
|
||||
import me.lambdaurora.lambdacontrols.client.compat.LambdaControlsCompat;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.Controller;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
||||
import me.lambdaurora.lambdacontrols.client.gui.LambdaControlsHud;
|
||||
import me.lambdaurora.lambdacontrols.client.gui.TouchscreenOverlay;
|
||||
import me.lambdaurora.spruceui.event.OpenScreenCallback;
|
||||
import me.lambdaurora.spruceui.hud.HudManager;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
|
||||
import net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry;
|
||||
import net.fabricmc.fabric.api.event.client.ClientTickCallback;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import net.minecraft.client.toast.SystemToast;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.text.LiteralText;
|
||||
@@ -38,25 +39,26 @@ import org.lwjgl.glfw.GLFW;
|
||||
* Represents the LambdaControls client mod.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.2.0
|
||||
* @version 1.3.2
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class LambdaControlsClient extends LambdaControls implements ClientModInitializer
|
||||
{
|
||||
private static LambdaControlsClient INSTANCE;
|
||||
public static final FabricKeyBinding BINDING_LOOK_UP = FabricKeyBinding.Builder.create(new Identifier(LambdaControlsConstants.NAMESPACE, "look_up"),
|
||||
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_8, "key.categories.movement").build();
|
||||
public static final FabricKeyBinding BINDING_LOOK_RIGHT = FabricKeyBinding.Builder.create(new Identifier(LambdaControlsConstants.NAMESPACE, "look_right"),
|
||||
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_6, "key.categories.movement").build();
|
||||
public static final FabricKeyBinding BINDING_LOOK_DOWN = FabricKeyBinding.Builder.create(new Identifier(LambdaControlsConstants.NAMESPACE, "look_down"),
|
||||
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_2, "key.categories.movement").build();
|
||||
public static final FabricKeyBinding BINDING_LOOK_LEFT = FabricKeyBinding.Builder.create(new Identifier(LambdaControlsConstants.NAMESPACE, "look_left"),
|
||||
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_4, "key.categories.movement").build();
|
||||
public static final KeyBinding BINDING_LOOK_UP = InputManager.makeKeyBinding(new Identifier(LambdaControlsConstants.NAMESPACE, "look_up"),
|
||||
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_8, "key.categories.movement");
|
||||
public static final KeyBinding BINDING_LOOK_RIGHT = InputManager.makeKeyBinding(new Identifier(LambdaControlsConstants.NAMESPACE, "look_right"),
|
||||
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_6, "key.categories.movement");
|
||||
public static final KeyBinding BINDING_LOOK_DOWN = InputManager.makeKeyBinding(new Identifier(LambdaControlsConstants.NAMESPACE, "look_down"),
|
||||
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_2, "key.categories.movement");
|
||||
public static final KeyBinding BINDING_LOOK_LEFT = InputManager.makeKeyBinding(new Identifier(LambdaControlsConstants.NAMESPACE, "look_left"),
|
||||
InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_4, "key.categories.movement");
|
||||
public static final Identifier CONTROLLER_BUTTONS = new Identifier(LambdaControlsConstants.NAMESPACE, "textures/gui/controller_buttons.png");
|
||||
public static final Identifier CONTROLLER_AXIS = new Identifier(LambdaControlsConstants.NAMESPACE, "textures/gui/controller_axis.png");
|
||||
public static final Identifier CURSOR_TEXTURE = new Identifier(LambdaControlsConstants.NAMESPACE, "textures/gui/cursor.png");
|
||||
public final LambdaControlsConfig config = new LambdaControlsConfig(this);
|
||||
public final LambdaInput input = new LambdaInput(this);
|
||||
public final LambdaReacharound reacharound = new LambdaReacharound();
|
||||
private LambdaControlsHud hud;
|
||||
private ControlsMode previousControlsMode;
|
||||
|
||||
@@ -64,10 +66,10 @@ public class LambdaControlsClient extends LambdaControls implements ClientModIni
|
||||
public void onInitializeClient()
|
||||
{
|
||||
INSTANCE = this;
|
||||
KeyBindingRegistry.INSTANCE.register(BINDING_LOOK_UP);
|
||||
KeyBindingRegistry.INSTANCE.register(BINDING_LOOK_RIGHT);
|
||||
KeyBindingRegistry.INSTANCE.register(BINDING_LOOK_DOWN);
|
||||
KeyBindingRegistry.INSTANCE.register(BINDING_LOOK_LEFT);
|
||||
KeyBindingHelper.registerKeyBinding(BINDING_LOOK_UP);
|
||||
KeyBindingHelper.registerKeyBinding(BINDING_LOOK_RIGHT);
|
||||
KeyBindingHelper.registerKeyBinding(BINDING_LOOK_DOWN);
|
||||
KeyBindingHelper.registerKeyBinding(BINDING_LOOK_LEFT);
|
||||
|
||||
ClientSidePacketRegistry.INSTANCE.register(CONTROLS_MODE_CHANNEL, (context, attachedData) -> context.getTaskQueue()
|
||||
.execute(() -> ClientSidePacketRegistry.INSTANCE.sendToServer(CONTROLS_MODE_CHANNEL, this.makeControlsModeBuffer(this.config.getControlsMode()))));
|
||||
@@ -77,7 +79,8 @@ public class LambdaControlsClient extends LambdaControls implements ClientModIni
|
||||
LambdaControlsFeature.fromName(name).ifPresent(feature -> context.getTaskQueue().execute(() -> feature.setAllowed(allowed)));
|
||||
});
|
||||
|
||||
ClientTickCallback.EVENT.register(this::onTick);
|
||||
ClientTickEvents.START_CLIENT_TICK.register(this.reacharound::tick);
|
||||
ClientTickEvents.END_CLIENT_TICK.register(this::onTick);
|
||||
|
||||
OpenScreenCallback.EVENT.register((client, screen) -> {
|
||||
if (screen == null && this.config.getControlsMode() == ControlsMode.TOUCHSCREEN) {
|
||||
|
||||
@@ -34,37 +34,39 @@ import static org.lwjgl.glfw.GLFW.GLFW_GAMEPAD_AXIS_LEFT_Y;
|
||||
public class LambdaControlsConfig
|
||||
{
|
||||
// General
|
||||
private static final ControlsMode DEFAULT_CONTROLS_MODE = ControlsMode.DEFAULT;
|
||||
private static final boolean DEFAULT_AUTO_SWITCH_MODE = false;
|
||||
private static final ControlsMode DEFAULT_CONTROLS_MODE = ControlsMode.DEFAULT;
|
||||
private static final boolean DEFAULT_AUTO_SWITCH_MODE = false;
|
||||
// HUD
|
||||
private static final boolean DEFAULT_HUD_ENABLE = true;
|
||||
private static final HudSide DEFAULT_HUD_SIDE = HudSide.LEFT;
|
||||
private static final boolean DEFAULT_HUD_ENABLE = true;
|
||||
private static final HudSide DEFAULT_HUD_SIDE = HudSide.LEFT;
|
||||
// Gameplay
|
||||
private static final boolean DEFAULT_FAST_BLOCK_INTERACTION = true;
|
||||
private static final boolean DEFAULT_FLY_DRIFTING = false;
|
||||
private static final boolean DEFAULT_FLY_VERTICAL_DRIFTING = true;
|
||||
private static final boolean DEFAULT_FRONT_BLOCK_PLACING = false;
|
||||
private static final boolean DEFAULT_FRONT_BLOCK_OUTLINE = true;
|
||||
private static final boolean DEFAULT_FAST_BLOCK_INTERACTION = true;
|
||||
private static final boolean DEFAULT_FLY_DRIFTING = false;
|
||||
private static final boolean DEFAULT_FLY_VERTICAL_DRIFTING = true;
|
||||
private static final boolean DEFAULT_FRONT_BLOCK_PLACING = false;
|
||||
private static final boolean DEFAULT_VERTICAL_REACHAROUND = false;
|
||||
private static final boolean DEFAULT_REACHAROUND_OUTLINE = true;
|
||||
private static final int[] DEFAULT_REACHAROUND_OUTLINE_COLOR = new int[]{255, 255, 255, 102};
|
||||
// Controller
|
||||
private static final ControllerType DEFAULT_CONTROLLER_TYPE = ControllerType.DEFAULT;
|
||||
private static final double DEFAULT_DEAD_ZONE = 0.25;
|
||||
private static final double DEFAULT_ROTATION_SPEED = 40.0;
|
||||
private static final double DEFAULT_MOUSE_SPEED = 25.0;
|
||||
private static final boolean DEFAULT_UNFOCUSED_INPUT = false;
|
||||
private static final boolean DEFAULT_VIRTUAL_MOUSE = false;
|
||||
private static final VirtualMouseSkin DEFAULT_VIRTUAL_MOUSE_SKIN = VirtualMouseSkin.DEFAULT_LIGHT;
|
||||
private static final ControllerType DEFAULT_CONTROLLER_TYPE = ControllerType.DEFAULT;
|
||||
private static final double DEFAULT_DEAD_ZONE = 0.25;
|
||||
private static final double DEFAULT_ROTATION_SPEED = 40.0;
|
||||
private static final double DEFAULT_MOUSE_SPEED = 25.0;
|
||||
private static final boolean DEFAULT_UNFOCUSED_INPUT = false;
|
||||
private static final boolean DEFAULT_VIRTUAL_MOUSE = false;
|
||||
private static final VirtualMouseSkin DEFAULT_VIRTUAL_MOUSE_SKIN = VirtualMouseSkin.DEFAULT_LIGHT;
|
||||
|
||||
private static final Pattern BUTTON_BINDING_PATTERN = Pattern.compile("(-?\\d+)\\+?");
|
||||
|
||||
protected final FileConfig config = FileConfig.builder("config/lambdacontrols.toml").concurrent().defaultResource("/config.toml").build();
|
||||
private final LambdaControlsClient mod;
|
||||
private ControlsMode controlsMode;
|
||||
private ControllerType controllerType;
|
||||
private ControllerType controllerType;
|
||||
// Gameplay.
|
||||
private boolean shouldRenderFrontBlockOutline;
|
||||
private int[] frontBlockOutlineColor;
|
||||
private boolean shouldRenderReacharoundOutline;
|
||||
private int[] reacharoundOutlineColor;
|
||||
// Controller settings
|
||||
private double deadZone;
|
||||
private double deadZone;
|
||||
private double rotationSpeed;
|
||||
private double mouseSpeed;
|
||||
private boolean unfocusedInput;
|
||||
@@ -93,9 +95,10 @@ public class LambdaControlsConfig
|
||||
this.hudSide = HudSide.byId(this.config.getOrElse("hud.side", DEFAULT_HUD_SIDE.getName())).orElse(DEFAULT_HUD_SIDE);
|
||||
// Gameplay
|
||||
LambdaControlsFeature.FAST_BLOCK_PLACING.setEnabled(this.config.getOrElse("gameplay.fast_block_placing", DEFAULT_FAST_BLOCK_INTERACTION));
|
||||
LambdaControlsFeature.FRONT_BLOCK_PLACING.setEnabled(this.config.getOrElse("gameplay.front_block_placing.enabled", DEFAULT_FRONT_BLOCK_PLACING));
|
||||
this.shouldRenderFrontBlockOutline = this.config.getOrElse("gameplay.front_block_placing.outline", DEFAULT_FRONT_BLOCK_OUTLINE);
|
||||
this.frontBlockOutlineColor = this.config.getOptional("gameplay.front_block_placing.outline_color").map(hex -> parseColor((String) hex)).orElse(new int[]{255, 255, 255, 102});
|
||||
LambdaControlsFeature.FRONT_BLOCK_PLACING.setEnabled(this.config.getOrElse("gameplay.reacharound.horizontal", DEFAULT_FRONT_BLOCK_PLACING));
|
||||
LambdaControlsFeature.VERTICAL_REACHAROUND.setEnabled(this.config.getOrElse("gameplay.reacharound.vertical", DEFAULT_VERTICAL_REACHAROUND));
|
||||
this.shouldRenderReacharoundOutline = this.config.getOrElse("gameplay.reacharound.outline", DEFAULT_REACHAROUND_OUTLINE);
|
||||
this.reacharoundOutlineColor = this.config.getOptional("gameplay.reacharound.outline_color").map(hex -> parseColor((String) hex)).orElse(DEFAULT_REACHAROUND_OUTLINE_COLOR);
|
||||
// Controller settings.
|
||||
this.controllerType = ControllerType.byId(this.config.getOrElse("controller.type", DEFAULT_CONTROLLER_TYPE.getName())).orElse(DEFAULT_CONTROLLER_TYPE);
|
||||
this.deadZone = this.config.getOrElse("controller.dead_zone", DEFAULT_DEAD_ZONE);
|
||||
@@ -133,10 +136,19 @@ public class LambdaControlsConfig
|
||||
}
|
||||
});
|
||||
|
||||
// This shouldn't happen if the configuration is new.
|
||||
if (!this.config.contains("gameplay.front_block_placing.enabled") && this.config.contains("gameplay.front_block_placing")) {
|
||||
this.config.remove("gameplay.front_block_placing");
|
||||
this.config.set("gameplay.front_block_placing.enabled", DEFAULT_FRONT_BLOCK_PLACING);
|
||||
if (this.config.contains("gameplay.front_block_placing.enabled")) {
|
||||
this.setFrontBlockPlacing(this.config.getOrElse("gameplay.front_block_placing.enabled", DEFAULT_FRONT_BLOCK_PLACING));
|
||||
this.config.remove("gameplay.front_block_placing.enabled");
|
||||
}
|
||||
|
||||
if (this.config.contains("gameplay.front_block_placing.outline")) {
|
||||
this.setRenderReacharoundOutline(this.config.getOrElse("gameplay.front_block_placing.outline", DEFAULT_REACHAROUND_OUTLINE));
|
||||
this.config.remove("gameplay.front_block_placing.outline");
|
||||
}
|
||||
|
||||
if (this.config.contains("gameplay.front_block_placing.outline_color")) {
|
||||
this.config.getOptional("gameplay.front_block_placing.outline_color").ifPresent(color -> this.config.set("gameplay.reacharound.outline_color", color));
|
||||
this.config.remove("gameplay.front_block_placing.outline_color");
|
||||
}
|
||||
|
||||
this.renamed("controller.controls.tab_left", "controller.controls.tab_back");
|
||||
@@ -165,7 +177,8 @@ public class LambdaControlsConfig
|
||||
this.setFlyDrifting(DEFAULT_FLY_DRIFTING);
|
||||
this.setFlyVerticalDrifting(DEFAULT_FLY_VERTICAL_DRIFTING);
|
||||
this.setFrontBlockPlacing(DEFAULT_FRONT_BLOCK_PLACING);
|
||||
this.setRenderFrontBlockOutline(DEFAULT_FRONT_BLOCK_OUTLINE);
|
||||
this.setVerticalReacharound(DEFAULT_VERTICAL_REACHAROUND);
|
||||
this.setRenderReacharoundOutline(DEFAULT_REACHAROUND_OUTLINE);
|
||||
// Controller
|
||||
this.setControllerType(DEFAULT_CONTROLLER_TYPE);
|
||||
this.setDeadZone(DEFAULT_DEAD_ZONE);
|
||||
@@ -352,7 +365,28 @@ public class LambdaControlsConfig
|
||||
public void setFrontBlockPlacing(boolean enable)
|
||||
{
|
||||
LambdaControlsFeature.FRONT_BLOCK_PLACING.setEnabled(enable);
|
||||
this.config.set("gameplay.front_block_placing.enabled", enable);
|
||||
this.config.set("gameplay.reacharound.horizontal", enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether vertical reacharound is enabled or not.
|
||||
*
|
||||
* @return True if vertical reacharound is enabled, else false.
|
||||
*/
|
||||
public boolean hasVerticalReacharound()
|
||||
{
|
||||
return LambdaControlsFeature.VERTICAL_REACHAROUND.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether vertical reacharound is enabled or not.
|
||||
*
|
||||
* @param enable True if vertical reacharound is enabled, else false.
|
||||
*/
|
||||
public void setVerticalReacharound(boolean enable)
|
||||
{
|
||||
LambdaControlsFeature.VERTICAL_REACHAROUND.setEnabled(enable);
|
||||
this.config.set("gameplay.reacharound.vertical", enable);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -360,9 +394,9 @@ public class LambdaControlsConfig
|
||||
*
|
||||
* @return True if front block placing outline is enabled, else false.
|
||||
*/
|
||||
public boolean shouldRenderFrontBlockOutline()
|
||||
public boolean shouldRenderReacharoundOutline()
|
||||
{
|
||||
return this.shouldRenderFrontBlockOutline;
|
||||
return this.shouldRenderReacharoundOutline;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -370,9 +404,9 @@ public class LambdaControlsConfig
|
||||
*
|
||||
* @param render True if front block placing outline is enabled, else false.
|
||||
*/
|
||||
public void setRenderFrontBlockOutline(boolean render)
|
||||
public void setRenderReacharoundOutline(boolean render)
|
||||
{
|
||||
this.config.set("gameplay.front_block_placing.outline", this.shouldRenderFrontBlockOutline = render);
|
||||
this.config.set("gameplay.reacharound.outline", this.shouldRenderReacharoundOutline = render);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -382,9 +416,9 @@ public class LambdaControlsConfig
|
||||
*
|
||||
* @return The color as a RGBA integer array.
|
||||
*/
|
||||
public int[] getFrontBlockOutlineColor()
|
||||
public int[] getReacharoundOutlineColor()
|
||||
{
|
||||
return this.frontBlockOutlineColor;
|
||||
return this.reacharoundOutlineColor;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -18,17 +18,11 @@ import me.lambdaurora.lambdacontrols.client.gui.LambdaControlsSettingsScreen;
|
||||
* Represents the API implementation of ModMenu for LambdaControls.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.2.0
|
||||
* @version 1.3.0
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class LambdaControlsModMenu implements ModMenuApi
|
||||
{
|
||||
@Override
|
||||
public String getModId()
|
||||
{
|
||||
return LambdaControlsConstants.NAMESPACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory()
|
||||
{
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client;
|
||||
|
||||
import me.lambdaurora.lambdacontrols.LambdaControlsFeature;
|
||||
import me.lambdaurora.lambdacontrols.client.compat.LambdaControlsCompat;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.Controller;
|
||||
@@ -19,36 +18,27 @@ import me.lambdaurora.lambdacontrols.client.gui.TouchscreenOverlay;
|
||||
import me.lambdaurora.lambdacontrols.client.mixin.AdvancementsScreenAccessor;
|
||||
import me.lambdaurora.lambdacontrols.client.mixin.CreativeInventoryScreenAccessor;
|
||||
import me.lambdaurora.lambdacontrols.client.mixin.EntryListWidgetAccessor;
|
||||
import me.lambdaurora.lambdacontrols.client.util.ContainerScreenAccessor;
|
||||
import me.lambdaurora.lambdacontrols.client.util.HandledScreenAccessor;
|
||||
import me.lambdaurora.lambdacontrols.client.util.MouseAccessor;
|
||||
import me.lambdaurora.spruceui.SpruceLabelWidget;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FluidBlock;
|
||||
import net.minecraft.block.SlabBlock;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.ParentElement;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.advancement.AdvancementTab;
|
||||
import net.minecraft.client.gui.screen.advancement.AdvancementsScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.ContainerScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
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.AbstractPressableButtonWidget;
|
||||
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
|
||||
import net.minecraft.client.gui.widget.EntryListWidget;
|
||||
import net.minecraft.client.gui.widget.SliderWidget;
|
||||
import net.minecraft.container.Slot;
|
||||
import net.minecraft.container.SlotActionType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.screen.slot.SlotActionType;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import org.aperlambda.lambdacommon.utils.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -71,24 +61,24 @@ import static org.lwjgl.glfw.GLFW.*;
|
||||
* Represents the LambdaControls' input handler.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.2.0
|
||||
* @version 1.3.2
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LambdaInput
|
||||
{
|
||||
private static final Map<Integer, Integer> BUTTON_COOLDOWNS = new HashMap<>();
|
||||
private static final Map<Integer, Integer> BUTTON_COOLDOWNS = new HashMap<>();
|
||||
private final LambdaControlsConfig config;
|
||||
// Cooldowns
|
||||
private int actionGuiCooldown = 0;
|
||||
private int ignoreNextA = 0;
|
||||
private double targetYaw = 0.0;
|
||||
private double targetPitch = 0.0;
|
||||
private float prevXAxis = 0.F;
|
||||
private float prevYAxis = 0.F;
|
||||
private int targetMouseX = 0;
|
||||
private int targetMouseY = 0;
|
||||
private float mouseSpeedX = 0.F;
|
||||
private float mouseSpeedY = 0.F;
|
||||
private int actionGuiCooldown = 0;
|
||||
private boolean ignoreNextARelease = false;
|
||||
private double targetYaw = 0.0;
|
||||
private double targetPitch = 0.0;
|
||||
private float prevXAxis = 0.F;
|
||||
private float prevYAxis = 0.F;
|
||||
private int targetMouseX = 0;
|
||||
private int targetMouseY = 0;
|
||||
private float mouseSpeedX = 0.F;
|
||||
private float mouseSpeedY = 0.F;
|
||||
|
||||
public LambdaInput(@NotNull LambdaControlsClient mod)
|
||||
{
|
||||
@@ -155,9 +145,6 @@ public class LambdaInput
|
||||
if (allowInput)
|
||||
InputManager.updateBindings(client);
|
||||
|
||||
if (this.ignoreNextA > 0)
|
||||
this.ignoreNextA--;
|
||||
|
||||
if (client.currentScreen instanceof ControllerControlsScreen && InputManager.STATES.entrySet().parallelStream().map(Map.Entry::getValue).allMatch(ButtonState::isUnpressed)) {
|
||||
ControllerControlsScreen screen = (ControllerControlsScreen) client.currentScreen;
|
||||
if (screen.focusedBinding != null && !screen.waiting) {
|
||||
@@ -320,50 +307,96 @@ public class LambdaInput
|
||||
}
|
||||
}
|
||||
|
||||
if (client.currentScreen instanceof ContainerScreen && client.interactionManager != null && client.player != null) {
|
||||
double x = client.mouse.getX() * (double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth();
|
||||
double y = client.mouse.getY() * (double) client.getWindow().getScaledHeight() / (double) client.getWindow().getHeight();
|
||||
Slot slot = ((ContainerScreenAccessor) client.currentScreen).lambdacontrols_getSlotAt(x, y);
|
||||
SlotActionType slotAction = SlotActionType.PICKUP;
|
||||
if (button == GLFW.GLFW_GAMEPAD_BUTTON_A && slot != null) {
|
||||
if (client.currentScreen instanceof CreativeInventoryScreen) {
|
||||
if (((CreativeInventoryScreenAccessor) client.currentScreen).lambdacontrols_isCreativeInventorySlot(slot))
|
||||
slotAction = SlotActionType.CLONE;
|
||||
}
|
||||
client.interactionManager.clickSlot(((ContainerScreen) client.currentScreen).getContainer().syncId, slot.id, GLFW.GLFW_MOUSE_BUTTON_1, slotAction, client.player);
|
||||
client.player.playerContainer.sendContentUpdates();
|
||||
this.actionGuiCooldown = 5;
|
||||
return;
|
||||
} else if (button == GLFW.GLFW_GAMEPAD_BUTTON_B) {
|
||||
client.player.closeContainer();
|
||||
return;
|
||||
} else if (button == GLFW.GLFW_GAMEPAD_BUTTON_X && slot != null) {
|
||||
client.interactionManager.clickSlot(((ContainerScreen) client.currentScreen).getContainer().syncId, slot.id, GLFW.GLFW_MOUSE_BUTTON_2, SlotActionType.PICKUP, client.player);
|
||||
return;
|
||||
} else if (button == GLFW.GLFW_GAMEPAD_BUTTON_Y && slot != null) {
|
||||
client.interactionManager.clickSlot(((ContainerScreen) client.currentScreen).getContainer().syncId, slot.id, GLFW.GLFW_MOUSE_BUTTON_1, SlotActionType.QUICK_MOVE, client.player);
|
||||
return;
|
||||
}
|
||||
} else if (button == GLFW.GLFW_GAMEPAD_BUTTON_B) {
|
||||
if (this.handleInventory(client, button)) {
|
||||
this.ignoreNextARelease = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (button == GLFW.GLFW_GAMEPAD_BUTTON_B) {
|
||||
if (client.currentScreen != null) {
|
||||
client.currentScreen.onClose();
|
||||
if (!LambdaControlsCompat.handleMenuBack(client, client.currentScreen))
|
||||
client.currentScreen.onClose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (button == GLFW.GLFW_GAMEPAD_BUTTON_A && client.currentScreen != null && !isScreenInteractive(client.currentScreen) && this.actionGuiCooldown == 0 && this.ignoreNextA == 0) {
|
||||
double mouseX = client.mouse.getX() * (double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth();
|
||||
double mouseY = client.mouse.getY() * (double) client.getWindow().getScaledHeight() / (double) client.getWindow().getHeight();
|
||||
if (action == 0) {
|
||||
client.currentScreen.mouseClicked(mouseX, mouseY, GLFW.GLFW_MOUSE_BUTTON_1);
|
||||
} else if (action == 1) {
|
||||
client.currentScreen.mouseReleased(mouseX, mouseY, GLFW.GLFW_MOUSE_BUTTON_1);
|
||||
if (button == GLFW.GLFW_GAMEPAD_BUTTON_A && client.currentScreen != null && !isScreenInteractive(client.currentScreen) && this.actionGuiCooldown == 0) {
|
||||
if (!this.ignoreNextARelease) {
|
||||
double mouseX = client.mouse.getX() * (double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth();
|
||||
double mouseY = client.mouse.getY() * (double) client.getWindow().getScaledHeight() / (double) client.getWindow().getHeight();
|
||||
if (action == 0) {
|
||||
client.currentScreen.mouseClicked(mouseX, mouseY, GLFW.GLFW_MOUSE_BUTTON_1);
|
||||
} else if (action == 1) {
|
||||
client.currentScreen.mouseReleased(mouseX, mouseY, GLFW.GLFW_MOUSE_BUTTON_1);
|
||||
}
|
||||
this.actionGuiCooldown = 5;
|
||||
} else {
|
||||
this.ignoreNextARelease = false;
|
||||
}
|
||||
this.actionGuiCooldown = 5;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles inventory interaction.
|
||||
*
|
||||
* @param client The client instance.
|
||||
* @param button The button pressed.
|
||||
* @return True if an inventory interaction was done.
|
||||
*/
|
||||
private boolean handleInventory(@NotNull MinecraftClient client, int button)
|
||||
{
|
||||
if (!(client.currentScreen instanceof HandledScreen))
|
||||
return false;
|
||||
|
||||
if (client.interactionManager == null || client.player == null)
|
||||
return false;
|
||||
|
||||
if (button == GLFW.GLFW_GAMEPAD_BUTTON_B) {
|
||||
client.player.closeHandledScreen();
|
||||
return true;
|
||||
}
|
||||
|
||||
double x = client.mouse.getX() * (double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth();
|
||||
double y = client.mouse.getY() * (double) client.getWindow().getScaledHeight() / (double) client.getWindow().getHeight();
|
||||
|
||||
HandledScreen screen = (HandledScreen) client.currentScreen;
|
||||
HandledScreenAccessor accessor = (HandledScreenAccessor) screen;
|
||||
Slot slot = ((HandledScreenAccessor) client.currentScreen).lambdacontrols_getSlotAt(x, y);
|
||||
|
||||
int slotId;
|
||||
if (slot == null) {
|
||||
if (client.player.inventory.getCursorStack().isEmpty())
|
||||
return false;
|
||||
slotId = accessor.lambdacontrols_isClickOutsideBounds(x, y, accessor.getX(), accessor.getY(), GLFW_MOUSE_BUTTON_1) ? -999 : -1;
|
||||
} else {
|
||||
slotId = slot.id;
|
||||
}
|
||||
|
||||
SlotActionType actionType = SlotActionType.PICKUP;
|
||||
int clickData = GLFW.GLFW_MOUSE_BUTTON_1;
|
||||
switch (button) {
|
||||
case GLFW_GAMEPAD_BUTTON_A:
|
||||
if (screen instanceof CreativeInventoryScreen)
|
||||
if (((CreativeInventoryScreenAccessor) screen).lambdacontrols_isCreativeInventorySlot(slot))
|
||||
actionType = SlotActionType.CLONE;
|
||||
if (slot != null && LambdaControlsCompat.streamCompatHandlers().anyMatch(handler -> handler.isCreativeSlot(screen, slot)))
|
||||
actionType = SlotActionType.CLONE;
|
||||
break;
|
||||
case GLFW.GLFW_GAMEPAD_BUTTON_X:
|
||||
clickData = GLFW_MOUSE_BUTTON_2;
|
||||
break;
|
||||
case GLFW.GLFW_GAMEPAD_BUTTON_Y:
|
||||
actionType = SlotActionType.QUICK_MOVE;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
accessor.lambdacontrols_onMouseClick(slot, slotId, clickData, actionType);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void handleAxe(@NotNull MinecraftClient client, int axis, float value, float absValue, int state)
|
||||
{
|
||||
int asButtonState = value > 0.5F ? 1 : (value < -0.5F ? 2 : 0);
|
||||
@@ -562,7 +595,7 @@ public class LambdaInput
|
||||
this.actionGuiCooldown = 2; // Prevent to press too quickly the focused element, so we have to skip 5 ticks.
|
||||
return false;
|
||||
} else if (element instanceof AlwaysSelectedEntryListWidget) {
|
||||
((EntryListWidgetAccessor) element).lambdacontrols_moveSelection(right ? 1 : -1);
|
||||
((EntryListWidgetAccessor) element).lambdacontrols_moveSelection(right ? EntryListWidget.class_5403.field_25661 : EntryListWidget.class_5403.field_25662);
|
||||
return false;
|
||||
} else if (element instanceof ParentElement) {
|
||||
ParentElement entryList = (ParentElement) element;
|
||||
@@ -620,26 +653,26 @@ public class LambdaInput
|
||||
|
||||
public static boolean isScreenInteractive(@NotNull Screen screen)
|
||||
{
|
||||
return !(screen instanceof AdvancementsScreen || screen instanceof ContainerScreen || LambdaControlsCompat.requireMouseOnScreen(screen));
|
||||
return !(screen instanceof AdvancementsScreen || screen instanceof HandledScreen || LambdaControlsCompat.requireMouseOnScreen(screen));
|
||||
}
|
||||
|
||||
// Inspired from https://github.com/MrCrayfish/Controllable/blob/1.14.X/src/main/java/com/mrcrayfish/controllable/client/ControllerInput.java#L686.
|
||||
private void moveMouseToClosestSlot(@NotNull MinecraftClient client, @Nullable Screen screen)
|
||||
{
|
||||
// Makes the mouse attracted to slots. This helps with selecting items when using a controller.
|
||||
if (screen instanceof ContainerScreen) {
|
||||
ContainerScreen inventoryScreen = (ContainerScreen) screen;
|
||||
ContainerScreenAccessor accessor = (ContainerScreenAccessor) inventoryScreen;
|
||||
if (screen instanceof HandledScreen) {
|
||||
HandledScreen inventoryScreen = (HandledScreen) screen;
|
||||
HandledScreenAccessor accessor = (HandledScreenAccessor) inventoryScreen;
|
||||
int guiLeft = accessor.getX();
|
||||
int guiTop = accessor.getY();
|
||||
int mouseX = (int) (targetMouseX * (double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth());
|
||||
int mouseY = (int) (targetMouseY * (double) client.getWindow().getScaledHeight() / (double) client.getWindow().getHeight());
|
||||
|
||||
// Finds the closest slot in the GUI within 14 pixels.
|
||||
Optional<Pair<Slot, Double>> closestSlot = inventoryScreen.getContainer().slots.parallelStream()
|
||||
Optional<Pair<Slot, Double>> closestSlot = inventoryScreen.getScreenHandler().slots.parallelStream()
|
||||
.map(slot -> {
|
||||
int x = guiLeft + slot.xPosition + 8;
|
||||
int y = guiTop + slot.yPosition + 8;
|
||||
int x = guiLeft + slot.x + 8;
|
||||
int y = guiTop + slot.y + 8;
|
||||
|
||||
// Distance between the slot and the cursor.
|
||||
double distance = Math.sqrt(Math.pow(x - mouseX, 2) + Math.pow(y - mouseY, 2));
|
||||
@@ -650,8 +683,8 @@ public class LambdaInput
|
||||
if (closestSlot.isPresent()) {
|
||||
Slot slot = closestSlot.get().key;
|
||||
if (slot.hasStack() || !client.player.inventory.getMainHandStack().isEmpty()) {
|
||||
int slotCenterXScaled = guiLeft + slot.xPosition + 8;
|
||||
int slotCenterYScaled = guiTop + slot.yPosition + 8;
|
||||
int slotCenterXScaled = guiLeft + slot.x + 8;
|
||||
int slotCenterYScaled = guiTop + slot.y + 8;
|
||||
int slotCenterX = (int) (slotCenterXScaled / ((double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth()));
|
||||
int slotCenterY = (int) (slotCenterYScaled / ((double) client.getWindow().getScaledHeight() / (double) client.getWindow().getHeight()));
|
||||
double deltaX = slotCenterX - targetMouseX;
|
||||
@@ -679,71 +712,4 @@ public class LambdaInput
|
||||
this.mouseSpeedY = 0.F;
|
||||
}
|
||||
}
|
||||
|
||||
public static Direction getMoveDirection(@Nullable BlockPos lastPos, @NotNull BlockPos newPos)
|
||||
{
|
||||
if (lastPos == null)
|
||||
return null;
|
||||
BlockPos vector = newPos.subtract(lastPos);
|
||||
if (vector.getX() > 0)
|
||||
return Direction.EAST;
|
||||
else if (vector.getX() < 0)
|
||||
return Direction.WEST;
|
||||
else if (vector.getZ() > 0)
|
||||
return Direction.SOUTH;
|
||||
else if (vector.getZ() < 0)
|
||||
return Direction.NORTH;
|
||||
else if (vector.getY() > 0)
|
||||
return Direction.UP;
|
||||
else if (vector.getY() < 0)
|
||||
return Direction.DOWN;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a nullable block hit result if front placing is possible.
|
||||
*
|
||||
* @param client The client instance.
|
||||
* @return A block hit result if front placing is possible.
|
||||
*/
|
||||
public static @Nullable BlockHitResult tryFrontPlace(@NotNull MinecraftClient client)
|
||||
{
|
||||
if (!LambdaControlsFeature.FRONT_BLOCK_PLACING.isAvailable())
|
||||
return null;
|
||||
if (client.player != null && client.crosshairTarget != null && client.crosshairTarget.getType() == HitResult.Type.MISS && client.player.onGround && client.player.pitch > 35.0F) {
|
||||
if (client.player.isRiding())
|
||||
return null;
|
||||
BlockPos playerPos = client.player.getBlockPos().down();
|
||||
BlockPos targetPos = new BlockPos(client.crosshairTarget.getPos()).subtract(playerPos);
|
||||
BlockPos vector = new BlockPos(MathHelper.clamp(targetPos.getX(), -1, 1), 0, MathHelper.clamp(targetPos.getZ(), -1, 1));
|
||||
BlockPos blockPos = playerPos.add(vector);
|
||||
|
||||
Direction direction = client.player.getHorizontalFacing();
|
||||
|
||||
BlockState state = client.world.getBlockState(blockPos);
|
||||
if (!state.isAir())
|
||||
return null;
|
||||
BlockState adjacentBlockState = client.world.getBlockState(blockPos.offset(direction.getOpposite()));
|
||||
if (adjacentBlockState.isAir() || adjacentBlockState.getBlock() instanceof FluidBlock || (vector.getX() == 0 && vector.getZ() == 0)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new BlockHitResult(client.crosshairTarget.getPos(), direction, blockPos, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static @NotNull BlockHitResult withSideForFrontPlace(@NotNull BlockHitResult result, @Nullable ItemStack stack)
|
||||
{
|
||||
if (stack == null || stack.isEmpty() || !(stack.getItem() instanceof BlockItem))
|
||||
return result;
|
||||
return withSideForFrontPlace(result, Block.getBlockFromItem(stack.getItem()));
|
||||
}
|
||||
|
||||
public static @NotNull BlockHitResult withSideForFrontPlace(@NotNull BlockHitResult result, @NotNull Block block)
|
||||
{
|
||||
if (block instanceof SlabBlock)
|
||||
result = result.withSide(Direction.DOWN);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright © 2020 LambdAurora <aurora42lambda@gmail.com>
|
||||
*
|
||||
* This file is part of LambdaControls.
|
||||
*
|
||||
* Licensed under the MIT license. For more information,
|
||||
* see the LICENSE file.
|
||||
*/
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client;
|
||||
|
||||
import me.lambdaurora.lambdacontrols.LambdaControlsFeature;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FluidBlock;
|
||||
import net.minecraft.block.SlabBlock;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.RayTraceContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents the reacharound API of LambdaControls.
|
||||
*
|
||||
* @version 1.3.2
|
||||
* @since 1.3.2
|
||||
*/
|
||||
public class LambdaReacharound
|
||||
{
|
||||
private BlockHitResult lastReacharoundResult = null;
|
||||
private boolean lastReacharoundVertical = false;
|
||||
|
||||
public void tick(@NotNull MinecraftClient client)
|
||||
{
|
||||
this.lastReacharoundResult = this.tryVerticalReachAround(client);
|
||||
if (this.lastReacharoundResult == null) {
|
||||
this.lastReacharoundResult = this.tryFrontPlace(client);
|
||||
this.lastReacharoundVertical = false;
|
||||
} else this.lastReacharoundVertical = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last reach around result.
|
||||
*
|
||||
* @return The last reach around result.
|
||||
*/
|
||||
public @Nullable BlockHitResult getLastReacharoundResult()
|
||||
{
|
||||
return this.lastReacharoundResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the last reach around is vertical.
|
||||
*
|
||||
* @return True if the reach around is vertical.
|
||||
*/
|
||||
public boolean isLastReacharoundVertical()
|
||||
{
|
||||
return this.lastReacharoundVertical;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether reacharound is available or not.
|
||||
*
|
||||
* @return True if reacharound is available, else false.
|
||||
*/
|
||||
public boolean isReacharoundAvailable()
|
||||
{
|
||||
return LambdaControlsFeature.FRONT_BLOCK_PLACING.isAvailable() || LambdaControlsFeature.VERTICAL_REACHAROUND.isAvailable();
|
||||
}
|
||||
|
||||
private float getPlayerRange(@NotNull MinecraftClient client)
|
||||
{
|
||||
return client.interactionManager != null ? client.interactionManager.getReachDistance() : 0.f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a nullable block hit result if vertical reacharound is possible.
|
||||
*
|
||||
* @param client The client instance.
|
||||
* @return A block hit result if vertical reacharound is possible, else null.
|
||||
*/
|
||||
public @Nullable BlockHitResult tryVerticalReachAround(@NotNull MinecraftClient client)
|
||||
{
|
||||
if (!LambdaControlsFeature.VERTICAL_REACHAROUND.isAvailable())
|
||||
return null;
|
||||
if (client.player == null || client.world == null || client.crosshairTarget == null || client.crosshairTarget.getType() != HitResult.Type.MISS
|
||||
|| !client.player.isOnGround() || client.player.pitch < 80.0F
|
||||
|| client.player.isRiding())
|
||||
return null;
|
||||
|
||||
Vec3d pos = client.player.getCameraPosVec(1.0F);
|
||||
Vec3d rotationVec = client.player.getRotationVec(1.0F);
|
||||
float range = getPlayerRange(client);
|
||||
Vec3d rayVec = pos.add(rotationVec.x * range, rotationVec.y * range, rotationVec.z * range).add(0, 0.75, 0);
|
||||
BlockHitResult result = client.world.rayTrace(new RayTraceContext(pos, rayVec, RayTraceContext.ShapeType.OUTLINE, RayTraceContext.FluidHandling.NONE, client.player));
|
||||
|
||||
if (result.getType() == HitResult.Type.BLOCK) {
|
||||
BlockPos blockPos = result.getBlockPos().down();
|
||||
BlockState state = client.world.getBlockState(blockPos);
|
||||
|
||||
if (client.player.getBlockPos().getY() - blockPos.getY() > 1 && (client.world.isAir(blockPos) || state.getMaterial().isReplaceable())) {
|
||||
return new BlockHitResult(result.getPos(), Direction.DOWN, blockPos, false);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a nullable block hit result if front placing is possible.
|
||||
*
|
||||
* @param client The client instance.
|
||||
* @return A block hit result if front placing is possible.
|
||||
*/
|
||||
public @Nullable BlockHitResult tryFrontPlace(@NotNull MinecraftClient client)
|
||||
{
|
||||
if (!LambdaControlsFeature.FRONT_BLOCK_PLACING.isAvailable())
|
||||
return null;
|
||||
if (client.player != null && client.crosshairTarget != null && client.crosshairTarget.getType() == HitResult.Type.MISS && client.player.isOnGround() && client.player.pitch > 35.0F) {
|
||||
if (client.player.isRiding())
|
||||
return null;
|
||||
BlockPos playerPos = client.player.getBlockPos().down();
|
||||
BlockPos targetPos = new BlockPos(client.crosshairTarget.getPos()).subtract(playerPos);
|
||||
BlockPos vector = new BlockPos(MathHelper.clamp(targetPos.getX(), -1, 1), 0, MathHelper.clamp(targetPos.getZ(), -1, 1));
|
||||
BlockPos blockPos = playerPos.add(vector);
|
||||
|
||||
Direction direction = client.player.getHorizontalFacing();
|
||||
|
||||
BlockState state = client.world.getBlockState(blockPos);
|
||||
if (!state.isAir())
|
||||
return null;
|
||||
BlockState adjacentBlockState = client.world.getBlockState(blockPos.offset(direction.getOpposite()));
|
||||
if (adjacentBlockState.isAir() || adjacentBlockState.getBlock() instanceof FluidBlock || (vector.getX() == 0 && vector.getZ() == 0)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new BlockHitResult(client.crosshairTarget.getPos(), direction, blockPos, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static @NotNull BlockHitResult withSideForReacharound(@NotNull BlockHitResult result, @Nullable ItemStack stack)
|
||||
{
|
||||
if (stack == null || stack.isEmpty() || !(stack.getItem() instanceof BlockItem))
|
||||
return result;
|
||||
return withSideForReacharound(result, Block.getBlockFromItem(stack.getItem()));
|
||||
}
|
||||
|
||||
public static @NotNull BlockHitResult withSideForReacharound(@NotNull BlockHitResult result, @NotNull Block block)
|
||||
{
|
||||
if (block instanceof SlabBlock)
|
||||
result = result.withSide(Direction.DOWN);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -10,14 +10,20 @@
|
||||
package me.lambdaurora.lambdacontrols.client.compat;
|
||||
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a compatibility handler for a mod.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.2.0
|
||||
* @version 1.3.2
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface CompatHandler
|
||||
@@ -33,10 +39,58 @@ public interface CompatHandler
|
||||
* Returns whether the mouse is required on the specified screen.
|
||||
*
|
||||
* @param screen The screen.
|
||||
* @return True if the mouse is requried on the specified screen, else false.
|
||||
* @return True if the mouse is required on the specified screen, else false.
|
||||
*/
|
||||
default boolean requireMouseOnScreen(Screen screen)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the current slot is a creative slot or not.
|
||||
*
|
||||
* @param screen The screen.
|
||||
* @param slot The slot to check.
|
||||
* @return True if the slot is a creative slot, else false.
|
||||
*/
|
||||
default boolean isCreativeSlot(@NotNull HandledScreen screen, @NotNull Slot slot)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a custom translation key to make custom attack action strings on the HUD.
|
||||
*
|
||||
* @param client The client instance.
|
||||
* @param placeResult The last place block result.
|
||||
* @return Null if untouched, else a translation key.
|
||||
*/
|
||||
default String getAttackActionAt(@NotNull MinecraftClient client, @Nullable BlockHitResult placeResult)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a custom translation key to make custom use action strings on the HUD.
|
||||
*
|
||||
* @param client The client instance.
|
||||
* @param placeResult The last place block result.
|
||||
* @return Null if untouched, else a translation key.
|
||||
*/
|
||||
default String getUseActionAt(@NotNull MinecraftClient client, @Nullable BlockHitResult placeResult)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the menu back button.
|
||||
*
|
||||
* @param client The client instance.
|
||||
* @param screen The screen.
|
||||
* @return True if the handle was fired and succeed, else false.
|
||||
*/
|
||||
default boolean handleMenuBack(@NotNull MinecraftClient client, @NotNull Screen screen)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright © 2020 LambdAurora <aurora42lambda@gmail.com>
|
||||
*
|
||||
* This file is part of LambdaControls.
|
||||
*
|
||||
* Licensed under the MIT license. For more information,
|
||||
* see the LICENSE file.
|
||||
*/
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client.compat;
|
||||
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import org.aperlambda.lambdacommon.utils.LambdaReflection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Represents HQM compatibility handler.
|
||||
*
|
||||
* This is bad.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.3.2
|
||||
* @since 1.3.2
|
||||
*/
|
||||
public class HQMCompat implements CompatHandler
|
||||
{
|
||||
public static final String GUI_BASE_CLASS_PATH = "hardcorequesting.client.interfaces.GuiBase";
|
||||
private Optional<Class<?>> guiBaseClass;
|
||||
|
||||
@Override
|
||||
public void handle(@NotNull LambdaControlsClient mod)
|
||||
{
|
||||
this.guiBaseClass = LambdaReflection.getClass(GUI_BASE_CLASS_PATH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requireMouseOnScreen(Screen screen)
|
||||
{
|
||||
return this.guiBaseClass.map(clazz -> clazz.isInstance(screen)).orElse(false);
|
||||
}
|
||||
}
|
||||
@@ -12,18 +12,23 @@ package me.lambdaurora.lambdacontrols.client.compat;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import org.aperlambda.lambdacommon.utils.LambdaReflection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Represents a compatibility handler.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.1.0
|
||||
* @version 1.3.2
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class LambdaControlsCompat
|
||||
@@ -45,10 +50,34 @@ public class LambdaControlsCompat
|
||||
mod.log("Adding REI compatiblity...");
|
||||
HANDLERS.add(new ReiCompat());
|
||||
}
|
||||
if (FabricLoader.getInstance().isModLoaded("hardcorequesting") && LambdaReflection.doesClassExist(HQMCompat.GUI_BASE_CLASS_PATH)) {
|
||||
mod.log("Adding HQM compatibility...");
|
||||
HANDLERS.add(new HQMCompat());
|
||||
}
|
||||
HANDLERS.forEach(handler -> handler.handle(mod));
|
||||
InputManager.loadButtonBindings(mod.config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new compatibility handler.
|
||||
*
|
||||
* @param handler The compatibility handler to register.
|
||||
*/
|
||||
public static void registerCompatHandler(@NotNull CompatHandler handler)
|
||||
{
|
||||
HANDLERS.add(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams through compatibility handlers.
|
||||
*
|
||||
* @return A stream of compatibility handlers.
|
||||
*/
|
||||
public static Stream<CompatHandler> streamCompatHandlers()
|
||||
{
|
||||
return HANDLERS.stream();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the mouse is required on the specified screen.
|
||||
*
|
||||
@@ -60,6 +89,57 @@ public class LambdaControlsCompat
|
||||
return HANDLERS.stream().anyMatch(handler -> handler.requireMouseOnScreen(screen));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a custom translation key to make custom attack action strings on the HUD.
|
||||
*
|
||||
* @param client The client instance.
|
||||
* @param placeResult The last place block result.
|
||||
* @return Null if untouched, else a translation key.
|
||||
*/
|
||||
public static String getAttackActionAt(@NotNull MinecraftClient client, @Nullable BlockHitResult placeResult)
|
||||
{
|
||||
for (CompatHandler handler : HANDLERS) {
|
||||
String action = handler.getAttackActionAt(client, placeResult);
|
||||
if (action != null) {
|
||||
return action;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a custom translation key to make custom use action strings on the HUD.
|
||||
*
|
||||
* @param client The client instance.
|
||||
* @param placeResult The last place block result.
|
||||
* @return Null if untouched, else a translation key.
|
||||
*/
|
||||
public static String getUseActionAt(@NotNull MinecraftClient client, @Nullable BlockHitResult placeResult)
|
||||
{
|
||||
for (CompatHandler handler : HANDLERS) {
|
||||
String action = handler.getUseActionAt(client, placeResult);
|
||||
if (action != null) {
|
||||
return action;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the menu back button.
|
||||
*
|
||||
* @param client The client instance.
|
||||
* @param screen The screen.
|
||||
* @return True if the handle was fired and succeed, else false.
|
||||
*/
|
||||
public static boolean handleMenuBack(@NotNull MinecraftClient client, @NotNull Screen screen) {
|
||||
for (CompatHandler handler : HANDLERS) {
|
||||
if (handler.handleMenuBack(client, screen))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether Roughly Enough Items is present.
|
||||
*
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client.compat;
|
||||
|
||||
import io.github.joaoh1.okzoomer.OkZoomer;
|
||||
import io.github.joaoh1.okzoomer.client.OkZoomerClientMod;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -19,12 +19,12 @@ import org.lwjgl.glfw.GLFW;
|
||||
* Represents a compatibility handler for OkZoomer.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.1.0
|
||||
* @version 1.3.0
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class OkZoomerCompat implements CompatHandler
|
||||
{
|
||||
public static final String OKZOOMER_CLASS_PATH = "io.github.joaoh1.okzoomer.OkZoomer";
|
||||
public static final String OKZOOMER_CLASS_PATH = "io.github.joaoh1.okzoomer.client.OkZoomerClientMod";
|
||||
|
||||
@Override
|
||||
public void handle(@NotNull LambdaControlsClient mod)
|
||||
@@ -34,7 +34,7 @@ public class OkZoomerCompat implements CompatHandler
|
||||
.onlyInGame()
|
||||
.cooldown(true)
|
||||
.category(ButtonBinding.MISC_CATEGORY)
|
||||
.linkKeybind(OkZoomer.zoomKeyBinding)
|
||||
.linkKeybind(OkZoomerClientMod.zoomKeyBinding)
|
||||
.register();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,14 @@ import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.InputHandlers;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.PressAction;
|
||||
import me.shedaniel.rei.api.REIHelper;
|
||||
import me.shedaniel.rei.api.RecipeCategory;
|
||||
import me.shedaniel.rei.gui.ContainerScreenOverlay;
|
||||
import me.shedaniel.rei.gui.RecipeViewingScreen;
|
||||
import me.shedaniel.rei.gui.VillagerRecipeViewingScreen;
|
||||
import me.shedaniel.rei.gui.widget.EntryListWidget;
|
||||
import me.shedaniel.rei.impl.ScreenHelper;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.aperlambda.lambdacommon.utils.LambdaReflection;
|
||||
@@ -37,13 +39,12 @@ import static org.lwjgl.glfw.GLFW.*;
|
||||
* Represents a compatibility handler for REI.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.2.0
|
||||
* @version 1.3.2
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public class ReiCompat implements CompatHandler
|
||||
{
|
||||
private static EntryListWidget ENTRY_LIST_WIDGET;
|
||||
public static ButtonBinding TAB_BACK;
|
||||
|
||||
@Override
|
||||
public void handle(@NotNull LambdaControlsClient mod)
|
||||
@@ -106,6 +107,17 @@ public class ReiCompat implements CompatHandler
|
||||
return screen instanceof RecipeViewingScreen || screen instanceof VillagerRecipeViewingScreen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMenuBack(@NotNull MinecraftClient client, @NotNull Screen screen)
|
||||
{
|
||||
if (!isViewingScreen(screen))
|
||||
return false;
|
||||
|
||||
MinecraftClient.getInstance().openScreen(REIHelper.getInstance().getPreviousContainerScreen());
|
||||
ScreenHelper.getLastOverlay().init();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static EntryListWidget getEntryListWidget()
|
||||
{
|
||||
if (ENTRY_LIST_WIDGET == null) {
|
||||
@@ -155,9 +167,9 @@ public class ReiCompat implements CompatHandler
|
||||
if (client.currentScreen instanceof RecipeViewingScreen) {
|
||||
RecipeViewingScreenAccessor screen = (RecipeViewingScreenAccessor) client.currentScreen;
|
||||
if (next)
|
||||
screen.getCategoryNext().onPressed();
|
||||
screen.getCategoryNext().onClick();
|
||||
else
|
||||
screen.getCategoryBack().onPressed();
|
||||
screen.getCategoryBack().onClick();
|
||||
return true;
|
||||
} else if (client.currentScreen instanceof VillagerRecipeViewingScreen) {
|
||||
VillagerRecipeViewingScreenAccessor screen = (VillagerRecipeViewingScreenAccessor) client.currentScreen;
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client.compat.mixin;
|
||||
|
||||
import me.shedaniel.rei.api.widgets.Button;
|
||||
import me.shedaniel.rei.gui.RecipeViewingScreen;
|
||||
import me.shedaniel.rei.gui.widget.ButtonWidget;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@@ -18,15 +18,15 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
* Represents an accessor to REI's RecipeViewingScreen.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.2.0
|
||||
* @version 1.3.0
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@Mixin(RecipeViewingScreen.class)
|
||||
public interface RecipeViewingScreenAccessor
|
||||
{
|
||||
@Accessor("categoryBack")
|
||||
ButtonWidget getCategoryBack();
|
||||
Button getCategoryBack();
|
||||
|
||||
@Accessor("categoryNext")
|
||||
ButtonWidget getCategoryNext();
|
||||
Button getCategoryNext();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.options.GameOptions;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import org.aperlambda.lambdacommon.Identifier;
|
||||
import org.aperlambda.lambdacommon.utils.Nameable;
|
||||
import org.aperlambda.lambdacommon.utils.function.PairPredicate;
|
||||
@@ -31,7 +33,7 @@ import static org.lwjgl.glfw.GLFW.*;
|
||||
* Represents a button binding.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.1.0
|
||||
* @version 1.3.0
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class ButtonBinding implements Nameable
|
||||
@@ -320,64 +322,63 @@ public class ButtonBinding implements Nameable
|
||||
* @param button The button.
|
||||
* @return The localized name of the button.
|
||||
*/
|
||||
public static @NotNull
|
||||
String getLocalizedButtonName(int button)
|
||||
public static @NotNull Text getLocalizedButtonName(int button)
|
||||
{
|
||||
switch (button % 500) {
|
||||
case -1:
|
||||
return I18n.translate("key.keyboard.unknown");
|
||||
return new TranslatableText("key.keyboard.unknown");
|
||||
case GLFW_GAMEPAD_BUTTON_A:
|
||||
return I18n.translate("lambdacontrols.button.a");
|
||||
return new TranslatableText("lambdacontrols.button.a");
|
||||
case GLFW_GAMEPAD_BUTTON_B:
|
||||
return I18n.translate("lambdacontrols.button.b");
|
||||
return new TranslatableText("lambdacontrols.button.b");
|
||||
case GLFW_GAMEPAD_BUTTON_X:
|
||||
return I18n.translate("lambdacontrols.button.x");
|
||||
return new TranslatableText("lambdacontrols.button.x");
|
||||
case GLFW_GAMEPAD_BUTTON_Y:
|
||||
return I18n.translate("lambdacontrols.button.y");
|
||||
return new TranslatableText("lambdacontrols.button.y");
|
||||
case GLFW_GAMEPAD_BUTTON_LEFT_BUMPER:
|
||||
return I18n.translate("lambdacontrols.button.left_bumper");
|
||||
return new TranslatableText("lambdacontrols.button.left_bumper");
|
||||
case GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER:
|
||||
return I18n.translate("lambdacontrols.button.right_bumper");
|
||||
return new TranslatableText("lambdacontrols.button.right_bumper");
|
||||
case GLFW_GAMEPAD_BUTTON_BACK:
|
||||
return I18n.translate("lambdacontrols.button.back");
|
||||
return new TranslatableText("lambdacontrols.button.back");
|
||||
case GLFW_GAMEPAD_BUTTON_START:
|
||||
return I18n.translate("lambdacontrols.button.start");
|
||||
return new TranslatableText("lambdacontrols.button.start");
|
||||
case GLFW_GAMEPAD_BUTTON_GUIDE:
|
||||
return I18n.translate("lambdacontrols.button.guide");
|
||||
return new TranslatableText("lambdacontrols.button.guide");
|
||||
case GLFW_GAMEPAD_BUTTON_LEFT_THUMB:
|
||||
return I18n.translate("lambdacontrols.button.left_thumb");
|
||||
return new TranslatableText("lambdacontrols.button.left_thumb");
|
||||
case GLFW_GAMEPAD_BUTTON_RIGHT_THUMB:
|
||||
return I18n.translate("lambdacontrols.button.right_thumb");
|
||||
return new TranslatableText("lambdacontrols.button.right_thumb");
|
||||
case GLFW_GAMEPAD_BUTTON_DPAD_UP:
|
||||
return I18n.translate("lambdacontrols.button.dpad_up");
|
||||
return new TranslatableText("lambdacontrols.button.dpad_up");
|
||||
case GLFW_GAMEPAD_BUTTON_DPAD_RIGHT:
|
||||
return I18n.translate("lambdacontrols.button.dpad_right");
|
||||
return new TranslatableText("lambdacontrols.button.dpad_right");
|
||||
case GLFW_GAMEPAD_BUTTON_DPAD_DOWN:
|
||||
return I18n.translate("lambdacontrols.button.dpad_down");
|
||||
return new TranslatableText("lambdacontrols.button.dpad_down");
|
||||
case GLFW_GAMEPAD_BUTTON_DPAD_LEFT:
|
||||
return I18n.translate("lambdacontrols.button.dpad_left");
|
||||
return new TranslatableText("lambdacontrols.button.dpad_left");
|
||||
case 100:
|
||||
return I18n.translate("lambdacontrols.axis.left_x+");
|
||||
return new TranslatableText("lambdacontrols.axis.left_x+");
|
||||
case 101:
|
||||
return I18n.translate("lambdacontrols.axis.left_y+");
|
||||
return new TranslatableText("lambdacontrols.axis.left_y+");
|
||||
case 102:
|
||||
return I18n.translate("lambdacontrols.axis.right_x+");
|
||||
return new TranslatableText("lambdacontrols.axis.right_x+");
|
||||
case 103:
|
||||
return I18n.translate("lambdacontrols.axis.right_y+");
|
||||
return new TranslatableText("lambdacontrols.axis.right_y+");
|
||||
case 104:
|
||||
return I18n.translate("lambdacontrols.axis.left_trigger");
|
||||
return new TranslatableText("lambdacontrols.axis.left_trigger");
|
||||
case 105:
|
||||
return I18n.translate("lambdacontrols.axis.right_trigger");
|
||||
return new TranslatableText("lambdacontrols.axis.right_trigger");
|
||||
case 200:
|
||||
return I18n.translate("lambdacontrols.axis.left_x-");
|
||||
return new TranslatableText("lambdacontrols.axis.left_x-");
|
||||
case 201:
|
||||
return I18n.translate("lambdacontrols.axis.left_y-");
|
||||
return new TranslatableText("lambdacontrols.axis.left_y-");
|
||||
case 202:
|
||||
return I18n.translate("lambdacontrols.axis.right_x-");
|
||||
return new TranslatableText("lambdacontrols.axis.right_x-");
|
||||
case 203:
|
||||
return I18n.translate("lambdacontrols.axis.right_y-");
|
||||
return new TranslatableText("lambdacontrols.axis.right_y-");
|
||||
default:
|
||||
return I18n.translate("lambdacontrols.button.unknown", button);
|
||||
return new TranslatableText("lambdacontrols.button.unknown", button);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,18 +13,18 @@ import me.lambdaurora.lambdacontrols.client.ButtonState;
|
||||
import me.lambdaurora.lambdacontrols.client.mixin.AdvancementsScreenAccessor;
|
||||
import me.lambdaurora.lambdacontrols.client.mixin.CreativeInventoryScreenAccessor;
|
||||
import me.lambdaurora.lambdacontrols.client.mixin.RecipeBookWidgetAccessor;
|
||||
import me.lambdaurora.lambdacontrols.client.util.ContainerScreenAccessor;
|
||||
import me.lambdaurora.lambdacontrols.client.util.HandledScreenAccessor;
|
||||
import me.lambdaurora.lambdacontrols.client.util.KeyBindingAccessor;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.advancement.AdvancementTab;
|
||||
import net.minecraft.client.gui.screen.advancement.AdvancementsScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.ContainerScreen;
|
||||
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.screen.recipebook.RecipeGroupButtonWidget;
|
||||
import net.minecraft.client.util.ScreenshotUtils;
|
||||
import net.minecraft.container.Slot;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import org.aperlambda.lambdacommon.utils.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -38,7 +38,7 @@ import java.util.stream.Collectors;
|
||||
* Represents some input handlers.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.2.0
|
||||
* @version 1.3.0
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class InputHandlers
|
||||
@@ -109,8 +109,8 @@ public class InputHandlers
|
||||
// If in game, then pause the game.
|
||||
if (client.currentScreen == null)
|
||||
client.openPauseMenu(false);
|
||||
else if (client.currentScreen instanceof ContainerScreen && client.player != null) // If the current screen is a container then close it.
|
||||
client.player.closeContainer();
|
||||
else if (client.currentScreen instanceof HandledScreen && client.player != null) // If the current screen is a container then close it.
|
||||
client.player.closeHandledScreen();
|
||||
else // Else just close the current screen.
|
||||
client.currentScreen.onClose();
|
||||
}
|
||||
@@ -145,11 +145,11 @@ public class InputHandlers
|
||||
public static PressAction handleInventorySlotPad(int direction)
|
||||
{
|
||||
return (client, binding, action) -> {
|
||||
if (!(client.currentScreen instanceof ContainerScreen && action != ButtonState.RELEASE))
|
||||
if (!(client.currentScreen instanceof HandledScreen && action != ButtonState.RELEASE))
|
||||
return false;
|
||||
|
||||
ContainerScreen inventory = (ContainerScreen) client.currentScreen;
|
||||
ContainerScreenAccessor accessor = (ContainerScreenAccessor) inventory;
|
||||
HandledScreen inventory = (HandledScreen) client.currentScreen;
|
||||
HandledScreenAccessor accessor = (HandledScreenAccessor) inventory;
|
||||
int guiLeft = accessor.getX();
|
||||
int guiTop = accessor.getY();
|
||||
double mouseX = client.mouse.getX() * (double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth();
|
||||
@@ -159,17 +159,17 @@ public class InputHandlers
|
||||
Slot mouseSlot = accessor.lambdacontrols_getSlotAt(mouseX, mouseY);
|
||||
|
||||
// Finds the closest slot in the GUI within 14 pixels.
|
||||
Optional<Slot> closestSlot = inventory.getContainer().slots.parallelStream()
|
||||
Optional<Slot> closestSlot = inventory.getScreenHandler().slots.parallelStream()
|
||||
.filter(Predicate.isEqual(mouseSlot).negate())
|
||||
.map(slot -> {
|
||||
int posX = guiLeft + slot.xPosition + 8;
|
||||
int posY = guiTop + slot.yPosition + 8;
|
||||
int posX = guiLeft + slot.x + 8;
|
||||
int posY = guiTop + slot.y + 8;
|
||||
|
||||
int otherPosX = (int) mouseX;
|
||||
int otherPosY = (int) mouseY;
|
||||
if (mouseSlot != null) {
|
||||
otherPosX = guiLeft + mouseSlot.xPosition + 8;
|
||||
otherPosY = guiTop + mouseSlot.yPosition + 8;
|
||||
otherPosX = guiLeft + mouseSlot.x + 8;
|
||||
otherPosY = guiTop + mouseSlot.y + 8;
|
||||
}
|
||||
|
||||
// Distance between the slot and the cursor.
|
||||
@@ -177,13 +177,13 @@ public class InputHandlers
|
||||
return Pair.of(slot, distance);
|
||||
}).filter(entry -> {
|
||||
Slot slot = entry.key;
|
||||
int posX = guiLeft + slot.xPosition + 8;
|
||||
int posY = guiTop + slot.yPosition + 8;
|
||||
int posX = guiLeft + slot.x + 8;
|
||||
int posY = guiTop + slot.y + 8;
|
||||
int otherPosX = (int) mouseX;
|
||||
int otherPosY = (int) mouseY;
|
||||
if (mouseSlot != null) {
|
||||
otherPosX = guiLeft + mouseSlot.xPosition + 8;
|
||||
otherPosY = guiTop + mouseSlot.yPosition + 8;
|
||||
otherPosX = guiLeft + mouseSlot.x + 8;
|
||||
otherPosY = guiTop + mouseSlot.y + 8;
|
||||
}
|
||||
if (direction == 0)
|
||||
return posY < otherPosY;
|
||||
@@ -201,8 +201,8 @@ public class InputHandlers
|
||||
|
||||
if (closestSlot.isPresent()) {
|
||||
Slot slot = closestSlot.get();
|
||||
int x = guiLeft + slot.xPosition + 8;
|
||||
int y = guiTop + slot.yPosition + 8;
|
||||
int x = guiLeft + slot.x + 8;
|
||||
int y = guiTop + slot.y + 8;
|
||||
InputManager.queueMousePosition(x * (double) client.getWindow().getWidth() / (double) client.getWindow().getScaledWidth(),
|
||||
y * (double) client.getWindow().getHeight() / (double) client.getWindow().getScaledHeight());
|
||||
return true;
|
||||
@@ -244,7 +244,7 @@ public class InputHandlers
|
||||
*/
|
||||
public static boolean inInventory(@NotNull MinecraftClient client, @NotNull ButtonBinding binding)
|
||||
{
|
||||
return client.currentScreen instanceof ContainerScreen;
|
||||
return client.currentScreen instanceof HandledScreen;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,8 @@ import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsConfig;
|
||||
import me.lambdaurora.lambdacontrols.client.util.MouseAccessor;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import org.aperlambda.lambdacommon.Identifier;
|
||||
import org.aperlambda.lambdacommon.utils.function.PairPredicate;
|
||||
@@ -30,7 +32,7 @@ import java.util.stream.Stream;
|
||||
* Represents an input manager for controllers.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.2.0
|
||||
* @version 1.3.0
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class InputManager
|
||||
@@ -358,4 +360,34 @@ public class InputManager
|
||||
{
|
||||
return CATEGORIES.stream();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new key binding instance.
|
||||
* @param id The identifier of the key binding.
|
||||
* @param type The type.
|
||||
* @param code The code.
|
||||
* @param category The category of the key binding.
|
||||
* @return The key binding.
|
||||
*
|
||||
* @see #makeKeyBinding(Identifier, InputUtil.Type, int, String)
|
||||
*/
|
||||
public static @NotNull KeyBinding makeKeyBinding(@NotNull net.minecraft.util.Identifier id, InputUtil.Type type, int code, @NotNull String category)
|
||||
{
|
||||
return makeKeyBinding(new Identifier(id.getNamespace(), id.getPath()), type, code, category);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new key binding instance.
|
||||
* @param id The identifier of the key binding.
|
||||
* @param type The type.
|
||||
* @param code The code.
|
||||
* @param category The category of the key binding.
|
||||
* @return The key binding.
|
||||
*
|
||||
* @see #makeKeyBinding(net.minecraft.util.Identifier, InputUtil.Type, int, String)
|
||||
*/
|
||||
public static @NotNull KeyBinding makeKeyBinding(@NotNull Identifier id, InputUtil.Type type, int code, @NotNull String category)
|
||||
{
|
||||
return new KeyBinding(String.format("key.%s.%s", id.getNamespace(), id.getName()), type, code, category);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,13 @@
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client.gui;
|
||||
|
||||
import me.lambdaurora.lambdacontrols.LambdaControls;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||
import me.lambdaurora.spruceui.AbstractIconButtonWidget;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
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 org.aperlambda.lambdacommon.utils.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -33,25 +36,25 @@ public class ControllerButtonWidget extends AbstractIconButtonWidget
|
||||
public void update()
|
||||
{
|
||||
int length = binding.getButton().length;
|
||||
this.setMessage(this.binding.isNotBound() ? I18n.translate("lambdacontrols.not_bound") :
|
||||
(length > 0 ? ButtonBinding.getLocalizedButtonName(binding.getButton()[0]) : "<>"));
|
||||
this.setMessage(this.binding.isNotBound() ? LambdaControls.NOT_BOUND_TEXT :
|
||||
(length > 0 ? ButtonBinding.getLocalizedButtonName(binding.getButton()[0]) : new LiteralText("<>")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
public Text getMessage()
|
||||
{
|
||||
if (this.binding.getButton().length > 1)
|
||||
return "";
|
||||
return LiteralText.EMPTY;
|
||||
return super.getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int renderIcon(int mouseX, int mouseY, float delta, int x, int y)
|
||||
protected int renderIcon(MatrixStack matrices, int mouseX, int mouseY, float delta, int x, int y)
|
||||
{
|
||||
if (this.binding.getButton().length > 1) {
|
||||
x += (this.width / 2 - this.iconWidth / 2) - 4;
|
||||
}
|
||||
Pair<Integer, Integer> size = LambdaControlsRenderer.drawButton(x, y, this.binding, MinecraftClient.getInstance());
|
||||
Pair<Integer, Integer> size = LambdaControlsRenderer.drawButton(matrices, x, y, this.binding, MinecraftClient.getInstance());
|
||||
this.iconWidth = size.key;
|
||||
return size.value;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import me.lambdaurora.spruceui.SpruceButtonWidget;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.options.ControlsOptionsScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import org.aperlambda.lambdacommon.utils.function.Predicates;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -56,26 +56,30 @@ public class ControllerControlsScreen extends Screen
|
||||
@Override
|
||||
protected void init()
|
||||
{
|
||||
this.addButton(new SpruceButtonWidget(this.width / 2 - 155, 18, this.hideSettings ? 310 : 150, 20, I18n.translate("lambdacontrols.menu.keyboard_controls"),
|
||||
btn -> this.minecraft.openScreen(new ControlsOptionsScreen(this, this.minecraft.options))));
|
||||
this.addButton(new SpruceButtonWidget(this.width / 2 - 155, 18, this.hideSettings ? 310 : 150, 20,
|
||||
new TranslatableText("lambdacontrols.menu.keyboard_controls"),
|
||||
btn -> this.client.openScreen(new ControlsOptionsScreen(this, this.client.options))));
|
||||
if (!this.hideSettings)
|
||||
this.addButton(new SpruceButtonWidget(this.width / 2 - 155 + 160, 18, 150, 20, I18n.translate("menu.options"),
|
||||
btn -> this.minecraft.openScreen(new LambdaControlsSettingsScreen(this, true))));
|
||||
this.bindingsListWidget = new ControlsListWidget(this, this.minecraft);
|
||||
this.addButton(new SpruceButtonWidget(this.width / 2 - 155 + 160, 18, 150, 20,
|
||||
new TranslatableText("menu.options"),
|
||||
btn -> this.client.openScreen(new LambdaControlsSettingsScreen(this, true))));
|
||||
this.bindingsListWidget = new ControlsListWidget(this, this.client);
|
||||
this.children.add(this.bindingsListWidget);
|
||||
this.resetButton = this.addButton(new ButtonWidget(this.width / 2 - 155, this.height - 29, 150, 20, I18n.translate("controls.resetAll"),
|
||||
this.resetButton = this.addButton(new ButtonWidget(this.width / 2 - 155, this.height - 29, 150, 20,
|
||||
new TranslatableText("controls.resetAll"),
|
||||
btn -> InputManager.streamBindings().forEach(binding -> this.mod.config.setButtonBinding(binding, binding.getDefaultButton()))));
|
||||
this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, 20, I18n.translate("gui.done"),
|
||||
btn -> this.minecraft.openScreen(this.parent)));
|
||||
this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, 20,
|
||||
new TranslatableText("gui.done"),
|
||||
btn -> this.client.openScreen(this.parent)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float delta)
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
this.renderBackground();
|
||||
this.bindingsListWidget.render(mouseX, mouseY, delta);
|
||||
this.drawCenteredString(this.font, this.title.asFormattedString(), this.width / 2, 8, 16777215);
|
||||
this.renderBackground(matrices);
|
||||
this.bindingsListWidget.render(matrices, mouseX, mouseY, delta);
|
||||
this.drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 8, 16777215);
|
||||
this.resetButton.active = InputManager.streamBindings().anyMatch(Predicates.not(ButtonBinding::isDefault));
|
||||
super.render(mouseX, mouseY, delta);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@ import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ElementListWidget;
|
||||
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.TranslatableText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -48,7 +52,7 @@ public class ControlsListWidget extends ElementListWidget<ControlsListWidget.Ent
|
||||
this.addEntry(new CategoryEntry(category));
|
||||
|
||||
category.getBindings().forEach(binding -> {
|
||||
int i = client.textRenderer.getStringWidth(I18n.translate(binding.getTranslationKey()));
|
||||
int i = client.textRenderer.getWidth(I18n.translate(binding.getTranslationKey()));
|
||||
if (i > this.field_2733) {
|
||||
this.field_2733 = i;
|
||||
}
|
||||
@@ -59,9 +63,9 @@ public class ControlsListWidget extends ElementListWidget<ControlsListWidget.Ent
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getScrollbarPosition()
|
||||
protected int getScrollbarPositionX()
|
||||
{
|
||||
return super.getScrollbarPosition() + 15;
|
||||
return super.getScrollbarPositionX() + 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,28 +92,28 @@ public class ControlsListWidget extends ElementListWidget<ControlsListWidget.Ent
|
||||
gui.waiting = true;
|
||||
})
|
||||
{
|
||||
protected String getNarrationMessage()
|
||||
protected MutableText getNarrationMessage()
|
||||
{
|
||||
return binding.isNotBound() ? I18n.translate("narrator.controls.unbound", bindingName) : I18n.translate("narrator.controls.bound", bindingName, super.getNarrationMessage());
|
||||
return binding.isNotBound() ? new TranslatableText("narrator.controls.unbound", bindingName) : new TranslatableText("narrator.controls.bound", bindingName, super.getNarrationMessage());
|
||||
}
|
||||
};
|
||||
this.resetButton = new ButtonWidget(0, 0, 50, 20, I18n.translate("controls.reset"),
|
||||
this.resetButton = new ButtonWidget(0, 0, 50, 20, new TranslatableText("controls.reset"),
|
||||
btn -> gui.mod.config.setButtonBinding(binding, binding.getDefaultButton()))
|
||||
{
|
||||
protected String getNarrationMessage()
|
||||
protected MutableText getNarrationMessage()
|
||||
{
|
||||
return I18n.translate("narrator.controls.reset", bindingName);
|
||||
return new TranslatableText("narrator.controls.reset", bindingName);
|
||||
}
|
||||
};
|
||||
this.unboundButton = new ButtonWidget(0, 0, 50, 20, I18n.translate("lambdacontrols.menu.unbound"),
|
||||
this.unboundButton = new ButtonWidget(0, 0, 50, 20, new TranslatableText("lambdacontrols.menu.unbound"),
|
||||
btn -> {
|
||||
gui.mod.config.setButtonBinding(binding, UNBOUND);
|
||||
gui.focusedBinding = null;
|
||||
})
|
||||
{
|
||||
protected String getNarrationMessage()
|
||||
protected MutableText getNarrationMessage()
|
||||
{
|
||||
return I18n.translate("lambdacontrols.narrator.unbound", bindingName);
|
||||
return new TranslatableText("lambdacontrols.narrator.unbound", bindingName);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -121,34 +125,38 @@ public class ControlsListWidget extends ElementListWidget<ControlsListWidget.Ent
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean hovering, float delta)
|
||||
public void render(MatrixStack matrices, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean hovering, float delta)
|
||||
{
|
||||
boolean focused = gui.focusedBinding == this.binding;
|
||||
TextRenderer textRenderer = ControlsListWidget.this.minecraft.textRenderer;
|
||||
TextRenderer textRenderer = ControlsListWidget.this.client.textRenderer;
|
||||
String bindingName = this.bindingName;
|
||||
float var10002 = (float) (x + 70 - ControlsListWidget.this.field_2733);
|
||||
int var10003 = y + height / 2;
|
||||
textRenderer.draw(bindingName, var10002, (float) (var10003 - 9 / 2), 16777215);
|
||||
textRenderer.draw(matrices, bindingName, var10002, (float) (var10003 - 9 / 2), 16777215);
|
||||
this.resetButton.x = this.unboundButton.x = x + 190;
|
||||
this.resetButton.y = this.unboundButton.y = y;
|
||||
this.resetButton.active = !this.binding.isDefault();
|
||||
if (focused)
|
||||
this.unboundButton.render(mouseX, mouseY, delta);
|
||||
this.unboundButton.render(matrices, mouseX, mouseY, delta);
|
||||
else
|
||||
this.resetButton.render(mouseX, mouseY, delta);
|
||||
this.resetButton.render(matrices, mouseX, mouseY, delta);
|
||||
this.editButton.x = x + 75;
|
||||
this.editButton.y = y;
|
||||
this.editButton.update();
|
||||
|
||||
if (focused) {
|
||||
this.editButton.setMessage(Formatting.WHITE + "> " + Formatting.YELLOW + this.editButton.getMessage() + Formatting.WHITE + " <");
|
||||
MutableText text = new LiteralText("> ").formatted(Formatting.WHITE);
|
||||
text.append(this.editButton.getMessage().copy().formatted(Formatting.YELLOW));
|
||||
this.editButton.setMessage(text.append(new LiteralText(" <").formatted(Formatting.WHITE)));
|
||||
} else if (!this.binding.isNotBound() && InputManager.hasDuplicatedBindings(this.binding)) {
|
||||
this.editButton.setMessage(Formatting.RED + this.editButton.getMessage());
|
||||
MutableText text = this.editButton.getMessage().copy();
|
||||
this.editButton.setMessage(text.formatted(Formatting.RED));
|
||||
} else if (this.binding.isNotBound()) {
|
||||
this.editButton.setMessage(Formatting.GOLD + this.editButton.getMessage());
|
||||
MutableText text = this.editButton.getMessage().copy();
|
||||
this.editButton.setMessage(text.formatted(Formatting.GOLD));
|
||||
}
|
||||
|
||||
this.editButton.render(mouseX, mouseY, delta);
|
||||
this.editButton.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button)
|
||||
@@ -175,13 +183,13 @@ public class ControlsListWidget extends ElementListWidget<ControlsListWidget.Ent
|
||||
public CategoryEntry(@NotNull ButtonCategory category)
|
||||
{
|
||||
this.name = category.getTranslatedName();
|
||||
this.nameWidth = ControlsListWidget.this.minecraft.textRenderer.getStringWidth(this.name);
|
||||
this.nameWidth = ControlsListWidget.this.client.textRenderer.getWidth(this.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean hovering, float delta)
|
||||
public void render(MatrixStack matrices, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean hovering, float delta)
|
||||
{
|
||||
ControlsListWidget.this.minecraft.textRenderer.draw(this.name, (float) (ControlsListWidget.this.minecraft.currentScreen.width / 2 - this.nameWidth / 2),
|
||||
ControlsListWidget.this.client.textRenderer.draw(matrices, this.name, (float) (ControlsListWidget.this.client.currentScreen.width / 2 - this.nameWidth / 2),
|
||||
(float) ((y + height) - 9 - 1), 16777215);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,15 +13,13 @@ import me.lambdaurora.lambdacontrols.ControlsMode;
|
||||
import me.lambdaurora.lambdacontrols.LambdaControlsConstants;
|
||||
import me.lambdaurora.lambdacontrols.client.HudSide;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaInput;
|
||||
import me.lambdaurora.lambdacontrols.client.compat.LambdaControlsCompat;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||
import me.lambdaurora.spruceui.hud.Hud;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.util.math.Matrix4f;
|
||||
import net.minecraft.client.util.math.Rotation3;
|
||||
import net.minecraft.client.util.Window;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -34,26 +32,27 @@ import org.jetbrains.annotations.Nullable;
|
||||
* Represents the LambdaControls HUD.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.2.0
|
||||
* @version 1.3.2
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LambdaControlsHud extends Hud
|
||||
{
|
||||
private final LambdaControlsClient mod;
|
||||
private MinecraftClient client;
|
||||
private int attackWidth = 0;
|
||||
private int attackButtonWidth = 0;
|
||||
private int dropItemWidth = 0;
|
||||
private int dropItemButtonWidth = 0;
|
||||
private int inventoryWidth = 0;
|
||||
private int inventoryButtonWidth = 0;
|
||||
private int swapHandsWidth = 0;
|
||||
private int swapHandsButtonWidth = 0;
|
||||
private int useWidth = 0;
|
||||
private int useButtonWidth = 0;
|
||||
private int attackWidth = 0;
|
||||
private int attackButtonWidth = 0;
|
||||
private int dropItemWidth = 0;
|
||||
private int dropItemButtonWidth = 0;
|
||||
private int inventoryWidth = 0;
|
||||
private int inventoryButtonWidth = 0;
|
||||
private int swapHandsWidth = 0;
|
||||
private int swapHandsButtonWidth = 0;
|
||||
private int useWidth = 0;
|
||||
private int useButtonWidth = 0;
|
||||
private BlockHitResult placeHitResult;
|
||||
private String attackAction = "";
|
||||
private String placeAction = "";
|
||||
private String attackAction = "";
|
||||
private String placeAction = "";
|
||||
private int ticksDisplayedCrosshair = 0;
|
||||
|
||||
public LambdaControlsHud(@NotNull LambdaControlsClient mod)
|
||||
{
|
||||
@@ -79,26 +78,37 @@ public class LambdaControlsHud extends Hud
|
||||
/**
|
||||
* Renders the LambdaControls' HUD.
|
||||
*/
|
||||
public void render(float tickDelta)
|
||||
@Override
|
||||
public void render(MatrixStack matrices, float tickDelta)
|
||||
{
|
||||
if (this.mod.config.getControlsMode() == ControlsMode.CONTROLLER && this.client.currentScreen == null) {
|
||||
int y = bottom(2);
|
||||
this.renderFirstIcons(this.mod.config.getHudSide() == HudSide.LEFT ? 2 : client.getWindow().getScaledWidth() - 2, y);
|
||||
this.renderSecondIcons(this.mod.config.getHudSide() == HudSide.RIGHT ? 2 : client.getWindow().getScaledWidth() - 2, y);
|
||||
VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
|
||||
Matrix4f matrix4f = Rotation3.identity().getMatrix();
|
||||
this.renderFirstSection(this.mod.config.getHudSide() == HudSide.LEFT ? 2 : client.getWindow().getScaledWidth() - 2, y, immediate, matrix4f);
|
||||
this.renderSecondSection(this.mod.config.getHudSide() == HudSide.RIGHT ? 2 : client.getWindow().getScaledWidth() - 2, y, immediate, matrix4f);
|
||||
immediate.draw();
|
||||
this.renderFirstIcons(matrices, this.mod.config.getHudSide() == HudSide.LEFT ? 2 : client.getWindow().getScaledWidth() - 2, y);
|
||||
this.renderSecondIcons(matrices, this.mod.config.getHudSide() == HudSide.RIGHT ? 2 : client.getWindow().getScaledWidth() - 2, y);
|
||||
this.renderFirstSection(matrices, this.mod.config.getHudSide() == HudSide.LEFT ? 2 : client.getWindow().getScaledWidth() - 2, y);
|
||||
this.renderSecondSection(matrices, this.mod.config.getHudSide() == HudSide.RIGHT ? 2 : client.getWindow().getScaledWidth() - 2, y);
|
||||
}
|
||||
|
||||
if (this.mod.reacharound.isLastReacharoundVertical()) {
|
||||
// Render crosshair indicator.
|
||||
Window window = this.client.getWindow();
|
||||
String text = "[ ]";
|
||||
|
||||
float scale = Math.min(5, this.ticksDisplayedCrosshair + tickDelta) / 5F;
|
||||
scale *= scale;
|
||||
int opacity = ((int) (255 * scale)) << 24;
|
||||
|
||||
this.client.textRenderer.draw(matrices, text, window.getScaledWidth() / 2.f - this.client.textRenderer.getWidth(text) / 2.f,
|
||||
window.getScaledHeight() / 2.f - 4, 0xCCCCCC | opacity);
|
||||
}
|
||||
}
|
||||
|
||||
public void renderFirstIcons(int x, int y)
|
||||
public void renderFirstIcons(MatrixStack matrices, int x, int y)
|
||||
{
|
||||
int offset = 2 + this.inventoryWidth + this.inventoryButtonWidth + 4;
|
||||
int currentX = this.mod.config.getHudSide() == HudSide.LEFT ? x : x - this.inventoryButtonWidth;
|
||||
this.drawButton(currentX, y, ButtonBinding.INVENTORY, true);
|
||||
this.drawButton(currentX += (this.mod.config.getHudSide() == HudSide.LEFT ? offset : -offset), y, ButtonBinding.SWAP_HANDS, true);
|
||||
this.drawButton(matrices, currentX, y, ButtonBinding.INVENTORY, true);
|
||||
this.drawButton(matrices, currentX += (this.mod.config.getHudSide() == HudSide.LEFT ? offset : -offset), y, ButtonBinding.SWAP_HANDS, true);
|
||||
offset = 2 + this.swapHandsWidth + this.dropItemButtonWidth + 4;
|
||||
if (this.client.options.showSubtitles && this.mod.config.getHudSide() == HudSide.RIGHT) {
|
||||
currentX += -offset;
|
||||
@@ -106,17 +116,17 @@ public class LambdaControlsHud extends Hud
|
||||
currentX = this.mod.config.getHudSide() == HudSide.LEFT ? x : x - this.dropItemButtonWidth;
|
||||
y -= 24;
|
||||
}
|
||||
this.drawButton(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(int x, int y)
|
||||
public void renderSecondIcons(MatrixStack matrices, int x, int y)
|
||||
{
|
||||
int offset;
|
||||
int currentX = x;
|
||||
if (!this.placeAction.isEmpty()) {
|
||||
if (this.mod.config.getHudSide() == HudSide.LEFT)
|
||||
currentX -= this.useButtonWidth;
|
||||
this.drawButton(currentX, y, ButtonBinding.USE, true);
|
||||
this.drawButton(matrices, currentX, y, ButtonBinding.USE, true);
|
||||
offset = 2 + this.useWidth + 4;
|
||||
if (this.client.options.showSubtitles && this.mod.config.getHudSide() == HudSide.LEFT) {
|
||||
currentX -= offset;
|
||||
@@ -129,33 +139,33 @@ public class LambdaControlsHud extends Hud
|
||||
if (this.mod.config.getHudSide() == HudSide.LEFT)
|
||||
currentX -= this.attackButtonWidth;
|
||||
|
||||
this.drawButton(currentX, y, ButtonBinding.ATTACK, this.attackWidth != 0);
|
||||
this.drawButton(matrices, currentX, y, ButtonBinding.ATTACK, this.attackWidth != 0);
|
||||
}
|
||||
|
||||
public void renderFirstSection(int x, int y, @NotNull VertexConsumerProvider.Immediate immediate, @NotNull Matrix4f matrix4f)
|
||||
public void renderFirstSection(MatrixStack matrices, int x, int y)
|
||||
{
|
||||
int currentX = this.mod.config.getHudSide() == HudSide.LEFT ? x + this.inventoryButtonWidth + 2 : x - this.inventoryButtonWidth - 2 - this.inventoryWidth;
|
||||
this.drawTip(currentX, y, ButtonBinding.INVENTORY, true, immediate, matrix4f);
|
||||
this.drawTip(matrices, currentX, y, ButtonBinding.INVENTORY, true);
|
||||
currentX += this.mod.config.getHudSide() == HudSide.LEFT ? this.inventoryWidth + 4 + this.swapHandsButtonWidth + 2
|
||||
: -this.swapHandsWidth - 2 - this.swapHandsButtonWidth - 4;
|
||||
this.drawTip(currentX, y, ButtonBinding.SWAP_HANDS, true, immediate, matrix4f);
|
||||
this.drawTip(matrices, currentX, y, ButtonBinding.SWAP_HANDS, true);
|
||||
if (this.client.options.showSubtitles && this.mod.config.getHudSide() == HudSide.RIGHT) {
|
||||
currentX += -this.dropItemWidth - 2 - this.dropItemButtonWidth - 4;
|
||||
} else {
|
||||
y -= 24;
|
||||
currentX = this.mod.config.getHudSide() == HudSide.LEFT ? x + this.dropItemButtonWidth + 2 : x - this.dropItemButtonWidth - 2 - this.dropItemWidth;
|
||||
}
|
||||
this.drawTip(currentX, y, ButtonBinding.DROP_ITEM, !this.client.player.getMainHandStack().isEmpty(), immediate, matrix4f);
|
||||
this.drawTip(matrices, currentX, y, ButtonBinding.DROP_ITEM, !this.client.player.getMainHandStack().isEmpty());
|
||||
}
|
||||
|
||||
public void renderSecondSection(int x, int y, @NotNull VertexConsumerProvider.Immediate immediate, @NotNull Matrix4f matrix4f)
|
||||
public void renderSecondSection(MatrixStack matrices, int x, int y)
|
||||
{
|
||||
int currentX = x;
|
||||
|
||||
if (!this.placeAction.isEmpty()) {
|
||||
currentX += this.mod.config.getHudSide() == HudSide.RIGHT ? this.useButtonWidth + 2 : -this.useButtonWidth - 2 - this.useWidth;
|
||||
|
||||
this.drawTip(currentX, y, this.placeAction, true, immediate, matrix4f);
|
||||
this.drawTip(matrices, currentX, y, this.placeAction, true);
|
||||
|
||||
if (this.client.options.showSubtitles && this.mod.config.getHudSide() == HudSide.LEFT) {
|
||||
currentX -= 4;
|
||||
@@ -167,7 +177,7 @@ public class LambdaControlsHud extends Hud
|
||||
|
||||
currentX += this.mod.config.getHudSide() == HudSide.RIGHT ? this.attackButtonWidth + 2 : -this.attackButtonWidth - 2 - this.attackWidth;
|
||||
|
||||
this.drawTip(currentX, y, this.attackAction, this.attackWidth != 0, immediate, matrix4f);
|
||||
this.drawTip(matrices, currentX, y, this.attackAction, this.attackWidth != 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -182,7 +192,7 @@ public class LambdaControlsHud extends Hud
|
||||
|
||||
// Update "Use" tip status.
|
||||
if (this.client.crosshairTarget.getType() == HitResult.Type.MISS) {
|
||||
this.placeHitResult = LambdaInput.tryFrontPlace(this.client);
|
||||
this.placeHitResult = this.mod.reacharound.getLastReacharoundResult();
|
||||
this.attackAction = "";
|
||||
this.attackWidth = 0;
|
||||
} else {
|
||||
@@ -195,8 +205,26 @@ public class LambdaControlsHud extends Hud
|
||||
this.attackWidth = this.width(attackAction);
|
||||
}
|
||||
|
||||
ItemStack stack = this.client.player.getMainHandStack();
|
||||
if ((stack == null || stack.isEmpty()) && ((stack = this.client.player.getOffHandStack()) == null || stack.isEmpty())) {
|
||||
if (this.mod.reacharound.isLastReacharoundVertical()) {
|
||||
if (this.ticksDisplayedCrosshair < 5)
|
||||
this.ticksDisplayedCrosshair++;
|
||||
} else {
|
||||
this.ticksDisplayedCrosshair = 0;
|
||||
}
|
||||
|
||||
String customAttackAction = LambdaControlsCompat.getAttackActionAt(this.client, this.placeHitResult);
|
||||
if (customAttackAction != null) {
|
||||
this.attackAction = customAttackAction;
|
||||
this.attackWidth = this.width(customAttackAction);
|
||||
}
|
||||
|
||||
ItemStack stack = null;
|
||||
if (this.client.player != null) {
|
||||
stack = this.client.player.getMainHandStack();
|
||||
if (stack == null || stack.isEmpty())
|
||||
stack = this.client.player.getOffHandStack();
|
||||
}
|
||||
if (stack == null || stack.isEmpty()) {
|
||||
placeAction = "";
|
||||
} else {
|
||||
if (this.placeHitResult != null && stack.getItem() instanceof BlockItem) {
|
||||
@@ -206,6 +234,10 @@ public class LambdaControlsHud extends Hud
|
||||
}
|
||||
}
|
||||
|
||||
String customUseAction = LambdaControlsCompat.getUseActionAt(this.client, this.placeHitResult);
|
||||
if (customUseAction != null)
|
||||
placeAction = customUseAction;
|
||||
|
||||
this.placeAction = placeAction;
|
||||
|
||||
// Cache the "Use" tip width.
|
||||
@@ -236,27 +268,26 @@ public class LambdaControlsHud extends Hud
|
||||
{
|
||||
if (text == null || text.isEmpty())
|
||||
return 0;
|
||||
return this.client.textRenderer.getStringWidth(I18n.translate(text));
|
||||
return this.client.textRenderer.getWidth(I18n.translate(text));
|
||||
}
|
||||
|
||||
private void drawButton(int x, int y, @NotNull ButtonBinding button, boolean display)
|
||||
private void drawButton(MatrixStack matrices, int x, int y, @NotNull ButtonBinding button, boolean display)
|
||||
{
|
||||
if (display)
|
||||
LambdaControlsRenderer.drawButton(x, y, button, this.client);
|
||||
LambdaControlsRenderer.drawButton(matrices, x, y, button, this.client);
|
||||
}
|
||||
|
||||
private void drawTip(int x, int y, @NotNull ButtonBinding button, boolean display, @NotNull VertexConsumerProvider.Immediate immediate, @NotNull Matrix4f matrix4f)
|
||||
private void drawTip(MatrixStack matrices, int x, int y, @NotNull ButtonBinding button, boolean display)
|
||||
{
|
||||
this.drawTip(x, y, button.getTranslationKey(), display, immediate, matrix4f);
|
||||
this.drawTip(matrices, x, y, button.getTranslationKey(), display);
|
||||
}
|
||||
|
||||
private void drawTip(int x, int y, @NotNull String action, boolean display, @NotNull VertexConsumerProvider.Immediate immediate, @NotNull Matrix4f matrix4f)
|
||||
private void drawTip(MatrixStack matrices, int x, int y, @NotNull String action, boolean display)
|
||||
{
|
||||
if (!display)
|
||||
return;
|
||||
String translatedAction = I18n.translate(action);
|
||||
int textY = (LambdaControlsRenderer.ICON_SIZE / 2 - this.client.textRenderer.fontHeight / 2) + 1;
|
||||
client.textRenderer.draw(translatedAction, (float) x, (float) (y + textY), 14737632, true, matrix4f, immediate,
|
||||
false, 0, 15728880);
|
||||
this.client.textRenderer.draw(matrices, translatedAction, (float) x, (float) (y + textY), 14737632);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,27 +11,25 @@ package me.lambdaurora.lambdacontrols.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaInput;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||
import me.lambdaurora.lambdacontrols.client.util.ContainerScreenAccessor;
|
||||
import me.lambdaurora.lambdacontrols.client.util.HandledScreenAccessor;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.screen.ingame.ContainerScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.container.Slot;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import org.aperlambda.lambdacommon.utils.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Represents the LambdaControls renderer.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.2.0
|
||||
* @version 1.3.2
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public class LambdaControlsRenderer
|
||||
@@ -88,19 +86,19 @@ public class LambdaControlsRenderer
|
||||
return width;
|
||||
}
|
||||
|
||||
public static Pair<Integer, Integer> drawButton(int x, int y, @NotNull ButtonBinding button, @NotNull MinecraftClient client)
|
||||
public static Pair<Integer, Integer> drawButton(MatrixStack matrices, int x, int y, @NotNull ButtonBinding button, @NotNull MinecraftClient client)
|
||||
{
|
||||
return drawButton(x, y, button.getButton(), client);
|
||||
return drawButton(matrices, x, y, button.getButton(), client);
|
||||
}
|
||||
|
||||
public static Pair<Integer, Integer> drawButton(int x, int y, int[] buttons, @NotNull MinecraftClient client)
|
||||
public static Pair<Integer, Integer> drawButton(MatrixStack matrices, int x, int y, int[] buttons, @NotNull MinecraftClient client)
|
||||
{
|
||||
int height = 0;
|
||||
int length = 0;
|
||||
int currentX = x;
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
int btn = buttons[i];
|
||||
int size = drawButton(currentX, y, btn, client);
|
||||
int size = drawButton(matrices, currentX, y, btn, client);
|
||||
if (size > height)
|
||||
height = size;
|
||||
length += size;
|
||||
@@ -113,7 +111,7 @@ public class LambdaControlsRenderer
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecated")
|
||||
public static int drawButton(int x, int y, int button, @NotNull MinecraftClient client)
|
||||
public static int drawButton(MatrixStack matrices, int x, int y, int button, @NotNull MinecraftClient client)
|
||||
{
|
||||
boolean second = false;
|
||||
if (button == -1)
|
||||
@@ -196,7 +194,7 @@ public class LambdaControlsRenderer
|
||||
int assetSize = axis ? AXIS_SIZE : BUTTON_SIZE;
|
||||
|
||||
RenderSystem.color4f(1.0F, second ? 0.0F : 1.0F, 1.0F, 1.0F);
|
||||
DrawableHelper.blit(x + (ICON_SIZE / 2 - assetSize / 2), y + (ICON_SIZE / 2 - assetSize / 2),
|
||||
DrawableHelper.drawTexture(matrices, x + (ICON_SIZE / 2 - assetSize / 2), y + (ICON_SIZE / 2 - assetSize / 2),
|
||||
(float) buttonOffset, (float) (controllerType * (axis ? AXIS_SIZE : BUTTON_SIZE)),
|
||||
assetSize, assetSize,
|
||||
256, 256);
|
||||
@@ -205,20 +203,20 @@ public class LambdaControlsRenderer
|
||||
return ICON_SIZE;
|
||||
}
|
||||
|
||||
public static int drawButtonTip(int x, int y, @NotNull ButtonBinding button, boolean display, @NotNull MinecraftClient client)
|
||||
public static int drawButtonTip(MatrixStack matrices, int x, int y, @NotNull ButtonBinding button, boolean display, @NotNull MinecraftClient client)
|
||||
{
|
||||
return drawButtonTip(x, y, button.getButton(), button.getTranslationKey(), display, client);
|
||||
return drawButtonTip(matrices, x, y, button.getButton(), button.getTranslationKey(), display, client);
|
||||
}
|
||||
|
||||
public static int drawButtonTip(int x, int y, int[] button, @NotNull String action, boolean display, @NotNull MinecraftClient client)
|
||||
public static int drawButtonTip(MatrixStack matrices, int x, int y, int[] button, @NotNull String action, boolean display, @NotNull MinecraftClient client)
|
||||
{
|
||||
if (display) {
|
||||
int buttonWidth = drawButton(x, y, button, client).key;
|
||||
int buttonWidth = drawButton(matrices, x, y, button, client).key;
|
||||
|
||||
String translatedAction = I18n.translate(action);
|
||||
int textY = (LambdaControlsRenderer.ICON_SIZE / 2 - client.textRenderer.fontHeight / 2) + 1;
|
||||
|
||||
return client.textRenderer.drawWithShadow(translatedAction, (float) (x + buttonWidth + 2), (float) (y + textY), 14737632);
|
||||
return client.textRenderer.drawWithShadow(matrices, translatedAction, (float) (x + buttonWidth + 2), (float) (y + textY), 14737632);
|
||||
}
|
||||
|
||||
return -10;
|
||||
@@ -226,12 +224,12 @@ public class LambdaControlsRenderer
|
||||
|
||||
private static int getButtonTipWidth(@NotNull String action, @NotNull TextRenderer textRenderer)
|
||||
{
|
||||
return 15 + 5 + textRenderer.getStringWidth(action);
|
||||
return 15 + 5 + textRenderer.getWidth(action);
|
||||
}
|
||||
|
||||
public static void renderVirtualCursor(@NotNull MatrixStack matrices, @NotNull MinecraftClient client)
|
||||
{
|
||||
if (!LambdaControlsClient.get().config.hasVirtualMouse() || client.currentScreen == null)
|
||||
if (!LambdaControlsClient.get().config.hasVirtualMouse() || (client.currentScreen == null || LambdaInput.isScreenInteractive(client.currentScreen)))
|
||||
return;
|
||||
|
||||
int mouseX = (int) (client.mouse.getX() * (double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth());
|
||||
@@ -239,30 +237,16 @@ public class LambdaControlsRenderer
|
||||
|
||||
boolean hoverSlot = false;
|
||||
|
||||
if (client.currentScreen instanceof ContainerScreen) {
|
||||
ContainerScreen inventoryScreen = (ContainerScreen) client.currentScreen;
|
||||
ContainerScreenAccessor accessor = (ContainerScreenAccessor) inventoryScreen;
|
||||
int guiLeft = accessor.getX();
|
||||
int guiTop = accessor.getY();
|
||||
if (client.currentScreen instanceof HandledScreen) {
|
||||
HandledScreenAccessor inventoryScreen = (HandledScreenAccessor) client.currentScreen;
|
||||
int guiLeft = inventoryScreen.getX();
|
||||
int guiTop = inventoryScreen.getY();
|
||||
|
||||
// Finds the closest slot in the GUI within 14 pixels.
|
||||
int finalMouseX = mouseX;
|
||||
int finalMouseY = mouseY;
|
||||
Optional<Pair<Slot, Double>> closestSlot = inventoryScreen.getContainer().slots.parallelStream()
|
||||
.map(slot -> {
|
||||
int x = guiLeft + slot.xPosition + 8;
|
||||
int y = guiTop + slot.yPosition + 8;
|
||||
Slot slot = inventoryScreen.lambdacontrols_getSlotAt(mouseX, mouseY);
|
||||
|
||||
// Distance between the slot and the cursor.
|
||||
double distance = Math.sqrt(Math.pow(x - finalMouseX, 2) + Math.pow(y - finalMouseY, 2));
|
||||
return Pair.of(slot, distance);
|
||||
}).filter(entry -> entry.value <= 9.0)
|
||||
.min(Comparator.comparingDouble(p -> p.value));
|
||||
|
||||
if (closestSlot.isPresent()) {
|
||||
Slot slot = closestSlot.get().key;
|
||||
mouseX = guiLeft + slot.xPosition;
|
||||
mouseY = guiTop + slot.yPosition;
|
||||
if (slot != null) {
|
||||
mouseX = guiLeft + slot.x;
|
||||
mouseY = guiTop + slot.y;
|
||||
hoverSlot = true;
|
||||
}
|
||||
}
|
||||
@@ -291,7 +275,7 @@ public class LambdaControlsRenderer
|
||||
RenderSystem.disableDepthTest();
|
||||
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
DrawableHelper.blit(x, y, hoverSlot ? 16.F : 0.F, LambdaControlsClient.get().config.getVirtualMouseSkin().ordinal() * 16.F, 16, 16, 32, 64);
|
||||
DrawableHelper.drawTexture(matrices, x, y, hoverSlot ? 16.F : 0.F, LambdaControlsClient.get().config.getVirtualMouseSkin().ordinal() * 16.F, 16, 16, 32, 64);
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ import net.minecraft.client.gui.widget.ButtonListWidget;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.options.Option;
|
||||
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.TranslatableText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Util;
|
||||
@@ -35,7 +38,7 @@ import org.lwjgl.glfw.GLFW;
|
||||
*/
|
||||
public class LambdaControlsSettingsScreen extends Screen
|
||||
{
|
||||
public static final String GAMEPAD_TOOL_URL = "http://generalarcade.com/gamepadtool/";
|
||||
public static final String GAMEPAD_TOOL_URL = "https://generalarcade.com/gamepadtool/";
|
||||
final LambdaControlsClient mod;
|
||||
private final Screen parent;
|
||||
private final boolean hideControls;
|
||||
@@ -48,6 +51,7 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
private final Option autoJumpOption;
|
||||
private final Option fastBlockPlacingOption;
|
||||
private final Option frontBlockPlacingOption;
|
||||
private final Option verticalReacharoundOption;
|
||||
private final Option flyDriftingOption;
|
||||
private final Option flyVerticalDriftingOption;
|
||||
// Controller options
|
||||
@@ -63,7 +67,9 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
// Hud options
|
||||
private final Option hudEnableOption;
|
||||
private final Option hudSideOption;
|
||||
private final String controllerMappingsUrlText = I18n.translate("lambdacontrols.controller.mappings.2", Formatting.GOLD.toString(), GAMEPAD_TOOL_URL, Formatting.RESET.toString());
|
||||
private final MutableText controllerMappingsUrlText = new LiteralText("(")
|
||||
.append(new LiteralText(GAMEPAD_TOOL_URL).formatted(Formatting.GOLD))
|
||||
.append("),");
|
||||
private ButtonListWidget list;
|
||||
private SpruceLabelWidget gamepadToolUrlLabel;
|
||||
|
||||
@@ -76,19 +82,19 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
// General options
|
||||
this.autoSwitchModeOption = new SpruceBooleanOption("lambdacontrols.menu.auto_switch_mode", this.mod.config::hasAutoSwitchMode,
|
||||
this.mod.config::setAutoSwitchMode, new TranslatableText("lambdacontrols.tooltip.auto_switch_mode"), true);
|
||||
this.rotationSpeedOption = new SpruceDoubleOption("lambdacontrols.menu.rotation_speed", 0.0, 150.0, 0.5F, this.mod.config::getRotationSpeed,
|
||||
this.rotationSpeedOption = new SpruceDoubleOption("lambdacontrols.menu.rotation_speed", 0.0, 100.0, 0.5F, this.mod.config::getRotationSpeed,
|
||||
newValue -> {
|
||||
synchronized (this.mod.config) {
|
||||
this.mod.config.setRotationSpeed(newValue);
|
||||
}
|
||||
}, option -> option.getDisplayPrefix() + option.get(),
|
||||
}, option -> option.getDisplayPrefix().append(String.valueOf(option.get())),
|
||||
new TranslatableText("lambdacontrols.tooltip.rotation_speed"));
|
||||
this.mouseSpeedOption = new SpruceDoubleOption("lambdacontrols.menu.mouse_speed", 0.0, 150.0, 0.5F, this.mod.config::getMouseSpeed,
|
||||
newValue -> {
|
||||
synchronized (this.mod.config) {
|
||||
this.mod.config.setMouseSpeed(newValue);
|
||||
}
|
||||
}, option -> option.getDisplayPrefix() + option.get(),
|
||||
}, option -> option.getDisplayPrefix().append(String.valueOf(option.get())),
|
||||
new TranslatableText("lambdacontrols.tooltip.mouse_speed"));
|
||||
this.resetOption = new SpruceResetOption(btn -> {
|
||||
this.mod.config.reset();
|
||||
@@ -99,8 +105,10 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
this.autoJumpOption = SpruceBooleanOption.fromVanilla("options.autoJump", Option.AUTO_JUMP, null, true);
|
||||
this.fastBlockPlacingOption = new SpruceBooleanOption("lambdacontrols.menu.fast_block_placing", this.mod.config::hasFastBlockPlacing,
|
||||
this.mod.config::setFastBlockPlacing, new TranslatableText("lambdacontrols.tooltip.fast_block_placing"), true);
|
||||
this.frontBlockPlacingOption = new SpruceBooleanOption("lambdacontrols.menu.front_block_placing", this.mod.config::hasFrontBlockPlacing,
|
||||
this.mod.config::setFrontBlockPlacing, new TranslatableText("lambdacontrols.tooltip.front_block_placing"), true);
|
||||
this.frontBlockPlacingOption = new SpruceBooleanOption("lambdacontrols.menu.reacharound.horizontal", this.mod.config::hasFrontBlockPlacing,
|
||||
this.mod.config::setFrontBlockPlacing, new TranslatableText("lambdacontrols.tooltip.reacharound.horizontal"), true);
|
||||
this.verticalReacharoundOption = new SpruceBooleanOption("lambdacontrols.menu.reacharound.vertical", this.mod.config::hasVerticalReacharound,
|
||||
this.mod.config::setVerticalReacharound, new TranslatableText("lambdacontrols.tooltip.reacharound.vertical"), true);
|
||||
this.flyDriftingOption = new SpruceBooleanOption("lambdacontrols.menu.fly_drifting", this.mod.config::hasFlyDrifting,
|
||||
this.mod.config::setFlyDrifting, new TranslatableText("lambdacontrols.tooltip.fly_drifting"), true);
|
||||
this.flyVerticalDriftingOption = new SpruceBooleanOption("lambdacontrols.menu.fly_drifting_vertical", this.mod.config::hasFlyVerticalDrifting,
|
||||
@@ -115,11 +123,11 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
}, option -> {
|
||||
String controllerName = this.mod.config.getController().getName();
|
||||
if (!this.mod.config.getController().isConnected())
|
||||
return option.getDisplayPrefix() + Formatting.RED + controllerName;
|
||||
return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.RED));
|
||||
else if (!this.mod.config.getController().isGamepad())
|
||||
return option.getDisplayPrefix() + Formatting.GOLD + controllerName;
|
||||
return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.GOLD));
|
||||
else
|
||||
return option.getDisplayPrefix() + controllerName;
|
||||
return option.getDisplayPrefix().append(controllerName);
|
||||
}, null);
|
||||
this.secondControllerOption = new SpruceCyclingOption("lambdacontrols.menu.controller2",
|
||||
amount -> {
|
||||
@@ -131,16 +139,16 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
}, option -> this.mod.config.getSecondController().map(controller -> {
|
||||
String controllerName = controller.getName();
|
||||
if (!controller.isConnected())
|
||||
return option.getDisplayPrefix() + Formatting.RED + controllerName;
|
||||
return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.RED));
|
||||
else if (!controller.isGamepad())
|
||||
return option.getDisplayPrefix() + Formatting.GOLD + controllerName;
|
||||
return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.GOLD));
|
||||
else
|
||||
return option.getDisplayPrefix() + controllerName;
|
||||
}).orElse(option.getDisplayPrefix() + Formatting.RED + I18n.translate("options.off")),
|
||||
return option.getDisplayPrefix().append(controllerName);
|
||||
}).orElse(option.getDisplayPrefix().append(new TranslatableText("options.off").formatted(Formatting.RED))),
|
||||
new TranslatableText("lambdacontrols.tooltip.controller2"));
|
||||
this.controllerTypeOption = new SpruceCyclingOption("lambdacontrols.menu.controller_type",
|
||||
amount -> this.mod.config.setControllerType(this.mod.config.getControllerType().next()),
|
||||
option -> option.getDisplayPrefix() + this.mod.config.getControllerType().getTranslatedName(),
|
||||
option -> option.getDisplayPrefix().append(this.mod.config.getControllerType().getTranslatedName()),
|
||||
new TranslatableText("lambdacontrols.tooltip.controller_type"));
|
||||
this.deadZoneOption = new SpruceDoubleOption("lambdacontrols.menu.dead_zone", 0.05, 1.0, 0.05F, this.mod.config::getDeadZone,
|
||||
newValue -> {
|
||||
@@ -149,7 +157,7 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
}
|
||||
}, option -> {
|
||||
String value = String.valueOf(option.get());
|
||||
return option.getDisplayPrefix() + value.substring(0, Math.min(value.length(), 5));
|
||||
return option.getDisplayPrefix().append(value.substring(0, Math.min(value.length(), 5)));
|
||||
}, new TranslatableText("lambdacontrols.tooltip.dead_zone"));
|
||||
this.invertsRightXAxis = new SpruceBooleanOption("lambdacontrols.menu.invert_right_x_axis", this.mod.config::doesInvertRightXAxis,
|
||||
newValue -> {
|
||||
@@ -169,14 +177,14 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
this.mod.config::setVirtualMouse, new TranslatableText("lambdacontrols.tooltip.virtual_mouse"), true);
|
||||
this.virtualMouseSkinOption = new SpruceCyclingOption("lambdacontrols.menu.virtual_mouse.skin",
|
||||
amount -> this.mod.config.setVirtualMouseSkin(this.mod.config.getVirtualMouseSkin().next()),
|
||||
option -> option.getDisplayPrefix() + this.mod.config.getVirtualMouseSkin().getTranslatedName(),
|
||||
option -> option.getDisplayPrefix().append(this.mod.config.getVirtualMouseSkin().getTranslatedName()),
|
||||
null);
|
||||
// HUD options
|
||||
this.hudEnableOption = new SpruceBooleanOption("lambdacontrols.menu.hud_enable", this.mod.config::isHudEnabled,
|
||||
this.mod::setHudEnabled, new TranslatableText("lambdacontrols.tooltip.hud_enable"), true);
|
||||
this.hudSideOption = new SpruceCyclingOption("lambdacontrols.menu.hud_side",
|
||||
amount -> this.mod.config.setHudSide(this.mod.config.getHudSide().next()),
|
||||
option -> option.getDisplayPrefix() + this.mod.config.getHudSide().getTranslatedName(),
|
||||
option -> option.getDisplayPrefix().append(this.mod.config.getHudSide().getTranslatedName()),
|
||||
new TranslatableText("lambdacontrols.tooltip.hud_side"));
|
||||
}
|
||||
|
||||
@@ -196,7 +204,7 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
|
||||
private int getTextHeight()
|
||||
{
|
||||
return (5 + this.font.fontHeight) * 3 + 5;
|
||||
return (5 + this.textRenderer.fontHeight) * 3 + 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,37 +213,37 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
super.init();
|
||||
int buttonHeight = 20;
|
||||
SpruceButtonWidget controlsModeBtn = new SpruceButtonWidget(this.width / 2 - 155, 18, this.hideControls ? 310 : 150, buttonHeight,
|
||||
I18n.translate("lambdacontrols.menu.controls_mode") + ": " + I18n.translate(this.mod.config.getControlsMode().getTranslationKey()),
|
||||
new TranslatableText("lambdacontrols.menu.controls_mode").append(": ").append(new TranslatableText(this.mod.config.getControlsMode().getTranslationKey())),
|
||||
btn -> {
|
||||
ControlsMode next = this.mod.config.getControlsMode().next();
|
||||
btn.setMessage(I18n.translate("lambdacontrols.menu.controls_mode") + ": " + I18n.translate(next.getTranslationKey()));
|
||||
btn.setMessage(new TranslatableText("lambdacontrols.menu.controls_mode").append(": ").append(new TranslatableText(next.getTranslationKey())));
|
||||
this.mod.config.setControlsMode(next);
|
||||
this.mod.config.save();
|
||||
|
||||
if (this.minecraft.player != null) {
|
||||
if (this.client.player != null) {
|
||||
ClientSidePacketRegistry.INSTANCE.sendToServer(LambdaControls.CONTROLS_MODE_CHANNEL, this.mod.makeControlsModeBuffer(next));
|
||||
}
|
||||
});
|
||||
controlsModeBtn.setTooltip(new TranslatableText("lambdacontrols.tooltip.controls_mode"));
|
||||
this.addButton(controlsModeBtn);
|
||||
if (!this.hideControls)
|
||||
this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, 18, 150, buttonHeight, I18n.translate("options.controls"),
|
||||
this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, 18, 150, buttonHeight, new TranslatableText("options.controls"),
|
||||
btn -> {
|
||||
if (this.mod.config.getControlsMode() == ControlsMode.CONTROLLER)
|
||||
this.minecraft.openScreen(new ControllerControlsScreen(this, true));
|
||||
this.client.openScreen(new ControllerControlsScreen(this, true));
|
||||
else
|
||||
this.minecraft.openScreen(new ControlsOptionsScreen(this, this.minecraft.options));
|
||||
this.client.openScreen(new ControlsOptionsScreen(this, this.client.options));
|
||||
}));
|
||||
|
||||
this.list = new ButtonListWidget(this.minecraft, this.width, this.height, 43, this.height - 29 - this.getTextHeight(), 25);
|
||||
this.list = new ButtonListWidget(this.client, this.width, this.height, 43, this.height - 29 - this.getTextHeight(), 25);
|
||||
// General options
|
||||
this.list.addSingleOptionEntry(new SpruceSeparatorOption("lambdacontrols.menu.title.general", true, null));
|
||||
this.list.addOptionEntry(this.rotationSpeedOption, this.mouseSpeedOption);
|
||||
this.list.addSingleOptionEntry(this.autoSwitchModeOption);
|
||||
// Gameplay options
|
||||
this.list.addSingleOptionEntry(new SpruceSeparatorOption("lambdacontrols.menu.title.gameplay", true, null));
|
||||
this.list.addSingleOptionEntry(this.autoJumpOption);
|
||||
this.list.addOptionEntry(this.fastBlockPlacingOption, this.frontBlockPlacingOption);
|
||||
this.list.addOptionEntry(this.autoJumpOption, this.fastBlockPlacingOption);
|
||||
this.list.addOptionEntry(this.frontBlockPlacingOption, this.verticalReacharoundOption);
|
||||
this.list.addSingleOptionEntry(this.flyDriftingOption);
|
||||
this.list.addSingleOptionEntry(this.flyVerticalDriftingOption);
|
||||
// Controller options
|
||||
@@ -252,27 +260,27 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
this.list.addOptionEntry(this.hudEnableOption, this.hudSideOption);
|
||||
this.children.add(this.list);
|
||||
|
||||
this.gamepadToolUrlLabel = new SpruceLabelWidget(this.width / 2, this.height - 29 - (5 + this.font.fontHeight) * 2, this.controllerMappingsUrlText, this.width,
|
||||
this.gamepadToolUrlLabel = new SpruceLabelWidget(this.width / 2, this.height - 29 - (5 + this.textRenderer.fontHeight) * 2, this.controllerMappingsUrlText, this.width,
|
||||
label -> Util.getOperatingSystem().open(GAMEPAD_TOOL_URL), true);
|
||||
this.gamepadToolUrlLabel.setTooltip(new TranslatableText("chat.link.open"));
|
||||
this.children.add(this.gamepadToolUrlLabel);
|
||||
|
||||
this.addButton(this.resetOption.createButton(this.minecraft.options, this.width / 2 - 155, this.height - 29, 150));
|
||||
this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, buttonHeight, I18n.translate("gui.done"),
|
||||
(buttonWidget) -> this.minecraft.openScreen(this.parent)));
|
||||
this.addButton(this.resetOption.createButton(this.client.options, this.width / 2 - 155, this.height - 29, 150));
|
||||
this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, buttonHeight, new TranslatableText("gui.done"),
|
||||
(buttonWidget) -> this.client.openScreen(this.parent)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float delta)
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
this.renderBackground();
|
||||
this.list.render(mouseX, mouseY, delta);
|
||||
super.render(mouseX, mouseY, delta);
|
||||
this.drawCenteredString(this.font, I18n.translate("lambdacontrols.menu.title"), this.width / 2, 8, 16777215);
|
||||
this.drawCenteredString(this.font, I18n.translate("lambdacontrols.controller.mappings.1", Formatting.GREEN.toString(), Formatting.RESET.toString()), this.width / 2, this.height - 29 - (5 + this.font.fontHeight) * 3, 10526880);
|
||||
this.gamepadToolUrlLabel.render(mouseX, mouseY, delta);
|
||||
this.drawCenteredString(this.font, I18n.translate("lambdacontrols.controller.mappings.3", Formatting.GREEN.toString(), Formatting.RESET.toString()), this.width / 2, this.height - 29 - (5 + this.font.fontHeight), 10526880);
|
||||
this.renderBackground(matrices);
|
||||
this.list.render(matrices, mouseX, mouseY, delta);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
this.drawCenteredString(matrices, this.textRenderer, I18n.translate("lambdacontrols.menu.title"), this.width / 2, 8, 16777215);
|
||||
this.drawCenteredString(matrices, this.textRenderer, I18n.translate("lambdacontrols.controller.mappings.1", Formatting.GREEN.toString(), Formatting.RESET.toString()), this.width / 2, this.height - 29 - (5 + this.textRenderer.fontHeight) * 3, 10526880);
|
||||
this.gamepadToolUrlLabel.render(matrices, mouseX, mouseY, delta);
|
||||
this.drawCenteredString(matrices, this.textRenderer, I18n.translate("lambdacontrols.controller.mappings.3", Formatting.GREEN.toString(), Formatting.RESET.toString()), this.width / 2, this.height - 29 - (5 + this.textRenderer.fontHeight), 10526880);
|
||||
|
||||
Tooltip.renderAll();
|
||||
Tooltip.renderAll(matrices);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ReloadControllerMappingsOption extends Option implements Nameable
|
||||
@Override
|
||||
public AbstractButtonWidget createButton(GameOptions options, int x, int y, int width)
|
||||
{
|
||||
SpruceButtonWidget button = new SpruceButtonWidget(x, y, width, 20, this.getName(), btn -> {
|
||||
SpruceButtonWidget button = new SpruceButtonWidget(x, y, width, 20, new TranslatableText(KEY), btn -> {
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
Controller.updateMappings();
|
||||
if (client.currentScreen != null)
|
||||
|
||||
@@ -70,14 +70,14 @@ public class TouchscreenOverlay extends Screen
|
||||
|
||||
private void pauseGame(boolean bl)
|
||||
{
|
||||
if (this.minecraft == null)
|
||||
if (this.client == null)
|
||||
return;
|
||||
boolean bl2 = this.minecraft.isIntegratedServerRunning() && !this.minecraft.getServer().isRemote();
|
||||
boolean bl2 = this.client.isIntegratedServerRunning() && !this.client.getServer().isRemote();
|
||||
if (bl2) {
|
||||
this.minecraft.openScreen(new GameMenuScreen(!bl));
|
||||
this.minecraft.getSoundManager().pauseAll();
|
||||
this.client.openScreen(new GameMenuScreen(!bl));
|
||||
this.client.getSoundManager().pauseAll();
|
||||
} else {
|
||||
this.minecraft.openScreen(new GameMenuScreen(true));
|
||||
this.client.openScreen(new GameMenuScreen(true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,9 +99,9 @@ public class TouchscreenOverlay extends Screen
|
||||
*/
|
||||
private void updateJumpButtons()
|
||||
{
|
||||
if (this.minecraft == null)
|
||||
if (this.client == null)
|
||||
return;
|
||||
if (this.minecraft.player.abilities.allowFlying && this.minecraft.player.abilities.flying) {
|
||||
if (this.client.player.abilities.allowFlying && this.client.player.abilities.flying) {
|
||||
boolean oldStateFly = this.flyButton.visible;
|
||||
this.jumpButton.visible = false;
|
||||
this.flyButton.visible = true;
|
||||
@@ -128,7 +128,7 @@ public class TouchscreenOverlay extends Screen
|
||||
*/
|
||||
private void handleJump(ButtonWidget btn, boolean state)
|
||||
{
|
||||
((KeyBindingAccessor) this.minecraft.options.keyJump).lambdacontrols_handlePressState(state);
|
||||
((KeyBindingAccessor) this.client.options.keyJump).lambdacontrols_handlePressState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,27 +149,27 @@ public class TouchscreenOverlay extends Screen
|
||||
protected void init()
|
||||
{
|
||||
super.init();
|
||||
int scaledWidth = this.minecraft.getWindow().getScaledWidth();
|
||||
int scaledHeight = this.minecraft.getWindow().getScaledHeight();
|
||||
int scaledWidth = this.client.getWindow().getScaledWidth();
|
||||
int scaledHeight = this.client.getWindow().getScaledHeight();
|
||||
this.addButton(new TexturedButtonWidget(scaledWidth / 2 - 20, 0, 20, 20, 0, 106, 20, ButtonWidget.WIDGETS_LOCATION, 256, 256,
|
||||
btn -> this.minecraft.openScreen(new ChatScreen("")), ""));
|
||||
btn -> this.client.openScreen(new ChatScreen("")), LiteralText.EMPTY));
|
||||
this.addButton(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.minecraft.options.mainArm == Arm.LEFT) {
|
||||
if (this.client.options.mainArm == Arm.LEFT) {
|
||||
inventoryButtonX = inventoryButtonX - 91 - 24;
|
||||
} else {
|
||||
inventoryButtonX = inventoryButtonX + 91 + 4;
|
||||
}
|
||||
this.addButton(new TexturedButtonWidget(inventoryButtonX, inventoryButtonY, 20, 20, 20, 0, 20, WIDGETS_LOCATION, 256, 256,
|
||||
btn -> {
|
||||
if (this.minecraft.interactionManager.hasRidingInventory()) {
|
||||
this.minecraft.player.openRidingInventory();
|
||||
if (this.client.interactionManager.hasRidingInventory()) {
|
||||
this.client.player.openRidingInventory();
|
||||
} else {
|
||||
this.minecraft.getTutorialManager().onInventoryOpened();
|
||||
this.minecraft.openScreen(new InventoryScreen(this.minecraft.player));
|
||||
this.client.getTutorialManager().onInventoryOpened();
|
||||
this.client.openScreen(new InventoryScreen(this.client.player));
|
||||
}
|
||||
}));
|
||||
int jumpButtonX, swapHandsX, sneakButtonX;
|
||||
@@ -187,31 +187,31 @@ public class TouchscreenOverlay extends Screen
|
||||
this.addButton(new SpruceTexturedButtonWidget(swapHandsX, sneakButtonY, 20, 20, 0, 160, 20, WIDGETS_LOCATION,
|
||||
(btn, state) -> {
|
||||
if (state) {
|
||||
if (!this.minecraft.player.isSpectator()) {
|
||||
this.minecraft.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.SWAP_HELD_ITEMS, BlockPos.ORIGIN, Direction.DOWN));
|
||||
if (!this.client.player.isSpectator()) {
|
||||
this.client.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ORIGIN, Direction.DOWN));
|
||||
}
|
||||
}
|
||||
}));
|
||||
// Drop
|
||||
this.addButton(new SpruceTexturedButtonWidget(swapHandsX, sneakButtonY + 5 + 20, 20, 20, 20, 160, 20, WIDGETS_LOCATION,
|
||||
(btn, state) -> ((KeyBindingAccessor) this.minecraft.options.keyDrop).lambdacontrols_handlePressState(state)));
|
||||
(btn, state) -> ((KeyBindingAccessor) this.client.options.keyDrop).lambdacontrols_handlePressState(state)));
|
||||
// Jump keys
|
||||
this.addButton(this.jumpButton = new SpruceTexturedButtonWidget(jumpButtonX, sneakButtonY, 20, 20, 0, 40, 20, WIDGETS_LOCATION,
|
||||
this::handleJump));
|
||||
this.addButton(this.flyButton = new SpruceTexturedButtonWidget(jumpButtonX, sneakButtonY, 20, 20, 20, 40, 20, WIDGETS_LOCATION,
|
||||
(btn, state) -> {
|
||||
if (this.flyButtonEnableTicks == 0) this.minecraft.player.abilities.flying = false;
|
||||
if (this.flyButtonEnableTicks == 0) this.client.player.abilities.flying = false;
|
||||
}));
|
||||
this.addButton(this.flyUpButton = new SpruceTexturedButtonWidget(jumpButtonX, sneakButtonY - 5 - 20, 20, 20, 40, 40, 20, WIDGETS_LOCATION,
|
||||
this::handleJump));
|
||||
this.addButton(this.flyDownButton = new SpruceTexturedButtonWidget(jumpButtonX, sneakButtonY + 20 + 5, 20, 20, 60, 40, 20, WIDGETS_LOCATION,
|
||||
(btn, state) -> ((KeyBindingAccessor) this.minecraft.options.keySneak).lambdacontrols_handlePressState(state)));
|
||||
(btn, state) -> ((KeyBindingAccessor) this.client.options.keySneak).lambdacontrols_handlePressState(state)));
|
||||
this.updateJumpButtons();
|
||||
// Movements keys
|
||||
this.addButton((this.startSneakButton = new SpruceTexturedButtonWidget(sneakButtonX, sneakButtonY, 20, 20, 0, 120, 20, WIDGETS_LOCATION,
|
||||
(btn, state) -> {
|
||||
if (state) {
|
||||
((KeyBindingAccessor) this.minecraft.options.keySneak).lambdacontrols_handlePressState(true);
|
||||
((KeyBindingAccessor) this.client.options.keySneak).lambdacontrols_handlePressState(true);
|
||||
this.startSneakButton.visible = false;
|
||||
this.endSneakButton.visible = true;
|
||||
}
|
||||
@@ -219,7 +219,7 @@ public class TouchscreenOverlay extends Screen
|
||||
this.addButton((this.endSneakButton = new SpruceTexturedButtonWidget(sneakButtonX, sneakButtonY, 20, 20, 20, 120, 20, WIDGETS_LOCATION,
|
||||
(btn, state) -> {
|
||||
if (state) {
|
||||
((KeyBindingAccessor) this.minecraft.options.keySneak).lambdacontrols_handlePressState(false);
|
||||
((KeyBindingAccessor) this.client.options.keySneak).lambdacontrols_handlePressState(false);
|
||||
this.endSneakButton.visible = false;
|
||||
this.startSneakButton.visible = true;
|
||||
}
|
||||
@@ -227,49 +227,49 @@ public class TouchscreenOverlay extends Screen
|
||||
this.endSneakButton.visible = false;
|
||||
this.addButton(this.forwardLeftButton = new SpruceTexturedButtonWidget(sneakButtonX - 20 - 5, sneakButtonY - 5 - 20, 20, 20, 80, 80, 20, WIDGETS_LOCATION,
|
||||
(btn, state) -> {
|
||||
((KeyBindingAccessor) this.minecraft.options.keyForward).lambdacontrols_handlePressState(state);
|
||||
((KeyBindingAccessor) this.minecraft.options.keyLeft).lambdacontrols_handlePressState(state);
|
||||
((KeyBindingAccessor) this.client.options.keyForward).lambdacontrols_handlePressState(state);
|
||||
((KeyBindingAccessor) this.client.options.keyLeft).lambdacontrols_handlePressState(state);
|
||||
this.updateForwardButtonsState(state);
|
||||
}));
|
||||
this.forwardLeftButton.visible = false;
|
||||
this.addButton(new SpruceTexturedButtonWidget(sneakButtonX, sneakButtonY - 5 - 20, 20, 20, 0, 80, 20, WIDGETS_LOCATION,
|
||||
(btn, state) -> {
|
||||
((KeyBindingAccessor) this.minecraft.options.keyForward).lambdacontrols_handlePressState(state);
|
||||
((KeyBindingAccessor) this.client.options.keyForward).lambdacontrols_handlePressState(state);
|
||||
this.updateForwardButtonsState(state);
|
||||
this.forwardLeftButton.visible = true;
|
||||
this.forwardRightButton.visible = true;
|
||||
}));
|
||||
this.addButton(this.forwardRightButton = new SpruceTexturedButtonWidget(sneakButtonX + 20 + 5, sneakButtonY - 5 - 20, 20, 20, 100, 80, 20, WIDGETS_LOCATION,
|
||||
(btn, state) -> {
|
||||
((KeyBindingAccessor) this.minecraft.options.keyForward).lambdacontrols_handlePressState(state);
|
||||
((KeyBindingAccessor) this.minecraft.options.keyRight).lambdacontrols_handlePressState(state);
|
||||
((KeyBindingAccessor) this.client.options.keyForward).lambdacontrols_handlePressState(state);
|
||||
((KeyBindingAccessor) this.client.options.keyRight).lambdacontrols_handlePressState(state);
|
||||
this.updateForwardButtonsState(state);
|
||||
}));
|
||||
this.forwardRightButton.visible = true;
|
||||
this.addButton(new SpruceTexturedButtonWidget(sneakButtonX + 20 + 5, sneakButtonY, 20, 20, 20, 80, 20, WIDGETS_LOCATION,
|
||||
(btn, state) -> ((KeyBindingAccessor) this.minecraft.options.keyRight).lambdacontrols_handlePressState(state)));
|
||||
(btn, state) -> ((KeyBindingAccessor) this.client.options.keyRight).lambdacontrols_handlePressState(state)));
|
||||
this.addButton(new SpruceTexturedButtonWidget(sneakButtonX, sneakButtonY + 20 + 5, 20, 20, 40, 80, 20, WIDGETS_LOCATION,
|
||||
(btn, state) -> ((KeyBindingAccessor) this.minecraft.options.keyBack).lambdacontrols_handlePressState(state)));
|
||||
(btn, state) -> ((KeyBindingAccessor) this.client.options.keyBack).lambdacontrols_handlePressState(state)));
|
||||
this.addButton(new SpruceTexturedButtonWidget(sneakButtonX - 20 - 5, sneakButtonY, 20, 20, 60, 80, 20, WIDGETS_LOCATION,
|
||||
(btn, state) -> ((KeyBindingAccessor) this.minecraft.options.keyLeft).lambdacontrols_handlePressState(state)));
|
||||
}
|
||||
(btn, state) -> ((KeyBindingAccessor) this.client.options.keyLeft).lambdacontrols_handlePressState(state)));
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float delta)
|
||||
{
|
||||
super.render(mouseX, mouseY, delta);
|
||||
this.buttons.forEach(button -> {
|
||||
if (button instanceof SpruceTexturedButtonWidget) {
|
||||
((SpruceTexturedButtonWidget) button).setSilent(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button)
|
||||
{
|
||||
if (mouseY >= (double) (this.height - 22) && this.minecraft != null && this.minecraft.player != null) {
|
||||
if (mouseY >= (double) (this.height - 22) && this.client != null && this.client.player != null) {
|
||||
int centerX = this.width / 2;
|
||||
if (mouseX >= (double) (centerX - 90) && mouseX <= (double) (centerX + 90)) {
|
||||
for (int slot = 0; slot < 9; ++slot) {
|
||||
int slotX = centerX - 90 + slot * 20 + 2;
|
||||
if (mouseX >= (double) slotX && mouseX <= (double) (slotX + 20)) {
|
||||
this.minecraft.player.inventory.selectedSlot = slot;
|
||||
this.client.player.inventory.selectedSlot = slot;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -281,16 +281,16 @@ public class TouchscreenOverlay extends Screen
|
||||
@Override
|
||||
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY)
|
||||
{
|
||||
if (button == GLFW.GLFW_MOUSE_BUTTON_1 && this.minecraft != null) {
|
||||
if (button == GLFW.GLFW_MOUSE_BUTTON_1 && this.client != null) {
|
||||
if (deltaY > 0.01)
|
||||
this.mod.input.handleLook(this.minecraft, GLFW_GAMEPAD_AXIS_RIGHT_Y, (float) Math.abs(deltaY / 5.0), 2);
|
||||
this.mod.input.handleLook(this.client, GLFW_GAMEPAD_AXIS_RIGHT_Y, (float) Math.abs(deltaY / 5.0), 2);
|
||||
else if (deltaY < 0.01)
|
||||
this.mod.input.handleLook(this.minecraft, GLFW_GAMEPAD_AXIS_RIGHT_Y, (float) Math.abs(deltaY / 5.0), 1);
|
||||
this.mod.input.handleLook(this.client, GLFW_GAMEPAD_AXIS_RIGHT_Y, (float) Math.abs(deltaY / 5.0), 1);
|
||||
|
||||
if (deltaX > 0.01)
|
||||
this.mod.input.handleLook(this.minecraft, GLFW_GAMEPAD_AXIS_RIGHT_X, (float) Math.abs(deltaX / 5.0), 2);
|
||||
this.mod.input.handleLook(this.client, GLFW_GAMEPAD_AXIS_RIGHT_X, (float) Math.abs(deltaX / 5.0), 2);
|
||||
else if (deltaX < 0.01)
|
||||
this.mod.input.handleLook(this.minecraft, GLFW_GAMEPAD_AXIS_RIGHT_X, (float) Math.abs(deltaX / 5.0), 1);
|
||||
this.mod.input.handleLook(this.client, GLFW_GAMEPAD_AXIS_RIGHT_X, (float) Math.abs(deltaX / 5.0), 1);
|
||||
}
|
||||
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.options.GameOptions;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -40,7 +41,7 @@ public class ControlsOptionsScreenMixin extends GameOptionsScreen
|
||||
if (this.parent instanceof ControllerControlsScreen)
|
||||
return this.addButton(btn);
|
||||
else
|
||||
return this.addButton(new ButtonWidget(btn.x, btn.y, btn.getWidth(), ((AbstractButtonWidgetAccessor) btn).getHeight(), I18n.translate("menu.options"),
|
||||
b -> this.minecraft.openScreen(new LambdaControlsSettingsScreen(this, true))));
|
||||
return this.addButton(new ButtonWidget(btn.x, btn.y, btn.getWidth(), ((AbstractButtonWidgetAccessor) btn).getHeight(), new TranslatableText("menu.options"),
|
||||
b -> this.client.openScreen(new LambdaControlsSettingsScreen(this, true))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
package me.lambdaurora.lambdacontrols.client.mixin;
|
||||
|
||||
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
|
||||
import net.minecraft.container.Slot;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@@ -17,5 +17,5 @@ import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
public interface EntryListWidgetAccessor
|
||||
{
|
||||
@Invoker("moveSelection")
|
||||
void lambdacontrols_moveSelection(int amount);
|
||||
void lambdacontrols_moveSelection(EntryListWidget.class_5403 direction);
|
||||
}
|
||||
|
||||
@@ -13,24 +13,29 @@ import me.lambdaurora.lambdacontrols.ControlsMode;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import me.lambdaurora.lambdacontrols.client.compat.LambdaControlsCompat;
|
||||
import me.lambdaurora.lambdacontrols.client.gui.LambdaControlsRenderer;
|
||||
import me.lambdaurora.lambdacontrols.client.util.ContainerScreenAccessor;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import me.lambdaurora.lambdacontrols.client.util.HandledScreenAccessor;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.ingame.ContainerScreen;
|
||||
import net.minecraft.container.Slot;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.screen.slot.SlotActionType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Represents the mixin for the class ContainerScreen.
|
||||
*/
|
||||
@Mixin(ContainerScreen.class)
|
||||
public abstract class ContainerScreenMixin implements ContainerScreenAccessor
|
||||
@Mixin(HandledScreen.class)
|
||||
public abstract class HandledScreenMixin implements HandledScreenAccessor
|
||||
{
|
||||
@Accessor("x")
|
||||
public abstract int getX();
|
||||
@@ -41,21 +46,27 @@ public abstract class ContainerScreenMixin implements ContainerScreenAccessor
|
||||
@Invoker("getSlotAt")
|
||||
public abstract Slot lambdacontrols_getSlotAt(double posX, double posY);
|
||||
|
||||
@Invoker("isClickOutsideBounds")
|
||||
public abstract boolean lambdacontrols_isClickOutsideBounds(double mouseX, double mouseY, int x, int y, int button);
|
||||
|
||||
@Invoker("onMouseClick")
|
||||
public abstract void lambdacontrols_onMouseClick(@Nullable Slot slot, int slotId, int clickData, SlotActionType actionType);
|
||||
|
||||
@Inject(method = "render", at = @At("RETURN"))
|
||||
public void onRender(int mouseX, int mouseY, float delta, CallbackInfo ci)
|
||||
public void onRender(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci)
|
||||
{
|
||||
if (LambdaControlsClient.get().config.getControlsMode() == ControlsMode.CONTROLLER) {
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
int x = 2, y = client.getWindow().getScaledHeight() - 2 - LambdaControlsRenderer.ICON_SIZE;
|
||||
|
||||
x = LambdaControlsRenderer.drawButtonTip(x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_A}, "lambdacontrols.action.pickup_all", true, client) + 2;
|
||||
x = LambdaControlsRenderer.drawButtonTip(x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_B}, "lambdacontrols.action.exit", true, client) + 2;
|
||||
x = LambdaControlsRenderer.drawButtonTip(matrices, x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_A}, "lambdacontrols.action.pickup_all", true, client) + 2;
|
||||
x = LambdaControlsRenderer.drawButtonTip(matrices, x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_B}, "lambdacontrols.action.exit", true, client) + 2;
|
||||
if (LambdaControlsCompat.isReiPresent()) {
|
||||
x = 2;
|
||||
y -= 24;
|
||||
}
|
||||
x = LambdaControlsRenderer.drawButtonTip(x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_X}, "lambdacontrols.action.pickup", true, client) + 2;
|
||||
LambdaControlsRenderer.drawButtonTip(x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_Y}, "lambdacontrols.action.quick_move", true, client);
|
||||
x = LambdaControlsRenderer.drawButtonTip(matrices, x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_X}, "lambdacontrols.action.pickup", true, client) + 2;
|
||||
LambdaControlsRenderer.drawButtonTip(matrices, x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_Y}, "lambdacontrols.action.quick_move", true, client);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,8 @@ package me.lambdaurora.lambdacontrols.client.mixin;
|
||||
|
||||
import me.lambdaurora.lambdacontrols.LambdaControlsFeature;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaInput;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaReacharound;
|
||||
import me.lambdaurora.lambdacontrols.client.gui.LambdaControlsRenderer;
|
||||
import me.lambdaurora.lambdacontrols.client.util.FrontBlockPlaceResultAccessor;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
@@ -40,7 +39,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
public abstract class MinecraftClientMixin implements FrontBlockPlaceResultAccessor
|
||||
public abstract class MinecraftClientMixin
|
||||
{
|
||||
@Shadow
|
||||
@Nullable
|
||||
@@ -65,18 +64,10 @@ public abstract class MinecraftClientMixin implements FrontBlockPlaceResultAcces
|
||||
@Shadow
|
||||
private int itemUseCooldown;
|
||||
|
||||
private BlockHitResult lambdacontrols_frontBlockPlaceResult = null;
|
||||
|
||||
private BlockPos lambdacontrols_lastTargetPos;
|
||||
private Vec3d lambdacontrols_lastPos;
|
||||
private Direction lambdacontrols_lastTargetSide;
|
||||
|
||||
@Override
|
||||
public @Nullable BlockHitResult lambdacontrols_getFrontBlockPlaceResult()
|
||||
{
|
||||
return this.lambdacontrols_frontBlockPlaceResult;
|
||||
}
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void onInit(CallbackInfo ci)
|
||||
{
|
||||
@@ -88,7 +79,7 @@ public abstract class MinecraftClientMixin implements FrontBlockPlaceResultAcces
|
||||
{
|
||||
if (this.player == null)
|
||||
return;
|
||||
this.lambdacontrols_frontBlockPlaceResult = LambdaInput.tryFrontPlace(((MinecraftClient) (Object) this));
|
||||
|
||||
if (!LambdaControlsFeature.FAST_BLOCK_PLACING.isAvailable())
|
||||
return;
|
||||
if (this.lambdacontrols_lastPos == null)
|
||||
@@ -131,7 +122,8 @@ public abstract class MinecraftClientMixin implements FrontBlockPlaceResultAcces
|
||||
}
|
||||
|
||||
@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) {
|
||||
private void renderVirtualCursor(boolean fullRender, CallbackInfo ci)
|
||||
{
|
||||
LambdaControlsRenderer.renderVirtualCursor(new MatrixStack(), (MinecraftClient) (Object) this);
|
||||
}
|
||||
|
||||
@@ -144,15 +136,15 @@ public abstract class MinecraftClientMixin implements FrontBlockPlaceResultAcces
|
||||
@Inject(method = "doItemUse()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/hit/HitResult;getType()Lnet/minecraft/util/hit/HitResult$Type;"), locals = LocalCapture.CAPTURE_FAILEXCEPTION, cancellable = true)
|
||||
private void onItemUse(CallbackInfo ci, Hand[] hands, int handCount, int handIndex, Hand hand, ItemStack stackInHand)
|
||||
{
|
||||
if (!stackInHand.isEmpty() && this.player.pitch > 35.0F && LambdaControlsFeature.FRONT_BLOCK_PLACING.isAvailable()) {
|
||||
if (this.crosshairTarget != null && this.crosshairTarget.getType() == HitResult.Type.MISS && this.player.onGround) {
|
||||
if (!stackInHand.isEmpty() && this.player.pitch > 35.0F && LambdaControlsClient.get().reacharound.isReacharoundAvailable()) {
|
||||
if (this.crosshairTarget != null && this.crosshairTarget.getType() == HitResult.Type.MISS && this.player.isOnGround()) {
|
||||
if (!stackInHand.isEmpty() && stackInHand.getItem() instanceof BlockItem) {
|
||||
BlockHitResult hitResult = LambdaInput.tryFrontPlace(((MinecraftClient) (Object) this));
|
||||
BlockHitResult hitResult = LambdaControlsClient.get().reacharound.getLastReacharoundResult();
|
||||
|
||||
if (hitResult == null)
|
||||
return;
|
||||
|
||||
hitResult = LambdaInput.withSideForFrontPlace(hitResult, stackInHand);
|
||||
hitResult = LambdaReacharound.withSideForReacharound(hitResult, stackInHand);
|
||||
|
||||
int previousStackCount = stackInHand.getCount();
|
||||
ActionResult result = this.interactionManager.interactBlock(this.player, this.world, hand, hitResult);
|
||||
|
||||
@@ -13,12 +13,16 @@ import me.lambdaurora.lambdacontrols.ControlsMode;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsConfig;
|
||||
import me.lambdaurora.lambdacontrols.client.util.MouseAccessor;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.Mouse;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
/**
|
||||
* Adds extra access to the mouse.
|
||||
@@ -26,14 +30,31 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(Mouse.class)
|
||||
public abstract class MouseMixin implements MouseAccessor
|
||||
{
|
||||
@Shadow
|
||||
@Final
|
||||
private MinecraftClient client;
|
||||
|
||||
@Invoker("onCursorPos")
|
||||
public abstract void lambdacontrols_onCursorPos(long window, double x, double y);
|
||||
|
||||
@Inject(method = "isCursorLocked", at = @At("HEAD"), cancellable = true)
|
||||
private void isCursorLocked(CallbackInfoReturnable<Boolean> ci)
|
||||
{
|
||||
if (client.currentScreen == null) {
|
||||
LambdaControlsConfig config = LambdaControlsClient.get().config;
|
||||
if (config.getControlsMode() == ControlsMode.CONTROLLER && config.hasVirtualMouse()) {
|
||||
ci.setReturnValue(true);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "lockCursor", at = @At("HEAD"), cancellable = true)
|
||||
private void onMouseLocked(CallbackInfo ci)
|
||||
private void onCursorLocked(CallbackInfo ci)
|
||||
{
|
||||
LambdaControlsConfig config = LambdaControlsClient.get().config;
|
||||
if (config.getControlsMode() == ControlsMode.TOUCHSCREEN || config.hasVirtualMouse())
|
||||
if (config.getControlsMode() == ControlsMode.TOUCHSCREEN
|
||||
|| (config.getControlsMode() == ControlsMode.CONTROLLER && config.hasVirtualMouse()))
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import me.lambdaurora.lambdacontrols.ControlsMode;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import me.lambdaurora.lambdacontrols.client.gui.ControllerControlsScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.SettingsScreen;
|
||||
import net.minecraft.client.gui.screen.options.OptionsScreen;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.text.Text;
|
||||
@@ -24,20 +24,20 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
/**
|
||||
* Injects the new controls settings button.
|
||||
*/
|
||||
@Mixin(SettingsScreen.class)
|
||||
public class SettingsScreenMixin extends Screen
|
||||
@Mixin(OptionsScreen.class)
|
||||
public class OptionsScreenMixin extends Screen
|
||||
{
|
||||
protected SettingsScreenMixin(Text title)
|
||||
protected OptionsScreenMixin(Text title)
|
||||
{
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Redirect(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/SettingsScreen;addButton(Lnet/minecraft/client/gui/widget/AbstractButtonWidget;)Lnet/minecraft/client/gui/widget/AbstractButtonWidget;", ordinal = 7))
|
||||
private AbstractButtonWidget lambdacontrols_onInit(SettingsScreen screen, AbstractButtonWidget btn)
|
||||
@Redirect(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/options/OptionsScreen;addButton(Lnet/minecraft/client/gui/widget/AbstractButtonWidget;)Lnet/minecraft/client/gui/widget/AbstractButtonWidget;", ordinal = 7))
|
||||
private AbstractButtonWidget lambdacontrols_onInit(OptionsScreen screen, AbstractButtonWidget btn)
|
||||
{
|
||||
if (LambdaControlsClient.get().config.getControlsMode() == ControlsMode.CONTROLLER) {
|
||||
return this.addButton(new ButtonWidget(btn.x, btn.y, btn.getWidth(), ((AbstractButtonWidgetAccessor) btn).getHeight(), btn.getMessage(),
|
||||
b -> this.minecraft.openScreen(new ControllerControlsScreen(this, false))));
|
||||
b -> this.client.openScreen(new ControllerControlsScreen(this, false))));
|
||||
} else {
|
||||
return this.addButton(btn);
|
||||
}
|
||||
@@ -10,16 +10,14 @@
|
||||
package me.lambdaurora.lambdacontrols.client.mixin;
|
||||
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaInput;
|
||||
import me.lambdaurora.lambdacontrols.client.util.FrontBlockPlaceResultAccessor;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaReacharound;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.util.math.Matrix4f;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.EntityContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -28,6 +26,7 @@ import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
@@ -74,9 +73,9 @@ public abstract class WorldRendererMixin
|
||||
Profiler profiler, Vec3d cameraPos, double x, double y, double z, Matrix4f modelMatrix, boolean bl, Frustum frustum2, boolean bl3,
|
||||
VertexConsumerProvider.Immediate immediate)
|
||||
{
|
||||
if (this.client.crosshairTarget == null || this.client.crosshairTarget.getType() != HitResult.Type.MISS || !LambdaControlsClient.get().config.shouldRenderFrontBlockOutline())
|
||||
if (this.client.crosshairTarget == null || this.client.crosshairTarget.getType() != HitResult.Type.MISS || !LambdaControlsClient.get().config.shouldRenderReacharoundOutline())
|
||||
return;
|
||||
BlockHitResult result = ((FrontBlockPlaceResultAccessor) client).lambdacontrols_getFrontBlockPlaceResult();
|
||||
BlockHitResult result = LambdaControlsClient.get().reacharound.getLastReacharoundResult();
|
||||
if (result == null)
|
||||
return;
|
||||
BlockPos blockPos = result.getBlockPos();
|
||||
@@ -85,14 +84,14 @@ public abstract class WorldRendererMixin
|
||||
if (stack == null || !(stack.getItem() instanceof BlockItem))
|
||||
return;
|
||||
Block block = ((BlockItem) stack.getItem()).getBlock();
|
||||
result = LambdaInput.withSideForFrontPlace(result, block);
|
||||
result = LambdaReacharound.withSideForReacharound(result, block);
|
||||
ItemPlacementContext context = new ItemPlacementContext(new ItemUsageContext(this.client.player, Hand.MAIN_HAND, result));
|
||||
VertexConsumer vertexConsumer = immediate.getBuffer(RenderLayer.getLines());
|
||||
BlockState placementState = block.getPlacementState(context);
|
||||
if (placementState == null)
|
||||
return;
|
||||
VoxelShape outlineShape = placementState.getOutlineShape(this.client.world, blockPos, EntityContext.of(camera.getFocusedEntity()));
|
||||
int[] color = LambdaControlsClient.get().config.getFrontBlockOutlineColor();
|
||||
VoxelShape outlineShape = placementState.getOutlineShape(this.client.world, blockPos, ShapeContext.of(camera.getFocusedEntity()));
|
||||
int[] color = LambdaControlsClient.get().config.getReacharoundOutlineColor();
|
||||
drawShapeOutline(matrices, vertexConsumer, outlineShape, (double) blockPos.getX() - x, (double) blockPos.getY() - y, (double) blockPos.getZ() - z, color[0] / 255.f, color[1] / 255.f, color[2] / 255.f, color[3] / 255.f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright © 2020 LambdAurora <aurora42lambda@gmail.com>
|
||||
*
|
||||
* This file is part of LambdaControls.
|
||||
*
|
||||
* Licensed under the MIT license. For more information,
|
||||
* see the LICENSE file.
|
||||
*/
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client.ring;
|
||||
|
||||
/**
|
||||
* Represents a key binding ring.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.4.0
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public class KeyBindingRing
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2020 LambdAurora <aurora42lambda@gmail.com>
|
||||
*
|
||||
* This file is part of LambdaControls.
|
||||
*
|
||||
* Licensed under the MIT license. For more information,
|
||||
* see the LICENSE file.
|
||||
*/
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client.util;
|
||||
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents an accessor of the BlockHitResult for the front block placing feature.
|
||||
* <p>
|
||||
* It is implemented by {@link net.minecraft.client.MinecraftClient}.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.2.0
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public interface FrontBlockPlaceResultAccessor
|
||||
{
|
||||
/**
|
||||
* Returns the {@link BlockHitResult} if a block can be placed with the front block placing feature.
|
||||
*
|
||||
* @return If possible a {@link BlockHitResult}, else a null value.
|
||||
*/
|
||||
@Nullable BlockHitResult lambdacontrols_getFrontBlockPlaceResult();
|
||||
}
|
||||
@@ -9,12 +9,14 @@
|
||||
|
||||
package me.lambdaurora.lambdacontrols.client.util;
|
||||
|
||||
import net.minecraft.container.Slot;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.screen.slot.SlotActionType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents an accessor to AbstractContainerScreen.
|
||||
*/
|
||||
public interface ContainerScreenAccessor
|
||||
public interface HandledScreenAccessor
|
||||
{
|
||||
/**
|
||||
* Gets the left coordinate of the GUI.
|
||||
@@ -38,4 +40,16 @@ public interface ContainerScreenAccessor
|
||||
* @return The slot at the specified position.
|
||||
*/
|
||||
Slot lambdacontrols_getSlotAt(double pos_x, double pos_y);
|
||||
|
||||
boolean lambdacontrols_isClickOutsideBounds(double mouseX, double mouseY, int x, int y, int button);
|
||||
|
||||
/**
|
||||
* Handles a mouse click on the specified slot.
|
||||
*
|
||||
* @param slot The slot instance.
|
||||
* @param slotId The slot id.
|
||||
* @param clickData The click data.
|
||||
* @param actionType The action type.
|
||||
*/
|
||||
void lambdacontrols_onMouseClick(@Nullable Slot slot, int slotId, int clickData, SlotActionType actionType);
|
||||
}
|
||||
@@ -60,7 +60,6 @@
|
||||
"lambdacontrols.controller.connected": "Controller %d connected.",
|
||||
"lambdacontrols.controller.disconnected": "Controller %d disconnected.",
|
||||
"lambdacontrols.controller.mappings.1": "To configure the controller mappings, please use %sSDL2 Gamepad Tool%s",
|
||||
"lambdacontrols.controller.mappings.2": "(%s%s%s),",
|
||||
"lambdacontrols.controller.mappings.3": "and put the mapping in `%s.minecraft/config/gamecontrollerdb.txt%s`.",
|
||||
"lambdacontrols.controller.mappings.updated": "Updated mappings!",
|
||||
"lambdacontrols.controller_type.default": "default",
|
||||
@@ -83,13 +82,14 @@
|
||||
"lambdacontrols.menu.fast_block_placing": "Fast Block Placing",
|
||||
"lambdacontrols.menu.fly_drifting": "Fly Drifting",
|
||||
"lambdacontrols.menu.fly_drifting_vertical": "Vertical Fly Drifting",
|
||||
"lambdacontrols.menu.front_block_placing": "Front Block Placing",
|
||||
"lambdacontrols.menu.hud_enable": "Enable HUD",
|
||||
"lambdacontrols.menu.hud_side": "HUD Side",
|
||||
"lambdacontrols.menu.invert_right_x_axis": "Invert Right X",
|
||||
"lambdacontrols.menu.invert_right_y_axis": "Invert Right Y",
|
||||
"lambdacontrols.menu.keyboard_controls": "Keyboard Controls...",
|
||||
"lambdacontrols.menu.mouse_speed": "Mouse Speed",
|
||||
"lambdacontrols.menu.reacharound.horizontal": "Front Block Placing",
|
||||
"lambdacontrols.menu.reacharound.vertical": "Vertical Reacharound",
|
||||
"lambdacontrols.menu.reload_controller_mappings": "Reload Controller Mappings",
|
||||
"lambdacontrols.menu.rotation_speed": "Rotation Speed",
|
||||
"lambdacontrols.menu.title": "LambdaControls - Settings",
|
||||
@@ -112,12 +112,13 @@
|
||||
"lambdacontrols.tooltip.fast_block_placing": "While flying in creative mode, enables fast block placing depending on your speed. §cOn some servers this might be considered as cheating.",
|
||||
"lambdacontrols.tooltip.fly_drifting": "While flying, enables Vanilla drifting/inertia.",
|
||||
"lambdacontrols.tooltip.fly_drifting_vertical": "While flying, enables Vanilla vertical drifting/intertia.",
|
||||
"lambdacontrols.tooltip.front_block_placing": "Enables front block placing, §cmight be considered cheating on some servers§r.",
|
||||
"lambdacontrols.tooltip.hud_enable": "Toggles the on-screen controller button indicator.",
|
||||
"lambdacontrols.tooltip.hud_side": "The position of the HUD.",
|
||||
"lambdacontrols.tooltip.mouse_speed": "The controller's emulated mouse speed.",
|
||||
"lambdacontrols.tooltip.rotation_speed": "The camera rotation speed in controller mode.",
|
||||
"lambdacontrols.tooltip.reacharound.horizontal": "Enables front block placing, §cmight be considered cheating on some servers§r.",
|
||||
"lambdacontrols.tooltip.reacharound.vertical": "Enables vertical reacharound, §cmight be considered cheating on some servers§r.",
|
||||
"lambdacontrols.tooltip.reload_controller_mappings": "Reloads the controller mappings file.",
|
||||
"lambdacontrols.tooltip.rotation_speed": "The camera rotation speed in controller mode.",
|
||||
"lambdacontrols.tooltip.unfocused_input": "Allow controller input when the window is not focused.",
|
||||
"lambdacontrols.tooltip.virtual_mouse": "Enable the virtual mouse which is handful in the case of a splitscreen.",
|
||||
"lambdacontrols.virtual_mouse.skin.default_light": "Default Light",
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
"lambdacontrols.controller.connected": "Manette %d connecté.",
|
||||
"lambdacontrols.controller.disconnected": "Manette %d déconnecté.",
|
||||
"lambdacontrols.controller.mappings.1": "Pour configurer les correspondances de la manette, veuillez utiliser %sSDL2 Gamepad Tool%s",
|
||||
"lambdacontrols.controller.mappings.2": "(%s%s%s),",
|
||||
"lambdacontrols.controller.mappings.3": "et mettez les correspondances dans le fichier `%s.minecraft/config/gamecontrollerdb.txt%s`.",
|
||||
"lambdacontrols.controller.mappings.updated": "Configuration des manettes mise à jour!",
|
||||
"lambdacontrols.controller_type.default": "default",
|
||||
@@ -82,13 +81,14 @@
|
||||
"lambdacontrols.menu.dead_zone": "Zone morte",
|
||||
"lambdacontrols.menu.fly_drifting": "Inertie de vol",
|
||||
"lambdacontrols.menu.fly_drifting_vertical": "Inertie verticale de vol",
|
||||
"lambdacontrols.menu.front_block_placing": "Placement avant de bloc",
|
||||
"lambdacontrols.menu.hud_enable": "Activer le HUD",
|
||||
"lambdacontrols.menu.hud_side": "Côté du HUD",
|
||||
"lambdacontrols.menu.invert_right_x_axis": "Inverser le stick droit (X)",
|
||||
"lambdacontrols.menu.invert_right_y_axis": "Inverser le stick droit (Y)",
|
||||
"lambdacontrols.menu.keyboard_controls": "Contrôles clavier...",
|
||||
"lambdacontrols.menu.mouse_speed": "Vitesse de la souris",
|
||||
"lambdacontrols.menu.reacharound.horizontal": "Placement avant de bloc",
|
||||
"lambdacontrols.menu.reacharound.vertical": "Placement vertical",
|
||||
"lambdacontrols.menu.reload_controller_mappings": "Recharge la configuration des manettes",
|
||||
"lambdacontrols.menu.rotation_speed": "Vitesse de rotation",
|
||||
"lambdacontrols.menu.title": "LambdaControls - Paramètres",
|
||||
@@ -108,14 +108,16 @@
|
||||
"lambdacontrols.tooltip.controller_type": "Le type de contrôle n'influe que sur les boutons affichés.",
|
||||
"lambdacontrols.tooltip.controls_mode": "Change le mode de contrôle.",
|
||||
"lambdacontrols.tooltip.dead_zone": "Zone morte des axes de la manette.",
|
||||
"lambdacontrols.tooltip.fast_block_placing": "Active le placement rapide de blocs en vol.",
|
||||
"lambdacontrols.tooltip.fly_drifting": "Pendant que le joueur vole, active le glissement Vanilla.",
|
||||
"lambdacontrols.tooltip.fly_drifting_vertical": "Pendant que le joueur vole, active le glissement vertical Vanilla.",
|
||||
"lambdacontrols.tooltip.front_block_placing": "Active le placement avant de blocs, §cpeut être considérer comme de la trice sur certains serveurs§r.",
|
||||
"lambdacontrols.tooltip.hud_enable": "Détermine si l'indicateur des buttons de la manette doit être affiché ou non.",
|
||||
"lambdacontrols.tooltip.hud_side": "Change la position du HUD.",
|
||||
"lambdacontrols.tooltip.mouse_speed": "Change la vitesse de la souris émulée par la manette.",
|
||||
"lambdacontrols.tooltip.rotation_speed": "Change la vitesse de rotation de la caméra.",
|
||||
"lambdacontrols.tooltip.reacharound.horizontal": "Active le placement avant de blocs, §cpeut être considérer comme de la triche sur certains serveurs§r.",
|
||||
"lambdacontrols.tooltip.reacharound.vertical": "Active le placement vertical de blocs, c'est-à-dire de blocs en dessous du bloc sur lequel vous êtes placé, §cpeut être considérer comme de la triche sur certains serveurs§r.",
|
||||
"lambdacontrols.tooltip.reload_controller_mappings": "Recharge le fichier de configuration des manettes.",
|
||||
"lambdacontrols.tooltip.rotation_speed": "Change la vitesse de rotation de la caméra.",
|
||||
"lambdacontrols.tooltip.unfocused_input": "Autorise les entrées manette quand la fenêtre n'est pas sélectionnée.",
|
||||
"lambdacontrols.tooltip.virtual_mouse": "Active la souris virtuelle qui est pratique dans le cas d'un écran partagé.",
|
||||
"lambdacontrols.virtual_mouse.skin.default_light": "défaut clair",
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
"lambdacontrols.controller.connected": "Manette %d connecté.",
|
||||
"lambdacontrols.controller.disconnected": "Manette %d déconnecté.",
|
||||
"lambdacontrols.controller.mappings.1": "Pour configurer les correspondances de la manette, veuillez utiliser %sSDL2 Gamepad Tool%s",
|
||||
"lambdacontrols.controller.mappings.2": "(%s%s%s),",
|
||||
"lambdacontrols.controller.mappings.3": "et mettez les correspondances dans le fichier `%s.minecraft/config/gamecontrollerdb.txt%s`.",
|
||||
"lambdacontrols.controller.mappings.updated": "Configuration des manettes mise à jour!",
|
||||
"lambdacontrols.controller_type.default": "default",
|
||||
@@ -82,13 +81,14 @@
|
||||
"lambdacontrols.menu.dead_zone": "Zone morte",
|
||||
"lambdacontrols.menu.fly_drifting": "Inertie de vol",
|
||||
"lambdacontrols.menu.fly_drifting_vertical": "Inertie verticale de vol",
|
||||
"lambdacontrols.menu.front_block_placing": "Placement avant de bloc",
|
||||
"lambdacontrols.menu.hud_enable": "Activer le HUD",
|
||||
"lambdacontrols.menu.hud_side": "Côté du HUD",
|
||||
"lambdacontrols.menu.invert_right_x_axis": "Inverser le stick droit (X)",
|
||||
"lambdacontrols.menu.invert_right_y_axis": "Inverser le stick droit (Y)",
|
||||
"lambdacontrols.menu.keyboard_controls": "Contrôles clavier...",
|
||||
"lambdacontrols.menu.mouse_speed": "Vitesse de la souris",
|
||||
"lambdacontrols.menu.reacharound.horizontal": "Placement avant de bloc",
|
||||
"lambdacontrols.menu.reacharound.vertical": "Placement vertical",
|
||||
"lambdacontrols.menu.reload_controller_mappings": "Recharge la configuration des manettes",
|
||||
"lambdacontrols.menu.rotation_speed": "Vitesse de rotation",
|
||||
"lambdacontrols.menu.title": "LambdaControls - Paramètres",
|
||||
@@ -108,14 +108,16 @@
|
||||
"lambdacontrols.tooltip.controller_type": "Le type de contrôle n'influe que sur les boutons affichés.",
|
||||
"lambdacontrols.tooltip.controls_mode": "Change le mode de contrôle.",
|
||||
"lambdacontrols.tooltip.dead_zone": "Zone morte des axes de la manette.",
|
||||
"lambdacontrols.tooltip.fast_block_placing": "Active le placement rapide de blocs en vol.",
|
||||
"lambdacontrols.tooltip.fly_drifting": "Pendant que le joueur vole, active le glissement Vanilla.",
|
||||
"lambdacontrols.tooltip.fly_drifting_vertical": "Pendant que le joueur vole, active le glissement vertical Vanilla.",
|
||||
"lambdacontrols.tooltip.front_block_placing": "Active le placement avant de blocs, §cpeut être considérer comme de la trice sur certains serveurs§r.",
|
||||
"lambdacontrols.tooltip.hud_enable": "Détermine si l'indicateur des buttons de la manette doit être affiché ou non.",
|
||||
"lambdacontrols.tooltip.hud_side": "Change la position du HUD.",
|
||||
"lambdacontrols.tooltip.mouse_speed": "Change la vitesse de la souris émulée par la manette.",
|
||||
"lambdacontrols.tooltip.rotation_speed": "Change la vitesse de rotation de la caméra.",
|
||||
"lambdacontrols.tooltip.reacharound.horizontal": "Active le placement avant de blocs, §cpeut être considérer comme de la triche sur certains serveurs§r.",
|
||||
"lambdacontrols.tooltip.reacharound.vertical": "Active le placement vertical de blocs, c'est-à-dire de blocs en dessous du bloc sur lequel vous êtes placé, §cpeut être considérer comme de la triche sur certains serveurs§r.",
|
||||
"lambdacontrols.tooltip.reload_controller_mappings": "Recharge le fichier de configuration des manettes.",
|
||||
"lambdacontrols.tooltip.rotation_speed": "Change la vitesse de rotation de la caméra.",
|
||||
"lambdacontrols.tooltip.unfocused_input": "Autorise les entrées manette quand la fenêtre n'est pas sélectionnée.",
|
||||
"lambdacontrols.tooltip.virtual_mouse": "Active la souris virtuelle qui est pratique dans le cas d'un écran partagé.",
|
||||
"lambdacontrols.virtual_mouse.skin.default_light": "défaut clair",
|
||||
|
||||
@@ -21,9 +21,11 @@ auto_switch_mode = false
|
||||
drifting = false
|
||||
# Enables vertical fly drifting.
|
||||
vertical_drifting = true
|
||||
[gameplay.front_block_placing]
|
||||
[gameplay.reacharound]
|
||||
# Enables front block placing like in Bedrock Edition.
|
||||
enabled = false
|
||||
horizontal = false
|
||||
# Enables vertical reacharound.
|
||||
vertical = false
|
||||
# Enables front block placing outline.
|
||||
outline = true
|
||||
# The color in a hexadecimal format of the outline.
|
||||
@@ -40,7 +42,7 @@ auto_switch_mode = false
|
||||
# Controller's dead zone.
|
||||
dead_zone = 0.20
|
||||
# Rotation speed for look directions.
|
||||
rotation_speed = 40.0
|
||||
rotation_speed = 10.0
|
||||
# Mouse speed in GUI.
|
||||
mouse_speed = 30.0
|
||||
# Inverts the right X axis.
|
||||
|
||||
@@ -31,23 +31,28 @@
|
||||
"lambdacontrols_compat.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.4.0",
|
||||
"fabricloader": ">=0.8.0",
|
||||
"fabric": "*",
|
||||
"minecraft": ">=1.15",
|
||||
"spruceui": ">=1.3.5"
|
||||
"minecraft": ">=1.16",
|
||||
"spruceui": ">=1.5.2"
|
||||
},
|
||||
"recommends": {
|
||||
"modmenu": ">=1.9.0",
|
||||
"okzoomer": ">=1.0.4"
|
||||
"modmenu": ">=1.12.2"
|
||||
},
|
||||
"suggests": {
|
||||
"flamingo": "*",
|
||||
"roughlyenoughitems": ">=3.4.5"
|
||||
"roughlyenoughitems": ">=4.5.5",
|
||||
"okzoomer": ">=4.0.0"
|
||||
},
|
||||
"breaks": {
|
||||
"modmenu": "<1.9.0"
|
||||
"modmenu": "<1.12.2",
|
||||
"optifabric": "*"
|
||||
},
|
||||
"custom": {
|
||||
"modmenu:clientsideOnly": true
|
||||
"modmenu:clientsideOnly": true,
|
||||
"modupdater": {
|
||||
"strategy": "curseforge",
|
||||
"projectID": 354231
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
"client": [
|
||||
"AbstractButtonWidgetAccessor",
|
||||
"AdvancementsScreenAccessor",
|
||||
"ContainerScreenMixin",
|
||||
"ClientPlayerEntityMixin",
|
||||
"ClientPlayNetworkHandlerMixin",
|
||||
"ControlsOptionsScreenMixin",
|
||||
@@ -13,11 +12,12 @@
|
||||
"EntryListWidgetAccessor",
|
||||
"GameOptionsMixin",
|
||||
"GameRendererMixin",
|
||||
"HandledScreenMixin",
|
||||
"KeyBindingMixin",
|
||||
"MinecraftClientMixin",
|
||||
"MouseMixin",
|
||||
"OptionsScreenMixin",
|
||||
"RecipeBookWidgetAccessor",
|
||||
"SettingsScreenMixin",
|
||||
"WorldRendererMixin"
|
||||
],
|
||||
"injectors": {
|
||||
|
||||
@@ -3,17 +3,17 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/use
|
||||
minecraft_version=1.15.2
|
||||
yarn_mappings=1.15.2+build.14:v2
|
||||
loader_version=0.7.6+build.180
|
||||
minecraft_version=1.16.1
|
||||
yarn_mappings=1.16.1+build.9:v2
|
||||
loader_version=0.8.8+build.202
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.2.0
|
||||
maven_group = me.lambdaurora
|
||||
mod_version = 1.3.2
|
||||
maven_group = me.lambdaurora.lambdacontrols
|
||||
archives_base_name = lambdacontrols
|
||||
|
||||
# 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.4.29+build.290-1.15
|
||||
spruceui_version=1.3.5
|
||||
modmenu_version=1.10.1+build.30
|
||||
fabric_version=0.14.0+build.371-1.16
|
||||
spruceui_version=1.5.2
|
||||
modmenu_version=1.12.2+build.17
|
||||
|
||||
Reference in New Issue
Block a user