Skip to content

Commit

Permalink
sound/disc_type.go: Add new Minecraft 1.21 music discs
Browse files Browse the repository at this point in the history
  • Loading branch information
DaPigGuy committed Jun 14, 2024
1 parent a331470 commit 35bb4b3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
6 changes: 6 additions & 0 deletions server/session/world.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,12 @@ func (s *Session) playSound(pos mgl64.Vec3, t world.Sound, disableRelative bool)
pk.SoundType = packet.SoundEventRecord5
case sound.DiscRelic():
pk.SoundType = packet.SoundEventRecordRelic
case sound.DiscCreator():
pk.SoundType = packet.SoundEventRecordCreator
case sound.DiscCreatorMusicBox():
pk.SoundType = packet.SoundEventRecordCreatorMusicBox
case sound.DiscPrecipice():
pk.SoundType = packet.SoundEventRecordPrecipice
}
case sound.MusicDiscEnd:
pk.SoundType = packet.SoundEventRecordNull
Expand Down
40 changes: 34 additions & 6 deletions server/world/sound/disc_type.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package sound

import (
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

// DiscType represents the type of music disc. Typically, Minecraft has a total of 15 music discs.
type DiscType struct {
disc
Expand Down Expand Up @@ -85,11 +90,27 @@ func DiscRelic() DiscType {
return DiscType{15}
}

// DiscCreator returns the music disc "Creator".
func DiscCreator() DiscType {
return DiscType{16}
}

// DiscCreatorMusicBox returns the music disc "Creator (Music Box)".
func DiscCreatorMusicBox() DiscType {
return DiscType{17}
}

// DiscPrecipice returns the music disc "Precipice".
func DiscPrecipice() DiscType {
return DiscType{18}
}

// MusicDiscs returns a list of all existing music discs.
func MusicDiscs() []DiscType {
return []DiscType{
Disc13(), DiscCat(), DiscBlocks(), DiscChirp(), DiscFar(), DiscMall(), DiscMellohi(), DiscStal(),
DiscStrad(), DiscWard(), Disc11(), DiscWait(), DiscOtherside(), DiscPigstep(), Disc5(), DiscRelic(),
DiscCreator(), DiscCreatorMusicBox(), DiscPrecipice(),
}
}

Expand Down Expand Up @@ -136,17 +157,24 @@ func (d disc) String() string {
return "5"
case 15:
return "relic"
case 16:
return "creator"
case 17:
return "creator_music_box"
case 18:
return "precipice"
}
panic("unknown record type")
}

// DisplayName ...
func (d disc) DisplayName() string {
switch d {
case 13:
return "Pigstep"
case 15:
return "Relic"
case 17:
return "Creator (Music Box)"
}
if d > 12 {
return cases.Title(language.English, cases.Compact).String(d.String())
}
return d.String()
}
Expand All @@ -157,11 +185,11 @@ func (d disc) Author() string {
return "C418"
}
switch d {
case 12, 13:
case 12, 13, 16, 17:
return "Lena Raine"
case 14:
return "Samuel Åberg"
case 15:
case 15, 18:
return "Aaron Cherof"
}
panic("unknown record type")
Expand Down

0 comments on commit 35bb4b3

Please sign in to comment.