Skip to content

Commit 4b9bebe

Browse files
committed
Replace ear-piercing beep sound with a separate on off beep (Soaryn) sound
1 parent 8f0adf1 commit 4b9bebe

File tree

22 files changed

+54
-40
lines changed

22 files changed

+54
-40
lines changed

src/datagen/generated/mekanism/.cache/70ecf5bbefc27eadffc9d4d9ba3cdf3f3bb4064c

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datagen/generated/mekanism/assets/mekanism/sounds.json

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datagen/main/java/mekanism/client/sound/MekanismSoundProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ private void addHolidaySoundEvents() {
8080

8181
private void addGuiSoundEvents() {
8282
String basePath = "gui/";
83-
//Manually call this to skip applying a subtitle
84-
addSoundEvent(MekanismSounds.BEEP, basePath + "beep", UnaryOperator.identity(), sound -> sound.pitch(0.8F));
83+
//Manually call this to skip applying subtitles
84+
addSoundEvent(MekanismSounds.BEEP_ON, basePath + "beep_on", UnaryOperator.identity(), sound -> sound.pitch(0.8F));
85+
addSoundEvent(MekanismSounds.BEEP_OFF, basePath + "beep_off", UnaryOperator.identity(), sound -> sound.pitch(0.8F));
8586
}
8687
}

src/main/java/mekanism/client/gui/GuiModuleTweaker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected void addGuiElements() {
8686
select(index);
8787
}
8888
addRenderableWidget(new GuiSlot(SlotType.NORMAL, this, slot.x - 1, slot.y - 1)
89-
.click((e, x, y) -> select(index), MekanismSounds.BEEP)
89+
.click((e, x, y) -> select(index), 1.0F, MekanismSounds.BEEP_ON)
9090
.overlayColor(isValidItem(index) ? null : () -> 0xCC333333)
9191
.with(() -> index == selected ? SlotOverlay.SELECT : null));
9292
}

src/main/java/mekanism/client/gui/element/GuiDigitalIconToggle.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public GuiDigitalIconToggle(IGuiWrapper gui, int x, int y, int width, int height
2121
this.typeSupplier = typeSupplier;
2222
this.typeSetter = typeSetter;
2323
this.options = enumClass.getEnumConstants();
24-
this.clickSound = MekanismSounds.BEEP;
24+
this.clickSound = MekanismSounds.BEEP_ON;
25+
this.clickVolume = 1.0F;
2526
tooltip(() -> Collections.singletonList(this.typeSupplier.get().getTooltip()));
2627
}
2728

src/main/java/mekanism/client/gui/element/GuiDigitalSwitch.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public GuiDigitalSwitch(IGuiWrapper gui, int x, int y, ResourceLocation icon, Bo
2626
this.icon = icon;
2727
this.stateSupplier = stateSupplier;
2828
this.onToggle = onToggle;
29-
this.clickSound = MekanismSounds.BEEP;
29+
this.clickSound = () -> this.stateSupplier.getAsBoolean() ? MekanismSounds.BEEP_OFF.get() : MekanismSounds.BEEP_ON.get();
30+
this.clickVolume = 1.0F;
3031
}
3132

3233
@Override

src/main/java/mekanism/client/gui/element/GuiDropdown.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public GuiDropdown(IGuiWrapper gui, int x, int y, int width, Class<TYPE> enumCla
3535
this.options = enumClass.getEnumConstants();
3636
this.typeTooltips = new EnumMap<>(enumClass);
3737
this.active = true;
38-
this.clickSound = MekanismSounds.BEEP;
38+
this.clickSound = MekanismSounds.BEEP_ON;
39+
this.clickVolume = 1.0F;
3940
}
4041

4142
@Override

src/main/java/mekanism/client/gui/element/GuiDumpButton.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import mekanism.common.util.MekanismUtils;
99
import mekanism.common.util.MekanismUtils.ResourceType;
1010
import net.minecraft.client.gui.GuiGraphics;
11-
import net.minecraft.sounds.SoundEvents;
1211
import net.minecraft.world.level.block.entity.BlockEntity;
1312
import org.jetbrains.annotations.NotNull;
1413

@@ -20,7 +19,7 @@ public class GuiDumpButton<TILE extends BlockEntity & IHasDumpButton> extends Gu
2019
public GuiDumpButton(IGuiWrapper gui, TILE tile, int x, int y) {
2120
super(MekanismUtils.getResource(ResourceType.GUI, "dump.png"), gui, x, y, 21, 10);
2221
this.tile = tile;
23-
this.clickSound = SoundEvents.UI_BUTTON_CLICK;
22+
this.clickSound = BUTTON_CLICK_SOUND;
2423
}
2524

2625
@Override

src/main/java/mekanism/client/gui/element/GuiElement.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.Optional;
88
import java.util.function.Consumer;
99
import java.util.function.Predicate;
10+
import java.util.function.Supplier;
1011
import mekanism.api.text.ILangEntry;
1112
import mekanism.client.gui.GuiMekanism;
1213
import mekanism.client.gui.GuiUtils;
@@ -35,10 +36,10 @@
3536
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
3637
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
3738
import net.minecraft.client.sounds.SoundManager;
38-
import net.minecraft.core.Holder;
3939
import net.minecraft.network.chat.Component;
4040
import net.minecraft.resources.ResourceLocation;
4141
import net.minecraft.sounds.SoundEvent;
42+
import net.minecraft.sounds.SoundEvents;
4243
import net.minecraft.util.Mth;
4344
import org.jetbrains.annotations.NotNull;
4445
import org.jetbrains.annotations.Nullable;
@@ -49,6 +50,7 @@ public abstract class GuiElement extends AbstractWidget implements IFancyFontRen
4950
private static final int BUTTON_TEX_X = 200, BUTTON_TEX_Y = 60, BUTTON_INDIVIDUAL_TEX_Y = BUTTON_TEX_Y / 3;
5051
public static final ResourceLocation WARNING_BACKGROUND_TEXTURE = MekanismUtils.getResource(ResourceType.GUI, "warning_background.png");
5152
public static final ResourceLocation WARNING_TEXTURE = MekanismUtils.getResource(ResourceType.GUI, "warning.png");
53+
protected static Supplier<SoundEvent> BUTTON_CLICK_SOUND = SoundEvents.UI_BUTTON_CLICK::value;
5254

5355
public static final Minecraft minecraft = Minecraft.getInstance();
5456

@@ -63,7 +65,9 @@ public abstract class GuiElement extends AbstractWidget implements IFancyFontRen
6365

6466
private IGuiWrapper guiObj;
6567
@Nullable
66-
protected Holder<SoundEvent> clickSound;
68+
protected Supplier<SoundEvent> clickSound;
69+
//Default to the value from SimpleSoundInstance.forUI
70+
protected float clickVolume = 0.25F;
6771
protected int relativeX;
6872
protected int relativeY;
6973
public boolean isOverlay;
@@ -653,16 +657,18 @@ protected void renderBackgroundTexture(GuiGraphics guiGraphics, ResourceLocation
653657
@Override
654658
public void playDownSound(@NotNull SoundManager soundHandler) {
655659
if (clickSound != null) {
656-
playClickSound(soundHandler, clickSound);
660+
playClickSound(soundHandler, clickSound, clickVolume);
657661
}
658662
}
659663

660-
protected static void playClickSound(Holder<SoundEvent> sound) {
661-
playClickSound(minecraft.getSoundManager(), sound);
664+
protected static void playClickSound(Supplier<SoundEvent> sound) {
665+
//Default to the value from SimpleSoundInstance.forUI
666+
playClickSound(minecraft.getSoundManager(), sound, 0.25F);
662667
}
663668

664-
private static void playClickSound(@NotNull SoundManager soundHandler, @NotNull Holder<SoundEvent> sound) {
665-
soundHandler.play(SimpleSoundInstance.forUI(sound, 1.0F));
669+
private static void playClickSound(@NotNull SoundManager soundHandler, @NotNull Supplier<SoundEvent> sound, float clickVolume) {
670+
671+
soundHandler.play(SimpleSoundInstance.forUI(sound.get(), 1.0F, clickVolume));
666672
}
667673

668674
protected void drawTiledSprite(GuiGraphics guiGraphics, int xPosition, int yPosition, int yOffset, int desiredWidth, int desiredHeight, TextureAtlasSprite sprite,

src/main/java/mekanism/client/gui/element/GuiInsetElement.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import mekanism.client.gui.IGuiWrapper;
44
import net.minecraft.client.gui.GuiGraphics;
55
import net.minecraft.resources.ResourceLocation;
6-
import net.minecraft.sounds.SoundEvents;
76
import org.jetbrains.annotations.NotNull;
87

98
public abstract class GuiInsetElement<DATA_SOURCE> extends GuiSideHolder {
@@ -22,7 +21,7 @@ public GuiInsetElement(ResourceLocation overlay, IGuiWrapper gui, DATA_SOURCE da
2221
this.innerHeight = innerSize;
2322
//TODO: decide what to do if this doesn't divide nicely
2423
this.border = (width - innerWidth) / 2;
25-
this.clickSound = SoundEvents.UI_BUTTON_CLICK;
24+
this.clickSound = BUTTON_CLICK_SOUND;
2625
active = true;
2726
}
2827

0 commit comments

Comments
 (0)