Documentation ¶
Index ¶
- type BlockStatus
- type Chunk
- type ChunkLoc
- type Section
- type TilePosition
- type World
- func (w *World) GetBlockStatus(x, y, z int) BlockStatus
- func (w *World) LoadChunk(x, z int, c *Chunk)
- func (w *World) MultiBlockUpdate(loc ChunkLoc, sectionY int, blocks []pk.VarLong) bool
- func (w *World) OnEntityDestroy(eIDs []pk.VarInt) error
- func (w *World) OnEntityLookUpdate(pkt ptypes.EntityRotation) error
- func (w *World) OnEntityPosLookUpdate(pkt ptypes.EntityPositionLook) error
- func (w *World) OnEntityPosUpdate(pkt ptypes.EntityPosition) error
- func (w *World) OnSpawnEntity(pkt ptypes.SpawnEntity) error
- func (w *World) OnSpawnLivingEntity(pkt ptypes.SpawnLivingEntity) error
- func (w *World) OnSpawnPlayer(pkt ptypes.SpawnPlayer) error
- func (w *World) PlayerEntities() []entity.Entity
- func (w *World) Signs() []entity.BlockEntity
- func (w *World) TileEntityUpdate(pkt ptypes.TileEntityData) error
- func (w *World) UnaryBlockUpdate(pos pk.Position, bStateID BlockStatus) bool
- func (w *World) UnloadChunk(loc ChunkLoc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockStatus ¶
type BlockStatus uint32
type Chunk ¶
type Chunk struct { Sections [16]Section TileEntities map[TilePosition]entity.BlockEntity }
Chunk store a 256*16*16 area of blocks, sharded on the Y axis into 16 sections.
type Section ¶
type Section interface { // GetBlock return block status, offset can be calculate by SectionOffset. GetBlock(offset uint) BlockStatus // SetBlock is the reverse operation of GetBlock. SetBlock(offset uint, s BlockStatus) }
Section implements storage of blocks within a fixed 16*16*16 area.
type TilePosition ¶
type TilePosition uint32
TilePosition describes the location of a tile/block entity within a chunk.
func ToTilePos ¶
func ToTilePos(x, y, z int) TilePosition
func (TilePosition) Pos ¶
func (p TilePosition) Pos() (x, y, z int)
func (TilePosition) String ¶
func (p TilePosition) String() string
type World ¶
type World struct { Entities map[int32]*entity.Entity Chunks map[ChunkLoc]*Chunk // contains filtered or unexported fields }
World record all of the things in the world where player at
func (*World) GetBlockStatus ¶
func (w *World) GetBlockStatus(x, y, z int) BlockStatus
GetBlockStatus return the state ID of the block at the given position.
func (*World) MultiBlockUpdate ¶
MultiBlockUpdate updates a packed specification of blocks within a single section of a chunk.
func (*World) OnEntityDestroy ¶
OnEntityDestroy should be called when a DestroyEntities packet is recieved.
func (*World) OnEntityLookUpdate ¶
func (w *World) OnEntityLookUpdate(pkt ptypes.EntityRotation) error
OnEntityLookUpdate should be called when an EntityRotation packet is recieved.
func (*World) OnEntityPosLookUpdate ¶
func (w *World) OnEntityPosLookUpdate(pkt ptypes.EntityPositionLook) error
OnEntityPosLookUpdate should be called when an EntityPositionLook packet is recieved.
func (*World) OnEntityPosUpdate ¶
func (w *World) OnEntityPosUpdate(pkt ptypes.EntityPosition) error
OnEntityPosUpdate should be called when an EntityPosition packet is recieved.
func (*World) OnSpawnEntity ¶
func (w *World) OnSpawnEntity(pkt ptypes.SpawnEntity) error
OnSpawnEntity should be called when a SpawnEntity packet is recieved.
func (*World) OnSpawnLivingEntity ¶
func (w *World) OnSpawnLivingEntity(pkt ptypes.SpawnLivingEntity) error
OnSpawnLivingEntity should be called when a SpawnLivingEntity packet is recieved.
func (*World) OnSpawnPlayer ¶
func (w *World) OnSpawnPlayer(pkt ptypes.SpawnPlayer) error
OnSpawnPlayer should be called when a SpawnPlayer packet is recieved.
func (*World) PlayerEntities ¶
PlayerEntities returns a list of players on the server within viewing range.
func (*World) Signs ¶
func (w *World) Signs() []entity.BlockEntity
Signs returns a list of signs on the server within viewing range.
func (*World) TileEntityUpdate ¶
func (w *World) TileEntityUpdate(pkt ptypes.TileEntityData) error
func (*World) UnaryBlockUpdate ¶
func (w *World) UnaryBlockUpdate(pos pk.Position, bStateID BlockStatus) bool
UnaryBlockUpdate updates the block at the specified position with a new state ID.
func (*World) UnloadChunk ¶
UnloadChunk unloads a chunk from the world.