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 *t = append(*t, blockID) 16 return true 17 } 18 19 // Remove is a convenience method to remove a block id from the transparent 20 // block list 21 func (t *TransparentBlockList) Remove(blockID uint16) bool { 22 for n, b := range *t { 23 if b == blockID { 24 lt := len(*t) - 1 25 (*t)[n], (*t) = (*t)[lt], (*t)[:lt] 26 return true 27 } 28 } 29 return false 30 } 31 32 // LightBlockList is a map of block ids to the amount of light they give off 33 type LightBlockList map[uint16]uint8 34 35 // Add is a convenience method for the light block list. It adds a new block id 36 // to the list with its corresponding light level 37 func (l LightBlockList) Add(blockID uint16, light uint8) bool { 38 toRet := true 39 if _, ok := l[blockID]; ok { 40 toRet = false 41 } 42 l[blockID] = light 43 return toRet 44 } 45 46 // Remove is a convenience method to remove a block id from the light block 47 // list 48 func (l LightBlockList) Remove(blockID uint16) bool { 49 if _, ok := l[blockID]; ok { 50 delete(l, blockID) 51 return true 52 } 53 return false 54 } 55 56 var ( 57 // TransparentBlocks is a slice of the block ids that are transparent. 58 // This is used in lighting calculations and is user overrideable for custom 59 // blocks 60 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} 61 // LightBlocks is a map of block ids to the amount of light they give off 62 LightBlocks = LightBlockList{ 63 10: 15, 64 11: 15, 65 39: 1, 66 50: 14, 67 51: 15, 68 62: 13, 69 74: 13, 70 76: 7, 71 89: 15, 72 90: 11, 73 91: 15, 74 94: 9, 75 117: 1, 76 119: 15, 77 120: 1, 78 122: 1, 79 124: 15, 80 130: 7, 81 138: 15, 82 } 83 ) 84