Ejemplo n.º 1
0
  public DefaultTileRenderer(DynmapCore core, ConfigurationNode configuration) {
    name = configuration.getString("name", null);
    prefix = configuration.getString("prefix", name);
    maximumHeight = configuration.getInteger("maximumheight", 127);
    shadowstrength = configuration.getDouble("shadowstrength", 0.0);
    if (shadowstrength > 0.0) {
      shadowscale = new int[16];
      shadowscale[15] = 256;
      /* Normal brightness weight in MC is a 20% relative dropoff per step */
      for (int i = 14; i >= 0; i--) {
        double v = shadowscale[i + 1] * (1.0 - (0.2 * shadowstrength));
        shadowscale[i] = (int) v;
        if (shadowscale[i] > 256) shadowscale[i] = 256;
        if (shadowscale[i] < 0) shadowscale[i] = 0;
      }
    }
    ambientlight = configuration.getInteger("ambientlight", 15);
    if (ambientlight < 15) {
      lightscale = new int[16];
      for (int i = 0; i < 16; i++) {
        if (i < (15 - ambientlight)) lightscale[i] = 0;
        else lightscale[i] = i - (15 - ambientlight);
      }
    }
    colorScheme = ColorScheme.getScheme(core, (String) configuration.get("colorscheme"));
    night_and_day = configuration.getBoolean("night-and-day", false);
    transparency = configuration.getBoolean("transparency", true); /* Default on */
    String biomeopt = configuration.getString("biomecolored", "none");
    if (biomeopt.equals("biome")) {
      biomecolored = BiomeColorOption.BIOME;
    } else if (biomeopt.equals("temperature")) {
      biomecolored = BiomeColorOption.TEMPERATURE;
    } else if (biomeopt.equals("rainfall")) {
      biomecolored = BiomeColorOption.RAINFALL;
    } else {
      biomecolored = BiomeColorOption.NONE;
    }

    title = configuration.getString("title");
    icon = configuration.getString("icon");
    bg_cfg = configuration.getString("background");
    bg_day_cfg = configuration.getString("backgroundday");
    bg_night_cfg = configuration.getString("backgroundnight");
    mapzoomin = configuration.getInteger("mapzoomin", 2);
    is_protected = configuration.getBoolean("protected", false);
  }
Ejemplo n.º 2
0
 public DefaultTileRenderer(ConfigurationNode configuration) {
   this.configuration = configuration;
   name = (String) configuration.get("prefix");
   Object o = configuration.get("maximumheight");
   if (o != null) {
     maximumHeight = Integer.parseInt(String.valueOf(o));
     if (maximumHeight > 127) maximumHeight = 127;
   }
   o = configuration.get("shadowstrength");
   if (o != null) {
     double shadowweight = Double.parseDouble(String.valueOf(o));
     if (shadowweight > 0.0) {
       shadowscale = new int[16];
       shadowscale[15] = 256;
       /* Normal brightness weight in MC is a 20% relative dropoff per step */
       for (int i = 14; i >= 0; i--) {
         double v = shadowscale[i + 1] * (1.0 - (0.2 * shadowweight));
         shadowscale[i] = (int) v;
         if (shadowscale[i] > 256) shadowscale[i] = 256;
         if (shadowscale[i] < 0) shadowscale[i] = 0;
       }
     }
   }
   o = configuration.get("ambientlight");
   if (o != null) {
     int v = Integer.parseInt(String.valueOf(o));
     lightscale = new int[16];
     for (int i = 0; i < 16; i++) {
       if (i < (15 - v)) lightscale[i] = 0;
       else lightscale[i] = i - (15 - v);
     }
   }
   colorScheme = ColorScheme.getScheme((String) configuration.get("colorscheme"));
   night_and_day = configuration.getBoolean("night-and-day", false);
   transparency = configuration.getBoolean("transparency", true); /* Default on */
 }
Ejemplo n.º 3
0
  protected void scan(
      DynmapWorld world,
      int seq,
      boolean isnether,
      final Color result,
      final Color result_day,
      MapIterator mapiter) {
    int lightlevel = 15;
    int lightlevel_day = 15;
    BiomeMap bio = null;
    double rain = 0.0;
    double temp = 0.0;
    result.setTransparent();
    if (result_day != null) result_day.setTransparent();
    for (; ; ) {
      if (mapiter.getY() < 0) {
        return;
      }
      int id = mapiter.getBlockTypeID();
      int data = 0;
      if (isnether) {
          /* Make bedrock ceiling into air in nether */
        if (id != 0) {
          /* Remember first color we see, in case we wind up solid */
          if (result.isTransparent()) {
            try {
              if (colorScheme.colors[id] != null) {
                result.setColor(colorScheme.colors[id][seq]);
              }
            } catch (ArrayIndexOutOfBoundsException aioobx) {
              colorScheme.resizeColorArray(id);
            }
          }
          id = 0;
        } else isnether = false;
      }
      if (id != 0) {
          /* No update needed for air */
        switch (biomecolored) {
          case NONE:
            try {
              if (colorScheme.datacolors[id] != null) {
                  /* If data colored */
                data = mapiter.getBlockData();
              }
            } catch (ArrayIndexOutOfBoundsException aioobx) {
              colorScheme.resizeColorArray(id);
            }
            break;
          case BIOME:
            bio = mapiter.getBiome();
            break;
          case RAINFALL:
            rain = mapiter.getRawBiomeRainfall();
            break;
          case TEMPERATURE:
            temp = mapiter.getRawBiomeTemperature();
            break;
        }
        if ((shadowscale != null) && (mapiter.getY() < (mapiter.getWorldHeight() - 1))) {
          /* Find light level of previous chunk */
          BlockStep last = mapiter.unstepPosition();
          lightlevel = lightlevel_day = mapiter.getBlockSkyLight();
          if (lightscale != null) lightlevel = lightscale[lightlevel];
          if ((lightlevel < 15) || (lightlevel_day < 15)) {
            int emitted = mapiter.getBlockEmittedLight();
            lightlevel = Math.max(emitted, lightlevel);
            lightlevel_day = Math.max(emitted, lightlevel_day);
          }
          mapiter.stepPosition(last);
        }
      }

      switch (seq) {
        case 0:
          mapiter.stepPosition(BlockStep.X_MINUS);
          break;
        case 1:
        case 3:
          mapiter.stepPosition(BlockStep.Y_MINUS);
          break;
        case 2:
          mapiter.stepPosition(BlockStep.Z_PLUS);
          break;
      }

      seq = (seq + 1) & 3;

      if (id != 0) {
        if (highlightBlocks.contains(id)) {
          result.setColor(highlightColor);
          return;
        }
        Color[] colors = null;
        switch (biomecolored) {
          case NONE:
            try {
              if (data != 0) colors = colorScheme.datacolors[id][data];
              else colors = colorScheme.colors[id];
            } catch (ArrayIndexOutOfBoundsException aioobx) {
              colorScheme.resizeColorArray(id);
            }
            break;
          case BIOME:
            if (bio != null) colors = colorScheme.biomecolors[bio.ordinal()];
            break;
          case RAINFALL:
            colors = colorScheme.getRainColor(rain);
            break;
          case TEMPERATURE:
            colors = colorScheme.getTempColor(temp);
            break;
        }
        if (colors != null) {
          Color c = colors[seq];
          if (c.getAlpha() > 0) {
            /* we found something that isn't transparent, or not doing transparency */
            if ((!transparency) || (c.getAlpha() == 255)) {
              /* it's opaque - the ray ends here */
              result.setARGB(c.getARGB() | 0xFF000000);
              if (lightlevel < 15) {
                  /* Not full light? */
                shadowColor(result, lightlevel);
              }
              if (result_day != null) {
                if (lightlevel_day == lightlevel) /* Same light = same result */
                  result_day.setColor(result);
                else {
                  result_day.setColor(c);
                  if (lightlevel_day < 15) shadowColor(result_day, lightlevel_day);
                }
              }
              return;
            }

            /* this block is transparent, so recurse */
            scan(world, seq, isnether, result, result_day, mapiter);

            int cr = c.getRed();
            int cg = c.getGreen();
            int cb = c.getBlue();
            int ca = c.getAlpha();
            if (lightlevel < 15) {
              int scale = shadowscale[lightlevel];
              cr = (cr * scale) >> 8;
              cg = (cg * scale) >> 8;
              cb = (cb * scale) >> 8;
            }
            cr *= ca;
            cg *= ca;
            cb *= ca;
            int na = 255 - ca;
            result.setRGBA(
                (result.getRed() * na + cr) >> 8,
                (result.getGreen() * na + cg) >> 8,
                (result.getBlue() * na + cb) >> 8,
                255);
            /* Handle day also */
            if (result_day != null) {
              cr = c.getRed();
              cg = c.getGreen();
              cb = c.getBlue();
              if (lightlevel_day < 15) {
                int scale = shadowscale[lightlevel_day];
                cr = (cr * scale) >> 8;
                cg = (cg * scale) >> 8;
                cb = (cb * scale) >> 8;
              }
              cr *= ca;
              cg *= ca;
              cb *= ca;
              result_day.setRGBA(
                  (result_day.getRed() * na + cr) >> 8,
                  (result_day.getGreen() * na + cg) >> 8,
                  (result_day.getBlue() * na + cb) >> 8,
                  255);
            }
            return;
          }
        }
      }
    }
  }