Skip to content

Commit

Permalink
Fix music not always playing
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrptonaught committed Jul 7, 2024
1 parent b327263 commit 24e380a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.parallel=true

# Fabric Properties
minecraft_version=1.21
yarn_mappings=1.21+build.2
yarn_mappings=1.21+build.7
loader_version=0.15.11

# Fabric API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public void setMusic(MusicPack pack) {
if (pack == null) {
this.masterPack = null;
this.playingPack = null;
this.currentSong = null;
this.endTime = 0;
return;
}

Expand All @@ -37,6 +39,12 @@ public void setMusic(MusicPack pack) {
this.playingPack.songs = new LinkedHashMap<>();
this.playingPack.play_order = pack.play_order;
this.playingPack.delay = pack.delay;
this.currentSong = null;
this.endTime = 0;
}

public void play() {
tickMusic = true;
}

public boolean isSongFinished(long currentTime) {
Expand Down Expand Up @@ -86,6 +94,7 @@ private void playSong(ServerPlayerEntity player, Identifier songID) {
Vec3d vec3d = player.getPos();

player.networkHandler.sendPacket(new PlaySoundS2CPacket(registryEntry, SoundCategory.MUSIC, vec3d.getX(), vec3d.getY(), vec3d.getZ(), 1, 1, player.getRandom().nextLong()));
System.out.println("Playing " + songID + " for " + player.getName().getString());
}

private void stopSong(ServerPlayerEntity player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void tick(ServerPlayerEntity player, long currentTime) {
}

public void startMusic() {
musicStatus.tickMusic = true;
musicStatus.play();
}

public void skipSong(ServerPlayerEntity player) {
Expand Down

0 comments on commit 24e380a

Please sign in to comment.