MCPcopy Create free account
hub / github.com/TyphoonMC/TyphoonCore / WritePacketWithoutCompression

Method WritePacketWithoutCompression

connection.go:330–359  ·  view source on GitHub ↗
(packet Packet)

Source from the content-addressed store, hash-verified

328}
329
330func (player *Player) WritePacketWithoutCompression(packet Packet) (err error) {
331 buff := newVarBuffer(256)
332 tmp := player.io
333 player.io = &ConnReadWrite{
334 rdr: tmp.rdr,
335 wtr: buff,
336 }
337
338 id, proto := packet.Id()
339 if player.state == PLAY {
340 id = player.HackClientbound(id, proto)
341 }
342 if id == -1 {
343 return
344 }
345 player.WriteVarInt(id)
346 packet.Write(player)
347
348 ln := newVarBuffer(0)
349 player.io.wtr = ln
350 player.WriteVarInt(buff.Len())
351 player.io = tmp
352 player.conn.Write(ln.Bytes())
353 player.conn.Write(buff.Bytes())
354
355 if config.Logs {
356 log.Printf("#%d <- %d %s", player.id, id, fmt.Sprint(packet))
357 }
358 return nil
359}
360
361func (player *Player) WritePacketWithCompression(packet Packet) (err error) {
362 buff := newVarBuffer(256)

Callers 1

WritePacketMethod · 0.95

Calls 7

HackClientboundMethod · 0.95
WriteVarIntMethod · 0.95
newVarBufferFunction · 0.85
LenMethod · 0.80
BytesMethod · 0.80
IdMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected