github.com/df-mc/dragonfly@v0.9.13/server/item/category/category.go (about) 1 package category 2 3 // Category represents the category a custom item will be displayed in, in the creative inventory. 4 type Category struct { 5 group string 6 category uint8 7 } 8 9 // Construction is the first tab in the creative inventory and usually contains blocks that are more for decoration and 10 // building than actual functionality. 11 func Construction() Category { 12 return Category{category: 1} 13 } 14 15 // Nature is the fourth tab in the creative inventory and usually contains blocks and items that can be found naturally 16 // in vanilla-generated world. 17 func Nature() Category { 18 return Category{category: 2} 19 } 20 21 // Equipment is the second tab in the creative inventory and usually contains armour, weapons and tools. 22 func Equipment() Category { 23 return Category{category: 3} 24 } 25 26 // Items is the third tab in the creative inventory and usually contains blocks and items that do not come under any 27 // other category, such as minerals, mob drops, containers and redstone etc. 28 func Items() Category { 29 return Category{category: 4} 30 } 31 32 // Uint8 ... 33 func (c Category) Uint8() uint8 { 34 return c.category 35 } 36 37 // WithGroup returns the category with the provided subgroup. This can be used to put an item inside a group such as 38 // swords, food or different types of blocks. 39 func (c Category) WithGroup(group string) Category { 40 c.group = group 41 return c 42 } 43 44 // String ... 45 func (c Category) String() string { 46 switch c.category { 47 case 1: 48 return "construction" 49 case 2: 50 return "nature" 51 case 3: 52 return "equipment" 53 case 4: 54 return "items" 55 } 56 panic("should never happen") 57 } 58 59 // Group ... 60 func (c Category) Group() string { 61 if len(c.group) > 0 { 62 return "itemGroup.name." + c.group 63 } 64 return "" 65 }