diff options
author | Raven Szewczyk <git@eigenraven.me> | 2024-08-15 22:44:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-15 21:44:13 +0000 |
commit | 5decfda1dd1b3bbfdb1098f409aa50162ea32dc2 (patch) | |
tree | fd3dd1c237a0c8c4d4953dd7e529f5b5d89e6e34 /src/mixin/java/gregtech | |
parent | 799d5edf98e7e9f6152f432cdc48eac858398c8a (diff) | |
download | GT5-Unofficial-5decfda1dd1b3bbfdb1098f409aa50162ea32dc2.tar.gz GT5-Unofficial-5decfda1dd1b3bbfdb1098f409aa50162ea32dc2.tar.bz2 GT5-Unofficial-5decfda1dd1b3bbfdb1098f409aa50162ea32dc2.zip |
Electric jukebox (#2827)
* GT music system
* Minor fix for some glitches when switching dimensions with P2Ps on both sides
* Most features implemented except headphones
* Implement wireless headphones
* Disable debug mode
* Spotless
---------
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/mixin/java/gregtech')
-rw-r--r-- | src/mixin/java/gregtech/mixin/mixins/early/minecraft/SoundManagerInnerMixin.java | 33 | ||||
-rw-r--r-- | src/mixin/java/gregtech/mixin/mixins/early/minecraft/SoundManagerMixin.java | 52 |
2 files changed, 85 insertions, 0 deletions
diff --git a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/SoundManagerInnerMixin.java b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/SoundManagerInnerMixin.java new file mode 100644 index 0000000000..6150f495b6 --- /dev/null +++ b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/SoundManagerInnerMixin.java @@ -0,0 +1,33 @@ +package gregtech.mixin.mixins.early.minecraft; + +import net.minecraft.client.resources.IResource; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.util.ResourceLocation; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; + +import gregtech.client.SeekingOggCodec; + +@Mixin(targets = "net.minecraft.client.audio.SoundManager$2$1") +public abstract class SoundManagerInnerMixin { + + @WrapOperation( + method = "getInputStream", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/resources/IResourceManager;getResource(Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/resources/IResource;")) + IResource gt5u$stripSeekParams(IResourceManager instance, ResourceLocation location, + Operation<IResource> original) { + if (location.getResourcePath() + .endsWith(SeekingOggCodec.EXTENSION)) { + location = new ResourceLocation( + location.getResourceDomain(), + SeekingOggCodec.stripSeekMetadata(location.getResourcePath())); + } + return original.call(instance, location); + } +} diff --git a/src/mixin/java/gregtech/mixin/mixins/early/minecraft/SoundManagerMixin.java b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/SoundManagerMixin.java new file mode 100644 index 0000000000..f65d247a4e --- /dev/null +++ b/src/mixin/java/gregtech/mixin/mixins/early/minecraft/SoundManagerMixin.java @@ -0,0 +1,52 @@ +package gregtech.mixin.mixins.early.minecraft; + +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.SoundManager; +import net.minecraft.client.audio.SoundPoolEntry; +import net.minecraft.util.ResourceLocation; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.llamalad7.mixinextras.sugar.Local; + +import gregtech.api.util.GT_MusicSystem; +import gregtech.client.ISeekingSound; +import gregtech.client.SeekingOggCodec; + +@Mixin(SoundManager.class) +public class SoundManagerMixin { + + @WrapOperation( + method = "playSound", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/audio/SoundPoolEntry;getSoundPoolEntryLocation()Lnet/minecraft/util/ResourceLocation;")) + ResourceLocation gt5u$wrap(SoundPoolEntry instance, Operation<ResourceLocation> original, + @Local(argsOnly = true) ISound sound) { + ResourceLocation result = original.call(instance); + if (sound instanceof ISeekingSound seekingSound) { + result = SeekingOggCodec.seekResource(result, seekingSound.getSeekMillisecondOffset()); + } + return result; + } + + @Inject(method = "stopAllSounds", at = @At("HEAD")) + void gt5u$notifyOfSoundStop(CallbackInfo ci) { + GT_MusicSystem.ClientSystem.onSoundBatchStop(); + } + + @Inject(method = "pauseAllSounds", at = @At("HEAD")) + void gt5u$notifyOfSoundPause(CallbackInfo ci) { + GT_MusicSystem.ClientSystem.onSoundBatchPause(); + } + + @Inject(method = "resumeAllSounds", at = @At("HEAD")) + void gt5u$notifyOfSoundResume(CallbackInfo ci) { + GT_MusicSystem.ClientSystem.onSoundBatchResume(); + } +} |