mirror of
https://github.com/chylex/Better-Controls.git
synced 2025-08-18 10:31:48 +02:00
Compare commits
13 Commits
forge/1.15
...
forge/1.16
Author | SHA1 | Date | |
---|---|---|---|
2617208482
|
|||
b74818fc4c
|
|||
fa92d958b7 | |||
b254d724cd | |||
22892d5654 | |||
473e2e6609 | |||
fe95cee3d9 | |||
cde46814d8 | |||
3812f83f85 | |||
4c3978d762 | |||
349e0ebb3f | |||
eb81c5f635 | |||
5031d83962 |
@@ -21,8 +21,8 @@ apply plugin: 'net.minecraftforge.gradle'
|
|||||||
apply plugin: 'org.spongepowered.mixin'
|
apply plugin: 'org.spongepowered.mixin'
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
|
|
||||||
def mcversion = "1.15.2"
|
def mcversion = "1.16.4"
|
||||||
def forgeversion = "31.2.45"
|
def forgeversion = "35.0.1"
|
||||||
|
|
||||||
def prefixName = 'displayName = '
|
def prefixName = 'displayName = '
|
||||||
def prefixVersion = 'version = '
|
def prefixVersion = 'version = '
|
||||||
@@ -38,7 +38,7 @@ archivesBaseName = metaName.replaceAll('\\s', '')
|
|||||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
|
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: 'snapshot', version: '20201030-1.15.1'
|
mappings channel: 'snapshot', version: '20201028-1.16.3'
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
client {
|
client {
|
||||||
@@ -74,7 +74,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
archiveName = archivesBaseName + '-' + mcversion + '-v' + version + '.jar'
|
archiveName = archivesBaseName + '-' + mcversion + '+v' + version + '.jar'
|
||||||
|
|
||||||
from('./') {
|
from('./') {
|
||||||
include 'LICENSE'
|
include 'LICENSE'
|
||||||
|
@@ -12,11 +12,12 @@ import chylex.bettercontrols.input.ModifierKey;
|
|||||||
import chylex.bettercontrols.input.SprintMode;
|
import chylex.bettercontrols.input.SprintMode;
|
||||||
import chylex.bettercontrols.util.Key;
|
import chylex.bettercontrols.util.Key;
|
||||||
import chylex.bettercontrols.util.LiteralText;
|
import chylex.bettercontrols.util.LiteralText;
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
import net.minecraft.client.gui.DialogTexts;
|
||||||
import net.minecraft.client.gui.IGuiEventListener;
|
import net.minecraft.client.gui.IGuiEventListener;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.screen.SettingsScreen;
|
import net.minecraft.client.gui.screen.SettingsScreen;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -246,21 +247,21 @@ public class BetterControlsScreen extends SettingsScreen{
|
|||||||
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;
|
||||||
|
|
||||||
addButton(new Button(width / 2 - 99, height - 29, 200, 20, I18n.format("gui.done"), btn -> minecraft.displayGuiScreen(parentScreen)));
|
addButton(new Button(width / 2 - 99, height - 29, 200, 20, DialogTexts.GUI_DONE, btn -> minecraft.displayGuiScreen(parentScreen)));
|
||||||
children.add(optionsWidget = new OptionListWidget(21, height - 32, width, height, elements, y - TITLE_MARGIN_TOP + BOTTOM_PADDING));
|
addListener(optionsWidget = new OptionListWidget(21, height - 32, width, height, elements, y - TITLE_MARGIN_TOP + BOTTOM_PADDING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removed(){
|
public void onClose(){
|
||||||
BetterControlsMod.config.save();
|
BetterControlsMod.config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(final int mouseX, final int mouseY, final float delta){
|
public void render(final MatrixStack matrices, final int mouseX, final int mouseY, final float delta){
|
||||||
renderBackground();
|
renderBackground(matrices);
|
||||||
optionsWidget.render(mouseX, mouseY, delta);
|
optionsWidget.render(matrices, mouseX, mouseY, delta);
|
||||||
drawCenteredString(font, title.getString(), width / 2, 8, (255 << 16) | (255 << 8) | 255);
|
drawCenteredString(matrices, font, title, width / 2, 8, (255 << 16) | (255 << 8) | 255);
|
||||||
super.render(mouseX, mouseY, delta);
|
super.render(matrices, mouseX, mouseY, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startEditingKeyBinding(final KeyBindingWidget widget){
|
private void startEditingKeyBinding(final KeyBindingWidget widget){
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package chylex.bettercontrols.gui;
|
package chylex.bettercontrols.gui;
|
||||||
import chylex.bettercontrols.gui.OptionListWidget.Entry;
|
import chylex.bettercontrols.gui.OptionListWidget.Entry;
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import net.minecraft.client.gui.IGuiEventListener;
|
import net.minecraft.client.gui.IGuiEventListener;
|
||||||
import net.minecraft.client.gui.IRenderable;
|
import net.minecraft.client.gui.IRenderable;
|
||||||
import net.minecraft.client.gui.widget.list.AbstractOptionList;
|
import net.minecraft.client.gui.widget.list.AbstractOptionList;
|
||||||
@@ -61,7 +62,7 @@ public final class OptionListWidget extends AbstractOptionList<Entry>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getRowLeft(){
|
public int getRowLeft(){
|
||||||
return super.getRowLeft() - ROW_PADDING;
|
return super.getRowLeft() - ROW_PADDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,12 +86,12 @@ public final class OptionListWidget extends AbstractOptionList<Entry>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends IGuiEventListener> children(){
|
public List<? extends IGuiEventListener> getEventListeners(){
|
||||||
return Collections.unmodifiableList(elements);
|
return Collections.unmodifiableList(elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(final int index, final int y, final int x, final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean hovered, final float tickDelta){
|
public void render(final MatrixStack matrices, final int index, final int y, final int x, final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean hovered, final float tickDelta){
|
||||||
for(final IGuiEventListener element : elements){
|
for(final IGuiEventListener element : elements){
|
||||||
final Offset offset = offsets.get(element);
|
final Offset offset = offsets.get(element);
|
||||||
|
|
||||||
@@ -106,7 +107,7 @@ public final class OptionListWidget extends AbstractOptionList<Entry>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (element instanceof IRenderable){
|
if (element instanceof IRenderable){
|
||||||
((IRenderable)element).render(mouseX, mouseY, tickDelta);
|
((IRenderable)element).render(matrices, mouseX, mouseY, tickDelta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package chylex.bettercontrols.gui;
|
package chylex.bettercontrols.gui;
|
||||||
import chylex.bettercontrols.mixin.AccessOptionButtonWidgetOption;
|
|
||||||
import chylex.bettercontrols.mixin.AccessScreenButtons;
|
import chylex.bettercontrols.mixin.AccessScreenButtons;
|
||||||
|
import net.minecraft.client.AbstractOption;
|
||||||
import net.minecraft.client.gui.AccessibilityScreen;
|
import net.minecraft.client.gui.AccessibilityScreen;
|
||||||
import net.minecraft.client.gui.IGuiEventListener;
|
import net.minecraft.client.gui.IGuiEventListener;
|
||||||
import net.minecraft.client.gui.INestedGuiEventHandler;
|
import net.minecraft.client.gui.INestedGuiEventHandler;
|
||||||
@@ -8,7 +8,6 @@ import net.minecraft.client.gui.screen.ControlsScreen;
|
|||||||
import net.minecraft.client.gui.widget.button.AbstractButton;
|
import net.minecraft.client.gui.widget.button.AbstractButton;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.client.gui.widget.button.OptionButton;
|
import net.minecraft.client.gui.widget.button.OptionButton;
|
||||||
import net.minecraft.client.settings.AbstractOption;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import static chylex.bettercontrols.util.Statics.MINECRAFT;
|
import static chylex.bettercontrols.util.Statics.MINECRAFT;
|
||||||
@@ -19,12 +18,12 @@ public final class ScreenPatcher{
|
|||||||
public static void onControlsScreenOpened(final ControlsScreen screen){
|
public static void onControlsScreenOpened(final ControlsScreen screen){
|
||||||
final AccessScreenButtons accessor = (AccessScreenButtons)screen;
|
final AccessScreenButtons accessor = (AccessScreenButtons)screen;
|
||||||
|
|
||||||
final List<? extends IGuiEventListener> children = screen.children();
|
final List<? extends IGuiEventListener> children = screen.getEventListeners();
|
||||||
final List<AbstractButton> buttons = accessor.getButtons();
|
final List<AbstractButton> buttons = accessor.getButtons();
|
||||||
|
|
||||||
final AbstractButton autoJump = buttons
|
final AbstractButton autoJump = buttons
|
||||||
.stream()
|
.stream()
|
||||||
.filter(it -> it instanceof OptionButton && ((AccessOptionButtonWidgetOption)it).getOption() == AbstractOption.AUTO_JUMP)
|
.filter(it -> it instanceof OptionButton && ((OptionButton)it).func_238517_a_() == AbstractOption.AUTO_JUMP)
|
||||||
.findAny()
|
.findAny()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
@@ -32,17 +31,17 @@ public final class ScreenPatcher{
|
|||||||
children.remove(autoJump);
|
children.remove(autoJump);
|
||||||
buttons.remove(autoJump);
|
buttons.remove(autoJump);
|
||||||
|
|
||||||
accessor.callAddButton(new Button(autoJump.x, autoJump.y, autoJump.getWidth(), 20, BetterControlsScreen.TITLE.copy().appendText("...").getString(), btn -> {
|
accessor.callAddButton(new Button(autoJump.x, autoJump.y, autoJump.getWidth(), 20, BetterControlsScreen.TITLE.copy().appendString("..."), btn -> {
|
||||||
MINECRAFT.displayGuiScreen(new BetterControlsScreen(screen));
|
MINECRAFT.displayGuiScreen(new BetterControlsScreen(screen));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onAccessibilityScreenOpened(final AccessibilityScreen screen){
|
public static void onAccessibilityScreenOpened(final AccessibilityScreen screen){
|
||||||
walkChildren(screen.children(), it -> {
|
walkChildren(screen.getEventListeners(), it -> {
|
||||||
if (it instanceof OptionButton){
|
if (it instanceof OptionButton){
|
||||||
final OptionButton button = (OptionButton)it;
|
final OptionButton button = (OptionButton)it;
|
||||||
final AbstractOption option = ((AccessOptionButtonWidgetOption)button).getOption();
|
final AbstractOption option = button.func_238517_a_();
|
||||||
|
|
||||||
if (option == AbstractOption.SPRINT || option == AbstractOption.SNEAK){
|
if (option == AbstractOption.SPRINT || option == AbstractOption.SNEAK){
|
||||||
button.active = false;
|
button.active = false;
|
||||||
@@ -56,7 +55,7 @@ public final class ScreenPatcher{
|
|||||||
callback.accept(listener);
|
callback.accept(listener);
|
||||||
|
|
||||||
if (listener instanceof INestedGuiEventHandler){
|
if (listener instanceof INestedGuiEventHandler){
|
||||||
walkChildren(((INestedGuiEventHandler)listener).children(), callback);
|
walkChildren(((INestedGuiEventHandler)listener).getEventListeners(), callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
package chylex.bettercontrols.gui.elements;
|
package chylex.bettercontrols.gui.elements;
|
||||||
import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
|
import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
|
||||||
|
import net.minecraft.client.gui.DialogTexts;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
|
|
||||||
public final class BooleanValueWidget extends Button{
|
public final class BooleanValueWidget extends Button{
|
||||||
private final BooleanConsumer onChanged;
|
private final BooleanConsumer onChanged;
|
||||||
private boolean value;
|
private boolean value;
|
||||||
|
|
||||||
public BooleanValueWidget(final int x, final int y, final int width, final int height, final boolean currentValue, final BooleanConsumer onChanged){
|
public BooleanValueWidget(final int x, final int y, final int width, final int height, final boolean currentValue, final BooleanConsumer onChanged){
|
||||||
super(x, y, width, height, I18n.format(currentValue ? "options.on" : "options.off"), ignore -> {});
|
super(x, y, width, height, currentValue ? DialogTexts.OPTIONS_ON : DialogTexts.OPTIONS_OFF, ignore -> {});
|
||||||
this.value = currentValue;
|
this.value = currentValue;
|
||||||
this.onChanged = onChanged;
|
this.onChanged = onChanged;
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ public final class BooleanValueWidget extends Button{
|
|||||||
public void onPress(){
|
public void onPress(){
|
||||||
super.onPress();
|
super.onPress();
|
||||||
value = !value;
|
value = !value;
|
||||||
setMessage(I18n.format(value ? "options.on" : "options.off"));
|
setMessage(value ? DialogTexts.OPTIONS_ON : DialogTexts.OPTIONS_OFF);
|
||||||
onChanged.accept(value);
|
onChanged.accept(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ public class CycleButtonWidget<T> extends Button{
|
|||||||
private T selectedValue;
|
private T selectedValue;
|
||||||
|
|
||||||
public CycleButtonWidget(final int x, final int y, final int width, final int height, final List<Option<T>> options, final T selectedValue, final Consumer<T> onChanged){
|
public CycleButtonWidget(final int x, final int y, final int width, final int height, final List<Option<T>> options, final T selectedValue, final Consumer<T> onChanged){
|
||||||
super(x, y, width, height, Option.find(options, selectedValue).getText().getString(), btn -> {});
|
super(x, y, width, height, Option.find(options, selectedValue).getText(), btn -> {});
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.selectedValue = selectedValue;
|
this.selectedValue = selectedValue;
|
||||||
this.onChanged = onChanged;
|
this.onChanged = onChanged;
|
||||||
@@ -31,6 +31,6 @@ public class CycleButtonWidget<T> extends Button{
|
|||||||
|
|
||||||
selectedValue = newSelectedOption.getValue();
|
selectedValue = newSelectedOption.getValue();
|
||||||
onChanged.accept(selectedValue);
|
onChanged.accept(selectedValue);
|
||||||
setMessage(newSelectedOption.getText().getString());
|
setMessage(newSelectedOption.getText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,11 +10,10 @@ public final class DiscreteValueSliderWidget<T> extends AbstractSlider{
|
|||||||
private T selectedValue;
|
private T selectedValue;
|
||||||
|
|
||||||
public DiscreteValueSliderWidget(final int x, final int y, final int width, final int height, final List<Option<T>> options, final T selectedValue, final Consumer<T> onChanged){
|
public DiscreteValueSliderWidget(final int x, final int y, final int width, final int height, final List<Option<T>> options, final T selectedValue, final Consumer<T> onChanged){
|
||||||
super(x, y, width, height, options.indexOf(Option.find(options, selectedValue)) / (options.size() - 1.0));
|
super(x, y, width, height, Option.find(options, selectedValue).getText(), options.indexOf(Option.find(options, selectedValue)) / (options.size() - 1.0));
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.selectedValue = selectedValue;
|
this.selectedValue = selectedValue;
|
||||||
this.onChanged = onChanged;
|
this.onChanged = onChanged;
|
||||||
updateMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiscreteValueSliderWidget(final int x, final int y, final int width, final List<Option<T>> options, final T selectedValue, final Consumer<T> onChanged){
|
public DiscreteValueSliderWidget(final int x, final int y, final int width, final List<Option<T>> options, final T selectedValue, final Consumer<T> onChanged){
|
||||||
@@ -22,16 +21,16 @@ public final class DiscreteValueSliderWidget<T> extends AbstractSlider{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Option<T> getSelectedOption(){
|
public Option<T> getSelectedOption(){
|
||||||
return options.get(MathHelper.floor(MathHelper.clampedLerp(0.0, options.size() - 1.0, value)));
|
return options.get(MathHelper.floor(MathHelper.clampedLerp(0.0, options.size() - 1.0, sliderValue)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateMessage(){
|
protected void func_230979_b_(){
|
||||||
setMessage(getSelectedOption().getText().getString());
|
setMessage(getSelectedOption().getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void applyValue(){
|
protected void func_230972_a_(){
|
||||||
final T newSelectedValue = getSelectedOption().getValue();
|
final T newSelectedValue = getSelectedOption().getValue();
|
||||||
|
|
||||||
if (selectedValue != newSelectedValue){
|
if (selectedValue != newSelectedValue){
|
||||||
|
@@ -2,10 +2,11 @@ package chylex.bettercontrols.gui.elements;
|
|||||||
import chylex.bettercontrols.util.Key;
|
import chylex.bettercontrols.util.Key;
|
||||||
import net.minecraft.client.gui.widget.button.AbstractButton;
|
import net.minecraft.client.gui.widget.button.AbstractButton;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.client.util.InputMappings;
|
import net.minecraft.client.util.InputMappings;
|
||||||
|
import net.minecraft.util.text.IFormattableTextComponent;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -23,7 +24,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 KeyBinding binding, final Consumer<KeyBindingWidget> onEditingStarted){
|
public KeyBindingWidget(final int x, final int y, final int width, final int height, final KeyBinding binding, final Consumer<KeyBindingWidget> onEditingStarted){
|
||||||
super(x, y, width, height, "", btn -> {});
|
super(x, y, width, height, StringTextComponent.EMPTY, btn -> {});
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
this.bindingName = new TranslationTextComponent(binding.getTranslationKey());
|
this.bindingName = new TranslationTextComponent(binding.getTranslationKey());
|
||||||
this.onEditingStarted = onEditingStarted;
|
this.onEditingStarted = onEditingStarted;
|
||||||
@@ -40,8 +41,8 @@ public final class KeyBindingWidget extends Button{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getNarrationMessage(){
|
protected IFormattableTextComponent getNarrationMessage(){
|
||||||
return Key.isUnbound(binding) ? I18n.format("narrator.controls.unbound", bindingName) : I18n.format("narrator.controls.bound", bindingName, super.getNarrationMessage());
|
return Key.isUnbound(binding) ? new TranslationTextComponent("narrator.controls.unbound", bindingName) : new TranslationTextComponent("narrator.controls.bound", bindingName, super.getNarrationMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -78,13 +79,13 @@ public final class KeyBindingWidget extends Button{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isEditing){
|
if (isEditing){
|
||||||
setMessage(TextFormatting.WHITE + "> " + TextFormatting.YELLOW + Key.getBoundKeyText(binding) + TextFormatting.WHITE + " <");
|
setMessage((new StringTextComponent("> ")).append(Key.getBoundKeyText(binding).deepCopy().mergeStyle(TextFormatting.YELLOW)).appendString(" <").mergeStyle(TextFormatting.YELLOW));
|
||||||
}
|
}
|
||||||
else if (hasConflict){
|
else if (hasConflict){
|
||||||
setMessage(TextFormatting.RED + Key.getBoundKeyText(binding));
|
setMessage(Key.getBoundKeyText(binding).deepCopy().mergeStyle(TextFormatting.RED));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
setMessage(Key.isUnbound(binding) ? "(No Binding)" : Key.getBoundKeyText(binding));
|
setMessage(Key.isUnbound(binding) ? new StringTextComponent("(No Binding)") : Key.getBoundKeyText(binding));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
package chylex.bettercontrols.gui.elements;
|
package chylex.bettercontrols.gui.elements;
|
||||||
import chylex.bettercontrols.gui.OptionListWidget.Widget;
|
import chylex.bettercontrols.gui.OptionListWidget.Widget;
|
||||||
import chylex.bettercontrols.util.LiteralText;
|
import chylex.bettercontrols.util.LiteralText;
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import net.minecraft.client.gui.AbstractGui;
|
import net.minecraft.client.gui.AbstractGui;
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import net.minecraft.util.IReorderingProcessor;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import static chylex.bettercontrols.util.Statics.MINECRAFT;
|
import static chylex.bettercontrols.util.Statics.MINECRAFT;
|
||||||
|
|
||||||
@@ -55,17 +57,17 @@ public final class TextWidget extends AbstractGui implements Widget{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(final int mouseX, final int mouseY, final float delta){
|
public void render(final MatrixStack matrices, final int mouseX, final int mouseY, final float delta){
|
||||||
final FontRenderer textRenderer = MINECRAFT.fontRenderer;
|
final FontRenderer textRenderer = MINECRAFT.fontRenderer;
|
||||||
final List<String> lines = textRenderer.listFormattedStringToWidth(text.getString(), width);
|
final List<IReorderingProcessor> lines = textRenderer.trimStringToWidth(text, width);
|
||||||
final int lineHeight = textRenderer.FONT_HEIGHT + 1;
|
final int lineHeight = textRenderer.FONT_HEIGHT + 1;
|
||||||
|
|
||||||
final int finalX = align == CENTER ? x + (width / 2) - (lines.stream().mapToInt(textRenderer::getStringWidth).max().orElse(0) / 2) : x;
|
final int finalX = align == CENTER ? x + (width / 2) - (lines.stream().mapToInt(textRenderer::func_243245_a).max().orElse(0) / 2) : x;
|
||||||
final int finalY = y + (height / 2) - (lineHeight * lines.size() / 2) + 1;
|
final int finalY = y + (height / 2) - (lineHeight * lines.size() / 2) + 1;
|
||||||
|
|
||||||
for(int i = 0; i < lines.size(); i++){
|
for(int i = 0; i < lines.size(); i++){
|
||||||
final String line = lines.get(i);
|
final IReorderingProcessor line = lines.get(i);
|
||||||
textRenderer.drawStringWithShadow(line, finalX, finalY + (i * lineHeight), (255 << 16) | (255 << 8) | 255);
|
textRenderer.func_238407_a_(matrices, line, finalX, finalY + (i * lineHeight), (255 << 16) | (255 << 8) | 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,14 +1,15 @@
|
|||||||
package chylex.bettercontrols.input;
|
package chylex.bettercontrols.input;
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.client.util.InputMappings.Type;
|
import net.minecraft.client.util.InputMappings.Type;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class KeyBindingWithModifier extends KeyBinding{
|
public class KeyBindingWithModifier extends KeyBinding{
|
||||||
public static final String CATEGORY = "key.categories.bettercontrols";
|
public static final String CATEGORY = "key.categories.bettercontrols";
|
||||||
|
|
||||||
public static boolean checkCategoryMatches(final String text){
|
public static boolean checkCategoryMatches(final ITextComponent text){
|
||||||
return I18n.format(CATEGORY).equals(text);
|
return text instanceof TranslationTextComponent && CATEGORY.equals(((TranslationTextComponent)text).getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
package chylex.bettercontrols.mixin;
|
package chylex.bettercontrols.mixin;
|
||||||
import net.minecraft.client.gui.widget.list.KeyBindingList.CategoryEntry;
|
import net.minecraft.client.gui.widget.list.KeyBindingList.CategoryEntry;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
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;
|
||||||
|
|
||||||
@Mixin(CategoryEntry.class)
|
@Mixin(CategoryEntry.class)
|
||||||
public interface AccessControlsListCategory{
|
public interface AccessControlsListCategory{
|
||||||
@Accessor("labelText")
|
@Accessor("labelText")
|
||||||
String getText();
|
ITextComponent getText();
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +0,0 @@
|
|||||||
package chylex.bettercontrols.mixin;
|
|
||||||
import net.minecraft.client.gui.widget.button.OptionButton;
|
|
||||||
import net.minecraft.client.settings.AbstractOption;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
|
||||||
|
|
||||||
@Mixin(OptionButton.class)
|
|
||||||
public interface AccessOptionButtonWidgetOption{
|
|
||||||
@Accessor("enumOptions")
|
|
||||||
AbstractOption getOption();
|
|
||||||
}
|
|
@@ -12,7 +12,7 @@ import static org.spongepowered.asm.mixin.injection.At.Shift.AFTER;
|
|||||||
|
|
||||||
@Mixin(MovementInputFromOptions.class)
|
@Mixin(MovementInputFromOptions.class)
|
||||||
public abstract class HookClientPlayerInputTick{
|
public abstract class HookClientPlayerInputTick{
|
||||||
@Inject(method = "func_225607_a_(Z)V", at = @At(value = "FIELD", target = "Lnet/minecraft/util/MovementInputFromOptions;forwardKeyDown:Z", ordinal = 0, shift = AFTER))
|
@Inject(method = "tickMovement(Z)V", at = @At(value = "FIELD", target = "Lnet/minecraft/util/MovementInputFromOptions;forwardKeyDown:Z", ordinal = 0, shift = AFTER))
|
||||||
private void afterInputTick(final CallbackInfo info){
|
private void afterInputTick(final CallbackInfo info){
|
||||||
final MovementInput input = (MovementInput)(Object)this;
|
final MovementInput input = (MovementInput)(Object)this;
|
||||||
final ClientPlayerEntity player = MINECRAFT.player;
|
final ClientPlayerEntity player = MINECRAFT.player;
|
||||||
|
@@ -22,7 +22,7 @@ public abstract class HookClientPlayerTick extends AbstractClientPlayerEntity{
|
|||||||
PlayerTicker.get(player).atHead(player);
|
PlayerTicker.get(player).atHead(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "livingTick()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/MovementInput;func_225607_a_(Z)V", ordinal = 0, shift = AFTER))
|
@Inject(method = "livingTick()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/MovementInput;tickMovement(Z)V", ordinal = 0, shift = AFTER))
|
||||||
private void afterInputTick(final CallbackInfo info){
|
private void afterInputTick(final CallbackInfo info){
|
||||||
final ClientPlayerEntity player = (ClientPlayerEntity)(Object)this;
|
final ClientPlayerEntity player = (ClientPlayerEntity)(Object)this;
|
||||||
PlayerTicker.get(player).afterInputTick(player);
|
PlayerTicker.get(player).afterInputTick(player);
|
||||||
|
@@ -22,7 +22,7 @@ public abstract class HookControlsListWidget extends AbstractOptionList<Entry>{
|
|||||||
|
|
||||||
@Inject(method = "<init>", at = @At("TAIL"))
|
@Inject(method = "<init>", at = @At("TAIL"))
|
||||||
public void init(final ControlsScreen parent, final Minecraft client, final CallbackInfo ci){
|
public void init(final ControlsScreen parent, final Minecraft client, final CallbackInfo ci){
|
||||||
children().removeIf(it -> {
|
getEventListeners().removeIf(it -> {
|
||||||
if (it instanceof CategoryEntry && KeyBindingWithModifier.checkCategoryMatches(((AccessControlsListCategory)it).getText())){
|
if (it instanceof CategoryEntry && KeyBindingWithModifier.checkCategoryMatches(((AccessControlsListCategory)it).getText())){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -75,7 +75,7 @@ public final class PlayerTicker{
|
|||||||
|
|
||||||
public void atHead(final ClientPlayerEntity player){
|
public void atHead(final ClientPlayerEntity player){
|
||||||
if (FlightHelper.shouldFlyOnGround(player)){
|
if (FlightHelper.shouldFlyOnGround(player)){
|
||||||
player.onGround = false;
|
player.setOnGround(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cfg().doubleTapForwardToSprint){
|
if (!cfg().doubleTapForwardToSprint){
|
||||||
@@ -209,7 +209,7 @@ public final class PlayerTicker{
|
|||||||
public void afterSuperCall(final ClientPlayerEntity player){
|
public void afterSuperCall(final ClientPlayerEntity player){
|
||||||
if (FlightHelper.shouldFlyOnGround(player)){
|
if (FlightHelper.shouldFlyOnGround(player)){
|
||||||
final boolean isSneaking = player.isSneaking();
|
final boolean isSneaking = player.isSneaking();
|
||||||
final boolean isOnGround = player.onGround;
|
final boolean isOnGround = player.isOnGround();
|
||||||
|
|
||||||
if (!isSneaking){
|
if (!isSneaking){
|
||||||
wasSneakingBeforeTouchingGround = false;
|
wasSneakingBeforeTouchingGround = false;
|
||||||
@@ -236,7 +236,7 @@ public final class PlayerTicker{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cancelLanding){
|
if (cancelLanding){
|
||||||
player.onGround = false;
|
player.setOnGround(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ public final class PlayerTicker{
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
--temporaryFlyOnGroundTimer;
|
--temporaryFlyOnGroundTimer;
|
||||||
player.onGround = false;
|
player.setOnGround(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@ package chylex.bettercontrols.util;
|
|||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.client.util.InputMappings;
|
import net.minecraft.client.util.InputMappings;
|
||||||
import net.minecraft.client.util.InputMappings.Input;
|
import net.minecraft.client.util.InputMappings.Input;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
|
||||||
public final class Key{
|
public final class Key{
|
||||||
private Key(){}
|
private Key(){}
|
||||||
@@ -20,8 +21,8 @@ public final class Key{
|
|||||||
return binding.isPressed();
|
return binding.isPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getBoundKeyText(final KeyBinding binding){
|
public static ITextComponent getBoundKeyText(final KeyBinding binding){
|
||||||
return binding.getLocalizedName();
|
return binding.func_238171_j_();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void bind(final KeyBinding binding, final Input input){
|
public static void bind(final KeyBinding binding, final Input input){
|
||||||
|
@@ -18,13 +18,13 @@ The features complement vanilla mechanics without giving unfair advantages, so s
|
|||||||
[[dependencies.bettercontrols]]
|
[[dependencies.bettercontrols]]
|
||||||
modId = "minecraft"
|
modId = "minecraft"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "[1.15.2,1.16)"
|
versionRange = "[1.16.3,)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
|
||||||
[[dependencies.bettercontrols]]
|
[[dependencies.bettercontrols]]
|
||||||
modId = "forge"
|
modId = "forge"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "[31.2.44,)"
|
versionRange = "[31,)"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "BOTH"
|
side = "BOTH"
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
"AccessControlsListKeyBinding",
|
"AccessControlsListKeyBinding",
|
||||||
"AccessGameRendererFields",
|
"AccessGameRendererFields",
|
||||||
"AccessKeyBindingFields",
|
"AccessKeyBindingFields",
|
||||||
"AccessOptionButtonWidgetOption",
|
|
||||||
"AccessPlayerFields",
|
"AccessPlayerFields",
|
||||||
"AccessScreenButtons",
|
"AccessScreenButtons",
|
||||||
"AccessStickyKeyBindingStateGetter",
|
"AccessStickyKeyBindingStateGetter",
|
||||||
|
Reference in New Issue
Block a user