-
Notifications
You must be signed in to change notification settings - Fork 141
/
durability.go
29 lines (26 loc) · 1.09 KB
/
durability.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package item
// Durable represents an item that has durability, and may therefore be broken. Some durable items, when
// broken, create a new item, such as an elytra.
type Durable interface {
// DurabilityInfo returns info related to the durability of an item.
DurabilityInfo() DurabilityInfo
}
// DurabilityInfo is the info of a durable item. It include fields that must be set in order to define
// durability related behaviour.
type DurabilityInfo struct {
// MaxDurability is the maximum durability that this item may have. This field must be positive for the
// durability to function properly.
MaxDurability int
// BrokenItem is the item created when the item is broken. For most durable items, this is simply an
// air item.
BrokenItem func() Stack
// AttackDurability and BreakDurability are the losses in durability that the item sustains when they are
// used to do the respective actions.
AttackDurability, BreakDurability int
}
// simpleItem is a convenience function to return an item stack as BrokenItem.
func simpleItem(i Stack) func() Stack {
return func() Stack {
return i
}
}