cancel the click sound on the button
This commit is contained in:
parent
867046ea12
commit
c7cce9a4b8
|
@ -11,6 +11,8 @@ import net.minecraft.client.world.ClientWorld;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
@ -25,6 +27,9 @@ import java.util.Random;
|
||||||
public class Mod implements ClientModInitializer {
|
public class Mod implements ClientModInitializer {
|
||||||
public static final Logger LOGGER = LoggerFactory.getLogger("super-secret-revival");
|
public static final Logger LOGGER = LoggerFactory.getLogger("super-secret-revival");
|
||||||
|
|
||||||
|
// also used for identifying the button (Don't Worry about it)
|
||||||
|
public static final Text BUTTON_TEXT = new TranslatableText("options.supersecretrevival.super_secret_settings");
|
||||||
|
|
||||||
private static KeyBinding disableShaderKeybind = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
private static KeyBinding disableShaderKeybind = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
||||||
"key.supersecretrevival.disable", // The translation key of the keybinding's name
|
"key.supersecretrevival.disable", // The translation key of the keybinding's name
|
||||||
InputUtil.Type.KEYSYM, // The type of the keybinding, KEYSYM for keyboard, MOUSE for mouse.
|
InputUtil.Type.KEYSYM, // The type of the keybinding, KEYSYM for keyboard, MOUSE for mouse.
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package zone.oat.supersecretrevival.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||||
|
import net.minecraft.client.sound.SoundManager;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import zone.oat.supersecretrevival.Mod;
|
||||||
|
|
||||||
|
@Mixin(ClickableWidget.class)
|
||||||
|
public class CancelClickSoundMixin {
|
||||||
|
@Shadow private Text message;
|
||||||
|
|
||||||
|
@Inject(method = "playDownSound", at = @At(value = "HEAD"), cancellable = true)
|
||||||
|
private void injected(SoundManager soundManager, CallbackInfo ci) {
|
||||||
|
if (this.message.equals(Mod.BUTTON_TEXT)) ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,7 +24,7 @@ public class SecretSettingsButtonMixin extends Screen {
|
||||||
this.height / 6 + 18,
|
this.height / 6 + 18,
|
||||||
150,
|
150,
|
||||||
20,
|
20,
|
||||||
new TranslatableText("options.supersecretrevival.super_secret_settings"),
|
Mod.BUTTON_TEXT,
|
||||||
(button) -> {
|
(button) -> {
|
||||||
Mod.triggerSuperSecretSettings();
|
Mod.triggerSuperSecretSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"mixins": [],
|
"mixins": [],
|
||||||
"client": [
|
"client": [
|
||||||
|
"CancelClickSoundMixin",
|
||||||
"SecretSettingsButtonMixin"
|
"SecretSettingsButtonMixin"
|
||||||
],
|
],
|
||||||
"server": [],
|
"server": [],
|
||||||
|
|
Loading…
Reference in New Issue