world

package
v1.15.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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.

func DecodeChunkColumn

func DecodeChunkColumn(mask int32, data []byte) (*Chunk, error)

DecodeChunkColumn decode the chunk data structure. If decoding went error, successful decoded data will be returned.

type ChunkLoc

type ChunkLoc struct {
	X, Z int
}

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) LoadChunk

func (w *World) LoadChunk(x, z int, c *Chunk)

LoadChunk adds the given chunk to the world.

func (*World) MultiBlockUpdate

func (w *World) MultiBlockUpdate(loc ChunkLoc, sectionY int, blocks []pk.VarLong) bool

MultiBlockUpdate updates a packed specification of blocks within a single section of a chunk.

func (*World) OnEntityDestroy

func (w *World) OnEntityDestroy(eIDs []pk.VarInt) error

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

func (w *World) PlayerEntities() []entity.Entity

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

func (w *World) UnloadChunk(loc ChunkLoc)

UnloadChunk unloads a chunk from the world.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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