Exemplo n.º 1
0
 private static boolean getConnectedTexture(
     IBlockAccess blockAccess,
     Block block,
     int origTexture,
     int i,
     int j,
     int k,
     int face,
     TileOverride[][] allOverrides,
     int index) {
   if (index < 0 || index >= allOverrides.length) {
     return false;
   }
   TileOverride[] overrides = allOverrides[index];
   if (overrides == null) {
     return false;
   }
   for (int n = 0; n < overrides.length; n++) {
     TileOverride override = overrides[n];
     if (override == null) {
       continue;
     }
     if (override.disabled) {
       overrides[n] = null;
       continue;
     }
     newTexture = override.texture;
     newTextureIndex = override.getTile(blockAccess, block, origTexture, i, j, k, face);
     if (newTextureIndex >= 0) {
       return true;
     }
   }
   return false;
 }
Exemplo n.º 2
0
  private static TileOverride setupOutline(
      int tileNum, BufferedImage terrain, BufferedImage template) {
    switch (tileNum) {
      case TILE_NUM_STILL_LAVA: // still lava
      case TILE_NUM_FLOWING_LAVA: // flowing lava
      case TILE_NUM_STILL_WATER: // still water
      case TILE_NUM_FLOWING_WATER: // flowing water
      case TILE_NUM_FIRE_E_W: // fire east-west
      case TILE_NUM_FIRE_N_S: // fire north-south
      case TILE_NUM_PORTAL: // portal
        return null;

      default:
        break;
    }

    int tileSize = terrain.getWidth() / 16;
    int tileX = (tileNum % 16) * tileSize;
    int tileY = (tileNum / 16) * tileSize;
    BufferedImage newImage =
        new BufferedImage(template.getWidth(), template.getHeight(), BufferedImage.TYPE_INT_ARGB);

    for (int x = 0; x < template.getWidth(); x++) {
      for (int y = 0; y < template.getHeight(); y++) {
        int rgb = template.getRGB(x, y);
        if ((rgb & 0xff000000) == 0) {
          rgb = terrain.getRGB(tileX + (x % tileSize), tileY + (y % tileSize));
        }
        newImage.setRGB(x, y, rgb);
      }
    }

    return TileOverride.create(newImage);
  }
Exemplo n.º 3
0
 private static void loadBasicOverride(
     Properties properties, TileOverride[][] allOverrides, int index) {
   TileOverride override = TileOverride.create("/ctm", properties, false);
   if (override == null || allOverrides == null || index < 0 || index >= allOverrides.length) {
     return;
   }
   TileOverride[] oldList = allOverrides[index];
   if (oldList == null) {
     allOverrides[index] = new TileOverride[] {override};
   } else {
     TileOverride[] newList = new TileOverride[oldList.length + 1];
     System.arraycopy(oldList, 0, newList, 0, oldList.length);
     newList[oldList.length] = override;
     allOverrides[index] = newList;
   }
 }
Exemplo n.º 4
0
 private static TileOverride[][] loadOverrides(String type, int length, boolean connectByTile) {
   TileOverride[][] allOverrides = new TileOverride[length][];
   if (enableStandard || enableNonStandard) {
     for (int i = 0; i < length; i++) {
       ArrayList<TileOverride> tmpOverrides = null;
       for (char c = 'a' - 1; c <= 'z'; c++) {
         String prefix = "/ctm/" + type + i + (c >= 'a' ? "" + c : "");
         TileOverride override = TileOverride.create(prefix, null, connectByTile);
         if (override == null) {
           break;
         }
         if (tmpOverrides == null) {
           tmpOverrides = new ArrayList<TileOverride>();
         }
         tmpOverrides.add(override);
       }
       if (tmpOverrides != null) {
         allOverrides[i] = new TileOverride[tmpOverrides.size()];
         tmpOverrides.toArray(allOverrides[i]);
       }
     }
   }
   return allOverrides;
 }