github.com/df-mc/dragonfly@v0.9.13/server/item/poisonous_potato.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  // PoisonousPotato is a type of potato that can poison the player.
    11  type PoisonousPotato struct {
    12  	defaultFood
    13  }
    14  
    15  // Consume ...
    16  func (p PoisonousPotato) Consume(_ *world.World, c Consumer) Stack {
    17  	c.Saturate(2, 1.2)
    18  	if rand.Float64() < 0.6 {
    19  		c.AddEffect(effect.New(effect.Poison{}, 1, 5*time.Second))
    20  	}
    21  	return Stack{}
    22  }
    23  
    24  // EncodeItem ...
    25  func (p PoisonousPotato) EncodeItem() (name string, meta int16) {
    26  	return "minecraft:poisonous_potato", 0
    27  }