github.com/df-mc/dragonfly@v0.9.13/server/block/basalt.go (about) 1 package block 2 3 import ( 4 "github.com/df-mc/dragonfly/server/block/cube" 5 "github.com/df-mc/dragonfly/server/item" 6 "github.com/df-mc/dragonfly/server/world" 7 "github.com/go-gl/mathgl/mgl64" 8 ) 9 10 // Basalt is a type of igneous rock found in the Nether. 11 type Basalt struct { 12 solid 13 bassDrum 14 15 // Polished specifies if the basalt is its polished variant. 16 Polished bool 17 // Axis is the axis which the basalt faces. 18 Axis cube.Axis 19 } 20 21 // UseOnBlock ... 22 func (b Basalt) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, user item.User, ctx *item.UseContext) (used bool) { 23 pos, face, used = firstReplaceable(w, pos, face, b) 24 if !used { 25 return 26 } 27 b.Axis = face.Axis() 28 29 place(w, pos, b, user, ctx) 30 return placed(ctx) 31 } 32 33 // BreakInfo ... 34 func (b Basalt) BreakInfo() BreakInfo { 35 return newBreakInfo(1.25, pickaxeHarvestable, pickaxeEffective, oneOf(b)).withBlastResistance(21) 36 } 37 38 // EncodeItem ... 39 func (b Basalt) EncodeItem() (name string, meta int16) { 40 if b.Polished { 41 return "minecraft:polished_basalt", 0 42 } 43 return "minecraft:basalt", 0 44 } 45 46 // EncodeBlock ... 47 func (b Basalt) EncodeBlock() (name string, properties map[string]any) { 48 if b.Polished { 49 return "minecraft:polished_basalt", map[string]any{"pillar_axis": b.Axis.String()} 50 } 51 return "minecraft:basalt", map[string]any{"pillar_axis": b.Axis.String()} 52 } 53 54 // allBasalt ... 55 func allBasalt() (basalt []world.Block) { 56 for _, axis := range cube.Axes() { 57 basalt = append(basalt, Basalt{Axis: axis, Polished: false}) 58 basalt = append(basalt, Basalt{Axis: axis, Polished: true}) 59 } 60 return 61 }