github.com/df-mc/dragonfly@v0.9.13/server/item/chicken.go (about) 1 package item 2 3 import ( 4 "github.com/df-mc/dragonfly/server/entity/effect" 5 "github.com/df-mc/dragonfly/server/world" 6 "math/rand" 7 "time" 8 ) 9 10 // Chicken is a food item obtained from chickens. It can be cooked in a furnace, smoker, or campfire. 11 type Chicken struct { 12 defaultFood 13 14 // Cooked is whether the chicken is cooked. 15 Cooked bool 16 } 17 18 // Consume ... 19 func (c Chicken) Consume(_ *world.World, co Consumer) Stack { 20 if c.Cooked { 21 co.Saturate(6, 7.2) 22 } else { 23 co.Saturate(2, 1.2) 24 if rand.Float64() < 0.3 { 25 co.AddEffect(effect.New(effect.Hunger{}, 1, 30*time.Second)) 26 } 27 } 28 return Stack{} 29 } 30 31 // SmeltInfo ... 32 func (c Chicken) SmeltInfo() SmeltInfo { 33 if c.Cooked { 34 return SmeltInfo{} 35 } 36 return newFoodSmeltInfo(NewStack(Chicken{Cooked: true}, 1), 0.35) 37 } 38 39 // EncodeItem ... 40 func (c Chicken) EncodeItem() (name string, meta int16) { 41 if c.Cooked { 42 return "minecraft:cooked_chicken", 0 43 } 44 return "minecraft:chicken", 0 45 }