// AddEntity creates a mob or item in this chunk and notifies all chunk // subscribers of the new entity func (chunk *Chunk) AddEntity(s gamerules.INonPlayerEntity) { newEntityId := chunk.shard.entityMgr.NewEntity() s.SetEntityId(newEntityId) chunk.entities[newEntityId] = s // Spawn new item/mob for players. buf := &bytes.Buffer{} s.SendSpawn(buf) chunk.reqMulticastPlayers(-1, buf.Bytes()) }
// AddEntity creates a mob or item in this chunk and notifies all chunk // subscribers of the new entity func (chunk *Chunk) AddEntity(s gamerules.INonPlayerEntity) { newEntityId := chunk.shard.entityMgr.NewEntity() s.SetEntityId(newEntityId) chunk.entities[newEntityId] = s // Spawn new item/mob for players. data := chunk.shard.pktSerial.SerializePackets(s.SpawnPackets(nil)...) chunk.reqMulticastPlayers(-1, data) chunk.storeDirty = true }