github.com/df-mc/dragonfly@v0.9.13/server/block/muddy_mangrove_roots.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 // MuddyMangroveRoots are a decorative variant of mangrove roots. 11 type MuddyMangroveRoots struct { 12 solid 13 14 // Axis is the axis which the muddy mangrove roots faces. 15 Axis cube.Axis 16 } 17 18 // BreakInfo ... 19 func (m MuddyMangroveRoots) BreakInfo() BreakInfo { 20 return newBreakInfo(0.7, alwaysHarvestable, shovelEffective, oneOf(m)) 21 } 22 23 // SoilFor ... 24 func (MuddyMangroveRoots) SoilFor(block world.Block) bool { 25 switch block.(type) { 26 case TallGrass, DoubleTallGrass, Flower, DoubleFlower, NetherSprouts: 27 return true 28 } 29 return false 30 } 31 32 // UseOnBlock ... 33 func (m MuddyMangroveRoots) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, user item.User, ctx *item.UseContext) (used bool) { 34 pos, face, used = firstReplaceable(w, pos, face, m) 35 if !used { 36 return 37 } 38 m.Axis = face.Axis() 39 40 place(w, pos, m, user, ctx) 41 return placed(ctx) 42 } 43 44 // EncodeItem ... 45 func (MuddyMangroveRoots) EncodeItem() (name string, meta int16) { 46 return "minecraft:muddy_mangrove_roots", 0 47 } 48 49 // EncodeBlock ... 50 func (m MuddyMangroveRoots) EncodeBlock() (string, map[string]any) { 51 return "minecraft:muddy_mangrove_roots", map[string]any{"pillar_axis": m.Axis.String()} 52 } 53 54 // allMuddyMangroveRoots ... 55 func allMuddyMangroveRoots() (roots []world.Block) { 56 for _, axis := range cube.Axes() { 57 roots = append(roots, MuddyMangroveRoots{Axis: axis}) 58 } 59 return 60 }