up3
Build and deploy / Build (push) Has been cancelled
Build and deploy / Update Contributors (push) Has been cancelled
Build and deploy / Deploy (push) Has been cancelled

This commit is contained in:
2026-07-09 08:33:57 +08:00
commit 26ed99fda6
845 changed files with 75419 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
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 includes 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
// Persistent is true if the item is persistent, i.e. it will not be destroyed when at its last durability stage.
Persistent bool
}
// Repairable represents a durable item that can be repaired by other items.
type Repairable interface {
Durable
RepairableBy(i Stack) bool
}
// simpleItem is a convenience function to return an item stack as BrokenItem.
func simpleItem(i Stack) func() Stack {
return func() Stack {
return i
}
}