metadata

package
v0.0.0-...-2a33acd Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// I am not using iota here, as these constants should be exactly what is defined as per the minecraft wiki.
	// If I used iota, it would be less clear what each individual value was.
	EntityType_Byte         = 0
	EntityType_VarInt       = 1
	EntityType_Float        = 2
	EntityType_String       = 3
	EntityType_Chat         = 4
	EntityType_OptChat      = 5
	EntityType_Item         = 6
	EntityType_Bool         = 7
	EntityType_Rotation     = 8 // 3 floats in a row
	EntityType_Position     = 9
	EntityType_OptPosition  = 10
	EntityType_Direction    = 11 // (Down = 0, Up = 1, North = 2, South = 3, West = 4, East = 5)
	EntityType_OptUUID      = 12
	EntityType_BlockID      = 13 // blockstate
	EntityType_NBT          = 14
	EntityType_Particle     = 15
	EntityType_VillagerData = 16 // 3 VarInts: villager type, villager profession, level
	EntityType_OptVarInt    = 17 // used for EID. 0 means absent, 1+ is an actual id
	EntityType_Pose         = 18 // 0: STANDING, 1: FALL_FLYING, 2: SLEEPING, 3: SWIMMING, 4: SPIN_ATTACK, 5: SNEAKING, 6: DYING

	Direction_Down  = 0
	Direction_Up    = 1
	Direction_North = 2
	Direction_South = 3
	Direction_West  = 4
	Direction_East  = 5

	Pose_Standing   = 0
	Pose_FallFlying = 1
	Pose_Sleeping   = 2
	Pose_Swimming   = 3
	Pose_SpinAttack = 4
	Pose_Sneaking   = 5
	Pose_Dying      = 6
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	// contains filtered or unexported fields
}

This is an entitiy metadata map. It matches one version of the game, and uses types that are equivalent to the newest version. These types are translated as best as possible in the proxy, but you will still run into issues. Therefore, you should use a entity.Metadata, which understands what type of entity you are talking about, and knows how to correctly set the fields for each version.

func New

func New() *Metadata

func (*Metadata) ClearDirty

func (m *Metadata) ClearDirty() bool

Sets dirty to false, and returns the previous value

func (*Metadata) Dirty

func (m *Metadata) Dirty() bool

Gets whether or not the metadata is dirty

func (*Metadata) Get

func (m *Metadata) Get(index byte) (interface{}, bool)

Gets the value at a given index.

This will return true if the value is set, and false if it is not set. It is up to the user to figure out of casting is safe, as all fields are set with calls to Write, and the type of any field can be changed at any time. This type will never change the type of values, only the user can change those.

func (*Metadata) GetType

func (m *Metadata) GetType(index byte, mtype int32) interface{}

Gets the value at a given index. If the value is not set, then it will insert a default value into the metadata, with the given type, and return that. If the value is already set, no matter what the type is, it will return that other value.

If it writes a value, it will mark the metadata as dirty

func (*Metadata) String

func (m *Metadata) String() string

func (*Metadata) ToProto

func (m *Metadata) ToProto() *pb.EntityMetadata

func (*Metadata) Write

func (m *Metadata) Write(index byte, mtype int32, value interface{})

Whenever this is called, it will mark the metadata as dirty.

type Particle

type Particle struct {
	ID   int32
	Data []byte
}

func (Particle) String

func (p Particle) String() string

type Rotation

type Rotation struct {
	X, Y, Z float32
}

func (Rotation) String

func (r Rotation) String() string

type VillagerData

type VillagerData struct {
	Type, Profession, Level int32
}

func (VillagerData) String

func (v VillagerData) String() string

Jump to

Keyboard shortcuts

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