Skip to content

1.21 fabric 分支 增加自动续播音乐功能#67

Open
1499501762 wants to merge 32 commits into
TartaricAcid:1.21-fabricfrom
1499501762:1.21-fabric
Open

1.21 fabric 分支 增加自动续播音乐功能#67
1499501762 wants to merge 32 commits into
TartaricAcid:1.21-fabricfrom
1499501762:1.21-fabric

Conversation

@1499501762

Copy link
Copy Markdown

酒石酸佬好,

根据自己的想法在1.21 fabric分支里增加了根据距离自动管理和续播音乐的功能,

  • 在远离唱片机96格自动停止唱片,靠近时续播的功能(应对区块卸载加载环境)

  • 重新载入世界时检查唱片机96格内的玩家并尝试续播

  • 在服务端环境下增加了登入时通过重置玩家标记的简单实现方法完成了服务端环境下在范围内登入的自动续播(因为1tick内清除和重新添加到notified标记的原因还加了对于瞬态标记变化导致音乐异常停止的防护,酒石酸佬也可以改为登出时在所有notified标记内清除,登入时重新检查并加入到notified标记内,目前因为未知原因我这样写notified标记内对应的玩家的UUID不会更新,只能改用现在的比较蠢的实现方法了)

  • 增加了在弹出和更换CD时停止播放并重置进度,以适配机械动力等潜在模组的自动化换唱片结构

  • 另外增加了与net_music_list扩展的支持,会在环境中存在net_music_list模组时在服务端播放一首歌完成后归零播放进度和停止音乐(歌曲结束后停止音乐可能在多个卡顿的环境下可能是不必要的,所以只在安装了扩展的时候向客户端发送停止播放消息以免出现多播的问题)

  • 另外计划加入歌曲缓存功能以便减少网络请求和歌曲加载时间,请问酒石酸佬缓存网易云歌曲和元数据在本地客户端是否是被允许的合法PR?

以下所有PR均已在我本地build和单机/服务端环境测试

再次感谢酒石酸佬创建和维护这个模组!
谢谢!

1499501762 and others added 11 commits January 3, 2026 19:35
- Added skipToProgress method in NetMusicAudioStream to allow skipping to a specific playback position.
- Enhanced NetMusicSound to support starting playback from a specified progress.
- Introduced PlayProgressMessage and UpdatePlayProgressC2SMessage for syncing playback progress between client and server.
- Implemented PlayProgressMessageReceiver and UpdatePlayProgressC2SReceiver to handle incoming progress messages.
- Updated TileEntityMusicPlayer to manage and synchronize playback progress.
- Added logging for progress updates and playback state changes for better debugging.
…and prevent duplicate playback

- Added ClientMusicPlaybackManager to track currently playing sounds at specific BlockPos.
- Introduced deduplication logic to avoid rapid replays of the same sound.
- Updated MusicPlayManager to utilize ClientMusicPlaybackManager for sound registration and playback.
- Modified NetMusicSound to register and unregister sounds with ClientMusicPlaybackManager.
- Enhanced TileEntityMusicPlayer to handle playback recovery and progress synchronization with the server.
- Implemented StopMusicMessage and StopMusicMessageReceiver to handle stopping sounds on the client side.
- Removed unnecessary progress update messages from the client to the server, centralizing progress calculation on the server.
…eck logic when players join

refactor: Optimize music playback management to avoid duplicate message processing
- Added detailed logging in MusicPlayManager for sound instance creation and playback.
- Implemented defensive cleanup in MusicToClientMessageReceiver to handle rapid reconnections.
- Introduced a delay mechanism for sound creation to ensure audio system readiness.
- Added configuration option ENABLE_AUTO_STOP_ON_END in GeneralConfig to control auto-stop behavior.
- Improved server event handling for player join and disconnect events, including cleanup of notified flags.
- Enhanced TileEntityMusicPlayer with optimizations for player notifications and playback progress synchronization.
- Updated language files for new configuration options.

fix: Fixed two resume playback failure issues
- Fixed an issue where a TE was not added to the ActivePlayersPerWorld map after server restart, resulting in a second resume playback without continuity after server restart
- Fixed a rare issue where the world used for loading in single player mode was too long, resulting in a failed resume playback
@1499501762 1499501762 marked this pull request as draft January 3, 2026 22:52
@1499501762 1499501762 marked this pull request as ready for review January 3, 2026 22:54
@1499501762

1499501762 commented Jan 3, 2026

Copy link
Copy Markdown
Author
  • 尝试修复了一个在单机环境下因加载世界时过慢偶发的由于SoundManager在注册sound后,出于某种原因没有开始续播的问题(目前是延时1秒等待完全加载,由于没有完全定位到问题,暂时使用这样的修复方法应该也够用了)
  • 修复了一个服务端在播放时重新启动导致的getActiveMapForWorld 返回空值造成登入服务器后退出二次登录续播异常的问题
  • 移除了一些不影响功能实现的重复功能,增加了节流措施,减少整体tick性能影响

…anagement

- Added `EntityMusicPersistentState` to handle persistent storage of entity music sessions.
- Introduced `EntityMusicPlayerManager` for managing associations between entities and music players.
- Implemented atomic registration and unregistration methods to prevent duplicate playback instances.
- Enhanced network messaging to prioritize entity ID lookups for efficient playback restoration.
- Updated broadcasting strategy to reduce network noise by notifying only nearby players.
- Ensured compatibility with existing data structures during migration.
- Comprehensive logging for debugging and monitoring playback sessions.
@1499501762

1499501762 commented Jan 5, 2026

Copy link
Copy Markdown
Author
  • 增加了允许在实体上管理播放和续播的功能,提供更好的扩展性
  • 改用了Nbt持久化的方式,依赖区块/方块实体的同步方式管理播放和续播,不再使用服务端在tick中通距离管理的方式,减少服务端tick性能开销,目前存在一些bug
    已知bug:
  • 在服务器环境下重启服务器,方块上的播放器在区块卸载重载之后的续播异常(已计划修复)

@1499501762 1499501762 marked this pull request as draft January 5, 2026 15:47
@1499501762 1499501762 marked this pull request as ready for review January 8, 2026 16:20
@1499501762

Copy link
Copy Markdown
Author
  • 修复已知的bug
  • 增加了技术文档和集成指南

@gly091020

Copy link
Copy Markdown

@1499501762 我看到你的移植是fork的fabric版本的播放列表,但是那个版本是个半成品,不推荐使用(就一个正式版),目前活跃的是1.21.1neoforge,你可以试试移植这个版本的(而且歌曲缓存我已经写了),同版本应该会好移植一点。
你的仓库好像没有开issue,我只能在这里反馈了。
当然,还是感谢你的移植,你的使用教程写的比我精细多了👍

@1499501762

Copy link
Copy Markdown
Author
  • 修改了世界初始化时的续播机制,现在续播不依赖延迟了(部分注释可能未更新)

@1499501762

1499501762 commented Jan 16, 2026

Copy link
Copy Markdown
Author

@1499501762 我看到你的移植是fork的fabric版本的播放列表,但是那个版本是个半成品,不推荐使用(就一个正式版),目前活跃的是1.21.1neoforge,你可以试试移植这个版本的(而且歌曲缓存我已经写了),同版本应该会好移植一点。 你的仓库好像没有开issue,我只能在这里反馈了。 当然,还是感谢你的移植,你的使用教程写的比我精细多了👍

已计划移植,目前看到你这个模组的依赖里面有create和flywheel,⚠️这两个模组目前没有Fabric1.21.1的版本⚠️,可能会被移除部分特性,已在准备移植的仓库开启Issue,后续可以在目标仓库交流

@1499501762

Copy link
Copy Markdown
Author
  • 已知仍然存在偶发的因为音频管线初始化导致的第一次进入存档/服务器偶发的续播异常无声音,已排除延迟创建方法,计划使用音频探针方法

@1499501762

Copy link
Copy Markdown
Author
  • 已知和'Simple voice chat'处在同一环境下时,由于此模组在世界初始化时会重建/初始化音频管线导致的续播异常,计划反射相应事件进行主动适配

…ize the handling and retry strategy of playback requests
@1499501762

Copy link
Copy Markdown
Author
  • 修复了已知bug
  • 更新了集成文档

…set behavior of voicechat during non-world initialization condition
@TartaricAcid

Copy link
Copy Markdown
Owner

不好意思前段时间有点忙没来得及处理,我先看看,然后把这部分代码同步到其他三个版本

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants