mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-13 23:25:10 +01:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd065f7b5b | ||
|
|
2785d634dc | ||
|
|
257f01ec19 | ||
|
|
127c44a046 | ||
|
|
272ef6b1dd | ||
|
|
155278130f | ||
|
|
3f221feb26 | ||
|
|
7cfd8c9b77 | ||
|
|
2c53575d17 | ||
|
|
24f7054eff |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,11 +1,13 @@
|
|||||||
#
|
#
|
||||||
# LambdAurora's ignore file
|
# LambdAurora's ignore file
|
||||||
#
|
#
|
||||||
# v0.12
|
# v0.13
|
||||||
|
|
||||||
# JetBrains
|
# JetBrains
|
||||||
.idea/
|
.idea/
|
||||||
*.iml
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
## Intellij IDEA
|
## Intellij IDEA
|
||||||
out/
|
out/
|
||||||
## CLion
|
## CLion
|
||||||
|
|||||||
44
CHANGELOG.md
44
CHANGELOG.md
@@ -45,3 +45,47 @@ This update also has a backport 1.14.4 version ([#9](https://github.com/LambdAur
|
|||||||
- Added reset settings button.
|
- Added reset settings button.
|
||||||
- HUD side affects button indicators now.
|
- HUD side affects button indicators now.
|
||||||
- Added support for Advancements tabs.
|
- Added support for Advancements tabs.
|
||||||
|
|
||||||
|
### v1.1.1
|
||||||
|
|
||||||
|
## v1.2.0-1.3.0
|
||||||
|
|
||||||
|
- Improved rotation algorithm ([#11](https://github.com/LambdAurora/LambdaControls/issues/11)).
|
||||||
|
- Added virtual mouse.
|
||||||
|
- Added outline on front block placing.
|
||||||
|
- Added fast block placement ([#8](https://github.com/LambdAurora/LambdaControls/issues/8)).
|
||||||
|
- Added [REI](https://www.curseforge.com/minecraft/mc-mods/roughly-enough-items) compatibility.
|
||||||
|
- Improved HUD.
|
||||||
|
- Added recipe book control.
|
||||||
|
- And more!
|
||||||
|
- v1.3.0 specific: Updated to Minecraft 1.16.1
|
||||||
|
|
||||||
|
### v1.3.1
|
||||||
|
|
||||||
|
- Fixed broken inventory interactions ([#13](https://github.com/LambdAurora/LambdaControls/issues/13))
|
||||||
|
- Fixed virtual mouse preventing continuous attack (thus making breaking blocks impossible).
|
||||||
|
- Added support for [ModUpdater](https://gitea.thebrokenrail.com/TheBrokenRail/ModUpdater) hopefully.
|
||||||
|
- Updated [SpruceUI](https://github.com/LambdAurora/SpruceUI) to 1.5.2.
|
||||||
|
|
||||||
|
### v1.3.2
|
||||||
|
|
||||||
|
- Added vertical reacharound.
|
||||||
|
- Added more API for compatibility handlers.
|
||||||
|
- Improved reacharound API.
|
||||||
|
- Improved [REI](https://www.curseforge.com/minecraft/mc-mods/roughly-enough-items) compatibility.
|
||||||
|
|
||||||
|
## v1.4.0
|
||||||
|
|
||||||
|
- Added analog movements ([#10](https://github.com/LambdAurora/LambdaControls/issues/10)).
|
||||||
|
- Improved Ok Zoomer compability.
|
||||||
|
- Updated [SpruceUI](https://github.com/LambdAurora/SpruceUI) to 1.5.8 to ensure 1.16.2 compability.
|
||||||
|
- Internal changes:
|
||||||
|
- Added analog input value to button bindings.
|
||||||
|
- Replace lot of strings with Texts.
|
||||||
|
- Improved block outline rendering injection.
|
||||||
|
- Shadow library jars instead of Jar-in-Jar.
|
||||||
|
- Fixed crash in inventory ([#16](https://github.com/LambdAurora/LambdaControls/issues/16))
|
||||||
|
- WIP:
|
||||||
|
- Started to work on action ring.
|
||||||
|
- Will allow for better compability with other mods.
|
||||||
|
- Might be interesting for keyboard users too.
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -7,13 +7,15 @@
|
|||||||

|

|
||||||
[](https://www.curseforge.com/minecraft/mc-mods/lambdacontrols)
|
[](https://www.curseforge.com/minecraft/mc-mods/lambdacontrols)
|
||||||
|
|
||||||
A Fabric Minecraft mod which adds better controls like controller support.
|
A Fabric Minecraft mod which adds better controls, reach-around and controller support.
|
||||||
|
|
||||||
## What's this mod?
|
## What's this mod?
|
||||||
|
|
||||||
|
This mod adds better controls, reach-around features, etc.
|
||||||
|
|
||||||
Haven't you dreamed to travel in your modded Minecraft world with your controller? Yes? Then this mod is made for you!
|
Haven't you dreamed to travel in your modded Minecraft world with your controller? Yes? Then this mod is made for you!
|
||||||
|
|
||||||
This mod adds a controller support (and an experimental touchscreen support).
|
This mod also adds controller support.
|
||||||
|
|
||||||
## ✅ Features:
|
## ✅ Features:
|
||||||
|
|
||||||
@@ -21,12 +23,14 @@ This mod adds a controller support (and an experimental touchscreen support).
|
|||||||
- Touchscreen support (very experimental and buggy).
|
- Touchscreen support (very experimental and buggy).
|
||||||
- Keyboard controls to look around.
|
- Keyboard controls to look around.
|
||||||
- Toggleable on screen button indicator (like in Bedrock Edition).
|
- Toggleable on screen button indicator (like in Bedrock Edition).
|
||||||
|
- Vertical reach-around.
|
||||||
- Many Bedrock Edition features:
|
- Many Bedrock Edition features:
|
||||||
- Toggleable fly drifting
|
- Toggleable fly drifting
|
||||||
- Front block placing (be careful with this one)
|
- Front block placing (be careful with this one)
|
||||||
- New controls settings!
|
- New controls settings!
|
||||||
- Many options in config to change to your liking.
|
- Many options in config to change to your liking.
|
||||||
- Many controllers supported and in a simply way your own controller mappings.
|
- 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:
|
## 🎮 Supported Controllers:
|
||||||
|
|
||||||
@@ -38,4 +42,4 @@ This mod adds a controller support (and an experimental touchscreen support).
|
|||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
Just do `./gradlew :fabric:build` and everything should build just fine!
|
Just do `./gradlew :fabric:shadowRemapJar` and everything should build just fine!
|
||||||
|
|||||||
18
build.gradle
18
build.gradle
@@ -20,12 +20,18 @@ allprojects {
|
|||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
publishing {
|
||||||
// if it is present.
|
repositories {
|
||||||
// If you remove this task, sources will not be generated.
|
mavenLocal()
|
||||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
maven {
|
||||||
classifier = "sources"
|
name = "GithubPackages"
|
||||||
from sourceSets.main.allSource
|
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 {
|
plugins {
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
archivesBaseName = project.archives_base_name + "-core"
|
archivesBaseName = project.archives_base_name + "-core"
|
||||||
@@ -7,11 +8,25 @@ archivesBaseName = project.archives_base_name + "-core"
|
|||||||
dependencies {
|
dependencies {
|
||||||
api "org.jetbrains:annotations:17.0.0"
|
api "org.jetbrains:annotations:17.0.0"
|
||||||
api "org.aperlambda:lambdajcommon:1.8.0"
|
api "org.aperlambda:lambdajcommon:1.8.0"
|
||||||
api "com.electronwill.night-config:core:3.5.3"
|
|
||||||
api "com.electronwill.night-config:toml:3.5.3"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
|
||||||
|
withSourcesJar()
|
||||||
|
}
|
||||||
|
|
||||||
|
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.
|
* Represents a feature.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.2.0
|
* @version 1.3.2
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
public class LambdaControlsFeature implements Nameable
|
public class LambdaControlsFeature implements Nameable
|
||||||
{
|
{
|
||||||
private static final List<LambdaControlsFeature> FEATURES = new ArrayList<>();
|
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);
|
||||||
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 String key;
|
||||||
private final boolean defaultAllowed;
|
private final boolean defaultAllowed;
|
||||||
@@ -155,7 +156,8 @@ public class LambdaControlsFeature implements Nameable
|
|||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
FEATURES.add(FRONT_BLOCK_PLACING);
|
|
||||||
FEATURES.add(FAST_BLOCK_PLACING);
|
FEATURES.add(FAST_BLOCK_PLACING);
|
||||||
|
FEATURES.add(FRONT_BLOCK_PLACING);
|
||||||
|
FEATURES.add(VERTICAL_REACHAROUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
|
import net.fabricmc.loom.task.RemapJarTask
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '0.4-SNAPSHOT'
|
id 'fabric-loom' version '0.4-SNAPSHOT'
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version = "${project.mod_version}+${project.minecraft_version}"
|
||||||
archivesBaseName = project.archives_base_name + "-fabric"
|
archivesBaseName = project.archives_base_name + "-fabric"
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
@@ -30,35 +33,37 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
|
shadowInternal
|
||||||
shadow
|
shadow
|
||||||
|
api.extendsFrom shadow
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
//to change the versions see the gradle.properties file
|
//to change the versions see the gradle.properties file
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}"
|
mappings "net.fabricmc:yarn:${project.yarn_mappings}"
|
||||||
modCompile "net.fabricmc:fabric-loader:${project.loader_version}"
|
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||||
|
|
||||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||||
modApi "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
|
|
||||||
modCompile "io.github.prospector:modmenu:${project.modmenu_version}"
|
modImplementation "io.github.prospector:modmenu:${project.modmenu_version}"
|
||||||
modCompile "com.github.lambdaurora:spruceui:${project.spruceui_version}"
|
modImplementation "com.github.lambdaurora:spruceui:${project.spruceui_version}"
|
||||||
include "com.github.lambdaurora:spruceui:${project.spruceui_version}"
|
include "com.github.lambdaurora:spruceui:${project.spruceui_version}"
|
||||||
|
|
||||||
// Compatibility mods
|
// Compatibility mods
|
||||||
modCompile "io.github.joaoh1:okzoomer:4.0.0-alpha.3.1.16.pre5"
|
modImplementation "io.github.joaoh1:okzoomer:4.0.0-alpha.4.1.16.1"
|
||||||
modCompile "me.shedaniel:RoughlyEnoughItems:4.5.5"
|
modImplementation "me.shedaniel:RoughlyEnoughItems:4.5.5"
|
||||||
|
|
||||||
api project(":core")
|
api project(":core")
|
||||||
shadow project(":core")
|
shadowInternal project(":core")
|
||||||
include "org.jetbrains:annotations:17.0.0"
|
shadow("org.aperlambda:lambdajcommon:1.8.0") {
|
||||||
include("org.aperlambda:lambdajcommon:1.8.0") {
|
// Minecraft already has all that google crap.
|
||||||
exclude group: 'com.google.code.gson'
|
exclude group: 'com.google.code.gson'
|
||||||
exclude group: 'com.google.guava'
|
exclude group: 'com.google.guava'
|
||||||
}
|
}
|
||||||
include "com.electronwill.night-config:core:3.5.3"
|
shadow "com.electronwill.night-config:core:3.5.3"
|
||||||
include "com.electronwill.night-config:toml:3.5.3"
|
shadow "com.electronwill.night-config:toml:3.5.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
@@ -77,18 +82,56 @@ processResources {
|
|||||||
java {
|
java {
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
|
||||||
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
from "../LICENSE"
|
from "../LICENSE"
|
||||||
|
}
|
||||||
|
|
||||||
|
task shadowJar(type: Jar) {
|
||||||
|
archiveClassifier.set("dev")
|
||||||
|
|
||||||
|
from sourceSets.main.output
|
||||||
|
|
||||||
from {
|
from {
|
||||||
configurations.shadow.filter {
|
configurations.shadowInternal.filter {
|
||||||
it.getName().contains("lambdacontrols")
|
it.getName().contains("lambdacontrols")
|
||||||
}.collect {
|
}.collect {
|
||||||
it.isDirectory() ? it : zipTree(it)
|
it.isDirectory() ? it : zipTree(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
from {
|
||||||
|
configurations.shadow.collect {
|
||||||
|
it.isDirectory() ? it : zipTree(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task shadowRemapJar(type: RemapJarTask) {
|
||||||
|
dependsOn shadowJar
|
||||||
|
|
||||||
|
input = file("${project.buildDir}/libs/$archivesBaseName-$version-dev.jar")
|
||||||
|
archiveName = "${archivesBaseName}-${version}.jar"
|
||||||
|
addNestedDependencies = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// configure the maven publication
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
mavenJava(MavenPublication) {
|
||||||
|
// add all the jars that should be included when publishing to maven
|
||||||
|
artifact(remapJar) {
|
||||||
|
builtBy remapJar
|
||||||
|
}
|
||||||
|
artifact(sourcesJar) {
|
||||||
|
builtBy remapSourcesJar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowJar.dependsOn(":core:jar")
|
||||||
build.dependsOn(":core:build")
|
build.dependsOn(":core:build")
|
||||||
|
publish.dependsOn(":core:publish")
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
|
|
||||||
package me.lambdaurora.lambdacontrols.client;
|
package me.lambdaurora.lambdacontrols.client;
|
||||||
|
|
||||||
import net.minecraft.client.resource.language.I18n;
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
import org.aperlambda.lambdacommon.utils.Nameable;
|
import org.aperlambda.lambdacommon.utils.Nameable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ import java.util.Optional;
|
|||||||
* Represents a controller type.
|
* Represents a controller type.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.0.0
|
* @version 1.4.0
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public enum ControllerType implements Nameable
|
public enum ControllerType implements Nameable
|
||||||
@@ -32,11 +33,13 @@ public enum ControllerType implements Nameable
|
|||||||
STEAM(4),
|
STEAM(4),
|
||||||
OUYA(5);
|
OUYA(5);
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
|
private final Text text;
|
||||||
|
|
||||||
ControllerType(int id)
|
ControllerType(int id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
this.text = new TranslatableText(this.getTranslationKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,7 +57,7 @@ public enum ControllerType implements Nameable
|
|||||||
*
|
*
|
||||||
* @return The next available controller type.
|
* @return The next available controller type.
|
||||||
*/
|
*/
|
||||||
public ControllerType next()
|
public @NotNull ControllerType next()
|
||||||
{
|
{
|
||||||
ControllerType[] v = values();
|
ControllerType[] v = values();
|
||||||
if (v.length == this.ordinal() + 1)
|
if (v.length == this.ordinal() + 1)
|
||||||
@@ -63,13 +66,23 @@ public enum ControllerType implements Nameable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the translated name of this controller type.
|
* Returns the translation key of this controller type.
|
||||||
*
|
*
|
||||||
* @return The translated name of this controller type.
|
* @return The translation key.
|
||||||
*/
|
*/
|
||||||
public String getTranslatedName()
|
public @NotNull String getTranslationKey()
|
||||||
{
|
{
|
||||||
return I18n.translate("lambdacontrols.controller_type." + this.getName());
|
return "lambdacontrols.controller_type." + this.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the translated text of this controller type.
|
||||||
|
*
|
||||||
|
* @return The translated text of this controller type.
|
||||||
|
*/
|
||||||
|
public @NotNull Text getTranslatedText()
|
||||||
|
{
|
||||||
|
return this.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -84,7 +97,7 @@ public enum ControllerType implements Nameable
|
|||||||
* @param id The identifier of the controller type.
|
* @param id The identifier of the controller type.
|
||||||
* @return The controller type if found, else empty.
|
* @return The controller type if found, else empty.
|
||||||
*/
|
*/
|
||||||
public static Optional<ControllerType> byId(@NotNull String id)
|
public static @NotNull Optional<ControllerType> byId(@NotNull String id)
|
||||||
{
|
{
|
||||||
return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst();
|
return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
package me.lambdaurora.lambdacontrols.client;
|
package me.lambdaurora.lambdacontrols.client;
|
||||||
|
|
||||||
import net.minecraft.client.resource.language.I18n;
|
import net.minecraft.client.resource.language.I18n;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
import org.aperlambda.lambdacommon.utils.Nameable;
|
import org.aperlambda.lambdacommon.utils.Nameable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -20,7 +22,7 @@ import java.util.Optional;
|
|||||||
* Represents the hud side which is the side where the movements buttons are.
|
* Represents the hud side which is the side where the movements buttons are.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.0.0
|
* @version 1.4.0
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public enum HudSide implements Nameable
|
public enum HudSide implements Nameable
|
||||||
@@ -28,12 +30,19 @@ public enum HudSide implements Nameable
|
|||||||
LEFT,
|
LEFT,
|
||||||
RIGHT;
|
RIGHT;
|
||||||
|
|
||||||
|
private final Text text;
|
||||||
|
|
||||||
|
HudSide()
|
||||||
|
{
|
||||||
|
this.text = new TranslatableText(this.getTranslationKey());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the next side available.
|
* Returns the next side available.
|
||||||
*
|
*
|
||||||
* @return The next available side.
|
* @return The next available side.
|
||||||
*/
|
*/
|
||||||
public HudSide next()
|
public @NotNull HudSide next()
|
||||||
{
|
{
|
||||||
HudSide[] v = values();
|
HudSide[] v = values();
|
||||||
if (v.length == this.ordinal() + 1)
|
if (v.length == this.ordinal() + 1)
|
||||||
@@ -42,13 +51,23 @@ public enum HudSide implements Nameable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the translated name of this hud side.
|
* Returns the translation key of this hud side.
|
||||||
*
|
*
|
||||||
* @return The translated name of this hud side.
|
* @return The translation key of this hude side.
|
||||||
*/
|
*/
|
||||||
public String getTranslatedName()
|
public @NotNull String getTranslationKey()
|
||||||
{
|
{
|
||||||
return I18n.translate("lambdacontrols.hud_side." + this.getName());
|
return "lambdacontrols.hud_side." + this.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the translated text of this hud side.
|
||||||
|
*
|
||||||
|
* @return The translated text of this hud side.
|
||||||
|
*/
|
||||||
|
public @NotNull Text getTranslatedText()
|
||||||
|
{
|
||||||
|
return this.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -63,7 +82,7 @@ public enum HudSide implements Nameable
|
|||||||
* @param id The identifier of the hud side.
|
* @param id The identifier of the hud side.
|
||||||
* @return The hud side if found, else empty.
|
* @return The hud side if found, else empty.
|
||||||
*/
|
*/
|
||||||
public static Optional<HudSide> byId(@NotNull String id)
|
public static @NotNull Optional<HudSide> byId(@NotNull String id)
|
||||||
{
|
{
|
||||||
return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst();
|
return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import me.lambdaurora.spruceui.event.OpenScreenCallback;
|
|||||||
import me.lambdaurora.spruceui.hud.HudManager;
|
import me.lambdaurora.spruceui.hud.HudManager;
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||||
import net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry;
|
|
||||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||||
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
|
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
@@ -40,7 +39,7 @@ import org.lwjgl.glfw.GLFW;
|
|||||||
* Represents the LambdaControls client mod.
|
* Represents the LambdaControls client mod.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.3.0
|
* @version 1.3.2
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
public class LambdaControlsClient extends LambdaControls implements ClientModInitializer
|
public class LambdaControlsClient extends LambdaControls implements ClientModInitializer
|
||||||
@@ -59,6 +58,7 @@ public class LambdaControlsClient extends LambdaControls implements ClientModIni
|
|||||||
public static final Identifier CURSOR_TEXTURE = new Identifier(LambdaControlsConstants.NAMESPACE, "textures/gui/cursor.png");
|
public static final Identifier CURSOR_TEXTURE = new Identifier(LambdaControlsConstants.NAMESPACE, "textures/gui/cursor.png");
|
||||||
public final LambdaControlsConfig config = new LambdaControlsConfig(this);
|
public final LambdaControlsConfig config = new LambdaControlsConfig(this);
|
||||||
public final LambdaInput input = new LambdaInput(this);
|
public final LambdaInput input = new LambdaInput(this);
|
||||||
|
public final LambdaReacharound reacharound = new LambdaReacharound();
|
||||||
private LambdaControlsHud hud;
|
private LambdaControlsHud hud;
|
||||||
private ControlsMode previousControlsMode;
|
private ControlsMode previousControlsMode;
|
||||||
|
|
||||||
@@ -79,6 +79,7 @@ public class LambdaControlsClient extends LambdaControls implements ClientModIni
|
|||||||
LambdaControlsFeature.fromName(name).ifPresent(feature -> context.getTaskQueue().execute(() -> feature.setAllowed(allowed)));
|
LambdaControlsFeature.fromName(name).ifPresent(feature -> context.getTaskQueue().execute(() -> feature.setAllowed(allowed)));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ClientTickEvents.START_CLIENT_TICK.register(this.reacharound::tick);
|
||||||
ClientTickEvents.END_CLIENT_TICK.register(this::onTick);
|
ClientTickEvents.END_CLIENT_TICK.register(this::onTick);
|
||||||
|
|
||||||
OpenScreenCallback.EVENT.register((client, screen) -> {
|
OpenScreenCallback.EVENT.register((client, screen) -> {
|
||||||
|
|||||||
@@ -34,25 +34,27 @@ import static org.lwjgl.glfw.GLFW.GLFW_GAMEPAD_AXIS_LEFT_Y;
|
|||||||
public class LambdaControlsConfig
|
public class LambdaControlsConfig
|
||||||
{
|
{
|
||||||
// General
|
// General
|
||||||
private static final ControlsMode DEFAULT_CONTROLS_MODE = ControlsMode.DEFAULT;
|
private static final ControlsMode DEFAULT_CONTROLS_MODE = ControlsMode.DEFAULT;
|
||||||
private static final boolean DEFAULT_AUTO_SWITCH_MODE = false;
|
private static final boolean DEFAULT_AUTO_SWITCH_MODE = false;
|
||||||
// HUD
|
// HUD
|
||||||
private static final boolean DEFAULT_HUD_ENABLE = true;
|
private static final boolean DEFAULT_HUD_ENABLE = true;
|
||||||
private static final HudSide DEFAULT_HUD_SIDE = HudSide.LEFT;
|
private static final HudSide DEFAULT_HUD_SIDE = HudSide.LEFT;
|
||||||
// Gameplay
|
// Gameplay
|
||||||
private static final boolean DEFAULT_FAST_BLOCK_INTERACTION = true;
|
private static final boolean DEFAULT_FAST_BLOCK_INTERACTION = true;
|
||||||
private static final boolean DEFAULT_FLY_DRIFTING = false;
|
private static final boolean DEFAULT_FLY_DRIFTING = false;
|
||||||
private static final boolean DEFAULT_FLY_VERTICAL_DRIFTING = true;
|
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_PLACING = false;
|
||||||
private static final boolean DEFAULT_FRONT_BLOCK_OUTLINE = true;
|
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
|
// Controller
|
||||||
private static final ControllerType DEFAULT_CONTROLLER_TYPE = ControllerType.DEFAULT;
|
private static final ControllerType DEFAULT_CONTROLLER_TYPE = ControllerType.DEFAULT;
|
||||||
private static final double DEFAULT_DEAD_ZONE = 0.25;
|
private static final double DEFAULT_DEAD_ZONE = 0.25;
|
||||||
private static final double DEFAULT_ROTATION_SPEED = 40.0;
|
private static final double DEFAULT_ROTATION_SPEED = 40.0;
|
||||||
private static final double DEFAULT_MOUSE_SPEED = 25.0;
|
private static final double DEFAULT_MOUSE_SPEED = 25.0;
|
||||||
private static final boolean DEFAULT_UNFOCUSED_INPUT = false;
|
private static final boolean DEFAULT_UNFOCUSED_INPUT = false;
|
||||||
private static final boolean DEFAULT_VIRTUAL_MOUSE = false;
|
private static final boolean DEFAULT_VIRTUAL_MOUSE = false;
|
||||||
private static final VirtualMouseSkin DEFAULT_VIRTUAL_MOUSE_SKIN = VirtualMouseSkin.DEFAULT_LIGHT;
|
private static final VirtualMouseSkin DEFAULT_VIRTUAL_MOUSE_SKIN = VirtualMouseSkin.DEFAULT_LIGHT;
|
||||||
|
|
||||||
private static final Pattern BUTTON_BINDING_PATTERN = Pattern.compile("(-?\\d+)\\+?");
|
private static final Pattern BUTTON_BINDING_PATTERN = Pattern.compile("(-?\\d+)\\+?");
|
||||||
|
|
||||||
@@ -61,8 +63,8 @@ public class LambdaControlsConfig
|
|||||||
private ControlsMode controlsMode;
|
private ControlsMode controlsMode;
|
||||||
private ControllerType controllerType;
|
private ControllerType controllerType;
|
||||||
// Gameplay.
|
// Gameplay.
|
||||||
private boolean shouldRenderFrontBlockOutline;
|
private boolean shouldRenderReacharoundOutline;
|
||||||
private int[] frontBlockOutlineColor;
|
private int[] reacharoundOutlineColor;
|
||||||
// Controller settings
|
// Controller settings
|
||||||
private double deadZone;
|
private double deadZone;
|
||||||
private double rotationSpeed;
|
private double rotationSpeed;
|
||||||
@@ -93,9 +95,10 @@ public class LambdaControlsConfig
|
|||||||
this.hudSide = HudSide.byId(this.config.getOrElse("hud.side", DEFAULT_HUD_SIDE.getName())).orElse(DEFAULT_HUD_SIDE);
|
this.hudSide = HudSide.byId(this.config.getOrElse("hud.side", DEFAULT_HUD_SIDE.getName())).orElse(DEFAULT_HUD_SIDE);
|
||||||
// Gameplay
|
// Gameplay
|
||||||
LambdaControlsFeature.FAST_BLOCK_PLACING.setEnabled(this.config.getOrElse("gameplay.fast_block_placing", DEFAULT_FAST_BLOCK_INTERACTION));
|
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));
|
LambdaControlsFeature.FRONT_BLOCK_PLACING.setEnabled(this.config.getOrElse("gameplay.reacharound.horizontal", DEFAULT_FRONT_BLOCK_PLACING));
|
||||||
this.shouldRenderFrontBlockOutline = this.config.getOrElse("gameplay.front_block_placing.outline", DEFAULT_FRONT_BLOCK_OUTLINE);
|
LambdaControlsFeature.VERTICAL_REACHAROUND.setEnabled(this.config.getOrElse("gameplay.reacharound.vertical", DEFAULT_VERTICAL_REACHAROUND));
|
||||||
this.frontBlockOutlineColor = this.config.getOptional("gameplay.front_block_placing.outline_color").map(hex -> parseColor((String) hex)).orElse(new int[]{255, 255, 255, 102});
|
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.
|
// Controller settings.
|
||||||
this.controllerType = ControllerType.byId(this.config.getOrElse("controller.type", DEFAULT_CONTROLLER_TYPE.getName())).orElse(DEFAULT_CONTROLLER_TYPE);
|
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);
|
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")) {
|
||||||
if (!this.config.contains("gameplay.front_block_placing.enabled") && this.config.contains("gameplay.front_block_placing")) {
|
this.setFrontBlockPlacing(this.config.getOrElse("gameplay.front_block_placing.enabled", DEFAULT_FRONT_BLOCK_PLACING));
|
||||||
this.config.remove("gameplay.front_block_placing");
|
this.config.remove("gameplay.front_block_placing.enabled");
|
||||||
this.config.set("gameplay.front_block_placing.enabled", DEFAULT_FRONT_BLOCK_PLACING);
|
}
|
||||||
|
|
||||||
|
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");
|
this.renamed("controller.controls.tab_left", "controller.controls.tab_back");
|
||||||
@@ -165,7 +177,8 @@ public class LambdaControlsConfig
|
|||||||
this.setFlyDrifting(DEFAULT_FLY_DRIFTING);
|
this.setFlyDrifting(DEFAULT_FLY_DRIFTING);
|
||||||
this.setFlyVerticalDrifting(DEFAULT_FLY_VERTICAL_DRIFTING);
|
this.setFlyVerticalDrifting(DEFAULT_FLY_VERTICAL_DRIFTING);
|
||||||
this.setFrontBlockPlacing(DEFAULT_FRONT_BLOCK_PLACING);
|
this.setFrontBlockPlacing(DEFAULT_FRONT_BLOCK_PLACING);
|
||||||
this.setRenderFrontBlockOutline(DEFAULT_FRONT_BLOCK_OUTLINE);
|
this.setVerticalReacharound(DEFAULT_VERTICAL_REACHAROUND);
|
||||||
|
this.setRenderReacharoundOutline(DEFAULT_REACHAROUND_OUTLINE);
|
||||||
// Controller
|
// Controller
|
||||||
this.setControllerType(DEFAULT_CONTROLLER_TYPE);
|
this.setControllerType(DEFAULT_CONTROLLER_TYPE);
|
||||||
this.setDeadZone(DEFAULT_DEAD_ZONE);
|
this.setDeadZone(DEFAULT_DEAD_ZONE);
|
||||||
@@ -352,7 +365,28 @@ public class LambdaControlsConfig
|
|||||||
public void setFrontBlockPlacing(boolean enable)
|
public void setFrontBlockPlacing(boolean enable)
|
||||||
{
|
{
|
||||||
LambdaControlsFeature.FRONT_BLOCK_PLACING.setEnabled(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.
|
* @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.
|
* @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.
|
* @return The color as a RGBA integer array.
|
||||||
*/
|
*/
|
||||||
public int[] getFrontBlockOutlineColor()
|
public int[] getReacharoundOutlineColor()
|
||||||
{
|
{
|
||||||
return this.frontBlockOutlineColor;
|
return this.reacharoundOutlineColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ package me.lambdaurora.lambdacontrols.client;
|
|||||||
|
|
||||||
import io.github.prospector.modmenu.api.ConfigScreenFactory;
|
import io.github.prospector.modmenu.api.ConfigScreenFactory;
|
||||||
import io.github.prospector.modmenu.api.ModMenuApi;
|
import io.github.prospector.modmenu.api.ModMenuApi;
|
||||||
import me.lambdaurora.lambdacontrols.LambdaControlsConstants;
|
|
||||||
import me.lambdaurora.lambdacontrols.client.gui.LambdaControlsSettingsScreen;
|
import me.lambdaurora.lambdacontrols.client.gui.LambdaControlsSettingsScreen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
package me.lambdaurora.lambdacontrols.client;
|
package me.lambdaurora.lambdacontrols.client;
|
||||||
|
|
||||||
import me.lambdaurora.lambdacontrols.LambdaControlsFeature;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import me.lambdaurora.lambdacontrols.client.compat.LambdaControlsCompat;
|
import me.lambdaurora.lambdacontrols.client.compat.LambdaControlsCompat;
|
||||||
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||||
import me.lambdaurora.lambdacontrols.client.controller.Controller;
|
import me.lambdaurora.lambdacontrols.client.controller.Controller;
|
||||||
@@ -22,10 +22,6 @@ import me.lambdaurora.lambdacontrols.client.mixin.EntryListWidgetAccessor;
|
|||||||
import me.lambdaurora.lambdacontrols.client.util.HandledScreenAccessor;
|
import me.lambdaurora.lambdacontrols.client.util.HandledScreenAccessor;
|
||||||
import me.lambdaurora.lambdacontrols.client.util.MouseAccessor;
|
import me.lambdaurora.lambdacontrols.client.util.MouseAccessor;
|
||||||
import me.lambdaurora.spruceui.SpruceLabelWidget;
|
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.MinecraftClient;
|
||||||
import net.minecraft.client.gui.Element;
|
import net.minecraft.client.gui.Element;
|
||||||
import net.minecraft.client.gui.ParentElement;
|
import net.minecraft.client.gui.ParentElement;
|
||||||
@@ -36,20 +32,16 @@ import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
|
|||||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget;
|
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget;
|
||||||
|
import net.minecraft.client.gui.screen.pack.ResourcePackScreen;
|
||||||
import net.minecraft.client.gui.screen.world.WorldListWidget;
|
import net.minecraft.client.gui.screen.world.WorldListWidget;
|
||||||
import net.minecraft.client.gui.widget.AbstractPressableButtonWidget;
|
import net.minecraft.client.gui.widget.AbstractPressableButtonWidget;
|
||||||
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
|
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
|
||||||
import net.minecraft.client.gui.widget.EntryListWidget;
|
import net.minecraft.client.gui.widget.EntryListWidget;
|
||||||
import net.minecraft.client.gui.widget.SliderWidget;
|
import net.minecraft.client.gui.widget.SliderWidget;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.BlockItem;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.screen.slot.Slot;
|
import net.minecraft.screen.slot.Slot;
|
||||||
import net.minecraft.screen.slot.SlotActionType;
|
import net.minecraft.screen.slot.SlotActionType;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.text.TranslatableText;
|
||||||
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.MathHelper;
|
||||||
import org.aperlambda.lambdacommon.utils.Pair;
|
import org.aperlambda.lambdacommon.utils.Pair;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -72,24 +64,25 @@ import static org.lwjgl.glfw.GLFW.*;
|
|||||||
* Represents the LambdaControls' input handler.
|
* Represents the LambdaControls' input handler.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.3.0
|
* @version 1.4.0
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public class LambdaInput
|
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;
|
private final LambdaControlsConfig config;
|
||||||
// Cooldowns
|
// Cooldowns
|
||||||
private int actionGuiCooldown = 0;
|
private int actionGuiCooldown = 0;
|
||||||
private int ignoreNextA = 0;
|
private boolean ignoreNextARelease = false;
|
||||||
private double targetYaw = 0.0;
|
private double targetYaw = 0.0;
|
||||||
private double targetPitch = 0.0;
|
private double targetPitch = 0.0;
|
||||||
private float prevXAxis = 0.F;
|
private float prevXAxis = 0.F;
|
||||||
private float prevYAxis = 0.F;
|
private float prevYAxis = 0.F;
|
||||||
private int targetMouseX = 0;
|
private int targetMouseX = 0;
|
||||||
private int targetMouseY = 0;
|
private int targetMouseY = 0;
|
||||||
private float mouseSpeedX = 0.F;
|
private float mouseSpeedX = 0.F;
|
||||||
private float mouseSpeedY = 0.F;
|
private float mouseSpeedY = 0.F;
|
||||||
|
private int inventoryInteractionCooldown = 0;
|
||||||
|
|
||||||
public LambdaInput(@NotNull LambdaControlsClient mod)
|
public LambdaInput(@NotNull LambdaControlsClient mod)
|
||||||
{
|
{
|
||||||
@@ -156,9 +149,6 @@ public class LambdaInput
|
|||||||
if (allowInput)
|
if (allowInput)
|
||||||
InputManager.updateBindings(client);
|
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)) {
|
if (client.currentScreen instanceof ControllerControlsScreen && InputManager.STATES.entrySet().parallelStream().map(Map.Entry::getValue).allMatch(ButtonState::isUnpressed)) {
|
||||||
ControllerControlsScreen screen = (ControllerControlsScreen) client.currentScreen;
|
ControllerControlsScreen screen = (ControllerControlsScreen) client.currentScreen;
|
||||||
if (screen.focusedBinding != null && !screen.waiting) {
|
if (screen.focusedBinding != null && !screen.waiting) {
|
||||||
@@ -169,6 +159,9 @@ public class LambdaInput
|
|||||||
screen.focusedBinding = null;
|
screen.focusedBinding = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.inventoryInteractionCooldown > 0)
|
||||||
|
this.inventoryInteractionCooldown--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -226,6 +219,7 @@ public class LambdaInput
|
|||||||
((MouseAccessor) client.mouse).lambdacontrols_onCursorPos(client.getWindow().getHandle(), 0, 0);
|
((MouseAccessor) client.mouse).lambdacontrols_onCursorPos(client.getWindow().getHandle(), 0, 0);
|
||||||
INPUT_MANAGER.resetMouseTarget(client);
|
INPUT_MANAGER.resetMouseTarget(client);
|
||||||
}
|
}
|
||||||
|
this.inventoryInteractionCooldown = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchButtonInput(@NotNull MinecraftClient client, @NotNull GLFWGamepadState gamepadState, boolean leftJoycon)
|
private void fetchButtonInput(@NotNull MinecraftClient client, @NotNull GLFWGamepadState gamepadState, boolean leftJoycon)
|
||||||
@@ -321,50 +315,123 @@ public class LambdaInput
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client.currentScreen instanceof HandledScreen && client.interactionManager != null && client.player != null) {
|
if (this.handleInventory(client, button)) {
|
||||||
double x = client.mouse.getX() * (double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth();
|
this.ignoreNextARelease = true;
|
||||||
double y = client.mouse.getY() * (double) client.getWindow().getScaledHeight() / (double) client.getWindow().getHeight();
|
return;
|
||||||
Slot slot = ((HandledScreenAccessor) client.currentScreen).lambdacontrols_getSlotAt(x, y);
|
}
|
||||||
SlotActionType slotAction = SlotActionType.PICKUP;
|
|
||||||
if (button == GLFW.GLFW_GAMEPAD_BUTTON_A && slot != null) {
|
if (button == GLFW.GLFW_GAMEPAD_BUTTON_B) {
|
||||||
if (client.currentScreen instanceof CreativeInventoryScreen) {
|
|
||||||
if (((CreativeInventoryScreenAccessor) client.currentScreen).lambdacontrols_isCreativeInventorySlot(slot))
|
|
||||||
slotAction = SlotActionType.CLONE;
|
|
||||||
}
|
|
||||||
client.interactionManager.clickSlot(((HandledScreen) client.currentScreen).getScreenHandler().syncId, slot.id, GLFW.GLFW_MOUSE_BUTTON_1, slotAction, client.player);
|
|
||||||
client.player.playerScreenHandler.sendContentUpdates();
|
|
||||||
this.actionGuiCooldown = 5;
|
|
||||||
return;
|
|
||||||
} else if (button == GLFW.GLFW_GAMEPAD_BUTTON_B) {
|
|
||||||
client.player.closeHandledScreen();
|
|
||||||
return;
|
|
||||||
} else if (button == GLFW.GLFW_GAMEPAD_BUTTON_X && slot != null) {
|
|
||||||
client.interactionManager.clickSlot(((HandledScreen) client.currentScreen).getScreenHandler().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(((HandledScreen) client.currentScreen).getScreenHandler().syncId, slot.id, GLFW.GLFW_MOUSE_BUTTON_1, SlotActionType.QUICK_MOVE, client.player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else if (button == GLFW.GLFW_GAMEPAD_BUTTON_B) {
|
|
||||||
if (client.currentScreen != null) {
|
if (client.currentScreen != null) {
|
||||||
client.currentScreen.onClose();
|
if (!LambdaControlsCompat.handleMenuBack(client, client.currentScreen))
|
||||||
|
if (!this.tryGoBack(client.currentScreen))
|
||||||
|
client.currentScreen.onClose();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button == GLFW.GLFW_GAMEPAD_BUTTON_A && client.currentScreen != null && !isScreenInteractive(client.currentScreen) && this.actionGuiCooldown == 0 && this.ignoreNextA == 0) {
|
if (button == GLFW.GLFW_GAMEPAD_BUTTON_A && client.currentScreen != null && !isScreenInteractive(client.currentScreen) && this.actionGuiCooldown == 0) {
|
||||||
double mouseX = client.mouse.getX() * (double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth();
|
if (!this.ignoreNextARelease) {
|
||||||
double mouseY = client.mouse.getY() * (double) client.getWindow().getScaledHeight() / (double) client.getWindow().getHeight();
|
double mouseX = client.mouse.getX() * (double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth();
|
||||||
if (action == 0) {
|
double mouseY = client.mouse.getY() * (double) client.getWindow().getScaledHeight() / (double) client.getWindow().getHeight();
|
||||||
client.currentScreen.mouseClicked(mouseX, mouseY, GLFW.GLFW_MOUSE_BUTTON_1);
|
if (action == 0) {
|
||||||
} else if (action == 1) {
|
Screen.wrapScreenError(() -> client.currentScreen.mouseClicked(mouseX, mouseY, GLFW.GLFW_MOUSE_BUTTON_1),
|
||||||
client.currentScreen.mouseReleased(mouseX, mouseY, GLFW.GLFW_MOUSE_BUTTON_1);
|
"mouseClicked event handler", client.currentScreen.getClass().getCanonicalName());
|
||||||
|
} else if (action == 1) {
|
||||||
|
Screen.wrapScreenError(() -> client.currentScreen.mouseReleased(mouseX, mouseY, GLFW.GLFW_MOUSE_BUTTON_1),
|
||||||
|
"mouseReleased event handler", client.currentScreen.getClass().getCanonicalName());
|
||||||
|
}
|
||||||
|
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 (this.inventoryInteractionCooldown > 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to go back.
|
||||||
|
*
|
||||||
|
* @param screen The current screen.
|
||||||
|
* @return True if successful, else false.
|
||||||
|
*/
|
||||||
|
public boolean tryGoBack(@NotNull Screen screen)
|
||||||
|
{
|
||||||
|
ImmutableSet<String> set = ImmutableSet.of("gui.back", "gui.done", "gui.cancel", "gui.toTitle", "gui.toMenu");
|
||||||
|
return screen.children().stream().filter(element -> element instanceof AbstractPressableButtonWidget)
|
||||||
|
.map(element -> (AbstractPressableButtonWidget) element)
|
||||||
|
.filter(element -> element.getMessage() instanceof TranslatableText)
|
||||||
|
.anyMatch(element -> {
|
||||||
|
if (set.stream().anyMatch(key -> key.equals(((TranslatableText) element.getMessage()).getKey()))) {
|
||||||
|
element.onPress();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void handleAxe(@NotNull MinecraftClient client, int axis, float value, float absValue, int state)
|
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);
|
int asButtonState = value > 0.5F ? 1 : (value < -0.5F ? 2 : 0);
|
||||||
@@ -401,6 +468,17 @@ public class LambdaInput
|
|||||||
BUTTON_COOLDOWNS.put(axisAsButton(axis, false), 5);
|
BUTTON_COOLDOWNS.put(axisAsButton(axis, false), 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float axisValue = absValue < this.config.getDeadZone() ? 0.f : (float) (absValue - this.config.getDeadZone());
|
||||||
|
axisValue /= (1.0 - this.config.getDeadZone());
|
||||||
|
if (currentPlusState)
|
||||||
|
InputManager.BUTTON_VALUES.put(axisAsButton(axis, true), axisValue);
|
||||||
|
else
|
||||||
|
InputManager.BUTTON_VALUES.put(axisAsButton(axis, true), 0.f);
|
||||||
|
if (currentMinusState)
|
||||||
|
InputManager.BUTTON_VALUES.put(axisAsButton(axis, false), axisValue);
|
||||||
|
else
|
||||||
|
InputManager.BUTTON_VALUES.put(axisAsButton(axis, false), 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
double deadZone = this.config.getDeadZone();
|
double deadZone = this.config.getDeadZone();
|
||||||
@@ -425,6 +503,7 @@ public class LambdaInput
|
|||||||
if (axis == GLFW_GAMEPAD_AXIS_RIGHT_Y) {
|
if (axis == GLFW_GAMEPAD_AXIS_RIGHT_Y) {
|
||||||
CreativeInventoryScreen screen = (CreativeInventoryScreen) client.currentScreen;
|
CreativeInventoryScreen screen = (CreativeInventoryScreen) client.currentScreen;
|
||||||
CreativeInventoryScreenAccessor accessor = (CreativeInventoryScreenAccessor) screen;
|
CreativeInventoryScreenAccessor accessor = (CreativeInventoryScreenAccessor) screen;
|
||||||
|
// @TODO allow rebinding to left stick
|
||||||
if (accessor.lambdacontrols_hasScrollbar() && absValue >= deadZone) {
|
if (accessor.lambdacontrols_hasScrollbar() && absValue >= deadZone) {
|
||||||
screen.mouseScrolled(0.0, 0.0, -value);
|
screen.mouseScrolled(0.0, 0.0, -value);
|
||||||
}
|
}
|
||||||
@@ -563,7 +642,7 @@ public class LambdaInput
|
|||||||
this.actionGuiCooldown = 2; // Prevent to press too quickly the focused element, so we have to skip 5 ticks.
|
this.actionGuiCooldown = 2; // Prevent to press too quickly the focused element, so we have to skip 5 ticks.
|
||||||
return false;
|
return false;
|
||||||
} else if (element instanceof AlwaysSelectedEntryListWidget) {
|
} else if (element instanceof AlwaysSelectedEntryListWidget) {
|
||||||
((EntryListWidgetAccessor) element).lambdacontrols_moveSelection(right ? EntryListWidget.class_5403.field_25661 : EntryListWidget.class_5403.field_25662);
|
((EntryListWidgetAccessor) element).lambdacontrols_moveSelection(right ? EntryListWidget.MoveDirection.UP : EntryListWidget.MoveDirection.DOWN);
|
||||||
return false;
|
return false;
|
||||||
} else if (element instanceof ParentElement) {
|
} else if (element instanceof ParentElement) {
|
||||||
ParentElement entryList = (ParentElement) element;
|
ParentElement entryList = (ParentElement) element;
|
||||||
@@ -621,7 +700,7 @@ public class LambdaInput
|
|||||||
|
|
||||||
public static boolean isScreenInteractive(@NotNull Screen screen)
|
public static boolean isScreenInteractive(@NotNull Screen screen)
|
||||||
{
|
{
|
||||||
return !(screen instanceof AdvancementsScreen || screen instanceof HandledScreen || LambdaControlsCompat.requireMouseOnScreen(screen));
|
return !(screen instanceof AdvancementsScreen || screen instanceof HandledScreen || screen instanceof ResourcePackScreen || LambdaControlsCompat.requireMouseOnScreen(screen));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inspired from https://github.com/MrCrayfish/Controllable/blob/1.14.X/src/main/java/com/mrcrayfish/controllable/client/ControllerInput.java#L686.
|
// Inspired from https://github.com/MrCrayfish/Controllable/blob/1.14.X/src/main/java/com/mrcrayfish/controllable/client/ControllerInput.java#L686.
|
||||||
@@ -680,71 +759,4 @@ public class LambdaInput
|
|||||||
this.mouseSpeedY = 0.F;
|
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.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 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
|
|
||||||
package me.lambdaurora.lambdacontrols.client;
|
package me.lambdaurora.lambdacontrols.client;
|
||||||
|
|
||||||
import net.minecraft.client.resource.language.I18n;
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
import org.aperlambda.lambdacommon.utils.Nameable;
|
import org.aperlambda.lambdacommon.utils.Nameable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ import java.util.Optional;
|
|||||||
/**
|
/**
|
||||||
* Represents the virtual mouse skins.
|
* Represents the virtual mouse skins.
|
||||||
*
|
*
|
||||||
* @version 1.2.0
|
* @version 1.4.0
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
public enum VirtualMouseSkin implements Nameable
|
public enum VirtualMouseSkin implements Nameable
|
||||||
@@ -29,10 +30,13 @@ public enum VirtualMouseSkin implements Nameable
|
|||||||
SECOND_LIGHT("second_light"),
|
SECOND_LIGHT("second_light"),
|
||||||
SECOND_DARK("second_dark");
|
SECOND_DARK("second_dark");
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
|
private final Text text;
|
||||||
|
|
||||||
VirtualMouseSkin(String name) {
|
VirtualMouseSkin(String name)
|
||||||
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.text = new TranslatableText(this.getTranslationKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +44,7 @@ public enum VirtualMouseSkin implements Nameable
|
|||||||
*
|
*
|
||||||
* @return The next available virtual mouse skin.
|
* @return The next available virtual mouse skin.
|
||||||
*/
|
*/
|
||||||
public VirtualMouseSkin next()
|
public @NotNull VirtualMouseSkin next()
|
||||||
{
|
{
|
||||||
VirtualMouseSkin[] v = values();
|
VirtualMouseSkin[] v = values();
|
||||||
if (v.length == this.ordinal() + 1)
|
if (v.length == this.ordinal() + 1)
|
||||||
@@ -49,13 +53,23 @@ public enum VirtualMouseSkin implements Nameable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the translated name of this controller type.
|
* Returns the translation key of this virtual mouse skin.
|
||||||
*
|
*
|
||||||
* @return The translated name of this controller type.
|
* @return The virtual mouse skin's translation key.
|
||||||
*/
|
*/
|
||||||
public String getTranslatedName()
|
public @NotNull String getTranslationKey()
|
||||||
{
|
{
|
||||||
return I18n.translate("lambdacontrols.virtual_mouse.skin." + this.getName());
|
return "lambdacontrols.virtual_mouse.skin." + this.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the translated text of this virtual mouse skin.
|
||||||
|
*
|
||||||
|
* @return The translated text of this virtual mouse skin.
|
||||||
|
*/
|
||||||
|
public @NotNull Text getTranslatedText()
|
||||||
|
{
|
||||||
|
return this.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -65,12 +79,12 @@ public enum VirtualMouseSkin implements Nameable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the controller type from its identifier.
|
* Gets the virtual mouse skin from its identifier.
|
||||||
*
|
*
|
||||||
* @param id The identifier of the controller type.
|
* @param id The identifier of the virtual mouse skin.
|
||||||
* @return The controller type if found, else empty.
|
* @return The virtual mouse skin if found, else empty.
|
||||||
*/
|
*/
|
||||||
public static Optional<VirtualMouseSkin> byId(@NotNull String id)
|
public static @NotNull Optional<VirtualMouseSkin> byId(@NotNull String id)
|
||||||
{
|
{
|
||||||
return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst();
|
return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,14 +10,19 @@
|
|||||||
package me.lambdaurora.lambdacontrols.client.compat;
|
package me.lambdaurora.lambdacontrols.client.compat;
|
||||||
|
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||||
|
import net.minecraft.screen.slot.Slot;
|
||||||
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a compatibility handler for a mod.
|
* Represents a compatibility handler for a mod.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.2.0
|
* @version 1.3.2
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
public interface CompatHandler
|
public interface CompatHandler
|
||||||
@@ -33,10 +38,58 @@ public interface CompatHandler
|
|||||||
* Returns whether the mouse is required on the specified screen.
|
* Returns whether the mouse is required on the specified screen.
|
||||||
*
|
*
|
||||||
* @param screen The 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)
|
default boolean requireMouseOnScreen(Screen screen)
|
||||||
{
|
{
|
||||||
return false;
|
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.
|
||||||
|
* <p>
|
||||||
|
* 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,22 @@ package me.lambdaurora.lambdacontrols.client.compat;
|
|||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||||
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import org.aperlambda.lambdacommon.utils.LambdaReflection;
|
import org.aperlambda.lambdacommon.utils.LambdaReflection;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a compatibility handler.
|
* Represents a compatibility handler.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.1.0
|
* @version 1.3.2
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
public class LambdaControlsCompat
|
public class LambdaControlsCompat
|
||||||
@@ -37,7 +41,7 @@ public class LambdaControlsCompat
|
|||||||
*/
|
*/
|
||||||
public static void init(@NotNull LambdaControlsClient mod)
|
public static void init(@NotNull LambdaControlsClient mod)
|
||||||
{
|
{
|
||||||
if (FabricLoader.getInstance().isModLoaded("okzoomer") && LambdaReflection.doesClassExist(OkZoomerCompat.OKZOOMER_CLASS_PATH)) {
|
if (FabricLoader.getInstance().isModLoaded("okzoomer")) {
|
||||||
mod.log("Adding okzoomer compatibility...");
|
mod.log("Adding okzoomer compatibility...");
|
||||||
HANDLERS.add(new OkZoomerCompat());
|
HANDLERS.add(new OkZoomerCompat());
|
||||||
}
|
}
|
||||||
@@ -45,10 +49,34 @@ public class LambdaControlsCompat
|
|||||||
mod.log("Adding REI compatiblity...");
|
mod.log("Adding REI compatiblity...");
|
||||||
HANDLERS.add(new ReiCompat());
|
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));
|
HANDLERS.forEach(handler -> handler.handle(mod));
|
||||||
InputManager.loadButtonBindings(mod.config);
|
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.
|
* Returns whether the mouse is required on the specified screen.
|
||||||
*
|
*
|
||||||
@@ -60,6 +88,58 @@ public class LambdaControlsCompat
|
|||||||
return HANDLERS.stream().anyMatch(handler -> handler.requireMouseOnScreen(screen));
|
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.
|
* Returns whether Roughly Enough Items is present.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -10,8 +10,10 @@
|
|||||||
package me.lambdaurora.lambdacontrols.client.compat;
|
package me.lambdaurora.lambdacontrols.client.compat;
|
||||||
|
|
||||||
import io.github.joaoh1.okzoomer.client.OkZoomerClientMod;
|
import io.github.joaoh1.okzoomer.client.OkZoomerClientMod;
|
||||||
|
import io.github.joaoh1.okzoomer.main.OkZoomerMod;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||||
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||||
|
import org.aperlambda.lambdacommon.Identifier;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
@@ -36,5 +38,26 @@ public class OkZoomerCompat implements CompatHandler
|
|||||||
.category(ButtonBinding.MISC_CATEGORY)
|
.category(ButtonBinding.MISC_CATEGORY)
|
||||||
.linkKeybind(OkZoomerClientMod.zoomKeyBinding)
|
.linkKeybind(OkZoomerClientMod.zoomKeyBinding)
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
|
new ButtonBinding.Builder("zoom.in")
|
||||||
|
.buttons(GLFW.GLFW_GAMEPAD_BUTTON_DPAD_UP, ButtonBinding.axisAsButton(GLFW.GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER, true))
|
||||||
|
.onlyInGame()
|
||||||
|
.cooldown(true)
|
||||||
|
.category(ButtonBinding.MISC_CATEGORY)
|
||||||
|
.linkKeybind(OkZoomerClientMod.increaseZoomKeyBinding)
|
||||||
|
.register();
|
||||||
|
new ButtonBinding.Builder("zoom.out")
|
||||||
|
.buttons(GLFW.GLFW_GAMEPAD_BUTTON_DPAD_UP, ButtonBinding.axisAsButton(GLFW.GLFW_GAMEPAD_AXIS_LEFT_TRIGGER, true))
|
||||||
|
.onlyInGame()
|
||||||
|
.cooldown(true)
|
||||||
|
.category(ButtonBinding.MISC_CATEGORY)
|
||||||
|
.linkKeybind(OkZoomerClientMod.decreaseZoomKeyBinding)
|
||||||
|
.register();
|
||||||
|
new ButtonBinding.Builder("zoom.reset")
|
||||||
|
.onlyInGame()
|
||||||
|
.cooldown(true)
|
||||||
|
.category(ButtonBinding.MISC_CATEGORY)
|
||||||
|
.linkKeybind(OkZoomerClientMod.resetZoomKeyBinding)
|
||||||
|
.register();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,14 @@ import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
|||||||
import me.lambdaurora.lambdacontrols.client.controller.InputHandlers;
|
import me.lambdaurora.lambdacontrols.client.controller.InputHandlers;
|
||||||
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
||||||
import me.lambdaurora.lambdacontrols.client.controller.PressAction;
|
import me.lambdaurora.lambdacontrols.client.controller.PressAction;
|
||||||
|
import me.shedaniel.rei.api.REIHelper;
|
||||||
import me.shedaniel.rei.api.RecipeCategory;
|
import me.shedaniel.rei.api.RecipeCategory;
|
||||||
import me.shedaniel.rei.gui.ContainerScreenOverlay;
|
import me.shedaniel.rei.gui.ContainerScreenOverlay;
|
||||||
import me.shedaniel.rei.gui.RecipeViewingScreen;
|
import me.shedaniel.rei.gui.RecipeViewingScreen;
|
||||||
import me.shedaniel.rei.gui.VillagerRecipeViewingScreen;
|
import me.shedaniel.rei.gui.VillagerRecipeViewingScreen;
|
||||||
import me.shedaniel.rei.gui.widget.EntryListWidget;
|
import me.shedaniel.rei.gui.widget.EntryListWidget;
|
||||||
import me.shedaniel.rei.impl.ScreenHelper;
|
import me.shedaniel.rei.impl.ScreenHelper;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import org.aperlambda.lambdacommon.utils.LambdaReflection;
|
import org.aperlambda.lambdacommon.utils.LambdaReflection;
|
||||||
@@ -37,13 +39,12 @@ import static org.lwjgl.glfw.GLFW.*;
|
|||||||
* Represents a compatibility handler for REI.
|
* Represents a compatibility handler for REI.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.3.0
|
* @version 1.4.0
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
public class ReiCompat implements CompatHandler
|
public class ReiCompat implements CompatHandler
|
||||||
{
|
{
|
||||||
private static EntryListWidget ENTRY_LIST_WIDGET;
|
private static EntryListWidget ENTRY_LIST_WIDGET;
|
||||||
public static ButtonBinding TAB_BACK;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(@NotNull LambdaControlsClient mod)
|
public void handle(@NotNull LambdaControlsClient mod)
|
||||||
@@ -78,7 +79,7 @@ public class ReiCompat implements CompatHandler
|
|||||||
InputManager.registerBinding(new ButtonBinding.Builder(new Identifier("rei", "show_usage"))
|
InputManager.registerBinding(new ButtonBinding.Builder(new Identifier("rei", "show_usage"))
|
||||||
.buttons(GLFW_GAMEPAD_BUTTON_RIGHT_THUMB)
|
.buttons(GLFW_GAMEPAD_BUTTON_RIGHT_THUMB)
|
||||||
.filter((client, binding) -> InputHandlers.inInventory(client, binding) || isViewingScreen(client.currentScreen))
|
.filter((client, binding) -> InputHandlers.inInventory(client, binding) || isViewingScreen(client.currentScreen))
|
||||||
.action((client, button, action) -> {
|
.action((client, button, value, action) -> {
|
||||||
if (action != ButtonState.RELEASE)
|
if (action != ButtonState.RELEASE)
|
||||||
return false;
|
return false;
|
||||||
Optional<ContainerScreenOverlay> overlay = ScreenHelper.getOptionalOverlay();
|
Optional<ContainerScreenOverlay> overlay = ScreenHelper.getOptionalOverlay();
|
||||||
@@ -106,6 +107,17 @@ public class ReiCompat implements CompatHandler
|
|||||||
return screen instanceof RecipeViewingScreen || screen instanceof VillagerRecipeViewingScreen;
|
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()
|
private static EntryListWidget getEntryListWidget()
|
||||||
{
|
{
|
||||||
if (ENTRY_LIST_WIDGET == null) {
|
if (ENTRY_LIST_WIDGET == null) {
|
||||||
@@ -118,7 +130,7 @@ public class ReiCompat implements CompatHandler
|
|||||||
|
|
||||||
private static PressAction handlePage(boolean next)
|
private static PressAction handlePage(boolean next)
|
||||||
{
|
{
|
||||||
return (client, button, action) -> {
|
return (client, button, value, action) -> {
|
||||||
if (action == ButtonState.RELEASE)
|
if (action == ButtonState.RELEASE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -148,7 +160,7 @@ public class ReiCompat implements CompatHandler
|
|||||||
*/
|
*/
|
||||||
private static PressAction handleTab(boolean next)
|
private static PressAction handleTab(boolean next)
|
||||||
{
|
{
|
||||||
return (client, button, action) -> {
|
return (client, button, value, action) -> {
|
||||||
if (action != ButtonState.RELEASE)
|
if (action != ButtonState.RELEASE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
|||||||
* Represents an accessor to REI's RecipeViewingScreen.
|
* Represents an accessor to REI's RecipeViewingScreen.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.3.0
|
* @version 1.4.0
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
@Mixin(RecipeViewingScreen.class)
|
@Mixin(value = RecipeViewingScreen.class, remap = false)
|
||||||
public interface RecipeViewingScreenAccessor
|
public interface RecipeViewingScreenAccessor
|
||||||
{
|
{
|
||||||
@Accessor("categoryBack")
|
@Accessor("categoryBack")
|
||||||
|
|||||||
@@ -21,19 +21,19 @@ import java.util.List;
|
|||||||
* Represents an accessor to REI's VillagerRecipeViewingScreen.
|
* Represents an accessor to REI's VillagerRecipeViewingScreen.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.2.0
|
* @version 1.4.1
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
@Mixin(VillagerRecipeViewingScreen.class)
|
@Mixin(VillagerRecipeViewingScreen.class)
|
||||||
public interface VillagerRecipeViewingScreenAccessor
|
public interface VillagerRecipeViewingScreenAccessor
|
||||||
{
|
{
|
||||||
@Accessor("categories")
|
@Accessor(value = "categories", remap = false)
|
||||||
List<RecipeCategory<?>> getCategories();
|
List<RecipeCategory<?>> getCategories();
|
||||||
|
|
||||||
@Accessor("selectedCategoryIndex")
|
@Accessor(value = "selectedCategoryIndex", remap = false)
|
||||||
int getSelectedCategoryIndex();
|
int getSelectedCategoryIndex();
|
||||||
|
|
||||||
@Accessor("selectedCategoryIndex")
|
@Accessor(value = "selectedCategoryIndex", remap = false)
|
||||||
void setSelectedCategoryIndex(int selectedCategoryIndex);
|
void setSelectedCategoryIndex(int selectedCategoryIndex);
|
||||||
|
|
||||||
@Invoker("init")
|
@Invoker("init")
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import me.lambdaurora.lambdacontrols.client.ButtonState;
|
|||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.options.GameOptions;
|
import net.minecraft.client.options.GameOptions;
|
||||||
import net.minecraft.client.options.KeyBinding;
|
import net.minecraft.client.options.KeyBinding;
|
||||||
import net.minecraft.client.resource.language.I18n;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import org.aperlambda.lambdacommon.Identifier;
|
import org.aperlambda.lambdacommon.Identifier;
|
||||||
@@ -33,7 +32,7 @@ import static org.lwjgl.glfw.GLFW.*;
|
|||||||
* Represents a button binding.
|
* Represents a button binding.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.3.0
|
* @version 1.4.0
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public class ButtonBinding implements Nameable
|
public class ButtonBinding implements Nameable
|
||||||
@@ -45,21 +44,25 @@ public class ButtonBinding implements Nameable
|
|||||||
public static final ButtonCategory MISC_CATEGORY;
|
public static final ButtonCategory MISC_CATEGORY;
|
||||||
|
|
||||||
public static final ButtonBinding ATTACK = new Builder("attack").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER, true)).onlyInGame().register();
|
public static final ButtonBinding ATTACK = new Builder("attack").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER, true)).onlyInGame().register();
|
||||||
public static final ButtonBinding BACK = new Builder("back").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_LEFT_Y, false)).onlyInGame().register();
|
public static final ButtonBinding BACK = new Builder("back").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_LEFT_Y, false))
|
||||||
|
.action(MovementHandler.HANDLER).onlyInGame().register();
|
||||||
public static final ButtonBinding CHAT = new Builder("chat").buttons(GLFW_GAMEPAD_BUTTON_DPAD_RIGHT).onlyInGame().cooldown(true).register();
|
public static final ButtonBinding CHAT = new Builder("chat").buttons(GLFW_GAMEPAD_BUTTON_DPAD_RIGHT).onlyInGame().cooldown(true).register();
|
||||||
public static final ButtonBinding DROP_ITEM = new Builder("drop_item").buttons(GLFW_GAMEPAD_BUTTON_B).onlyInGame().cooldown(true).register();
|
public static final ButtonBinding DROP_ITEM = new Builder("drop_item").buttons(GLFW_GAMEPAD_BUTTON_B).onlyInGame().cooldown(true).register();
|
||||||
public static final ButtonBinding FORWARD = new Builder("forward").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_LEFT_Y, true)).onlyInGame().register();
|
public static final ButtonBinding FORWARD = new Builder("forward").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_LEFT_Y, true))
|
||||||
|
.action(MovementHandler.HANDLER).onlyInGame().register();
|
||||||
public static final ButtonBinding HOTBAR_LEFT = new Builder("hotbar_left").buttons(GLFW_GAMEPAD_BUTTON_LEFT_BUMPER)
|
public static final ButtonBinding HOTBAR_LEFT = new Builder("hotbar_left").buttons(GLFW_GAMEPAD_BUTTON_LEFT_BUMPER)
|
||||||
.action(InputHandlers.handleHotbar(false)).onlyInGame().cooldown(true).register();
|
.action(InputHandlers.handleHotbar(false)).onlyInGame().cooldown(true).register();
|
||||||
public static final ButtonBinding HOTBAR_RIGHT = new Builder("hotbar_right").buttons(GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER)
|
public static final ButtonBinding HOTBAR_RIGHT = new Builder("hotbar_right").buttons(GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER)
|
||||||
.action(InputHandlers.handleHotbar(true)).onlyInGame().cooldown(true).register();
|
.action(InputHandlers.handleHotbar(true)).onlyInGame().cooldown(true).register();
|
||||||
public static final ButtonBinding INVENTORY = new Builder("inventory").buttons(GLFW_GAMEPAD_BUTTON_Y).onlyInGame().cooldown(true).register();
|
public static final ButtonBinding INVENTORY = new Builder("inventory").buttons(GLFW_GAMEPAD_BUTTON_Y).onlyInGame().cooldown(true).register();
|
||||||
public static final ButtonBinding JUMP = new Builder("jump").buttons(GLFW_GAMEPAD_BUTTON_A).onlyInGame().register();
|
public static final ButtonBinding JUMP = new Builder("jump").buttons(GLFW_GAMEPAD_BUTTON_A).onlyInGame().register();
|
||||||
public static final ButtonBinding LEFT = new Builder("left").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_LEFT_X, false)).onlyInGame().register();
|
public static final ButtonBinding LEFT = new Builder("left").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_LEFT_X, false))
|
||||||
|
.action(MovementHandler.HANDLER).onlyInGame().register();
|
||||||
public static final ButtonBinding PAUSE_GAME = new Builder("pause_game").buttons(GLFW_GAMEPAD_BUTTON_START).action(InputHandlers::handlePauseGame).cooldown(true).register();
|
public static final ButtonBinding PAUSE_GAME = new Builder("pause_game").buttons(GLFW_GAMEPAD_BUTTON_START).action(InputHandlers::handlePauseGame).cooldown(true).register();
|
||||||
public static final ButtonBinding PICK_BLOCK = new Builder("pick_block").buttons(GLFW_GAMEPAD_BUTTON_DPAD_LEFT).onlyInGame().cooldown(true).register();
|
public static final ButtonBinding PICK_BLOCK = new Builder("pick_block").buttons(GLFW_GAMEPAD_BUTTON_DPAD_LEFT).onlyInGame().cooldown(true).register();
|
||||||
public static final ButtonBinding PLAYER_LIST = new Builder("player_list").buttons(GLFW_GAMEPAD_BUTTON_BACK).onlyInGame().register();
|
public static final ButtonBinding PLAYER_LIST = new Builder("player_list").buttons(GLFW_GAMEPAD_BUTTON_BACK).onlyInGame().register();
|
||||||
public static final ButtonBinding RIGHT = new Builder("right").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_LEFT_X, true)).register();
|
public static final ButtonBinding RIGHT = new Builder("right").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_LEFT_X, true))
|
||||||
|
.action(MovementHandler.HANDLER).register();
|
||||||
public static final ButtonBinding SCREENSHOT = new Builder("screenshot").buttons(GLFW_GAMEPAD_BUTTON_DPAD_UP, GLFW_GAMEPAD_BUTTON_A)
|
public static final ButtonBinding SCREENSHOT = new Builder("screenshot").buttons(GLFW_GAMEPAD_BUTTON_DPAD_UP, GLFW_GAMEPAD_BUTTON_A)
|
||||||
.action(InputHandlers::handleScreenshot).cooldown(true).register();
|
.action(InputHandlers::handleScreenshot).cooldown(true).register();
|
||||||
public static final ButtonBinding SLOT_DOWN = new Builder("slot_down").buttons(GLFW_GAMEPAD_BUTTON_DPAD_DOWN)
|
public static final ButtonBinding SLOT_DOWN = new Builder("slot_down").buttons(GLFW_GAMEPAD_BUTTON_DPAD_DOWN)
|
||||||
@@ -229,7 +232,7 @@ public class ButtonBinding implements Nameable
|
|||||||
* @param client The client instance.
|
* @param client The client instance.
|
||||||
* @param state The state.
|
* @param state The state.
|
||||||
*/
|
*/
|
||||||
public void handle(@NotNull MinecraftClient client, @NotNull ButtonState state)
|
public void handle(@NotNull MinecraftClient client, float value, @NotNull ButtonState state)
|
||||||
{
|
{
|
||||||
if (state == ButtonState.REPEAT && this.hasCooldown && this.cooldown != 0)
|
if (state == ButtonState.REPEAT && this.hasCooldown && this.cooldown != 0)
|
||||||
return;
|
return;
|
||||||
@@ -238,7 +241,7 @@ public class ButtonBinding implements Nameable
|
|||||||
|
|
||||||
}
|
}
|
||||||
for (int i = this.actions.size() - 1; i >= 0; i--) {
|
for (int i = this.actions.size() - 1; i >= 0; i--) {
|
||||||
if (this.actions.get(i).press(client, this, state))
|
if (this.actions.get(i).press(client, this, value, state))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -254,8 +257,7 @@ public class ButtonBinding implements Nameable
|
|||||||
*
|
*
|
||||||
* @return The translation key.
|
* @return The translation key.
|
||||||
*/
|
*/
|
||||||
public @NotNull
|
public @NotNull String getTranslationKey()
|
||||||
String getTranslationKey()
|
|
||||||
{
|
{
|
||||||
return "lambdacontrols.action." + this.getName();
|
return "lambdacontrols.action." + this.getName();
|
||||||
}
|
}
|
||||||
@@ -283,6 +285,18 @@ public class ButtonBinding implements Nameable
|
|||||||
return positive ? 100 + axis : 200 + axis;
|
return positive ? 100 + axis : 200 + axis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the specified button is an axis or not.
|
||||||
|
*
|
||||||
|
* @param button The button.
|
||||||
|
* @return True if the button is an axis, else false.
|
||||||
|
*/
|
||||||
|
public static boolean isAxis(int button)
|
||||||
|
{
|
||||||
|
button %= 500;
|
||||||
|
return button >= 100;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the second Joycon's specified button code.
|
* Returns the second Joycon's specified button code.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
package me.lambdaurora.lambdacontrols.client.controller;
|
package me.lambdaurora.lambdacontrols.client.controller;
|
||||||
|
|
||||||
import me.lambdaurora.lambdacontrols.client.ButtonState;
|
import me.lambdaurora.lambdacontrols.client.ButtonState;
|
||||||
|
import me.lambdaurora.lambdacontrols.client.LambdaInput;
|
||||||
import me.lambdaurora.lambdacontrols.client.mixin.AdvancementsScreenAccessor;
|
import me.lambdaurora.lambdacontrols.client.mixin.AdvancementsScreenAccessor;
|
||||||
import me.lambdaurora.lambdacontrols.client.mixin.CreativeInventoryScreenAccessor;
|
import me.lambdaurora.lambdacontrols.client.mixin.CreativeInventoryScreenAccessor;
|
||||||
import me.lambdaurora.lambdacontrols.client.mixin.RecipeBookWidgetAccessor;
|
import me.lambdaurora.lambdacontrols.client.mixin.RecipeBookWidgetAccessor;
|
||||||
@@ -38,7 +39,7 @@ import java.util.stream.Collectors;
|
|||||||
* Represents some input handlers.
|
* Represents some input handlers.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.3.0
|
* @version 1.4.0
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
public class InputHandlers
|
public class InputHandlers
|
||||||
@@ -49,7 +50,7 @@ public class InputHandlers
|
|||||||
|
|
||||||
public static PressAction handleHotbar(boolean next)
|
public static PressAction handleHotbar(boolean next)
|
||||||
{
|
{
|
||||||
return (client, button, action) -> {
|
return (client, button, value, action) -> {
|
||||||
if (action == ButtonState.RELEASE)
|
if (action == ButtonState.RELEASE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -74,6 +75,8 @@ public class InputHandlers
|
|||||||
RecipeBookWidgetAccessor recipeBook = (RecipeBookWidgetAccessor) ((InventoryScreen) client.currentScreen).getRecipeBookWidget();
|
RecipeBookWidgetAccessor recipeBook = (RecipeBookWidgetAccessor) ((InventoryScreen) client.currentScreen).getRecipeBookWidget();
|
||||||
List<RecipeGroupButtonWidget> tabs = recipeBook.getTabButtons();
|
List<RecipeGroupButtonWidget> tabs = recipeBook.getTabButtons();
|
||||||
RecipeGroupButtonWidget currentTab = recipeBook.getCurrentTab();
|
RecipeGroupButtonWidget currentTab = recipeBook.getCurrentTab();
|
||||||
|
if (currentTab == null)
|
||||||
|
return false;
|
||||||
int nextTab = tabs.indexOf(currentTab) + (next ? 1 : -1);
|
int nextTab = tabs.indexOf(currentTab) + (next ? 1 : -1);
|
||||||
if (nextTab < 0)
|
if (nextTab < 0)
|
||||||
nextTab = tabs.size() - 1;
|
nextTab = tabs.size() - 1;
|
||||||
@@ -83,10 +86,13 @@ public class InputHandlers
|
|||||||
recipeBook.setCurrentTab(currentTab = tabs.get(nextTab));
|
recipeBook.setCurrentTab(currentTab = tabs.get(nextTab));
|
||||||
currentTab.setToggled(true);
|
currentTab.setToggled(true);
|
||||||
recipeBook.lambdacontrols_refreshResults(true);
|
recipeBook.lambdacontrols_refreshResults(true);
|
||||||
|
return true;
|
||||||
} else if (client.currentScreen instanceof AdvancementsScreen) {
|
} else if (client.currentScreen instanceof AdvancementsScreen) {
|
||||||
AdvancementsScreenAccessor screen = (AdvancementsScreenAccessor) client.currentScreen;
|
AdvancementsScreenAccessor screen = (AdvancementsScreenAccessor) client.currentScreen;
|
||||||
List<AdvancementTab> tabs = screen.getTabs().values().stream().distinct().collect(Collectors.toList());
|
List<AdvancementTab> tabs = screen.getTabs().values().stream().distinct().collect(Collectors.toList());
|
||||||
AdvancementTab tab = screen.getSelectedTab();
|
AdvancementTab tab = screen.getSelectedTab();
|
||||||
|
if (tab == null)
|
||||||
|
return false;
|
||||||
for (int i = 0; i < tabs.size(); i++) {
|
for (int i = 0; i < tabs.size(); i++) {
|
||||||
if (tabs.get(i).equals(tab)) {
|
if (tabs.get(i).equals(tab)) {
|
||||||
int nextTab = i + (next ? 1 : -1);
|
int nextTab = i + (next ? 1 : -1);
|
||||||
@@ -98,12 +104,13 @@ public class InputHandlers
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handlePauseGame(@NotNull MinecraftClient client, @NotNull ButtonBinding binding, @NotNull ButtonState action)
|
public static boolean handlePauseGame(@NotNull MinecraftClient client, @NotNull ButtonBinding binding, float value, @NotNull ButtonState action)
|
||||||
{
|
{
|
||||||
if (action == ButtonState.PRESS) {
|
if (action == ButtonState.PRESS) {
|
||||||
// If in game, then pause the game.
|
// If in game, then pause the game.
|
||||||
@@ -125,15 +132,15 @@ public class InputHandlers
|
|||||||
* @param action The action done on the binding.
|
* @param action The action done on the binding.
|
||||||
* @return True if handled, else false.
|
* @return True if handled, else false.
|
||||||
*/
|
*/
|
||||||
public static boolean handleScreenshot(@NotNull MinecraftClient client, @NotNull ButtonBinding binding, @NotNull ButtonState action)
|
public static boolean handleScreenshot(@NotNull MinecraftClient client, @NotNull ButtonBinding binding, float value, @NotNull ButtonState action)
|
||||||
{
|
{
|
||||||
if (action == ButtonState.PRESS)
|
if (action == ButtonState.RELEASE)
|
||||||
ScreenshotUtils.saveScreenshot(client.runDirectory, client.getWindow().getFramebufferWidth(), client.getWindow().getFramebufferHeight(), client.getFramebuffer(),
|
ScreenshotUtils.saveScreenshot(client.runDirectory, client.getWindow().getFramebufferWidth(), client.getWindow().getFramebufferHeight(), client.getFramebuffer(),
|
||||||
text -> client.execute(() -> client.inGameHud.getChatHud().addMessage(text)));
|
text -> client.execute(() -> client.inGameHud.getChatHud().addMessage(text)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handleToggleSneak(@NotNull MinecraftClient client, @NotNull ButtonBinding button, @NotNull ButtonState action)
|
public static boolean handleToggleSneak(@NotNull MinecraftClient client, @NotNull ButtonBinding button, float value, @NotNull ButtonState action)
|
||||||
{
|
{
|
||||||
if (client.player != null && !client.player.abilities.flying) {
|
if (client.player != null && !client.player.abilities.flying) {
|
||||||
button.asKeyBinding().filter(binding -> action == ButtonState.PRESS).ifPresent(binding -> ((KeyBindingAccessor) binding).lambdacontrols_handlePressState(!binding.isPressed()));
|
button.asKeyBinding().filter(binding -> action == ButtonState.PRESS).ifPresent(binding -> ((KeyBindingAccessor) binding).lambdacontrols_handlePressState(!binding.isPressed()));
|
||||||
@@ -144,7 +151,7 @@ public class InputHandlers
|
|||||||
|
|
||||||
public static PressAction handleInventorySlotPad(int direction)
|
public static PressAction handleInventorySlotPad(int direction)
|
||||||
{
|
{
|
||||||
return (client, binding, action) -> {
|
return (client, binding, value, action) -> {
|
||||||
if (!(client.currentScreen instanceof HandledScreen && action != ButtonState.RELEASE))
|
if (!(client.currentScreen instanceof HandledScreen && action != ButtonState.RELEASE))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -235,6 +242,20 @@ public class InputHandlers
|
|||||||
return client.currentScreen == null;
|
return client.currentScreen == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the client is in a non-interactive screen (which means require mouse input) or not.
|
||||||
|
*
|
||||||
|
* @param client The client instance.
|
||||||
|
* @param binding The affected binding.
|
||||||
|
* @return True if the client is in a non-interactive screen, else false.
|
||||||
|
*/
|
||||||
|
public static boolean inNonInteractiveScreens(@NotNull MinecraftClient client, @NotNull ButtonBinding binding)
|
||||||
|
{
|
||||||
|
if (client.currentScreen == null)
|
||||||
|
return false;
|
||||||
|
return !LambdaInput.isScreenInteractive(client.currentScreen);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the client is in an inventory or not.
|
* Returns whether the client is in an inventory or not.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import net.minecraft.client.options.KeyBinding;
|
|||||||
import net.minecraft.client.util.InputUtil;
|
import net.minecraft.client.util.InputUtil;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import org.aperlambda.lambdacommon.Identifier;
|
import org.aperlambda.lambdacommon.Identifier;
|
||||||
|
import org.aperlambda.lambdacommon.utils.Pair;
|
||||||
import org.aperlambda.lambdacommon.utils.function.PairPredicate;
|
import org.aperlambda.lambdacommon.utils.function.PairPredicate;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
@@ -32,7 +33,7 @@ import java.util.stream.Stream;
|
|||||||
* Represents an input manager for controllers.
|
* Represents an input manager for controllers.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.3.0
|
* @version 1.4.0
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
public class InputManager
|
public class InputManager
|
||||||
@@ -41,6 +42,7 @@ public class InputManager
|
|||||||
private static final List<ButtonBinding> BINDINGS = new ArrayList<>();
|
private static final List<ButtonBinding> BINDINGS = new ArrayList<>();
|
||||||
private static final List<ButtonCategory> CATEGORIES = new ArrayList<>();
|
private static final List<ButtonCategory> CATEGORIES = new ArrayList<>();
|
||||||
public static final Map<Integer, ButtonState> STATES = new HashMap<>();
|
public static final Map<Integer, ButtonState> STATES = new HashMap<>();
|
||||||
|
public static final Map<Integer, Float> BUTTON_VALUES = new HashMap<>();
|
||||||
private int prevTargetMouseX = 0;
|
private int prevTargetMouseX = 0;
|
||||||
private int prevTargetMouseY = 0;
|
private int prevTargetMouseY = 0;
|
||||||
private int targetMouseX = 0;
|
private int targetMouseX = 0;
|
||||||
@@ -244,6 +246,23 @@ public class InputManager
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float getBindingValue(@NotNull ButtonBinding binding, @NotNull ButtonState state)
|
||||||
|
{
|
||||||
|
if (state.isUnpressed())
|
||||||
|
return 0.f;
|
||||||
|
|
||||||
|
float value = 0.f;
|
||||||
|
for (int btn : binding.getButton()) {
|
||||||
|
if (ButtonBinding.isAxis(btn)) {
|
||||||
|
value = BUTTON_VALUES.getOrDefault(btn, 1.f);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
value = 1.f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the button has duplicated bindings.
|
* Returns whether the button has duplicated bindings.
|
||||||
*
|
*
|
||||||
@@ -317,7 +336,7 @@ public class InputManager
|
|||||||
public static void updateBindings(@NotNull MinecraftClient client)
|
public static void updateBindings(@NotNull MinecraftClient client)
|
||||||
{
|
{
|
||||||
List<Integer> skipButtons = new ArrayList<>();
|
List<Integer> skipButtons = new ArrayList<>();
|
||||||
Map<ButtonBinding, ButtonState> states = new HashMap<>();
|
Map<ButtonBinding, Pair<ButtonState, Float>> states = new HashMap<>();
|
||||||
for (ButtonBinding binding : BINDINGS) {
|
for (ButtonBinding binding : BINDINGS) {
|
||||||
ButtonState state = binding.isAvailable(client) ? getBindingState(binding) : ButtonState.NONE;
|
ButtonState state = binding.isAvailable(client) ? getBindingState(binding) : ButtonState.NONE;
|
||||||
if (skipButtons.stream().anyMatch(btn -> containsButton(binding.getButton(), btn))) {
|
if (skipButtons.stream().anyMatch(btn -> containsButton(binding.getButton(), btn))) {
|
||||||
@@ -330,12 +349,15 @@ public class InputManager
|
|||||||
binding.update();
|
binding.update();
|
||||||
if (binding.pressed)
|
if (binding.pressed)
|
||||||
Arrays.stream(binding.getButton()).forEach(skipButtons::add);
|
Arrays.stream(binding.getButton()).forEach(skipButtons::add);
|
||||||
states.put(binding, state);
|
|
||||||
|
float value = getBindingValue(binding, state);
|
||||||
|
|
||||||
|
states.put(binding, Pair.of(state, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
states.forEach((binding, state) -> {
|
states.forEach((binding, state) -> {
|
||||||
if (state != ButtonState.NONE) {
|
if (state.key != ButtonState.NONE) {
|
||||||
binding.handle(client, state);
|
binding.handle(client, state.value, state.key);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -363,12 +385,12 @@ public class InputManager
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new key binding instance.
|
* Returns a new key binding instance.
|
||||||
* @param id The identifier of the key binding.
|
*
|
||||||
* @param type The type.
|
* @param id The identifier of the key binding.
|
||||||
* @param code The code.
|
* @param type The type.
|
||||||
|
* @param code The code.
|
||||||
* @param category The category of the key binding.
|
* @param category The category of the key binding.
|
||||||
* @return The key binding.
|
* @return The key binding.
|
||||||
*
|
|
||||||
* @see #makeKeyBinding(Identifier, InputUtil.Type, int, String)
|
* @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)
|
public static @NotNull KeyBinding makeKeyBinding(@NotNull net.minecraft.util.Identifier id, InputUtil.Type type, int code, @NotNull String category)
|
||||||
@@ -378,12 +400,12 @@ public class InputManager
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new key binding instance.
|
* Returns a new key binding instance.
|
||||||
* @param id The identifier of the key binding.
|
*
|
||||||
* @param type The type.
|
* @param id The identifier of the key binding.
|
||||||
* @param code The code.
|
* @param type The type.
|
||||||
|
* @param code The code.
|
||||||
* @param category The category of the key binding.
|
* @param category The category of the key binding.
|
||||||
* @return The key binding.
|
* @return The key binding.
|
||||||
*
|
|
||||||
* @see #makeKeyBinding(net.minecraft.util.Identifier, InputUtil.Type, int, String)
|
* @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)
|
public static @NotNull KeyBinding makeKeyBinding(@NotNull Identifier id, InputUtil.Type type, int code, @NotNull String category)
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* 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.controller;
|
||||||
|
|
||||||
|
import me.lambdaurora.lambdacontrols.client.ButtonState;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the movement handler.
|
||||||
|
*
|
||||||
|
* @author LambdAurora
|
||||||
|
* @version 1.4.0
|
||||||
|
* @since 1.4.0
|
||||||
|
*/
|
||||||
|
public final class MovementHandler implements PressAction
|
||||||
|
{
|
||||||
|
public static final MovementHandler HANDLER = new MovementHandler();
|
||||||
|
private boolean shouldOverrideMovement = false;
|
||||||
|
private boolean pressingForward = false;
|
||||||
|
private boolean pressingBack = false;
|
||||||
|
private boolean pressingLeft = false;
|
||||||
|
private boolean pressingRight = false;
|
||||||
|
private float movementForward = 0.f;
|
||||||
|
private float movementSideways = 0.f;
|
||||||
|
|
||||||
|
private MovementHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies movement input of this handler to the player's input.
|
||||||
|
*
|
||||||
|
* @param player The client player.
|
||||||
|
*/
|
||||||
|
public void applyMovement(@NotNull ClientPlayerEntity player)
|
||||||
|
{
|
||||||
|
if (!this.shouldOverrideMovement)
|
||||||
|
return;
|
||||||
|
player.input.pressingForward = this.pressingForward;
|
||||||
|
player.input.pressingBack = this.pressingBack;
|
||||||
|
player.input.pressingLeft = this.pressingLeft;
|
||||||
|
player.input.pressingRight = this.pressingRight;
|
||||||
|
player.input.movementForward = this.movementForward;
|
||||||
|
player.input.movementSideways = this.movementSideways;
|
||||||
|
this.shouldOverrideMovement = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean press(@NotNull MinecraftClient client, @NotNull ButtonBinding button, float value, @NotNull ButtonState action)
|
||||||
|
{
|
||||||
|
if (client.currentScreen != null || client.player == null)
|
||||||
|
return this.shouldOverrideMovement = false;
|
||||||
|
|
||||||
|
int direction = 0;
|
||||||
|
if (button == ButtonBinding.FORWARD || button == ButtonBinding.LEFT)
|
||||||
|
direction = 1;
|
||||||
|
else if (button == ButtonBinding.BACK || button == ButtonBinding.RIGHT)
|
||||||
|
direction = -1;
|
||||||
|
|
||||||
|
if (direction == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
this.shouldOverrideMovement = true;
|
||||||
|
|
||||||
|
value = (float) Math.pow(value, 2);
|
||||||
|
|
||||||
|
if (button == ButtonBinding.FORWARD || button == ButtonBinding.BACK) {
|
||||||
|
// Handle forward movement.
|
||||||
|
this.pressingForward = direction > 0;
|
||||||
|
this.pressingBack = direction < 0;
|
||||||
|
this.movementForward = direction * value;
|
||||||
|
|
||||||
|
// Slowing down if sneaking.
|
||||||
|
if (client.player.input.sneaking)
|
||||||
|
this.movementForward *= 0.3D;
|
||||||
|
} else {
|
||||||
|
// Handle sideways movement.
|
||||||
|
this.pressingLeft = direction > 0;
|
||||||
|
this.pressingRight = direction < 0;
|
||||||
|
this.movementSideways = direction * value;
|
||||||
|
|
||||||
|
// Slowing down if sneaking.
|
||||||
|
if (client.player.input.sneaking)
|
||||||
|
this.movementSideways *= 0.3D;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,13 +18,13 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
* Represents a press action callback.
|
* Represents a press action callback.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.1.0
|
* @version 1.4.0
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface PressAction
|
public interface PressAction
|
||||||
{
|
{
|
||||||
PressAction DEFAULT_ACTION = (client, button, action) -> {
|
PressAction DEFAULT_ACTION = (client, button, value, action) -> {
|
||||||
if (action == ButtonState.REPEAT || client.currentScreen != null)
|
if (action == ButtonState.REPEAT || client.currentScreen != null)
|
||||||
return false;
|
return false;
|
||||||
button.asKeyBinding().ifPresent(binding -> ((KeyBindingAccessor) binding).lambdacontrols_handlePressState(button.isButtonDown()));
|
button.asKeyBinding().ifPresent(binding -> ((KeyBindingAccessor) binding).lambdacontrols_handlePressState(button.isButtonDown()));
|
||||||
@@ -37,5 +37,5 @@ public interface PressAction
|
|||||||
* @param client The client instance.
|
* @param client The client instance.
|
||||||
* @param action The action done.
|
* @param action The action done.
|
||||||
*/
|
*/
|
||||||
boolean press(@NotNull MinecraftClient client, @NotNull ButtonBinding button, @NotNull ButtonState action);
|
boolean press(@NotNull MinecraftClient client, @NotNull ButtonBinding button, float value, @NotNull ButtonState action);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
|||||||
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||||
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
||||||
import me.lambdaurora.spruceui.SpruceButtonWidget;
|
import me.lambdaurora.spruceui.SpruceButtonWidget;
|
||||||
|
import me.lambdaurora.spruceui.SpruceTexts;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.screen.options.ControlsOptionsScreen;
|
import net.minecraft.client.gui.screen.options.ControlsOptionsScreen;
|
||||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
@@ -61,7 +62,7 @@ public class ControllerControlsScreen extends Screen
|
|||||||
btn -> this.client.openScreen(new ControlsOptionsScreen(this, this.client.options))));
|
btn -> this.client.openScreen(new ControlsOptionsScreen(this, this.client.options))));
|
||||||
if (!this.hideSettings)
|
if (!this.hideSettings)
|
||||||
this.addButton(new SpruceButtonWidget(this.width / 2 - 155 + 160, 18, 150, 20,
|
this.addButton(new SpruceButtonWidget(this.width / 2 - 155 + 160, 18, 150, 20,
|
||||||
new TranslatableText("menu.options"),
|
SpruceTexts.MENU_OPTIONS,
|
||||||
btn -> this.client.openScreen(new LambdaControlsSettingsScreen(this, true))));
|
btn -> this.client.openScreen(new LambdaControlsSettingsScreen(this, true))));
|
||||||
this.bindingsListWidget = new ControlsListWidget(this, this.client);
|
this.bindingsListWidget = new ControlsListWidget(this, this.client);
|
||||||
this.children.add(this.bindingsListWidget);
|
this.children.add(this.bindingsListWidget);
|
||||||
@@ -69,7 +70,7 @@ public class ControllerControlsScreen extends Screen
|
|||||||
new TranslatableText("controls.resetAll"),
|
new TranslatableText("controls.resetAll"),
|
||||||
btn -> InputManager.streamBindings().forEach(binding -> this.mod.config.setButtonBinding(binding, binding.getDefaultButton()))));
|
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,
|
this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, 20,
|
||||||
new TranslatableText("gui.done"),
|
SpruceTexts.GUI_DONE,
|
||||||
btn -> this.client.openScreen(this.parent)));
|
btn -> this.client.openScreen(this.parent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ package me.lambdaurora.lambdacontrols.client.gui;
|
|||||||
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||||
import me.lambdaurora.lambdacontrols.client.controller.ButtonCategory;
|
import me.lambdaurora.lambdacontrols.client.controller.ButtonCategory;
|
||||||
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
||||||
|
import me.lambdaurora.spruceui.SpruceTexts;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
@@ -105,7 +106,7 @@ public class ControlsListWidget extends ElementListWidget<ControlsListWidget.Ent
|
|||||||
return new TranslatableText("narrator.controls.reset", bindingName);
|
return new TranslatableText("narrator.controls.reset", bindingName);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.unboundButton = new ButtonWidget(0, 0, 50, 20, new TranslatableText("lambdacontrols.menu.unbound"),
|
this.unboundButton = new ButtonWidget(0, 0, 50, 20, SpruceTexts.OPTIONS_GENERIC_UNBOUND,
|
||||||
btn -> {
|
btn -> {
|
||||||
gui.mod.config.setButtonBinding(binding, UNBOUND);
|
gui.mod.config.setButtonBinding(binding, UNBOUND);
|
||||||
gui.focusedBinding = null;
|
gui.focusedBinding = null;
|
||||||
|
|||||||
@@ -13,11 +13,12 @@ import me.lambdaurora.lambdacontrols.ControlsMode;
|
|||||||
import me.lambdaurora.lambdacontrols.LambdaControlsConstants;
|
import me.lambdaurora.lambdacontrols.LambdaControlsConstants;
|
||||||
import me.lambdaurora.lambdacontrols.client.HudSide;
|
import me.lambdaurora.lambdacontrols.client.HudSide;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
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.lambdacontrols.client.controller.ButtonBinding;
|
||||||
import me.lambdaurora.spruceui.hud.Hud;
|
import me.lambdaurora.spruceui.hud.Hud;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.resource.language.I18n;
|
import net.minecraft.client.resource.language.I18n;
|
||||||
|
import net.minecraft.client.util.Window;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -31,26 +32,27 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
* Represents the LambdaControls HUD.
|
* Represents the LambdaControls HUD.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.3.0
|
* @version 1.3.2
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public class LambdaControlsHud extends Hud
|
public class LambdaControlsHud extends Hud
|
||||||
{
|
{
|
||||||
private final LambdaControlsClient mod;
|
private final LambdaControlsClient mod;
|
||||||
private MinecraftClient client;
|
private MinecraftClient client;
|
||||||
private int attackWidth = 0;
|
private int attackWidth = 0;
|
||||||
private int attackButtonWidth = 0;
|
private int attackButtonWidth = 0;
|
||||||
private int dropItemWidth = 0;
|
private int dropItemWidth = 0;
|
||||||
private int dropItemButtonWidth = 0;
|
private int dropItemButtonWidth = 0;
|
||||||
private int inventoryWidth = 0;
|
private int inventoryWidth = 0;
|
||||||
private int inventoryButtonWidth = 0;
|
private int inventoryButtonWidth = 0;
|
||||||
private int swapHandsWidth = 0;
|
private int swapHandsWidth = 0;
|
||||||
private int swapHandsButtonWidth = 0;
|
private int swapHandsButtonWidth = 0;
|
||||||
private int useWidth = 0;
|
private int useWidth = 0;
|
||||||
private int useButtonWidth = 0;
|
private int useButtonWidth = 0;
|
||||||
private BlockHitResult placeHitResult;
|
private BlockHitResult placeHitResult;
|
||||||
private String attackAction = "";
|
private String attackAction = "";
|
||||||
private String placeAction = "";
|
private String placeAction = "";
|
||||||
|
private int ticksDisplayedCrosshair = 0;
|
||||||
|
|
||||||
public LambdaControlsHud(@NotNull LambdaControlsClient mod)
|
public LambdaControlsHud(@NotNull LambdaControlsClient mod)
|
||||||
{
|
{
|
||||||
@@ -86,6 +88,19 @@ public class LambdaControlsHud extends Hud
|
|||||||
this.renderFirstSection(matrices, this.mod.config.getHudSide() == HudSide.LEFT ? 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);
|
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(MatrixStack matrices, int x, int y)
|
public void renderFirstIcons(MatrixStack matrices, int x, int y)
|
||||||
@@ -177,7 +192,7 @@ public class LambdaControlsHud extends Hud
|
|||||||
|
|
||||||
// Update "Use" tip status.
|
// Update "Use" tip status.
|
||||||
if (this.client.crosshairTarget.getType() == HitResult.Type.MISS) {
|
if (this.client.crosshairTarget.getType() == HitResult.Type.MISS) {
|
||||||
this.placeHitResult = LambdaInput.tryFrontPlace(this.client);
|
this.placeHitResult = this.mod.reacharound.getLastReacharoundResult();
|
||||||
this.attackAction = "";
|
this.attackAction = "";
|
||||||
this.attackWidth = 0;
|
this.attackWidth = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -190,8 +205,26 @@ public class LambdaControlsHud extends Hud
|
|||||||
this.attackWidth = this.width(attackAction);
|
this.attackWidth = this.width(attackAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = this.client.player.getMainHandStack();
|
if (this.mod.reacharound.isLastReacharoundVertical()) {
|
||||||
if ((stack == null || stack.isEmpty()) && ((stack = this.client.player.getOffHandStack()) == null || stack.isEmpty())) {
|
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 = "";
|
placeAction = "";
|
||||||
} else {
|
} else {
|
||||||
if (this.placeHitResult != null && stack.getItem() instanceof BlockItem) {
|
if (this.placeHitResult != null && stack.getItem() instanceof BlockItem) {
|
||||||
@@ -201,6 +234,10 @@ public class LambdaControlsHud extends Hud
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String customUseAction = LambdaControlsCompat.getUseActionAt(this.client, this.placeHitResult);
|
||||||
|
if (customUseAction != null)
|
||||||
|
placeAction = customUseAction;
|
||||||
|
|
||||||
this.placeAction = placeAction;
|
this.placeAction = placeAction;
|
||||||
|
|
||||||
// Cache the "Use" tip width.
|
// Cache the "Use" tip width.
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package me.lambdaurora.lambdacontrols.client.gui;
|
|||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||||
|
import me.lambdaurora.lambdacontrols.client.LambdaInput;
|
||||||
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||||
import me.lambdaurora.lambdacontrols.client.util.HandledScreenAccessor;
|
import me.lambdaurora.lambdacontrols.client.util.HandledScreenAccessor;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
@@ -24,14 +25,11 @@ import org.aperlambda.lambdacommon.utils.Pair;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the LambdaControls renderer.
|
* Represents the LambdaControls renderer.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.3.0
|
* @version 1.3.2
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
public class LambdaControlsRenderer
|
public class LambdaControlsRenderer
|
||||||
@@ -231,7 +229,7 @@ public class LambdaControlsRenderer
|
|||||||
|
|
||||||
public static void renderVirtualCursor(@NotNull MatrixStack matrices, @NotNull MinecraftClient client)
|
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;
|
return;
|
||||||
|
|
||||||
int mouseX = (int) (client.mouse.getX() * (double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth());
|
int mouseX = (int) (client.mouse.getX() * (double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth());
|
||||||
@@ -240,27 +238,13 @@ public class LambdaControlsRenderer
|
|||||||
boolean hoverSlot = false;
|
boolean hoverSlot = false;
|
||||||
|
|
||||||
if (client.currentScreen instanceof HandledScreen) {
|
if (client.currentScreen instanceof HandledScreen) {
|
||||||
HandledScreen inventoryScreen = (HandledScreen) client.currentScreen;
|
HandledScreenAccessor inventoryScreen = (HandledScreenAccessor) client.currentScreen;
|
||||||
HandledScreenAccessor accessor = (HandledScreenAccessor) inventoryScreen;
|
int guiLeft = inventoryScreen.getX();
|
||||||
int guiLeft = accessor.getX();
|
int guiTop = inventoryScreen.getY();
|
||||||
int guiTop = accessor.getY();
|
|
||||||
|
|
||||||
// Finds the closest slot in the GUI within 14 pixels.
|
Slot slot = inventoryScreen.lambdacontrols_getSlotAt(mouseX, mouseY);
|
||||||
int finalMouseX = mouseX;
|
|
||||||
int finalMouseY = mouseY;
|
|
||||||
Optional<Pair<Slot, Double>> closestSlot = inventoryScreen.getScreenHandler().slots.parallelStream()
|
|
||||||
.map(slot -> {
|
|
||||||
int x = guiLeft + slot.x + 8;
|
|
||||||
int y = guiTop + slot.y + 8;
|
|
||||||
|
|
||||||
// Distance between the slot and the cursor.
|
if (slot != null) {
|
||||||
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.x;
|
mouseX = guiLeft + slot.x;
|
||||||
mouseY = guiTop + slot.y;
|
mouseY = guiTop + slot.y;
|
||||||
hoverSlot = true;
|
hoverSlot = true;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
|||||||
import me.lambdaurora.lambdacontrols.client.controller.Controller;
|
import me.lambdaurora.lambdacontrols.client.controller.Controller;
|
||||||
import me.lambdaurora.spruceui.SpruceButtonWidget;
|
import me.lambdaurora.spruceui.SpruceButtonWidget;
|
||||||
import me.lambdaurora.spruceui.SpruceLabelWidget;
|
import me.lambdaurora.spruceui.SpruceLabelWidget;
|
||||||
|
import me.lambdaurora.spruceui.SpruceTexts;
|
||||||
import me.lambdaurora.spruceui.Tooltip;
|
import me.lambdaurora.spruceui.Tooltip;
|
||||||
import me.lambdaurora.spruceui.option.*;
|
import me.lambdaurora.spruceui.option.*;
|
||||||
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
|
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
|
||||||
@@ -51,6 +52,7 @@ public class LambdaControlsSettingsScreen extends Screen
|
|||||||
private final Option autoJumpOption;
|
private final Option autoJumpOption;
|
||||||
private final Option fastBlockPlacingOption;
|
private final Option fastBlockPlacingOption;
|
||||||
private final Option frontBlockPlacingOption;
|
private final Option frontBlockPlacingOption;
|
||||||
|
private final Option verticalReacharoundOption;
|
||||||
private final Option flyDriftingOption;
|
private final Option flyDriftingOption;
|
||||||
private final Option flyVerticalDriftingOption;
|
private final Option flyVerticalDriftingOption;
|
||||||
// Controller options
|
// Controller options
|
||||||
@@ -86,14 +88,14 @@ public class LambdaControlsSettingsScreen extends Screen
|
|||||||
synchronized (this.mod.config) {
|
synchronized (this.mod.config) {
|
||||||
this.mod.config.setRotationSpeed(newValue);
|
this.mod.config.setRotationSpeed(newValue);
|
||||||
}
|
}
|
||||||
}, option -> option.getDisplayPrefix().append(String.valueOf(option.get())),
|
}, option -> option.getDisplayText(new LiteralText(String.valueOf(option.get()))),
|
||||||
new TranslatableText("lambdacontrols.tooltip.rotation_speed"));
|
new TranslatableText("lambdacontrols.tooltip.rotation_speed"));
|
||||||
this.mouseSpeedOption = new SpruceDoubleOption("lambdacontrols.menu.mouse_speed", 0.0, 150.0, 0.5F, this.mod.config::getMouseSpeed,
|
this.mouseSpeedOption = new SpruceDoubleOption("lambdacontrols.menu.mouse_speed", 0.0, 150.0, 0.5F, this.mod.config::getMouseSpeed,
|
||||||
newValue -> {
|
newValue -> {
|
||||||
synchronized (this.mod.config) {
|
synchronized (this.mod.config) {
|
||||||
this.mod.config.setMouseSpeed(newValue);
|
this.mod.config.setMouseSpeed(newValue);
|
||||||
}
|
}
|
||||||
}, option -> option.getDisplayPrefix().append(String.valueOf(option.get())),
|
}, option -> option.getDisplayText(new LiteralText(String.valueOf(option.get()))),
|
||||||
new TranslatableText("lambdacontrols.tooltip.mouse_speed"));
|
new TranslatableText("lambdacontrols.tooltip.mouse_speed"));
|
||||||
this.resetOption = new SpruceResetOption(btn -> {
|
this.resetOption = new SpruceResetOption(btn -> {
|
||||||
this.mod.config.reset();
|
this.mod.config.reset();
|
||||||
@@ -104,8 +106,10 @@ public class LambdaControlsSettingsScreen extends Screen
|
|||||||
this.autoJumpOption = SpruceBooleanOption.fromVanilla("options.autoJump", Option.AUTO_JUMP, null, true);
|
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.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.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.frontBlockPlacingOption = new SpruceBooleanOption("lambdacontrols.menu.reacharound.horizontal", this.mod.config::hasFrontBlockPlacing,
|
||||||
this.mod.config::setFrontBlockPlacing, new TranslatableText("lambdacontrols.tooltip.front_block_placing"), true);
|
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.flyDriftingOption = new SpruceBooleanOption("lambdacontrols.menu.fly_drifting", this.mod.config::hasFlyDrifting,
|
||||||
this.mod.config::setFlyDrifting, new TranslatableText("lambdacontrols.tooltip.fly_drifting"), true);
|
this.mod.config::setFlyDrifting, new TranslatableText("lambdacontrols.tooltip.fly_drifting"), true);
|
||||||
this.flyVerticalDriftingOption = new SpruceBooleanOption("lambdacontrols.menu.fly_drifting_vertical", this.mod.config::hasFlyVerticalDrifting,
|
this.flyVerticalDriftingOption = new SpruceBooleanOption("lambdacontrols.menu.fly_drifting_vertical", this.mod.config::hasFlyVerticalDrifting,
|
||||||
@@ -120,11 +124,11 @@ public class LambdaControlsSettingsScreen extends Screen
|
|||||||
}, option -> {
|
}, option -> {
|
||||||
String controllerName = this.mod.config.getController().getName();
|
String controllerName = this.mod.config.getController().getName();
|
||||||
if (!this.mod.config.getController().isConnected())
|
if (!this.mod.config.getController().isConnected())
|
||||||
return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.RED));
|
return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.RED));
|
||||||
else if (!this.mod.config.getController().isGamepad())
|
else if (!this.mod.config.getController().isGamepad())
|
||||||
return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.GOLD));
|
return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.GOLD));
|
||||||
else
|
else
|
||||||
return option.getDisplayPrefix().append(controllerName);
|
return option.getDisplayText(new LiteralText(controllerName));
|
||||||
}, null);
|
}, null);
|
||||||
this.secondControllerOption = new SpruceCyclingOption("lambdacontrols.menu.controller2",
|
this.secondControllerOption = new SpruceCyclingOption("lambdacontrols.menu.controller2",
|
||||||
amount -> {
|
amount -> {
|
||||||
@@ -136,16 +140,16 @@ public class LambdaControlsSettingsScreen extends Screen
|
|||||||
}, option -> this.mod.config.getSecondController().map(controller -> {
|
}, option -> this.mod.config.getSecondController().map(controller -> {
|
||||||
String controllerName = controller.getName();
|
String controllerName = controller.getName();
|
||||||
if (!controller.isConnected())
|
if (!controller.isConnected())
|
||||||
return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.RED));
|
return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.RED));
|
||||||
else if (!controller.isGamepad())
|
else if (!controller.isGamepad())
|
||||||
return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.GOLD));
|
return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.GOLD));
|
||||||
else
|
else
|
||||||
return option.getDisplayPrefix().append(controllerName);
|
return option.getDisplayText(new LiteralText(controllerName));
|
||||||
}).orElse(option.getDisplayPrefix().append(new TranslatableText("options.off").formatted(Formatting.RED))),
|
}).orElse(option.getDisplayText(SpruceTexts.OPTIONS_OFF.shallowCopy().formatted(Formatting.RED))),
|
||||||
new TranslatableText("lambdacontrols.tooltip.controller2"));
|
new TranslatableText("lambdacontrols.tooltip.controller2"));
|
||||||
this.controllerTypeOption = new SpruceCyclingOption("lambdacontrols.menu.controller_type",
|
this.controllerTypeOption = new SpruceCyclingOption("lambdacontrols.menu.controller_type",
|
||||||
amount -> this.mod.config.setControllerType(this.mod.config.getControllerType().next()),
|
amount -> this.mod.config.setControllerType(this.mod.config.getControllerType().next()),
|
||||||
option -> option.getDisplayPrefix().append(this.mod.config.getControllerType().getTranslatedName()),
|
option -> option.getDisplayText(this.mod.config.getControllerType().getTranslatedText()),
|
||||||
new TranslatableText("lambdacontrols.tooltip.controller_type"));
|
new TranslatableText("lambdacontrols.tooltip.controller_type"));
|
||||||
this.deadZoneOption = new SpruceDoubleOption("lambdacontrols.menu.dead_zone", 0.05, 1.0, 0.05F, this.mod.config::getDeadZone,
|
this.deadZoneOption = new SpruceDoubleOption("lambdacontrols.menu.dead_zone", 0.05, 1.0, 0.05F, this.mod.config::getDeadZone,
|
||||||
newValue -> {
|
newValue -> {
|
||||||
@@ -154,7 +158,7 @@ public class LambdaControlsSettingsScreen extends Screen
|
|||||||
}
|
}
|
||||||
}, option -> {
|
}, option -> {
|
||||||
String value = String.valueOf(option.get());
|
String value = String.valueOf(option.get());
|
||||||
return option.getDisplayPrefix().append(value.substring(0, Math.min(value.length(), 5)));
|
return option.getDisplayText(new LiteralText(value.substring(0, Math.min(value.length(), 5))));
|
||||||
}, new TranslatableText("lambdacontrols.tooltip.dead_zone"));
|
}, new TranslatableText("lambdacontrols.tooltip.dead_zone"));
|
||||||
this.invertsRightXAxis = new SpruceBooleanOption("lambdacontrols.menu.invert_right_x_axis", this.mod.config::doesInvertRightXAxis,
|
this.invertsRightXAxis = new SpruceBooleanOption("lambdacontrols.menu.invert_right_x_axis", this.mod.config::doesInvertRightXAxis,
|
||||||
newValue -> {
|
newValue -> {
|
||||||
@@ -174,14 +178,14 @@ public class LambdaControlsSettingsScreen extends Screen
|
|||||||
this.mod.config::setVirtualMouse, new TranslatableText("lambdacontrols.tooltip.virtual_mouse"), true);
|
this.mod.config::setVirtualMouse, new TranslatableText("lambdacontrols.tooltip.virtual_mouse"), true);
|
||||||
this.virtualMouseSkinOption = new SpruceCyclingOption("lambdacontrols.menu.virtual_mouse.skin",
|
this.virtualMouseSkinOption = new SpruceCyclingOption("lambdacontrols.menu.virtual_mouse.skin",
|
||||||
amount -> this.mod.config.setVirtualMouseSkin(this.mod.config.getVirtualMouseSkin().next()),
|
amount -> this.mod.config.setVirtualMouseSkin(this.mod.config.getVirtualMouseSkin().next()),
|
||||||
option -> option.getDisplayPrefix().append(this.mod.config.getVirtualMouseSkin().getTranslatedName()),
|
option -> option.getDisplayText(this.mod.config.getVirtualMouseSkin().getTranslatedText()),
|
||||||
null);
|
null);
|
||||||
// HUD options
|
// HUD options
|
||||||
this.hudEnableOption = new SpruceBooleanOption("lambdacontrols.menu.hud_enable", this.mod.config::isHudEnabled,
|
this.hudEnableOption = new SpruceBooleanOption("lambdacontrols.menu.hud_enable", this.mod.config::isHudEnabled,
|
||||||
this.mod::setHudEnabled, new TranslatableText("lambdacontrols.tooltip.hud_enable"), true);
|
this.mod::setHudEnabled, new TranslatableText("lambdacontrols.tooltip.hud_enable"), true);
|
||||||
this.hudSideOption = new SpruceCyclingOption("lambdacontrols.menu.hud_side",
|
this.hudSideOption = new SpruceCyclingOption("lambdacontrols.menu.hud_side",
|
||||||
amount -> this.mod.config.setHudSide(this.mod.config.getHudSide().next()),
|
amount -> this.mod.config.setHudSide(this.mod.config.getHudSide().next()),
|
||||||
option -> option.getDisplayPrefix().append(this.mod.config.getHudSide().getTranslatedName()),
|
option -> option.getDisplayText(this.mod.config.getHudSide().getTranslatedText()),
|
||||||
new TranslatableText("lambdacontrols.tooltip.hud_side"));
|
new TranslatableText("lambdacontrols.tooltip.hud_side"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,8 +243,8 @@ public class LambdaControlsSettingsScreen extends Screen
|
|||||||
this.list.addSingleOptionEntry(this.autoSwitchModeOption);
|
this.list.addSingleOptionEntry(this.autoSwitchModeOption);
|
||||||
// Gameplay options
|
// Gameplay options
|
||||||
this.list.addSingleOptionEntry(new SpruceSeparatorOption("lambdacontrols.menu.title.gameplay", true, null));
|
this.list.addSingleOptionEntry(new SpruceSeparatorOption("lambdacontrols.menu.title.gameplay", true, null));
|
||||||
this.list.addSingleOptionEntry(this.autoJumpOption);
|
this.list.addOptionEntry(this.autoJumpOption, this.fastBlockPlacingOption);
|
||||||
this.list.addOptionEntry(this.fastBlockPlacingOption, this.frontBlockPlacingOption);
|
this.list.addOptionEntry(this.frontBlockPlacingOption, this.verticalReacharoundOption);
|
||||||
this.list.addSingleOptionEntry(this.flyDriftingOption);
|
this.list.addSingleOptionEntry(this.flyDriftingOption);
|
||||||
this.list.addSingleOptionEntry(this.flyVerticalDriftingOption);
|
this.list.addSingleOptionEntry(this.flyVerticalDriftingOption);
|
||||||
// Controller options
|
// Controller options
|
||||||
@@ -263,7 +267,7 @@ public class LambdaControlsSettingsScreen extends Screen
|
|||||||
this.children.add(this.gamepadToolUrlLabel);
|
this.children.add(this.gamepadToolUrlLabel);
|
||||||
|
|
||||||
this.addButton(this.resetOption.createButton(this.client.options, this.width / 2 - 155, this.height - 29, 150));
|
this.addButton(this.resetOption.createButton(this.client.options, this.width / 2 - 155, this.height - 29, 150));
|
||||||
this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, buttonHeight, new TranslatableText("gui.done"),
|
this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, buttonHeight, SpruceTexts.GUI_DONE,
|
||||||
(buttonWidget) -> this.client.openScreen(this.parent)));
|
(buttonWidget) -> this.client.openScreen(this.parent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package me.lambdaurora.lambdacontrols.client.mixin;
|
|||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||||
|
import me.lambdaurora.lambdacontrols.client.controller.MovementHandler;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.input.Input;
|
import net.minecraft.client.input.Input;
|
||||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
@@ -69,6 +70,12 @@ public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick(Z)V", shift = At.Shift.AFTER))
|
||||||
|
public void onInputUpdate(CallbackInfo ci)
|
||||||
|
{
|
||||||
|
MovementHandler.HANDLER.applyMovement((ClientPlayerEntity) (Object) this);
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isCamera()Z"))
|
@Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isCamera()Z"))
|
||||||
public void onTickMovement(CallbackInfo ci)
|
public void onTickMovement(CallbackInfo ci)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import net.minecraft.client.gui.screen.options.GameOptionsScreen;
|
|||||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
import net.minecraft.client.options.GameOptions;
|
import net.minecraft.client.options.GameOptions;
|
||||||
import net.minecraft.client.resource.language.I18n;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|||||||
@@ -17,5 +17,5 @@ import org.spongepowered.asm.mixin.gen.Invoker;
|
|||||||
public interface EntryListWidgetAccessor
|
public interface EntryListWidgetAccessor
|
||||||
{
|
{
|
||||||
@Invoker("moveSelection")
|
@Invoker("moveSelection")
|
||||||
void lambdacontrols_moveSelection(EntryListWidget.class_5403 direction);
|
void lambdacontrols_moveSelection(EntryListWidget.MoveDirection direction);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import net.minecraft.client.MinecraftClient;
|
|||||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.screen.slot.Slot;
|
import net.minecraft.screen.slot.Slot;
|
||||||
|
import net.minecraft.screen.slot.SlotActionType;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
@@ -41,6 +43,12 @@ public abstract class HandledScreenMixin implements HandledScreenAccessor
|
|||||||
@Invoker("getSlotAt")
|
@Invoker("getSlotAt")
|
||||||
public abstract Slot lambdacontrols_getSlotAt(double posX, double posY);
|
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"))
|
@Inject(method = "render", at = @At("RETURN"))
|
||||||
public void onRender(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci)
|
public void onRender(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,9 +11,8 @@ package me.lambdaurora.lambdacontrols.client.mixin;
|
|||||||
|
|
||||||
import me.lambdaurora.lambdacontrols.LambdaControlsFeature;
|
import me.lambdaurora.lambdacontrols.LambdaControlsFeature;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
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.gui.LambdaControlsRenderer;
|
||||||
import me.lambdaurora.lambdacontrols.client.util.FrontBlockPlaceResultAccessor;
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
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;
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
|
|
||||||
@Mixin(MinecraftClient.class)
|
@Mixin(MinecraftClient.class)
|
||||||
public abstract class MinecraftClientMixin implements FrontBlockPlaceResultAccessor
|
public abstract class MinecraftClientMixin
|
||||||
{
|
{
|
||||||
@Shadow
|
@Shadow
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -65,18 +64,10 @@ public abstract class MinecraftClientMixin implements FrontBlockPlaceResultAcces
|
|||||||
@Shadow
|
@Shadow
|
||||||
private int itemUseCooldown;
|
private int itemUseCooldown;
|
||||||
|
|
||||||
private BlockHitResult lambdacontrols_frontBlockPlaceResult = null;
|
|
||||||
|
|
||||||
private BlockPos lambdacontrols_lastTargetPos;
|
private BlockPos lambdacontrols_lastTargetPos;
|
||||||
private Vec3d lambdacontrols_lastPos;
|
private Vec3d lambdacontrols_lastPos;
|
||||||
private Direction lambdacontrols_lastTargetSide;
|
private Direction lambdacontrols_lastTargetSide;
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable BlockHitResult lambdacontrols_getFrontBlockPlaceResult()
|
|
||||||
{
|
|
||||||
return this.lambdacontrols_frontBlockPlaceResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "<init>", at = @At("RETURN"))
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
private void onInit(CallbackInfo ci)
|
private void onInit(CallbackInfo ci)
|
||||||
{
|
{
|
||||||
@@ -88,7 +79,7 @@ public abstract class MinecraftClientMixin implements FrontBlockPlaceResultAcces
|
|||||||
{
|
{
|
||||||
if (this.player == null)
|
if (this.player == null)
|
||||||
return;
|
return;
|
||||||
this.lambdacontrols_frontBlockPlaceResult = LambdaInput.tryFrontPlace(((MinecraftClient) (Object) this));
|
|
||||||
if (!LambdaControlsFeature.FAST_BLOCK_PLACING.isAvailable())
|
if (!LambdaControlsFeature.FAST_BLOCK_PLACING.isAvailable())
|
||||||
return;
|
return;
|
||||||
if (this.lambdacontrols_lastPos == null)
|
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))
|
@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);
|
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)
|
@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)
|
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 (!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 (this.crosshairTarget != null && this.crosshairTarget.getType() == HitResult.Type.MISS && this.player.isOnGround()) {
|
||||||
if (!stackInHand.isEmpty() && stackInHand.getItem() instanceof BlockItem) {
|
if (!stackInHand.isEmpty() && stackInHand.getItem() instanceof BlockItem) {
|
||||||
BlockHitResult hitResult = LambdaInput.tryFrontPlace(((MinecraftClient) (Object) this));
|
BlockHitResult hitResult = LambdaControlsClient.get().reacharound.getLastReacharoundResult();
|
||||||
|
|
||||||
if (hitResult == null)
|
if (hitResult == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hitResult = LambdaInput.withSideForFrontPlace(hitResult, stackInHand);
|
hitResult = LambdaReacharound.withSideForReacharound(hitResult, stackInHand);
|
||||||
|
|
||||||
int previousStackCount = stackInHand.getCount();
|
int previousStackCount = stackInHand.getCount();
|
||||||
ActionResult result = this.interactionManager.interactBlock(this.player, this.world, hand, hitResult);
|
ActionResult result = this.interactionManager.interactBlock(this.player, this.world, hand, hitResult);
|
||||||
|
|||||||
@@ -13,12 +13,17 @@ import me.lambdaurora.lambdacontrols.ControlsMode;
|
|||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsConfig;
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsConfig;
|
||||||
import me.lambdaurora.lambdacontrols.client.util.MouseAccessor;
|
import me.lambdaurora.lambdacontrols.client.util.MouseAccessor;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.Mouse;
|
import net.minecraft.client.Mouse;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds extra access to the mouse.
|
* Adds extra access to the mouse.
|
||||||
@@ -26,14 +31,41 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
@Mixin(Mouse.class)
|
@Mixin(Mouse.class)
|
||||||
public abstract class MouseMixin implements MouseAccessor
|
public abstract class MouseMixin implements MouseAccessor
|
||||||
{
|
{
|
||||||
|
@Shadow
|
||||||
|
@Final
|
||||||
|
private MinecraftClient client;
|
||||||
|
|
||||||
@Invoker("onCursorPos")
|
@Invoker("onCursorPos")
|
||||||
public abstract void lambdacontrols_onCursorPos(long window, double x, double y);
|
public abstract void lambdacontrols_onCursorPos(long window, double x, double y);
|
||||||
|
|
||||||
|
@Inject(method = "method_1605", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/client/gui/screen/Screen;mouseReleased(DDI)Z"))
|
||||||
|
private void onMouseBackButton(boolean[] result, double mouseX, double mouseY, int button, CallbackInfo ci)
|
||||||
|
{
|
||||||
|
if (!result[0] && button == GLFW.GLFW_MOUSE_BUTTON_4 && this.client.currentScreen != null) {
|
||||||
|
if (LambdaControlsClient.get().input.tryGoBack(this.client.currentScreen)) {
|
||||||
|
result[0] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "isCursorLocked", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void isCursorLocked(CallbackInfoReturnable<Boolean> ci)
|
||||||
|
{
|
||||||
|
if (this.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)
|
@Inject(method = "lockCursor", at = @At("HEAD"), cancellable = true)
|
||||||
private void onMouseLocked(CallbackInfo ci)
|
private void onCursorLocked(CallbackInfo ci)
|
||||||
{
|
{
|
||||||
LambdaControlsConfig config = LambdaControlsClient.get().config;
|
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();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,7 @@
|
|||||||
package me.lambdaurora.lambdacontrols.client.mixin;
|
package me.lambdaurora.lambdacontrols.client.mixin;
|
||||||
|
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaInput;
|
import me.lambdaurora.lambdacontrols.client.LambdaReacharound;
|
||||||
import me.lambdaurora.lambdacontrols.client.util.FrontBlockPlaceResultAccessor;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.block.ShapeContext;
|
||||||
@@ -29,7 +28,6 @@ import net.minecraft.util.hit.HitResult;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Matrix4f;
|
import net.minecraft.util.math.Matrix4f;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.profiler.Profiler;
|
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -54,6 +52,10 @@ public abstract class WorldRendererMixin
|
|||||||
@Shadow
|
@Shadow
|
||||||
private ClientWorld world;
|
private ClientWorld world;
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
@Final
|
||||||
|
private BufferBuilderStorage bufferBuilders;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
private static void drawShapeOutline(MatrixStack matrixStack, VertexConsumer vertexConsumer, VoxelShape voxelShape, double d, double e, double f, float g, float h, float i, float j)
|
private static void drawShapeOutline(MatrixStack matrixStack, VertexConsumer vertexConsumer, VoxelShape voxelShape, double d, double e, double f, float g, float h, float i, float j)
|
||||||
{
|
{
|
||||||
@@ -66,17 +68,14 @@ public abstract class WorldRendererMixin
|
|||||||
target = "Lnet/minecraft/client/MinecraftClient;crosshairTarget:Lnet/minecraft/util/hit/HitResult;",
|
target = "Lnet/minecraft/client/MinecraftClient;crosshairTarget:Lnet/minecraft/util/hit/HitResult;",
|
||||||
ordinal = 1,
|
ordinal = 1,
|
||||||
shift = At.Shift.AFTER
|
shift = At.Shift.AFTER
|
||||||
),
|
)
|
||||||
locals = LocalCapture.CAPTURE_FAILEXCEPTION
|
|
||||||
)
|
)
|
||||||
private void onOutlineRender(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer,
|
private void onOutlineRender(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer,
|
||||||
LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, CallbackInfo ci,
|
LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, CallbackInfo ci)
|
||||||
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;
|
return;
|
||||||
BlockHitResult result = ((FrontBlockPlaceResultAccessor) client).lambdacontrols_getFrontBlockPlaceResult();
|
BlockHitResult result = LambdaControlsClient.get().reacharound.getLastReacharoundResult();
|
||||||
if (result == null)
|
if (result == null)
|
||||||
return;
|
return;
|
||||||
BlockPos blockPos = result.getBlockPos();
|
BlockPos blockPos = result.getBlockPos();
|
||||||
@@ -84,16 +83,23 @@ public abstract class WorldRendererMixin
|
|||||||
ItemStack stack = this.client.player.getStackInHand(Hand.MAIN_HAND);
|
ItemStack stack = this.client.player.getStackInHand(Hand.MAIN_HAND);
|
||||||
if (stack == null || !(stack.getItem() instanceof BlockItem))
|
if (stack == null || !(stack.getItem() instanceof BlockItem))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Block block = ((BlockItem) stack.getItem()).getBlock();
|
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));
|
ItemPlacementContext context = new ItemPlacementContext(new ItemUsageContext(this.client.player, Hand.MAIN_HAND, result));
|
||||||
VertexConsumer vertexConsumer = immediate.getBuffer(RenderLayer.getLines());
|
|
||||||
BlockState placementState = block.getPlacementState(context);
|
BlockState placementState = block.getPlacementState(context);
|
||||||
if (placementState == null)
|
if (placementState == null)
|
||||||
return;
|
return;
|
||||||
|
Vec3d pos = camera.getPos();
|
||||||
|
|
||||||
VoxelShape outlineShape = placementState.getOutlineShape(this.client.world, blockPos, ShapeContext.of(camera.getFocusedEntity()));
|
VoxelShape outlineShape = placementState.getOutlineShape(this.client.world, blockPos, ShapeContext.of(camera.getFocusedEntity()));
|
||||||
int[] color = LambdaControlsClient.get().config.getFrontBlockOutlineColor();
|
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);
|
|
||||||
|
VertexConsumer vertexConsumer = this.bufferBuilders.getEntityVertexConsumers().getBuffer(RenderLayer.getLines());
|
||||||
|
drawShapeOutline(matrices, vertexConsumer, outlineShape,
|
||||||
|
(double) blockPos.getX() - pos.getX(), (double) blockPos.getY() - pos.getY(), (double) blockPos.getZ() - pos.getZ(),
|
||||||
|
color[0] / 255.f, color[1] / 255.f, color[2] / 255.f, color[3] / 255.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import me.lambdaurora.lambdacontrols.client.util.KeyBindingAccessor;
|
||||||
|
import net.minecraft.client.options.KeyBinding;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class KeyBindingRingAction extends RingAction
|
||||||
|
{
|
||||||
|
public final KeyBinding binding;
|
||||||
|
|
||||||
|
public KeyBindingRingAction(@NotNull KeyBinding binding)
|
||||||
|
{
|
||||||
|
this.binding = binding;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getName()
|
||||||
|
{
|
||||||
|
return this.binding.getTranslationKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAction(@NotNull RingButtonMode mode)
|
||||||
|
{
|
||||||
|
KeyBindingAccessor accessor = (KeyBindingAccessor) this.binding;
|
||||||
|
switch (mode) {
|
||||||
|
case PRESS:
|
||||||
|
case HOLD:
|
||||||
|
accessor.lambdacontrols_handlePressState(this.activated);
|
||||||
|
break;
|
||||||
|
case TOGGLE:
|
||||||
|
accessor.lambdacontrols_handlePressState(!this.binding.isPressed());
|
||||||
|
this.activated = !this.binding.isPressed();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a key binding ring.
|
||||||
|
*
|
||||||
|
* @author LambdAurora
|
||||||
|
* @version 1.4.0
|
||||||
|
* @since 1.4.0
|
||||||
|
*/
|
||||||
|
public class LambdaRing
|
||||||
|
{
|
||||||
|
private final List<RingPage> pages = new ArrayList<>(Collections.singletonList(new RingPage()));
|
||||||
|
private int currentPage = 0;
|
||||||
|
|
||||||
|
public LambdaRing()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull RingPage getCurrentPage()
|
||||||
|
{
|
||||||
|
if (this.currentPage >= this.pages.size())
|
||||||
|
this.currentPage = this.pages.size() - 1;
|
||||||
|
else if (this.currentPage < 0)
|
||||||
|
this.currentPage = 0;
|
||||||
|
return this.pages.get(this.currentPage);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import org.aperlambda.lambdacommon.utils.Nameable;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a ring action.
|
||||||
|
*
|
||||||
|
* @author LambdAurora
|
||||||
|
* @version 1.4.0
|
||||||
|
* @since 1.4.0
|
||||||
|
*/
|
||||||
|
public abstract class RingAction implements Nameable
|
||||||
|
{
|
||||||
|
protected boolean activated = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the translated name of the ring action.
|
||||||
|
*
|
||||||
|
* @return The translated name.
|
||||||
|
*/
|
||||||
|
public TranslatableText getTranslatedName()
|
||||||
|
{
|
||||||
|
return new TranslatableText(this.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the action is activated or not.
|
||||||
|
*
|
||||||
|
* @return True if the action is activated, else false.
|
||||||
|
*/
|
||||||
|
public boolean isActivated()
|
||||||
|
{
|
||||||
|
return this.activated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void activate(@NotNull RingButtonMode mode)
|
||||||
|
{
|
||||||
|
this.activated = !this.activated;
|
||||||
|
|
||||||
|
this.onAction(mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void onAction(@NotNull RingButtonMode mode);
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
|
import org.aperlambda.lambdacommon.utils.Nameable;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the mode of a ring button.
|
||||||
|
*
|
||||||
|
* @author LambdAurora
|
||||||
|
* @version 1.4.0
|
||||||
|
* @since 1.4.0
|
||||||
|
*/
|
||||||
|
public enum RingButtonMode implements Nameable
|
||||||
|
{
|
||||||
|
PRESS("press"),
|
||||||
|
HOLD("hold"),
|
||||||
|
TOGGLE("toggle");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final Text text;
|
||||||
|
|
||||||
|
RingButtonMode(@NotNull String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.text = new TranslatableText(this.getTranslationKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the next ring button mode available.
|
||||||
|
*
|
||||||
|
* @return The next ring button mode.
|
||||||
|
*/
|
||||||
|
public @NotNull RingButtonMode next()
|
||||||
|
{
|
||||||
|
RingButtonMode[] v = values();
|
||||||
|
if (v.length == this.ordinal() + 1)
|
||||||
|
return v[0];
|
||||||
|
return v[this.ordinal() + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the translation key of this ring button mode.
|
||||||
|
*
|
||||||
|
* @return The translation key of this ring button mode.
|
||||||
|
*/
|
||||||
|
public @NotNull String getTranslationKey()
|
||||||
|
{
|
||||||
|
return "lambdacontrols.ring.button_mode." + this.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the translated name of this ring button mode.
|
||||||
|
*
|
||||||
|
* @return The translated name of this ring button mode.
|
||||||
|
*/
|
||||||
|
public @NotNull Text getTranslatedText()
|
||||||
|
{
|
||||||
|
return this.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getName()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* 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 ring page.
|
||||||
|
*
|
||||||
|
* @author LambdAurora
|
||||||
|
* @version 1.4.0
|
||||||
|
* @since 1.4.0
|
||||||
|
*/
|
||||||
|
public class RingPage
|
||||||
|
{
|
||||||
|
private RingAction[] actions = new RingAction[8];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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();
|
|
||||||
}
|
|
||||||
@@ -10,6 +10,8 @@
|
|||||||
package me.lambdaurora.lambdacontrols.client.util;
|
package me.lambdaurora.lambdacontrols.client.util;
|
||||||
|
|
||||||
import net.minecraft.screen.slot.Slot;
|
import net.minecraft.screen.slot.Slot;
|
||||||
|
import net.minecraft.screen.slot.SlotActionType;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an accessor to AbstractContainerScreen.
|
* Represents an accessor to AbstractContainerScreen.
|
||||||
@@ -38,4 +40,16 @@ public interface HandledScreenAccessor
|
|||||||
* @return The slot at the specified position.
|
* @return The slot at the specified position.
|
||||||
*/
|
*/
|
||||||
Slot lambdacontrols_getSlotAt(double pos_x, double pos_y);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,9 @@
|
|||||||
"lambdacontrols.action.toggle_smooth_camera": "Toggle Cinematic Camera",
|
"lambdacontrols.action.toggle_smooth_camera": "Toggle Cinematic Camera",
|
||||||
"lambdacontrols.action.use": "Use",
|
"lambdacontrols.action.use": "Use",
|
||||||
"lambdacontrols.action.zoom": "Zoom",
|
"lambdacontrols.action.zoom": "Zoom",
|
||||||
|
"lambdacontrols.action.zoom.in": "Increase Zoom",
|
||||||
|
"lambdacontrols.action.zoom.out": "Decrease Zoom",
|
||||||
|
"lambdacontrols.action.zoom.reset": "Reset Zoom",
|
||||||
"lambdacontrols.button.a": "A",
|
"lambdacontrols.button.a": "A",
|
||||||
"lambdacontrols.button.b": "B",
|
"lambdacontrols.button.b": "B",
|
||||||
"lambdacontrols.button.x": "X",
|
"lambdacontrols.button.x": "X",
|
||||||
@@ -82,13 +85,14 @@
|
|||||||
"lambdacontrols.menu.fast_block_placing": "Fast Block Placing",
|
"lambdacontrols.menu.fast_block_placing": "Fast Block Placing",
|
||||||
"lambdacontrols.menu.fly_drifting": "Fly Drifting",
|
"lambdacontrols.menu.fly_drifting": "Fly Drifting",
|
||||||
"lambdacontrols.menu.fly_drifting_vertical": "Vertical 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_enable": "Enable HUD",
|
||||||
"lambdacontrols.menu.hud_side": "HUD Side",
|
"lambdacontrols.menu.hud_side": "HUD Side",
|
||||||
"lambdacontrols.menu.invert_right_x_axis": "Invert Right X",
|
"lambdacontrols.menu.invert_right_x_axis": "Invert Right X",
|
||||||
"lambdacontrols.menu.invert_right_y_axis": "Invert Right Y",
|
"lambdacontrols.menu.invert_right_y_axis": "Invert Right Y",
|
||||||
"lambdacontrols.menu.keyboard_controls": "Keyboard Controls...",
|
"lambdacontrols.menu.keyboard_controls": "Keyboard Controls...",
|
||||||
"lambdacontrols.menu.mouse_speed": "Mouse Speed",
|
"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.reload_controller_mappings": "Reload Controller Mappings",
|
||||||
"lambdacontrols.menu.rotation_speed": "Rotation Speed",
|
"lambdacontrols.menu.rotation_speed": "Rotation Speed",
|
||||||
"lambdacontrols.menu.title": "LambdaControls - Settings",
|
"lambdacontrols.menu.title": "LambdaControls - Settings",
|
||||||
@@ -97,7 +101,6 @@
|
|||||||
"lambdacontrols.menu.title.gameplay": "Gameplay Options",
|
"lambdacontrols.menu.title.gameplay": "Gameplay Options",
|
||||||
"lambdacontrols.menu.title.general": "General Options",
|
"lambdacontrols.menu.title.general": "General Options",
|
||||||
"lambdacontrols.menu.title.hud": "HUD Options",
|
"lambdacontrols.menu.title.hud": "HUD Options",
|
||||||
"lambdacontrols.menu.unbound": "Unbound",
|
|
||||||
"lambdacontrols.menu.unfocused_input": "Unfocused Input",
|
"lambdacontrols.menu.unfocused_input": "Unfocused Input",
|
||||||
"lambdacontrols.menu.virtual_mouse": "Virtual Mouse",
|
"lambdacontrols.menu.virtual_mouse": "Virtual Mouse",
|
||||||
"lambdacontrols.menu.virtual_mouse.skin": "Virtual Mouse Skin",
|
"lambdacontrols.menu.virtual_mouse.skin": "Virtual Mouse Skin",
|
||||||
@@ -111,12 +114,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.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": "While flying, enables Vanilla drifting/inertia.",
|
||||||
"lambdacontrols.tooltip.fly_drifting_vertical": "While flying, enables Vanilla vertical drifting/intertia.",
|
"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_enable": "Toggles the on-screen controller button indicator.",
|
||||||
"lambdacontrols.tooltip.hud_side": "The position of the HUD.",
|
"lambdacontrols.tooltip.hud_side": "The position of the HUD.",
|
||||||
"lambdacontrols.tooltip.mouse_speed": "The controller's emulated mouse speed.",
|
"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.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.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.tooltip.virtual_mouse": "Enable the virtual mouse which is handful in the case of a splitscreen.",
|
||||||
"lambdacontrols.virtual_mouse.skin.default_light": "Default Light",
|
"lambdacontrols.virtual_mouse.skin.default_light": "Default Light",
|
||||||
|
|||||||
@@ -81,13 +81,14 @@
|
|||||||
"lambdacontrols.menu.dead_zone": "Zone morte",
|
"lambdacontrols.menu.dead_zone": "Zone morte",
|
||||||
"lambdacontrols.menu.fly_drifting": "Inertie de vol",
|
"lambdacontrols.menu.fly_drifting": "Inertie de vol",
|
||||||
"lambdacontrols.menu.fly_drifting_vertical": "Inertie verticale 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_enable": "Activer le HUD",
|
||||||
"lambdacontrols.menu.hud_side": "Côté du HUD",
|
"lambdacontrols.menu.hud_side": "Côté du HUD",
|
||||||
"lambdacontrols.menu.invert_right_x_axis": "Inverser le stick droit (X)",
|
"lambdacontrols.menu.invert_right_x_axis": "Inverser le stick droit (X)",
|
||||||
"lambdacontrols.menu.invert_right_y_axis": "Inverser le stick droit (Y)",
|
"lambdacontrols.menu.invert_right_y_axis": "Inverser le stick droit (Y)",
|
||||||
"lambdacontrols.menu.keyboard_controls": "Contrôles clavier...",
|
"lambdacontrols.menu.keyboard_controls": "Contrôles clavier...",
|
||||||
"lambdacontrols.menu.mouse_speed": "Vitesse de la souris",
|
"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.reload_controller_mappings": "Recharge la configuration des manettes",
|
||||||
"lambdacontrols.menu.rotation_speed": "Vitesse de rotation",
|
"lambdacontrols.menu.rotation_speed": "Vitesse de rotation",
|
||||||
"lambdacontrols.menu.title": "LambdaControls - Paramètres",
|
"lambdacontrols.menu.title": "LambdaControls - Paramètres",
|
||||||
@@ -96,7 +97,6 @@
|
|||||||
"lambdacontrols.menu.title.gameplay": "Options de Gameplay",
|
"lambdacontrols.menu.title.gameplay": "Options de Gameplay",
|
||||||
"lambdacontrols.menu.title.general": "Options générales",
|
"lambdacontrols.menu.title.general": "Options générales",
|
||||||
"lambdacontrols.menu.title.hud": "Options du HUD",
|
"lambdacontrols.menu.title.hud": "Options du HUD",
|
||||||
"lambdacontrols.menu.unbound": "Délier",
|
|
||||||
"lambdacontrols.menu.unfocused_input": "Entrée en fond",
|
"lambdacontrols.menu.unfocused_input": "Entrée en fond",
|
||||||
"lambdacontrols.menu.virtual_mouse": "Souris virtuelle",
|
"lambdacontrols.menu.virtual_mouse": "Souris virtuelle",
|
||||||
"lambdacontrols.menu.virtual_mouse.skin": "Apparence souris virtuelle",
|
"lambdacontrols.menu.virtual_mouse.skin": "Apparence souris virtuelle",
|
||||||
@@ -107,14 +107,16 @@
|
|||||||
"lambdacontrols.tooltip.controller_type": "Le type de contrôle n'influe que sur les boutons affichés.",
|
"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.controls_mode": "Change le mode de contrôle.",
|
||||||
"lambdacontrols.tooltip.dead_zone": "Zone morte des axes de la manette.",
|
"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": "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.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_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.hud_side": "Change la position du HUD.",
|
||||||
"lambdacontrols.tooltip.mouse_speed": "Change la vitesse de la souris émulée par la manette.",
|
"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.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.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.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",
|
"lambdacontrols.virtual_mouse.skin.default_light": "défaut clair",
|
||||||
|
|||||||
@@ -81,13 +81,14 @@
|
|||||||
"lambdacontrols.menu.dead_zone": "Zone morte",
|
"lambdacontrols.menu.dead_zone": "Zone morte",
|
||||||
"lambdacontrols.menu.fly_drifting": "Inertie de vol",
|
"lambdacontrols.menu.fly_drifting": "Inertie de vol",
|
||||||
"lambdacontrols.menu.fly_drifting_vertical": "Inertie verticale 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_enable": "Activer le HUD",
|
||||||
"lambdacontrols.menu.hud_side": "Côté du HUD",
|
"lambdacontrols.menu.hud_side": "Côté du HUD",
|
||||||
"lambdacontrols.menu.invert_right_x_axis": "Inverser le stick droit (X)",
|
"lambdacontrols.menu.invert_right_x_axis": "Inverser le stick droit (X)",
|
||||||
"lambdacontrols.menu.invert_right_y_axis": "Inverser le stick droit (Y)",
|
"lambdacontrols.menu.invert_right_y_axis": "Inverser le stick droit (Y)",
|
||||||
"lambdacontrols.menu.keyboard_controls": "Contrôles clavier...",
|
"lambdacontrols.menu.keyboard_controls": "Contrôles clavier...",
|
||||||
"lambdacontrols.menu.mouse_speed": "Vitesse de la souris",
|
"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.reload_controller_mappings": "Recharge la configuration des manettes",
|
||||||
"lambdacontrols.menu.rotation_speed": "Vitesse de rotation",
|
"lambdacontrols.menu.rotation_speed": "Vitesse de rotation",
|
||||||
"lambdacontrols.menu.title": "LambdaControls - Paramètres",
|
"lambdacontrols.menu.title": "LambdaControls - Paramètres",
|
||||||
@@ -96,7 +97,6 @@
|
|||||||
"lambdacontrols.menu.title.gameplay": "Options de Gameplay",
|
"lambdacontrols.menu.title.gameplay": "Options de Gameplay",
|
||||||
"lambdacontrols.menu.title.general": "Options générales",
|
"lambdacontrols.menu.title.general": "Options générales",
|
||||||
"lambdacontrols.menu.title.hud": "Options du HUD",
|
"lambdacontrols.menu.title.hud": "Options du HUD",
|
||||||
"lambdacontrols.menu.unbound": "Délier",
|
|
||||||
"lambdacontrols.menu.unfocused_input": "Entrée en fond",
|
"lambdacontrols.menu.unfocused_input": "Entrée en fond",
|
||||||
"lambdacontrols.menu.virtual_mouse": "Souris virtuelle",
|
"lambdacontrols.menu.virtual_mouse": "Souris virtuelle",
|
||||||
"lambdacontrols.menu.virtual_mouse.skin": "Apparence souris virtuelle",
|
"lambdacontrols.menu.virtual_mouse.skin": "Apparence souris virtuelle",
|
||||||
@@ -107,14 +107,16 @@
|
|||||||
"lambdacontrols.tooltip.controller_type": "Le type de contrôle n'influe que sur les boutons affichés.",
|
"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.controls_mode": "Change le mode de contrôle.",
|
||||||
"lambdacontrols.tooltip.dead_zone": "Zone morte des axes de la manette.",
|
"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": "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.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_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.hud_side": "Change la position du HUD.",
|
||||||
"lambdacontrols.tooltip.mouse_speed": "Change la vitesse de la souris émulée par la manette.",
|
"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.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.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.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",
|
"lambdacontrols.virtual_mouse.skin.default_light": "défaut clair",
|
||||||
|
|||||||
@@ -21,9 +21,11 @@ auto_switch_mode = false
|
|||||||
drifting = false
|
drifting = false
|
||||||
# Enables vertical fly drifting.
|
# Enables vertical fly drifting.
|
||||||
vertical_drifting = true
|
vertical_drifting = true
|
||||||
[gameplay.front_block_placing]
|
[gameplay.reacharound]
|
||||||
# Enables front block placing like in Bedrock Edition.
|
# Enables front block placing like in Bedrock Edition.
|
||||||
enabled = false
|
horizontal = false
|
||||||
|
# Enables vertical reacharound.
|
||||||
|
vertical = false
|
||||||
# Enables front block placing outline.
|
# Enables front block placing outline.
|
||||||
outline = true
|
outline = true
|
||||||
# The color in a hexadecimal format of the outline.
|
# The color in a hexadecimal format of the outline.
|
||||||
|
|||||||
@@ -34,21 +34,25 @@
|
|||||||
"fabricloader": ">=0.8.0",
|
"fabricloader": ">=0.8.0",
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"minecraft": ">=1.16",
|
"minecraft": ">=1.16",
|
||||||
"spruceui": ">=1.5.1"
|
"spruceui": ">=1.5.2"
|
||||||
},
|
},
|
||||||
"recommends": {
|
"recommends": {
|
||||||
"modmenu": ">=1.12.2",
|
"modmenu": ">=1.12.2"
|
||||||
"okzoomer": ">=4.0.0"
|
|
||||||
},
|
},
|
||||||
"suggests": {
|
"suggests": {
|
||||||
"flamingo": "*",
|
"flamingo": "*",
|
||||||
"roughlyenoughitems": ">=4.5.5"
|
"roughlyenoughitems": ">=4.5.5",
|
||||||
|
"okzoomer": ">=4.0.0"
|
||||||
},
|
},
|
||||||
"breaks": {
|
"breaks": {
|
||||||
"modmenu": "<1.12.2",
|
"modmenu": "<1.12.2",
|
||||||
"optifabric": "*"
|
"optifabric": "*"
|
||||||
},
|
},
|
||||||
"custom": {
|
"custom": {
|
||||||
"modmenu:clientsideOnly": true
|
"modmenu:clientsideOnly": true,
|
||||||
|
"modupdater": {
|
||||||
|
"strategy": "curseforge",
|
||||||
|
"projectID": 354231
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/use
|
# check these on https://fabricmc.net/use
|
||||||
minecraft_version=1.16.1
|
minecraft_version=1.16.1
|
||||||
yarn_mappings=1.16.1+build.9:v2
|
yarn_mappings=1.16.1+build.21:v2
|
||||||
loader_version=0.8.8+build.202
|
loader_version=0.9.0+build.204
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.3.0
|
mod_version = 1.4.1
|
||||||
maven_group = me.lambdaurora
|
maven_group = me.lambdaurora.lambdacontrols
|
||||||
archives_base_name = lambdacontrols
|
archives_base_name = lambdacontrols
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||||
fabric_version=0.14.0+build.371-1.16
|
fabric_version=0.15.0+build.379-1.16.1
|
||||||
spruceui_version=1.5.1
|
spruceui_version=1.5.9
|
||||||
modmenu_version=1.12.2+build.17
|
modmenu_version=1.12.2+build.17
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,5 @@
|
|||||||
#Mon Oct 28 18:23:18 CET 2019
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
|
|
||||||
|
|||||||
35
gradlew
vendored
35
gradlew
vendored
@@ -82,6 +82,7 @@ esac
|
|||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
@@ -125,10 +126,11 @@ if $darwin; then
|
|||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# For Cygwin, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if $cygwin ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
@@ -154,19 +156,19 @@ if $cygwin ; then
|
|||||||
else
|
else
|
||||||
eval `echo args$i`="\"$arg\""
|
eval `echo args$i`="\"$arg\""
|
||||||
fi
|
fi
|
||||||
i=$((i+1))
|
i=`expr $i + 1`
|
||||||
done
|
done
|
||||||
case $i in
|
case $i in
|
||||||
(0) set -- ;;
|
0) set -- ;;
|
||||||
(1) set -- "$args0" ;;
|
1) set -- "$args0" ;;
|
||||||
(2) set -- "$args0" "$args1" ;;
|
2) set -- "$args0" "$args1" ;;
|
||||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -175,14 +177,9 @@ save () {
|
|||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
echo " "
|
echo " "
|
||||||
}
|
}
|
||||||
APP_ARGS=$(save "$@")
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
|
||||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
204
gradlew.bat
vendored
204
gradlew.bat
vendored
@@ -1,100 +1,104 @@
|
|||||||
@rem
|
@rem
|
||||||
@rem Copyright 2015 the original author or authors.
|
@rem Copyright 2015 the original author or authors.
|
||||||
@rem
|
@rem
|
||||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@rem you may not use this file except in compliance with the License.
|
@rem you may not use this file except in compliance with the License.
|
||||||
@rem You may obtain a copy of the License at
|
@rem You may obtain a copy of the License at
|
||||||
@rem
|
@rem
|
||||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
@rem
|
@rem
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@rem
|
@rem
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
@rem Set local scope for the variables with windows NT shell
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
@rem Find java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
echo.
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
echo.
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo.
|
||||||
echo location of your Java installation.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
goto fail
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
:findJavaFromJavaHome
|
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
goto fail
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
if exist "%JAVA_EXE%" goto init
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
echo.
|
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
if exist "%JAVA_EXE%" goto init
|
||||||
echo.
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo.
|
||||||
echo location of your Java installation.
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
goto fail
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
:init
|
|
||||||
@rem Get command-line arguments, handling Windows variants
|
goto fail
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
:win9xME_args
|
|
||||||
@rem Slurp the command line arguments.
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
set CMD_LINE_ARGS=
|
|
||||||
set _SKIP=2
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
:win9xME_args_slurp
|
set CMD_LINE_ARGS=
|
||||||
if "x%~1" == "x" goto execute
|
set _SKIP=2
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
:execute
|
|
||||||
@rem Setup the command line
|
set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
@rem Execute Gradle
|
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
:end
|
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem Execute Gradle
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
:fail
|
:end
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
@rem End local scope for the variables with windows NT shell
|
||||||
rem the _cmd.exe /c_ return code!
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
|
||||||
exit /b 1
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
:mainEnd
|
rem the _cmd.exe /c_ return code!
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
:omega
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
|
|||||||
Reference in New Issue
Block a user