github.com/df-mc/dragonfly@v0.9.13/server/item/rotten_flesh.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  // RottenFlesh is a food item that can be eaten by the player, at the high risk of inflicting Hunger.
    11  type RottenFlesh struct {
    12  	defaultFood
    13  }
    14  
    15  // Consume ...
    16  func (RottenFlesh) Consume(_ *world.World, c Consumer) Stack {
    17  	c.Saturate(4, 0.8)
    18  	if rand.Float64() < 0.8 {
    19  		c.AddEffect(effect.New(effect.Hunger{}, 1, 30*time.Second))
    20  	}
    21  	return Stack{}
    22  }
    23  
    24  // EncodeItem ...
    25  func (RottenFlesh) EncodeItem() (name string, meta int16) {
    26  	return "minecraft:rotten_flesh", 0
    27  }