Files
mc/server/session/handler_sub_chunk_request.go
T
TarnaWijaya 26ed99fda6
Build and deploy / Build (push) Has been cancelled
Build and deploy / Update Contributors (push) Has been cancelled
Build and deploy / Deploy (push) Has been cancelled
up3
2026-07-09 08:33:57 +08:00

29 lines
976 B
Go

package session
import (
"github.com/df-mc/dragonfly/server/world"
"github.com/sandertv/gophertunnel/minecraft/protocol"
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
)
// SubChunkRequestHandler handles sub-chunk requests from the client. The server will respond with a packet containing
// the requested sub-chunks.
type SubChunkRequestHandler struct{}
// Handle ...
func (*SubChunkRequestHandler) Handle(p packet.Packet, s *Session, tx *world.Tx, _ Controllable) error {
pk := p.(*packet.SubChunkRequest)
if dimID, _ := world.DimensionID(tx.World().Dimension()); pk.Dimension != int32(dimID) {
// Outdated sub chunk request from a previous dimension.
s.writePacket(&packet.SubChunk{
Dimension: pk.Dimension,
Position: pk.Position,
CacheEnabled: s.conn.ClientCacheEnabled(),
SubChunkEntries: []protocol.SubChunkEntry{},
})
return nil
}
s.ViewSubChunks(world.SubChunkPos(pk.Position), pk.Offsets, tx)
return nil
}