Skip to content

Commit 37ecd4a

Browse files
committed
Fix staff grid ambience sometimes playing when opening the splicing table
1 parent 015b142 commit 37ecd4a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Common/src/main/java/gay/object/hexdebug/mixin/MixinGuiSpellcasting.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
import at.petrak.hexcasting.common.msgs.MsgNewSpellPatternC2S;
99
import at.petrak.hexcasting.xplat.IClientXplatAbstractions;
1010
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
11+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
12+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
1113
import gay.object.hexdebug.gui.splicing.IMixinGuiSpellcasting;
14+
import net.minecraft.client.resources.sounds.SoundInstance;
15+
import net.minecraft.client.sounds.SoundManager;
1216
import net.minecraft.world.InteractionHand;
1317
import org.jetbrains.annotations.NotNull;
1418
import org.jetbrains.annotations.Nullable;
@@ -41,6 +45,18 @@ public abstract class MixinGuiSpellcasting implements IMixinGuiSpellcasting {
4145
@Override
4246
public abstract InteractionHand getHandOpenedWith();
4347

48+
@WrapWithCondition(
49+
method = "init",
50+
at = @At(
51+
value = "INVOKE",
52+
target = "Lnet/minecraft/client/sounds/SoundManager;play(Lnet/minecraft/client/resources/sounds/SoundInstance;)V"
53+
)
54+
)
55+
private boolean cancelAmbiance$hexdebug(SoundManager instance, SoundInstance sound) {
56+
// if this is being used for a splicing table, don't play the sound
57+
return onDrawSplicingTablePattern$hexdebug == null;
58+
}
59+
4460
@WrapWithCondition(
4561
method = "drawEnd",
4662
at = @At(

Common/src/main/kotlin/gay/object/hexdebug/gui/splicing/SplicingTableScreen.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package gay.`object`.hexdebug.gui.splicing
22

33
import at.petrak.hexcasting.api.utils.asTranslatedComponent
44
import at.petrak.hexcasting.client.gui.GuiSpellcasting
5-
import at.petrak.hexcasting.common.lib.HexSounds
65
import com.mojang.blaze3d.systems.RenderSystem
76
import gay.`object`.hexdebug.HexDebug
87
import gay.`object`.hexdebug.config.HexDebugConfig
@@ -117,7 +116,6 @@ class SplicingTableScreen(
117116
super.init()
118117

119118
guiSpellcasting.init(minecraft!!, width, height)
120-
Minecraft.getInstance().soundManager.stop(HexSounds.CASTING_AMBIANCE.location, null)
121119

122120
titleLabelX = (imageWidth - font.width(title)) / 2
123121

0 commit comments

Comments
 (0)