diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/Ext.kt index b438fb865..4103e8d04 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/Ext.kt @@ -2,6 +2,12 @@ package ru.dbotthepony.mc.otm.client import net.minecraft.client.Minecraft import net.minecraft.client.gui.Font +import net.minecraft.client.resources.sounds.SimpleSoundInstance +import net.minecraft.sounds.SoundEvents inline val minecraft: Minecraft get() = Minecraft.getInstance() inline val font: Font get() = minecraft.font + +fun playGuiClickSound() { + minecraft.soundManager.play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0f)) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt index a82248570..b4712fdea 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt @@ -7,16 +7,14 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.Int2ObjectFunction import net.minecraft.ChatFormatting import net.minecraft.client.Minecraft -import net.minecraft.client.resources.sounds.SimpleSoundInstance import net.minecraft.network.chat.Component -import net.minecraft.sounds.SoundEvents import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.android.AndroidResearch import ru.dbotthepony.mc.otm.android.AndroidResearchType import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.drawColor import ru.dbotthepony.mc.otm.client.render.drawLine @@ -383,7 +381,7 @@ private class AndroidResearchButton( MatteryPlayerNetworkChannel.sendToServer(AndroidResearchRequestPacket(node.type)) } - minecraft.soundManager.play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0f)) + playGuiClickSound() } return true @@ -479,6 +477,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { if (isPreview) { + playGuiClickSound() openResearchTree() return true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ButtonPanel.kt index 894f97933..7a48b5ec2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ButtonPanel.kt @@ -5,11 +5,9 @@ import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting import net.minecraft.client.gui.components.Button import net.minecraft.client.gui.components.Button.OnPress -import net.minecraft.client.resources.sounds.SimpleSoundInstance import net.minecraft.network.chat.Component -import net.minecraft.sounds.SoundEvents +import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.core.TextComponent -import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.next @@ -121,7 +119,7 @@ abstract class SquareButtonPanel( override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { if (!isDisabled) { if (!pressed) { - minecraft.soundManager.play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0f)) + playGuiClickSound() } pressed = true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/CheckBox.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/CheckBox.kt index d9c736923..593424157 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/CheckBox.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/CheckBox.kt @@ -1,10 +1,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.client.resources.sounds.SimpleSoundInstance import net.minecraft.network.chat.Component -import net.minecraft.sounds.SoundEvents -import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.SkinElement import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.MatteryScreen @@ -33,7 +31,7 @@ open class CheckBoxPanel( override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { checked = !checked - minecraft.soundManager.play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0f)) + playGuiClickSound() return true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 245a40790..5b3532ac4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -2,14 +2,12 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.client.Minecraft import net.minecraft.client.gui.narration.NarratableEntry import net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority import net.minecraft.client.gui.narration.NarrationElementOutput -import net.minecraft.client.resources.sounds.SimpleSoundInstance import net.minecraft.network.chat.Component -import net.minecraft.sounds.SoundEvents import org.lwjgl.opengl.GL30 +import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.MatteryScreen @@ -159,7 +157,7 @@ open class FramePanel( isActive = true onOpen() - Minecraft.getInstance().soundManager.play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0f)) + playGuiClickSound() return true }