Sound Packet Commit

This commit is contained in:
Kam committed 2025-01-30 01:35:48 -05:00
1 parent e8e868993b
commit 31c7ceacab
21 files changed
+181 -409

No files matched your search

@@ -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(){