Skip to content

Commit 70b8145

Browse files
committed
Merge branch 'multiversion/dev' into port/26.1
2 parents 7f212ba + aec7bb1 commit 70b8145

132 files changed

Lines changed: 4573 additions & 3220 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ dependencies {
101101
// Already included by YetAnotherConfigLib, but we need it too, so let's define explicit dep
102102
api("org.quiltmc.parsers:json:${property("deps.quiltparsers")}")
103103

104+
if (stonecutter.current.parsed < "1.21.11") {
105+
compileOnly("org.jspecify:jspecify:1.0.0")
106+
}
107+
104108
// sodium compat
105109
modDependency("sodium", { "maven.modrinth:sodium:$it" })
106110
// RSO compat

changelog.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ This version has the following targets:
77

88
**By donating on my [Patreon](https://patreon.com/isxander), you will gain access to builds of Controlify for splitscreen support and snapshot versions**
99

10-
## Changes
10+
## Bug Fixes
1111

12-
- Fix various issues relating to focusing widgets in GUI screens
13-
- Sign "Done" button no longer gains initial focus preventing typing enter
14-
- JAR is now signed with a GPG key
12+
- Fix config migration not migrating bindings
13+
- Fix never saving bindings

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
org.gradle.jvmargs=-Xmx4G
22
org.gradle.parallel=true
33

4-
modVersion=2.5.1
4+
modVersion=3.0.0-beta.2
55
modId=controlify
66
modName=Controlify
77
modDescription=The most advanced controller mod for Minecraft.

src/main/java/dev/isxander/controlify/Controlify.java

Lines changed: 144 additions & 129 deletions
Large diffs are not rendered by default.

src/main/java/dev/isxander/controlify/api/event/ControlifyEvents.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public final class ControlifyEvents {
4242
*/
4343
public static final EventHandler<LookInputModifier> LOOK_INPUT_MODIFIER = EventHandler.createPlatformBackedEvent();
4444

45-
public record ControllerConnected(ControllerEntity controller, boolean hotplugged, boolean newController) {
45+
public record ControllerConnected(ControllerEntity controller, boolean hotplugged, @Deprecated boolean newController) {
4646
}
4747

4848
public record ControllerDisconnected(ControllerEntity controller) {

src/main/java/dev/isxander/controlify/api/guide/GuideVerbosity.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
package dev.isxander.controlify.api.guide;
22

3+
import com.mojang.serialization.Codec;
34
import dev.isxander.yacl3.api.NameableEnum;
45
import net.minecraft.network.chat.Component;
6+
import net.minecraft.util.StringRepresentable;
7+
import org.jspecify.annotations.NonNull;
58

6-
public enum GuideVerbosity implements NameableEnum {
9+
public enum GuideVerbosity implements NameableEnum, StringRepresentable {
710
FULL(3),
811
REDUCED(2),
912
MINIMAL(1);
13+
14+
public static final Codec<GuideVerbosity> CODEC = StringRepresentable.fromEnum(GuideVerbosity::values);
1015

1116
private final int level;
1217

@@ -22,4 +27,9 @@ public int getLevel() {
2227
public Component getDisplayName() {
2328
return Component.translatable("controlify.guide_verbosity." + name().toLowerCase());
2429
}
30+
31+
@Override
32+
public @NonNull String getSerializedName() {
33+
return name().toLowerCase();
34+
}
2535
}

src/main/java/dev/isxander/controlify/api/guide/InGameFacts.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ private InGameFacts() {}
103103
/** When the player is using toggle sneak (does not mean it is currently toggled on) */
104104
public static final Fact<InGameCtx> IS_TOGGLE_SNEAK = register(
105105
CUtil.rl("is_toggle_sneak"),
106-
ctx -> ctx.controller().genericConfig().config().toggleSneak
106+
ctx -> ctx.controller().settings().generic.toggleSneak
107107
);
108108
/** When the player is using toggle sprint (does not mean it is currently toggled on) */
109109
public static final Fact<InGameCtx> IS_TOGGLE_SPRINT = register(
110110
CUtil.rl("is_toggle_sprint"),
111-
ctx -> ctx.controller().genericConfig().config().toggleSprint
111+
ctx -> ctx.controller().settings().generic.toggleSprint
112112
);
113113
/** When the player is attempting to sprint (pressing the sprint key, or it is toggled on) */
114114
public static final Fact<InGameCtx> SPRINTING = register(

src/main/java/dev/isxander/controlify/bindings/ControlifyBindApiImpl.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,21 @@ private void checkLocked() {
7575
throw new IllegalStateException("Registry is locked. Cannot add bind now.");
7676
}
7777

78-
public List<InputBinding> provideBindsForController(ControllerEntity controller) {
78+
/**
79+
* Provides all bindings for a given controller.
80+
* @param controller The controller to provide bindings for. Can be null to get a list of all bindings.
81+
* @return A list of input bindings.
82+
*/
83+
public List<InputBinding> provideBindsForController(@Nullable ControllerEntity controller) {
7984
List<InputBinding> bindings = new ArrayList<>();
8085

8186
for (RegistryEntry entry : bindEntries) {
82-
if (!entry.filter().test(controller))
87+
if (controller != null && !entry.filter().test(controller))
8388
continue;
8489

8590
InputBindingImpl binding = entry.builder().apply(controller);
8691

87-
if (entry.emulation() != null) {
92+
if (controller != null && entry.emulation() != null) {
8893
BooleanSupplier emulationToggle = null;
8994
if (entry.emulationToggle() != null) {
9095
emulationToggle = () -> entry.emulationToggle().apply(controller);
@@ -118,7 +123,7 @@ public Stream<Identifier> getAllBindIds() {
118123

119124
private record RegistryEntry(
120125
Predicate<ControllerEntity> filter,
121-
Function<ControllerEntity, InputBindingImpl> builder,
126+
Function<@Nullable ControllerEntity, InputBindingImpl> builder,
122127
KeyMapping emulation,
123128
Function<ControllerEntity, Boolean> emulationToggle,
124129
Identifier id

src/main/java/dev/isxander/controlify/bindings/ControlifyBindings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public final class ControlifyBindings {
8080
.id("controlify", "sprint")
8181
.category(MOVEMENT_CATEGORY)
8282
.allowedContexts(BindContext.IN_GAME)
83-
.keyEmulation(options.keySprint, c -> c.genericConfig().config().toggleSprint));
83+
.keyEmulation(options.keySprint, c -> c.settings().generic.toggleSprint));
8484
public static final InputBindingSupplier SNEAK = ControlifyBindApi.get().registerBinding(builder -> builder
8585
.id("controlify", "sneak")
8686
.category(MOVEMENT_CATEGORY)

src/main/java/dev/isxander/controlify/bindings/InputBindingBuilderImpl.java

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import dev.isxander.controlify.bindings.input.EmptyInput;
77
import dev.isxander.controlify.bindings.input.Input;
88
import dev.isxander.controlify.controller.ControllerEntity;
9+
import dev.isxander.controlify.controller.id.ControllerType;
910
import dev.isxander.controlify.utils.CUtil;
1011
import net.minecraft.client.KeyMapping;
1112
import net.minecraft.locale.Language;
@@ -118,20 +119,24 @@ public InputBindingBuilder keyEmulation(@NotNull KeyMapping keyMapping) {
118119
return keyEmulation(keyMapping, null);
119120
}
120121

121-
public InputBindingImpl build(ControllerEntity controller) {
122+
public InputBindingImpl build(@Nullable ControllerEntity controller) {
122123
Validate.isTrue(locked, "Tried to build builder before it was locked.");
123124

124-
Component name = createDefaultString(controller, null, false);
125+
Identifier controllerType = controller != null
126+
? controller.info().type().namespace()
127+
: ControllerType.DEFAULT.namespace();
128+
129+
Component name = createDefaultString(controllerType, null, false);
125130
if (customName != null) name = customName;
126131

127-
Component description = createDefaultString(controller, "desc", true);
132+
Component description = createDefaultString(controllerType, "desc", true);
128133
if (customDescription != null) description = customDescription;
129134
if (description == null) description = Component.empty();
130135

131136
Supplier<Input> defaultSupplier = () -> {
132137
// retrieve every tick so the bind provider isn't cached after a resource reload
133138
DefaultBindProvider provider = Controlify.instance().defaultBindManager().getDefaultBindProvider(
134-
controller.info().type().namespace()
139+
controllerType
135140
);
136141

137142
Input input = provider.getDefaultBind(id);
@@ -141,7 +146,17 @@ public InputBindingImpl build(ControllerEntity controller) {
141146
return input;
142147
};
143148

144-
return new InputBindingImpl(controller, id, name, description, category, defaultSupplier, allowedContexts, radialCandidate);
149+
return new InputBindingImpl(
150+
controller != null ? controller.input().orElse(null) : null,
151+
controllerType,
152+
id,
153+
name,
154+
description,
155+
category,
156+
defaultSupplier,
157+
allowedContexts,
158+
radialCandidate
159+
);
145160
}
146161

147162
@NotNull
@@ -171,12 +186,10 @@ private void checkLocked() {
171186
Validate.isTrue(!locked, "Tried to modify binding builder after is has been locked!");
172187
}
173188

174-
private Component createDefaultString(ControllerEntity controller, @Nullable String suffix, boolean notExistToNull) {
189+
private Component createDefaultString(Identifier controllerType, @Nullable String suffix, boolean notExistToNull) {
175190
Objects.requireNonNull(id);
176191

177-
Identifier type = controller.info().type().namespace();
178-
179-
String typeSpecificKey = type.toLanguageKey("controlify.binding", id.toLanguageKey());
192+
String typeSpecificKey = controllerType.toLanguageKey("controlify.binding", id.toLanguageKey());
180193
if (suffix != null) typeSpecificKey += "." + suffix;
181194
if (Language.getInstance().has(typeSpecificKey)) {
182195
return Component.translatable(typeSpecificKey);

0 commit comments

Comments
 (0)