github.com/df-mc/dragonfly@v0.9.13/server/block/wood_fence.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 "time" 9 ) 10 11 // WoodFence are blocks similar to Walls, which cannot normally be jumped over. Unlike walls however, 12 // they allow the player (but not mobs) to see through them, making for excellent barriers. 13 type WoodFence struct { 14 transparent 15 bass 16 sourceWaterDisplacer 17 18 // Wood is the type of wood of the fence. This field must have one of the values found in the wood 19 // package. 20 Wood WoodType 21 } 22 23 // BreakInfo ... 24 func (w WoodFence) BreakInfo() BreakInfo { 25 return newBreakInfo(2, alwaysHarvestable, axeEffective, oneOf(w)).withBlastResistance(15) 26 } 27 28 // SideClosed ... 29 func (WoodFence) SideClosed(cube.Pos, cube.Pos, *world.World) bool { 30 return false 31 } 32 33 // FlammabilityInfo ... 34 func (w WoodFence) FlammabilityInfo() FlammabilityInfo { 35 if !w.Wood.Flammable() { 36 return newFlammabilityInfo(0, 0, false) 37 } 38 return newFlammabilityInfo(5, 20, true) 39 } 40 41 // FuelInfo ... 42 func (WoodFence) FuelInfo() item.FuelInfo { 43 return newFuelInfo(time.Second * 15) 44 } 45 46 // EncodeBlock ... 47 func (w WoodFence) EncodeBlock() (name string, properties map[string]any) { 48 return "minecraft:" + w.Wood.String() + "_fence", nil 49 } 50 51 // Model ... 52 func (w WoodFence) Model() world.BlockModel { 53 return model.Fence{Wood: true} 54 } 55 56 // EncodeItem ... 57 func (w WoodFence) EncodeItem() (name string, meta int16) { 58 return "minecraft:" + w.Wood.String() + "_fence", 0 59 } 60 61 // allFence ... 62 func allFence() (fence []world.Block) { 63 for _, w := range WoodTypes() { 64 fence = append(fence, WoodFence{Wood: w}) 65 } 66 return 67 }