mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 20:25:13 +00:00
Implemented a way to play ISound(s) to players without using a sound ID.
This commit is contained in:
1 parent
a895c8bd24
commit
5d520837b1
8 files changed
+34
-1
No files matched your search
@@ -505,6 +505,13 @@ public class NoppesUtilPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
public static void playSoundTo(EntityPlayerMP player, ScriptSound sound) {
|
||||
NBTTagCompound compound = sound.writeToNBT();
|
||||
if (sound.sourceEntity == null || player.worldObj.provider.dimensionId == sound.sourceEntity.getDimension()) {
|
||||
Server.sendData(player, EnumPacketClient.PLAY_SOUND_TO_NO_ID, compound);
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopSoundFor(EntityPlayerMP player, int id) {
|
||||
Server.sendData(player, EnumPacketClient.STOP_SOUND_FOR, id);
|
||||
}
|
||||
|
||||
@@ -336,6 +336,13 @@ public class NoppesUtilServer {
|
||||
}
|
||||
}
|
||||
|
||||
public static void playSound(ScriptSound sound) {
|
||||
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
for (EntityPlayer player : list) {
|
||||
NoppesUtilPlayer.playSoundTo((EntityPlayerMP) player, sound);
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopSound(int id) {
|
||||
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
for (EntityPlayer player : list) {
|
||||
|
||||
@@ -314,6 +314,11 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
|
||||
ScriptSoundController.Instance.playSound(id,sound);
|
||||
}
|
||||
else if(type == EnumPacketClient.PLAY_SOUND_TO_NO_ID) {
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
ScriptClientSound sound = ScriptClientSound.fromScriptSound(compound, player.worldObj);
|
||||
ScriptSoundController.Instance.playSound(sound);
|
||||
}
|
||||
else if(type == EnumPacketClient.STOP_SOUND_FOR) {
|
||||
int id = buffer.readInt();
|
||||
ScriptSoundController.Instance.stopSound(id);
|
||||
|
||||
@@ -35,6 +35,11 @@ public class ScriptSoundController {
|
||||
soundHandler.playSound(sound);
|
||||
}
|
||||
|
||||
public void playSound(ScriptClientSound sound) {
|
||||
SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
|
||||
soundHandler.playSound(sound);
|
||||
}
|
||||
|
||||
public void stopSound(int id) {
|
||||
SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
|
||||
if (sounds.containsKey(id)) {
|
||||
|
||||
@@ -42,6 +42,7 @@ public enum EnumPacketClient {
|
||||
OVERLAY_QUEST_TRACKING,
|
||||
DISABLE_MOUSE_INPUT,
|
||||
PLAY_SOUND_TO,
|
||||
PLAY_SOUND_TO_NO_ID,
|
||||
STOP_SOUND_FOR,
|
||||
PAUSE_SOUNDS,
|
||||
CONTINUE_SOUNDS,
|
||||
|
||||
@@ -491,6 +491,10 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
NoppesUtilServer.playSound(id, (ScriptSound) sound);
|
||||
}
|
||||
|
||||
public void playSound(ISound sound) {
|
||||
NoppesUtilServer.playSound((ScriptSound) sound);
|
||||
}
|
||||
|
||||
public void stopSound(int id) {
|
||||
NoppesUtilServer.stopSound(id);
|
||||
}
|
||||
|
||||
@@ -590,6 +590,10 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
NoppesUtilPlayer.playSoundTo(player, id, (ScriptSound) sound);
|
||||
}
|
||||
|
||||
public void playSound(ISound sound) {
|
||||
NoppesUtilPlayer.playSoundTo(player, (ScriptSound) sound);
|
||||
}
|
||||
|
||||
public void stopSound(int id) {
|
||||
NoppesUtilPlayer.stopSoundFor(player, id);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user