types

package
v0.0.0-...-566b5d1 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2011 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TicksPerDay         = 24000
	TicksPerSecond      = 20
	NanosecondsInSecond = 1e9
)
View Source
const (
	DimensionNether = DimensionId(-1)
	DimensionNormal = DimensionId(0)
)
View Source
const (
	MobTypeIdCreeper      = EntityMobType(50)
	MobTypeIdSkeleton     = EntityMobType(51)
	MobTypeIdSpider       = EntityMobType(52)
	MobTypeIdGiantZombie  = EntityMobType(53)
	MobTypeIdZombie       = EntityMobType(54)
	MobTypeIdSlime        = EntityMobType(55)
	MobTypeIdGhast        = EntityMobType(56)
	MobTypeIdZombiePigman = EntityMobType(57)
	MobTypeIdPig          = EntityMobType(90)
	MobTypeIdSheep        = EntityMobType(91)
	MobTypeIdCow          = EntityMobType(92)
	MobTypeIdHen          = EntityMobType(93)
	MobTypeIdSquid        = EntityMobType(94)
	MobTypeIdWolf         = EntityMobType(95)
)
View Source
const (
	EntityAnimationNone     = EntityAnimation(0)
	EntityAnimationSwingArm = EntityAnimation(1)
	EntityAnimationDamage   = EntityAnimation(2)
	EntityAnimationUnknown1 = EntityAnimation(102)
	EntityAnimationCrouch   = EntityAnimation(104)
	EntityAnimationUncrouch = EntityAnimation(105)
)
View Source
const (
	EntityActionCrouch   = EntityAction(1)
	EntityActionUncrouch = EntityAction(2)
)
View Source
const (
	ObjTypeIdBoat           = ObjTypeId(1)
	ObjTypeIdMinecart       = ObjTypeId(10)
	ObjTypeIdStorageCart    = ObjTypeId(11)
	ObjTypeIdPoweredCart    = ObjTypeId(12)
	ObjTypeIdActivatedTnt   = ObjTypeId(50)
	ObjTypeIdArrow          = ObjTypeId(60)
	ObjTypeIdThrownSnowball = ObjTypeId(61)
	ObjTypeIdThrownEgg      = ObjTypeId(62)
	ObjTypeIdFallingSand    = ObjTypeId(70)
	ObjTypeIdFallingGravel  = ObjTypeId(71)
	ObjTypeIdFishingFloat   = ObjTypeId(90)
)
View Source
const (
	InstrumentIdDoubleBass = InstrumentId(1)
	InstrumentIdSnareDrum  = InstrumentId(2)
	InstrumentIdSticks     = InstrumentId(3)
	InstrumentIdBassDrum   = InstrumentId(4)
	InstrumentIdHarp       = InstrumentId(5)
)
View Source
const (
	NotePitchMin = NotePitch(0)
	NotePitchMax = NotePitch(24)
)
View Source
const (
	BlockIdMin = 0
	BlockIdAir = BlockId(0)
	BlockIdMax = 255
)
View Source
const (
	FaceNull     = Face(-1)
	FaceMinValid = 0
	FaceBottom   = 0
	FaceTop      = 1
	FaceEast     = 2
	FaceWest     = 3
	FaceNorth    = 4
	FaceSouth    = 5
	FaceMaxValid = 5
)

Used when a block face is not appropriate to the situation, but block location data passed (such as using an item not on a block).

View Source
const (
	DigStarted    = DigStatus(0)
	DigBlockBroke = DigStatus(2)
	DigDropItem   = DigStatus(4)
)
View Source
const (
	WindowIdCursor    = WindowId(-1)
	WindowIdInventory = WindowId(0)
	WindowIdFreeMin   = WindowId(1)
	WindowIdFreeMax   = WindowId(127)
)
View Source
const (
	InvTypeIdChest     = InvTypeId(0)
	InvTypeIdWorkbench = InvTypeId(1)
	InvTypeIdFurnace   = InvTypeId(2)
	InvTypeIdDispenser = InvTypeId(3)
)
View Source
const (
	SlotIdCursor = SlotId(-1)
	SlotIdNull   = SlotId(999) // Clicked outside window.
)
View Source
const (
	PrgBarIdFurnaceProgress = PrgBarId(0)
	PrgBarIdFurnaceFire     = PrgBarId(1)
)
View Source
const (
	TxStateAccepted = TxState(iota)
	TxStateRejected
	TxStateDeferred
)
View Source
const (
	VelocityComponentMax = 28800
	VelocityComponentMin = -28800

	AbsToIntVelocityComponent = TicksPerSecond * 32000 / 100
)
View Source
const (
	ChunkHShift = 4
	ChunkYShift = 7
	// Chunk coordinates can be converted to block coordinates
	ChunkSizeH = 1 << ChunkHShift
	ChunkSizeY = 1 << ChunkYShift
	ChunkHMask = ChunkSizeH - 1
	ChunkYMask = ChunkSizeY - 1

	// The area within which a client receives updates.
	ChunkRadius = 10
	// The radius in which all chunks must be sent before completing a client's
	// login process.
	MinChunkRadius = 2

	// Sometimes it is useful to convert block coordinates to pixels
	PixelShift     = 5
	PixelsPerBlock = 1 << PixelShift

	PixelsPerChunkShift = (ChunkHShift + PixelShift)
	PixelsPerChunk      = 1 << PixelsPerChunkShift

	// Millipixels are used in velocity values
	MilliPixelsPerPixel = 1000
	MilliPixelsPerBlock = PixelsPerBlock * MilliPixelsPerPixel
)
View Source
const (
	MaxXCoord = math.MaxInt32
	MinXCoord = math.MinInt32
	MaxYCoord = math.MaxInt8
	MinYCoord = 0
	MaxZCoord = math.MaxInt32
	MinZCoord = math.MinInt32
)
View Source
const (
	// Client should unload the chunk
	ChunkUnload = ChunkLoadMode(0)

	// Client should initialise the chunk
	ChunkInit = ChunkLoadMode(1)
)
View Source
const (
	DegreesToBytes = 256.0 / 360.0
)
View Source
const (
	// MaxInteractDistance is the maximum distance at which a player can interact
	// with something, such as dig.
	MaxInteractDistance = AbsCoord(6)
)
View Source
const (
	// Each shard is ShardSize * ShardSize chunks square.
	ShardSize = 16
)

Variables

View Source
var MobNameByType = map[EntityMobType]string{}

MobNameByType reverses the MobTypeByName mapping, initialized in init().

View Source
var MobTypeByName = map[string]EntityMobType{
	"Creeper":      MobTypeIdCreeper,
	"Skeleton":     MobTypeIdSkeleton,
	"Spider":       MobTypeIdSpider,
	"GiantZombie":  MobTypeIdGiantZombie,
	"Zombie":       MobTypeIdZombie,
	"Slime":        MobTypeIdSlime,
	"Ghast":        MobTypeIdGhast,
	"ZombiePigman": MobTypeIdZombiePigman,
	"Pig":          MobTypeIdPig,
	"Sheep":        MobTypeIdSheep,
	"Cow":          MobTypeIdCow,
	"Hen":          MobTypeIdHen,
	"Squid":        MobTypeIdSquid,
	"Wolf":         MobTypeIdWolf,
}
View Source
var ObjNameByType = map[ObjTypeId]string{}

ObjNameByType reverses ObjTypeByName (initialized in init()).

View Source
var ObjTypeByName = map[string]ObjTypeId{
	"Boat":           ObjTypeIdBoat,
	"Minecart":       ObjTypeIdMinecart,
	"StorageCart":    ObjTypeIdStorageCart,
	"PoweredCart":    ObjTypeIdPoweredCart,
	"ActivatedTnt":   ObjTypeIdActivatedTnt,
	"Arrow":          ObjTypeIdArrow,
	"ThrownSnowball": ObjTypeIdThrownSnowball,
	"ThrownEgg":      ObjTypeIdThrownEgg,
	"FallingSand":    ObjTypeIdFallingSand,
	"FallingGravel":  ObjTypeIdFallingGravel,
	"FishingFloat":   ObjTypeIdFishingFloat,
}

Functions

This section is empty.

Types

type AbsCoord

type AbsCoord float64

Specifies exact world distance in blocks (floating point)

type AbsIntCoord

type AbsIntCoord int32

Specifies approximate world distance in pixels (absolute / PixelsPerBlock)

type AbsIntXyz

type AbsIntXyz struct {
	X, Y, Z AbsIntCoord
}

func (*AbsIntXyz) IAdd

func (abs *AbsIntXyz) IAdd(dx, dy, dz AbsIntCoord)

func (*AbsIntXyz) ToBlockXyz

func (p *AbsIntXyz) ToBlockXyz() *BlockXyz

func (*AbsIntXyz) ToChunkXz

func (abs *AbsIntXyz) ToChunkXz() *ChunkXz

Convert (x, z) absolute integer coordinates to chunk coordinates

type AbsVelocity

type AbsVelocity struct {
	X, Y, Z AbsVelocityCoord
}

func (*AbsVelocity) ToVelocity

func (v *AbsVelocity) ToVelocity() *Velocity

type AbsVelocityCoord

type AbsVelocityCoord AbsCoord

AbsVelocityCoord is measured in blocks per tick.

func (AbsVelocityCoord) ToVelocityComponent

func (v AbsVelocityCoord) ToVelocityComponent() VelocityComponent

type AbsXyz

type AbsXyz struct {
	X, Y, Z AbsCoord
}

func (*AbsXyz) ApplyVelocity

func (p *AbsXyz) ApplyVelocity(dt TickTime, v *AbsVelocity)

func (*AbsXyz) IsWithinDistanceOf

func (p *AbsXyz) IsWithinDistanceOf(other *AbsXyz, maxDistance AbsCoord) bool

func (*AbsXyz) ToAbsIntXyz

func (p *AbsXyz) ToAbsIntXyz() *AbsIntXyz

func (*AbsXyz) ToBlockXyz

func (p *AbsXyz) ToBlockXyz() *BlockXyz

func (*AbsXyz) ToChunkXz

func (p *AbsXyz) ToChunkXz() ChunkXz

Convert an (x, z) absolute coordinate pair to chunk coordinates

func (*AbsXyz) ToShardXz

func (p *AbsXyz) ToShardXz() ShardXz

type AngleBytes

type AngleBytes byte

An angle, where there are 256 units in a circle.

type AngleDegrees

type AngleDegrees float32

An angle in degrees

func (*AngleDegrees) ToAngleBytes

func (d *AngleDegrees) ToAngleBytes() AngleBytes

type BlockCoord

type BlockCoord int32

Coordinate of a block within the world

func (BlockCoord) ToChunkLocalCoord

func (b BlockCoord) ToChunkLocalCoord() (c ChunkCoord, s SubChunkCoord)

type BlockId

type BlockId byte

type BlockIndex

type BlockIndex uint32

func (BlockIndex) BlockData

func (bi BlockIndex) BlockData(blockData []byte) byte

func (BlockIndex) BlockId

func (bi BlockIndex) BlockId(blocks []byte) BlockId

func (BlockIndex) SetBlockData

func (bi BlockIndex) SetBlockData(blockData []byte, data byte)

SetBlockData is used to set block metadata inside an array of bytes, where each byte contains packed nibbles.

func (BlockIndex) SetBlockId

func (bi BlockIndex) SetBlockId(blocks []byte, id BlockId)

func (BlockIndex) ToSubChunkXyz

func (bi BlockIndex) ToSubChunkXyz() (subLoc SubChunkXyz)

type BlockXyz

type BlockXyz struct {
	X BlockCoord
	Y BlockYCoord
	Z BlockCoord
}

BlockXyz represents the position of a block within the world.

func (*BlockXyz) AddXyz

func (b *BlockXyz) AddXyz(dx BlockCoord, dy BlockYCoord, dz BlockCoord) (newb *BlockXyz)

Translate one block location to another by dx, dy, dz, checking for overflow. If overflow occurs, return nil. There may be a more elegant solution to check this, here we go for simplicity and clarity. This function assumes we cannot have a negative Y coordinate.

func (*BlockXyz) Equals

func (b *BlockXyz) Equals(rhs BlockXyz) bool

func (*BlockXyz) IsNull

func (b *BlockXyz) IsNull() bool

Test if a block location is not appropriate to the situation, but block location data passed (such as using an item not on a block).

func (*BlockXyz) IsZero

func (b *BlockXyz) IsZero() bool

Test if a block location is the 0 block. This is used in certain situations such as PacketPlayerBlockHit, when the player is throwing an item rather than hitting an item in a chunk.

func (*BlockXyz) MidPointToAbsXyz

func (blockLoc *BlockXyz) MidPointToAbsXyz() AbsXyz

func (*BlockXyz) ToAbsIntXyz

func (blockLoc *BlockXyz) ToAbsIntXyz() *AbsIntXyz

func (*BlockXyz) ToAbsXyz

func (blockLoc *BlockXyz) ToAbsXyz() *AbsXyz

func (*BlockXyz) ToChunkLocal

func (blockLoc *BlockXyz) ToChunkLocal() (chunkLoc *ChunkXz, subLoc *SubChunkXyz)

Convert an (x, y, z) block coordinate to chunk coordinates and the coordinates of the block within the chunk

func (*BlockXyz) ToChunkXz

func (blockLoc *BlockXyz) ToChunkXz() (chunkLoc *ChunkXz)

Convert an (x, y, z) block coordinate to chunk coordinates.

type BlockYCoord

type BlockYCoord int8

type ChunkCoord

type ChunkCoord int32

Coordinate of a chunk in the world (block / 16).

func (ChunkCoord) Abs

func (c ChunkCoord) Abs() ChunkCoord

func (ChunkCoord) ToShardCoord

func (c ChunkCoord) ToShardCoord() (s ShardCoord)

type ChunkLoadMode

type ChunkLoadMode byte

type ChunkXz

type ChunkXz struct {
	X, Z ChunkCoord
}

ChunkXz represents the position of a chunk within the world.

func (*ChunkXz) ChunkCornerBlockXY

func (chunkLoc *ChunkXz) ChunkCornerBlockXY() *BlockXyz

Returns the world BlockXyz position of the (0, 0, 0) block in the chunk

func (*ChunkXz) ChunkKey

func (chunkLoc *ChunkXz) ChunkKey() uint64

Converts a chunk location into a key suitable for using in a hash.

func (*ChunkXz) ToBlockXyz

func (chunkLoc *ChunkXz) ToBlockXyz(subLoc *SubChunkXyz) *BlockXyz

Convert a position within a chunk to a block position within the world

func (*ChunkXz) ToShardXz

func (chunkLoc *ChunkXz) ToShardXz() ShardXz

ToShardXz returns the location of the shard that the chunk is within.

type DigStatus

type DigStatus byte

type DimensionId

type DimensionId int8

Which 'world'?

type EntityAction

type EntityAction byte

type EntityAnimation

type EntityAnimation byte

type EntityId

type EntityId int32

func (EntityId) GetEntityId

func (e EntityId) GetEntityId() EntityId

func (*EntityId) SetEntityId

func (e *EntityId) SetEntityId(entityId EntityId)

type EntityMobType

type EntityMobType byte

The type of mob

type EntityStatus

type EntityStatus byte

type Face

type Face int8

Block face (0-5)

func (Face) Dxyz

func (f Face) Dxyz() (dx BlockCoord, dy BlockYCoord, dz BlockCoord)

type Health

type Health int16

Player/mob health.

type InstrumentId

type InstrumentId byte

type InvTypeId

type InvTypeId int8

type ItemCount

type ItemCount int8

How many items are in a stack/slot etc.

type ItemData

type ItemData int16

Item metadata. The meaning of this varies depending upon the item type. In the case of tools/armor it indicates "uses" or "damage".

type ItemTypeId

type ItemTypeId int16

Item type ID

func (ItemTypeId) ToBlockId

func (id ItemTypeId) ToBlockId() (blockId BlockId, ok bool)

ToBlockId returns the ItemTypeId as a BlockId, or 0, ok=false if it's not a valid BlockId.

type LookBytes

type LookBytes struct {
	Yaw, Pitch AngleBytes
}

type LookDegrees

type LookDegrees struct {
	// Pitch is -ve when looking above the horizontal, and +ve below
	Yaw, Pitch AngleDegrees
}

func (*LookDegrees) ToLookBytes

func (l *LookDegrees) ToLookBytes() *LookBytes

type NotePitch

type NotePitch byte

type ObjTypeId

type ObjTypeId int8

type OrientationBytes

type OrientationBytes struct {
	Yaw, Pitch, Roll AngleBytes
}

type OrientationDegrees

type OrientationDegrees struct {
	Yaw, Pitch, Roll AngleDegrees
}

type PaintingTypeId

type PaintingTypeId int32

type PrgBarId

type PrgBarId int16

type PrgBarValue

type PrgBarValue int16

type RandomSeed

type RandomSeed int64

type RelMove

type RelMove struct {
	X, Y, Z RelMoveCoord
}

type RelMoveCoord

type RelMoveCoord int8

Relative movement, using same units as AbsIntCoord, but in byte form so constrained

type ShardCoord

type ShardCoord int32

type ShardXz

type ShardXz struct {
	X, Z ShardCoord
}

func (*ShardXz) Equals

func (loc *ShardXz) Equals(other *ShardXz) bool

func (*ShardXz) Key

func (loc *ShardXz) Key() uint64

Converts a ShardXz location into a key suitable for using in a hash.

func (*ShardXz) ToChunkXz

func (loc *ShardXz) ToChunkXz() ChunkXz

type SlotId

type SlotId int16

ID of the slow in inventory or other item-slotted window element

type StatisticId

type StatisticId int32

ID specifying a player statistic.

type SubChunkCoord

type SubChunkCoord byte

Coordinate of a block within a chunk

type SubChunkSize

type SubChunkSize struct {
	X, Y, Z SubChunkSizeCoord
}

type SubChunkSizeCoord

type SubChunkSizeCoord byte

Size of a sub-chunk

type SubChunkXyz

type SubChunkXyz struct {
	X, Y, Z SubChunkCoord
}

SubChunkXyz represents the position of a block within a chunk.

func (*SubChunkXyz) BlockIndex

func (subLoc *SubChunkXyz) BlockIndex() (index BlockIndex, ok bool)

BlockIndex returns the relevant index for a block with a given position within a chunk. If subLoc represents an invalid position, then ok=False is returned.

type TickTime

type TickTime float64

1 "TickTime" is the duration of a server "tick". This value is intended for use in sub-tick physics calculations.

type Ticks

type Ticks int64

type TxId

type TxId int16

Transaction ID.

type TxState

type TxState byte

Transaction state.

type Velocity

type Velocity struct {
	X, Y, Z VelocityComponent
}

type VelocityComponent

type VelocityComponent int16

VelocityComponent in VelocityComponentBlocksPerTick

type WindowId

type WindowId int8

ID specifying which slotted window, such as inventory

Jump to

Keyboard shortcuts

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