Beispiel #1
0
 public final int getSmoothWaterColorMultiplier(int[] colormap, int width) {
   int mult = 0xFFFFFF;
   try {
     int rx = x - x_base;
     int rz = z - z_base;
     BiomeMap bm = biomemap[rx][rz];
     if (sameneighborbiomecnt[rx][rz] >= (byte) 8) {
         /* All neighbors same? */
       mult = colormap[bm.biomeLookup(width)];
     } else {
       int raccum = 0;
       int gaccum = 0;
       int baccum = 0;
       for (int xoff = -1; xoff < 2; xoff++) {
         for (int zoff = -1; zoff < 2; zoff++) {
           bm = biomemap[rx + xoff][rz + zoff];
           int rmult = colormap[bm.biomeLookup(width)];
           raccum += (rmult >> 16) & 0xFF;
           gaccum += (rmult >> 8) & 0xFF;
           baccum += rmult & 0xFF;
         }
       }
       mult = ((raccum / 9) << 16) | ((gaccum / 9) << 8) | (baccum / 9);
     }
   } catch (Exception x) {
     exceptions++;
     mult = 0xFFFFFF;
   }
   return mult;
 }
Beispiel #2
0
 public final int getSmoothWaterColorMultiplier() {
   try {
     int rx = x - x_base;
     int rz = z - z_base;
     BiomeMap bm = biomemap[rx][rz];
     if (sameneighborbiomecnt[rx][rz] >= (byte) 8) {
         /* All neighbors same? */
       return bm.getWaterColorMult();
     }
     int raccum = 0;
     int gaccum = 0;
     int baccum = 0;
     for (int xoff = -1; xoff < 2; xoff++) {
       for (int zoff = -1; zoff < 2; zoff++) {
         bm = biomemap[rx + xoff][rz + zoff];
         int mult = bm.getWaterColorMult();
         raccum += (mult >> 16) & 0xFF;
         gaccum += (mult >> 8) & 0xFF;
         baccum += mult & 0xFF;
       }
     }
     return ((raccum / 9) << 16) | ((gaccum / 9) << 8) | (baccum / 9);
   } catch (Exception x) {
     exceptions++;
     return 0xFFFFFF;
   }
 }
Beispiel #3
0
    private void biomePrep() {
      if (sameneighborbiomecnt != null) return;
      int x_size = x_dim << 4;
      int z_size = (z_max - z_min + 1) << 4;
      sameneighborbiomecnt = new byte[x_size][];
      biomemap = new BiomeMap[x_size][];
      for (int i = 0; i < x_size; i++) {
        sameneighborbiomecnt[i] = new byte[z_size];
        biomemap[i] = new BiomeMap[z_size];
      }
      Object[] biomebase = null;
      ChunkSnapshot biome_css = null;
      for (int i = 0; i < x_size; i++) {
        initialize(i + x_base, 64, z_base);
        for (int j = 0; j < z_size; j++) {
          BiomeMap bm;

          if (snap != biome_css) {
            biomebase = null;
            biome_css = snap;
            if (biome_css instanceof SpoutChunkSnapshot) {
              biome_css = ((SpoutChunkSnapshot) biome_css).chunk;
            }
            biomebase = helper.getBiomeBaseFromSnapshot(biome_css);
          }
          if (biomebase != null) {
            bm = BiomeMap.byBiomeID(helper.getBiomeBaseID(biomebase[bz << 4 | bx]));
          } else {
            Biome bb = snap.getBiome(bx, bz);
            if (bb == null) bm = BiomeMap.NULL;
            else bm = biome_to_bmap[bb.ordinal()];
          }
          biomemap[i][j] = bm;
          int cnt = 0;
          if (i > 0) {
            if (bm == biomemap[i - 1][j]) {
                /* Same as one to left */
              cnt++;
              sameneighborbiomecnt[i - 1][j]++;
            }
            if ((j > 0) && (bm == biomemap[i - 1][j - 1])) {
              cnt++;
              sameneighborbiomecnt[i - 1][j - 1]++;
            }
            if ((j < (z_size - 1)) && (bm == biomemap[i - 1][j + 1])) {
              cnt++;
              sameneighborbiomecnt[i - 1][j + 1]++;
            }
          }
          if ((j > 0) && (biomemap[i][j] == biomemap[i][j - 1])) {
              /* Same as one to above */
            cnt++;
            sameneighborbiomecnt[i][j - 1]++;
          }
          sameneighborbiomecnt[i][j] = (byte) cnt;

          stepPosition(BlockStep.Z_PLUS);
        }
      }
    }
Beispiel #4
0
 @Override
 public String[] getBiomeIDs() {
   BiomeMap[] b = BiomeMap.values();
   String[] bname = new String[b.length];
   for (int i = 0; i < bname.length; i++) bname[i] = b[i].toString();
   return bname;
 }
Beispiel #5
0
 static {
   Biome[] b = Biome.values();
   BiomeMap[] bm = BiomeMap.values();
   biome_to_bmap = new BiomeMap[256];
   for (int i = 0; i < biome_to_bmap.length; i++) {
     biome_to_bmap[i] = BiomeMap.NULL;
   }
   for (int i = 0; i < b.length; i++) {
     String bs = b[i].toString();
     for (int j = 0; j < bm.length; j++) {
       if (bm[j].toString().equals(bs)) {
         biome_to_bmap[b[i].ordinal()] = bm[j];
         break;
       }
     }
   }
 }
 public int getSmoothWaterColorMultiplier(int[] colormap, int width) {
   // TODO Auto-generated method stub
   BiomeMap bm = getBiome();
   return colormap[bm.biomeLookup(width)];
 }
 public int getSmoothWaterColorMultiplier() {
   // TODO Auto-generated method stub
   BiomeMap bm = getBiome();
   return bm.getWaterColorMult();
 }
 public int getSmoothColorMultiplier(int[] colormap, int width, int[] swampmap, int swampwidth) {
   // TODO Auto-generated method stub
   BiomeMap bm = getBiome();
   if (bm == BiomeMap.SWAMPLAND) return swampmap[bm.biomeLookup(swampwidth)];
   else return colormap[bm.biomeLookup(width)];
 }
 public int getSmoothFoliageColorMultiplier(int[] colormap, int width) {
   // TODO Auto-generated method stub
   BiomeMap bm = getBiome();
   return bm.getModifiedFoliageMultiplier(colormap[bm.biomeLookup(width)]);
 }
 public int getSmoothGrassColorMultiplier(int[] colormap, int width) {
   // TODO
   BiomeMap bm = getBiome();
   return bm.getModifiedGrassMultiplier(colormap[bm.biomeLookup(width)]);
 }
  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;
          }
        }
      }
    }
  }