highmc

package module
v0.0.0-...-94daeb9 Latest Latest
Warning

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

Go to latest
Published: May 15, 2016 License: LGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoginHead byte = 0x8f + iota
	PlayStatusHead
	DisconnectHead
	BatchHead
	TextHead
	SetTimeHead
	StartGameHead
	AddPlayerHead
	RemovePlayerHead
	AddEntityHead
	RemoveEntityHead
	AddItemEntityHead
	TakeItemEntityHead
	MoveEntityHead
	MovePlayerHead
	RemoveBlockHead
	UpdateBlockHead
	AddPaintingHead
	ExplodeHead
	LevelEventHead
	BlockEventHead
	EntityEventHead
	MobEffectHead
	UpdateAttributesHead
	MobEquipmentHead
	MobArmorEquipmentHead
	InteractHead
	UseItemHead
	PlayerActionHead
	HurtArmorHead
	SetEntityDataHead
	SetEntityMotionHead
	SetEntityLinkHead
	SetHealthHead
	SetSpawnPositionHead
	AnimateHead
	RespawnHead
	DropItemHead
	ContainerOpenHead
	ContainerCloseHead
	ContainerSetSlotHead
	ContainerSetDataHead
	ContainerSetContentHead
	CraftingDataHead
	CraftingEventHead
	AdventureSettingsHead
	BlockEntityDataHead

	FullChunkDataHead
	SetDifficultyHead

	SetPlayerGametypeHead
	PlayerListHead

	RequestChunkRadiusHead
	ChunkRadiusUpdateHead
)

Packet IDs

View Source
const (
	LoginSuccess uint32 = iota
	LoginFailedClient
	LoginFailedServer
	PlayerSpawn
)

Packet-specific constants

View Source
const (
	TextTypeRaw byte = iota
	TextTypeChat
	TextTypeTranslation
	TextTypePopup
	TextTypeTip
	TextTypeSystem
)

Packet-specific constants

View Source
const (
	DayTime     = 0
	SunsetTime  = 12000
	NightTime   = 14000
	SunriseTime = 23000
	FullTime    = 24000
)

Packet-specific constants

View Source
const (
	ModeNormal   byte = 0
	ModeReset    byte = 1
	ModeRotation byte = 2
)

Packet-specific constants

View Source
const (
	UpdateNone byte = (1 << iota) >> 1
	UpdateNeighbors
	UpdateNetwork
	UpdateNographic
	UpdatePriority
	UpdateAll         = UpdateNeighbors | UpdateNetwork
	UpdateAllPriority = UpdateAll | UpdatePriority
)

Packet-specific constants

View Source
const (
	EventSoundClick                = 1000
	EventSoundClickFail            = 1001
	EventSoundShoot                = 1002
	EventSoundDoor                 = 1003
	EventSoundFizz                 = 1004
	EventSoundTNT                  = 1005
	EventSoundGhast                = 1007
	EventSoundGhastShoot           = 1008
	EventSoundBlazeShoot           = 1009
	EventSoundDoorBump             = 1010
	EventSoundDoorCrash            = 1012
	EventSoundBatFly               = 1015
	EventSoundZombieInfect         = 1016
	EventSoundZombieHeal           = 1017
	EventSoundEndermanTeleport     = 1018
	EventSoundAnvilBreak           = 1020
	EventSoundAnvilUse             = 1021
	EventSoundAnvilFall            = 1022
	EventSoundItemDrop             = 1030
	EventSoundItemThrown           = 1031
	EventSoundItemFrameItemAdded   = 1040
	EventSoundItemFramePlaced      = 1041
	EventSoundItemFrameRemoved     = 1042
	EventSoundItemFrameItemRemoved = 1043
	EventSoundItemFrameItemRotated = 1044
	EventSoundButtonClick          = 3500
	EventParticleShoot             = 2000
	EventParticleDestroy           = 2001
	EventParticleSplash            = 2002
	EventParticleEyeDespawn        = 2003
	EventParticleSpawn             = 2004
	EventParticleUnknown           = 2005
	EventStartRain                 = 3001
	EventStartThunder              = 3002
	EventStopRain                  = 3003
	EventStopThunder               = 3004
	EventSetData                   = 4000
	EventPlayersSleeping           = 9800
)

Packet-specific constants

View Source
const (
	EventHurtAnimation byte = iota + 2
	EventDeathAnimation

	EventTameFail
	EventTameSuccess
	EventShakeWet
	EventUseItem
	EventEatGrassAnimation
	EventFishHookBubble
	EventFishHookPosition
	EventFishHookHook
	EventFishHookTease
	EventSquidInkCloud
	EventAmbientSound
	EventRespawn
)

Packet-specific constants

View Source
const (
	EffectAdd byte = iota + 1
	EffectModify
	EffectRemove
)

Packet-specific constants

View Source
const (
	ActionStartBreak uint32 = iota
	ActionAbortBreak
	ActionStopBreak

	ActionReleaseItem
	ActionStopSleeping
	ActionRespawn
	ActionJump
	ActionStartSprint
	ActionStopSprint
	ActionStartSneak
	ActionStopSneak
	ActionDimensionChange
)

Packet-specific constants

View Source
const (
	InventoryWindow byte = 0
	ArmorWindow     byte = 0x78
	CreativeWindow  byte = 0x79
)

Packet-specific constants

View Source
const (
	OrderColumns byte = 0
	OrderLayered byte = 1
)

Packet-specific constants

View Source
const (
	PlayerListRemove byte = 0 // UUID only
	PlayerListAdd    byte = 1 // Everything!
)

Packet-specific constants

View Source
const (
	// RaknetMagic is a magic bytes for internal Raknet protocol.
	RaknetMagic = "\x00\xff\xff\x00\xfe\xfe\xfe\xfe\xfd\xfd\xfd\xfd\x12\x34\x56\x78"
	// RaknetProtocol is a internal Raknet protocol version.
	RaknetProtocol = 7
	// MinecraftProtocol is a mojang network protocol version.
	MinecraftProtocol = 60
	// MinecraftVersion is a human readable minecraft version.
	MinecraftVersion = "0.14.2"
)
View Source
const (
	Rose                = Poppy              // 38
	JackOLantern        = LitPumpkin         // 91
	Workbench           = CraftingTable      // 58
	RedstoneDust        = Redstone           // 331
	BakedPotatoes       = BakedPotato        // 393
	Potatoes            = Potato             // 392
	StoneWall           = CobbleWall         // 139
	MelonSlice          = Melon              // 360
	LitRedstoneOre      = GlowingRedstoneOre // 74
	GoldenShovel        = GoldShovel         // 284
	WoodSlabs           = WoodSlab           // 158
	WheatSeeds          = Seeds              // 295
	EnchantmentTable    = EnchantingTable    // 116
	NetherQuartz        = Quartz             // 406
	EnchantTable        = EnchantingTable    // 116
	Planks              = Plank              // 5
	DarkOakWoodenStairs = DarkOakWoodStairs  // 164
	NetherBrickBlock    = NetherBricks       // 112
	WoodDoorBlock       = DoorBlock          // 64
	WoodenDoorBlock     = DoorBlock          // 64
	GoldenAxe           = GoldAxe            // 286
	OakWoodStairs       = WoodStairs         // 53
	MossyStone          = MossStone          // 48
	GlassPanel          = GlassPane          // 102
	CookedBeef          = Steak              // 364
	SnowLayer           = Snow               // 78
	SugarcaneBlock      = Reeds              // 83
	WoodenPlank         = Plank              // 5
	Trunk2              = Wood2              // 162
	GoldenSword         = GoldSword          // 283
	WoodenSlab          = WoodSlab           // 158
	WoodenStairs        = WoodStairs         // 53
	RedFlower           = Poppy              // 38
	AcaciaWoodenStairs  = AcaciaWoodStairs   // 163
	OakWoodenStairs     = WoodStairs         // 53
	FlintAndSteel       = FlintSteel         // 259
	Slabs               = Slab               // 44
	GlowstoneBlock      = Glowstone          // 89
	Leave2              = Leaves2            // 161
	DoubleWoodSlabs     = DoubleWoodSlab     // 157
	Carrots             = Carrot             // 391
	DoubleWoodenSlabs   = DoubleWoodSlab     // 157
	BeetrootSeed        = BeetrootSeeds      // 458
	SugarCane           = Sugarcane          // 338
	GoldenHoe           = GoldHoe            // 294
	CobblestoneWall     = CobbleWall         // 139
	StoneBrick          = StoneBricks        // 98
	LitFurnace          = BurningFurnace     // 62
	JungleWoodenStairs  = JungleWoodStairs   // 136
	SpruceWoodenStairs  = SpruceWoodStairs   // 134
	DeadBush            = Bush               // 32
	DoubleSlabs         = DoubleSlab         // 43
	LilyPad             = WaterLily          // 111
	Sticks              = Stick              // 280
	Log2                = Wood2              // 162
	Vines               = Vine               // 106
	WoodenPlanks        = Plank              // 5
	Cobble              = Cobblestone        // 4
	IronBars            = IronBar            // 101
	Saplings            = Sapling            // 6
	BricksBlock         = Bricks             // 45
	Leave               = Leaves             // 18
	Wood                = Log                // 17
	WoodenSlabs         = WoodSlab           // 158
	BirchWoodenStairs   = BirchWoodStairs    // 135
	Trunk               = Log                // 17
	DoubleWoodenSlab    = DoubleWoodSlab     // 157
	GoldenNugget        = GoldNugget         // 371
	SugarCanes          = Sugarcane          // 338
	CobblestoneStairs   = CobbleStairs       // 67
	StainedHardenedClay = StainedClay        // 159
	GoldenPickaxe       = GoldPickaxe        // 285
)

aliases

View Source
const (
	SideDown  = iota // Y-
	SideUp           // Y+
	SideNorth        // Z-
	SideSouth        // Z+
	SideWest         // X-
	SideEast         // X+
)

Face/Side indicators

View Source
const (
	South = iota // Z+
	West         // X-
	North        // Z-
	East         // X+
)

Direction indicators

View Source
const MaxPingTries uint64 = 3

MaxPingTries defines max retry count on ping timeout. If ping timeouts MaxPingTries + 1 times, session will be closed.

View Source
const RecoveryTimeout = time.Second * 8

RecoveryTimeout defines how long packets can live on recoery queue. Once the packet is sent, the packet will be on recoery queue in RecoveryTimeout duration.

View Source
const (
	// Version is a version of this server.
	Version = "1.1.0 alpha-dev"
)

Variables

View Source
var AddressTemplate = []*net.UDPAddr{
	{IP: []byte{127, 0, 0, 1}, Port: 0},
	{IP: []byte{0, 0, 0, 0}, Port: 0},
	{IP: []byte{0, 0, 0, 0}, Port: 0},
	{IP: []byte{0, 0, 0, 0}, Port: 0},
	{IP: []byte{0, 0, 0, 0}, Port: 0},
	{IP: []byte{0, 0, 0, 0}, Port: 0},
	{IP: []byte{0, 0, 0, 0}, Port: 0},
	{IP: []byte{0, 0, 0, 0}, Port: 0},
	{IP: []byte{0, 0, 0, 0}, Port: 0},
	{IP: []byte{0, 0, 0, 0}, Port: 0},
}

AddressTemplate ...

View Source
var BuildTime = "unknown"

BuildTime is a timestamp when the program is built. You should set this with -ldflags "-X github.com/cr0sh/highmc.BuildTime="

View Source
var CreativeItems = []Item{}/* 474 elements not displayed */

CreativeItems is a list of inventory items for creative mode players.

View Source
var FallbackChunk = *new(Chunk)

FallbackChunk is a chunk to be returned if level provider fails to load chunk from file.

View Source
var GitCommit = "unknown"

GitCommit is a git commit hash for this project. You should set this with -ldflags "-X github.com/cr0sh/highmc.GitVersion="

View Source
var MaxPlayers int32

MaxPlayers is count of maximum available players

View Source
var OnlinePlayers int32

OnlinePlayers is count of online players

View Source
var Pool = make(BufferPool, 1024)

Pool is a default buffer pool for server.

View Source
var ServerName string

ServerName contains human readable server name

Functions

func BatchRead

func BatchRead(rd io.Reader, p ...interface{})

BatchRead batches ReadAny from given reference pointers.

func BatchWrite

func BatchWrite(wr io.Writer, p ...interface{})

BatchWrite batches WriteAny from given values.

func DecodeAck

func DecodeAck(b *bytes.Buffer) (t []uint32)

DecodeAck unpacks packet sequence numbers from given

func DecodeDeflate

func DecodeDeflate(b []byte) (*bytes.Buffer, error)

DecodeDeflate returns decompressed data of given byte slice.

func Dump

func Dump(buf *bytes.Buffer)

Dump prints hexdump for given

func EncodeAck

func EncodeAck(t ackTable) (b *bytes.Buffer)

EncodeAck packs packet sequence numbers into Raknet acknowledgment format.

func EncodeDeflate

func EncodeDeflate(b *bytes.Buffer) []byte

EncodeDeflate returns compressed data of given byte slice.

func GetServerString

func GetServerString() string

GetServerString returns server status message for unconnected pong

func GetSortedKeys

func GetSortedKeys(m interface{}) []int

GetSortedKeys will return a sorted slice of 'uint' keys from given map.

func NewPlayer

func NewPlayer(session *session) *player

NewPlayer creates new player struct.

func NewSession

func NewSession(address *net.UDPAddr) *session

NewSession returns new session instance.

func Read

func Read(rd io.Reader, n int) (b []byte, err error)

Read reads n bytes of data from buf. If buf returns smaller slice than n, returns OverFlow.

func ReadAddress

func ReadAddress(rd io.Reader) (addr *net.UDPAddr)

ReadAddress reads IP address/port from buffer.

func ReadAny

func ReadAny(rd io.Reader, p interface{})

ReadAny reads appropriate type from given reference value.

func ReadBool

func ReadBool(rd io.Reader) bool

ReadBool reads boolean from buffer.

func ReadByte

func ReadByte(rd io.Reader) byte

ReadByte reads unsigned byte from buffer.

func ReadDouble

func ReadDouble(rd io.Reader) float64

ReadDouble reads 64-bit float from buffer.

func ReadFloat

func ReadFloat(rd io.Reader) float32

ReadFloat reads 32-bit float from buffer.

func ReadInt

func ReadInt(rd io.Reader) uint32

ReadInt reads unsigned int from buffer.

func ReadLInt

func ReadLInt(rd io.Reader) uint32

ReadLInt reads unsigned little-endian int from buffer.

func ReadLLong

func ReadLLong(rd io.Reader) uint64

ReadLLong reads unsigned little-endian long from buffer.

func ReadLShort

func ReadLShort(rd io.Reader) uint16

ReadLShort reads unsigned little-endian short from buffer.

func ReadLTriad

func ReadLTriad(rd io.Reader) uint32

ReadLTriad reads unsigned little-endian 3-bytes triad from buffer.

func ReadLong

func ReadLong(rd io.Reader) uint64

ReadLong reads unsigned long from buffer.

func ReadShort

func ReadShort(rd io.Reader) uint16

ReadShort reads unsigned short from buffer.

func ReadString

func ReadString(rd io.Reader) (str string)

ReadString reads string from buffer.

func ReadTriad

func ReadTriad(rd io.Reader) uint32

ReadTriad reads unsigned 3-bytes triad from buffer.

func RegisterProvider

func RegisterProvider(provider LevelProvider)

RegisterProvider adds level format provider for server.

func Safe

func Safe(panicFunc func()) error

Safe runs panicFunc, recovers panic if exists, and returns as error.

func Try

func Try(tryFunc func(), panicHandle func(interface{}))

Try runs tryFunc, catches panic, and executes panicHandle with recovered panic.

func Write

func Write(wr io.Writer, b []byte) error

Write writes given byte array to buffer.

func WriteAddress

func WriteAddress(wr io.Writer, i *net.UDPAddr)

WriteAddress writes net.UDPAddr address to buffer.

func WriteAny

func WriteAny(wr io.Writer, p interface{})

WriteAny writes appropriate type from given interface{} value to buffer.

func WriteBool

func WriteBool(wr io.Writer, n bool)

WriteBool writes boolean to buffer.

func WriteByte

func WriteByte(wr io.Writer, n byte)

WriteByte writes unsigned byte to buffer.

func WriteDouble

func WriteDouble(wr io.Writer, f float64)

WriteDouble writes 64-bit float to buffer.

func WriteFloat

func WriteFloat(wr io.Writer, f float32)

WriteFloat writes 32-bit float to buffer.

func WriteInt

func WriteInt(wr io.Writer, n uint32)

WriteInt writes unsigned int to buffer.

func WriteLInt

func WriteLInt(wr io.Writer, n uint32)

WriteLInt writes unsigned little-endian int to buffer.

func WriteLLong

func WriteLLong(wr io.Writer, n uint64)

WriteLLong writes unsigned little-endian long to buffer.

func WriteLShort

func WriteLShort(wr io.Writer, n uint16)

WriteLShort writes unsigned little-endian short to buffer.

func WriteLTriad

func WriteLTriad(wr io.Writer, n uint32) error

WriteLTriad writes unsigned little-endian 3-bytes triad to buffer.

func WriteLong

func WriteLong(wr io.Writer, n uint64)

WriteLong writes unsigned long to buffer.

func WriteShort

func WriteShort(wr io.Writer, n uint16)

WriteShort writes unsigned short to buffer.

func WriteString

func WriteString(wr io.Writer, s string)

WriteString writes string to buffer.

func WriteTriad

func WriteTriad(wr io.Writer, n uint32)

WriteTriad writes unsigned 3-bytes triad to buffer.

Types

type Ack

type Ack struct {
	Seqs []uint32
}

Ack is a packet used in Raknet.

func (*Ack) Handle

func (pk *Ack) Handle(session *session)

Handle implements RaknetPacket interfaces.

func (*Ack) Read

func (pk *Ack) Read(buf *bytes.Buffer)

Read implements RaknetPacket interfaces.

func (*Ack) Write

func (pk *Ack) Write(buf *bytes.Buffer)

Write implements RaknetPacket interfaces.

type AddEntity

type AddEntity struct {
	EntityID               uint64
	Type                   uint32
	X, Y, Z                float32
	SpeedX, SpeedY, SpeedZ float32
	Yaw, Pitch             float32
	Metadata               []byte
	Link1, Link2           uint64
	Link3                  byte
}

AddEntity needs to be documented.

func (AddEntity) Pid

func (i AddEntity) Pid() byte

Pid implements MCPEPacket interface.

func (*AddEntity) Read

func (i *AddEntity) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (AddEntity) Write

func (i AddEntity) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type AddItemEntity

type AddItemEntity struct {
	EntityID uint64
	Item     *Item
	X        float32
	Y        float32
	Z        float32
	SpeedX   float32
	SpeedY   float32
	SpeedZ   float32
}

AddItemEntity needs to be documented.

func (AddItemEntity) Pid

func (i AddItemEntity) Pid() byte

Pid implements MCPEPacket interface.

func (*AddItemEntity) Read

func (i *AddItemEntity) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (AddItemEntity) Write

func (i AddItemEntity) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type AddPainting

type AddPainting struct {
	EntityID  uint64
	X         uint32
	Y         uint32
	Z         uint32
	Direction uint32
	Title     string
}

AddPainting needs to be documented.

func (AddPainting) Pid

func (i AddPainting) Pid() byte

Pid implements MCPEPacket interface.

func (*AddPainting) Read

func (i *AddPainting) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (AddPainting) Write

func (i AddPainting) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type AddPlayer

type AddPlayer struct {
	RawUUID                [16]byte
	Username               string
	EntityID               uint64
	X, Y, Z                float32
	SpeedX, SpeedY, SpeedZ float32
	BodyYaw, Yaw, Pitch    float32
	Metadata               []byte
}

AddPlayer needs to be documented.

func (AddPlayer) Pid

func (i AddPlayer) Pid() byte

Pid implements MCPEPacket interface.

func (*AddPlayer) Read

func (i *AddPlayer) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (AddPlayer) Write

func (i AddPlayer) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type AdventureSettings

type AdventureSettings struct {
	Flags            uint32
	UserPermission   uint32
	GlobalPermission uint32
}

AdventureSettings needs to be documented.

func (AdventureSettings) Pid

func (i AdventureSettings) Pid() byte

Pid implements MCPEPacket interface.

func (*AdventureSettings) Read

func (i *AdventureSettings) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (AdventureSettings) Write

func (i AdventureSettings) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type Animate

type Animate struct {
	Action   byte
	EntityID uint64
}

Animate needs to be documented.

func (Animate) Pid

func (i Animate) Pid() byte

Pid implements MCPEPacket interface.

func (*Animate) Read

func (i *Animate) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (Animate) Write

func (i Animate) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type Batch

type Batch struct {
	Payloads [][]byte
}

Batch needs to be documented.

func (Batch) Handle

func (i Batch) Handle(p *player) (err error)

Handle implements Handleable interface.

func (Batch) Pid

func (i Batch) Pid() byte

Pid implements MCPEPacket interface.

func (*Batch) Read

func (i *Batch) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (Batch) Write

func (i Batch) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type Block

type Block struct {
	ID   byte
	Meta byte
}

Block contains block data for each level positions

func (Block) Item

func (b Block) Item() Item

Item converts block to item struct.

type BlockEntityData

type BlockEntityData struct {
	X        uint32
	Y        uint32
	Z        uint32
	NamedTag []byte
}

BlockEntityData needs to be documented.

func (BlockEntityData) Pid

func (i BlockEntityData) Pid() byte

Pid implements MCPEPacket interface.

func (*BlockEntityData) Read

func (i *BlockEntityData) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (BlockEntityData) Write

func (i BlockEntityData) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type BlockEvent

type BlockEvent struct {
	X     uint32
	Y     uint32
	Z     uint32
	Case1 uint32
	Case2 uint32
}

BlockEvent needs to be documented.

func (BlockEvent) Pid

func (i BlockEvent) Pid() byte

Pid implements MCPEPacket interface.

func (*BlockEvent) Read

func (i *BlockEvent) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (BlockEvent) Write

func (i BlockEvent) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type BlockPos

type BlockPos struct {
	X, Z int32
	Y    byte
}

BlockPos is a type for x-y-z block coordinates.

type BlockRecord

type BlockRecord struct {
	X, Z  uint32
	Y     byte
	Block Block
	Flags byte
}

BlockRecord needs to be documented.

type BufferPool

type BufferPool chan *bytes.Buffer

BufferPool is a type to recycle bytes.Buffer objects for reducing GC throughput.

func (BufferPool) NewBuffer

func (pool BufferPool) NewBuffer(bs []byte) (buf *bytes.Buffer)

NewBuffer picks a recycled bytes.Buffer from pool. If pool is empty, NewBuffer creates new one. set bs to nil if you want empty buffer, without any initial values.

func (BufferPool) Recycle

func (pool BufferPool) Recycle(buf *bytes.Buffer)

Recycle resets and puts the buffer into the pool.

type Chunk

type Chunk struct {
	BlockData    [16 * 16 * 128]byte
	MetaData     [16 * 16 * 64]byte // Nibbles
	LightData    [16 * 16 * 64]byte // Nibbles
	SkyLightData [16 * 16 * 64]byte // Nibbles
	HeightMap    [16 * 16]byte
	BiomeData    [16 * 16 * 4]byte // Uints

	Position ChunkPos
	Refs     uint64
}

Chunk contains block data for each MCPE level chunks. Each chunk holds 16*16*128 blocks, and consumes at least 83208 bytes of memory.

A zero value for Chunk is a valid value.

func (*Chunk) CopyFrom

func (c *Chunk) CopyFrom(chunk Chunk)

CopyFrom gets everything from given chunk, and writes to the chunk instance.

func (*Chunk) FullChunkData

func (c *Chunk) FullChunkData() []byte

FullChunkData returns full chunk payload for FullChunkDataPacket. Order is layered.

func (*Chunk) GetBiomeColor

func (c *Chunk) GetBiomeColor(x, z byte) (r, g, b byte)

GetBiomeColor returns biome color on given X-Z coordinates.

func (*Chunk) GetBiomeID

func (c *Chunk) GetBiomeID(x, z byte) byte

GetBiomeID returns biome ID on given X-Z coordinates.

func (*Chunk) GetBlock

func (c *Chunk) GetBlock(x, y, z byte) byte

GetBlock returns block ID at given coordinates.

func (*Chunk) GetBlockLight

func (c *Chunk) GetBlockLight(x, y, z byte) byte

GetBlockLight returns block light level at given coordinates.

func (*Chunk) GetBlockMeta

func (c *Chunk) GetBlockMeta(x, y, z byte) byte

GetBlockMeta returns block meta at given coordinates.

func (*Chunk) GetBlockSkyLight

func (c *Chunk) GetBlockSkyLight(x, y, z byte) byte

GetBlockSkyLight returns sky light level at given coordinates.

func (*Chunk) GetHeightMap

func (c *Chunk) GetHeightMap(x, z byte) byte

GetHeightMap returns highest block height on given X-Z coordinates.

func (*Chunk) PopulateHeight

func (c *Chunk) PopulateHeight()

PopulateHeight populates chunk's block height map.

func (*Chunk) SetBiomeColor

func (c *Chunk) SetBiomeColor(x, z, r, g, b byte)

SetBiomeColor sets biome color on given X-Z coordinates.

func (*Chunk) SetBiomeID

func (c *Chunk) SetBiomeID(x, z, id byte)

SetBiomeID sets biome ID on given X-Z coordinates.

func (*Chunk) SetBlock

func (c *Chunk) SetBlock(x, y, z, id byte)

SetBlock sets block ID at given coordinates.

func (*Chunk) SetBlockLight

func (c *Chunk) SetBlockLight(x, y, z, id byte)

SetBlockLight sets block light level at given coordinates.

func (*Chunk) SetBlockMeta

func (c *Chunk) SetBlockMeta(x, y, z, id byte)

SetBlockMeta sets block meta at given coordinates.

func (*Chunk) SetBlockSkyLight

func (c *Chunk) SetBlockSkyLight(x, y, z, id byte)

SetBlockSkyLight sets sky light level at given coordinates.

func (*Chunk) SetHeightMap

func (c *Chunk) SetHeightMap(x, z, h byte)

SetHeightMap saves highest block height on given X-Z coordinates.

type ChunkDelivery

type ChunkDelivery struct {
	ChunkPos
	Chunk *Chunk
}

ChunkDelivery is a type for passing full chunk data to players.

type ChunkPos

type ChunkPos struct {
	X, Z int32
}

ChunkPos is a type for identifying chunks by x-z coordinate.

func GetChunkPos

func GetChunkPos(p BlockPos) ChunkPos

GetChunkPos extracts ChunkPos from BlockPos.

type ChunkRadiusUpdate

type ChunkRadiusUpdate struct {
	Radius uint32
}

ChunkRadiusUpdate needs to be documented.

func (ChunkRadiusUpdate) Pid

func (i ChunkRadiusUpdate) Pid() byte

Pid implements MCPEPacket interface.

func (*ChunkRadiusUpdate) Read

func (i *ChunkRadiusUpdate) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (ChunkRadiusUpdate) Write

func (i ChunkRadiusUpdate) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type ClientConnect

type ClientConnect struct {
	ClientID    uint64
	SendPing    uint64
	UseSecurity bool
}

ClientConnect is a packet used in Raknet.

func (*ClientConnect) Handle

func (pk *ClientConnect) Handle(session *session)

Handle implements RaknetPacket interfaces.

func (*ClientConnect) Read

func (pk *ClientConnect) Read(buf *bytes.Buffer)

Read implements RaknetPacket interfaces.

func (*ClientConnect) Write

func (pk *ClientConnect) Write(buf *bytes.Buffer)

Write implements RaknetPacket interfaces.

type ClientDisconnect

type ClientDisconnect struct{}

ClientDisconnect is a packet used in Raknet.

func (*ClientDisconnect) Handle

func (pk *ClientDisconnect) Handle(session *session)

Handle implements RaknetPacket interfaces.

func (*ClientDisconnect) Read

func (pk *ClientDisconnect) Read(buf *bytes.Buffer)

Read implements RaknetPacket interfaces.

func (*ClientDisconnect) Write

func (pk *ClientDisconnect) Write(buf *bytes.Buffer)

Write implements RaknetPacket interfaces.

type ClientHandshake

type ClientHandshake struct {
	Address            *net.UDPAddr
	SystemAddresses    []*net.UDPAddr
	SendPing, SendPong uint64
}

ClientHandshake is a packet used in Raknet.

func (*ClientHandshake) Handle

func (pk *ClientHandshake) Handle(session *session)

Handle implements RaknetPacket interfaces.

func (*ClientHandshake) Read

func (pk *ClientHandshake) Read(buf *bytes.Buffer)

Read implements RaknetPacket interfaces.

func (*ClientHandshake) Write

func (pk *ClientHandshake) Write(buf *bytes.Buffer)

Write implements RaknetPacket interfaces.

type ContainerClose

type ContainerClose struct {
	WindowID byte
}

ContainerClose needs to be documented.

func (ContainerClose) Pid

func (i ContainerClose) Pid() byte

Pid implements MCPEPacket interface.

func (*ContainerClose) Read

func (i *ContainerClose) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (ContainerClose) Write

func (i ContainerClose) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type ContainerOpen

type ContainerOpen struct {
	WindowID byte
	Type     byte
	Slots    uint16
	X        uint32
	Y        uint32
	Z        uint32
}

ContainerOpen needs to be documented.

func (ContainerOpen) Pid

func (i ContainerOpen) Pid() byte

Pid implements MCPEPacket interface.

func (*ContainerOpen) Read

func (i *ContainerOpen) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (ContainerOpen) Write

func (i ContainerOpen) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type ContainerSetContent

type ContainerSetContent struct {
	WindowID byte
	Slots    []Item
	Hotbar   []uint32
}

ContainerSetContent needs to be documented.

func (ContainerSetContent) Pid

func (i ContainerSetContent) Pid() byte

Pid implements MCPEPacket interface.

func (*ContainerSetContent) Read

func (i *ContainerSetContent) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (ContainerSetContent) Write

func (i ContainerSetContent) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type ContainerSetData

type ContainerSetData struct {
	WindowID byte
	Property uint16
	Value    uint16
}

ContainerSetData needs to be documented.

func (ContainerSetData) Pid

func (i ContainerSetData) Pid() byte

Pid implements MCPEPacket interface.

func (*ContainerSetData) Read

func (i *ContainerSetData) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (ContainerSetData) Write

func (i ContainerSetData) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type ContainerSetSlot

type ContainerSetSlot struct {
	Windowid   byte
	Slot       uint16
	HotbarSlot uint16
	Item       *Item
}

ContainerSetSlot needs to be documented.

func (ContainerSetSlot) Pid

func (i ContainerSetSlot) Pid() byte

Pid implements MCPEPacket interface.

func (*ContainerSetSlot) Read

func (i *ContainerSetSlot) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (ContainerSetSlot) Write

func (i ContainerSetSlot) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type CraftingData

type CraftingData struct{} // TODO

CraftingData needs to be documented.

func (CraftingData) Pid

func (i CraftingData) Pid() byte

Pid implements MCPEPacket interface.

func (*CraftingData) Read

func (i *CraftingData) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (CraftingData) Write

func (i CraftingData) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type CraftingEvent

type CraftingEvent struct{} // TODO

CraftingEvent needs to be documented.

func (CraftingEvent) Pid

func (i CraftingEvent) Pid() byte

Pid implements MCPEPacket interface.

func (*CraftingEvent) Read

func (i *CraftingEvent) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (CraftingEvent) Write

func (i CraftingEvent) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type DataPacket

type DataPacket struct {
	*bytes.Buffer
	Head      byte
	SendTime  time.Time
	SeqNumber uint32 // LE Triad
	Packets   []*EncapsulatedPacket
}

DataPacket is a packet struct, containing Raknet data packet fields.

func (*DataPacket) Decode

func (dp *DataPacket) Decode()

Decode decodes buffer to struct fields and decapsulates all packets.

func (*DataPacket) Encode

func (dp *DataPacket) Encode()

Encode encodes fields and packets to buffer.

func (*DataPacket) TotalLen

func (dp *DataPacket) TotalLen() int

TotalLen returns total buffer length of data packet.

type Disconnect

type Disconnect struct {
	Message string
}

Disconnect needs to be documented.

func (Disconnect) Handle

func (i Disconnect) Handle(p *player) (err error)

Handle implements Handleable interface.

func (*Disconnect) Pid

func (i *Disconnect) Pid() byte

Pid implements MCPEPacket interface.

func (*Disconnect) Read

func (i *Disconnect) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (*Disconnect) Write

func (i *Disconnect) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type DropItem

type DropItem struct {
	Type byte
	Item *Item
}

DropItem needs to be documented.

func (DropItem) Pid

func (i DropItem) Pid() byte

Pid implements MCPEPacket interface.

func (*DropItem) Read

func (i *DropItem) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (DropItem) Write

func (i DropItem) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type EncapsulatedPacket

type EncapsulatedPacket struct {
	*bytes.Buffer
	Reliability  byte
	HasSplit     bool
	MessageIndex uint32 // LE Triad
	OrderIndex   uint32 // LE Triad
	OrderChannel byte
	SplitCount   uint32
	SplitID      uint16
	SplitIndex   uint32
}

EncapsulatedPacket is a struct, containing more values for decoding/encoding encapsualted packets.

func NewEncapsulated

func NewEncapsulated(buf *bytes.Buffer) (ep *EncapsulatedPacket)

NewEncapsulated returns decoded EncapsulatedPacket struct from given binary. Do NOT set buf with *Packet struct. It could cause panic.

func (*EncapsulatedPacket) Bytes

func (ep *EncapsulatedPacket) Bytes() (buf *bytes.Buffer)

Bytes returns encoded binary from EncapsulatedPacket struct options.

func (*EncapsulatedPacket) TotalLen

func (ep *EncapsulatedPacket) TotalLen() int

TotalLen returns total binary length of EncapsulatedPacket.

type EntityEvent

type EntityEvent struct {
	EntityID uint64
	Event    byte
}

EntityEvent needs to be documented.

func (EntityEvent) Pid

func (i EntityEvent) Pid() byte

Pid implements MCPEPacket interface.

func (*EntityEvent) Read

func (i *EntityEvent) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (EntityEvent) Write

func (i EntityEvent) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type Explode

type Explode struct {
	X, Y, Z, Radius float32
	Records         [][3]byte // X, Y, Z byte
}

Explode needs to be documented.

func (Explode) Pid

func (i Explode) Pid() byte

Pid implements MCPEPacket interface.

func (*Explode) Read

func (i *Explode) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (Explode) Write

func (i Explode) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type FullChunkData

type FullChunkData struct {
	ChunkX, ChunkZ uint32
	Order          byte
	Payload        []byte
}

FullChunkData needs to be documented.

func (FullChunkData) Pid

func (i FullChunkData) Pid() byte

Pid implements MCPEPacket interface.

func (*FullChunkData) Read

func (i *FullChunkData) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (FullChunkData) Write

func (i FullChunkData) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type GeneralDataPacket

type GeneralDataPacket struct {
	SeqNumber uint32
	Packets   []*EncapsulatedPacket
}

GeneralDataPacket is a packet used in Raknet.

func (*GeneralDataPacket) Handle

func (pk *GeneralDataPacket) Handle(session *session)

Handle implements RaknetPacket interfaces.

func (*GeneralDataPacket) Read

func (pk *GeneralDataPacket) Read(buf *bytes.Buffer)

Read implements RaknetPacket interfaces.

func (*GeneralDataPacket) Write

func (pk *GeneralDataPacket) Write(buf *bytes.Buffer)

Write implements RaknetPacket interfaces.

type Handleable

type Handleable interface {
	MCPEPacket
	Handle(*player) error
}

Handleable is an interface for handling received MCPE packets.

type HurtArmor

type HurtArmor struct {
	Health byte
}

HurtArmor needs to be documented.

func (HurtArmor) Pid

func (i HurtArmor) Pid() byte

Pid implements MCPEPacket interface.

func (*HurtArmor) Read

func (i *HurtArmor) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (HurtArmor) Write

func (i HurtArmor) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type ID

type ID uint16

ID represents ID for Minecraft blocks/items.

const (
	Air         ID = iota
	Stone          // 1
	Grass          // 2
	Dirt           // 3
	Cobblestone    // 4
	Plank          // 5
	Sapling        // 6
	Bedrock        // 7
	Water          // 8
	StillWater     // 9
	Lava           // 10
	StillLava      // 11
	Sand           // 12
	Gravel         // 13
	GoldOre        // 14
	IronOre        // 15
	CoalOre        // 16
	Log            // 17
	Leaves         // 18
	Sponge         // 19
	Glass          // 20
	LapisOre       // 21
	LapisBlock     // 22

	Sandstone // 24

	BedBlock // 26

	Cobweb    // 30
	TallGrass // 31
	Bush      // 32

	Wool // 35

	Dandelion      // 37
	Poppy          // 38
	BrownMushroom  // 39
	RedMushroom    // 40
	GoldBlock      // 41
	IronBlock      // 42
	DoubleSlab     // 43
	Slab           // 44
	Bricks         // 45
	Tnt            // 46
	Bookshelf      // 47
	MossStone      // 48
	Obsidian       // 49
	Torch          // 50
	Fire           // 51
	MonsterSpawner // 52
	WoodStairs     // 53
	Chest          // 54

	DiamondOre     // 56
	DiamondBlock   // 57
	CraftingTable  // 58
	WheatBlock     // 59
	Farmland       // 60
	Furnace        // 61
	BurningFurnace // 62
	SignPost       // 63
	DoorBlock      // 64
	Ladder         // 65

	CobbleStairs // 67
	WallSign     // 68

	IronDoorBlock // 71

	RedstoneOre        // 73
	GlowingRedstoneOre // 74

	Snow      // 78
	Ice       // 79
	SnowBlock // 80
	Cactus    // 81
	ClayBlock // 82
	Reeds     // 83

	Fence      // 85
	Pumpkin    // 86
	Netherrack // 87
	SoulSand   // 88
	Glowstone  // 89

	LitPumpkin // 91
	CakeBlock  // 92

	Trapdoor // 96

	StoneBricks // 98

	IronBar            // 101
	GlassPane          // 102
	MelonBlock         // 103
	PumpkinStem        // 104
	MelonStem          // 105
	Vine               // 106
	FenceGate          // 107
	BrickStairs        // 108
	StoneBrickStairs   // 109
	Mycelium           // 110
	WaterLily          // 111
	NetherBricks       // 112
	NetherBrickFence   // 113
	NetherBricksStairs // 114

	EnchantingTable // 116
	BrewingStand    // 117

	EndPortal // 120
	EndStone  // 121

	SandstoneStairs // 128
	EmeraldOre      // 129

	EmeraldBlock     // 133
	SpruceWoodStairs // 134
	BirchWoodStairs  // 135
	JungleWoodStairs // 136

	CobbleWall     // 139
	FlowerPotBlock // 140
	CarrotBlock    // 141
	PotatoBlock    // 142

	Anvil        // 145
	TrappedChest // 146

	RedstoneBlock // 152

	QuartzBlock    // 155
	QuartzStairs   // 156
	DoubleWoodSlab // 157
	WoodSlab       // 158
	StainedClay    // 159

	Leaves2           // 161
	Wood2             // 162
	AcaciaWoodStairs  // 163
	DarkOakWoodStairs // 164

	IronTrapdoor // 167

	HayBale      // 170
	Carpet       // 171
	HardenedClay // 172
	CoalBlock    // 173
	PackedIce    // 174
	DoublePlant  // 175

	FenceGateSpruce  // 183
	FenceGateBirch   // 184
	FenceGateJungle  // 185
	FenceGateDarkOak // 186
	FenceGateAcacia  // 187

	GrassPath // 198

	Podzol          // 243
	BeetrootBlock   // 244
	Stonecutter     // 245
	GlowingObsidian // 246

	IronShovel        // 256
	IronPickaxe       // 257
	IronAxe           // 258
	FlintSteel        // 259
	Apple             // 260
	Bow               // 261
	Arrow             // 262
	Coal              // 263
	Diamond           // 264
	IronIngot         // 265
	GoldIngot         // 266
	IronSword         // 267
	WoodenSword       // 268
	WoodenShovel      // 269
	WoodenPickaxe     // 270
	WoodenAxe         // 271
	StoneSword        // 272
	StoneShovel       // 273
	StonePickaxe      // 274
	StoneAxe          // 275
	DiamondSword      // 276
	DiamondShovel     // 277
	DiamondPickaxe    // 278
	DiamondAxe        // 279
	Stick             // 280
	Bowl              // 281
	MushroomStew      // 282
	GoldSword         // 283
	GoldShovel        // 284
	GoldPickaxe       // 285
	GoldAxe           // 286
	String            // 287
	Feather           // 288
	Gunpowder         // 289
	WoodenHoe         // 290
	StoneHoe          // 291
	IronHoe           // 292
	DiamondHoe        // 293
	GoldHoe           // 294
	Seeds             // 295
	Wheat             // 296
	Bread             // 297
	LeatherCap        // 298
	LeatherTunic      // 299
	LeatherPants      // 300
	LeatherBoots      // 301
	ChainHelmet       // 302
	ChainChestplate   // 303
	ChainLeggings     // 304
	ChainBoots        // 305
	IronHelmet        // 306
	IronChestplate    // 307
	IronLeggings      // 308
	IronBoots         // 309
	DiamondHelmet     // 310
	DiamondChestplate // 311
	DiamondLeggings   // 312
	DiamondBoots      // 313
	GoldHelmet        // 314
	GoldChestplate    // 315
	GoldLeggings      // 316
	GoldBoots         // 317
	Flint             // 318
	RawPorkchop       // 319
	CookedPorkchop    // 320
	Painting          // 321
	GoldenApple       // 322
	Sign              // 323
	WoodenDoor        // 324
	Bucket            // 325

	Minecart // 328

	IronDoor // 330
	Redstone // 331
	Snowball // 332

	Leather // 334

	Brick     // 336
	Clay      // 337
	Sugarcane // 338
	Paper     // 339
	Book      // 340
	Slimeball // 341

	Egg           // 344
	Compass       // 345
	FishingRod    // 346
	Clock         // 347
	GlowstoneDust // 348
	RawFish       // 349
	CookedFish    // 350
	Dye           // 351
	Bone          // 352
	Sugar         // 353
	Cake          // 354
	Bed           // 355

	Cookie // 357

	Shears        // 359
	Melon         // 360
	PumpkinSeeds  // 361
	MelonSeeds    // 362
	RawBeef       // 363
	Steak         // 364
	RawChicken    // 365
	CookedChicken // 366

	GoldNugget // 371

	SpawnEgg // 383

	Emerald // 388

	FlowerPot   // 390
	Carrot      // 391
	Potato      // 392
	BakedPotato // 393

	PumpkinPie // 400

	NetherBrick // 405
	Quartz      // 406

	Camera        // 456
	Beetroot      // 457
	BeetrootSeeds // 458
	BeetrootSoup  // 459
)

item/block IDs

func StringID

func StringID(name string) ID

StringID returns item ID with given name. If there's no such item, returns -1(65535).

func (ID) Block

func (id ID) Block() byte

Block tries to convert item ID to block ID. If fails, it panics.

func (ID) String

func (id ID) String() string

String converts ID to string.

type Interact

type Interact struct {
	Action byte
	Target uint64
}

Interact needs to be documented.

func (Interact) Pid

func (i Interact) Pid() byte

Pid implements MCPEPacket interface.

func (*Interact) Read

func (i *Interact) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (Interact) Write

func (i Interact) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type Inventory

type Inventory []Item

Inventory is just a set of items, for containers or inventory holder entities.

type Item

type Item struct {
	ID       ID
	Meta     uint16
	Amount   byte
	Compound *nbt.Compound
}

Item contains item data for each container slots.

func (Item) Block

func (i Item) Block() Block

Block converts the item to block struct. If ID is not a block ID, it panics.

func (Item) IsBlock

func (i Item) IsBlock() bool

IsBlock returns whether the item block-convertable.

func (*Item) Read

func (i *Item) Read(buf io.Reader)

Read reads item data from io.Reader interface.

func (Item) Write

func (i Item) Write() []byte

Write returns byte slice with item data.

type Level

type Level struct {
	LoadedChunks map[ChunkPos]*Chunk

	Name     string
	Server   *Server
	Provider LevelProvider
	// contains filtered or unexported fields
}

Level is a struct to manage single MCPE world. Accessing level blocks must be done on level callbacks with Level.(RO/RW)(Async/*) func.

If you are writing many blocks to the level, use StagedWriter to buffer write operations.

func (*Level) Available

func (lv *Level) Available(pos BlockPos) bool

Available returns whether given block is loaded.

func (*Level) CreateChunk

func (lv *Level) CreateChunk(pos ChunkPos) *Chunk

CreateChunk creates the chunk on given ChunkPos.

func (*Level) Get

func (lv *Level) Get(p BlockPos) Block

Get returns Block from level.

func (*Level) GetID

func (lv *Level) GetID(p BlockPos) byte

GetID returns Block ID from level.

func (*Level) GetMeta

func (lv *Level) GetMeta(p BlockPos) byte

GetMeta returns Block Meta from level.

func (*Level) Init

func (lv *Level) Init()

Init initializes the level.

func (*Level) Lock

func (lv *Level) Lock()

Lock is a wrapping func for RWMutex.Lock()

func (*Level) RLock

func (lv *Level) RLock()

RLock is a wrapping func for RWMutex.RLock()

func (*Level) RO

func (lv *Level) RO(callback func(LevelReader))

RO executes given level callback in Read-Only mode.

func (*Level) RUnlock

func (lv *Level) RUnlock()

RUnlock is a wrapping func for RWMutex.RUnlock()

func (*Level) RW

func (lv *Level) RW(callback func(LevelReadWriter))

RW executes given level callback in Read-Write mode.

func (*Level) Set

func (lv *Level) Set(p BlockPos, b Block)

Set sets block ID/Meta to level.

func (*Level) SetID

func (lv *Level) SetID(p BlockPos, i byte)

SetID sets block ID to level.

func (*Level) SetMeta

func (lv *Level) SetMeta(p BlockPos, m byte)

SetMeta sets block Meta to level.

func (*Level) Unlock

func (lv *Level) Unlock()

Unlock is a wrapping func for RWMutex.Unlock()

type LevelEvent

type LevelEvent struct {
	EventID uint16
	X       float32
	Y       float32
	Z       float32
	Data    uint32
}

LevelEvent needs to be documented.

func (LevelEvent) Pid

func (i LevelEvent) Pid() byte

Pid implements MCPEPacket interface.

func (*LevelEvent) Read

func (i *LevelEvent) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (LevelEvent) Write

func (i LevelEvent) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type LevelProvider

type LevelProvider interface {
	Init(string)                      // Level name: usually used for file directories
	Loadable(ChunkPos) (string, bool) // Path: path to file, Ok: true if the chunk is saved on the file
	LoadChunk(ChunkPos, string) (*Chunk, error)
	WriteChunk(ChunkPos, *Chunk) error
	SaveAll(map[ChunkPos]*Chunk) error
}

LevelProvider is a interface for level formats.

func GetProvider

func GetProvider(name string) LevelProvider

GetProvider finds the provider with given name. If it doesn't present, returns nil.

type LevelReadWriter

type LevelReadWriter interface {
	LevelReader
	LevelWriter
}

LevelReadWriter = LevelReader + LevelWriter

type LevelReader

type LevelReader interface {
	Available(BlockPos) bool
	Get(BlockPos) Block
	GetID(BlockPos) byte
	GetMeta(BlockPos) byte
}

LevelReader is a level interface which allows Get* operations.

type LevelWriter

type LevelWriter interface {
	Set(BlockPos, Block)
	SetID(BlockPos, byte)
	SetMeta(BlockPos, byte)
	CreateChunk(ChunkPos) *Chunk
}

LevelWriter is a level interface which allows both Get/Set operations.

type Login

type Login struct {
	Username       string
	Proto1, Proto2 uint32
	ClientID       uint64
	RawUUID        [16]byte
	ServerAddress  string
	ClientSecret   string
	SkinName       string
	Skin           []byte
}

Login needs to be documented.

func (Login) Handle

func (i Login) Handle(p *player) (err error)

Handle implements Handleable interface.

func (Login) Pid

func (i Login) Pid() byte

Pid implements MCPEPacket interface.

func (*Login) Read

func (i *Login) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (Login) Write

func (i Login) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type MCPEPacket

type MCPEPacket interface {
	Pid() byte
	Read(*bytes.Buffer)
	Write() *bytes.Buffer
}

MCPEPacket is an interface for decoding/encoding MCPE packets.

func GetMCPEPacket

func GetMCPEPacket(pid byte) MCPEPacket

GetMCPEPacket returns MCPEPacket struct with given pid.

type MobArmorEquipment

type MobArmorEquipment struct {
	EntityID uint64
	Slots    [4]*Item
}

MobArmorEquipment needs to be documented.

func (MobArmorEquipment) Pid

func (i MobArmorEquipment) Pid() byte

Pid implements MCPEPacket interface.

func (*MobArmorEquipment) Read

func (i *MobArmorEquipment) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (MobArmorEquipment) Write

func (i MobArmorEquipment) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type MobEffect

type MobEffect struct {
	EntityID  uint64
	EventID   byte
	EffectID  byte
	Amplifier byte
	Particles bool
	Duration  uint32
}

MobEffect needs to be documented.

func (MobEffect) Pid

func (i MobEffect) Pid() byte

Pid implements MCPEPacket interface.

func (*MobEffect) Read

func (i *MobEffect) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (MobEffect) Write

func (i MobEffect) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type MobEquipment

type MobEquipment struct {
	EntityID     uint64
	Item         *Item
	Slot         byte
	SelectedSlot byte
}

MobEquipment needs to be documented.

func (MobEquipment) Pid

func (i MobEquipment) Pid() byte

Pid implements MCPEPacket interface.

func (*MobEquipment) Read

func (i *MobEquipment) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (MobEquipment) Write

func (i MobEquipment) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type MoveEntity

type MoveEntity struct {
	EntityIDs []uint64
	EntityPos [][6]float32 // X, Y, Z, Yaw, HeadYaw, Pitch
}

MoveEntity needs to be documented.

func (MoveEntity) Pid

func (i MoveEntity) Pid() byte

Pid implements MCPEPacket interface.

func (*MoveEntity) Read

func (i *MoveEntity) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (MoveEntity) Write

func (i MoveEntity) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type MovePlayer

type MovePlayer struct {
	EntityID uint64
	X        float32
	Y        float32
	Z        float32
	Yaw      float32
	BodyYaw  float32
	Pitch    float32
	Mode     byte
	OnGround byte
}

MovePlayer needs to be documented.

func (MovePlayer) Handle

func (i MovePlayer) Handle(p *player) (err error)

Handle implements Handleable interface.

func (MovePlayer) Pid

func (i MovePlayer) Pid() byte

Pid implements MCPEPacket interface.

func (*MovePlayer) Read

func (i *MovePlayer) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (MovePlayer) Write

func (i MovePlayer) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type Nack

type Nack struct {
	Seqs []uint32
}

Nack is a packet used in Raknet.

func (*Nack) Handle

func (pk *Nack) Handle(session *session)

Handle implements RaknetPacket interfaces.

func (*Nack) Read

func (pk *Nack) Read(buf *bytes.Buffer)

Read implements RaknetPacket interfaces.

func (*Nack) Write

func (pk *Nack) Write(buf *bytes.Buffer)

Write implements RaknetPacket interfaces.

type OpenConnectionReply1

type OpenConnectionReply1 struct {
	ServerID uint64
	MtuSize  uint16
}

OpenConnectionReply1 is a packet used in Raknet.

func (*OpenConnectionReply1) Handle

func (pk *OpenConnectionReply1) Handle(session *session)

Handle implements RaknetPacket interfaces.

func (*OpenConnectionReply1) Read

func (pk *OpenConnectionReply1) Read(buf *bytes.Buffer)

Read implements RaknetPacket interfaces.

func (*OpenConnectionReply1) Write

func (pk *OpenConnectionReply1) Write(buf *bytes.Buffer)

Write implements RaknetPacket interfaces.

type OpenConnectionReply2

type OpenConnectionReply2 struct {
	ServerID      uint64
	ClientAddress *net.UDPAddr
	MtuSize       uint16
}

OpenConnectionReply2 is a packet used in Raknet.

func (*OpenConnectionReply2) Handle

func (pk *OpenConnectionReply2) Handle(session *session)

Handle implements RaknetPacket interfaces.

func (*OpenConnectionReply2) Read

func (pk *OpenConnectionReply2) Read(buf *bytes.Buffer)

Read implements RaknetPacket interfaces.

func (*OpenConnectionReply2) Write

func (pk *OpenConnectionReply2) Write(buf *bytes.Buffer)

Write implements RaknetPacket interfaces.

type OpenConnectionRequest1

type OpenConnectionRequest1 struct {
	Protocol byte
	MtuSize  int
}

OpenConnectionRequest1 is a packet used in Raknet.

func (*OpenConnectionRequest1) Handle

func (pk *OpenConnectionRequest1) Handle(session *session)

Handle implements RaknetPacket interfaces.

func (*OpenConnectionRequest1) Read

func (pk *OpenConnectionRequest1) Read(buf *bytes.Buffer)

Read implements RaknetPacket interfaces.

func (*OpenConnectionRequest1) Write

func (pk *OpenConnectionRequest1) Write(buf *bytes.Buffer)

Write implements RaknetPacket interfaces.

type OpenConnectionRequest2

type OpenConnectionRequest2 struct {
	ServerAddress *net.UDPAddr
	MtuSize       uint16
	ClientID      uint64
}

OpenConnectionRequest2 is a packet used in Raknet.

func (*OpenConnectionRequest2) Handle

func (pk *OpenConnectionRequest2) Handle(session *session)

Handle implements RaknetPacket interfaces.

func (*OpenConnectionRequest2) Read

func (pk *OpenConnectionRequest2) Read(buf *bytes.Buffer)

Read implements RaknetPacket interfaces.

func (*OpenConnectionRequest2) Write

func (pk *OpenConnectionRequest2) Write(buf *bytes.Buffer)

Write implements RaknetPacket interfaces.

type Overflow

type Overflow struct {
	Need int
	Got  int
}

Overflow is an error indicates the reader could not read as you requested.

func (Overflow) Error

func (e Overflow) Error() string

Error implements the error interface.

type Packet

type Packet struct {
	*bytes.Buffer
	Address *net.UDPAddr
	Recycle bool
}

Packet is a struct which contains binary buffer, address, and send time.

func NewPacket

func NewPacket(pid byte) Packet

NewPacket creates new packet with given packet id.

type Ping

type Ping struct {
	PingID uint64
}

Ping is a packet used in Raknet.

func (*Ping) Handle

func (pk *Ping) Handle(session *session)

Handle implements RaknetPacket interfaces.

func (*Ping) Read

func (pk *Ping) Read(buf *bytes.Buffer)

Read implements RaknetPacket interfaces.

func (*Ping) Write

func (pk *Ping) Write(buf *bytes.Buffer)

Write implements RaknetPacket interfaces.

type PlayStatus

type PlayStatus struct {
	Status uint32
}

PlayStatus needs to be documented.

func (*PlayStatus) Pid

func (i *PlayStatus) Pid() byte

Pid implements MCPEPacket interface.

func (*PlayStatus) Read

func (i *PlayStatus) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (*PlayStatus) Write

func (i *PlayStatus) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type PlayerAction

type PlayerAction struct {
	EntityID uint64
	Action   uint32
	X        uint32
	Y        uint32
	Z        uint32
	Face     uint32
}

PlayerAction needs to be documented.

func (PlayerAction) Pid

func (i PlayerAction) Pid() byte

Pid implements MCPEPacket interface.

func (*PlayerAction) Read

func (i *PlayerAction) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (PlayerAction) Write

func (i PlayerAction) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type PlayerCallback

type PlayerCallback struct {
	Call func(*player)
}

PlayerCallback is a struct for delivering callbacks to other player goroutines; It is usually used to bypass race issues.

type PlayerInventory

type PlayerInventory struct {
	*Inventory
	Hotbars []Item
	Hand    Item
	Holder  *player
}

PlayerInventory is a inventory holder for players.

func (*PlayerInventory) Init

func (pi *PlayerInventory) Init()

Init initializes the inventory.

type PlayerList

type PlayerList struct {
	Type          byte
	PlayerEntries []PlayerListEntry
}

PlayerList needs to be documented.

func (PlayerList) Pid

func (i PlayerList) Pid() byte

Pid implements MCPEPacket interface.

func (*PlayerList) Read

func (i *PlayerList) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (PlayerList) Write

func (i PlayerList) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type PlayerListEntry

type PlayerListEntry struct {
	RawUUID            [16]byte
	EntityID           uint64
	Username, Skinname string
	Skin               []byte
}

PlayerListEntry needs to be documented.

type Pong

type Pong struct {
	PingID uint64
}

Pong is a packet used in Raknet.

func (*Pong) Handle

func (pk *Pong) Handle(session *session)

Handle implements RaknetPacket interfaces.

func (*Pong) Read

func (pk *Pong) Read(buf *bytes.Buffer)

Read implements RaknetPacket interfaces.

func (*Pong) Write

func (pk *Pong) Write(buf *bytes.Buffer)

Write implements RaknetPacket interfaces.

type RaknetPacket

type RaknetPacket interface {
	Read(*bytes.Buffer) // NOTE: remove first byte(pid) before Read().
	Handle(*session)
	Write(*bytes.Buffer) // NOTE: Write() should put pid before encoding with Pool.NewBuffer([]byte{), and should put target session address.
}

RaknetPacket is a handler interface for Raknet packets.

func GetDataPacket

func GetDataPacket(pid byte) (proto RaknetPacket)

GetDataPacket returns datapacket with given packet ID.

func GetRaknetPacket

func GetRaknetPacket(pid byte) (proto RaknetPacket)

GetRaknetPacket returns raknet packet with given packet ID.

type RemoveBlock

type RemoveBlock struct {
	EntityID uint64
	X, Z     uint32
	Y        byte
}

RemoveBlock needs to be documented.

func (RemoveBlock) Pid

func (i RemoveBlock) Pid() byte

Pid implements MCPEPacket interface.

func (*RemoveBlock) Read

func (i *RemoveBlock) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (RemoveBlock) Write

func (i RemoveBlock) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type RemoveEntity

type RemoveEntity struct {
	EntityID uint64
}

RemoveEntity needs to be documented.

func (RemoveEntity) Pid

func (i RemoveEntity) Pid() byte

Pid implements MCPEPacket interface.

func (*RemoveEntity) Read

func (i *RemoveEntity) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (RemoveEntity) Write

func (i RemoveEntity) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type RemovePlayer

type RemovePlayer struct {
	EntityID uint64
	RawUUID  [16]byte
}

RemovePlayer needs to be documented.

func (RemovePlayer) Pid

func (i RemovePlayer) Pid() byte

Pid implements MCPEPacket interface.

func (*RemovePlayer) Read

func (i *RemovePlayer) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (RemovePlayer) Write

func (i RemovePlayer) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type RequestChunkRadius

type RequestChunkRadius struct {
	Radius uint32
}

RequestChunkRadius needs to be documented.

func (RequestChunkRadius) Pid

func (i RequestChunkRadius) Pid() byte

Pid implements MCPEPacket interface.

func (*RequestChunkRadius) Read

func (i *RequestChunkRadius) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (RequestChunkRadius) Write

func (i RequestChunkRadius) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type Respawn

type Respawn struct {
	X float32
	Y float32
	Z float32
}

Respawn needs to be documented.

func (Respawn) Pid

func (i Respawn) Pid() byte

Pid implements MCPEPacket interface.

func (*Respawn) Read

func (i *Respawn) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (Respawn) Write

func (i Respawn) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type Router

type Router struct {
	Owner *Server
	// contains filtered or unexported fields
}

Router handles packets from network, and manages sessions.

func CreateRouter

func CreateRouter(port uint16) (r *Router, err error)

CreateRouter create/opens new raknet router with given port.

func (*Router) GetSession

func (r *Router) GetSession(address *net.UDPAddr, sendChannel chan Packet) *session

GetSession returns session with given identifier if exists, or creates new one.

func (*Router) Start

func (r *Router) Start()

Start makes router process network I/O operations.

type Server

type Server struct {
	*Router
	OpenSessions map[string]struct{}
	Levels       map[string]*Level
	// contains filtered or unexported fields
}

Server is a main server object.

func NewServer

func NewServer() *Server

NewServer creates new server object.

func (*Server) BroadcastPacket

func (s *Server) BroadcastPacket(pk MCPEPacket, filter func(*player) bool)

BroadcastPacket broadcasts given MCPEPacket to all online players. If filter is not nil server will send packet to players only filter returns true.

func (*Server) Message

func (s *Server) Message(msg string)

Message broadcasts message to all players.

func (*Server) RegisterPlayer

func (s *Server) RegisterPlayer(p *player) error

RegisterPlayer attempts to register the player to server.

func (*Server) RemovePlayer

func (s *Server) RemovePlayer(p, t *player)

RemovePlayer hides p from t.

func (*Server) ShowPlayer

func (s *Server) ShowPlayer(p, t *player)

ShowPlayer shows p to t.

func (*Server) Start

func (s *Server) Start()

Start starts the server.

func (*Server) UnregisterPlayer

func (s *Server) UnregisterPlayer(p *player) error

UnregisterPlayer attempts to unregister the player from server.

type ServerHandshake

type ServerHandshake struct {
	Address            *net.UDPAddr
	SystemAddresses    []*net.UDPAddr
	SendPing, SendPong uint64
}

ServerHandshake is a packet used in Raknet.

func (*ServerHandshake) Handle

func (pk *ServerHandshake) Handle(session *session)

Handle implements RaknetPacket interfaces.

func (*ServerHandshake) Read

func (pk *ServerHandshake) Read(buf *bytes.Buffer)

Read implements RaknetPacket interfaces.

func (*ServerHandshake) Write

func (pk *ServerHandshake) Write(buf *bytes.Buffer)

Write implements RaknetPacket interfaces.

type SetDifficulty

type SetDifficulty struct {
	Difficulty uint32
}

SetDifficulty needs to be documented.

func (SetDifficulty) Pid

func (i SetDifficulty) Pid() byte

Pid implements MCPEPacket interface.

func (*SetDifficulty) Read

func (i *SetDifficulty) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (SetDifficulty) Write

func (i SetDifficulty) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type SetEntityData

type SetEntityData struct{} // TODO Metadata

SetEntityData needs to be documented.

func (SetEntityData) Pid

func (i SetEntityData) Pid() byte

Pid implements MCPEPacket interface.

func (*SetEntityData) Read

func (i *SetEntityData) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (SetEntityData) Write

func (i SetEntityData) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type SetEntityLink struct {
	From uint64
	To   uint64
	Type byte
}

SetEntityLink needs to be documented.

func (SetEntityLink) Pid

func (i SetEntityLink) Pid() byte

Pid implements MCPEPacket interface.

func (*SetEntityLink) Read

func (i *SetEntityLink) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (SetEntityLink) Write

func (i SetEntityLink) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type SetEntityMotion

type SetEntityMotion struct {
	EntityIDs    []uint64
	EntityMotion [][6]float32 // X, Y, Z, Yaw, HeadYaw, Pitch
}

SetEntityMotion needs to be documented.

func (SetEntityMotion) Pid

func (i SetEntityMotion) Pid() byte

Pid implements MCPEPacket interface.

func (*SetEntityMotion) Read

func (i *SetEntityMotion) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (SetEntityMotion) Write

func (i SetEntityMotion) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type SetHealth

type SetHealth struct {
	Health uint32
}

SetHealth needs to be documented.

func (SetHealth) Pid

func (i SetHealth) Pid() byte

Pid implements MCPEPacket interface.

func (*SetHealth) Read

func (i *SetHealth) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (SetHealth) Write

func (i SetHealth) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type SetPlayerGametype

type SetPlayerGametype struct {
	Gamemode uint32
}

SetPlayerGametype needs to be documented.

func (SetPlayerGametype) Pid

func (i SetPlayerGametype) Pid() byte

Pid implements MCPEPacket interface.

func (*SetPlayerGametype) Read

func (i *SetPlayerGametype) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (SetPlayerGametype) Write

func (i SetPlayerGametype) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type SetSpawnPosition

type SetSpawnPosition struct {
	X uint32
	Y uint32
	Z uint32
}

SetSpawnPosition needs to be documented.

func (SetSpawnPosition) Pid

func (i SetSpawnPosition) Pid() byte

Pid implements MCPEPacket interface.

func (*SetSpawnPosition) Read

func (i *SetSpawnPosition) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (SetSpawnPosition) Write

func (i SetSpawnPosition) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type SetTime

type SetTime struct {
	Time    uint32
	Started bool
}

SetTime needs to be documented.

func (SetTime) Pid

func (i SetTime) Pid() byte

Pid implements MCPEPacket interface.

func (*SetTime) Read

func (i *SetTime) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (SetTime) Write

func (i SetTime) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type StagedWriter

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

StagedWriter is a wrapper for LevelReadWriter which buffers every write operations on stage, and batches write when executing Commit().

func NewStagedWriter

func NewStagedWriter(wrap LevelReadWriter) *StagedWriter

NewStagedWriter returns new StagedWriter object, with given LevelReadWriter wrapped.

func (*StagedWriter) Commit

func (sw *StagedWriter) Commit()

Commit batches all staged write operations and flushes the stage.

func (*StagedWriter) CreateChunk

func (sw *StagedWriter) CreateChunk(pos ChunkPos) *Chunk

CreateChunk wraps Level.CreateChunk method: do not use.

func (*StagedWriter) Set

func (sw *StagedWriter) Set(p BlockPos, b Block)

Set wraps Level.Set method.

func (*StagedWriter) SetID

func (sw *StagedWriter) SetID(p BlockPos, i byte)

SetID wraps Level.SetID method.

func (*StagedWriter) SetMeta

func (sw *StagedWriter) SetMeta(p BlockPos, m byte)

SetMeta wraps Level.SetMeta method.

type StartGame

type StartGame struct {
	Seed                   uint32
	Dimension              byte
	Generator              uint32
	Gamemode               uint32
	EntityID               uint64
	SpawnX, SpawnY, SpawnZ uint32
	X, Y, Z                float32
}

StartGame needs to be documented.

func (StartGame) Pid

func (i StartGame) Pid() byte

Pid implements MCPEPacket interface.

func (*StartGame) Read

func (i *StartGame) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (StartGame) Write

func (i StartGame) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type StringOverflow

type StringOverflow struct {
	Length int
}

StringOverflow represents the given string is too long for write

func (StringOverflow) Error

func (err StringOverflow) Error() string

Error implements the error interface.

type TakeItemEntity

type TakeItemEntity struct {
	Target   uint64
	EntityID uint64
}

TakeItemEntity needs to be documented.

func (TakeItemEntity) Pid

func (i TakeItemEntity) Pid() byte

Pid implements MCPEPacket interface.

func (*TakeItemEntity) Read

func (i *TakeItemEntity) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (TakeItemEntity) Write

func (i TakeItemEntity) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type Text

type Text struct {
	TextType byte
	Source   string
	Message  string
	Params   []string
}

Text needs to be documented.

func (Text) Handle

func (i Text) Handle(p *player) (err error)

Handle implements Handleable interface.

func (Text) Pid

func (i Text) Pid() byte

Pid implements MCPEPacket interface.

func (*Text) Read

func (i *Text) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (Text) Write

func (i Text) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type UpdateAttributes

type UpdateAttributes struct {
}

UpdateAttributes needs to be documented.

func (UpdateAttributes) Pid

func (i UpdateAttributes) Pid() byte

Pid implements MCPEPacket interface.

func (*UpdateAttributes) Read

func (i *UpdateAttributes) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (UpdateAttributes) Write

func (i UpdateAttributes) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type UpdateBlock

type UpdateBlock struct {
	BlockRecords []BlockRecord
}

UpdateBlock needs to be documented.

func (UpdateBlock) Pid

func (i UpdateBlock) Pid() byte

Pid implements MCPEPacket interface.

func (*UpdateBlock) Read

func (i *UpdateBlock) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (UpdateBlock) Write

func (i UpdateBlock) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type UseItem

type UseItem struct {
	X, Y, Z                uint32
	Face                   byte
	FloatX, FloatY, FloatZ float32
	PosX, PosY, PosZ       float32
	Item                   *Item
}

UseItem needs to be documented.

func (UseItem) Pid

func (i UseItem) Pid() byte

Pid implements MCPEPacket interface.

func (*UseItem) Read

func (i *UseItem) Read(buf *bytes.Buffer)

Read implements MCPEPacket interface.

func (UseItem) Write

func (i UseItem) Write() *bytes.Buffer

Write implements MCPEPacket interface.

type Vector2

type Vector2 struct {
	X, Y float32
}

Vector2 is a X-Y vector, containing 2nd-dimension position.

func (Vector2) Distance

func (v Vector2) Distance(to Vector2) float32

Distance calculates the distance between given vector.

func (Vector2) Vector3

func (v Vector2) Vector3() Vector3

Vector3 converts Vector2 to Vector3, setting X, Y as set before, but leaving Z zero.

type Vector3

type Vector3 struct {
	X, Y, Z float32
}

Vector3 is a X-Y-Z vector, containing 3rd-dimension position.

func (Vector3) Distance

func (v Vector3) Distance(to Vector3) float32

Distance calculates the distance between given vector.

Jump to

Keyboard shortcuts

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