mirror of
https://github.com/chylex/Better-Controls.git
synced 2025-04-23 03:15:47 +02:00
Release v1.2.3 for Minecraft 1.19+
This commit is contained in:
parent
7c2279b1d8
commit
2126402d28
@ -4,7 +4,7 @@ val fabricVersion: String by project
|
||||
|
||||
plugins {
|
||||
idea
|
||||
id("fabric-loom") version "0.10-SNAPSHOT"
|
||||
id("fabric-loom")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -9,10 +9,11 @@ modSourcesURL=https://github.com/chylex/Better-Controls
|
||||
modIssuesURL=https://github.com/chylex/Better-Controls/issues
|
||||
|
||||
# Dependencies
|
||||
minecraftVersion=1.18
|
||||
forgeVersion=38.0.8
|
||||
fabricVersion=0.12.8
|
||||
mixinVersion=0.8.4
|
||||
minecraftVersion=1.19
|
||||
forgeVersion=41.0.1
|
||||
fabricVersion=0.14.6
|
||||
loomVersion=0.12
|
||||
mixinVersion=0.8.5
|
||||
|
||||
# Gradle
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
|
@ -6,6 +6,12 @@ pluginManagement {
|
||||
maven(url = "https://maven.fabricmc.net/") { name = "Fabric" }
|
||||
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")) {
|
||||
|
@ -20,7 +20,6 @@ import net.minecraft.client.gui.screens.OptionsSubScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.CommonComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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.col4;
|
||||
import static chylex.bettercontrols.gui.elements.TextWidget.CENTER;
|
||||
import static net.minecraft.network.chat.Component.literal;
|
||||
|
||||
public class BetterControlsScreen extends OptionsSubScreen {
|
||||
private static TextComponent text(final String text) {
|
||||
return new TextComponent(text);
|
||||
private static Component text(final String text) {
|
||||
return literal(text);
|
||||
}
|
||||
|
||||
public static final Component TITLE = text("Better Controls");
|
||||
@ -85,7 +85,6 @@ public class BetterControlsScreen extends OptionsSubScreen {
|
||||
return y;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "AutoBoxing", "AutoUnboxing" })
|
||||
private int generateFlightOptions(int y, final List<GuiEventListener> elements) {
|
||||
final BetterControlsConfig cfg = BetterControlsCommon.getConfig();
|
||||
|
||||
|
@ -2,7 +2,6 @@ package chylex.bettercontrols.gui.elements;
|
||||
import net.minecraft.client.gui.components.AbstractSliderButton;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.util.Mth;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.List;
|
||||
@ -47,6 +46,6 @@ public final class DiscreteValueSliderWidget<T> extends AbstractSliderButton {
|
||||
|
||||
@Override
|
||||
protected @NotNull 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.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -24,7 +22,7 @@ public final class KeyBindingWidget extends Button {
|
||||
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) {
|
||||
super(x, y, width, height, TextComponent.EMPTY, btn -> {});
|
||||
super(x, y, width, height, Component.empty(), btn -> {});
|
||||
this.binding = binding;
|
||||
this.bindingName = bindingName;
|
||||
this.onEditingStarted = onEditingStarted;
|
||||
@ -42,7 +40,7 @@ public final class KeyBindingWidget extends Button {
|
||||
|
||||
@Override
|
||||
protected @NotNull 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
|
||||
@ -79,13 +77,13 @@ public final class KeyBindingWidget extends Button {
|
||||
}
|
||||
|
||||
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) {
|
||||
setMessage(binding.getTranslatedKeyMessage().copy().withStyle(ChatFormatting.RED));
|
||||
}
|
||||
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)
|
||||
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) {
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
final Input input = (Input)(Object)this;
|
||||
|
@ -4,6 +4,7 @@ import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.world.entity.player.ProfilePublicKey;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -12,8 +13,8 @@ import static org.spongepowered.asm.mixin.injection.At.Shift.AFTER;
|
||||
|
||||
@Mixin(LocalPlayer.class)
|
||||
public abstract class HookClientPlayerTick extends AbstractClientPlayer {
|
||||
protected HookClientPlayerTick(final ClientLevel world, final GameProfile profile) {
|
||||
super(world, profile);
|
||||
protected HookClientPlayerTick(final ClientLevel world, final GameProfile profile, final ProfilePublicKey profilePublicKey) {
|
||||
super(world, profile, profilePublicKey);
|
||||
}
|
||||
|
||||
@Inject(method = "aiStep()V", at = @At("HEAD"))
|
||||
@ -23,7 +24,7 @@ public abstract class HookClientPlayerTick extends AbstractClientPlayer {
|
||||
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) {
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
final LocalPlayer player = (LocalPlayer)(Object)this;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package chylex.bettercontrols.mixin;
|
||||
|
||||
import net.minecraft.client.CycleOption;
|
||||
import net.minecraft.client.Option;
|
||||
import net.minecraft.client.OptionInstance;
|
||||
import net.minecraft.client.Options;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
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.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(CycleOption.class)
|
||||
@Mixin(OptionInstance.class)
|
||||
public abstract class HookToggleOptionButtons {
|
||||
@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) {
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ public final class PlayerTicker {
|
||||
|
||||
// Logic
|
||||
|
||||
private final ToggleTracker toggleSprint = new ToggleTrackerForStickyKey(cfg().keyToggleSprint, KEY_SPRINT, toggled -> OPTIONS.toggleSprint = toggled);
|
||||
private final ToggleTracker toggleSneak = new ToggleTrackerForStickyKey(cfg().keyToggleSneak, KEY_SNEAK, toggled -> OPTIONS.toggleCrouch = toggled);
|
||||
private final ToggleTracker toggleSprint = new ToggleTrackerForStickyKey(cfg().keyToggleSprint, KEY_SPRINT, OPTIONS.toggleSprint()::set);
|
||||
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 toggleJump = new ToggleTracker(cfg().keyToggleJump, KEY_JUMP);
|
||||
|
||||
@ -91,7 +91,7 @@ public final class PlayerTicker {
|
||||
}
|
||||
|
||||
final SprintMode sprintMode = cfg().sprintMode;
|
||||
final boolean wasSprintToggled = OPTIONS.toggleSprint;
|
||||
final boolean wasSprintToggled = Boolean.TRUE.equals(OPTIONS.toggleSprint().get());
|
||||
final boolean isSprintToggled = toggleSprint.tick();
|
||||
|
||||
if (temporarySprintTimer > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user