Skip to content

Commit f96257a

Browse files
committed
Check JEI page count, fixes #4
1 parent ba6db2b commit f96257a

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
package mod.acgaming.extrasounds.mixin;
22

33
import mezz.jei.gui.overlay.IngredientGridWithNavigation;
4+
import mezz.jei.input.IPaged;
45
import mod.acgaming.extrasounds.config.ESConfig;
56
import mod.acgaming.extrasounds.sound.ESSoundEvents;
67
import mod.acgaming.extrasounds.sound.ESSoundManager;
8+
import org.spongepowered.asm.mixin.Final;
79
import org.spongepowered.asm.mixin.Mixin;
10+
import org.spongepowered.asm.mixin.Mutable;
11+
import org.spongepowered.asm.mixin.Shadow;
812
import org.spongepowered.asm.mixin.injection.At;
913
import org.spongepowered.asm.mixin.injection.Inject;
1014
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1115

1216
@Mixin(IngredientGridWithNavigation.class)
1317
public class IngredientGridWithNavigationMixin
1418
{
19+
@Final
20+
@Mutable
21+
@Shadow
22+
private final IPaged pageDelegate;
23+
24+
public IngredientGridWithNavigationMixin(IPaged pageDelegate) {this.pageDelegate = pageDelegate;}
25+
1526
@Inject(at = @At("HEAD"), method = "handleMouseScrolled", remap = false)
16-
protected void esScrollJEIPage(int mouseX, int mouseY, int scrollDelta, CallbackInfoReturnable<Boolean> cir)
27+
public void esScrollJEIPage(int mouseX, int mouseY, int scrollDelta, CallbackInfoReturnable<Boolean> cir)
1728
{
1829
if (ESConfig.soundToggles.esScrollJEIPageSound)
1930
{
20-
if (scrollDelta != 0)
31+
if (this.pageDelegate.getPageCount() > 1 && scrollDelta != 0)
2132
{
2233
ESSoundManager.playSound(ESSoundEvents.scroll_page);
2334
}

src/main/java/mod/acgaming/extrasounds/sound/ESSoundManager.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public static void playClickSound(ItemStack stackIn)
5757
{
5858
playSound(SoundEvents.BLOCK_WOOD_HIT, 2.0F, (float) ESConfig.soundVolume.esPickPlaceWoodSound);
5959
}
60+
6061
else if (checkOreDict(i, "dirt") || checkOreDict(i, "gravel"))
6162
{
6263
playSound(SoundEvents.BLOCK_GRAVEL_HIT, 2.0F, (float) ESConfig.soundVolume.esPickPlaceGravelSound);
@@ -73,6 +74,11 @@ else if (checkOreDict(i, "wool"))
7374
{
7475
playSound(SoundEvents.BLOCK_CLOTH_HIT, 2.0F, (float) ESConfig.soundVolume.esPickPlaceWoolSound);
7576
}
77+
else if (checkOreDict(i, "snow"))
78+
{
79+
playSound(SoundEvents.BLOCK_SNOW_HIT, 2.0F, (float) ESConfig.soundVolume.esPickPlaceSnowSound);
80+
}
81+
7682
else if (checkOreDictPrefix(i, "ingot") || checkOreDictPrefix(i, "nugget"))
7783
{
7884
playSound(SoundEvents.BLOCK_ANVIL_PLACE, 2.0F, (float) ESConfig.soundVolume.esPickPlaceMetalSound);
@@ -85,10 +91,7 @@ else if (checkOreDictPrefix(i, "dust"))
8591
{
8692
playSound(SoundEvents.BLOCK_SAND_BREAK, 2.0F, (float) ESConfig.soundVolume.esPickPlaceDustSound);
8793
}
88-
else if (checkOreDictPrefix(i, "snow"))
89-
{
90-
playSound(SoundEvents.BLOCK_SNOW_HIT, 2.0F, (float) ESConfig.soundVolume.esPickPlaceSnowSound);
91-
}
94+
9295
else
9396
{
9497
playSound(SoundEvents.BLOCK_STONE_HIT, 2.0F, (float) ESConfig.soundVolume.esPickPlaceDefaultSound);

0 commit comments

Comments
 (0)