up3
Build and deploy / Build (push) Has been cancelled
Build and deploy / Update Contributors (push) Has been cancelled
Build and deploy / Deploy (push) Has been cancelled

This commit is contained in:
2026-07-09 08:33:57 +08:00
commit 26ed99fda6
845 changed files with 75419 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
package sound
// LightningExplode ...
type LightningExplode struct{ sound }
// LightningThunder ...
type LightningThunder struct{ sound }
+223
View File
@@ -0,0 +1,223 @@
package sound
import (
"github.com/df-mc/dragonfly/server/world"
"github.com/go-gl/mathgl/mgl64"
)
// BlockPlace is a sound sent when a block is placed.
type BlockPlace struct {
// Block is the block which is placed, for which a sound should be played. The sound played depends on
// the block type.
Block world.Block
sound
}
// BlockBreaking is a sound sent continuously while a player is breaking a block.
type BlockBreaking struct {
// Block is the block which is being broken, for which a sound should be played. The sound played depends
// on the block type.
Block world.Block
sound
}
// GlassBreak is a sound played when a glass block or item is broken.
type GlassBreak struct{ sound }
// Fizz is a sound sent when a lava block and a water block interact with each other in a way that one of
// them turns into a solid block.
type Fizz struct{ sound }
// AnvilLand is played when an anvil lands on the ground.
type AnvilLand struct{ sound }
// AnvilUse is played when an anvil is used.
type AnvilUse struct{ sound }
// AnvilBreak is played when an anvil is broken.
type AnvilBreak struct{ sound }
// ChestOpen is played when a chest is opened.
type ChestOpen struct{ sound }
// ChestClose is played when a chest is closed.
type ChestClose struct{ sound }
// EnderChestOpen is played when a ender chest is opened.
type EnderChestOpen struct{ sound }
// EnderChestClose is played when a ender chest is closed.
type EnderChestClose struct{ sound }
// BarrelOpen is played when a barrel is opened.
type BarrelOpen struct{ sound }
// BarrelClose is played when a barrel is closed.
type BarrelClose struct{ sound }
// Deny is a sound played when a block is placed or broken above a 'Deny' block from Education edition.
type Deny struct{ sound }
// DoorOpen is a sound played when a door is opened.
type DoorOpen struct {
// Block is the block which is being opened, for which a sound should be played. The sound played depends on the
// block type.
Block world.Block
sound
}
// DoorClose is a sound played when a door is closed.
type DoorClose struct {
// Block is the block which is being closed, for which a sound should be played. The sound played depends on the
// block type.
Block world.Block
sound
}
// TrapdoorOpen is a sound played when a trapdoor is opened.
type TrapdoorOpen struct {
// Block is the block which is being opened, for which a sound should be played. The sound played depends on the
// block type.
Block world.Block
sound
}
// TrapdoorClose is a sound played when a trapdoor is closed.
type TrapdoorClose struct {
// Block is the block which is being closed, for which a sound should be played. The sound played depends on the
// block type.
Block world.Block
sound
}
// FenceGateOpen is a sound played when a fence gate is opened.
type FenceGateOpen struct {
// Block is the block which is being opened, for which a sound should be played. The sound played depends on the
// block type.
Block world.Block
sound
}
// FenceGateClose is a sound played when a fence gate is closed.
type FenceGateClose struct {
// Block is the block which is being closed, for which a sound should be played. The sound played depends on the
// block type.
Block world.Block
sound
}
// DoorCrash is a sound played when a door is forced open.
type DoorCrash struct{ sound }
// Click is a clicking sound.
type Click struct{ sound }
// Ignite is a sound played when using a flint & steel.
type Ignite struct{ sound }
// TNT is a sound played when TNT is ignited.
type TNT struct{ sound }
// FireExtinguish is a sound played when a fire is extinguished.
type FireExtinguish struct{ sound }
// Note is a sound played by note blocks.
type Note struct {
sound
// Instrument is the instrument of the note block.
Instrument Instrument
// Pitch is the pitch of the note.
Pitch int
}
// MusicDiscPlay is a sound played when a music disc has started playing in a jukebox.
type MusicDiscPlay struct {
sound
// DiscType is the disc type of the music disc.
DiscType DiscType
}
// MusicDiscEnd is a sound played when a music disc has stopped playing in a jukebox.
type MusicDiscEnd struct{ sound }
// ItemAdd is a sound played when an item is added to an item frame or campfire.
type ItemAdd struct{ sound }
// ItemFrameRemove is a sound played when an item is removed from an item frame.
type ItemFrameRemove struct{ sound }
// ItemFrameRotate is a sound played when an item frame's item is rotated.
type ItemFrameRotate struct{ sound }
// FurnaceCrackle is a sound played every one to five seconds from a furnace.
type FurnaceCrackle struct{ sound }
// CampfireCrackle is a sound played every one to five seconds from a campfire.
type CampfireCrackle struct{ sound }
// BlastFurnaceCrackle is a sound played every one to five seconds from a blast furnace.
type BlastFurnaceCrackle struct{ sound }
// SmokerCrackle is a sound played every one to five seconds from a smoker.
type SmokerCrackle struct{ sound }
// ComposterEmpty is a sound played when a composter has been emptied.
type ComposterEmpty struct{ sound }
// ComposterFill is a sound played when a composter has been filled, but not gone up a layer.
type ComposterFill struct{ sound }
// ComposterFillLayer is a sound played when a composter has been filled and gone up a layer.
type ComposterFillLayer struct{ sound }
// ComposterReady is a sound played when a composter has produced bone meal and is ready to be collected.
type ComposterReady struct{ sound }
// PotionBrewed is a sound played when a potion is brewed.
type PotionBrewed struct{ sound }
// PowerOn is a sound played when a redstone component is powered on.
type PowerOn struct{ sound }
// PowerOff is a sound played when a redstone component is powered off.
type PowerOff struct{ sound }
// LecternBookPlace is a sound played when a book is placed in a lectern.
type LecternBookPlace struct{ sound }
// SignWaxed is a sound played when a sign is waxed.
type SignWaxed struct{ sound }
// WaxedSignFailedInteraction is a sound played when a player tries to interact with a waxed sign.
type WaxedSignFailedInteraction struct{ sound }
// WaxRemoved is a sound played when wax is removed from a block.
type WaxRemoved struct{ sound }
// CopperScraped is a sound played when a player scrapes a copper block to reduce its oxidation level.
type CopperScraped struct{ sound }
// DecoratedPotInserted is a sound played when an item is successfully inserted into a decorated pot.
type DecoratedPotInserted struct {
sound
// Progress is how much of the decorated pot has been filled.
Progress float64
}
// DecoratedPotInsertFailed is a sound played when an item fails to be inserted into a decorated pot.
type DecoratedPotInsertFailed struct{ sound }
// sound implements the world.Sound interface.
type sound struct{}
// Play ...
func (sound) Play(*world.World, mgl64.Vec3) {}
+216
View File
@@ -0,0 +1,216 @@
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
}
// Disc13 returns the music disc "13".
func Disc13() DiscType {
return DiscType{0}
}
// DiscCat returns the music disc "cat".
func DiscCat() DiscType {
return DiscType{1}
}
// DiscBlocks returns the music disc "blocks".
func DiscBlocks() DiscType {
return DiscType{2}
}
// DiscChirp returns the music disc "chirp".
func DiscChirp() DiscType {
return DiscType{3}
}
// DiscFar returns the music disc "far".
func DiscFar() DiscType {
return DiscType{4}
}
// DiscMall returns the music disc "mall".
func DiscMall() DiscType {
return DiscType{5}
}
// DiscMellohi returns the music disc "mellohi".
func DiscMellohi() DiscType {
return DiscType{6}
}
// DiscStal returns the music disc "stal".
func DiscStal() DiscType {
return DiscType{7}
}
// DiscStrad returns the music disc "strad".
func DiscStrad() DiscType {
return DiscType{8}
}
// DiscWard returns the music disc "ward".
func DiscWard() DiscType {
return DiscType{9}
}
// Disc11 returns the music disc "11".
func Disc11() DiscType {
return DiscType{10}
}
// DiscWait returns the music disc "wait".
func DiscWait() DiscType {
return DiscType{11}
}
// DiscOtherside returns the music disc "otherside".
func DiscOtherside() DiscType {
return DiscType{12}
}
// DiscPigstep returns the music disc "Pigstep".
func DiscPigstep() DiscType {
return DiscType{13}
}
// Disc5 returns the music disc "5".
func Disc5() DiscType {
return DiscType{14}
}
// DiscRelic returns the music disc "Relic".
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}
}
// DiscTears returns the music disc "Tears".
func DiscTears() DiscType {
return DiscType{19}
}
// DiscLavaChicken returns the music disc "Lava Chicken".
func DiscLavaChicken() DiscType {
return DiscType{20}
}
// 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(), DiscTears(), DiscLavaChicken(),
}
}
// disc is the underlying value of a DiscType struct.
type disc uint8
// Uint8 converts the disc to an integer that uniquely identifies its type.
func (d disc) Uint8() uint8 {
return uint8(d)
}
// String ...
func (d disc) String() string {
switch d {
case 0:
return "13"
case 1:
return "cat"
case 2:
return "blocks"
case 3:
return "chirp"
case 4:
return "far"
case 5:
return "mall"
case 6:
return "mellohi"
case 7:
return "stal"
case 8:
return "strad"
case 9:
return "ward"
case 10:
return "11"
case 11:
return "wait"
case 12:
return "otherside"
case 13:
return "pigstep"
case 14:
return "5"
case 15:
return "relic"
case 16:
return "creator"
case 17:
return "creator_music_box"
case 18:
return "precipice"
case 19:
return "tears"
case 20:
return "lava_chicken"
}
panic("unknown record type")
}
// DisplayName ...
func (d disc) DisplayName() string {
switch d {
case 17:
return "Creator (Music Box)"
case 20:
return "Lava Chicken"
}
if d > 12 {
return cases.Title(language.English, cases.Compact).String(d.String())
}
return d.String()
}
// Author ...
func (d disc) Author() string {
if d <= 11 {
return "C418"
}
switch d {
case 12, 13, 16, 17:
return "Lena Raine"
case 14:
return "Samuel Åberg"
case 15, 18:
return "Aaron Cherof"
case 19:
return "Amos Roddy"
case 20:
return "Hyper Potions"
}
panic("unknown record type")
}
+60
View File
@@ -0,0 +1,60 @@
package sound
// Attack is a sound played when an entity, most notably a player, attacks another entity.
type Attack struct {
// Damage specifies if the attack actually dealt damage to the other entity. If set to false, the sound
// will be different from when set to true.
Damage bool
sound
}
// Drowning is a sound played when an entity is drowning in water.
type Drowning struct{ sound }
// Burning is a sound played when an entity is on fire.
type Burning struct{ sound }
// Fall is a sound played when an entity falls and hits ground.
type Fall struct {
// Distance is the distance the entity has fallen.
Distance float64
sound
}
// Burp is a sound played when a player finishes eating an item.
type Burp struct{ sound }
// Pop is a sound played when a chicken lays an egg.
type Pop struct{ sound }
// Explosion is a sound played when an explosion happens, such as from a creeper or TNT.
type Explosion struct{ sound }
// Thunder is a sound played when lightning strikes the ground.
type Thunder struct{ sound }
// LevelUp is a sound played for a player whenever they level up.
type LevelUp struct{ sound }
// Experience is a sound played whenever a player picks up an XP orb.
type Experience struct{ sound }
// GhastWarning is a sound played when a ghast is ready to attack.
type GhastWarning struct{ sound }
// GhastShoot is a sound played when a ghast shoots a fire charge.
type GhastShoot struct{ sound }
// FireworkLaunch is a sound played when a firework is launched.
type FireworkLaunch struct{ sound }
// FireworkHugeBlast is a sound played when a huge sphere firework explodes.
type FireworkHugeBlast struct{ sound }
// FireworkBlast is a sound played when a small sphere firework explodes.
type FireworkBlast struct{ sound }
// FireworkTwinkle is a sound played when a firework explodes and should twinkle.
type FireworkTwinkle struct{ sound }
+81
View File
@@ -0,0 +1,81 @@
package sound
// Horn represents a variant of a goat horn.
type Horn struct {
goatHornType
}
// Ponder returns the 'Ponder' goat horn type.
func Ponder() Horn {
return Horn{0}
}
// Sing returns the 'Sing' goat horn type.
func Sing() Horn {
return Horn{1}
}
// Seek returns the 'Seek' goat horn type.
func Seek() Horn {
return Horn{2}
}
// Feel returns the 'Feel' goat horn type.
func Feel() Horn {
return Horn{3}
}
// Admire returns the 'Admire' goat horn type.
func Admire() Horn {
return Horn{4}
}
// Call returns the 'Call' goat horn type.
func Call() Horn {
return Horn{5}
}
// Yearn returns the 'Yearn' goat horn type.
func Yearn() Horn {
return Horn{6}
}
// Dream returns the 'Dream' goat horn type.
func Dream() Horn {
return Horn{7}
}
type goatHornType uint8
// Uint8 returns the goat horn type as a uint8.
func (g goatHornType) Uint8() uint8 {
return uint8(g)
}
// Name returns the goat horn type's name.
func (g goatHornType) Name() string {
switch g {
case 0:
return "Ponder"
case 1:
return "Sing"
case 2:
return "Seek"
case 3:
return "Feel"
case 4:
return "Admire"
case 5:
return "Call"
case 6:
return "Yearn"
case 7:
return "Dream"
}
panic("should never happen")
}
// GoatHorns ...
func GoatHorns() []Horn {
return []Horn{Ponder(), Sing(), Seek(), Feel(), Admire(), Call(), Yearn(), Dream()}
}
+93
View File
@@ -0,0 +1,93 @@
package sound
// Instrument represents a note block instrument.
type Instrument struct {
instrument
}
type instrument int32
// Int32 ...
func (i instrument) Int32() int32 {
return int32(i)
}
// Piano is an instrument type for the note block.
func Piano() Instrument {
return Instrument{0}
}
// BassDrum is an instrument type for the note block.
func BassDrum() Instrument {
return Instrument{1}
}
// Snare is an instrument type for the note block.
func Snare() Instrument {
return Instrument{2}
}
// ClicksAndSticks is an instrument type for the note block.
func ClicksAndSticks() Instrument {
return Instrument{3}
}
// Bass is an instrument type for the note block.
func Bass() Instrument {
return Instrument{4}
}
// Flute is an instrument type for the note block.
func Flute() Instrument {
return Instrument{5}
}
// Bell is an instrument type for the note block.
func Bell() Instrument {
return Instrument{6}
}
// Guitar is an instrument type for the note block.
func Guitar() Instrument {
return Instrument{7}
}
// Chimes is an instrument type for the note block.
func Chimes() Instrument {
return Instrument{8}
}
// Xylophone is an instrument type for the note block.
func Xylophone() Instrument {
return Instrument{9}
}
// IronXylophone is an instrument type for the note block.
func IronXylophone() Instrument {
return Instrument{10}
}
// CowBell is an instrument type for the note block.
func CowBell() Instrument {
return Instrument{11}
}
// Didgeridoo is an instrument type for the note block.
func Didgeridoo() Instrument {
return Instrument{12}
}
// Bit is an instrument type for the note block.
func Bit() Instrument {
return Instrument{13}
}
// Banjo is an instrument type for the note block.
func Banjo() Instrument {
return Instrument{14}
}
// Pling is an instrument type for the note block.
func Pling() Instrument {
return Instrument{15}
}
+98
View File
@@ -0,0 +1,98 @@
package sound
import "github.com/df-mc/dragonfly/server/world"
// ItemBreak is a sound played when an item in the inventory is broken, such as when a tool reaches 0
// durability and breaks.
type ItemBreak struct{ sound }
// ItemThrow is a sound played when a player throws an item, such as a snowball.
type ItemThrow struct{ sound }
// ItemUseOn is a sound played when a player uses its item on a block. An example of this is when a player
// uses a shovel to turn grass into dirt path. Note that in these cases, the Block is actually the new block,
// not the old one.
type ItemUseOn struct {
// Block is generally the block that was created by using the item on a block. The sound played differs
// depending on this field.
Block world.Block
sound
}
// EquipItem is a sound played when the player fast equips an item by using it.
type EquipItem struct {
// Item is the item that was equipped. The sound played differs depending on this field.
Item world.Item
sound
}
// BucketFill is a sound played when a bucket is filled using a liquid source block from the world.
type BucketFill struct {
// Liquid is the liquid that the bucket is filled up with.
Liquid world.Liquid
sound
}
// BucketEmpty is a sound played when a bucket with a liquid in it is placed into the world.
type BucketEmpty struct {
// Liquid is the liquid that the bucket places into the world.
Liquid world.Liquid
sound
}
// BowShoot is a sound played when a bow is shot.
type BowShoot struct{ sound }
// CrossbowLoad is a sound when a crossbow is being loaded.
type CrossbowLoad struct {
// Stage is the stage of the crossbow.
Stage int
// QuickCharge returns if the item being used has quick charge enchantment.
QuickCharge bool
sound
}
// CrossbowShoot is a sound played when a crossbow is shot.
type CrossbowShoot struct{ sound }
const (
// CrossbowLoadingStart is the stage where a crossbows start to load.
CrossbowLoadingStart = iota
// CrossbowLoadingMiddle is the stage where a crossbow loading but not yet
// finished loading.
CrossbowLoadingMiddle
// CrossbowLoadingEnd is the stage where a crossbow is finished loading.
CrossbowLoadingEnd
)
// ArrowHit is a sound played when an arrow hits ground.
type ArrowHit struct{ sound }
// Teleport is a sound played upon teleportation of an enderman, or teleportation of a player by an ender pearl or a chorus fruit.
type Teleport struct{ sound }
// UseSpyglass is a sound played when a player uses a spyglass.
type UseSpyglass struct{ sound }
// StopUsingSpyglass is a sound played when a player stops using a spyglass.
type StopUsingSpyglass struct{ sound }
// GoatHorn is a sound played when a player uses a goat horn.
type GoatHorn struct {
// Horn is the type of the goat horn.
Horn Horn
sound
}
// FireCharge is a sound played when a player lights a block on fire with a fire charge, or when a dispenser or a
// blaze shoots a fireball.
type FireCharge struct{ sound }
// Totem is a sound played when a player uses a totem.
type Totem struct{ sound }