cancel the click sound on the button

This commit is contained in:
Jill 2022-11-03 12:58:06 +03:00
parent 867046ea12
commit c7cce9a4b8
4 changed files with 28 additions and 1 deletions

View File

@ -11,6 +11,8 @@ import net.minecraft.client.world.ClientWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import org.lwjgl.glfw.GLFW;
@ -25,6 +27,9 @@ import java.util.Random;
public class Mod implements ClientModInitializer {
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(
"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.

View File

@ -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();
}
}

View File

@ -24,7 +24,7 @@ public class SecretSettingsButtonMixin extends Screen {
this.height / 6 + 18,
150,
20,
new TranslatableText("options.supersecretrevival.super_secret_settings"),
Mod.BUTTON_TEXT,
(button) -> {
Mod.triggerSuperSecretSettings();
}

View File

@ -5,6 +5,7 @@
"compatibilityLevel": "JAVA_17",
"mixins": [],
"client": [
"CancelClickSoundMixin",
"SecretSettingsButtonMixin"
],
"server": [],