Skip to content

Commit aee48a1

Browse files
committed
Configurable sound volume
1 parent 4480036 commit aee48a1

File tree

12 files changed

+127
-49
lines changed

12 files changed

+127
-49
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ buildscript {
1818
apply plugin: 'net.minecraftforge.gradle.forge'
1919
apply plugin: 'org.spongepowered.mixin'
2020

21-
version = "1.12.2-1.0.0"
21+
version = "1.12.2-1.0.1"
2222
group = "mod.acgaming.extrasounds"
2323
archivesBaseName = "ExtraSounds"
2424

src/main/java/mod/acgaming/extrasounds/ExtraSounds.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class ExtraSounds
1010
{
1111
public static final String MODID = "extrasounds";
1212
public static final String NAME = "Extra Sounds";
13-
public static final String VERSION = "1.12.2-1.0.0";
13+
public static final String VERSION = "1.12.2-1.0.1";
1414
public static final Logger LOGGER = LogManager.getLogger("ES");
1515

1616
@Mod.EventHandler

src/main/java/mod/acgaming/extrasounds/SoundManager.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import net.minecraft.util.SoundEvent;
1111
import net.minecraftforge.oredict.OreDictionary;
1212

13+
import mod.acgaming.extrasounds.config.ESConfig;
14+
1315
public class SoundManager
1416
{
1517
public static Random random = new Random();
@@ -38,49 +40,49 @@ public static void playClickSound(ItemStack stackIn)
3840
{
3941
if (checkOreDictContains(i, "wood"))
4042
{
41-
playSound(SoundEvents.BLOCK_WOOD_HIT, 2.0F, 0.2F);
43+
playSound(SoundEvents.BLOCK_WOOD_HIT, 2.0F, (float) ESConfig.soundVolume.esPickPlaceWoodSound);
4244
}
4345
else if (checkOreDict(i, "dirt") || checkOreDict(i, "gravel"))
4446
{
45-
playSound(SoundEvents.BLOCK_GRAVEL_HIT, 2.0F, 0.2F);
47+
playSound(SoundEvents.BLOCK_GRAVEL_HIT, 2.0F, (float) ESConfig.soundVolume.esPickPlaceGravelSound);
4648
}
4749
else if (checkOreDict(i, "sand"))
4850
{
49-
playSound(SoundEvents.BLOCK_SAND_HIT, 2.0F, 0.4F);
51+
playSound(SoundEvents.BLOCK_SAND_HIT, 2.0F, (float) ESConfig.soundVolume.esPickPlaceSandSound);
5052
}
5153
else if (checkOreDict(i, "grass"))
5254
{
53-
playSound(SoundEvents.BLOCK_GRASS_HIT, 2.0F, 0.6F);
55+
playSound(SoundEvents.BLOCK_GRASS_HIT, 2.0F, (float) ESConfig.soundVolume.esPickPlaceGrassSound);
5456
}
5557
else if (checkOreDict(i, "wool"))
5658
{
57-
playSound(SoundEvents.BLOCK_CLOTH_HIT, 2.0F, 0.4F);
59+
playSound(SoundEvents.BLOCK_CLOTH_HIT, 2.0F, (float) ESConfig.soundVolume.esPickPlaceWoolSound);
5860
}
5961
else if (checkOreDictPrefix(i, "ingot") || checkOreDictPrefix(i, "nugget"))
6062
{
61-
playSound(SoundEvents.BLOCK_ANVIL_PLACE, 2.0F, 0.1F);
63+
playSound(SoundEvents.BLOCK_ANVIL_PLACE, 2.0F, (float) ESConfig.soundVolume.esPickPlaceMetalSound);
6264
}
6365
else if (checkOreDictPrefix(i, "gem"))
6466
{
65-
playSound(SoundEvents.BLOCK_NOTE_CHIME, 2.0F, 0.2F);
67+
playSound(SoundEvents.BLOCK_NOTE_CHIME, 2.0F, (float) ESConfig.soundVolume.esPickPlaceGemSound);
6668
}
6769
else if (checkOreDictPrefix(i, "dust"))
6870
{
69-
playSound(SoundEvents.BLOCK_SAND_BREAK, 2.0F, 0.6F);
71+
playSound(SoundEvents.BLOCK_SAND_BREAK, 2.0F, (float) ESConfig.soundVolume.esPickPlaceDustSound);
7072
}
7173
else
7274
{
73-
playSound(SoundEvents.BLOCK_STONE_HIT, 2.0F, 0.4F);
75+
playSound(SoundEvents.BLOCK_STONE_HIT, 2.0F, (float) ESConfig.soundVolume.esPickPlaceDefaultSound);
7476
}
7577
}
7678
}
7779
else if (stackIn.getItem() instanceof ItemFood)
7880
{
79-
playSound(SoundEvents.BLOCK_SLIME_STEP, 2.0F, 0.2F);
81+
playSound(SoundEvents.BLOCK_SLIME_STEP, 2.0F, (float) ESConfig.soundVolume.esPickPlaceFoodSound);
8082
}
8183
else
8284
{
83-
playSound(SoundEvents.BLOCK_STONE_HIT, 2.0F, 0.4F);
85+
playSound(SoundEvents.BLOCK_STONE_HIT, 2.0F, (float) ESConfig.soundVolume.esPickPlaceDefaultSound);
8486
}
8587
}
8688

src/main/java/mod/acgaming/extrasounds/config/ESConfig.java

Lines changed: 97 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,109 @@
1111
@Config(modid = ExtraSounds.MODID, name = "ExtraSounds")
1212
public class ESConfig
1313
{
14-
@Config.Name("Item Drop Sound")
15-
@Config.Comment("Play a sound when dropping items")
16-
public static boolean esDropItemSound = true;
14+
@Config.Name("Toggles")
15+
public static SoundToggles soundToggles = new SoundToggles();
1716

18-
@Config.Name("Item Pick/Place Sound")
19-
@Config.Comment("Play a sound when picking and placing items in GUIs")
20-
public static boolean esSlotClickSound = true;
17+
@Config.Name("Volume")
18+
public static SoundVolume soundVolume = new SoundVolume();
2119

22-
@Config.Name("Open/Close GUI Sound")
23-
@Config.Comment("Play a sound when opening and closing GUIs")
24-
public static boolean esOpenCloseGUISound = true;
20+
public static class SoundToggles
21+
{
22+
@Config.Name("Item Drop Sound")
23+
@Config.Comment("Play a sound when dropping items")
24+
public boolean esDropItemSound = true;
25+
26+
@Config.Name("Item Pick/Place Sound")
27+
@Config.Comment("Play a sound when picking and placing items in GUIs")
28+
public boolean esPickPlaceSound = true;
29+
30+
@Config.Name("Open/Close GUI Sound")
31+
@Config.Comment("Play a sound when opening and closing GUIs")
32+
public boolean esOpenCloseGUISound = true;
33+
34+
@Config.Name("Chat Message Sound")
35+
@Config.Comment("Play a sound on chat messages")
36+
public boolean esMessageSound = true;
37+
38+
@Config.Name("Chat Mention Sound")
39+
@Config.Comment("Play a sound on player name mentions in chat")
40+
public boolean esMentionSound = true;
41+
42+
@Config.Name("Typing Sound")
43+
@Config.Comment("Play a sound when typing in text fields")
44+
public boolean esTypingSound = true;
45+
46+
@Config.Name("Hotbar Slot Change Sound")
47+
@Config.Comment("Play a sound when changing hotbar slots")
48+
public boolean esHotbarSound = true;
49+
}
50+
51+
public static class SoundVolume
52+
{
53+
@Config.Name("Item Drop Sound Volume")
54+
@Config.Comment("Volume of the sound when dropping items")
55+
public double esDropItemSoundVolume = 0.4;
56+
57+
@Config.Name("Default Item Pick/Place Sound Volume")
58+
@Config.Comment("Volume of the fallback sound when picking and placing items in GUIs")
59+
public double esPickPlaceDefaultSound = 0.4;
2560

26-
@Config.Name("Chat Message Sound")
27-
@Config.Comment("Play a sound on chat messages")
28-
public static boolean esMessageSound = true;
61+
@Config.Name("Wood Item Pick/Place Sound Volume")
62+
@Config.Comment("Volume of the sound when picking and placing wooden items in GUIs")
63+
public double esPickPlaceWoodSound = 0.2;
2964

30-
@Config.Name("Chat Mention Sound")
31-
@Config.Comment("Play a sound on player name mentions in chat")
32-
public static boolean esMentionSound = true;
65+
@Config.Name("Gravel Item Pick/Place Sound Volume")
66+
@Config.Comment("Volume of the sound when picking and placing gravel items in GUIs")
67+
public double esPickPlaceGravelSound = 0.2;
3368

34-
@Config.Name("Typing Sound")
35-
@Config.Comment("Play a sound when typing in text fields")
36-
public static boolean esTypingSound = true;
69+
@Config.Name("Sand Item Pick/Place Sound Volume")
70+
@Config.Comment("Volume of the sound when picking and placing sand items in GUIs")
71+
public double esPickPlaceSandSound = 0.4;
3772

38-
@Config.Name("Hotbar Slot Change Sound")
39-
@Config.Comment("Play a sound when changing hotbar slots")
40-
public static boolean esHotbarSound = true;
73+
@Config.Name("Grass Item Pick/Place Sound Volume")
74+
@Config.Comment("Volume of the sound when picking and placing grass items in GUIs")
75+
public double esPickPlaceGrassSound = 0.6;
76+
77+
@Config.Name("Wool Item Pick/Place Sound Volume")
78+
@Config.Comment("Volume of the sound when picking and placing wool items in GUIs")
79+
public double esPickPlaceWoolSound = 0.4;
80+
81+
@Config.Name("Metal Item Pick/Place Sound Volume")
82+
@Config.Comment("Volume of the sound when picking and placing metal items in GUIs")
83+
public double esPickPlaceMetalSound = 0.1;
84+
85+
@Config.Name("Gem Item Pick/Place Sound Volume")
86+
@Config.Comment("Volume of the sound when picking and placing gem items in GUIs")
87+
public double esPickPlaceGemSound = 0.2;
88+
89+
@Config.Name("Dust Item Pick/Place Sound Volume")
90+
@Config.Comment("Volume of the sound when picking and placing gem items in GUIs")
91+
public double esPickPlaceDustSound = 0.6;
92+
93+
@Config.Name("Food Item Pick/Place Sound Volume")
94+
@Config.Comment("Volume of the sound when picking and placing food items in GUIs")
95+
public double esPickPlaceFoodSound = 0.2;
96+
97+
@Config.Name("Open/Close GUI Sound Volume")
98+
@Config.Comment("Volume of the sound when opening and closing GUIs")
99+
public double esOpenCloseGUISoundVolume = 1.5;
100+
101+
@Config.Name("Chat Message Sound Volume")
102+
@Config.Comment("Volume of the sound on chat messages")
103+
public double esMessageSoundVolume = 0.5;
104+
105+
@Config.Name("Chat Mention Sound Volume")
106+
@Config.Comment("Volume of the sound on player name mentions in chat")
107+
public double esMentionSoundVolume = 0.7;
108+
109+
@Config.Name("Typing Sound Volume")
110+
@Config.Comment("Volume of the sound when typing in text fields")
111+
public double esTypingSoundVolume = 0.2;
112+
113+
@Config.Name("Hotbar Slot Change Sound Volume")
114+
@Config.Comment("Volume of the sound when changing hotbar slots")
115+
public double esHotbarSoundVolume = 0.15;
116+
}
41117

42118
@Mod.EventBusSubscriber(modid = ExtraSounds.MODID)
43119
public static class EventHandler

src/main/java/mod/acgaming/extrasounds/mixin/EntityPlayerMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ public class EntityPlayerMixin
1818
@Inject(at = @At("TAIL"), method = "dropItem(Lnet/minecraft/item/ItemStack;ZZ)Lnet/minecraft/entity/item/EntityItem;")
1919
public void esDropItemSound(ItemStack droppedItem, boolean dropAround, boolean traceItem, CallbackInfoReturnable<EntityItem> cir)
2020
{
21-
if (ESConfig.esDropItemSound)
21+
if (ESConfig.soundToggles.esDropItemSound)
2222
{
2323
if (traceItem && !droppedItem.isEmpty())
2424
{
2525
float range = 0.1F;
2626
float pitch = 1.0F + range * (1.0F * droppedItem.getItem().getItemStackLimit() / droppedItem.getCount()) - range / 2;
27-
SoundManager.playSound(SoundEvents.BLOCK_LAVA_POP, pitch, 0.4F);
27+
SoundManager.playSound(SoundEvents.BLOCK_LAVA_POP, pitch, (float) ESConfig.soundVolume.esDropItemSoundVolume);
2828
}
2929
}
3030
}

src/main/java/mod/acgaming/extrasounds/mixin/GuiContainerCreativeMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class GuiContainerCreativeMixin
1818
@Inject(at = @At("HEAD"), method = "handleMouseClick")
1919
protected void esSlotClickSound(Slot slotIn, int slotId, int mouseButton, ClickType type, CallbackInfo ci)
2020
{
21-
if (ESConfig.esSlotClickSound)
21+
if (ESConfig.soundToggles.esPickPlaceSound)
2222
{
2323
if (slotIn != null)
2424
{

src/main/java/mod/acgaming/extrasounds/mixin/GuiContainerMixin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ public class GuiContainerMixin
1919
@Inject(at = @At("HEAD"), method = "initGui")
2020
public void esOpenGUISound(CallbackInfo ci)
2121
{
22-
if (ESConfig.esOpenCloseGUISound) SoundManager.playSound(SoundEvents.UI_TOAST_IN, 2.0F, 1.5F);
22+
if (ESConfig.soundToggles.esOpenCloseGUISound) SoundManager.playSound(SoundEvents.UI_TOAST_IN, 2.0F, (float) ESConfig.soundVolume.esOpenCloseGUISoundVolume);
2323
}
2424

2525
@Inject(at = @At("HEAD"), method = "onGuiClosed")
2626
public void esCloseGUISound(CallbackInfo ci)
2727
{
28-
if (ESConfig.esOpenCloseGUISound) SoundManager.playSound(SoundEvents.UI_TOAST_OUT, 2.0F, 1.5F);
28+
if (ESConfig.soundToggles.esOpenCloseGUISound) SoundManager.playSound(SoundEvents.UI_TOAST_OUT, 2.0F, (float) ESConfig.soundVolume.esOpenCloseGUISoundVolume);
2929
}
3030

3131
@Inject(at = @At("HEAD"), method = "handleMouseClick")
3232
protected void esSlotClickSound(Slot slotIn, int slotId, int mouseButton, ClickType type, CallbackInfo ci)
3333
{
34-
if (ESConfig.esSlotClickSound)
34+
if (ESConfig.soundToggles.esPickPlaceSound)
3535
{
3636
if (slotIn != null)
3737
{

src/main/java/mod/acgaming/extrasounds/mixin/GuiInventoryMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class GuiInventoryMixin
1818
@Inject(at = @At("HEAD"), method = "handleMouseClick")
1919
protected void esSlotClickSound(Slot slotIn, int slotId, int mouseButton, ClickType type, CallbackInfo ci)
2020
{
21-
if (ESConfig.esSlotClickSound)
21+
if (ESConfig.soundToggles.esPickPlaceSound)
2222
{
2323
if (slotIn != null)
2424
{

src/main/java/mod/acgaming/extrasounds/mixin/GuiNewChatMixin.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ private void esMessageMentionSound(ITextComponent chatComponent, int chatLineId,
2121
{
2222
if (Minecraft.getMinecraft().player == null || displayOnly) return;
2323

24-
if (ESConfig.esMessageSound)
24+
if (ESConfig.soundToggles.esMessageSound)
2525
{
26-
SoundManager.playSound(SoundEvents.BLOCK_NOTE_HAT, 2.0F, 0.5F);
26+
SoundManager.playSound(SoundEvents.BLOCK_NOTE_HAT, 2.0F, (float) ESConfig.soundVolume.esMessageSoundVolume);
2727
}
2828

29-
if (ESConfig.esMentionSound)
29+
if (ESConfig.soundToggles.esMentionSound)
3030
{
3131
String msg = chatComponent.getUnformattedText();
3232
EntityPlayerSP player = Minecraft.getMinecraft().player;
@@ -37,7 +37,7 @@ private void esMessageMentionSound(ITextComponent chatComponent, int chatLineId,
3737
// AVOID SELF-PINGS
3838
if (!msg.startsWith("<" + player.getName() + ">") || !msg.startsWith("<" + player.getDisplayNameString() + ">"))
3939
{
40-
SoundManager.playSound(SoundEvents.BLOCK_NOTE_CHIME, 1.8F, 0.7F);
40+
SoundManager.playSound(SoundEvents.BLOCK_NOTE_CHIME, 1.8F, (float) ESConfig.soundVolume.esMentionSoundVolume);
4141
}
4242
}
4343
}

src/main/java/mod/acgaming/extrasounds/mixin/GuiTextFieldMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public class GuiTextFieldMixin
1616
@Inject(at = @At("RETURN"), method = "textboxKeyTyped")
1717
public void esTypingSound(char chr, int modifiers, CallbackInfoReturnable<Boolean> cir)
1818
{
19-
if (ESConfig.esTypingSound)
19+
if (ESConfig.soundToggles.esTypingSound)
2020
{
21-
if (cir.getReturnValue()) SoundManager.playSound(SoundEvents.BLOCK_NOTE_HAT, 2.0F, 0.2F);
21+
if (cir.getReturnValue()) SoundManager.playSound(SoundEvents.BLOCK_NOTE_HAT, 2.0F, (float) ESConfig.soundVolume.esTypingSoundVolume);
2222
}
2323
}
2424
}

0 commit comments

Comments
 (0)