Documentation ¶
Index ¶
- Constants
- Variables
- func AllDyes() []world.Item
- func EnchantmentID(e EnchantmentType) (int, bool)
- func RegisterEnchantment(id int, enchantment EnchantmentType)
- type AmethystShard
- type Apple
- type Armour
- type ArmourTier
- type Arrow
- type Axe
- func (a Axe) AttackDamage() float64
- func (a Axe) BaseMiningEfficiency(world.Block) float64
- func (a Axe) DurabilityInfo() DurabilityInfo
- func (a Axe) EncodeItem() (name string, meta int16)
- func (a Axe) HarvestLevel() int
- func (a Axe) MaxCount() int
- func (a Axe) ToolType() ToolType
- func (a Axe) UseOnBlock(pos cube.Pos, _ cube.Face, _ mgl64.Vec3, w *world.World, _ User, ...) bool
- type BakedPotato
- type BeaconPayment
- type Beef
- type Beetroot
- type BeetrootSoup
- type BlazePowder
- type BlazeRod
- type Bone
- type BoneMeal
- type BoneMealAffected
- type Book
- type Boots
- func (b Boots) Boots() bool
- func (b Boots) DefencePoints() float64
- func (b Boots) DurabilityInfo() DurabilityInfo
- func (b Boots) EncodeItem() (name string, meta int16)
- func (b Boots) KnockBackResistance() float64
- func (b Boots) MaxCount() int
- func (b Boots) Use(_ *world.World, _ User, ctx *UseContext) bool
- type BootsType
- type Bow
- type Bowl
- type Bread
- type Brick
- type Bucket
- type Carrier
- type CarrotOnAStick
- type Charcoal
- type Chestplate
- func (c Chestplate) Chestplate() bool
- func (c Chestplate) DefencePoints() float64
- func (c Chestplate) DurabilityInfo() DurabilityInfo
- func (c Chestplate) EncodeItem() (name string, meta int16)
- func (c Chestplate) KnockBackResistance() float64
- func (c Chestplate) MaxCount() int
- func (c Chestplate) Use(_ *world.World, _ User, ctx *UseContext) bool
- type ChestplateType
- type Chicken
- type ClayBall
- type Clock
- type Coal
- type Cod
- type Colour
- func ColourBlack() Colour
- func ColourBlue() Colour
- func ColourBrown() Colour
- func ColourCyan() Colour
- func ColourGreen() Colour
- func ColourGrey() Colour
- func ColourLightBlue() Colour
- func ColourLightGrey() Colour
- func ColourLime() Colour
- func ColourMagenta() Colour
- func ColourOrange() Colour
- func ColourPink() Colour
- func ColourPurple() Colour
- func ColourRed() Colour
- func ColourWhite() Colour
- func ColourYellow() Colour
- func Colours() []Colour
- type Compass
- type Consumable
- type Consumer
- type Cookie
- type Cooldown
- type CopperIngot
- type Diamond
- type DragonBreath
- type DriedKelp
- type DurabilityInfo
- type Durable
- type Dye
- type Emerald
- type EnchantedApple
- type Enchantment
- type EnchantmentType
- type EnderPearl
- type Feather
- type FermentedSpiderEye
- type Flint
- type FlintAndSteel
- type GhastTear
- type GlassBottle
- type GlisteringMelonSlice
- type GlowstoneDust
- type GoldIngot
- type GoldNugget
- type GoldenApple
- type GoldenCarrot
- type Gunpowder
- type HeartOfTheSea
- type Helmet
- func (h Helmet) DefencePoints() float64
- func (h Helmet) DurabilityInfo() DurabilityInfo
- func (h Helmet) EncodeItem() (name string, meta int16)
- func (h Helmet) Helmet() bool
- func (h Helmet) KnockBackResistance() float64
- func (h Helmet) MaxCount() int
- func (h Helmet) Use(_ *world.World, _ User, ctx *UseContext) bool
- type HelmetType
- type Hoe
- func (h Hoe) AttackDamage() float64
- func (h Hoe) BaseMiningEfficiency(world.Block) float64
- func (h Hoe) DurabilityInfo() DurabilityInfo
- func (h Hoe) EncodeItem() (name string, meta int16)
- func (h Hoe) HarvestLevel() int
- func (h Hoe) MaxCount() int
- func (h Hoe) ToolType() ToolType
- func (h Hoe) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, _ User, ...) bool
- type Honeycomb
- type InkSac
- type IronIngot
- type IronNugget
- type LapisLazuli
- type Leather
- type Leggings
- func (l Leggings) DefencePoints() float64
- func (l Leggings) DurabilityInfo() DurabilityInfo
- func (l Leggings) EncodeItem() (name string, meta int16)
- func (l Leggings) KnockBackResistance() float64
- func (l Leggings) Leggings() bool
- func (l Leggings) MaxCount() int
- func (l Leggings) Use(_ *world.World, _ User, ctx *UseContext) bool
- type LeggingsType
- type MagmaCream
- type MaxCounter
- type MelonSlice
- type MushroomStew
- type Mutton
- type NautilusShell
- type NetherBrick
- type NetherQuartz
- type NetherStar
- type NetheriteIngot
- type NetheriteScrap
- type Paper
- type PhantomMembrane
- type Pickaxe
- func (p Pickaxe) AttackDamage() float64
- func (p Pickaxe) BaseMiningEfficiency(world.Block) float64
- func (p Pickaxe) DurabilityInfo() DurabilityInfo
- func (p Pickaxe) EncodeItem() (name string, meta int16)
- func (p Pickaxe) HarvestLevel() int
- func (p Pickaxe) MaxCount() int
- func (p Pickaxe) ToolType() ToolType
- type PoisonousPotato
- type PoppedChorusFruit
- type Porkchop
- type Potion
- type PrismarineCrystals
- type PrismarineShard
- type Pufferfish
- type PumpkinPie
- type Rabbit
- type RabbitFoot
- type RabbitHide
- type RabbitStew
- type RawCopper
- type RawGold
- type RawIron
- type Releasable
- type Releaser
- type RottenFlesh
- type Salmon
- type Scute
- type Shears
- func (s Shears) BaseMiningEfficiency(world.Block) float64
- func (s Shears) DurabilityInfo() DurabilityInfo
- func (s Shears) EncodeItem() (name string, meta int16)
- func (s Shears) HarvestLevel() int
- func (s Shears) MaxCount() int
- func (s Shears) ToolType() ToolType
- func (s Shears) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, _ User, ...) bool
- type Shovel
- func (s Shovel) AttackDamage() float64
- func (s Shovel) BaseMiningEfficiency(world.Block) float64
- func (s Shovel) DurabilityInfo() DurabilityInfo
- func (s Shovel) EncodeItem() (name string, meta int16)
- func (s Shovel) HarvestLevel() int
- func (s Shovel) MaxCount() int
- func (s Shovel) ToolType() ToolType
- func (s Shovel) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, _ User, ...) bool
- type ShulkerShell
- type Slimeball
- type Snowball
- type SpiderEye
- type SplashPotion
- type Spyglass
- type Stack
- func (s Stack) AddStack(s2 Stack) (a, b Stack)
- func (s Stack) AttackDamage() float64
- func (s Stack) Comparable(s2 Stack) bool
- func (s Stack) Count() int
- func (s Stack) CustomName() string
- func (s Stack) Damage(d int) Stack
- func (s Stack) Durability() int
- func (s Stack) Empty() bool
- func (s Stack) Enchantment(enchant EnchantmentType) (Enchantment, bool)
- func (s Stack) Enchantments() []Enchantment
- func (s Stack) Equal(s2 Stack) bool
- func (s Stack) Grow(n int) Stack
- func (s Stack) Item() world.Item
- func (s Stack) Lore() []string
- func (s Stack) MaxCount() int
- func (s Stack) MaxDurability() int
- func (s Stack) String() string
- func (s Stack) Value(key string) (val interface{}, ok bool)
- func (s Stack) Values() map[string]interface{}
- func (s Stack) WithCustomName(a ...interface{}) Stack
- func (s Stack) WithDurability(d int) Stack
- func (s Stack) WithEnchantments(enchants ...Enchantment) Stack
- func (s Stack) WithLore(lines ...string) Stack
- func (s Stack) WithValue(key string, val interface{}) Stack
- func (s Stack) WithoutEnchantments(enchants ...EnchantmentType) Stack
- type Stick
- type Sugar
- type Sword
- type Tool
- type ToolNone
- type ToolTier
- type ToolType
- type Totem
- type TropicalFish
- type TurtleShell
- func (t TurtleShell) DefencePoints() float64
- func (t TurtleShell) DurabilityInfo() DurabilityInfo
- func (t TurtleShell) EncodeItem() (name string, meta int16)
- func (t TurtleShell) Helmet() bool
- func (t TurtleShell) KnockBackResistance() float64
- func (t TurtleShell) MaxCount() int
- func (t TurtleShell) Use(_ *world.World, _ User, ctx *UseContext) bool
- type Usable
- type UsableOnBlock
- type UsableOnEntity
- type UseContext
- type User
- type WarpedFungusOnAStick
- type Weapon
- type Wheat
Constants ¶
const DefaultConsumeDuration = (time.Second * 161) / 100
DefaultConsumeDuration is the default duration that consuming an item takes. Dried kelp takes half this time to be consumed.
Variables ¶
var ( // ArmourTierLeather is the ArmourTier of leather armour. ArmourTierLeather = ArmourTier{BaseDurability: 55, Name: "leather"} // ArmourTierGold is the ArmourTier of gold armour. ArmourTierGold = ArmourTier{BaseDurability: 77, Name: "golden"} // ArmourTierChain is the ArmourTier of chain armour. ArmourTierChain = ArmourTier{BaseDurability: 166, Name: "chainmail"} // ArmourTierIron is the ArmourTier of iron armour. ArmourTierIron = ArmourTier{BaseDurability: 165, Name: "iron"} // ArmourTierDiamond is the ArmourTier of diamond armour. ArmourTierDiamond = ArmourTier{BaseDurability: 363, Name: "diamond"} // ArmourTierNetherite is the ArmourTier of netherite armour. ArmourTierNetherite = ArmourTier{BaseDurability: 408, KnockBackResistance: 0.1, Name: "netherite"} )
var ( // TypeNone is the ToolType of items that are not tools. TypeNone = ToolType{-1} // TypePickaxe is the ToolType for pickaxes. TypePickaxe = ToolType{0} // TypeAxe is the ToolType for axes. TypeAxe = ToolType{1} // TypeHoe is the ToolType for hoes. TypeHoe = ToolType{2} // TypeShovel is the ToolType for shovels. TypeShovel = ToolType{3} // TypeShears is the ToolType for shears. TypeShears = ToolType{4} // TypeSword is the ToolType for swords. TypeSword = ToolType{5} // ToolTierWood is the ToolTier of wood tools. This is the lowest possible tier. ToolTierWood = ToolTier{HarvestLevel: 1, Durability: 59, BaseMiningEfficiency: 2, BaseAttackDamage: 1, Name: "wooden"} // ToolTierGold is the ToolTier of gold tools. ToolTierGold = ToolTier{HarvestLevel: 1, Durability: 32, BaseMiningEfficiency: 12, BaseAttackDamage: 1, Name: "golden"} // ToolTierStone is the ToolTier of stone tools. ToolTierStone = ToolTier{HarvestLevel: 2, Durability: 131, BaseMiningEfficiency: 4, BaseAttackDamage: 2, Name: "stone"} // ToolTierIron is the ToolTier of iron tools. ToolTierIron = ToolTier{HarvestLevel: 3, Durability: 250, BaseMiningEfficiency: 6, BaseAttackDamage: 3, Name: "iron"} // ToolTierDiamond is the ToolTier of diamond tools. ToolTierDiamond = ToolTier{HarvestLevel: 4, Durability: 1561, BaseMiningEfficiency: 8, BaseAttackDamage: 4, Name: "diamond"} // ToolTierNetherite is the ToolTier of netherite tools. This is the highest possible tier. ToolTierNetherite = ToolTier{HarvestLevel: 4, Durability: 2031, BaseMiningEfficiency: 9, BaseAttackDamage: 5, Name: "netherite"} )
Functions ¶
func EnchantmentID ¶
func EnchantmentID(e EnchantmentType) (int, bool)
EnchantmentID attempts to return the ID the enchantment was registered with. If found, the id is returned and the bool true.
func RegisterEnchantment ¶
func RegisterEnchantment(id int, enchantment EnchantmentType)
RegisterEnchantment registers an enchantment with the ID passed. Once registered, enchantments may be received by instantiating an EnchantmentType struct (e.g. enchantment.Protection{})
Types ¶
type AmethystShard ¶
type AmethystShard struct{}
AmethystShard is a crystalline mineral obtained from mining a fully grown amethyst cluster.
func (AmethystShard) EncodeItem ¶
func (AmethystShard) EncodeItem() (name string, meta int16)
EncodeItem ...
type Apple ¶
type Apple struct {
// contains filtered or unexported fields
}
Apple is a food item that can be eaten by the player.
type Armour ¶
type Armour interface { // DefencePoints returns the defence points that the armour provides when worn. DefencePoints() float64 // KnockBackResistance returns a number from 0-1 that decides the amount of knock back force that is // resisted upon being attacked. 1 knock back resistance point client-side translates to 10% knock back // reduction. KnockBackResistance() float64 }
Armour represents an item that may be worn as armour. Generally, these items provide armour points, which reduce damage taken. Some pieces of armour also provide toughness, which negates damage proportional to the total damage dealt.
type ArmourTier ¶
type ArmourTier struct { // BaseDurability is the base durability of armour with this tier. This is otherwise the durability of // the helmet with this tier. BaseDurability float64 // KnockBackResistance is a number from 0-1 that decides the amount of knock back force that is resisted // upon being attacked. 1 knock back resistance point client-side translates to 10% knock back reduction. KnockBackResistance float64 // Name is the name of the tier. Name string }
ArmourTier represents the tier, or material, that a piece of armour is made of.
type Arrow ¶
Arrow is used as ammunition for bows, crossbows, and dispensers. Arrows can be modified to imbue status effects on players and mobs.
type Axe ¶
type Axe struct { // Tier is the tier of the axe. Tier ToolTier }
Axe is a tool generally used for mining wood-like blocks. It may also be used to break some plant-like blocks at a faster pace such as pumpkins.
func (Axe) BaseMiningEfficiency ¶
BaseMiningEfficiency ...
type BakedPotato ¶
type BakedPotato struct {
// contains filtered or unexported fields
}
BakedPotato is a food item that can be eaten by the player.
func (BakedPotato) AlwaysConsumable ¶
func (BakedPotato) AlwaysConsumable() bool
AlwaysConsumable ...
func (BakedPotato) Consume ¶
func (BakedPotato) Consume(_ *world.World, c Consumer) Stack
Consume ...
func (BakedPotato) ConsumeDuration ¶
ConsumeDuration ...
func (BakedPotato) EncodeItem ¶
func (BakedPotato) EncodeItem() (name string, meta int16)
EncodeItem ...
type BeaconPayment ¶
type BeaconPayment interface {
PayableForBeacon() bool
}
BeaconPayment represents an item that may be used as payment for a beacon to select effects to be broadcast to surrounding players.
type Beef ¶
type Beef struct { // Cooked is whether the beef is cooked. Cooked bool // contains filtered or unexported fields }
Beef is a food item obtained from cows. It can be cooked in a furnace, smoker, or campfire.
type Beetroot ¶
type Beetroot struct {
// contains filtered or unexported fields
}
Beetroot is a food and dye ingredient.
func (Beetroot) ConsumeDuration ¶
ConsumeDuration ...
func (Beetroot) EncodeItem ¶
EncodeItem ...
type BeetrootSoup ¶
type BeetrootSoup struct {
// contains filtered or unexported fields
}
BeetrootSoup is an unstackable food item.
func (BeetrootSoup) AlwaysConsumable ¶
func (BeetrootSoup) AlwaysConsumable() bool
AlwaysConsumable ...
func (BeetrootSoup) Consume ¶
func (BeetrootSoup) Consume(_ *world.World, c Consumer) Stack
Consume ...
func (BeetrootSoup) ConsumeDuration ¶
ConsumeDuration ...
func (BeetrootSoup) EncodeItem ¶
func (BeetrootSoup) EncodeItem() (name string, meta int16)
EncodeItem ...
type BlazePowder ¶
type BlazePowder struct{}
BlazePowder is an item made from a blaze rod obtained from blazes.
func (BlazePowder) EncodeItem ¶
func (BlazePowder) EncodeItem() (name string, meta int16)
EncodeItem ...
type Bone ¶
type Bone struct{}
Bone is an item primarily obtained as a drop from skeletons and their variants.
type BoneMeal ¶
type BoneMeal struct{}
BoneMeal is an item used to force growth in plants & crops.
func (BoneMeal) EncodeItem ¶
EncodeItem ...
type BoneMealAffected ¶
type BoneMealAffected interface { // BoneMeal attempts to affect the block using a bone meal item. BoneMeal(pos cube.Pos, w *world.World) bool }
BoneMealAffected represents a block that is affected when bone meal is used on it.
type Boots ¶
type Boots struct { // Tier is the tier of the boots. Tier ArmourTier }
Boots are a defensive item that may be equipped in the boots armour slot. They come in several tiers, like leather, gold, chain, iron and diamond.
func (Boots) KnockBackResistance ¶
KnockBackResistance ...
type Bow ¶
type Bow struct{}
Bow is a ranged weapon that fires arrows.
func (Bow) Release ¶
func (Bow) Release(releaser Releaser, duration time.Duration, ctx *UseContext)
Release ...
func (Bow) Requirements ¶
Requirements returns the required items to release this item.
type Bread ¶
type Bread struct {
// contains filtered or unexported fields
}
Bread is a food item that can be eaten by the player.
type Brick ¶
type Brick struct{}
Brick is an item made from clay, and is used for making bricks and flower pots.
type Bucket ¶
type Bucket struct { // Content is the content that the bucket has. By default, this value resolves to an empty bucket. Content world.Liquid }
Bucket is a tool used to carry water, lava, milk and fish.
type Carrier ¶
type Carrier interface { world.Entity // HeldItems returns the items currently held by the entity. Viewers of the entity will be able to see // these items. HeldItems() (mainHand, offHand Stack) }
Carrier represents an entity that is able to carry an item.
type CarrotOnAStick ¶
type CarrotOnAStick struct{}
CarrotOnAStick is an item that can be used to control saddled pigs.
func (CarrotOnAStick) EncodeItem ¶
func (CarrotOnAStick) EncodeItem() (name string, meta int16)
EncodeItem ...
type Chestplate ¶
type Chestplate struct { // Tier is the tier of the chestplate. Tier ArmourTier }
Chestplate is a defensive item that may be equipped in the chestplate slot. Generally, chestplates provide the most defence of all armour items.
func (Chestplate) DurabilityInfo ¶
func (c Chestplate) DurabilityInfo() DurabilityInfo
DurabilityInfo ...
func (Chestplate) EncodeItem ¶
func (c Chestplate) EncodeItem() (name string, meta int16)
EncodeItem ...
func (Chestplate) KnockBackResistance ¶
func (c Chestplate) KnockBackResistance() float64
KnockBackResistance ...
func (Chestplate) Use ¶
func (c Chestplate) Use(_ *world.World, _ User, ctx *UseContext) bool
Use handles the using of a chestplate to auto-equip it in the designated armour slot.
type ChestplateType ¶
ChestplateType is an Armour item that can be worn in the chestplate slot.
type Chicken ¶
type Chicken struct { // Cooked is whether the chicken is cooked. Cooked bool // contains filtered or unexported fields }
Chicken is a food item obtained from chickens. It can be cooked in a furnace, smoker, or campfire.
func (Chicken) ConsumeDuration ¶
ConsumeDuration ...
type Cod ¶
type Cod struct { // Cooked is whether the cod is cooked. Cooked bool // contains filtered or unexported fields }
Cod is a food item obtained from cod. It can be cooked in a furnace, smoker, or campfire.
type Colour ¶
type Colour struct {
// contains filtered or unexported fields
}
Colour represents the colour of a block. Typically, Minecraft blocks have a total of 16 different colours.
type Consumable ¶
type Consumable interface { // AlwaysConsumable specifies if the item is always consumable. Normal food can generally only be consumed // when the food bar is not full or when in creative mode. Returning true here means the item can always // be consumed, like golden apples or potions. AlwaysConsumable() bool // ConsumeDuration is the duration consuming the item takes. If the player is using the item for at least // this duration, the item will be consumed and have its Consume method called. ConsumeDuration() time.Duration // Consume consumes one item of the Stack that the Consumable is in. The Stack returned is added back to // the inventory after consuming the item. For potions, for example, an empty bottle is returned. Consume(w *world.World, c Consumer) Stack }
Consumable represents an item that may be consumed by a player. If an item implements this interface, a player may use and hold the item to consume it.
type Consumer ¶
type Consumer interface { User // Saturate saturates the Consumer's food bar by the amount of food points passed and the saturation by // up to as many saturation points as passed. The final saturation will never exceed the final food level. Saturate(food int, saturation float64) // AddEffect adds an effect.Effect to the Consumer. If the effect is instant, it is applied to the Consumer // immediately. If not, the effect is applied to the consumer every time the Tick method is called. // AddEffect will overwrite any effects present if the level of the effect is higher than the existing one, or // if the effects' levels are equal and the new effect has a longer duration. AddEffect(e effect.Effect) }
Consumer represents a User that is able to consume Consumable items.
type Cookie ¶
type Cookie struct {
// contains filtered or unexported fields
}
Cookie is a food item that can be obtained in large quantities, but do not restore hunger or saturation significantly.
type CopperIngot ¶
type CopperIngot struct{}
CopperIngot is a metal ingot melted from copper ore.
func (CopperIngot) EncodeItem ¶
func (c CopperIngot) EncodeItem() (name string, meta int16)
EncodeItem ...
type Diamond ¶
type Diamond struct{}
Diamond is a rare mineral obtained from diamond ore or loot chests.
type DragonBreath ¶
type DragonBreath struct{}
DragonBreath is a brewing item that is used solely to make lingering potions.
func (DragonBreath) EncodeItem ¶
func (DragonBreath) EncodeItem() (name string, meta int16)
EncodeItem ...
type DriedKelp ¶
type DriedKelp struct{}
DriedKelp is a food item that can be quickly eaten by the player.
func (DriedKelp) ConsumeDuration ¶
ConsumeDuration ...
func (DriedKelp) EncodeItem ¶
EncodeItem ...
type DurabilityInfo ¶
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 }
DurabilityInfo is the info of a durable item. It includes fields that must be set in order to define durability related behaviour.
type Durable ¶
type Durable interface { // DurabilityInfo returns info related to the durability of an item. DurabilityInfo() DurabilityInfo }
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 Dye ¶
type Dye struct { // Colour is the colour of the dye. Colour Colour }
Dye is an item that comes in 16 colours which allows you to colour blocks like concrete and sheep.
type Emerald ¶
type Emerald struct{}
Emerald is a rare mineral obtained from emerald ore or from villagers.
type EnchantedApple ¶
type EnchantedApple struct{}
EnchantedApple is a rare variant of the golden apple that has stronger effects.
func (EnchantedApple) AlwaysConsumable ¶
func (EnchantedApple) AlwaysConsumable() bool
AlwaysConsumable ...
func (EnchantedApple) Consume ¶
func (EnchantedApple) Consume(_ *world.World, c Consumer) Stack
Consume ...
func (EnchantedApple) ConsumeDuration ¶
func (EnchantedApple) ConsumeDuration() time.Duration
ConsumeDuration ...
func (EnchantedApple) EncodeItem ¶
func (EnchantedApple) EncodeItem() (name string, meta int16)
EncodeItem ...
type Enchantment ¶
type Enchantment struct {
// contains filtered or unexported fields
}
Enchantment is an enchantment that can be applied to a Stack. It holds an EnchantmentType and level that influences the power of the enchantment.
func NewEnchantment ¶
func NewEnchantment(t EnchantmentType, lvl int) Enchantment
NewEnchantment creates and returns an Enchantment with a specific EnchantmentType and level. If the level passed exceeds EnchantmentType.MaxLevel, NewEnchantment panics.
func (Enchantment) Level ¶
func (e Enchantment) Level() int
Level returns the current level of the Enchantment as passed to NewEnchantment upon construction.
func (Enchantment) Type ¶
func (e Enchantment) Type() EnchantmentType
Type returns the EnchantmentType of the Enchantment as passed to NewEnchantment upon construction.
type EnchantmentType ¶
type EnchantmentType interface { // Name returns the name of the enchantment. Name() string // MaxLevel returns the maximum level the enchantment should be able to have. MaxLevel() int // CompatibleWith is called when an enchantment is added to an item. It can be used to check if // the enchantment is compatible with the item stack based on the item type, current enchantments etc. CompatibleWith(s Stack) bool }
EnchantmentType represents an enchantment type that can be applied to a Stack, with specific behaviour that modifies the Stack's behaviour. An instance of an EnchantmentType may be created using NewEnchantment.
func EnchantmentByID ¶
func EnchantmentByID(id int) (EnchantmentType, bool)
EnchantmentByID attempts to return an enchantment by the ID it was registered with. If found, the enchantment found is returned and the bool true.
type EnderPearl ¶
type EnderPearl struct{}
EnderPearl is a smooth, greenish-blue item used to teleport and to make an eye of ender.
func (EnderPearl) EncodeItem ¶
func (EnderPearl) EncodeItem() (name string, meta int16)
EncodeItem ...
func (EnderPearl) Use ¶
func (e EnderPearl) Use(w *world.World, user User, ctx *UseContext) bool
Use ...
type Feather ¶
type Feather struct{}
Feather are items dropped by chickens and parrots, as well as tamed cats as morning gifts.
type FermentedSpiderEye ¶
type FermentedSpiderEye struct{}
FermentedSpiderEye is a brewing ingredient.
func (FermentedSpiderEye) EncodeItem ¶
func (FermentedSpiderEye) EncodeItem() (name string, meta int16)
EncodeItem ...
type FlintAndSteel ¶
type FlintAndSteel struct{}
FlintAndSteel is an item used to light blocks on fire.
func (FlintAndSteel) DurabilityInfo ¶
func (f FlintAndSteel) DurabilityInfo() DurabilityInfo
DurabilityInfo ...
func (FlintAndSteel) EncodeItem ¶
func (f FlintAndSteel) EncodeItem() (name string, meta int16)
EncodeItem ...
func (FlintAndSteel) UseOnBlock ¶
func (f FlintAndSteel) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, _ User, ctx *UseContext) bool
UseOnBlock ...
type GhastTear ¶
type GhastTear struct{}
GhastTear is a brewing item dropped by ghasts.
func (GhastTear) EncodeItem ¶
EncodeItem ...
type GlassBottle ¶
type GlassBottle struct{}
GlassBottle is an item that can hold various liquids.
func (GlassBottle) EncodeItem ¶
func (g GlassBottle) EncodeItem() (name string, meta int16)
EncodeItem ...
func (GlassBottle) UseOnBlock ¶
func (g GlassBottle) UseOnBlock(pos cube.Pos, _ cube.Face, _ mgl64.Vec3, w *world.World, _ User, ctx *UseContext) bool
UseOnBlock ...
type GlisteringMelonSlice ¶
type GlisteringMelonSlice struct{}
GlisteringMelonSlice is an inedible item used for brewing potions of healing. It is also one of the many potion ingredients that can be used to make mundane potions.
func (GlisteringMelonSlice) EncodeItem ¶
func (GlisteringMelonSlice) EncodeItem() (name string, meta int16)
EncodeItem ...
type GlowstoneDust ¶
type GlowstoneDust struct{}
GlowstoneDust is dropped when breaking the glowstone block.
func (GlowstoneDust) EncodeItem ¶
func (g GlowstoneDust) EncodeItem() (name string, meta int16)
EncodeItem ...
type GoldIngot ¶
type GoldIngot struct{}
GoldIngot is a metal ingot melted from raw gold or obtained from loot chests.
func (GoldIngot) EncodeItem ¶
EncodeItem ...
type GoldNugget ¶
type GoldNugget struct{}
GoldNugget is an item used to craft gold ingots & other various gold items.
func (GoldNugget) EncodeItem ¶
func (GoldNugget) EncodeItem() (name string, meta int16)
EncodeItem ...
type GoldenApple ¶
type GoldenApple struct{}
GoldenApple is a special food item that bestows beneficial effects.
func (GoldenApple) AlwaysConsumable ¶
func (e GoldenApple) AlwaysConsumable() bool
AlwaysConsumable ...
func (GoldenApple) Consume ¶
func (e GoldenApple) Consume(_ *world.World, c Consumer) Stack
Consume ...
func (GoldenApple) ConsumeDuration ¶
func (e GoldenApple) ConsumeDuration() time.Duration
ConsumeDuration ...
func (GoldenApple) EncodeItem ¶
func (e GoldenApple) EncodeItem() (name string, meta int16)
EncodeItem ...
type GoldenCarrot ¶
type GoldenCarrot struct {
// contains filtered or unexported fields
}
GoldenCarrot is a valuable food item and brewing ingredient. It provides the second most saturation in the game, behind Suspicious Stew crafted with either a Dandelion or Blue Orchid.
func (GoldenCarrot) AlwaysConsumable ¶
func (GoldenCarrot) AlwaysConsumable() bool
AlwaysConsumable ...
func (GoldenCarrot) Consume ¶
func (GoldenCarrot) Consume(_ *world.World, c Consumer) Stack
Consume ...
func (GoldenCarrot) ConsumeDuration ¶
ConsumeDuration ...
func (GoldenCarrot) EncodeItem ¶
func (GoldenCarrot) EncodeItem() (name string, meta int16)
EncodeItem ...
type Gunpowder ¶
type Gunpowder struct{}
Gunpowder is an item that is used for explosion-related recipes.
func (Gunpowder) EncodeItem ¶
EncodeItem ...
type HeartOfTheSea ¶
type HeartOfTheSea struct{}
HeartOfTheSea is a rare item that can be crafted into a conduit.
func (HeartOfTheSea) EncodeItem ¶
func (HeartOfTheSea) EncodeItem() (name string, meta int16)
EncodeItem ...
type Helmet ¶
type Helmet struct { // Tier is the tier of the armour. Tier ArmourTier }
Helmet is a defensive item that may be worn in the head slot. It comes in several tiers, each with different defence points and armour toughness.
func (Helmet) KnockBackResistance ¶
KnockBackResistance ...
type HelmetType ¶
HelmetType is an Armour item that can be worn in the helmet slot.
type Hoe ¶
type Hoe struct {
Tier ToolTier
}
Hoe is a tool generally used to till dirt and grass blocks into farmland blocks for planting crops. Additionally, a Hoe can be used to break certain types of blocks such as Crimson and Hay Blocks.
func (Hoe) BaseMiningEfficiency ¶
BaseMiningEfficiency ...
func (Hoe) HarvestLevel ¶
HarvestLevel returns the level that this hoe is able to harvest. If a block has a harvest level above this one, this hoe won't be able to harvest it.
type Honeycomb ¶
type Honeycomb struct{}
Honeycomb is an item obtained from bee nests and beehives.
func (Honeycomb) EncodeItem ¶
EncodeItem ...
type InkSac ¶
type InkSac struct { // Glowing specifies if the ink sac is that of a glow squid. If true, it may be used on a sign to light up its text. Glowing bool }
InkSac is an item dropped by a squid upon death used to create black dye, dark prismarine and book and quill. The glowing variant, obtained by killing a glow squid, may be used to cause sign text to light up.
func (InkSac) UseOnBlock ¶
func (i InkSac) UseOnBlock(pos cube.Pos, _ cube.Face, _ mgl64.Vec3, w *world.World, _ User, ctx *UseContext) bool
UseOnBlock handles the logic of using an ink sac on a sign. Glowing ink sacs turn the text of these signs glowing, whereas normal ink sacs revert them back to non-glowing text.
type IronIngot ¶
type IronIngot struct{}
IronIngot is a metal ingot melted from raw iron or obtained from loot chests.
func (IronIngot) EncodeItem ¶
EncodeItem ...
type IronNugget ¶
type IronNugget struct{}
IronNugget is a piece of iron that can be obtained by smelting iron tools/weapons or iron/chainmail armor.
func (IronNugget) EncodeItem ¶
func (IronNugget) EncodeItem() (name string, meta int16)
EncodeItem ...
type LapisLazuli ¶
type LapisLazuli struct{}
LapisLazuli is a mineral used for enchanting and decoration.
func (LapisLazuli) EncodeItem ¶
func (LapisLazuli) EncodeItem() (name string, meta int16)
EncodeItem ...
type Leather ¶
type Leather struct{}
Leather is an animal skin used to make item frames, armor and books.
type Leggings ¶
type Leggings struct { // Tier is the tier of the leggings. Tier ArmourTier }
Leggings are a defensive item that may be equipped in the leggings armour slot. They come in several tiers, like leather, gold, chain, iron and diamond.
func (Leggings) DurabilityInfo ¶
func (l Leggings) DurabilityInfo() DurabilityInfo
DurabilityInfo ...
func (Leggings) EncodeItem ¶
EncodeItem ...
func (Leggings) KnockBackResistance ¶
KnockBackResistance ...
type LeggingsType ¶
LeggingsType are an Armour item that can be worn in the leggings slot.
type MagmaCream ¶
type MagmaCream struct{}
MagmaCream is an item used in brewing to create potions of Fire Resistance, and to build magma blocks.
func (MagmaCream) EncodeItem ¶
func (m MagmaCream) EncodeItem() (name string, meta int16)
EncodeItem ...
type MaxCounter ¶
type MaxCounter interface { // MaxCount returns the maximum number of items that a stack may be composed of. The number returned must // be positive. MaxCount() int }
MaxCounter represents an item that has a specific max count. By default, each item will be expected to have a maximum count of 64. MaxCounter may be implemented to change this behaviour.
type MelonSlice ¶
type MelonSlice struct{}
MelonSlice is a food item dropped by melon blocks.
func (MelonSlice) AlwaysConsumable ¶
func (m MelonSlice) AlwaysConsumable() bool
AlwaysConsumable ...
func (MelonSlice) Consume ¶
func (m MelonSlice) Consume(_ *world.World, c Consumer) Stack
Consume ...
func (MelonSlice) ConsumeDuration ¶
func (m MelonSlice) ConsumeDuration() time.Duration
ConsumeDuration ...
func (MelonSlice) EncodeItem ¶
func (m MelonSlice) EncodeItem() (name string, meta int16)
EncodeItem ...
type MushroomStew ¶
type MushroomStew struct {
// contains filtered or unexported fields
}
MushroomStew is a food item.
func (MushroomStew) AlwaysConsumable ¶
func (MushroomStew) AlwaysConsumable() bool
AlwaysConsumable ...
func (MushroomStew) Consume ¶
func (MushroomStew) Consume(_ *world.World, c Consumer) Stack
Consume ...
func (MushroomStew) ConsumeDuration ¶
ConsumeDuration ...
func (MushroomStew) EncodeItem ¶
func (MushroomStew) EncodeItem() (name string, meta int16)
EncodeItem ...
type Mutton ¶
type Mutton struct { // Cooked is whether the mutton is cooked. Cooked bool // contains filtered or unexported fields }
Mutton is a food item obtained from sheep. It can be cooked in a furnace, smoker, or campfire.
type NautilusShell ¶
type NautilusShell struct{}
NautilusShell is an item that is used for crafting conduits.
func (NautilusShell) EncodeItem ¶
func (NautilusShell) EncodeItem() (name string, meta int16)
EncodeItem ...
type NetherBrick ¶
type NetherBrick struct{}
NetherBrick is an item made by smelting netherrack in a furnace.
func (NetherBrick) EncodeItem ¶
func (NetherBrick) EncodeItem() (name string, meta int16)
EncodeItem ...
type NetherQuartz ¶
type NetherQuartz struct{}
NetherQuartz is a smooth, white mineral found in the Nether.
func (NetherQuartz) EncodeItem ¶
func (NetherQuartz) EncodeItem() (name string, meta int16)
EncodeItem ...
type NetherStar ¶
type NetherStar struct{}
NetherStar is a rare item dropped by the wither that is used solely to craft beacons.
func (NetherStar) EncodeItem ¶
func (NetherStar) EncodeItem() (name string, meta int16)
EncodeItem ...
type NetheriteIngot ¶
type NetheriteIngot struct{}
NetheriteIngot is a rare mineral crafted with 4 pieces of netherite scrap and 4 gold ingots.
func (NetheriteIngot) EncodeItem ¶
func (NetheriteIngot) EncodeItem() (name string, meta int16)
EncodeItem ...
func (NetheriteIngot) PayableForBeacon ¶
func (NetheriteIngot) PayableForBeacon() bool
PayableForBeacon ...
type NetheriteScrap ¶
type NetheriteScrap struct{}
NetheriteScrap is a material smelted from ancient debris, which is found in the Nether.
func (NetheriteScrap) EncodeItem ¶
func (NetheriteScrap) EncodeItem() (name string, meta int16)
EncodeItem ...
type PhantomMembrane ¶
type PhantomMembrane struct{}
PhantomMembrane are leathery skins obtained from killing phantoms.
func (PhantomMembrane) EncodeItem ¶
func (PhantomMembrane) EncodeItem() (name string, meta int16)
EncodeItem ...
type Pickaxe ¶
type Pickaxe struct { // Tier is the tier of the pickaxe. Tier ToolTier }
Pickaxe is a tool generally used for mining stone-like blocks and ores at a higher speed and to obtain their drops.
func (Pickaxe) AttackDamage ¶
AttackDamage returns the attack damage to the pickaxe.
func (Pickaxe) BaseMiningEfficiency ¶
BaseMiningEfficiency is the base efficiency of the pickaxe, when it comes to mining blocks. This decides the speed with which blocks can be mined.
func (Pickaxe) HarvestLevel ¶
HarvestLevel returns the level that this pickaxe is able to harvest. If a block has a harvest level above this one, this pickaxe won't be able to harvest it.
type PoisonousPotato ¶
type PoisonousPotato struct {
// contains filtered or unexported fields
}
PoisonousPotato is a type of potato that can poison the player.
func (PoisonousPotato) AlwaysConsumable ¶
func (PoisonousPotato) AlwaysConsumable() bool
AlwaysConsumable ...
func (PoisonousPotato) Consume ¶
func (p PoisonousPotato) Consume(_ *world.World, c Consumer) Stack
Consume ...
func (PoisonousPotato) ConsumeDuration ¶
ConsumeDuration ...
func (PoisonousPotato) EncodeItem ¶
func (p PoisonousPotato) EncodeItem() (name string, meta int16)
EncodeItem ...
type PoppedChorusFruit ¶
type PoppedChorusFruit struct{}
PoppedChorusFruit is an item obtained by smelting chorus fruit, and used to craft end rods and purpur blocks. Unlike raw chorus fruit, the popped fruit is inedible.
func (PoppedChorusFruit) EncodeItem ¶
func (PoppedChorusFruit) EncodeItem() (name string, meta int16)
EncodeItem ...
type Porkchop ¶
type Porkchop struct { // Cooked is whether the porkchop is cooked. Cooked bool // contains filtered or unexported fields }
Porkchop is a food item obtained from pigs. It can be cooked in a furnace, smoker, or campfire.
func (Porkchop) ConsumeDuration ¶
ConsumeDuration ...
func (Porkchop) EncodeItem ¶
EncodeItem ...
type PrismarineCrystals ¶
type PrismarineCrystals struct{}
PrismarineCrystals are items obtained by defeating guardians or elder guardians. They are used for crafting sea lanterns.
func (PrismarineCrystals) EncodeItem ¶
func (p PrismarineCrystals) EncodeItem() (name string, meta int16)
EncodeItem ...
type PrismarineShard ¶
type PrismarineShard struct{}
PrismarineShard is an item obtained by defeating guardians or elder guardians.
func (PrismarineShard) EncodeItem ¶
func (PrismarineShard) EncodeItem() (name string, meta int16)
EncodeItem ...
type Pufferfish ¶
type Pufferfish struct {
// contains filtered or unexported fields
}
Pufferfish is a poisonous type of fish that is used to brew water breathing potions.
func (Pufferfish) Consume ¶
func (p Pufferfish) Consume(_ *world.World, c Consumer) Stack
Consume ...
func (Pufferfish) ConsumeDuration ¶
ConsumeDuration ...
func (Pufferfish) EncodeItem ¶
func (p Pufferfish) EncodeItem() (name string, meta int16)
EncodeItem ...
type PumpkinPie ¶
type PumpkinPie struct {
// contains filtered or unexported fields
}
PumpkinPie is a food item that can be eaten by the player.
func (PumpkinPie) ConsumeDuration ¶
ConsumeDuration ...
func (PumpkinPie) EncodeItem ¶
func (PumpkinPie) EncodeItem() (name string, meta int16)
EncodeItem ...
type Rabbit ¶
type Rabbit struct { // Cooked is whether the rabbit is cooked. Cooked bool // contains filtered or unexported fields }
Rabbit is a food item obtained from rabbits. It can be cooked in a furnace, smoker, or campfire.
type RabbitFoot ¶
type RabbitFoot struct{}
RabbitFoot is a brewing item obtained from rabbits.
func (RabbitFoot) EncodeItem ¶
func (RabbitFoot) EncodeItem() (name string, meta int16)
EncodeItem ...
type RabbitHide ¶
type RabbitHide struct{}
RabbitHide is an item dropped by rabbits.
func (RabbitHide) EncodeItem ¶
func (RabbitHide) EncodeItem() (name string, meta int16)
EncodeItem ...
type RabbitStew ¶
type RabbitStew struct {
// contains filtered or unexported fields
}
RabbitStew is a food item that can be eaten by the player.
func (RabbitStew) ConsumeDuration ¶
ConsumeDuration ...
func (RabbitStew) EncodeItem ¶
func (RabbitStew) EncodeItem() (name string, meta int16)
EncodeItem ...
type RawCopper ¶
type RawCopper struct{}
RawCopper is a raw metal resource obtained from mining copper ore.
func (RawCopper) EncodeItem ¶
EncodeItem ...
type Releasable ¶
type Releasable interface { // Release is called when an item is released. Release(releaser Releaser, duration time.Duration, ctx *UseContext) // Requirements returns the required items to release this item. Requirements() []Stack }
Releasable represents an item that can be released.
type Releaser ¶
type Releaser interface { User // GameMode returns the gamemode of the releaser. GameMode() world.GameMode // PlaySound plays a world.Sound that only this Releaser can hear. PlaySound(sound world.Sound) }
Releaser represents an entity that can release items, such as bows.
type RottenFlesh ¶
type RottenFlesh struct {
// contains filtered or unexported fields
}
RottenFlesh is a food item that can be eaten by the player, at the high risk of inflicting Hunger.
func (RottenFlesh) AlwaysConsumable ¶
func (RottenFlesh) AlwaysConsumable() bool
AlwaysConsumable ...
func (RottenFlesh) Consume ¶
func (RottenFlesh) Consume(_ *world.World, c Consumer) Stack
Consume ...
func (RottenFlesh) ConsumeDuration ¶
ConsumeDuration ...
func (RottenFlesh) EncodeItem ¶
func (RottenFlesh) EncodeItem() (name string, meta int16)
EncodeItem ...
type Salmon ¶
type Salmon struct { // Cooked is whether the salmon is cooked. Cooked bool // contains filtered or unexported fields }
Salmon is a food item obtained from salmons. It can be cooked in a furnace, smoker, or campfire.
type Scute ¶
type Scute struct{}
Scute is an item that baby turtles drop when they grow into adults.
type Shears ¶
type Shears struct{}
Shears is a tool used to shear sheep, mine a few types of blocks, and carve pumpkins.
func (Shears) BaseMiningEfficiency ¶
BaseMiningEfficiency ...
type Shovel ¶
type Shovel struct { // Tier is the tier of the shovel. Tier ToolTier }
Shovel is a tool generally used for mining ground-like blocks, such as sand, gravel and dirt. Additionally, shovels may be used to turn grass into dirt paths.
func (Shovel) AttackDamage ¶
AttackDamage returns the attack damage to the shovel.
func (Shovel) BaseMiningEfficiency ¶
BaseMiningEfficiency ...
type ShulkerShell ¶
type ShulkerShell struct{}
ShulkerShell are items dropped by shulkers that are used solely to craft shulker boxes.
func (ShulkerShell) EncodeItem ¶
func (ShulkerShell) EncodeItem() (name string, meta int16)
EncodeItem ...
type Slimeball ¶
type Slimeball struct{}
Slimeball is a crafting ingredient commonly dropped by slimes, and can be sneezed out by pandas.
func (Slimeball) EncodeItem ¶
EncodeItem ...
type Snowball ¶
type Snowball struct{}
Snowball is a throwable combat item obtained through shovelling snow.
func (Snowball) EncodeItem ¶
EncodeItem ...
type SpiderEye ¶
type SpiderEye struct {
// contains filtered or unexported fields
}
SpiderEye is a poisonous food and brewing item.
func (SpiderEye) ConsumeDuration ¶
ConsumeDuration ...
func (SpiderEye) EncodeItem ¶
EncodeItem ...
type SplashPotion ¶
SplashPotion is an item that grants effects when thrown.
func (SplashPotion) EncodeItem ¶
func (s SplashPotion) EncodeItem() (name string, meta int16)
EncodeItem ...
func (SplashPotion) Use ¶
func (s SplashPotion) Use(w *world.World, user User, ctx *UseContext) bool
Use ...
type Spyglass ¶
type Spyglass struct{}
Spyglass is an item that zooms in on an area the player is looking at, like a telescope.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack represents a stack of items. The stack shares the same item type and has a count which specifies the size of the stack.
func NewStack ¶
NewStack returns a new stack using the item type and the count passed. NewStack panics if the count passed is negative or if the item type passed is nil.
func (Stack) AddStack ¶
AddStack adds another stack to the stack and returns both stacks. The first stack returned will have as many items in it as possible to fit in the stack, according to a max count of either 64 or otherwise as returned by Item.MaxCount(). The second stack will have the leftover items: It may be empty if the count of both stacks together don't exceed the max count. If the two stacks are not comparable, AddStack will return both the original stack and the stack passed.
func (Stack) AttackDamage ¶
AttackDamage returns the attack damage to the stack. By default, the value returned is 2.0. If the item held implements the item.Weapon interface, this damage may be different.
func (Stack) Comparable ¶
Comparable checks if two stacks can be considered comparable. True is returned if the two stacks have an equal item type and have equal enchantments, lore and custom names, or if one of the stacks is empty.
func (Stack) Count ¶
Count returns the amount of items that is present on the stack. The count is guaranteed never to be negative.
func (Stack) CustomName ¶
CustomName returns the custom name set for the Stack. An empty string is returned if the Stack has no custom name set.
func (Stack) Damage ¶
Damage returns a new stack that is damaged by the amount passed. (Meaning, its durability lowered by the amount passed.) If the item does not implement the Durable interface, the original stack is returned. The damage passed may be negative to add durability. If the final durability reaches 0 or below, the item returned is the resulting item of the breaking of the item. If the final durability reaches a number higher than the maximum durability, the stack returned will get the maximum durability.
func (Stack) Durability ¶
Durability returns the current durability of the item stack. If the item is not one that implements the Durable interface, BaseDurability will always return -1. The closer the durability returned is to 0, the closer the item is to being broken.
func (Stack) Enchantment ¶
func (s Stack) Enchantment(enchant EnchantmentType) (Enchantment, bool)
Enchantment attempts to return an Enchantment set to the Stack using Stack.WithEnchantment(). If an Enchantment is found by the EnchantmentType, the enchantment and the bool true is returned.
func (Stack) Enchantments ¶
func (s Stack) Enchantments() []Enchantment
Enchantments returns an array of all Enchantments on the item.
func (Stack) Equal ¶
Equal checks if the two stacks are equal. Equal is equivalent to a Stack.Comparable check while also checking the count.
func (Stack) Grow ¶
Grow grows the Stack's count by n, returning the resulting Stack. If a positive number is passed, the stack is grown, whereas if a negative size is passed, the resulting Stack will have a lower count. The count of the returned Stack will never be negative.
func (Stack) Item ¶
Item returns the item that the stack holds. If the stack is considered empty (Stack.Empty()), Item will always return nil.
func (Stack) Lore ¶
Lore returns the lore set for the Stack. If no lore is present, the slice returned has a len of 0.
func (Stack) MaxCount ¶
MaxCount returns the maximum count that the stack is able to hold when added to an inventory or when added to an item entity.
func (Stack) MaxDurability ¶
MaxDurability returns the maximum durability that the item stack is able to have. If the item does not implement the Durable interface, MaxDurability will always return -1.
func (Stack) Value ¶
Value attempts to return a value set to the Stack using Stack.WithValue(). If a value is found by the key passed, it is returned and ok is true. If not found, the value returned is nil and ok is false.
func (Stack) Values ¶
Values returns all values associated with the stack by users. The map returned is a copy of the original: Modifying it will not modify the item stack.
func (Stack) WithCustomName ¶
WithCustomName returns a copy of the Stack with the custom name passed. The custom name is formatted according to the rules of fmt.Sprintln.
func (Stack) WithDurability ¶
WithDurability returns a new item stack with the durability passed. If the item does not implement the Durable interface, WithDurability returns the original stack. The closer the durability d is to 0, the closer the item is to being broken. If a durability of 0 is passed, a stack with the item type of the BrokenItem is returned. If a durability is passed that exceeds the maximum durability, the stack returned will have the maximum durability.
func (Stack) WithEnchantments ¶
func (s Stack) WithEnchantments(enchants ...Enchantment) Stack
WithEnchantments returns the current stack with the passed enchantments. If an enchantment is not compatible with the item stack, it will not be applied.
func (Stack) WithLore ¶
WithLore returns a copy of the Stack with the lore passed. Each string passed is put on a different line, where the first string is at the top and the last at the bottom. The lore may be cleared by passing no lines into the Stack.
func (Stack) WithValue ¶
WithValue returns the current Stack with a value set at a specific key. This method may be used to associate custom data with the item stack, which will persist through server restarts. The value stored may later be obtained by making a call to Stack.Value().
WithValue may be called with a nil value, in which case the value at the key will be cleared.
WithValue stores Values by encoding them using the encoding/gob package. Users of WithValue must ensure that their value is valid for encoding with this package.
func (Stack) WithoutEnchantments ¶
func (s Stack) WithoutEnchantments(enchants ...EnchantmentType) Stack
WithoutEnchantments returns the current stack but with the passed enchantments removed.
type Stick ¶
type Stick struct{}
Stick is one of the most abundant resources used for crafting many tools and items.
type Sugar ¶
type Sugar struct{}
Sugar is a food ingredient and brewing ingredient made from sugar canes.
type Sword ¶
type Sword struct { // Tier is the tier of the sword. Tier ToolTier }
Sword is a tool generally used to attack enemies. In addition, it may be used to mine any block slightly faster than without tool and to break cobwebs rapidly.
func (Sword) AttackDamage ¶
AttackDamage returns the attack damage to the sword.
func (Sword) BaseMiningEfficiency ¶
BaseMiningEfficiency always returns 1.5, unless the block passed is cobweb, in which case 15 is returned.
func (Sword) HarvestLevel ¶
HarvestLevel returns the harvest level of the sword tier.
type Tool ¶
type Tool interface { // ToolType returns the type of the tool. The blocks that can be mined with this tool depend on this // tool type. ToolType() ToolType // HarvestLevel returns the level that this tool is able to harvest. If a block has a harvest level above // this one, this tool won't be able to harvest it. HarvestLevel() int // BaseMiningEfficiency is the base efficiency of the tool, when it comes to mining blocks. This decides // the speed with which blocks can be mined. // Some tools have a mining efficiency that depends on the block (swords, shears). The block mined is // passed for this behaviour. BaseMiningEfficiency(b world.Block) float64 }
Tool represents an item that may be used as a tool.
type ToolNone ¶
type ToolNone struct{}
ToolNone is a ToolType typically used in functions for items that do not function as tools.
func (ToolNone) BaseMiningEfficiency ¶
BaseMiningEfficiency ...
type ToolTier ¶
type ToolTier struct { // HarvestLevel is the level that this tier of tools is able to harvest. If a block has a harvest level // above this one, a tool with this tier won't be able to harvest it. HarvestLevel int // BaseMiningEfficiency is the base efficiency of the tier, when it comes to mining blocks. This is // specifically used for tools such as pickaxes. BaseMiningEfficiency float64 // BaseAttackDamage is the base attack damage to tools with this tier. All tools have a constant value // that is added on top of this. BaseAttackDamage float64 // BaseDurability returns the maximum durability that a tool with this tier has. Durability int // Name is the name of the tier. Name string }
ToolTier represents the tier, or material, that a Tool is made of.
type ToolType ¶
type ToolType struct {
// contains filtered or unexported fields
}
ToolType represents the type of tool. This decides the type of blocks that the tool is used for.
type TropicalFish ¶
type TropicalFish struct {
// contains filtered or unexported fields
}
TropicalFish is a food item that cannot be cooked.
func (TropicalFish) AlwaysConsumable ¶
func (TropicalFish) AlwaysConsumable() bool
AlwaysConsumable ...
func (TropicalFish) Consume ¶
func (TropicalFish) Consume(_ *world.World, c Consumer) Stack
Consume ...
func (TropicalFish) ConsumeDuration ¶
ConsumeDuration ...
func (TropicalFish) EncodeItem ¶
func (TropicalFish) EncodeItem() (name string, meta int16)
EncodeItem ...
type TurtleShell ¶
type TurtleShell struct{}
TurtleShell are items that are used for brewing or as a helmet to give the player the Water Breathing status effect.
func (TurtleShell) DurabilityInfo ¶
func (t TurtleShell) DurabilityInfo() DurabilityInfo
DurabilityInfo ...
func (TurtleShell) EncodeItem ¶
func (t TurtleShell) EncodeItem() (name string, meta int16)
EncodeItem ...
func (TurtleShell) KnockBackResistance ¶
func (t TurtleShell) KnockBackResistance() float64
KnockBackResistance ...
func (TurtleShell) Use ¶
func (t TurtleShell) Use(_ *world.World, _ User, ctx *UseContext) bool
Use handles the using of a turtle shell to auto-equip it in an armour slot.
type Usable ¶
type Usable interface { // Use is called when the item is used in the air. The user that used the item and the world that the item // was used in are passed to the method. // Use returns a bool indicating if the item was used successfully. Use(w *world.World, user User, ctx *UseContext) bool }
Usable represents an item that may be used 'in the air'. If an item implements this interface, the Use method is called whenever the item is used while pointing at the air. (For example, when throwing an egg.)
type UsableOnBlock ¶
type UsableOnBlock interface { // UseOnBlock is called when an item is used on a block. The world passed is the world that the item was // used in. The user passed is the entity that used the item. Usually this entity is a player. // The position of the block that was clicked, along with the clicked face and the position clicked // relative to the corner of the block are passed. // UseOnBlock returns a bool indicating if the item was used successfully. UseOnBlock(pos cube.Pos, face cube.Face, clickPos mgl64.Vec3, w *world.World, user User, ctx *UseContext) bool }
UsableOnBlock represents an item that may be used on a block. If an item implements this interface, the UseOnBlock method is called whenever the item is used on a block.
type UsableOnEntity ¶
type UsableOnEntity interface { // UseOnEntity is called when an item is used on an entity. The world passed is the world that the item is // used in, and the entity clicked and the user of the item are also passed. // UseOnEntity returns a bool indicating if the item was used successfully. UseOnEntity(e world.Entity, w *world.World, user User, ctx *UseContext) bool }
UsableOnEntity represents an item that may be used on an entity. If an item implements this interface, the UseOnEntity method is called whenever the item is used on an entity.
type UseContext ¶
type UseContext struct { // Damage is the amount of damage that should be dealt to the item as a result of using it. Damage int // CountSub is how much of the count should be subtracted after using the item. CountSub int // IgnoreAABB specifies if placing the item should ignore the AABB of the player placing this. This is the case for // items such as cocoa beans. IgnoreAABB bool // NewItem is the item that is added after the item is used. If the player no longer has an item in the // hand, it'll be added there. NewItem Stack // ConsumedItems contains a list of items that were consumed in the process of using the item. ConsumedItems []Stack // NewItemSurvivalOnly will add any new items only in survival mode. NewItemSurvivalOnly bool // FirstFunc returns the first item in the context holder's inventory if found. The second return value describes // whether the item was found. The comparable function is used to compare the item to the given item. FirstFunc func(comparable func(Stack) bool) (Stack, bool) // SwapHeldWithArmour holds a function that swaps the item currently held by a User with armour slot i. SwapHeldWithArmour func(i int) }
UseContext is passed to every item Use methods. It may be used to subtract items or to deal damage to them after the action is complete.
func (*UseContext) Consume ¶
func (ctx *UseContext) Consume(s Stack)
Consume consumes the provided item when the context is handled.
func (*UseContext) DamageItem ¶
func (ctx *UseContext) DamageItem(d int)
DamageItem damages the item used by d points.
func (*UseContext) SubtractFromCount ¶
func (ctx *UseContext) SubtractFromCount(d int)
SubtractFromCount subtracts d from the count of the item stack used.
type User ¶
type User interface { Carrier // Facing returns the direction that the user is facing. Facing() cube.Direction SetHeldItems(mainHand, offHand Stack) }
User represents an entity that is able to use an item in the world, typically entities such as players, which interact with the world using an item.
type WarpedFungusOnAStick ¶
type WarpedFungusOnAStick struct{}
WarpedFungusOnAStick is an item that can be used to control saddled striders.
func (WarpedFungusOnAStick) EncodeItem ¶
func (WarpedFungusOnAStick) EncodeItem() (name string, meta int16)
EncodeItem ...
type Weapon ¶
type Weapon interface { // AttackDamage returns the custom attack damage to the weapon. The damage returned must not be negative. AttackDamage() float64 }
Weapon is an item that may be used as a weapon. It has an attack damage which may be different to the 2 damage that attacking with an empty hand deals.
Source Files ¶
- amethyst_shard.go
- apple.go
- armour.go
- arrow.go
- axe.go
- baked_potato.go
- beef.go
- beetroot.go
- beetroot_soup.go
- blaze_powder.go
- blaze_rod.go
- bone.go
- bone_meal.go
- book.go
- boots.go
- bow.go
- bowl.go
- bread.go
- brick.go
- bucket.go
- carrot_on_a_stick.go
- charcoal.go
- chestplate.go
- chicken.go
- clay_ball.go
- clock.go
- coal.go
- cod.go
- colour.go
- compass.go
- cookie.go
- copper_ingot.go
- diamond.go
- dragon_breath.go
- dried_kelp.go
- durability.go
- dye.go
- emerald.go
- enchanted_apple.go
- enchantment.go
- ender_pearl.go
- feather.go
- fermented_spider_eye.go
- flint.go
- flint_and_steel.go
- ghast_tear.go
- glass_bottle.go
- glistering_melon_slice.go
- glowstone_dust.go
- gold_ingot.go
- gold_nugget.go
- golden_apple.go
- golden_carrot.go
- gunpowder.go
- heart_of_the_sea.go
- helmet.go
- hoe.go
- honeycomb.go
- ink_sac.go
- iron_ingot.go
- iron_nugget.go
- item.go
- lapis_lazuli.go
- leather.go
- leggings.go
- magma_cream.go
- melon_slice.go
- mushroom_stew.go
- mutton.go
- nautilus_shell.go
- nether_brick.go
- nether_quartz.go
- nether_star.go
- netherite_ingot.go
- netherite_scrap.go
- paper.go
- phantom_membrane.go
- pickaxe.go
- poisonous_potato.go
- popped_chorus_fruit.go
- porkchop.go
- potion.go
- prismarine_crystal.go
- prismarine_shard.go
- pufferfish.go
- pumpkin_pie.go
- rabbit.go
- rabbit_foot.go
- rabbit_hide.go
- rabbit_stew.go
- raw_copper.go
- raw_gold.go
- raw_iron.go
- register.go
- rotten_flesh.go
- salmon.go
- scute.go
- shears.go
- shovel.go
- shulker_shell.go
- slimeball.go
- snowball.go
- spider_eye.go
- splash_potion.go
- spyglass.go
- stack.go
- stick.go
- sugar.go
- sword.go
- tool.go
- totem.go
- tropical_fish.go
- turtle_shell.go
- use.go
- warped_fungus_on_a_stick.go
- wheat.go