Documentation
¶
Index ¶
- Constants
- Variables
- type AbsCoord
- type AbsIntCoord
- type AbsIntXyz
- type AbsVelocity
- type AbsVelocityCoord
- type AbsXyz
- type AngleBytes
- type AngleDegrees
- type BlockCoord
- type BlockId
- type BlockIndex
- type BlockXyz
- func (b *BlockXyz) AddXyz(dx BlockCoord, dy BlockYCoord, dz BlockCoord) (newb *BlockXyz)
- func (b *BlockXyz) Equals(rhs BlockXyz) bool
- func (b *BlockXyz) IsNull() bool
- func (b *BlockXyz) IsZero() bool
- func (blockLoc *BlockXyz) MidPointToAbsXyz() AbsXyz
- func (blockLoc *BlockXyz) ToAbsIntXyz() *AbsIntXyz
- func (blockLoc *BlockXyz) ToAbsXyz() *AbsXyz
- func (blockLoc *BlockXyz) ToChunkLocal() (chunkLoc *ChunkXz, subLoc *SubChunkXyz)
- func (blockLoc *BlockXyz) ToChunkXz() (chunkLoc *ChunkXz)
- type BlockYCoord
- type ChunkCoord
- type ChunkLoadMode
- type ChunkXz
- type DigStatus
- type DimensionId
- type EntityAction
- type EntityAnimation
- type EntityEffect
- type EntityId
- type EntityMobType
- type EntityStatus
- type Face
- type FoodUnits
- type GameDifficulty
- type GameType
- type Health
- type InstrumentId
- type InvTypeId
- type ItemCount
- type ItemData
- type ItemTypeId
- type LookBytes
- type LookDegrees
- type NotePitch
- type ObjTypeId
- type OrientationBytes
- type OrientationDegrees
- type PaintingTypeId
- type PrgBarId
- type PrgBarValue
- type RandomSeed
- type RelMove
- type RelMoveCoord
- type ShardCoord
- type ShardXz
- type SlotId
- type SoundEffect
- type StatisticId
- type SubChunkCoord
- type SubChunkSize
- type SubChunkSizeCoord
- type SubChunkXyz
- type TickTime
- type Ticks
- type TxId
- type TxState
- type Velocity
- type VelocityComponent
- type WindowId
Constants ¶
const ( TicksPerDay = 24000 TicksPerSecond = 20 NanosecondsInSecond = 1e9 )
const ( GameDifficultyPeaceful = 0 GameDifficultyEasy = 1 GameDifficultyNormal = 2 GameDifficultyHard = 3 )
const ( DimensionNether = DimensionId(-1) DimensionNormal = DimensionId(0) )
const ( GameTypeSurvival = GameType(0) GameTypeCreative = GameType(1) )
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) )
const ( EntityAnimationNone = EntityAnimation(0) EntityAnimationSwingArm = EntityAnimation(1) EntityAnimationDamage = EntityAnimation(2) EntityAnimationUnknown1 = EntityAnimation(102) EntityAnimationCrouch = EntityAnimation(104) EntityAnimationUncrouch = EntityAnimation(105) )
const ( EntityEffectMoveFaster = EntityEffect(1) EntityEffectMoveSlower = EntityEffect(2) EntityEffectDigFaster = EntityEffect(3) EntityEffectDigSlower = EntityEffect(4) EntityEffectDamageBoost = EntityEffect(5) EntityEffectHeal = EntityEffect(6) EntityEffectHarm = EntityEffect(7) EntityEffectJump = EntityEffect(8) EntityEffectConfusion = EntityEffect(9) EntityEffectRegeneration = EntityEffect(10) EntityEffectResistance = EntityEffect(11) EntityEffectFireResistance = EntityEffect(12) EntityEffectWaterBreathing = EntityEffect(13) EntityEffectInvisibility = EntityEffect(14) EntityEffectBlindness = EntityEffect(15) EntityEffectNightVision = EntityEffect(16) EntityEffectSick = EntityEffect(17) EntityEffectWeakness = EntityEffect(18) EntityEffectPoison = EntityEffect(19) )
const ( EntityActionCrouch = EntityAction(1) EntityActionUncrouch = EntityAction(2) )
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) )
const ( InstrumentIdDoubleBass = InstrumentId(1) InstrumentIdSnareDrum = InstrumentId(2) InstrumentIdSticks = InstrumentId(3) InstrumentIdBassDrum = InstrumentId(4) InstrumentIdHarp = InstrumentId(5) )
const ( NotePitchMin = NotePitch(0) NotePitchMax = NotePitch(24) )
const ( SoundEffectClick2 = SoundEffect(1000) SoundEffectClick1 = SoundEffect(1001) SoundEffectBowFire = SoundEffect(1002) SoundEffectDoor = SoundEffect(1003) SoundEffectExtinguish = SoundEffect(1004) SoundEffectRecordPlay = SoundEffect(1005) SoundEffectSmoke = SoundEffect(2000) SoundEffectBlockBreak = SoundEffect(2001) )
const ( BlockIdMin = 0 BlockIdAir = BlockId(0) BlockIdMax = 255 )
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).
const ( DigStarted = DigStatus(0) DigBlockBroke = DigStatus(2) DigDropItem = DigStatus(4) )
const ( WindowIdCursor = WindowId(-1) WindowIdInventory = WindowId(0) WindowIdFreeMin = WindowId(1) WindowIdFreeMax = WindowId(127) )
const ( InvTypeIdChest = InvTypeId(0) InvTypeIdWorkbench = InvTypeId(1) InvTypeIdFurnace = InvTypeId(2) InvTypeIdDispenser = InvTypeId(3) )
const ( SlotIdCursor = SlotId(-1) SlotIdNull = SlotId(999) // Clicked outside window. )
const ( PrgBarIdFurnaceProgress = PrgBarId(0) PrgBarIdFurnaceFire = PrgBarId(1) )
const ( TxStateAccepted = TxState(iota) TxStateRejected TxStateDeferred )
const ( VelocityComponentMax = 28800 VelocityComponentMin = -28800 AbsToIntVelocityComponent = TicksPerSecond * 32000 / 100 )
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 )
const ( MaxXCoord = math.MaxInt32 MinXCoord = math.MinInt32 MaxYCoord = math.MaxInt8 MinYCoord = 0 MaxZCoord = math.MaxInt32 MinZCoord = math.MinInt32 )
const ( // Client should unload the chunk ChunkUnload = ChunkLoadMode(0) // Client should initialise the chunk ChunkInit = ChunkLoadMode(1) )
const (
DegreesToBytes = 256.0 / 360.0
)
const ( // MaxInteractDistance is the maximum distance at which a player can interact // with something, such as dig. MaxInteractDistance = AbsCoord(6) )
const (
// Each shard is ShardSize * ShardSize chunks square.
ShardSize = 16
)
Variables ¶
var MobNameByType = map[EntityMobType]string{}
MobNameByType reverses the MobTypeByName mapping, initialized in init().
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, }
var ObjNameByType = map[ObjTypeId]string{}
ObjNameByType reverses ObjTypeByName (initialized in init()).
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 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 ¶
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 (*AbsXyz) ToAbsIntXyz ¶
func (*AbsXyz) ToBlockXyz ¶
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 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) IsNull ¶
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 ¶
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 (*BlockXyz) ToAbsIntXyz ¶
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
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 ¶
Returns the world BlockXyz position of the (0, 0, 0) block in the chunk
func (*ChunkXz) ToBlockXyz ¶
func (chunkLoc *ChunkXz) ToBlockXyz(subLoc *SubChunkXyz) *BlockXyz
Convert a position within a chunk to a block position within the world
type EntityAction ¶
type EntityAction byte
type EntityAnimation ¶
type EntityAnimation byte
type EntityEffect ¶
type EntityEffect byte
EntityEffect is an effect that can be placed on a player (and other things?).
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 GameDifficulty ¶
type GameDifficulty int8
type InstrumentId ¶
type InstrumentId byte
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 OrientationBytes ¶
type OrientationBytes struct {
Yaw, Pitch, Roll AngleBytes
}
type OrientationDegrees ¶
type OrientationDegrees struct {
Yaw, Pitch, Roll AngleDegrees
}
type PaintingTypeId ¶
type PaintingTypeId int32
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
}
type SubChunkSize ¶
type SubChunkSize struct {
X, Y, Z SubChunkSizeCoord
}
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 Velocity ¶
type Velocity struct {
X, Y, Z VelocityComponent
}
type VelocityComponent ¶
type VelocityComponent int16
VelocityComponent in VelocityComponentBlocksPerTick