list of param2 coloring blocks
This commit is contained in:
parent
d6db939ffa
commit
2d4c2e2f84
@ -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,
|
||||
}
|
||||
}
|
||||
|
@ -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")
|
||||
//}
|
||||
|
5
static/extended_palette.txt
Normal file
5
static/extended_palette.txt
Normal file
@ -0,0 +1,5 @@
|
||||
unifiedbricks:brickblock
|
||||
unifiedbricks:clayblock
|
||||
unifiedbricks:brickblock_multicolor_dark
|
||||
unifiedbricks:brickblock_multicolor_medium
|
||||
unifiedbricks:brickblock_multicolor_light
|
Loading…
x
Reference in New Issue
Block a user