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