Skip to content

Commit

Permalink
Simplify prepares for render
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsupermanhd committed Dec 21, 2023
1 parent f9f66f2 commit 0056f6e
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions terrain.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/gorilla/mux"
"github.com/maxsupermanhd/WebChunk/chunkStorage"
biomes "github.com/maxsupermanhd/WebChunk/data/biomes"
"github.com/maxsupermanhd/WebChunk/data/biomes"
"github.com/maxsupermanhd/go-vmc/v764/level"
"github.com/maxsupermanhd/go-vmc/v764/level/block"
"github.com/maxsupermanhd/go-vmc/v764/save"
Expand Down Expand Up @@ -104,14 +104,13 @@ func prepareSectionBlockstates(s *save.Section) *level.PaletteContainer[block.St
if !ok {
b, ok = block.FromID["minecraft:"+v.Name]
if !ok {
log.Printf("Can not find block from id [%v]", v.Name)
return nil
}
}
if v.Properties.Data != nil {
err := v.Properties.Unmarshal(&b)
if err != nil {
log.Printf("Error unmarshling properties of block [%v] from [%v]: %v", v.Name, v.Properties.String(), err.Error())
// log.Printf("Error unmarshling properties of block [%v] from [%v]: %v", v.Name, v.Properties.String(), err.Error())
return nil
}
}
Expand All @@ -129,7 +128,7 @@ func prepareSectionBlockIDs(s *save.Section) *level.PaletteContainer[block.State
if !ok {
b, ok = block.FromID["minecraft:"+v.Name]
if !ok {
log.Printf("Can not find block from id [%v]", v.Name)
// log.Printf("Can not find block from id [%v]", v.Name)
return nil
}
}
Expand All @@ -139,15 +138,14 @@ func prepareSectionBlockIDs(s *save.Section) *level.PaletteContainer[block.State
}

func prepareSectionBiomes(s *save.Section) *level.PaletteContainer[level.BiomesState] {
rawp := []level.BiomesState{}
for _, vv := range s.Biomes.Palette {
rawp := make([]level.BiomesState, len(s.Biomes.Palette))
for pi, vv := range s.Biomes.Palette {
v := strings.TrimPrefix(string(vv), "minecraft:")
i, ok := biomes.BiomeID[v]
if !ok && os.Getenv("REPORT_CHUNK_PROBLEMS") == "all" {
log.Printf("Failed to find id of biome [%s], fallback to plains", v)
i = 1
if !ok {
i = 127
}
rawp = append(rawp, level.BiomesState(i))
rawp[pi] = level.BiomesState(i)
}
return level.NewBiomesPaletteContainerWithData(4*4*4, s.Biomes.Data, rawp)
}
Expand Down

0 comments on commit 0056f6e

Please sign in to comment.