|
3 | 3 | import io.github.techstreet.dfscript.event.RecieveSoundEvent; |
4 | 4 | import io.github.techstreet.dfscript.event.system.EventManager; |
5 | 5 | import io.github.techstreet.dfscript.util.chat.ChatUtil; |
| 6 | +import net.minecraft.client.sound.Sound; |
6 | 7 | import net.minecraft.client.sound.SoundInstance; |
7 | 8 | import net.minecraft.client.sound.SoundSystem; |
| 9 | +import net.minecraft.client.sound.WeightedSoundSet; |
8 | 10 | import net.minecraft.network.packet.s2c.play.PlaySoundIdS2CPacket; |
| 11 | +import net.minecraft.sound.SoundCategory; |
| 12 | +import net.minecraft.util.Identifier; |
| 13 | +import net.minecraft.util.math.MathHelper; |
9 | 14 | import org.spongepowered.asm.mixin.Mixin; |
| 15 | +import org.spongepowered.asm.mixin.Shadow; |
| 16 | +import org.spongepowered.asm.mixin.gen.Invoker; |
10 | 17 | import org.spongepowered.asm.mixin.injection.At; |
11 | 18 | import org.spongepowered.asm.mixin.injection.Inject; |
12 | 19 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 20 | +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; |
13 | 21 |
|
14 | 22 | @Mixin(SoundSystem.class) |
15 | | -public class MSoundSystem { |
16 | | - @Inject(method = "play", at = @At("HEAD"), cancellable = true) |
17 | | - public void play(SoundInstance sound, CallbackInfo ci) { |
18 | | - RecieveSoundEvent event = new RecieveSoundEvent(sound); |
| 23 | +public abstract class MSoundSystem { |
| 24 | + |
| 25 | + @Shadow |
| 26 | + public abstract float getAdjustedVolume(SoundInstance sound); |
| 27 | + @Shadow |
| 28 | + public abstract float getAdjustedPitch(SoundInstance sound); |
| 29 | + @Shadow |
| 30 | + public abstract float getSoundVolume(SoundCategory category); |
| 31 | + @Inject(method = "play", at = @At(value="INVOKE_ASSIGN", target="Lnet/minecraft/client/sound/SoundSystem;getAdjustedPitch(Lnet/minecraft/client/sound/SoundInstance;)F"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) |
| 32 | + public void play(SoundInstance sound, CallbackInfo ci, WeightedSoundSet weightedSoundSet, Identifier identifier, Sound sound2, float f, float g, SoundCategory soundCategory, float h, float i) { |
| 33 | + RecieveSoundEvent event = new RecieveSoundEvent(sound.getId(), h, i); |
19 | 34 | EventManager.getInstance().dispatch(event); |
20 | 35 |
|
21 | 36 | if (event.isCancelled()) { |
|
0 commit comments