Merge pull request #3932 from JurgenKuyper/CaveGradients

implemented user configurable start and stop of cave render
This commit is contained in:
mikeprimm 2023-02-27 06:01:35 -06:00 committed by GitHub
commit fd2e4ba8c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,8 @@ import org.json.simple.JSONObject;
public class CaveHDShader implements HDShader { public class CaveHDShader implements HDShader {
private String name; private String name;
private boolean iflit; private boolean iflit;
private Color startColor;
private Color endColor;
private BitSet hiddenids = new BitSet(); private BitSet hiddenids = new BitSet();
private void setHidden(DynmapBlockState blk) { private void setHidden(DynmapBlockState blk) {
@ -41,7 +43,8 @@ public class CaveHDShader implements HDShader {
public CaveHDShader(DynmapCore core, ConfigurationNode configuration) { public CaveHDShader(DynmapCore core, ConfigurationNode configuration) {
name = (String) configuration.get("name"); name = (String) configuration.get("name");
iflit = configuration.getBoolean("onlyiflit", false); iflit = configuration.getBoolean("onlyiflit", false);
startColor = configuration.getColor("startColor", "#0000FF");
endColor = configuration.getColor("endColor", "#00FF00");
for (int i = 0; i < DynmapBlockState.getGlobalIndexMax(); i++) { for (int i = 0; i < DynmapBlockState.getGlobalIndexMax(); i++) {
DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(i); DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(i);
if (bs.isAir() || bs.isWater()) { if (bs.isAir() || bs.isWater()) {
@ -187,17 +190,35 @@ public class CaveHDShader implements HDShader {
return false; return false;
} }
int cr, cg, cb; int cr, cg, cb;
int mult = 256; int mult;
int ys = mapiter.getY() >> yshift; int ys = mapiter.getY() >> yshift;
if (ys < 64) { if(startColor.getARGB() != 0xFF0000FF && endColor.getARGB() != 0xFF00FF00)
cr = 0; {
cg = 64 + ys * 3; if (startColor.getRed() + ys < 255)
cb = 255 - ys * 4; cr = startColor.getRed() + ys * endColor.getRed();
} else { else
cr = (ys - 64) * 4; cr = startColor.getRed() - ys * endColor.getRed();
cg = 255; if (startColor.getGreen() + ys < 255)
cb = 0; cg = startColor.getGreen() + ys * endColor.getGreen();
else
cg = startColor.getGreen() - ys * endColor.getGreen();
if (startColor.getBlue() + ys < 255)
cb = startColor.getBlue() + ys * endColor.getBlue();
else
cb = startColor.getBlue() - ys * endColor.getBlue();
}
else
{
if (ys < 64) {
cr = 0;
cg = 64 + ys * 3;
cb = 255 - ys * 4;
} else {
cr = (ys - 64) * 4;
cg = 255;
cb = 0;
}
} }
/* Figure out which color to use */ /* Figure out which color to use */
switch(ps.getLastBlockStep()) { switch(ps.getLastBlockStep()) {