// Need for create world config from network packet
  public WorldConfig(DataInputStream stream, LocalWorld world) throws IOException {
    // General information
    this.WorldName = readStringFromStream(stream);

    this.WorldFog = stream.readInt();
    this.WorldNightFog = stream.readInt();

    this.WorldFogR = ((WorldFog & 0xFF0000) >> 16) / 255F;
    this.WorldFogG = ((WorldFog & 0xFF00) >> 8) / 255F;
    this.WorldFogB = (WorldFog & 0xFF) / 255F;

    this.WorldNightFogR = ((WorldNightFog & 0xFF0000) >> 16) / 255F;
    this.WorldNightFogG = ((WorldNightFog & 0xFF00) >> 8) / 255F;
    this.WorldNightFogB = (WorldNightFog & 0xFF) / 255F;

    // Custom biomes + ids
    int count = stream.readInt();
    while (count-- > 0) {
      String name = readStringFromStream(stream);
      int id = stream.readInt();
      world.AddBiome(name, id);
      this.CustomBiomes.add(name);
      this.CustomBiomeIds.put(name, id);
    }

    // BiomeConfigs
    this.biomeConfigs = new BiomeConfig[world.getMaxBiomesCount()];

    count = stream.readInt();
    while (count-- > 0) {
      int id = stream.readInt();
      BiomeConfig config = new BiomeConfig(stream, this, world.getBiomeById(id));
      this.biomeConfigs[id] = config;
    }
  }
Esempio n. 2
0
  // Need for create world config from network packet
  public WorldConfig(DataInputStream stream, LocalWorld world) throws IOException {
    // Protocol version
    int protocolVersion = stream.readInt();
    if (protocolVersion != TCDefaultValues.ProtocolVersion.intValue())
      throw new IOException("Wrong TC protocol version");

    this.WorldName = ReadStringFromStream(stream);

    this.GenerationDepth = stream.readInt();
    this.BiomeRarityScale = stream.readInt();
    this.LandRarity = stream.readInt();
    this.LandSize = stream.readInt();
    this.LandFuzzy = stream.readInt();
    this.IceRarity = stream.readInt();
    this.IceSize = stream.readInt();
    this.FrozenOcean = stream.readBoolean();
    this.FrozenRivers = stream.readBoolean();
    this.RiverRarity = stream.readInt();
    this.RiverSize = stream.readInt();
    this.RiversEnabled = stream.readBoolean();

    this.oldBiomeSize = stream.readDouble();

    this.minTemperature = stream.readFloat();
    this.maxTemperature = stream.readFloat();

    this.minMoisture = stream.readFloat();
    this.maxMoisture = stream.readFloat();

    this.WorldFog = stream.readInt();
    this.WorldNightFog = stream.readInt();

    this.WorldFogR = ((WorldFog & 0xFF0000) >> 16) / 255F;
    this.WorldFogG = ((WorldFog & 0xFF00) >> 8) / 255F;
    this.WorldFogB = (WorldFog & 0xFF) / 255F;

    this.WorldNightFogR = ((WorldNightFog & 0xFF0000) >> 16) / 255F;
    this.WorldNightFogG = ((WorldNightFog & 0xFF00) >> 8) / 255F;
    this.WorldNightFogB = (WorldNightFog & 0xFF) / 255F;

    int count = stream.readInt();
    while (count-- > 0) {
      String name = ReadStringFromStream(stream);
      int id = stream.readInt();
      world.AddBiome(name, id);
      this.CustomBiomes.add(name);
      this.CustomBiomeIds.put(name, id);
    }

    this.biomeConfigs = new BiomeConfig[world.getMaxBiomesCount()];

    count = stream.readInt();
    while (count-- > 0) {
      int id = stream.readInt();
      BiomeConfig config = new BiomeConfig(stream, this, world.getBiomeById(id));
      this.biomeConfigs[id] = config;
    }

    count = stream.readInt();
    String name;
    while (count-- > 0) {
      name = ReadStringFromStream(stream);
      this.NormalBiomes.add(name);
    }

    count = stream.readInt();
    while (count-- > 0) {
      name = ReadStringFromStream(stream);
      this.IceBiomes.add(name);
    }

    count = stream.readInt();
    while (count-- > 0) {
      name = ReadStringFromStream(stream);
      this.IsleBiomes.add(name);
    }

    count = stream.readInt();
    while (count-- > 0) {
      name = ReadStringFromStream(stream);
      this.BorderBiomes.add(name);
    }

    for (BiomeConfig biomeConfig : this.biomeConfigs)
      if (biomeConfig != null && biomeConfig.Biome.isCustom())
        biomeConfig.Biome.setCustom(biomeConfig);
  }