Disable play sound when crafting with gt tools (#659)

This commit is contained in:
slprime authored and GitHub committed 2025-07-08 15:41:42 +02:00
1 parent 3a0722adc2
commit ca79cdd3c9
4 files changed
+28

No files matched your search

@@ -24,4 +24,6 @@ public interface IStackStringifyHandler {
return null;
}
default void playItemDamageSound(boolean enabled) {}
}
@@ -32,6 +32,8 @@ public class AutoCraftingManager {
boolean processed = false;
boolean changed = false;
StackInfo.playItemDamageSound(false);
do {
changed = false;
@@ -68,6 +70,8 @@ public class AutoCraftingManager {
} while (changed && !interrupted(guiContainer));
StackInfo.playItemDamageSound(true);
if (processed && !changed && !interrupted(guiContainer)) {
NEIClientUtils.playClickSound();
}
@@ -84,6 +84,12 @@ public class StackInfo {
return result;
}
public static void playItemDamageSound(boolean enabled) {
for (IStackStringifyHandler handler : stackStringifyHandlers) {
handler.playItemDamageSound(enabled);
}
}
public static ItemStack withAmount(ItemStack stack, long customCount) {
if (stack == null) return null;
final NBTTagCompound nbTag = StackInfo.itemStackToNBT(stack);
@@ -1,5 +1,6 @@
package codechicken.nei.recipe.stackinfo;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Optional;
@@ -22,6 +23,7 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
public static boolean replaceAE2FCFluidDrop = false;
private static Class<?> gtMetaGeneratedTool = null;
private static Method getContainerItem = null;
private static Field playSound = null;
static {
try {
@@ -40,6 +42,9 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
getContainerItem = gtMetaGeneratedTool
.getDeclaredMethod("getContainerItem", ItemStack.class, boolean.class, boolean.class);
getContainerItem.setAccessible(true);
playSound = gtMetaGeneratedTool.getDeclaredField("playSound");
playSound.setAccessible(true);
} catch (Exception ignored) {
/* Do nothing */
}
@@ -125,4 +130,15 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
return null;
}
@Override
public void playItemDamageSound(boolean enabled) {
if (playSound != null) {
try {
playSound.setBoolean(null, enabled);
} catch (Exception e) {}
}
}
}