1 // Package minecraft is a level viewer/editor for the popular creative game minecraft. 2 package minecraft // import "vimagination.zapto.org/minecraft" 3 4 // TransparentBlockList is a slice of the block ids that are transparent. 5 type TransparentBlockList []uint16 6 7 // Add is a convenience method for the transparent block list. It adds a new 8 // block id to the list, making sure to not add duplicates. 9 func (t *TransparentBlockList) Add(blockID uint16) bool { 10 for _, b := range *t { 11 if b == blockID { 12 return false 13 } 14 } 15 16 *t = append(*t, blockID) 17 18 return true 19 } 20 21 // Remove is a convenience method to remove a block id from the transparent 22 // block list. 23 func (t *TransparentBlockList) Remove(blockID uint16) bool { 24 for n, b := range *t { 25 if b == blockID { 26 lt := len(*t) - 1 27 (*t)[n], (*t) = (*t)[lt], (*t)[:lt] 28 29 return true 30 } 31 } 32 33 return false 34 } 35 36 // LightBlockList is a map of block ids to the amount of light they give off. 37 type LightBlockList map[uint16]uint8 38 39 // Add is a convenience method for the light block list. It adds a new block id 40 // to the list with its corresponding light level. 41 func (l LightBlockList) Add(blockID uint16, light uint8) bool { 42 toRet := true 43 44 if _, ok := l[blockID]; ok { 45 toRet = false 46 } 47 48 l[blockID] = light 49 50 return toRet 51 } 52 53 // Remove is a convenience method to remove a block id from the light block 54 // list. 55 func (l LightBlockList) Remove(blockID uint16) bool { 56 if _, ok := l[blockID]; ok { 57 delete(l, blockID) 58 59 return true 60 } 61 62 return false 63 } 64 65 var ( 66 // TransparentBlocks is a slice of the block ids that are transparent. 67 // This is used in lighting calculations and is user overridable for custom 68 // blocks. 69 TransparentBlocks = TransparentBlockList{0, 6, 18, 20, 26, 27, 28, 29, 30, 31, 33, 34, 37, 38, 39, 40, 50, 51, 52, 54, 55, 59, 63, 64, 65, 66, 69, 70, 71, 75, 76, 77, 78, 79, 81, 83, 85, 90, 92, 93, 94, 96, 102, 106, 107, 117, 118, 119, 120, 750} 70 // LightBlocks is a map of block ids to the amount of light they give off. 71 LightBlocks = LightBlockList{ 72 10: 15, 73 11: 15, 74 39: 1, 75 50: 14, 76 51: 15, 77 62: 13, 78 74: 13, 79 76: 7, 80 89: 15, 81 90: 11, 82 91: 15, 83 94: 9, 84 117: 1, 85 119: 15, 86 120: 1, 87 122: 1, 88 124: 15, 89 130: 7, 90 138: 15, 91 } 92 ) 93