MCPcopy Create free account
hub / github.com/ZeppelinMC/Zeppelin / encodeCompoundMap

Method encodeCompoundMap

protocol/nbt/encoder.go:356–547  ·  view source on GitHub ↗
(val reflect.Value)

Source from the content-addressed store, hash-verified

354}
355
356func (e *Encoder) encodeCompoundMap(val reflect.Value) error {
357 for _, key := range val.MapKeys() {
358 f := val.MapIndex(key)
359 name := key.String()
360
361 switch f.Kind() {
362 case reflect.Bool:
363 if err := e.writeByte(Byte); err != nil {
364 return err
365 }
366 if err := e.writeString(name); err != nil {
367 return err
368 }
369 b := f.Bool()
370 if err := e.writeByte(*(*int8)(unsafe.Pointer(&b))); err != nil {
371 return err
372 }
373 case reflect.Int8, reflect.Uint8:
374 if err := e.writeByte(Byte); err != nil {
375 return err
376 }
377 if err := e.writeString(name); err != nil {
378 return err
379 }
380 if f.CanUint() {
381 if err := e.writeByte(int8(f.Uint())); err != nil {
382 return err
383 }
384 } else {
385 if err := e.writeByte(int8(f.Int())); err != nil {
386 return err
387 }
388 }
389 case reflect.Int16, reflect.Uint16:
390 if err := e.writeByte(Short); err != nil {
391 return err
392 }
393 if err := e.writeString(name); err != nil {
394 return err
395 }
396 if f.CanUint() {
397 if err := e.writeShort(int16(f.Uint())); err != nil {
398 return err
399 }
400 } else {
401 if err := e.writeShort(int16(f.Int())); err != nil {
402 return err
403 }
404 }
405 case reflect.Int32, reflect.Uint32:
406 if err := e.writeByte(Int); err != nil {
407 return err
408 }
409 if err := e.writeString(name); err != nil {
410 return err
411 }
412 if f.CanUint() {
413 if err := e.writeInt(int32(f.Uint())); err != nil {

Callers 3

EncodeMethod · 0.95
encodeCompoundStructMethod · 0.95
encodeListMethod · 0.95

Calls 15

writeByteMethod · 0.95
writeStringMethod · 0.95
writeShortMethod · 0.95
writeIntMethod · 0.95
writeLongMethod · 0.95
writeFloatMethod · 0.95
writeDoubleMethod · 0.95
writeIntArrayMethod · 0.95
writeLongArrayMethod · 0.95
encodeListMethod · 0.95
encodeCompoundStructMethod · 0.95
PointerMethod · 0.80

Tested by

no test coverage detected