Documentation ¶
Index ¶
- Constants
- Variables
- func BlockUpdate(position minecraft.Position, blk block.Block)
- func GetPlayerCount() int32
- func JoinPlayer(player *Player)
- func LeftPlayer(player *Player)
- func RegisterForTick(cb func(), ticks int)
- func StartGameLoop()
- type BlockPlacement
- type PendingChange
- type Player
- func (p *Player) Change(cb func())
- func (p *Player) ChangeHeldItem(slot int)
- func (p *Player) String() string
- func (p *Player) TransformItemToStateId(itm *item.Item, face minecraft.Face) (uint16, bool)
- func (p *Player) UnitVector() math.Point
- func (p *Player) UpdateInventory(slot int, item *play.Slot)
- func (p *Player) ViewRect() *math.Rect
- type PlayerAction
- type PlayerActionType
- type World
Constants ¶
const ( PlayerActionDig = PlayerActionType(iota) PlayerActionPlace PlayerActionUseItem )
Variables ¶
var OurWorld = NewWorld( &flatgrass.FlatgraassGenerator{}, &nullprovider.NullProvider{}, )
the world we are going to use
Functions ¶
func BlockUpdate ¶
This is done right after the chunk processes all of the block changes that happened in this tick the reason for this is to make sure the map is in the most updated state.
if you want to register future block updates just use the ticker to register a block update, and since right after the ticker the block updates happen it will just work
func GetPlayerCount ¶
func GetPlayerCount() int32
func LeftPlayer ¶
func LeftPlayer(player *Player)
func RegisterForTick ¶
func RegisterForTick(cb func(), ticks int)
func StartGameLoop ¶
func StartGameLoop()
Types ¶
type BlockPlacement ¶
type PendingChange ¶
type PendingChange struct { Field interface{} Value interface{} ChangeFlag interface{} }
type Player ¶
type Player struct { // the socket socket.Socket // The entity player *entity.Player // Client settings we need to know about ViewDistance int // ping related Ping time.Duration LastKeepAlive time.Time PingChanged bool // The world we are in World *World ActionQueue *queue.Queue // the inventory of the player // https://wiki.vg/images/1/13/Inventory-slots.png HeldItemIndex int Inventory [46]*play.Slot // contains filtered or unexported fields }
func (*Player) ChangeHeldItem ¶
func (*Player) TransformItemToStateId ¶
Top level transformation function that turns an item to a block, this will also handle item uses like flint&steel and buckets.
The reason for that is that it is just easier to handle it on block placement rather than item use as the game sends more info
func (*Player) UnitVector ¶
func (*Player) UpdateInventory ¶
this is used when there is data from the player that should be updated on the server, this will also make sure to give back the player a confirmation about this
type PlayerAction ¶
type PlayerAction struct { Type PlayerActionType Data interface{} }
type PlayerActionType ¶
type PlayerActionType int
type World ¶
type World struct { // the minecraft world *world.World // The block changes in this world BlockChanges map[world.ChunkPos][]play.BlockRecord // contains filtered or unexported fields }