Skip to content

Commit e973833

Browse files
committed
fix: neoforge port
1 parent 91f697f commit e973833

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

src/main/java/com/ishland/fabric/rsls/mixin/MixinMusicTracker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class MixinMusicTracker {
3131
@Unique
3232
private CompletableFuture<Void> rsls$playFuture;
3333

34-
@WrapMethod(method = {"method_4858(Lnet/minecraft/class_10383;)V", "play"})
34+
@WrapMethod(method = {"startPlaying(Lnet/minecraft/client/sounds/MusicInfo;)V", "play"})
3535
private void wrapPlay(@Coerce Object instance, Operation<Void> original) {
3636
CompletableFuture<Void> rsls$playFuture1 = this.rsls$playFuture;
3737
if (rsls$playFuture1 != null && !rsls$playFuture1.isDone()) {
@@ -43,7 +43,7 @@ private void wrapPlay(@Coerce Object instance, Operation<Void> original) {
4343
this.rsls$playFuture = CompletableFuture.runAsync(() -> original.call(instance), taskQueue).orTimeout(15, TimeUnit.SECONDS);
4444
}
4545

46-
@WrapOperation(method = {"method_4858(Lnet/minecraft/class_10383;)V", "play"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/toast/ToastManager;onMusicTrackStart()V"))
46+
@WrapOperation(method = {"startPlaying(Lnet/minecraft/client/sounds/MusicInfo;)V", "play"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/toast/ToastManager;onMusicTrackStart()V"))
4747
private void wrapPlayListener(ToastManager instance, Operation<Void> original) {
4848
this.client.execute(() -> original.call(instance));
4949
}

src/main/java/com/ishland/fabric/rsls/mixin/MixinSoundManager.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import com.ishland.fabric.rsls.common.SoundManagerDuck;
44
import com.ishland.fabric.rsls.mixin.access.ISoundExecutor;
55
import com.ishland.fabric.rsls.mixin.access.ISoundSystem;
6+
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
7+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
8+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
69
import net.minecraft.client.sound.SoundExecutor;
710
import net.minecraft.client.sound.SoundInstance;
811
import net.minecraft.client.sound.SoundInstanceListener;
@@ -11,14 +14,14 @@
1114
import net.minecraft.client.sound.TickableSoundInstance;
1215
import net.minecraft.client.sound.WeightedSoundSet;
1316
import net.minecraft.sound.SoundCategory;
14-
import net.minecraft.util.Identifier;
1517
import org.jetbrains.annotations.Nullable;
1618
import org.spongepowered.asm.mixin.Final;
1719
import org.spongepowered.asm.mixin.Mixin;
1820
import org.spongepowered.asm.mixin.Mutable;
1921
import org.spongepowered.asm.mixin.Shadow;
2022
import org.spongepowered.asm.mixin.Unique;
2123
import org.spongepowered.asm.mixin.injection.At;
24+
import org.spongepowered.asm.mixin.injection.Coerce;
2225
import org.spongepowered.asm.mixin.injection.Inject;
2326
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2427

@@ -31,7 +34,7 @@ public abstract class MixinSoundManager implements SoundManagerDuck {
3134
@Shadow @Final private SoundSystem soundSystem;
3235

3336
@Mutable
34-
@Shadow @Final private Map<Identifier, WeightedSoundSet> sounds;
37+
@Shadow @Final private Map<?, WeightedSoundSet> sounds;
3538

3639
@Shadow public abstract void playNextTick(TickableSoundInstance sound);
3740

@@ -47,8 +50,6 @@ public abstract class MixinSoundManager implements SoundManagerDuck {
4750

4851
@Shadow public abstract void unregisterListener(SoundInstanceListener listener);
4952

50-
@Shadow public abstract void stopSounds(@Nullable Identifier id, @Nullable SoundCategory soundCategory);
51-
5253
@Shadow public abstract void reloadSounds();
5354

5455
@Inject(method = "<init>", at = @At("RETURN"), remap = false)
@@ -118,11 +119,12 @@ private void onUnregisterListener(SoundInstanceListener listener, CallbackInfo c
118119
}
119120
}
120121

121-
@Inject(method = "stopSounds", at = @At("HEAD"), cancellable = true)
122-
private void onStopSounds(Identifier id, SoundCategory soundCategory, CallbackInfo ci) {
122+
@WrapMethod(method = {"stop(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/sounds/SoundSource;)V", "stopSounds"})
123+
private void onStopSounds(@Coerce Object id, SoundCategory soundCategory, Operation<Void> original) {
123124
if (rsls$shouldRunOffthread()) {
124-
ci.cancel();
125-
((ISoundSystem) this.soundSystem).getTaskQueue().execute(() -> this.stopSounds(id, soundCategory));
125+
((ISoundSystem) this.soundSystem).getTaskQueue().execute(() -> original.call(id, soundCategory));
126+
} else {
127+
original.call(id, soundCategory);
126128
}
127129
}
128130

src/main/java/com/ishland/fabric/rsls/mixin/versions/sndmgr/patch_0/MixinSoundManager1_21_6.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import net.minecraft.client.sound.SoundSystem;
1111
import net.minecraft.client.sound.WeightedSoundSet;
1212
import net.minecraft.sound.SoundCategory;
13-
import net.minecraft.util.Identifier;
1413
import org.slf4j.Logger;
1514
import org.spongepowered.asm.mixin.Final;
1615
import org.spongepowered.asm.mixin.Mixin;
@@ -25,7 +24,7 @@
2524
@Mixin(SoundManager.class)
2625
public abstract class MixinSoundManager1_21_6 {
2726

28-
private static final Set<Identifier> rsls$unknownSounds = Sets.newConcurrentHashSet();
27+
// private static final Set<Identifier> rsls$unknownSounds = Sets.newConcurrentHashSet();
2928

3029
@Shadow @Final
3130
private SoundSystem soundSystem;
@@ -49,14 +48,15 @@ private void onPlay(SoundInstance sound, CallbackInfoReturnable<SoundSystem.Play
4948
}
5049

5150
WeightedSoundSet soundSet = sound.getSoundSet((SoundManager) (Object) this);
52-
Identifier identifier = sound.getId();
53-
if (soundSet == null) {
54-
if (rsls$unknownSounds.add(identifier)) {
55-
LOGGER.warn("Unable to play unknown soundEvent: {}", identifier);
56-
}
57-
cir.setReturnValue(SoundSystem.PlayResult.NOT_STARTED);
58-
return;
59-
}
51+
// Identifier is renamed in 1.21.11, so skip checks, but keep side effect
52+
// Identifier identifier = sound.getId();
53+
// if (soundSet == null) {
54+
// if (rsls$unknownSounds.add(identifier)) {
55+
// LOGGER.warn("Unable to play unknown soundEvent: {}", identifier);
56+
// }
57+
// cir.setReturnValue(SoundSystem.PlayResult.NOT_STARTED);
58+
// return;
59+
// }
6060

6161
Sound sound2 = sound.getSound();
6262
if (sound2 == SoundManager.INTENTIONALLY_EMPTY_SOUND || sound2 == SoundManager.MISSING_SOUND) {

src/main/java/com/ishland/fabric/rsls/mixin/versions/sndmgr/patch_1/MixinSoundManager1_21_9.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public abstract class MixinSoundManager1_21_9 {
2323
private SoundSystem soundSystem;
2424

2525
@Dynamic
26-
@WrapMethod(method = {"method_4865(Lnet/minecraft/class_3419;)V", "refreshSoundVolumes"})
26+
@WrapMethod(method = {"updateSourceVolume(Lnet/minecraft/sounds/SoundSource;)V", "refreshSoundVolumes"})
2727
private void onUpdateSoundVolume(SoundCategory category, Operation<Void> original) {
2828
if (((SoundManagerDuck) this).rsls$shouldRunOffthread()) {
2929
((ISoundSystem) this.soundSystem).getTaskQueue().execute(() -> original.call(category));

0 commit comments

Comments
 (0)