github.com/df-mc/dragonfly@v0.9.13/server/item/written_book_generation.go (about) 1 package item 2 3 // WrittenBookGeneration represents a WrittenBook generation. 4 type WrittenBookGeneration struct { 5 generation 6 } 7 8 type generation uint8 9 10 // OriginalGeneration is the original WrittenBook. 11 func OriginalGeneration() WrittenBookGeneration { 12 return WrittenBookGeneration{0} 13 } 14 15 // CopyGeneration is a copy of the original WrittenBook. 16 func CopyGeneration() WrittenBookGeneration { 17 return WrittenBookGeneration{1} 18 } 19 20 // CopyOfCopyGeneration is a copy of a copy of the original WrittenBook. 21 func CopyOfCopyGeneration() WrittenBookGeneration { 22 return WrittenBookGeneration{2} 23 } 24 25 // Uint8 returns the generation as a uint8. 26 func (g generation) Uint8() uint8 { 27 return uint8(g) 28 } 29 30 // String ... 31 func (g generation) String() string { 32 switch g { 33 case 0: 34 return "original" 35 case 1: 36 return "copy of original" 37 case 2: 38 return "copy of copy" 39 } 40 panic("unknown written book generation") 41 }