github.com/df-mc/dragonfly@v0.9.13/server/block/quartz.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 type ( 11 // Quartz is a mineral block used only for decoration. 12 Quartz struct { 13 solid 14 bassDrum 15 // Smooth specifies if the quartz block is smooth or not. 16 Smooth bool 17 } 18 19 // ChiseledQuartz is a mineral block used only for decoration. 20 ChiseledQuartz struct { 21 solid 22 bassDrum 23 } 24 // QuartzPillar is a mineral block used only for decoration. 25 QuartzPillar struct { 26 solid 27 bassDrum 28 // Axis is the axis which the quartz pillar block faces. 29 Axis cube.Axis 30 } 31 ) 32 33 // UseOnBlock handles the rotational placing of quartz pillar blocks. 34 func (q QuartzPillar) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, user item.User, ctx *item.UseContext) (used bool) { 35 pos, face, used = firstReplaceable(w, pos, face, q) 36 if !used { 37 return 38 } 39 q.Axis = face.Axis() 40 41 place(w, pos, q, user, ctx) 42 return placed(ctx) 43 } 44 45 // BreakInfo ... 46 func (q Quartz) BreakInfo() BreakInfo { 47 return newBreakInfo(0.8, pickaxeHarvestable, pickaxeEffective, oneOf(Quartz{})) 48 } 49 50 // BreakInfo ... 51 func (c ChiseledQuartz) BreakInfo() BreakInfo { 52 return newBreakInfo(0.8, pickaxeHarvestable, pickaxeEffective, simpleDrops(item.NewStack(c, 1))) 53 } 54 55 // BreakInfo ... 56 func (q QuartzPillar) BreakInfo() BreakInfo { 57 return newBreakInfo(0.8, pickaxeHarvestable, pickaxeEffective, simpleDrops(item.NewStack(q, 1))) 58 } 59 60 // SmeltInfo ... 61 func (q Quartz) SmeltInfo() item.SmeltInfo { 62 if q.Smooth { 63 return item.SmeltInfo{} 64 } 65 return newSmeltInfo(item.NewStack(Quartz{Smooth: true}, 1), 0.1) 66 } 67 68 // EncodeItem ... 69 func (q Quartz) EncodeItem() (name string, meta int16) { 70 if q.Smooth { 71 return "minecraft:quartz_block", 3 72 } 73 return "minecraft:quartz_block", 0 74 } 75 76 // EncodeItem ... 77 func (c ChiseledQuartz) EncodeItem() (name string, meta int16) { 78 return "minecraft:quartz_block", 1 79 } 80 81 // EncodeItem ... 82 func (q QuartzPillar) EncodeItem() (name string, meta int16) { 83 return "minecraft:quartz_block", 2 84 } 85 86 // EncodeBlock ... 87 func (q Quartz) EncodeBlock() (name string, properties map[string]any) { 88 if q.Smooth { 89 return "minecraft:quartz_block", map[string]any{"chisel_type": "smooth", "pillar_axis": "y"} 90 } 91 return "minecraft:quartz_block", map[string]any{"chisel_type": "default", "pillar_axis": "y"} 92 } 93 94 // EncodeBlock ... 95 func (ChiseledQuartz) EncodeBlock() (name string, properties map[string]any) { 96 return "minecraft:quartz_block", map[string]any{"chisel_type": "chiseled", "pillar_axis": "y"} 97 } 98 99 // EncodeBlock ... 100 func (q QuartzPillar) EncodeBlock() (name string, properties map[string]any) { 101 return "minecraft:quartz_block", map[string]any{"pillar_axis": q.Axis.String(), "chisel_type": "lines"} 102 } 103 104 // allQuartz ... 105 func allQuartz() (quartz []world.Block) { 106 quartz = append(quartz, Quartz{}) 107 quartz = append(quartz, Quartz{Smooth: true}) 108 quartz = append(quartz, ChiseledQuartz{}) 109 for _, a := range cube.Axes() { 110 quartz = append(quartz, QuartzPillar{Axis: a}) 111 } 112 return 113 }