mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 11:05:12 +00:00
Sound Packet Commit
This commit is contained in:
1 parent
e8e868993b
commit
31c7ceacab
21 files changed
+181
-409
No files matched your search
@@ -15,6 +15,7 @@ import kamkeel.npcs.network.packets.client.large.LargeScrollListPacket;
|
||||
import kamkeel.npcs.network.packets.client.large.sync.LargeSyncPacket;
|
||||
import kamkeel.npcs.network.packets.client.npc.DeleteNpcPacket;
|
||||
import kamkeel.npcs.network.packets.client.npc.EditNpcPacket;
|
||||
import kamkeel.npcs.network.packets.client.script.ScriptedParticlePacket;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
@@ -5,6 +5,7 @@ public enum EnumClientPacket {
|
||||
SYNC,
|
||||
CHAT_ALERT,
|
||||
ACHIEVEMENT,
|
||||
SOUND,
|
||||
PARTY_MESSAGE,
|
||||
SYNCRECIPES_ADD,
|
||||
SYNCRECIPES_WORKBENCH,
|
||||
@@ -44,12 +45,6 @@ public enum EnumClientPacket {
|
||||
UPDATE_ANIMATIONS,
|
||||
OVERLAY_QUEST_TRACKING,
|
||||
DISABLE_MOUSE_INPUT,
|
||||
PLAY_SOUND_TO,
|
||||
PLAY_SOUND_TO_NO_ID,
|
||||
STOP_SOUND_FOR,
|
||||
PAUSE_SOUNDS,
|
||||
CONTINUE_SOUNDS,
|
||||
STOP_SOUNDS,
|
||||
SYNC_WEAPON,
|
||||
MARK_DATA,
|
||||
SYNC_ADD, SYNC_END, SYNC_UPDATE, SYNC_REMOVE, SYNC_PLAYER,
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package kamkeel.npcs.network.enums;
|
||||
|
||||
public enum EnumSoundOperation {
|
||||
CONTINUE_SOUNDS,
|
||||
PAUSE_SOUNDS,
|
||||
PLAY_MUSIC,
|
||||
PLAY_SOUND,
|
||||
PLAY_SOUND_TO,
|
||||
PLAY_SOUND_TO_NO_ID,
|
||||
STOP_SOUND_FOR,
|
||||
STOP_SOUNDS
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package kamkeel.npcs.network.packets.client;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import kamkeel.npcs.network.enums.EnumSoundOperation;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.controllers.MusicController;
|
||||
import noppes.npcs.client.controllers.ScriptClientSound;
|
||||
import noppes.npcs.client.controllers.ScriptSoundController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class SoundManagementPacket extends AbstractPacket {
|
||||
private EnumSoundOperation operation;
|
||||
private String soundName;
|
||||
private float x, y, z;
|
||||
private NBTTagCompound nbt;
|
||||
private int soundId;
|
||||
|
||||
public SoundManagementPacket() {}
|
||||
|
||||
public SoundManagementPacket(EnumSoundOperation operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public SoundManagementPacket(EnumSoundOperation operation, String soundName) {
|
||||
this.operation = operation;
|
||||
this.soundName = soundName;
|
||||
}
|
||||
|
||||
public SoundManagementPacket(EnumSoundOperation operation, String soundName, float x, float y, float z) {
|
||||
this.operation = operation;
|
||||
this.soundName = soundName;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public SoundManagementPacket(EnumSoundOperation operation, int soundId, NBTTagCompound nbt) {
|
||||
this.operation = operation;
|
||||
this.soundId = soundId;
|
||||
this.nbt = nbt;
|
||||
}
|
||||
|
||||
public SoundManagementPacket(EnumSoundOperation operation, NBTTagCompound nbt) {
|
||||
this.operation = operation;
|
||||
this.nbt = nbt;
|
||||
}
|
||||
|
||||
public SoundManagementPacket(EnumSoundOperation operation, int soundId) {
|
||||
this.operation = operation;
|
||||
this.soundId = soundId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.SOUND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.CLIENT_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeInt(operation.ordinal());
|
||||
switch (operation) {
|
||||
case PLAY_MUSIC:
|
||||
case PLAY_SOUND:
|
||||
ByteBufUtils.writeString(out, soundName);
|
||||
if (operation == EnumSoundOperation.PLAY_SOUND) {
|
||||
out.writeFloat(x);
|
||||
out.writeFloat(y);
|
||||
out.writeFloat(z);
|
||||
}
|
||||
break;
|
||||
case PLAY_SOUND_TO:
|
||||
out.writeInt(soundId);
|
||||
ByteBufUtils.writeNBT(out, nbt);
|
||||
break;
|
||||
case PLAY_SOUND_TO_NO_ID:
|
||||
ByteBufUtils.writeNBT(out, nbt);
|
||||
break;
|
||||
case STOP_SOUND_FOR:
|
||||
out.writeInt(soundId);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
EnumSoundOperation operation = EnumSoundOperation.values()[in.readInt()];
|
||||
switch (operation) {
|
||||
case CONTINUE_SOUNDS:
|
||||
ScriptSoundController.Instance.continueAllSounds();
|
||||
break;
|
||||
case PAUSE_SOUNDS:
|
||||
ScriptSoundController.Instance.pauseAllSounds();
|
||||
break;
|
||||
case PLAY_MUSIC:
|
||||
String soundName = ByteBufUtils.readString(in);
|
||||
MusicController.Instance.playMusicBackground(soundName, player, Integer.MAX_VALUE);
|
||||
break;
|
||||
case PLAY_SOUND:
|
||||
String name = ByteBufUtils.readString(in);
|
||||
float x = in.readFloat();
|
||||
float y = in.readFloat();
|
||||
float z = in.readFloat();
|
||||
MusicController.Instance.playSound(name, x, y, z);
|
||||
break;
|
||||
case PLAY_SOUND_TO:
|
||||
int id = in.readInt();
|
||||
NBTTagCompound comp = ByteBufUtils.readNBT(in);
|
||||
ScriptClientSound sound = ScriptClientSound.fromScriptSound(comp, player.worldObj);
|
||||
ScriptSoundController.Instance.playSound(id, sound);
|
||||
break;
|
||||
case PLAY_SOUND_TO_NO_ID:
|
||||
NBTTagCompound tagCompound = ByteBufUtils.readNBT(in);
|
||||
ScriptClientSound soundNoId = ScriptClientSound.fromScriptSound(tagCompound, player.worldObj);
|
||||
ScriptSoundController.Instance.playSound(soundNoId);
|
||||
break;
|
||||
case STOP_SOUND_FOR:
|
||||
int stopID = in.readInt();
|
||||
ScriptSoundController.Instance.stopSound(stopID);
|
||||
break;
|
||||
case STOP_SOUNDS:
|
||||
ScriptSoundController.Instance.stopAllSounds();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package kamkeel.npcs.network.packets.client;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.client.controllers.ScriptSoundController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class StopSoundForPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|StopSoundFor";
|
||||
|
||||
public StopSoundForPacket() {}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.STOP_SOUND_FOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.CLIENT_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
int soundId = in.readInt();
|
||||
ScriptSoundController.Instance.stopSound(soundId);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package kamkeel.npcs.network.packets.client;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.client.controllers.ScriptSoundController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class StopSoundsPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|StopSounds";
|
||||
|
||||
public StopSoundsPacket() {}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.STOP_SOUNDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.CLIENT_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
ScriptSoundController.Instance.stopAllSounds();
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
package kamkeel.npcs.network.packets.client;
|
||||
package kamkeel.npcs.network.packets.client.script;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -8,7 +8,6 @@ import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
package kamkeel.npcs.network.packets.client;
|
||||
package kamkeel.npcs.network.packets.client.script;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -9,7 +9,6 @@ import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package kamkeel.npcs.network.packets.client;
|
||||
package kamkeel.npcs.network.packets.client.script;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -1,41 +0,0 @@
|
||||
package kamkeel.npcs.network.packets.client.sound;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.client.controllers.ScriptSoundController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class ContinueSoundsPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|ContinueSounds";
|
||||
|
||||
public ContinueSoundsPacket() {}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.CONTINUE_SOUNDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.CLIENT_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
ScriptSoundController.Instance.continueAllSounds();
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package kamkeel.npcs.network.packets.client.sound;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.client.controllers.ScriptSoundController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class PauseSoundsPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|PauseSounds";
|
||||
|
||||
public PauseSoundsPacket() {}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.PAUSE_SOUNDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.CLIENT_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
ScriptSoundController.Instance.pauseAllSounds();
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package kamkeel.npcs.network.packets.client.sound;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.controllers.MusicController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class PlayMusicPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|PlayMusic";
|
||||
|
||||
public PlayMusicPacket() {}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.PLAY_MUSIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.CLIENT_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
String musicName = Server.readString(in);
|
||||
MusicController.Instance.playMusicBackground(musicName, player, Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package kamkeel.npcs.network.packets.client.sound;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.controllers.MusicController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class PlaySoundPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|PlaySound";
|
||||
|
||||
public PlaySoundPacket() {}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.PLAY_SOUND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.CLIENT_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
String soundName = Server.readString(in);
|
||||
float x = in.readFloat();
|
||||
float y = in.readFloat();
|
||||
float z = in.readFloat();
|
||||
MusicController.Instance.playSound(soundName, x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package kamkeel.npcs.network.packets.client.sound;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.controllers.ScriptClientSound;
|
||||
import noppes.npcs.client.controllers.ScriptSoundController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class PlaySoundToNoIdPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|PlaySoundToNoId";
|
||||
|
||||
public PlaySoundToNoIdPacket() {}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.PLAY_SOUND_TO_NO_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.CLIENT_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
NBTTagCompound nbt = Server.readNBT(in);
|
||||
ScriptClientSound sound = ScriptClientSound.fromScriptSound(nbt, player.worldObj);
|
||||
ScriptSoundController.Instance.playSound(sound);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package kamkeel.npcs.network.packets.client.sound;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.controllers.ScriptClientSound;
|
||||
import noppes.npcs.client.controllers.ScriptSoundController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class PlaySoundToPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|PlaySoundTo";
|
||||
|
||||
public PlaySoundToPacket() {}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.PLAY_SOUND_TO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.CLIENT_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
int soundId = in.readInt();
|
||||
NBTTagCompound nbt = Server.readNBT(in);
|
||||
ScriptClientSound sound = ScriptClientSound.fromScriptSound(nbt, player.worldObj);
|
||||
ScriptSoundController.Instance.playSound(soundId, sound);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,10 @@ package noppes.npcs;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.PacketUtil;
|
||||
import kamkeel.npcs.network.enums.EnumSoundOperation;
|
||||
import kamkeel.npcs.network.packets.client.SoundManagementPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -773,30 +777,30 @@ public class NoppesUtilPlayer {
|
||||
public static void playSoundTo(EntityPlayerMP player, int id, ScriptSound sound) {
|
||||
NBTTagCompound compound = sound.writeToNBT();
|
||||
if (sound.sourceEntity == null || player.worldObj.provider.dimensionId == sound.sourceEntity.getDimension()) {
|
||||
Server.sendData(player, EnumPacketClient.PLAY_SOUND_TO, id, compound);
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PLAY_SOUND_TO, id, compound), player);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PLAY_SOUND_TO_NO_ID, compound), player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopSoundFor(EntityPlayerMP player, int id) {
|
||||
Server.sendData(player, EnumPacketClient.STOP_SOUND_FOR, id);
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.STOP_SOUND_FOR, id), player);
|
||||
}
|
||||
|
||||
public static void pauseSoundsFor(EntityPlayerMP player) {
|
||||
Server.sendData(player, EnumPacketClient.PAUSE_SOUNDS);
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PAUSE_SOUNDS), player);
|
||||
}
|
||||
|
||||
public static void continueSoundsFor(EntityPlayerMP player) {
|
||||
Server.sendData(player, EnumPacketClient.CONTINUE_SOUNDS);
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.CONTINUE_SOUNDS), player);
|
||||
}
|
||||
|
||||
public static void stopSoundsFor(EntityPlayerMP player) {
|
||||
Server.sendData(player, EnumPacketClient.STOP_SOUNDS);
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.STOP_SOUNDS), player);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.PacketUtil;
|
||||
import kamkeel.npcs.network.packets.client.DialogPacket;
|
||||
import kamkeel.npcs.network.packets.client.ParticlePacket;
|
||||
import kamkeel.npcs.network.packets.client.ScriptedParticlePacket;
|
||||
import kamkeel.npcs.network.packets.client.script.ScriptedParticlePacket;
|
||||
import kamkeel.npcs.network.packets.client.npc.DeleteNpcPacket;
|
||||
import kamkeel.npcs.network.packets.client.npc.EditNpcPacket;
|
||||
import kamkeel.npcs.network.packets.client.RolePacket;
|
||||
@@ -37,7 +37,6 @@ import net.minecraft.world.World;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumPlayerData;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.containers.ContainerManageBanks;
|
||||
|
||||
@@ -3,6 +3,9 @@ package noppes.npcs;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumSoundOperation;
|
||||
import kamkeel.npcs.network.packets.client.SoundManagementPacket;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
@@ -327,7 +330,7 @@ public class ServerEventsHandler {
|
||||
ItemStack item = player.getCurrentEquippedItem();
|
||||
if(item == null || item.getItem() != CustomItems.excalibur)
|
||||
return;
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.PLAY_MUSIC, "customnpcs:songs.excalibur");
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PLAY_MUSIC, "customnpcs:songs.excalibur"), (EntityPlayerMP)player);
|
||||
player.addChatMessage(new ChatComponentTranslation("<" + StatCollector.translateToLocal(item.getItem().getUnlocalizedName() + ".name") + "> " + ItemExcalibur.quotes[player.getRNG().nextInt(ItemExcalibur.quotes.length)]));
|
||||
}
|
||||
|
||||
|
||||
@@ -98,12 +98,6 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
return;
|
||||
NoppesUtil.setLastNpc((EntityNPCInterface) entity);
|
||||
}
|
||||
else if(type == EnumPacketClient.PLAY_MUSIC){
|
||||
MusicController.Instance.playMusicBackground(Server.readString(buffer), player, Integer.MAX_VALUE);
|
||||
}
|
||||
else if(type == EnumPacketClient.PLAY_SOUND){
|
||||
MusicController.Instance.playSound(Server.readString(buffer),buffer.readFloat(),buffer.readFloat(),buffer.readFloat());
|
||||
}
|
||||
else if(type == EnumPacketClient.UPDATE_NPC){
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(compound.getInteger("EntityId"));
|
||||
@@ -305,31 +299,6 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
else if(type == EnumPacketClient.PLAY_SOUND_TO) {
|
||||
int id = buffer.readInt();
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
ScriptClientSound sound = ScriptClientSound.fromScriptSound(compound, player.worldObj);
|
||||
|
||||
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);
|
||||
}
|
||||
else if(type == EnumPacketClient.PAUSE_SOUNDS) {
|
||||
ScriptSoundController.Instance.pauseAllSounds();
|
||||
}
|
||||
else if(type == EnumPacketClient.CONTINUE_SOUNDS) {
|
||||
ScriptSoundController.Instance.continueAllSounds();
|
||||
}
|
||||
else if(type == EnumPacketClient.STOP_SOUNDS) {
|
||||
ScriptSoundController.Instance.stopAllSounds();
|
||||
}
|
||||
else if(type == EnumPacketClient.SYNC_WEAPON) {
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(buffer.readInt());
|
||||
if(!(entity instanceof EntityNPCInterface))
|
||||
|
||||
@@ -7,8 +7,6 @@ public enum EnumPacketClient {
|
||||
DIALOG,
|
||||
QUEST_COMPLETION,
|
||||
EDIT_NPC,
|
||||
PLAY_SOUND,
|
||||
PLAY_MUSIC,
|
||||
UPDATE_NPC,
|
||||
ROLE,
|
||||
GUI,
|
||||
@@ -34,12 +32,6 @@ public enum EnumPacketClient {
|
||||
UPDATE_ANIMATIONS,
|
||||
OVERLAY_QUEST_TRACKING,
|
||||
DISABLE_MOUSE_INPUT,
|
||||
PLAY_SOUND_TO,
|
||||
PLAY_SOUND_TO_NO_ID,
|
||||
STOP_SOUND_FOR,
|
||||
PAUSE_SOUNDS,
|
||||
CONTINUE_SOUNDS,
|
||||
STOP_SOUNDS,
|
||||
SYNC_WEAPON,
|
||||
MARK_DATA,
|
||||
SYNC_CONFIG,
|
||||
|
||||
@@ -8,7 +8,9 @@ import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.addon.DBCAddon;
|
||||
import kamkeel.npcs.addon.client.DBCClient;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumSoundOperation;
|
||||
import kamkeel.npcs.network.packets.client.ChatBubblePacket;
|
||||
import kamkeel.npcs.network.packets.client.SoundManagementPacket;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -1022,9 +1024,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
return;
|
||||
|
||||
if(!line.getSound().isEmpty()){
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.PLAY_SOUND, line.getSound(), (float)posX, (float)posY, (float)posZ);
|
||||
}
|
||||
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PLAY_SOUND, line.getSound(), (float)posX, (float)posY, (float)posZ), (EntityPlayerMP)player);
|
||||
}
|
||||
PacketHandler.Instance.sendToPlayer(new ChatBubblePacket(this.getEntityId(), line.getText(), !line.hideText()), (EntityPlayerMP)player);
|
||||
}
|
||||
public boolean getAlwaysRenderNameTagForRender(){
|
||||
|
||||
Reference in new issue
Block a user