Update ColorSchemes, support block state based lookup

This commit is contained in:
Mike Primm 2021-12-28 16:27:01 -06:00
parent 44bcf6bbab
commit f577d8f6f4
9 changed files with 19804 additions and 773 deletions

View File

@ -9,33 +9,24 @@ import java.util.Scanner;
import org.dynmap.common.BiomeMap;
import org.dynmap.debug.Debug;
import org.dynmap.renderer.DynmapBlockState;
public class ColorScheme {
private static final HashMap<String, ColorScheme> cache = new HashMap<String, ColorScheme>();
public String name;
/* Switch to arrays - faster than map */
public Color[][] colors; /* [blk-type][step] */
public Color[][][] datacolors; /* [bkt-type][blk-dat][step] */
public final Color[][] colors; /* [global-state-idx][step] */
public final Color[][] biomecolors; /* [Biome.ordinal][step] */
public final Color[][] raincolors; /* [rain * 63][step] */
public final Color[][] tempcolors; /* [temp * 63][step] */
public ColorScheme(String name, Color[][] colors, Color[][][] datacolors, Color[][] biomecolors, Color[][] raincolors, Color[][] tempcolors) {
public ColorScheme(String name, Color[][] colors, Color[][] biomecolors, Color[][] raincolors, Color[][] tempcolors) {
this.name = name;
this.colors = colors;
this.datacolors = datacolors;
this.biomecolors = biomecolors;
this.raincolors = raincolors;
this.tempcolors = tempcolors;
//TODO: see if we can fix this for IDs vs names...
// for(int i = 0; i < colors.length; i++) {
// int id = MapManager.mapman.getBlockAlias(i);
// if(id != i) {
// this.colors[i] = this.colors[id];
// this.datacolors[i] = this.datacolors[id];
// }
// }
}
private static File getColorSchemeDirectory(DynmapCore core) {
@ -55,8 +46,7 @@ public class ColorScheme {
public static ColorScheme loadScheme(DynmapCore core, String name) {
File colorSchemeFile = new File(getColorSchemeDirectory(core), name + ".txt");
Color[][] colors = new Color[4096][];
Color[][][] datacolors = new Color[4096][][];
Color[][] colors = new Color[DynmapBlockState.getGlobalIndexMax()][];
Color[][] biomecolors = new Color[BiomeMap.values().length][];
Color[][] raincolors = new Color[64][];
Color[][] tempcolors = new Color[64][];
@ -98,15 +88,32 @@ public class ColorScheme {
if (split.length < 17) {
continue;
}
Integer id;
Integer id = null;
Integer dat = null;
boolean isbiome = false;
boolean istemp = false;
boolean israin = false;
DynmapBlockState state = null;
int idx = split[0].indexOf(':');
if(idx > 0) { /* ID:data - data color */
id = Integer.parseInt(split[0].substring(0, idx));
dat = Integer.parseInt(split[0].substring(idx+1));
if(idx > 0) { /* ID:data - data color OR blockstate - data color */
if (Character.isDigit(split[0].charAt(0))) {
id = Integer.parseInt(split[0].substring(0, idx));
dat = Integer.parseInt(split[0].substring(idx+1));
state = DynmapBlockState.getStateByLegacyBlockID(id);
if (state != null) {
state = state.getState(dat);
}
}
else {
String[] vsplit = split[0].split("[\\[\\]]");
Log.info(String.format("split[0]=%s,vsplit[0]=%s,vsplit[1]=%s", split[0], vsplit[0], vsplit.length > 1 ? vsplit[1] : ""));
if (vsplit.length > 1) {
state = DynmapBlockState.getStateByNameAndState(vsplit[0], vsplit[1]);
}
else {
state = DynmapBlockState.getBaseStateByName(vsplit[0]);
}
}
}
else if(split[0].charAt(0) == '[') { /* Biome color data */
String bio = split[0].substring(1);
@ -150,14 +157,7 @@ public class ColorScheme {
}
else {
id = Integer.parseInt(split[0]);
}
if((!isbiome) && (id >= colors.length)) {
Color[][] newcolors = new Color[id+1][];
System.arraycopy(colors, 0, newcolors, 0, colors.length);
colors = newcolors;
Color[][][] newdatacolors = new Color[id+1][][];
System.arraycopy(datacolors, 0, newdatacolors, 0, datacolors.length);
datacolors = newdatacolors;
state = DynmapBlockState.getStateByLegacyBlockID(id);
}
Color[] c = new Color[5];
@ -170,7 +170,7 @@ public class ColorScheme {
/* Blended color - for 'smooth' option on flat map */
c[4] = new Color((c[1].getRed()+c[3].getRed())/2, (c[1].getGreen()+c[3].getGreen())/2, (c[1].getBlue()+c[3].getBlue())/2, (c[1].getAlpha()+c[3].getAlpha())/2);
if(isbiome) {
if (isbiome) {
if(istemp) {
tempcolors[id] = c;
}
@ -180,34 +180,21 @@ public class ColorScheme {
else if((id >= 0) && (id < biomecolors.length))
biomecolors[id] = c;
}
else if(dat != null) {
Color[][] dcolor = datacolors[id]; /* Existing list? */
if(dcolor == null) {
dcolor = new Color[16][]; /* Make 16 index long list */
datacolors[id] = dcolor;
}
if((dat >= 0) && (dat < 16)) { /* Add color to list */
dcolor[dat] = c;
}
if(dat == 0) { /* Index zero is base color too */
colors[id] = c;
}
}
else {
colors[id] = c;
else if (state != null) {
int stateid = state.globalStateIndex;
colors[stateid] = c;
}
}
scanner.close();
/* Last, push base color into any open slots in data colors list */
for(int k = 0; k < datacolors.length; k++) {
Color[][] dc = datacolors[k]; /* see if data colors too */
if(dc != null) {
Color[] c = colors[k];
for(int i = 0; i < 16; i++) {
if(dc[i] == null)
dc[i] = c;
}
}
for (int i = 0; i < colors.length; i++) {
if (colors[i] == null) {
DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(i); // Get state
DynmapBlockState bsbase = bs.baseState;
if ((bsbase != null) && (colors[bsbase.globalStateIndex] != null)) {
colors[i] = colors[bsbase.globalStateIndex];
}
}
}
/* And interpolate any missing rain and temperature colors */
interpolateColorTable(tempcolors);
@ -218,7 +205,7 @@ public class ColorScheme {
} catch (FileNotFoundException e) {
Log.severe("Could not load colors '" + name + "' ('" + colorSchemeFile + "'): File not found.", e);
}
return new ColorScheme(name, colors, datacolors, biomecolors, raincolors, tempcolors);
return new ColorScheme(name, colors, biomecolors, raincolors, tempcolors);
}
public static void interpolateColorTable(Color[][] c) {
@ -270,16 +257,6 @@ public class ColorScheme {
else
return null;
}
public void resizeColorArray(int idx) {
if(idx >= colors.length){
Color[][] newcolors = new Color[idx+1][];
System.arraycopy(colors, 0, newcolors, 0, colors.length);
colors = newcolors;
Color[][][] newdatacolors = new Color[idx+1][][];
System.arraycopy(datacolors, 0, newdatacolors, 0, datacolors.length);
datacolors = newdatacolors;
}
}
public static void reset() {
cache.clear();
}

View File

@ -140,13 +140,11 @@ public class DefaultHDShader implements HDShader {
}
protected Color[] getBlockColors(DynmapBlockState block) {
//TODO: this will not work right on 1.13+, but thwo whole colorscheme thing is broken anyway...
int blocktype = block.globalStateIndex / 16;
int blockdata = block.globalStateIndex & 0x0F;
if((blockdata != 0) && (colorScheme.datacolors[blocktype] != null))
return colorScheme.datacolors[blocktype][blockdata];
else
return colorScheme.colors[blocktype];
int idx = block.globalStateIndex;
if (colorScheme.colors.length > idx) {
return colorScheme.colors[idx];
}
return null;
}
/**

File diff suppressed because it is too large Load Diff

View File

@ -31,22 +31,7 @@ minecraft:acacia_sapling[stage=1] 71 71 51 82 56 56 40 82 35 35 25 82 28 28 20 8
minecraft:dark_oak_sapling 37 40 30 121 29 32 24 121 18 20 15 121 14 16 12 121
minecraft:dark_oak_sapling[stage=1] 37 40 30 121 29 32 24 121 18 20 15 121 14 16 12 121
minecraft:bedrock 37 36 35 255 29 28 28 255 18 18 17 255 14 14 14 255
minecraft:water 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water[level=1] 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water[level=2] 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water[level=3] 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water[level=4] 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water[level=5] 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water[level=6] 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water[level=7] 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water[level=8] 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water[level=9] 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water[level=10] 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water[level=11] 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water[level=12] 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water[level=13] 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water[level=14] 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water[level=15] 77 193 124 144 61 154 99 144 38 96 62 144 30 77 49 144
minecraft:water 47 67 244 179 37 53 195 179 23 33 122 179 18 26 97 179
minecraft:lava 125 24 10 255 100 19 8 255 62 12 5 255 50 9 4 255
minecraft:lava[level=1] 125 24 10 255 100 19 8 255 62 12 5 255 50 9 4 255
minecraft:lava[level=2] 125 24 10 255 100 19 8 255 62 12 5 255 50 9 4 255

View File

@ -31,22 +31,7 @@ minecraft:acacia_sapling[stage=1] 75 76 25 81 60 60 20 81 37 38 12 81 30 30 10 8
minecraft:dark_oak_sapling 37 40 30 121 29 32 24 121 18 20 15 121 14 16 12 121
minecraft:dark_oak_sapling[stage=1] 37 40 30 121 29 32 24 121 18 20 15 121 14 16 12 121
minecraft:bedrock 38 39 42 255 30 31 33 255 19 19 21 255 15 15 16 255
minecraft:water 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water[level=1] 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water[level=2] 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water[level=3] 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water[level=4] 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water[level=5] 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water[level=6] 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water[level=7] 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water[level=8] 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water[level=9] 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water[level=10] 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water[level=11] 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water[level=12] 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water[level=13] 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water[level=14] 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water[level=15] 118 240 223 144 94 192 178 144 59 120 111 144 47 96 89 144
minecraft:water 47 67 244 179 37 53 195 179 23 33 122 179 18 26 97 179
minecraft:lava 125 24 10 255 100 19 8 255 62 12 5 255 50 9 4 255
minecraft:lava[level=1] 125 24 10 255 100 19 8 255 62 12 5 255 50 9 4 255
minecraft:lava[level=2] 125 24 10 255 100 19 8 255 62 12 5 255 50 9 4 255

View File

@ -31,22 +31,7 @@ minecraft:acacia_sapling[stage=1] 75 76 25 81 60 60 20 81 37 38 12 81 30 30 10 8
minecraft:dark_oak_sapling 37 40 30 121 29 32 24 121 18 20 15 121 14 16 12 121
minecraft:dark_oak_sapling[stage=1] 37 40 30 121 29 32 24 121 18 20 15 121 14 16 12 121
minecraft:bedrock 41 43 46 255 32 34 36 255 20 21 23 255 16 17 18 255
minecraft:water 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water[level=1] 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water[level=2] 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water[level=3] 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water[level=4] 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water[level=5] 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water[level=6] 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water[level=7] 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water[level=8] 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water[level=9] 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water[level=10] 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water[level=11] 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water[level=12] 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water[level=13] 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water[level=14] 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water[level=15] 209 221 196 149 167 176 156 149 104 110 98 149 83 88 78 149
minecraft:water 47 67 244 179 37 53 195 179 23 33 122 179 18 26 97 179
minecraft:lava 128 33 18 255 102 26 14 255 64 16 9 255 51 13 7 255
minecraft:lava[level=1] 128 33 18 255 102 26 14 255 64 16 9 255 51 13 7 255
minecraft:lava[level=2] 128 33 18 255 102 26 14 255 64 16 9 255 51 13 7 255

View File

@ -31,22 +31,7 @@ minecraft:acacia_sapling[stage=1] 88 93 51 64 70 74 40 64 44 46 25 64 35 37 20 6
minecraft:dark_oak_sapling 40 45 32 110 32 36 25 110 20 22 16 110 16 18 12 110
minecraft:dark_oak_sapling[stage=1] 40 45 32 110 32 36 25 110 20 22 16 110 16 18 12 110
minecraft:bedrock 65 60 56 255 52 48 44 255 32 30 28 255 26 24 22 255
minecraft:water 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water[level=1] 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water[level=2] 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water[level=3] 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water[level=4] 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water[level=5] 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water[level=6] 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water[level=7] 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water[level=8] 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water[level=9] 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water[level=10] 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water[level=11] 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water[level=12] 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water[level=13] 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water[level=14] 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water[level=15] 154 154 154 218 123 123 123 218 77 77 77 218 61 61 61 218
minecraft:water 47 67 244 179 37 53 195 179 23 33 122 179 18 26 97 179
minecraft:lava 200 63 39 255 160 50 31 255 100 31 19 255 80 25 15 255
minecraft:lava[level=1] 200 63 39 255 160 50 31 255 100 31 19 255 80 25 15 255
minecraft:lava[level=2] 200 63 39 255 160 50 31 255 100 31 19 255 80 25 15 255

View File

@ -31,22 +31,7 @@ minecraft:acacia_sapling[stage=1] 70 79 16 91 56 63 12 91 35 39 8 91 28 31 6 91
minecraft:dark_oak_sapling 47 70 18 102 37 56 14 102 23 35 9 102 18 28 7 102
minecraft:dark_oak_sapling[stage=1] 47 70 18 102 37 56 14 102 23 35 9 102 18 28 7 102
minecraft:bedrock 22 23 24 255 17 18 19 255 11 11 12 255 8 9 9 255
minecraft:water 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water[level=1] 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water[level=2] 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water[level=3] 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water[level=4] 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water[level=5] 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water[level=6] 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water[level=7] 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water[level=8] 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water[level=9] 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water[level=10] 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water[level=11] 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water[level=12] 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water[level=13] 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water[level=14] 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water[level=15] 210 210 210 179 168 168 168 179 105 105 105 179 84 84 84 179
minecraft:water 47 67 244 179 37 53 195 179 23 33 122 179 18 26 97 179
minecraft:lava 254 129 0 255 203 103 0 255 127 64 0 255 101 51 0 255
minecraft:lava[level=1] 254 129 0 255 203 103 0 255 127 64 0 255 101 51 0 255
minecraft:lava[level=2] 254 129 0 255 203 103 0 255 127 64 0 255 101 51 0 255

View File

@ -31,22 +31,7 @@ minecraft:acacia_sapling[stage=1] 118 117 23 110 94 93 18 110 59 58 11 110 47 46
minecraft:dark_oak_sapling 61 90 30 109 48 72 24 109 30 45 15 109 24 36 12 109
minecraft:dark_oak_sapling[stage=1] 61 90 30 109 48 72 24 109 30 45 15 109 24 36 12 109
minecraft:bedrock 85 85 85 255 68 68 68 255 42 42 42 255 34 34 34 255
minecraft:water 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water[level=1] 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water[level=2] 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water[level=3] 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water[level=4] 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water[level=5] 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water[level=6] 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water[level=7] 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water[level=8] 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water[level=9] 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water[level=10] 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water[level=11] 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water[level=12] 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water[level=13] 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water[level=14] 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water[level=15] 177 177 177 180 141 141 141 180 88 88 88 180 70 70 70 180
minecraft:water 47 67 244 179 37 53 195 179 23 33 122 179 18 26 97 179
minecraft:lava 216 104 26 255 172 83 20 255 108 52 13 255 86 41 10 255
minecraft:lava[level=1] 216 104 26 255 172 83 20 255 108 52 13 255 86 41 10 255
minecraft:lava[level=2] 216 104 26 255 172 83 20 255 108 52 13 255 86 41 10 255