mirror of
https://github.com/chylex/Better-Controls.git
synced 2025-09-13 20:32:14 +02:00
Compare commits
8 Commits
1.18
...
76af39fb18
Author | SHA1 | Date | |
---|---|---|---|
76af39fb18
|
|||
38fb2a1f1e
|
|||
e748c21efe
|
|||
bd9ba27ac3
|
|||
8a7febb76b
|
|||
553cc9c954
|
|||
6a35ef4203
|
|||
2126402d28
|
@@ -4,7 +4,7 @@ val fabricVersion: String by project
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
idea
|
idea
|
||||||
id("fabric-loom") version "0.10-SNAPSHOT"
|
id("fabric-loom")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
}],
|
}],
|
||||||
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.7.4",
|
"fabricloader": ">=${minimumFabricVersion}",
|
||||||
"minecraft": ">=1.17"
|
"minecraft": ">=${minimumMinecraftVersion}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@ import chylex.bettercontrols.gui.BetterControlsScreen;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.ConfigGuiHandler.ConfigGuiFactory;
|
import net.minecraftforge.client.ConfigScreenHandler.ConfigScreenFactory;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.fml.IExtensionPoint.DisplayTest;
|
import net.minecraftforge.fml.IExtensionPoint.DisplayTest;
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
@@ -16,7 +16,7 @@ import net.minecraftforge.network.NetworkConstants;
|
|||||||
public final class BetterControlsMod {
|
public final class BetterControlsMod {
|
||||||
public BetterControlsMod() {
|
public BetterControlsMod() {
|
||||||
BetterControlsCommon.setConfig(DistExecutor.safeCallWhenOn(Dist.CLIENT, () -> ClientLoader::loadConfig));
|
BetterControlsCommon.setConfig(DistExecutor.safeCallWhenOn(Dist.CLIENT, () -> ClientLoader::loadConfig));
|
||||||
ModLoadingContext.get().registerExtensionPoint(ConfigGuiFactory.class, () -> new ConfigGuiFactory(ClientLoader::createScreen));
|
ModLoadingContext.get().registerExtensionPoint(ConfigScreenFactory.class, () -> new ConfigScreenFactory(ClientLoader::createScreen));
|
||||||
ModLoadingContext.get().registerExtensionPoint(DisplayTest.class, () -> new DisplayTest(() -> NetworkConstants.IGNORESERVERONLY, (a, b) -> true));
|
ModLoadingContext.get().registerExtensionPoint(DisplayTest.class, () -> new DisplayTest(() -> NetworkConstants.IGNORESERVERONLY, (a, b) -> true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
modLoader = "javafml"
|
modLoader = "javafml"
|
||||||
loaderVersion = "[37,)"
|
loaderVersion = "[0,)"
|
||||||
|
|
||||||
authors = "${author}"
|
authors = "${author}"
|
||||||
license = "${license}"
|
license = "${license}"
|
||||||
@@ -15,13 +15,13 @@ logoFile = "icon.png"
|
|||||||
[[dependencies.${id}]]
|
[[dependencies.${id}]]
|
||||||
modId = "minecraft"
|
modId = "minecraft"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "[1.17.1,)"
|
versionRange = "[${minimumMinecraftVersion},)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
|
||||||
[[dependencies.${id}]]
|
[[dependencies.${id}]]
|
||||||
modId = "forge"
|
modId = "forge"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "[37,)"
|
versionRange = "[${minimumForgeVersion},)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
@@ -14,6 +14,10 @@ val modIssuesURL: String by project
|
|||||||
val minecraftVersion: String by project
|
val minecraftVersion: String by project
|
||||||
val mixinVersion: String by project
|
val mixinVersion: String by project
|
||||||
|
|
||||||
|
val minimumMinecraftVersion: String by project
|
||||||
|
val minimumForgeVersion: String by project
|
||||||
|
val minimumFabricVersion: String by project
|
||||||
|
|
||||||
val modNameStripped = modName.replace(" ", "")
|
val modNameStripped = modName.replace(" ", "")
|
||||||
val jarVersion = "$minecraftVersion+v$modVersion"
|
val jarVersion = "$minecraftVersion+v$modVersion"
|
||||||
|
|
||||||
@@ -110,6 +114,9 @@ subprojects {
|
|||||||
inputs.property("license", modLicense)
|
inputs.property("license", modLicense)
|
||||||
inputs.property("sourcesURL", modSourcesURL)
|
inputs.property("sourcesURL", modSourcesURL)
|
||||||
inputs.property("issuesURL", modIssuesURL)
|
inputs.property("issuesURL", modIssuesURL)
|
||||||
|
inputs.property("minimumMinecraftVersion", minimumMinecraftVersion)
|
||||||
|
inputs.property("minimumForgeVersion", minimumForgeVersion)
|
||||||
|
inputs.property("minimumFabricVersion", minimumFabricVersion)
|
||||||
|
|
||||||
from(rootProject.sourceSets.main.get().resources) {
|
from(rootProject.sourceSets.main.get().resources) {
|
||||||
expand(inputs.properties)
|
expand(inputs.properties)
|
||||||
|
@@ -3,16 +3,22 @@ modId=bettercontrols
|
|||||||
modName=Better Controls
|
modName=Better Controls
|
||||||
modDescription=Adds many powerful key bindings and options to control your movement.\\n\\nThe features complement vanilla mechanics without giving unfair advantages, so server use should be fine.
|
modDescription=Adds many powerful key bindings and options to control your movement.\\n\\nThe features complement vanilla mechanics without giving unfair advantages, so server use should be fine.
|
||||||
modAuthor=chylex
|
modAuthor=chylex
|
||||||
modVersion=1.2.3
|
modVersion=1.2.4
|
||||||
modLicense=MPL-2.0
|
modLicense=MPL-2.0
|
||||||
modSourcesURL=https://github.com/chylex/Better-Controls
|
modSourcesURL=https://github.com/chylex/Better-Controls
|
||||||
modIssuesURL=https://github.com/chylex/Better-Controls/issues
|
modIssuesURL=https://github.com/chylex/Better-Controls/issues
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
minecraftVersion=1.18
|
minecraftVersion=1.19.3
|
||||||
forgeVersion=38.0.8
|
forgeVersion=44.0.11
|
||||||
fabricVersion=0.12.8
|
fabricVersion=0.14.11
|
||||||
mixinVersion=0.8.4
|
loomVersion=0.12
|
||||||
|
mixinVersion=0.8.5
|
||||||
|
|
||||||
|
# Constraints
|
||||||
|
minimumMinecraftVersion=1.19.3
|
||||||
|
minimumForgeVersion=44.0.0
|
||||||
|
minimumFabricVersion=0.7.4
|
||||||
|
|
||||||
# Gradle
|
# Gradle
|
||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
|
@@ -6,6 +6,12 @@ pluginManagement {
|
|||||||
maven(url = "https://maven.fabricmc.net/") { name = "Fabric" }
|
maven(url = "https://maven.fabricmc.net/") { name = "Fabric" }
|
||||||
maven(url = "https://repo.spongepowered.org/repository/maven-public/") { name = "Sponge Snapshots" }
|
maven(url = "https://repo.spongepowered.org/repository/maven-public/") { name = "Sponge Snapshots" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
if (settings.extra.has("loomVersion")) {
|
||||||
|
id("fabric-loom") version "${settings.extra["loomVersion"]}-SNAPSHOT"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.extra.has("forgeVersion")) {
|
if (settings.extra.has("forgeVersion")) {
|
||||||
|
@@ -20,7 +20,6 @@ import net.minecraft.client.gui.screens.OptionsSubScreen;
|
|||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.CommonComponents;
|
import net.minecraft.network.chat.CommonComponents;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
@@ -34,10 +33,11 @@ import static chylex.bettercontrols.gui.OptionListWidget.ROW_WIDTH;
|
|||||||
import static chylex.bettercontrols.gui.OptionListWidget.col2;
|
import static chylex.bettercontrols.gui.OptionListWidget.col2;
|
||||||
import static chylex.bettercontrols.gui.OptionListWidget.col4;
|
import static chylex.bettercontrols.gui.OptionListWidget.col4;
|
||||||
import static chylex.bettercontrols.gui.elements.TextWidget.CENTER;
|
import static chylex.bettercontrols.gui.elements.TextWidget.CENTER;
|
||||||
|
import static net.minecraft.network.chat.Component.literal;
|
||||||
|
|
||||||
public class BetterControlsScreen extends OptionsSubScreen {
|
public class BetterControlsScreen extends OptionsSubScreen {
|
||||||
private static TextComponent text(final String text) {
|
private static Component text(final String text) {
|
||||||
return new TextComponent(text);
|
return literal(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Component TITLE = text("Better Controls");
|
public static final Component TITLE = text("Better Controls");
|
||||||
@@ -85,7 +85,6 @@ public class BetterControlsScreen extends OptionsSubScreen {
|
|||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "AutoBoxing", "AutoUnboxing" })
|
|
||||||
private int generateFlightOptions(int y, final List<GuiEventListener> elements) {
|
private int generateFlightOptions(int y, final List<GuiEventListener> elements) {
|
||||||
final BetterControlsConfig cfg = BetterControlsCommon.getConfig();
|
final BetterControlsConfig cfg = BetterControlsCommon.getConfig();
|
||||||
|
|
||||||
@@ -243,7 +242,7 @@ public class BetterControlsScreen extends OptionsSubScreen {
|
|||||||
elements.add(new TextWidget(0, y, ROW_WIDTH, ROW_HEIGHT, text("Miscellaneous"), CENTER));
|
elements.add(new TextWidget(0, y, ROW_WIDTH, ROW_HEIGHT, text("Miscellaneous"), CENTER));
|
||||||
y = generateMiscellaneousOptions(y + ROW_HEIGHT, elements) + TITLE_MARGIN_TOP;
|
y = generateMiscellaneousOptions(y + ROW_HEIGHT, elements) + TITLE_MARGIN_TOP;
|
||||||
|
|
||||||
addRenderableWidget(new Button(width / 2 - 99, height - 29, 200, 20, CommonComponents.GUI_DONE, btn -> minecraft.setScreen(lastScreen)));
|
addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, btn -> minecraft.setScreen(lastScreen)).pos(width / 2 - 99, height - 29).size(200, 20).build());
|
||||||
addWidget(optionsWidget = new OptionListWidget(21, height - 32, width, height, elements, y - TITLE_MARGIN_TOP + BOTTOM_PADDING));
|
addWidget(optionsWidget = new OptionListWidget(21, height - 32, width, height, elements, y - TITLE_MARGIN_TOP + BOTTOM_PADDING));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
import net.minecraft.client.gui.components.AbstractWidget;
|
||||||
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
|
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
|
||||||
import net.minecraft.client.gui.components.Widget;
|
import net.minecraft.client.gui.components.Renderable;
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -35,14 +35,14 @@ public final class OptionListWidget extends ContainerObjectSelectionList<Entry>
|
|||||||
return new Offset(widget.getX(), widget.getY());
|
return new Offset(widget.getX(), widget.getY());
|
||||||
}
|
}
|
||||||
else if (element instanceof final AbstractWidget widget) {
|
else if (element instanceof final AbstractWidget widget) {
|
||||||
return new Offset(widget.x, widget.y);
|
return new Offset(widget.getX(), widget.getY());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new Offset(0, 0);
|
return new Offset(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OptionWidget extends GuiEventListener, Widget {
|
public interface OptionWidget extends GuiEventListener, Renderable {
|
||||||
int getX();
|
int getX();
|
||||||
int getY();
|
int getY();
|
||||||
void setX(int x);
|
void setX(int x);
|
||||||
@@ -82,13 +82,15 @@ public final class OptionListWidget extends ContainerObjectSelectionList<Entry>
|
|||||||
this.offsets = elements.stream().collect(Collectors.toMap(Function.identity(), OptionListWidget::getElementOffset));
|
this.offsets = elements.stream().collect(Collectors.toMap(Function.identity(), OptionListWidget::getElementOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<? extends GuiEventListener> children() {
|
public List<? extends GuiEventListener> children() {
|
||||||
return Collections.unmodifiableList(elements);
|
return Collections.unmodifiableList(elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<? extends NarratableEntry> narratables() {
|
public List<? extends NarratableEntry> narratables() {
|
||||||
return Collections.unmodifiableList(narratables);
|
return Collections.unmodifiableList(narratables);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,16 +100,16 @@ public final class OptionListWidget extends ContainerObjectSelectionList<Entry>
|
|||||||
final Offset offset = offsets.get(element);
|
final Offset offset = offsets.get(element);
|
||||||
|
|
||||||
if (element instanceof final AbstractWidget widget) {
|
if (element instanceof final AbstractWidget widget) {
|
||||||
widget.x = x + offset.x;
|
widget.setX(x + offset.x);
|
||||||
widget.y = y + offset.y;
|
widget.setY(y + offset.y);
|
||||||
}
|
}
|
||||||
else if (element instanceof final OptionWidget widget) {
|
else if (element instanceof final OptionWidget widget) {
|
||||||
widget.setX(x + offset.x);
|
widget.setX(x + offset.x);
|
||||||
widget.setY(y + offset.y);
|
widget.setY(y + offset.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element instanceof final Widget widget) {
|
if (element instanceof final Renderable renderable) {
|
||||||
widget.render(matrices, mouseX, mouseY, tickDelta);
|
renderable.render(matrices, mouseX, mouseY, tickDelta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,6 @@ package chylex.bettercontrols.gui.elements;
|
|||||||
import net.minecraft.client.gui.components.AbstractSliderButton;
|
import net.minecraft.client.gui.components.AbstractSliderButton;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -45,8 +44,9 @@ public final class DiscreteValueSliderWidget<T> extends AbstractSliderButton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
protected @NotNull MutableComponent createNarrationMessage() {
|
protected MutableComponent createNarrationMessage() {
|
||||||
return new TranslatableComponent("gui.narrate.slider", narration.plainCopy().append(" ").append(getMessage()));
|
return Component.translatable("gui.narrate.slider", narration.plainCopy().append(" ").append(getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,8 +7,6 @@ import net.minecraft.client.gui.components.AbstractButton;
|
|||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -24,7 +22,7 @@ public final class KeyBindingWidget extends Button {
|
|||||||
private boolean isEditing;
|
private boolean isEditing;
|
||||||
|
|
||||||
public KeyBindingWidget(final int x, final int y, final int width, final int height, final Component bindingName, final KeyMapping binding, final Consumer<KeyBindingWidget> onEditingStarted) {
|
public KeyBindingWidget(final int x, final int y, final int width, final int height, final Component bindingName, final KeyMapping binding, final Consumer<KeyBindingWidget> onEditingStarted) {
|
||||||
super(x, y, width, height, TextComponent.EMPTY, btn -> {});
|
super(x, y, width, height, Component.empty(), btn -> {}, DEFAULT_NARRATION);
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
this.bindingName = bindingName;
|
this.bindingName = bindingName;
|
||||||
this.onEditingStarted = onEditingStarted;
|
this.onEditingStarted = onEditingStarted;
|
||||||
@@ -40,9 +38,10 @@ public final class KeyBindingWidget extends Button {
|
|||||||
button.active = !binding.isUnbound();
|
button.active = !binding.isUnbound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
protected @NotNull MutableComponent createNarrationMessage() {
|
protected MutableComponent createNarrationMessage() {
|
||||||
return binding.isUnbound() ? new TranslatableComponent("narrator.controls.unbound", bindingName) : new TranslatableComponent("narrator.controls.bound", bindingName, super.createNarrationMessage());
|
return binding.isUnbound() ? Component.translatable("narrator.controls.unbound", bindingName) : Component.translatable("narrator.controls.bound", bindingName, super.createNarrationMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -79,13 +78,13 @@ public final class KeyBindingWidget extends Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isEditing) {
|
if (isEditing) {
|
||||||
setMessage((new TextComponent("> ")).append(binding.getTranslatedKeyMessage().copy().withStyle(ChatFormatting.YELLOW)).append(" <").withStyle(ChatFormatting.YELLOW));
|
setMessage(Component.literal("> ").append(binding.getTranslatedKeyMessage().copy().withStyle(ChatFormatting.YELLOW)).append(" <").withStyle(ChatFormatting.YELLOW));
|
||||||
}
|
}
|
||||||
else if (hasConflict) {
|
else if (hasConflict) {
|
||||||
setMessage(binding.getTranslatedKeyMessage().copy().withStyle(ChatFormatting.RED));
|
setMessage(binding.getTranslatedKeyMessage().copy().withStyle(ChatFormatting.RED));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setMessage(binding.isUnbound() ? new TextComponent("(No Binding)") : binding.getTranslatedKeyMessage());
|
setMessage(binding.isUnbound() ? Component.literal("(No Binding)") : binding.getTranslatedKeyMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@ import static org.spongepowered.asm.mixin.injection.At.Shift.AFTER;
|
|||||||
|
|
||||||
@Mixin(KeyboardInput.class)
|
@Mixin(KeyboardInput.class)
|
||||||
public abstract class HookClientPlayerInputTick {
|
public abstract class HookClientPlayerInputTick {
|
||||||
@Inject(method = "tick(Z)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/KeyboardInput;up:Z", ordinal = 0, shift = AFTER))
|
@Inject(method = "tick(ZF)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/KeyboardInput;up:Z", ordinal = 0, shift = AFTER))
|
||||||
private void afterInputTick(final CallbackInfo info) {
|
private void afterInputTick(final CallbackInfo info) {
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
final Input input = (Input)(Object)this;
|
final Input input = (Input)(Object)this;
|
||||||
|
@@ -23,7 +23,7 @@ public abstract class HookClientPlayerTick extends AbstractClientPlayer {
|
|||||||
PlayerTicker.get(player).atHead(player);
|
PlayerTicker.get(player).atHead(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "aiStep()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/Input;tick(Z)V", ordinal = 0, shift = AFTER))
|
@Inject(method = "aiStep()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/Input;tick(ZF)V", ordinal = 0, shift = AFTER))
|
||||||
private void afterInputTick(final CallbackInfo info) {
|
private void afterInputTick(final CallbackInfo info) {
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
final LocalPlayer player = (LocalPlayer)(Object)this;
|
final LocalPlayer player = (LocalPlayer)(Object)this;
|
||||||
|
@@ -9,7 +9,9 @@ import net.minecraft.client.gui.components.events.GuiEventListener;
|
|||||||
import net.minecraft.client.gui.screens.OptionsSubScreen;
|
import net.minecraft.client.gui.screens.OptionsSubScreen;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.gui.screens.controls.ControlsScreen;
|
import net.minecraft.client.gui.screens.controls.ControlsScreen;
|
||||||
|
import net.minecraft.network.chat.CommonComponents;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
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;
|
||||||
@@ -29,25 +31,31 @@ public abstract class HookControlsScreen extends OptionsSubScreen {
|
|||||||
|
|
||||||
int leftBottomY = 0;
|
int leftBottomY = 0;
|
||||||
int rightBottomY = 0;
|
int rightBottomY = 0;
|
||||||
|
AbstractWidget doneButton = null;
|
||||||
|
|
||||||
for (final GuiEventListener child : children()) {
|
for (final GuiEventListener child : children()) {
|
||||||
if (!(child instanceof AbstractWidget widget)) {
|
if (!(child instanceof AbstractWidget widget)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int bottomY = widget.y + widget.getHeight();
|
if (widget instanceof Button button && button.getMessage() == CommonComponents.GUI_DONE) {
|
||||||
|
doneButton = widget;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (widget.x + widget.getWidth() < center) {
|
final int bottomY = widget.getY() + widget.getHeight();
|
||||||
|
|
||||||
|
if (widget.getX() + widget.getWidth() < center) {
|
||||||
leftBottomY = Math.max(leftBottomY, bottomY);
|
leftBottomY = Math.max(leftBottomY, bottomY);
|
||||||
}
|
}
|
||||||
if (widget.x >= center) {
|
if (widget.getX() >= center) {
|
||||||
rightBottomY = Math.max(rightBottomY, bottomY);
|
rightBottomY = Math.max(rightBottomY, bottomY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final int x, y;
|
final int x, y;
|
||||||
|
|
||||||
if (leftBottomY < rightBottomY) {
|
if (leftBottomY <= rightBottomY) {
|
||||||
x = center - 155;
|
x = center - 155;
|
||||||
y = leftBottomY + 4;
|
y = leftBottomY + 4;
|
||||||
}
|
}
|
||||||
@@ -56,6 +64,11 @@ public abstract class HookControlsScreen extends OptionsSubScreen {
|
|||||||
y = rightBottomY + 4;
|
y = rightBottomY + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
addRenderableWidget(new Button(x, y, 150, 20, BetterControlsScreen.TITLE.plainCopy().append("..."), btn -> Minecraft.getInstance().setScreen(new BetterControlsScreen(screen))));
|
final MutableComponent buttonTitle = BetterControlsScreen.TITLE.plainCopy().append("...");
|
||||||
|
addRenderableWidget(Button.builder(buttonTitle, btn -> Minecraft.getInstance().setScreen(new BetterControlsScreen(screen))).pos(x, y).size(150, 20).build());
|
||||||
|
|
||||||
|
if (doneButton != null) {
|
||||||
|
doneButton.setY(y + 24);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
package chylex.bettercontrols.mixin;
|
package chylex.bettercontrols.mixin;
|
||||||
|
|
||||||
import net.minecraft.client.CycleOption;
|
import net.minecraft.client.OptionInstance;
|
||||||
import net.minecraft.client.Option;
|
|
||||||
import net.minecraft.client.Options;
|
import net.minecraft.client.Options;
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
import net.minecraft.client.gui.components.AbstractWidget;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -9,14 +8,14 @@ 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.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(CycleOption.class)
|
@Mixin(OptionInstance.class)
|
||||||
public abstract class HookToggleOptionButtons {
|
public abstract class HookToggleOptionButtons {
|
||||||
@Inject(method = "createButton", at = @At("RETURN"))
|
@Inject(method = "createButton", at = @At("RETURN"))
|
||||||
private void disableToggleOptions(final Options options, final int x, final int y, final int width, final CallbackInfoReturnable<AbstractWidget> ci) {
|
private void disableToggleOptions(final Options options, final int x, final int y, final int width, final CallbackInfoReturnable<AbstractWidget> ci) {
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
final CycleOption<?> me = (CycleOption<?>)(Object)this;
|
final OptionInstance<?> me = (OptionInstance<?>)(Object)this;
|
||||||
|
|
||||||
if (me == Option.TOGGLE_CROUCH || me == Option.TOGGLE_SPRINT) {
|
if (me == options.toggleCrouch() || me == options.toggleSprint()) {
|
||||||
ci.getReturnValue().active = false;
|
ci.getReturnValue().active = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -50,8 +50,8 @@ public final class PlayerTicker {
|
|||||||
|
|
||||||
// Logic
|
// Logic
|
||||||
|
|
||||||
private final ToggleTracker toggleSprint = new ToggleTrackerForStickyKey(cfg().keyToggleSprint, KEY_SPRINT, toggled -> OPTIONS.toggleSprint = toggled);
|
private final ToggleTracker toggleSprint = new ToggleTrackerForStickyKey(cfg().keyToggleSprint, KEY_SPRINT, OPTIONS.toggleSprint()::set);
|
||||||
private final ToggleTracker toggleSneak = new ToggleTrackerForStickyKey(cfg().keyToggleSneak, KEY_SNEAK, toggled -> OPTIONS.toggleCrouch = toggled);
|
private final ToggleTracker toggleSneak = new ToggleTrackerForStickyKey(cfg().keyToggleSneak, KEY_SNEAK, OPTIONS.toggleCrouch()::set);
|
||||||
private final ToggleTracker toggleWalkForward = new ToggleTracker(cfg().keyToggleWalkForward, KEY_FORWARD);
|
private final ToggleTracker toggleWalkForward = new ToggleTracker(cfg().keyToggleWalkForward, KEY_FORWARD);
|
||||||
private final ToggleTracker toggleJump = new ToggleTracker(cfg().keyToggleJump, KEY_JUMP);
|
private final ToggleTracker toggleJump = new ToggleTracker(cfg().keyToggleJump, KEY_JUMP);
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public final class PlayerTicker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final SprintMode sprintMode = cfg().sprintMode;
|
final SprintMode sprintMode = cfg().sprintMode;
|
||||||
final boolean wasSprintToggled = OPTIONS.toggleSprint;
|
final boolean wasSprintToggled = Boolean.TRUE.equals(OPTIONS.toggleSprint().get());
|
||||||
final boolean isSprintToggled = toggleSprint.tick();
|
final boolean isSprintToggled = toggleSprint.tick();
|
||||||
|
|
||||||
if (temporarySprintTimer > 0) {
|
if (temporarySprintTimer > 0) {
|
||||||
|
Reference in New Issue
Block a user