list of param2 coloring blocks

This commit is contained in:
NatureFreshMilk 2019-06-20 07:55:18 +02:00
parent d6db939ffa
commit 2d4c2e2f84
3 changed files with 35 additions and 5 deletions

View File

@ -13,13 +13,14 @@ import (
)
type ColorMapping struct {
colors map[string]*color.RGBA
extendedpalette *Palette
colors map[string]*color.RGBA
extendedpaletteblock map[string]bool
extendedpalette *Palette
}
func (m *ColorMapping) GetColor(name string, param2 int) *color.RGBA {
//TODO: list of node->palette
if name == "unifiedbricks:brickblock" {
if m.extendedpaletteblock[name] {
// param2 coloring
return m.extendedpalette.GetColor(param2)
}
@ -108,8 +109,27 @@ func NewColorMapping() *ColorMapping {
panic(err)
}
scanner := bufio.NewScanner(bytes.NewReader(vfs.FSMustByte(false, "/extended_palette.txt")))
extendedpaletteblock := make(map[string]bool)
if err != nil {
panic(err)
}
for scanner.Scan() {
txt := strings.Trim(scanner.Text(), " ")
if len(txt) == 0 {
//empty
continue
}
extendedpaletteblock[txt] = true
}
return &ColorMapping{
colors: make(map[string]*color.RGBA),
extendedpalette: extendedpalette,
colors: make(map[string]*color.RGBA),
extendedpaletteblock: extendedpaletteblock,
extendedpalette: extendedpalette,
}
}

View File

@ -21,6 +21,11 @@ func TestNewMapping(t *testing.T) {
panic("no color")
}
c = m.GetColor("unifiedbricks:brickblock_multicolor_dark", 100)
if c == nil {
panic("no color")
}
//if c.A != 128 {
// panic("wrong alpha")
//}

View File

@ -0,0 +1,5 @@
unifiedbricks:brickblock
unifiedbricks:clayblock
unifiedbricks:brickblock_multicolor_dark
unifiedbricks:brickblock_multicolor_medium
unifiedbricks:brickblock_multicolor_light