|
2 | 2 |
|
3 | 3 | import com.gmail.gorayan3838.notebetterfabric.NoteBetterFabric; |
4 | 4 | import com.gmail.gorayan3838.notebetterfabric.config.SoundConfig; |
| 5 | +import net.minecraft.block.Block; |
5 | 6 | import net.minecraft.block.NoteBlock; |
6 | 7 | import net.minecraft.entity.player.PlayerEntity; |
| 8 | +import net.minecraft.registry.entry.RegistryEntry; |
7 | 9 | import net.minecraft.sound.SoundCategory; |
8 | 10 | import net.minecraft.sound.SoundEvent; |
9 | 11 | import net.minecraft.util.Identifier; |
10 | 12 | import net.minecraft.util.math.BlockPos; |
11 | | -import net.minecraft.util.registry.Registry; |
| 13 | +import net.minecraft.registry.Registries; |
12 | 14 | import net.minecraft.world.World; |
13 | 15 | import org.jetbrains.annotations.Nullable; |
14 | 16 | import org.spongepowered.asm.mixin.Mixin; |
|
21 | 23 | @Mixin(NoteBlock.class) |
22 | 24 | public class NoteBlockMixin { |
23 | 25 |
|
24 | | - @Redirect(method = "onSyncedBlockEvent", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;playSound(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/sound/SoundEvent;Lnet/minecraft/sound/SoundCategory;FF)V")) |
25 | | - private void injected(World world, @Nullable PlayerEntity player, BlockPos pos, SoundEvent sound, SoundCategory category, float volume, float pitch) { |
| 26 | + @Redirect(method = "onSyncedBlockEvent", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;playSound(Lnet/minecraft/entity/player/PlayerEntity;DDDLnet/minecraft/registry/entry/RegistryEntry;Lnet/minecraft/sound/SoundCategory;FFJ)V")) |
| 27 | + private void injected(World world, @Nullable PlayerEntity player, double x, double y, double z, RegistryEntry<SoundEvent> sound, SoundCategory category, float volume, float pitch, long seed) { |
| 28 | + BlockPos pos = new BlockPos((int) x, (int) y, (int) z); |
26 | 29 | SoundConfig.Mapping[] mappings = NoteBetterFabric.CONFIG.getMappings(); |
27 | | - List<SoundConfig.Mapping> filteredMappings = Arrays.stream(mappings).filter(mapping -> world.getBlockState(pos.down()).getBlock().equals(Registry.BLOCK.get(new Identifier(mapping.getBlock())))).toList(); |
| 30 | + List<SoundConfig.Mapping> filteredMappings = Arrays.stream(mappings).filter(mapping -> world.getBlockState(pos.down()).getBlock().equals(Registries.BLOCK.get(new Identifier(mapping.getBlock())))).toList(); |
28 | 31 | filteredMappings.forEach(mapping -> { |
29 | 32 | SoundConfig.Sound soundInfo = mapping.getSound(); |
30 | 33 | world.playSound( |
31 | 34 | null, |
32 | | - pos, |
33 | | - new SoundEvent(new Identifier(soundInfo.getSound())), |
| 35 | + x, |
| 36 | + y, |
| 37 | + z, |
| 38 | + SoundEvent.of(new Identifier(soundInfo.getSound())), |
34 | 39 | SoundCategory.RECORDS, |
35 | 40 | soundInfo.getVolume(), |
36 | | - soundInfo.getPitch() * pitch |
| 41 | + soundInfo.getPitch() * pitch, |
| 42 | + seed |
37 | 43 | ); |
38 | 44 | }); |
39 | 45 | if (!filteredMappings.isEmpty()) { |
40 | 46 | return; |
41 | 47 | } |
42 | | - world.playSound(null, pos, sound, SoundCategory.RECORDS, volume, pitch); |
| 48 | + world.playSound(null, x, y, z, sound, SoundCategory.RECORDS, volume, pitch, seed); |
43 | 49 | } |
44 | 50 | } |
0 commit comments