Skip to content

Commit 7936dae

Browse files
committed
fix
1 parent 4f0f571 commit 7936dae

2 files changed

Lines changed: 19 additions & 29 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mod_name=Channel
3030
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
3131
mod_license=GNU GPL 3.0
3232
# The mod version. See https://semver.org/
33-
mod_version=26.1.2-22+beta
33+
mod_version=26.1.2-23+beta
3434
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
3535
# This should match the base package used for the mod sources.
3636
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

src/main/java/cn/ussshenzhou/channel/input/ModKeyMappingRegistry.java

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
import com.mojang.blaze3d.platform.InputConstants;
88
import net.minecraft.client.KeyMapping;
99
import net.minecraft.client.Minecraft;
10-
import net.minecraft.client.gui.components.AbstractTextAreaWidget;
11-
import net.minecraft.client.gui.components.EditBox;
12-
import net.minecraft.client.gui.components.MultilineTextField;
1310
import net.minecraft.resources.Identifier;
1411
import net.minecraft.util.Util;
1512
import net.neoforged.api.distmarker.Dist;
1613
import net.neoforged.bus.api.SubscribeEvent;
1714
import net.neoforged.fml.common.EventBusSubscriber;
15+
import net.neoforged.neoforge.client.event.ClientTickEvent;
1816
import net.neoforged.neoforge.client.event.InputEvent;
1917
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
2018
import net.neoforged.neoforge.client.settings.KeyConflictContext;
@@ -52,39 +50,31 @@ public static void onKeyInput(InputEvent.Key event) {
5250
}
5351

5452
@SubscribeEvent
55-
public static void mute(InputEvent.Key event) {
53+
public static void switchMute(InputEvent.Key event) {
5654
var screen = Minecraft.getInstance().screen;
5755
if (screen != null) {
5856
return;
5957
}
60-
var cfg = ChannelClientConfig.get();
61-
if (event.getKey() == PTT.getKey().getValue() && modifierMatch(event.getModifiers(), PTT.getKeyModifier().codes())) {
62-
if (event.getAction() == InputConstants.PRESS || event.getAction() == InputConstants.REPEAT) {
63-
switch (cfg.trigger) {
64-
case PUSH_TO_TALK -> ChannelClientConfig.write(c -> c.onAir = true);
65-
case SWITCH -> {
66-
if (Util.getMillis() - lastSwitch >= 100) {
67-
ChannelClientConfig.write(c -> c.onAir = !c.onAir);
68-
lastSwitch = Util.getMillis();
69-
}
70-
}
71-
default -> {
72-
}
73-
}
74-
} else {
75-
if (cfg.trigger == Trigger.PUSH_TO_TALK) {
76-
ChannelClientConfig.write(c -> c.onAir = false);
77-
}
58+
if (ChannelClientConfig.get().trigger != Trigger.SWITCH) {
59+
return;
60+
}
61+
if (PTT.consumeClick()) {
62+
if (Util.getMillis() - lastSwitch >= 100) {
63+
ChannelClientConfig.write(c -> c.onAir = !c.onAir);
64+
lastSwitch = Util.getMillis();
7865
}
7966
}
8067
}
8168

82-
public static boolean modifierMatch(int combined, InputConstants.Key[] modifiers) {
83-
for (var m : modifiers) {
84-
if (combined == m.getValue()) {
85-
return true;
86-
}
69+
@SubscribeEvent
70+
public static void pushMute(ClientTickEvent.Pre event) {
71+
var cfg = ChannelClientConfig.get();
72+
if (cfg.trigger != Trigger.PUSH_TO_TALK) {
73+
return;
74+
}
75+
boolean toWrite = PTT.isDown();
76+
if (toWrite != cfg.onAir) {
77+
ChannelClientConfig.write(c -> c.onAir = toWrite);
8778
}
88-
return combined == 0;
8979
}
9080
}

0 commit comments

Comments
 (0)