github.com/df-mc/dragonfly@v0.9.13/server/item/rabbit.go (about)

     1  package item
     2  
     3  import "github.com/df-mc/dragonfly/server/world"
     4  
     5  // Rabbit is a food item obtained from rabbits. It can be cooked in a furnace, smoker, or campfire.
     6  type Rabbit struct {
     7  	defaultFood
     8  
     9  	// Cooked is whether the rabbit is cooked.
    10  	Cooked bool
    11  }
    12  
    13  // Consume ...
    14  func (r Rabbit) Consume(_ *world.World, c Consumer) Stack {
    15  	if r.Cooked {
    16  		c.Saturate(5, 6)
    17  	} else {
    18  		c.Saturate(3, 1.8)
    19  	}
    20  	return Stack{}
    21  }
    22  
    23  // SmeltInfo ...
    24  func (r Rabbit) SmeltInfo() SmeltInfo {
    25  	if r.Cooked {
    26  		return SmeltInfo{}
    27  	}
    28  	return newFoodSmeltInfo(NewStack(Rabbit{Cooked: true}, 1), 0.35)
    29  }
    30  
    31  // EncodeItem ...
    32  func (r Rabbit) EncodeItem() (name string, meta int16) {
    33  	if r.Cooked {
    34  		return "minecraft:cooked_rabbit", 0
    35  	}
    36  	return "minecraft:rabbit", 0
    37  }