Update level/chunk and heightmaps

This commit is contained in:
Tnze
2023-04-22 17:43:10 +08:00
parent e17642945d
commit de2996336c
5 changed files with 71 additions and 52 deletions

View File

@ -12,27 +12,24 @@ import (
// Chunk is 16* chunk
type Chunk struct {
DataVersion int32
XPos int32 `nbt:"xPos"`
YPos int32 `nbt:"yPos"`
ZPos int32 `nbt:"zPos"`
BlockEntities []nbt.RawMessage `nbt:"block_entities"`
Structures nbt.RawMessage `nbt:"structures"`
Heightmaps struct {
MotionBlocking []uint64 `nbt:"MOTION_BLOCKING"`
MotionBlockingNoLeaves []uint64 `nbt:"MOTION_BLOCKING_NO_LEAVES"`
OceanFloor []uint64 `nbt:"OCEAN_FLOOR"`
WorldSurface []uint64 `nbt:"WORLD_SURFACE"`
}
Sections []Section `nbt:"sections"`
BlockTicks nbt.RawMessage `nbt:"block_ticks"`
FluidTicks nbt.RawMessage `nbt:"fluid_ticks"`
PostProcessing nbt.RawMessage
BlockEntities []nbt.RawMessage `nbt:"block_entities"`
BlockTicks nbt.RawMessage `nbt:"block_ticks"`
CarvingMasks map[string][]uint64
DataVersion int32
Entities []nbt.RawMessage `nbt:"entities"`
FluidTicks nbt.RawMessage `nbt:"fluid_ticks"`
Heightmaps map[string][]uint64 // keys: "WORLD_SURFACE_WG", "WORLD_SURFACE", "WORLD_SURFACE_IGNORE_SNOW", "OCEAN_FLOOR_WG", "OCEAN_FLOOR", "MOTION_BLOCKING", "MOTION_BLOCKING_NO_LEAVES"
InhabitedTime int64
IsLightOn byte `nbt:"isLightOn"`
LastUpdate int64
Lights []nbt.RawMessage
PostProcessing nbt.RawMessage
Sections []Section `nbt:"sections"`
Status string
Structures nbt.RawMessage `nbt:"structures"`
XPos int32 `nbt:"xPos"`
YPos int32 `nbt:"yPos"`
ZPos int32 `nbt:"zPos"`
}
type Section struct {
@ -68,12 +65,13 @@ func (c *Chunk) Load(data []byte) (err error) {
case 3:
// none compression
}
if err != nil {
return err
}
_, err = nbt.NewDecoder(r).Decode(c)
d := nbt.NewDecoder(r)
//d.DisallowUnknownFields()
_, err = d.Decode(c)
return
}