Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import dev.isxander.controlify.neoforge.platform.VanillaKeyMappingHolder;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Options;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
Expand All @@ -24,7 +25,19 @@ public class OptionsMixin implements VanillaKeyMappingHolder {

@Unique private KeyMapping[] controlify$vanillaKeyMappings;

@Inject(method = "<init>", at = @At("RETURN"))
// Capture the vanilla key mappings as soon as the vanilla array is assigned.
// NeoForge appends modded key mappings to this field inside the constructor,
// so capturing at RETURN would make the "vanilla" snapshot include modded keys
// and the modded-key diff in NeoforgePlatformClientImpl would always be empty.
@Inject(
method = "<init>",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/client/Options;keyMappings:[Lnet/minecraft/client/KeyMapping;",
opcode = Opcodes.PUTFIELD,
shift = At.Shift.AFTER
)
)
private void storeVanillaKeybindsBeforeModification(CallbackInfo ci) {
this.controlify$vanillaKeyMappings = Arrays.copyOf(keyMappings, keyMappings.length);
}
Expand Down
Loading