Exemple #1
0
func (item *Item) UnmarshalNbt(tag *nbt.Compound) (err os.Error) {
	if err = item.PointObject.UnmarshalNbt(tag); err != nil {
		return
	}

	itemInfo, ok := tag.Lookup("Item").(*nbt.Compound)
	if !ok {
		return os.NewError("bad item data")
	}

	// Grab the basic item data
	id, idOk := itemInfo.Lookup("id").(*nbt.Short)
	count, countOk := itemInfo.Lookup("Count").(*nbt.Byte)
	data, dataOk := itemInfo.Lookup("Damage").(*nbt.Short)
	if !idOk || !countOk || !dataOk {
		return os.NewError("bad item data")
	}

	item.Slot = Slot{
		ItemTypeId: types.ItemTypeId(id.Value),
		Count:      types.ItemCount(count.Value),
		Data:       types.ItemData(data.Value),
	}

	return nil
}
Exemple #2
0
package gamerules

import (
	"chunkymonkey/types"
)

const (
	MaxStackDefault = types.ItemCount(64)
)

type ToolTypeId byte

type ItemType struct {
	Id       types.ItemTypeId
	Name     string
	MaxStack types.ItemCount
	ToolType ToolTypeId
	ToolUses types.ItemData
}

type ItemTypeMap map[types.ItemTypeId]*ItemType