items

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Air uint8 = iota
	Bedrock
	Bread
	Bucket
	Coal
	CoalOre
	CraftingTable
	Diamond
	DiamondAxe
	DiamondOre
	DiamondPickaxe
	DiamondShovel
	Dirt
	Furnace
	GoldIngot
	GoldOre
	GrassBlock
	GrassBlockSnow
	IronAxe
	IronIngot
	IronOre
	IronPickaxe
	IronShovel
	OakLeaves
	OakLog
	OakPlanks
	OakSapling
	Obsidian
	RawGold
	RawIron
	Sand
	SmoothStone
	Snow
	Snowball
	Stick
	Stone
	StoneAxe
	StoneBricks
	StonePickaxe
	StoneShovel
	Tnt
	Torch
	WaterBucket
	WoodenAxe
	WoodenPickaxe
	WoodenShovel
	Random
)

Item ID

View Source
const (
	None  tag = 0
	Block tag = 1 << iota
	OreBlock
	UnbreakableBlock
	NonSolidBlock
	Harvestable
	DropItem
	Item
	RawOre
	Tool
	Weapon
	Food
	MaterialWooden
	MaterialGold
	MaterialStone
	MaterialIron
	MaterialDiamond
	ToolHand
	ToolAxe
	ToolPickaxe
	ToolShovel
	ToolBucket
)

Item Bitmask tag

View Source
const All = tag(^uint(0))

Variables

View Source
var Blocks []uint8
View Source
var ColorMap = map[uint8]color.RGBA{
	Air:           rgb(0, 62, 161),
	CraftingTable: rgb(194, 137, 62),
	GrassBlock:    rgb(133, 75, 54),
	Dirt:          rgb(133, 75, 54),
	Sand:          rgb(199, 193, 158),
	Stone:         rgb(120, 120, 120),
	CoalOre:       rgb(0, 0, 0),
	GoldOre:       rgb(255, 221, 0),
	IronOre:       rgb(151, 176, 205),
	DiamondOre:    rgb(0, 247, 255),
	OakLog:        rgb(227, 131, 104),
	OakPlanks:     rgb(224, 153, 145),
	OakLeaves:     rgb(0, 160, 16),
}
View Source
var CraftingRecipes map[uint8]Recipe
View Source
var FurnaceRecipes map[uint8]Recipe
View Source
var Property = map[uint8]ItemProperty{
	Air: {
		DisplayName:  "Air",
		DropID:       Air,
		MaxStackSize: 1,
		Tags:         None | NonSolidBlock | UnbreakableBlock,
	},
	Bedrock: {
		DisplayName:  "Bedrock",
		DropID:       Bedrock,
		MaxStackSize: 1,
		Tags:         Block | UnbreakableBlock,
	},
	Random: {
		DisplayName:  "Random",
		MaxStackSize: 64,
		Tags:         Block | UnbreakableBlock,
	},
	Bread: {
		DisplayName:  "Bread",
		MaxStackSize: 64,
		Tags:         Item | Food,
	},
	Bucket: {
		DisplayName:  "Bucket",
		MaxStackSize: 1,
		Tags:         Item | Tool,
	},
	Coal: {
		DisplayName:  "Coal",
		MaxStackSize: 64,
		Tags:         Item | DropItem | RawOre,
	},
	CoalOre: {
		DisplayName:  "Coal Ore",
		DropID:       Coal,
		MaxStackSize: 64,
		Tags:         Block | OreBlock,
		BestToolTag:  ToolPickaxe,
	},
	CraftingTable: {
		DisplayName:  "Crafting Table",
		DropID:       CraftingTable,
		MaxStackSize: 1,
		Tags:         Block,
		BestToolTag:  ToolAxe,
	},
	Diamond: {
		DisplayName:  "Diamond",
		MaxStackSize: 64,
		Tags:         Item | DropItem | RawOre,
	},
	DiamondAxe: {
		DisplayName:  "Diamond Axe",
		MaxStackSize: 1,
		Tags:         Item | Tool | ToolAxe | Weapon | MaterialDiamond,
	},
	DiamondOre: {
		DisplayName:  "Diamond Ore",
		DropID:       Diamond,
		MaxStackSize: 64,
		Tags:         Block | OreBlock,
		BestToolTag:  ToolPickaxe,
	},
	DiamondPickaxe: {
		DisplayName:  "Diamond Pickaxe",
		MaxStackSize: 1,
		Tags:         Item | Tool | ToolPickaxe | MaterialDiamond,
	},
	DiamondShovel: {
		DisplayName:  "Diamond Shovel",
		MaxStackSize: 1,
		Tags:         Item | Tool | ToolShovel | MaterialDiamond,
	},
	Dirt: {
		DisplayName:  "Dirt",
		DropID:       Dirt,
		MaxStackSize: 64,
		Tags:         Block,
		BestToolTag:  ToolShovel,
	},
	Furnace: {
		DisplayName:  "Furnace",
		DropID:       Furnace,
		MaxStackSize: 1,
		Tags:         Block,
		BestToolTag:  ToolPickaxe,
	},
	GoldIngot: {
		DisplayName:  "Gold Ingot",
		MaxStackSize: 64,
		Tags:         Item,
	},
	GoldOre: {
		DisplayName:  "Gold Ore",
		DropID:       RawGold,
		MaxStackSize: 64,
		Tags:         Block | OreBlock,
		BestToolTag:  ToolPickaxe,
	},
	GrassBlock: {
		DisplayName:  "Grass Block",
		DropID:       Dirt,
		MaxStackSize: 64,
		Tags:         Block,
		BestToolTag:  ToolShovel,
	},
	GrassBlockSnow: {
		DisplayName:  "Grass Block Snow",
		DropID:       Dirt,
		MaxStackSize: 64,
		Tags:         Block,
		BestToolTag:  ToolShovel,
	},
	IronAxe: {
		DisplayName:  "Iron Axe",
		MaxStackSize: 1,
		Tags:         Item | Tool | ToolAxe | MaterialIron,
	},
	IronIngot: {
		DisplayName:  "Iron Ingot",
		MaxStackSize: 64,
		Tags:         Item,
	},
	IronOre: {
		DisplayName:  "Iron Ore",
		DropID:       RawIron,
		MaxStackSize: 64,
		Tags:         Block | OreBlock,
		BestToolTag:  ToolPickaxe,
	},
	IronPickaxe: {
		DisplayName:  "Iron Pickaxe",
		MaxStackSize: 1,
		Tags:         Item | Tool | ToolPickaxe | MaterialIron,
	},
	IronShovel: {
		DisplayName:  "Iron Shovel",
		MaxStackSize: 1,
		Tags:         Item | Tool | ToolShovel | MaterialIron,
	},
	OakLeaves: {
		DisplayName:  "Oak Leaves",
		DropID:       OakSapling,
		MaxStackSize: 64,
		Tags:         Block,
		BestToolTag:  All,
	},
	OakLog: {
		DisplayName:  "Oak Log",
		DropID:       OakLog,
		MaxStackSize: 64,
		Tags:         Block,
		BestToolTag:  ToolAxe,
	},
	OakPlanks: {
		DisplayName:  "Oak Planks",
		DropID:       OakPlanks,
		MaxStackSize: 64,
		Tags:         Block,
		BestToolTag:  ToolAxe,
	},
	OakSapling: {
		DisplayName:  "Oak Sapling",
		DropID:       OakSapling,
		MaxStackSize: 64,
		Tags:         Block | Item | NonSolidBlock,
		BestToolTag:  ToolAxe,
	},
	Obsidian: {
		DisplayName:  "Obsidian",
		DropID:       Obsidian,
		MaxStackSize: 64,
		Tags:         Block,
		BestToolTag:  ToolPickaxe,
	},
	RawGold: {
		DisplayName:  "Raw Gold",
		MaxStackSize: 64,
		Tags:         Item | DropItem | RawOre,
	},
	RawIron: {
		DisplayName:  "Raw Iron",
		MaxStackSize: 64,
		Tags:         Item | DropItem | RawOre,
	},
	Sand: {
		DisplayName:  "Sand",
		DropID:       Sand,
		MaxStackSize: 64,
		Tags:         Block,
		BestToolTag:  ToolShovel,
	},
	SmoothStone: {
		DisplayName:  "Smooth Stone",
		DropID:       SmoothStone,
		MaxStackSize: 64,
		Tags:         Block,
	},
	Snow: {
		DisplayName:  "Snow",
		DropID:       Dirt,
		MaxStackSize: 64,
		Tags:         Block,
		BestToolTag:  ToolShovel,
	},
	Snowball: {
		DisplayName:  "Snowball",
		DropID:       Snowball,
		MaxStackSize: 64,
		Tags:         Item,
	},
	Stick: {
		DisplayName:  "Stick",
		MaxStackSize: 64,
		Tags:         Item,
	},
	Stone: {
		DisplayName:  "Stone",
		DropID:       Stone,
		MaxStackSize: 64,
		Tags:         Block,
		BestToolTag:  ToolPickaxe,
	},
	StoneAxe: {
		DisplayName:  "Stone Axe",
		MaxStackSize: 1,
		Tags:         Item | Tool | ToolAxe | MaterialStone,
	},
	StoneBricks: {
		DisplayName:  "Stone Bricks",
		DropID:       StoneBricks,
		MaxStackSize: 64,
		Tags:         Block,
		BestToolTag:  ToolPickaxe,
	},
	StonePickaxe: {
		DisplayName:  "Stone Pickaxe",
		MaxStackSize: 1,
		Tags:         Item | Tool | ToolPickaxe | MaterialStone,
	},
	StoneShovel: {
		DisplayName:  "Stone Shovel",
		MaxStackSize: 1,
		Tags:         Item | Tool | ToolShovel | MaterialStone,
	},
	Tnt: {
		DisplayName:  "TNT",
		DropID:       Tnt,
		MaxStackSize: 64,
		Tags:         Block,
		BestToolTag:  All,
	},
	Torch: {
		DisplayName:  "Torch",
		DropID:       Torch,
		MaxStackSize: 64,
		Tags:         Item | Block | NonSolidBlock,
		BestToolTag:  All,
	},
	WaterBucket: {
		DisplayName:  "Water Bucket",
		MaxStackSize: 1,
		Tags:         Item | Tool | ToolBucket | MaterialIron,
	},
	WoodenAxe: {
		DisplayName:  "Wooden Axe",
		MaxStackSize: 1,
		Tags:         Item | Tool | ToolAxe | MaterialWooden,
	},
	WoodenPickaxe: {
		DisplayName:  "Wooden Pickaxe",
		MaxStackSize: 1,
		Tags:         Item | Tool | ToolPickaxe | MaterialWooden,
	},
	WoodenShovel: {
		DisplayName:  "Wooden Shovel",
		MaxStackSize: 1,
		Tags:         Item | Tool | ToolShovel | MaterialWooden,
	},
}

Functions

func DisplayName

func DisplayName(id uint8) string

func GetDefaultDurability

func GetDefaultDurability(id uint8) int

func HasTag

func HasTag(id uint8, tag tag) bool

func IsBestTool

func IsBestTool(blockID, toolID uint8) bool

func IsStackable

func IsStackable(id uint8) bool

func RandomBlock

func RandomBlock() uint8

func RandomItem

func RandomItem() uint8

Types

type CraftTable

type CraftTable struct {
	Pos        image.Point // Slot position
	Slots      [][]Slot
	ResultSlot Slot
}

func NewCraftTable

func NewCraftTable() *CraftTable

func (*CraftTable) CheckRecipe

func (c *CraftTable) CheckRecipe(recipes map[uint8]Recipe) (uint8, uint8)

returns zero (air) if no recipe is found, otherwise returns the recipe result and quantity.

func (*CraftTable) ClearCurrenSlot

func (c *CraftTable) ClearCurrenSlot()

func (*CraftTable) ClearTable

func (c *CraftTable) ClearTable()

func (*CraftTable) CurrentSlot

func (c *CraftTable) CurrentSlot() *Slot

func (*CraftTable) Equal

func (c *CraftTable) Equal(recipeA, recipeB Recipe) bool

func (*CraftTable) RemoveItem

func (c *CraftTable) RemoveItem(x, y int)

func (*CraftTable) UpdateResultSlot

func (c *CraftTable) UpdateResultSlot(recipes map[uint8]Recipe) uint8

returns minimum result item quantity

type Inventory

type Inventory struct {
	CurrentSlotIndex       int
	QuickSlot1, QuickSlot2 int
	Slots                  []Slot
}

func NewInventory

func NewInventory(size int) *Inventory

func (*Inventory) AddItemIfEmpty

func (i *Inventory) AddItemIfEmpty(id uint8, dura int) bool

AddItemIfEmpty adds item to inventory if empty

func (*Inventory) ClearCurrentSlot

func (i *Inventory) ClearCurrentSlot()

func (*Inventory) ClearSlot

func (i *Inventory) ClearSlot(index int)

func (*Inventory) CurrentSlot

func (i *Inventory) CurrentSlot() *Slot

func (*Inventory) CurrentSlotID

func (i *Inventory) CurrentSlotID() uint8

func (*Inventory) CurrentSlotQuantity

func (i *Inventory) CurrentSlotQuantity() uint8

func (*Inventory) HasEmptySlot

func (i *Inventory) HasEmptySlot() (index int, ok bool)

func (*Inventory) HasItem

func (i *Inventory) HasItem(id uint8) (index int, ok bool)

func (*Inventory) HasItemStackSpace

func (i *Inventory) HasItemStackSpace(id uint8) (index int, ok bool)

func (*Inventory) IsCurrentSlotEmpty

func (i *Inventory) IsCurrentSlotEmpty() bool

func (*Inventory) RandomFillAllSlots

func (i *Inventory) RandomFillAllSlots()

func (*Inventory) RemoveItem

func (i *Inventory) RemoveItem(id uint8) bool

func (*Inventory) RemoveItemFromSelectedSlot

func (i *Inventory) RemoveItemFromSelectedSlot() (uint8, int)

func (*Inventory) Reset

func (i *Inventory) Reset()

func (*Inventory) ResetUnusedSlots

func (i *Inventory) ResetUnusedSlots()

func (*Inventory) SelectNextSlot

func (i *Inventory) SelectNextSlot()

func (*Inventory) SelectPrevSlot

func (i *Inventory) SelectPrevSlot()

func (*Inventory) SetSize

func (i *Inventory) SetSize(n int)

func (*Inventory) SetSlot

func (i *Inventory) SetSlot(slotIndex int, id uint8, quantity uint8, dur int)

type ItemProperty

type ItemProperty struct {
	DisplayName  string
	DropID       uint8
	MaxStackSize uint8
	Tags         tag
	BestToolTag  tag
}

type Recipe

type Recipe [][]Slot

type Slot

type Slot struct {
	ID         uint8
	Quantity   uint8
	Durability int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL