mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-14 12:10:30 +00:00
Play sounds using ResourceLocation rather than SoundEvent
The latter is not registered when sounds are added via resource packs. Fixes #938. Probably.
This commit is contained in:
parent
045472577a
commit
6dd33f7099
@ -10,8 +10,8 @@ import net.minecraft.client.audio.ISound;
|
|||||||
import net.minecraft.client.audio.ITickableSound;
|
import net.minecraft.client.audio.ITickableSound;
|
||||||
import net.minecraft.client.audio.LocatableSound;
|
import net.minecraft.client.audio.LocatableSound;
|
||||||
import net.minecraft.client.audio.SoundHandler;
|
import net.minecraft.client.audio.SoundHandler;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.util.SoundCategory;
|
||||||
import net.minecraft.util.SoundEvent;
|
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -22,7 +22,7 @@ public class SoundManager
|
|||||||
{
|
{
|
||||||
private static final Map<UUID, MoveableSound> sounds = new HashMap<>();
|
private static final Map<UUID, MoveableSound> sounds = new HashMap<>();
|
||||||
|
|
||||||
public static void playSound( UUID source, Vector3d position, SoundEvent event, float volume, float pitch )
|
public static void playSound( UUID source, Vector3d position, ResourceLocation event, float volume, float pitch )
|
||||||
{
|
{
|
||||||
SoundHandler soundManager = Minecraft.getInstance().getSoundManager();
|
SoundHandler soundManager = Minecraft.getInstance().getSoundManager();
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ public class SoundManager
|
|||||||
|
|
||||||
private static class MoveableSound extends LocatableSound implements ITickableSound
|
private static class MoveableSound extends LocatableSound implements ITickableSound
|
||||||
{
|
{
|
||||||
protected MoveableSound( SoundEvent sound, Vector3d position, float volume, float pitch )
|
protected MoveableSound( ResourceLocation sound, Vector3d position, float volume, float pitch )
|
||||||
{
|
{
|
||||||
super( sound, SoundCategory.RECORDS );
|
super( sound, SoundCategory.RECORDS );
|
||||||
setPosition( position );
|
setPosition( position );
|
||||||
|
@ -9,12 +9,10 @@ import dan200.computercraft.client.SoundManager;
|
|||||||
import dan200.computercraft.shared.network.NetworkMessage;
|
import dan200.computercraft.shared.network.NetworkMessage;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.SoundEvent;
|
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.fml.network.NetworkEvent;
|
import net.minecraftforge.fml.network.NetworkEvent;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -68,7 +66,6 @@ public class SpeakerPlayClientMessage implements NetworkMessage
|
|||||||
@OnlyIn( Dist.CLIENT )
|
@OnlyIn( Dist.CLIENT )
|
||||||
public void handle( NetworkEvent.Context context )
|
public void handle( NetworkEvent.Context context )
|
||||||
{
|
{
|
||||||
SoundEvent sound = ForgeRegistries.SOUND_EVENTS.getValue( this.sound );
|
SoundManager.playSound( source, pos, sound, volume, pitch );
|
||||||
if( sound != null ) SoundManager.playSound( source, pos, sound, volume, pitch );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user