| 29 | } |
| 30 | |
| 31 | func (chunk *Chunk) EncodeBuf(biomeIndexes []string, buf *bytes.Buffer) *play.ChunkDataUpdateLight { |
| 32 | bstateId := int32(slices.Index(biomeIndexes, "minecraft:plains")) |
| 33 | |
| 34 | w := encoding.NewWriter(buf) |
| 35 | |
| 36 | pk := &play.ChunkDataUpdateLight{ |
| 37 | CX: chunk.X, |
| 38 | CZ: chunk.Z, |
| 39 | |
| 40 | Data: buf, |
| 41 | |
| 42 | Heightmaps: *(*play.Heightmaps)(unsafe.Pointer(&chunk.Heightmaps)), |
| 43 | |
| 44 | //BlockEntities: make([]play.BlockEntity, len(chunk.BlockEntities)), |
| 45 | |
| 46 | SkyLightMask: make(encoding.BitSet, 1), |
| 47 | EmptySkyLightMask: make(encoding.BitSet, 1), |
| 48 | SkyLightArrays: make([][]byte, 1, len(chunk.Sections)+1), |
| 49 | |
| 50 | BlockLightMask: make(encoding.BitSet, 1), |
| 51 | EmptyBlockLightMask: make(encoding.BitSet, 1), |
| 52 | BlockLightArrays: make([][]byte, 1, len(chunk.Sections)+1), |
| 53 | } |
| 54 | |
| 55 | pk.SkyLightMask.Set(1) |
| 56 | pk.EmptySkyLightMask.Set(1) |
| 57 | pk.SkyLightArrays[0] = emptyLightBuffer |
| 58 | |
| 59 | pk.BlockLightMask.Set(1) |
| 60 | pk.EmptyBlockLightMask.Set(1) |
| 61 | pk.BlockLightArrays[0] = emptyLightBuffer |
| 62 | |
| 63 | /*for i, entity := range chunk.BlockEntities { |
| 64 | pk.BlockEntities[i] = play.BlockEntity{ |
| 65 | X: entity.X, |
| 66 | Y: entity.Y, |
| 67 | Z: entity.Z, |
| 68 | Type: registry.BlockEntityType.Get(entity.Id), |
| 69 | Data: entity, |
| 70 | } |
| 71 | }*/ |
| 72 | |
| 73 | for secI, sec := range chunk.Sections { |
| 74 | var blockCount int16 = 1024 |
| 75 | blockBitsPerEntry, biomeBitsPerEntry := sec.BPE() |
| 76 | //var airId = -1 |
| 77 | |
| 78 | /*for i, state := range blockPalette { |
| 79 | name, _ := state.Encode() |
| 80 | if name == "minecraft:air" { |
| 81 | airId = i |
| 82 | break |
| 83 | } |
| 84 | } |
| 85 | if airId == -1 { |
| 86 | blockCount = 4096 |
| 87 | } |
| 88 | |