proto

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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientReadHandshake

func ClientReadHandshake(reader io.Reader) (serverId string, err os.Error)

func ClientReadPacket

func ClientReadPacket(reader io.Reader, handler IClientPacketHandler) os.Error

A client should call this to receive a single packet from a client. It will block until a packet was successfully handled, or there was an error.

func ClientWriteLogin

func ClientWriteLogin(writer io.Writer, username, password string) (err os.Error)

func ClientWritePlayerPositionLook

func ClientWritePlayerPositionLook(writer io.Writer, position *AbsXyz, stance AbsCoord, look *LookDegrees, onGround bool) (err os.Error)

func ServerReadHandshake

func ServerReadHandshake(reader io.Reader) (username string, err os.Error)

func ServerReadLogin

func ServerReadLogin(reader io.Reader) (username string, err os.Error)

func ServerReadPacket

func ServerReadPacket(reader io.Reader, handler IServerPacketHandler) os.Error

A server should call this to receive a single packet from a client. It will block until a packet was successfully handled, or there was an error.

func ServerWriteHandshake

func ServerWriteHandshake(writer io.Writer, reply string) (err os.Error)

func ServerWriteLogin

func ServerWriteLogin(writer io.Writer, entityId EntityId, mapSeed RandomSeed, dimension DimensionId) (err os.Error)

func ServerWritePlayerPositionLook

func ServerWritePlayerPositionLook(writer io.Writer, position *AbsXyz, stance AbsCoord, look *LookDegrees, onGround bool) (err os.Error)

func ServerWriteTimeUpdate

func ServerWriteTimeUpdate(writer io.Writer, time Ticks) os.Error

func WriteBedInvalid

func WriteBedInvalid(writer io.Writer, field1 byte) (err os.Error)

TODO Revise this when packet better understood.

func WriteBedUse

func WriteBedUse(writer io.Writer, flag bool, bedLoc *BlockXyz) (err os.Error)

func WriteBlockChange

func WriteBlockChange(writer io.Writer, blockLoc *BlockXyz, blockType BlockId, blockMetaData byte) (err os.Error)

func WriteBlockChangeMulti

func WriteBlockChangeMulti(writer io.Writer, chunkLoc *ChunkXz, blockCoords []SubChunkXyz, blockTypes []BlockId, blockMetaData []byte) (err os.Error)

func WriteChatMessage

func WriteChatMessage(writer io.Writer, message string) (err os.Error)

func WriteDisconnect

func WriteDisconnect(writer io.Writer, reason string) (err os.Error)

func WriteEntity

func WriteEntity(writer io.Writer, entityId EntityId) (err os.Error)

func WriteEntityAction

func WriteEntityAction(writer io.Writer, entityId EntityId, action EntityAction) (err os.Error)

func WriteEntityAnimation

func WriteEntityAnimation(writer io.Writer, entityId EntityId, animation EntityAnimation) (err os.Error)

func WriteEntityDestroy

func WriteEntityDestroy(writer io.Writer, entityId EntityId) os.Error

func WriteEntityEquipment

func WriteEntityEquipment(writer io.Writer, entityId EntityId, slot SlotId, itemTypeId ItemTypeId, data ItemData) (err os.Error)

func WriteEntityLook

func WriteEntityLook(writer io.Writer, entityId EntityId, look *LookBytes) os.Error

func WriteEntityLookAndRelMove

func WriteEntityLookAndRelMove(writer io.Writer, entityId EntityId, movement *RelMove, look *LookBytes) (err os.Error)

func WriteEntityMetadata

func WriteEntityMetadata(writer io.Writer, entityId EntityId, data []EntityMetadata) (err os.Error)

func WriteEntityRelMove

func WriteEntityRelMove(writer io.Writer, entityId EntityId, movement *RelMove) (err os.Error)

func WriteEntitySpawn

func WriteEntitySpawn(writer io.Writer, entityId EntityId, mobType EntityMobType, position *AbsIntXyz, look *LookBytes, data []EntityMetadata) (err os.Error)

func WriteEntityStatus

func WriteEntityStatus(writer io.Writer, entityId EntityId, status EntityStatus) (err os.Error)

func WriteEntityTeleport

func WriteEntityTeleport(writer io.Writer, entityId EntityId, position *AbsIntXyz, look *LookBytes) os.Error

func WriteEntityVelocity

func WriteEntityVelocity(writer io.Writer, entityId EntityId, velocity *Velocity) (err os.Error)

func WriteExplosion

func WriteExplosion(writer io.Writer, position *AbsXyz, power float32, blockOffsets []ExplosionOffsetXyz) (err os.Error)

func WriteHoldingChange

func WriteHoldingChange(writer io.Writer, slotId SlotId) (err os.Error)

func WriteIncrementStatistic

func WriteIncrementStatistic(writer io.Writer, statisticId StatisticId, delta int8) (err os.Error)

func WriteItemCollect

func WriteItemCollect(writer io.Writer, collectedItem EntityId, collector EntityId) (err os.Error)

func WriteItemSpawn

func WriteItemSpawn(writer io.Writer, entityId EntityId, itemTypeId ItemTypeId, amount ItemCount, data ItemData, position *AbsIntXyz, orientation *OrientationBytes) os.Error

func WriteKeepAlive

func WriteKeepAlive(writer io.Writer) os.Error

func WriteMapChunk

func WriteMapChunk(writer io.Writer, chunkLoc *ChunkXz, blocks, blockData, blockLight, skyLight []byte) (err os.Error)

func WriteNamedEntitySpawn

func WriteNamedEntitySpawn(writer io.Writer, entityId EntityId, name string, position *AbsIntXyz, look *LookBytes, currentItem ItemTypeId) (err os.Error)

func WriteNoteBlockPlay

func WriteNoteBlockPlay(writer io.Writer, position *BlockXyz, instrument InstrumentId, pitch NotePitch) (err os.Error)

func WriteObjectSpawn

func WriteObjectSpawn(writer io.Writer, entityId EntityId, objType ObjTypeId, position *AbsIntXyz, objectData *ObjectData) (err os.Error)

func WritePaintingSpawn

func WritePaintingSpawn(writer io.Writer, entityId EntityId, title string, position *BlockXyz, paintingType PaintingTypeId) (err os.Error)

func WritePlayer

func WritePlayer(writer io.Writer, onGround bool) (err os.Error)

func WritePlayerBlockHit

func WritePlayerBlockHit(writer io.Writer, status DigStatus, blockLoc *BlockXyz, face Face) (err os.Error)

func WritePlayerBlockInteract

func WritePlayerBlockInteract(writer io.Writer, itemTypeId ItemTypeId, blockLoc *BlockXyz, face Face, amount ItemCount, data ItemData) (err os.Error)

func WritePlayerLook

func WritePlayerLook(writer io.Writer, look *LookDegrees, onGround bool) (err os.Error)

func WritePlayerPosition

func WritePlayerPosition(writer io.Writer, position *AbsXyz, stance AbsCoord, onGround bool) os.Error

func WritePreChunk

func WritePreChunk(writer io.Writer, chunkLoc *ChunkXz, mode ChunkLoadMode) os.Error

func WriteRespawn

func WriteRespawn(writer io.Writer, dimension DimensionId) os.Error

func WriteSignUpdate

func WriteSignUpdate(writer io.Writer, position *BlockXyz, lines [4]string) (err os.Error)

func WriteSpawnPosition

func WriteSpawnPosition(writer io.Writer, position *BlockXyz) os.Error

func WriteUnknown0x3d

func WriteUnknown0x3d(writer io.Writer, field1, field2 int32, field3 int8, field4, field5 int32) (err os.Error)

func WriteUnknown0x83

func WriteUnknown0x83(writer io.Writer, field1, field2 int16, field3 string) (err os.Error)

func WriteUpdateHealth

func WriteUpdateHealth(writer io.Writer, health Health) (err os.Error)

func WriteUseEntity

func WriteUseEntity(writer io.Writer, user EntityId, target EntityId, leftClick bool) (err os.Error)

func WriteWeather

func WriteWeather(writer io.Writer, entityId EntityId, raining bool, position *AbsIntXyz) (err os.Error)

func WriteWindowClick

func WriteWindowClick(writer io.Writer, windowId WindowId, slot SlotId, rightClick bool, txId TxId, shiftClick bool, expectedSlot WindowSlot) (err os.Error)

func WriteWindowClose

func WriteWindowClose(writer io.Writer, windowId WindowId) (err os.Error)

func WriteWindowItems

func WriteWindowItems(writer io.Writer, windowId WindowId, items []WindowSlot) (err os.Error)

func WriteWindowOpen

func WriteWindowOpen(writer io.Writer, windowId WindowId, invTypeId InvTypeId, windowTitle string, numSlots byte) (err os.Error)

func WriteWindowProgressBar

func WriteWindowProgressBar(writer io.Writer, windowId WindowId, prgBarId PrgBarId, value PrgBarValue) os.Error

func WriteWindowSetSlot

func WriteWindowSetSlot(writer io.Writer, windowId WindowId, slot SlotId, itemTypeId ItemTypeId, amount ItemCount, data ItemData) (err os.Error)

func WriteWindowTransaction

func WriteWindowTransaction(writer io.Writer, windowId WindowId, txId TxId, accepted bool) (err os.Error)

Types

type EntityMetadata

type EntityMetadata struct {
	Field1 byte
	Field2 byte
	Field3 interface{}
}

type ExplosionOffsetXyz

type ExplosionOffsetXyz struct {
	X, Y, Z int8
}

type IClientPacketHandler

type IClientPacketHandler interface {
	IPacketHandler
	ClientPacketLogin(entityId EntityId, mapSeed RandomSeed, dimension DimensionId)
	PacketTimeUpdate(time Ticks)
	PacketBedUse(flag bool, bedLoc *BlockXyz)
	PacketNamedEntitySpawn(entityId EntityId, name string, position *AbsIntXyz, look *LookBytes, currentItem ItemTypeId)
	PacketEntityEquipment(entityId EntityId, slot SlotId, itemTypeId ItemTypeId, data ItemData)
	PacketSpawnPosition(position *BlockXyz)
	PacketUpdateHealth(health Health)
	PacketItemSpawn(entityId EntityId, itemTypeId ItemTypeId, count ItemCount, data ItemData, location *AbsIntXyz, orientation *OrientationBytes)
	PacketItemCollect(collectedItem EntityId, collector EntityId)
	PacketObjectSpawn(entityId EntityId, objType ObjTypeId, position *AbsIntXyz, objectData *ObjectData)
	PacketEntitySpawn(entityId EntityId, mobType EntityMobType, position *AbsIntXyz, look *LookBytes, data []EntityMetadata)
	PacketPaintingSpawn(entityId EntityId, title string, position *BlockXyz, paintingType PaintingTypeId)
	PacketEntityVelocity(entityId EntityId, velocity *Velocity)
	PacketEntityDestroy(entityId EntityId)
	PacketEntity(entityId EntityId)
	PacketEntityRelMove(entityId EntityId, movement *RelMove)
	PacketEntityLook(entityId EntityId, look *LookBytes)
	PacketEntityTeleport(entityId EntityId, position *AbsIntXyz, look *LookBytes)
	PacketEntityStatus(entityId EntityId, status EntityStatus)
	PacketEntityMetadata(entityId EntityId, metadata []EntityMetadata)

	PacketPreChunk(position *ChunkXz, mode ChunkLoadMode)
	PacketMapChunk(position *BlockXyz, size *SubChunkSize, data []byte)
	PacketBlockChangeMulti(chunkLoc *ChunkXz, blockCoords []SubChunkXyz, blockTypes []BlockId, blockMetaData []byte)
	PacketBlockChange(blockLoc *BlockXyz, blockType BlockId, blockMetaData byte)
	PacketNoteBlockPlay(position *BlockXyz, instrument InstrumentId, pitch NotePitch)

	// NOTE method signature likely to change
	PacketExplosion(position *AbsXyz, power float32, blockOffsets []ExplosionOffsetXyz)

	PacketBedInvalid(field1 byte)
	PacketWeather(entityId EntityId, raining bool, position *AbsIntXyz)

	PacketWindowOpen(windowId WindowId, invTypeId InvTypeId, windowTitle string, numSlots byte)
	PacketWindowSetSlot(windowId WindowId, slot SlotId, itemTypeId ItemTypeId, amount ItemCount, data ItemData)
	PacketWindowItems(windowId WindowId, items []WindowSlot)
	PacketWindowProgressBar(windowId WindowId, prgBarId PrgBarId, value PrgBarValue)
	PacketUnknown0x83(field1, field2 int16, field3 string)
	PacketIncrementStatistic(statisticId StatisticId, delta int8)
}

Clients to the protocol must implement this interface to receive packets

type IPacketHandler

type IPacketHandler interface {
	PacketKeepAlive()
	PacketChatMessage(message string)
	PacketEntityAction(entityId EntityId, action EntityAction)
	PacketUseEntity(user EntityId, target EntityId, leftClick bool)
	PacketRespawn(dimension DimensionId)
	PacketPlayerPosition(position *AbsXyz, stance AbsCoord, onGround bool)
	PacketPlayerLook(look *LookDegrees, onGround bool)
	PacketPlayerBlockHit(status DigStatus, blockLoc *BlockXyz, face Face)
	PacketPlayerBlockInteract(itemTypeId ItemTypeId, blockLoc *BlockXyz, face Face, amount ItemCount, data ItemData)
	PacketEntityAnimation(entityId EntityId, animation EntityAnimation)
	PacketUnknown0x1b(field1, field2 float32, field3, field4 bool, field5, field6 float32)
	PacketUnknown0x3d(field1, field2 int32, field3 int8, field4, field5 int32)
	PacketWindowTransaction(windowId WindowId, txId TxId, accepted bool)
	PacketSignUpdate(position *BlockXyz, lines [4]string)
	PacketDisconnect(reason string)
}

Packets commonly received by both client and server

type IServerPacketHandler

type IServerPacketHandler interface {
	IPacketHandler
	PacketPlayer(onGround bool)
	PacketHoldingChange(slotId SlotId)
	PacketWindowClose(windowId WindowId)
	PacketWindowClick(windowId WindowId, slot SlotId, rightClick bool, txId TxId, shiftClick bool, expectedSlot *WindowSlot)
}

Servers to the protocol must implement this interface to receive packets

type ObjectData

type ObjectData struct {
	Field1 int32
	Field2 [3]uint16
}

type WindowSlot

type WindowSlot struct {
	ItemTypeId ItemTypeId
	Count      ItemCount
	Data       ItemData
}

Jump to

Keyboard shortcuts

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