Example #1
0
  private void load_snap_from_xml(Element snap, StructureCollection structs, LinkedList tempList)
      throws VisualizerLoadException {
    Iterator iterator = snap.getChildren().iterator();

    if (!iterator.hasNext()) throw new VisualizerLoadException("Ran out of elements");

    structs.loadTitle((Element) (iterator.next()), tempList, this);
    structs.calcDimsAndStartPts(tempList, this);

    if (!iterator.hasNext()) return;
    Element child = (Element) iterator.next();

    if (child.getName().compareTo("doc_url") == 0) {
      // load the doc_url
      add_a_documentation_URL(child.getText().trim());
      if (!iterator.hasNext()) return;
      child = (Element) iterator.next();
    }

    if (child.getName().compareTo("pseudocode_url") == 0) {
      // load the psuedocode_url
      add_a_pseudocode_URL(child.getText().trim());
      if (!iterator.hasNext()) return;
      child = (Element) iterator.next();
    }

    if (child.getName().compareTo("audio_text") == 0) {
      // load the psuedocode_url
      add_audio_text(child.getText().trim());
      if (!iterator.hasNext()) return;
      child = (Element) iterator.next();
    }

    // create & load the individual structures, hooking them into the StructureCollection.
    // linespernode : calculate it at end of loadStructure call
    while (child.getName().compareTo("question_ref") != 0) {
      StructureType child_struct = assignStructureType(child);
      child_struct.loadStructure(child, tempList, this);
      structs.addChild(child_struct);

      if (!iterator.hasNext()) return;
      child = (Element) iterator.next();
    }

    if (child.getName().compareTo("question_ref") == 0) {
      // set up question ref
      add_a_question_xml(child.getAttributeValue("ref"));
    } else
      // should never happen
      throw new VisualizerLoadException(
          "Expected question_ref element, but found " + child.getName());

    if (iterator.hasNext()) {
      child = (Element) iterator.next();
      throw new VisualizerLoadException(
          "Found " + child.getName() + " when expecting end of snap.");
    }
  } // load_snap_from_xml
Example #2
0
  // createericlist with a String signature is used to process a String
  // containing a sequence of GAIGS structures
  // createericlist creates the list of graphics primitives for these snapshot(s).
  // After creating these lists, that are then appended to l, the list of snapshots,
  // Also must return the number of snapshots loaded from the string
  public /*synchronized*/ int createericlist(String structString) {
    int numsnaps = 0;
    if (debug) System.out.println("In create eric " + structString);
    StringTokenizer st = new StringTokenizer(structString, "\r\n");
    while (st.hasMoreTokens()) {
      numsnaps++; // ??
      String tempString;
      LinkedList tempList = new LinkedList();
      StructureType strct;
      tempString = st.nextToken();
      try {
        boolean headers = true;
        while (headers) {
          headers = false;
          if (tempString.toUpperCase().startsWith("VIEW")) {
            tempString = HandleViewParams(tempString, tempList, st);
            headers = true;
          }
          if (tempString.toUpperCase().startsWith("FIBQUESTION ")
              || tempString.toUpperCase().startsWith("MCQUESTION ")
              || tempString.toUpperCase().startsWith("MSQUESTION ")
              || tempString.toUpperCase().startsWith("TFQUESTION ")) {
            tempString = add_a_question(tempString, st);
            headers = true;
          }
        }

        if (tempString.toUpperCase().equals("STARTQUESTIONS")) {
          numsnaps--; // questions don't count as snapshots
          readQuestions(st);
          break;
        }
        // After returning from HandleViewParams, tempString should now contain
        // the line with the structure type and possible additional text height info
        StringTokenizer structLine = new StringTokenizer(tempString, " \t");
        String structType = structLine.nextToken();
        if (debug) System.out.println("About to assign structure" + structType);
        strct = assignStructureType(structType);
        strct.loadTextHeights(structLine, tempList, this);
        strct.loadLinesPerNodeInfo(st, tempList, this);

        strct.loadTitle(st, tempList, this);
        strct.loadStructure(st, tempList, this);
        strct.calcDimsAndStartPts(tempList, this);
        strct.drawTitle(tempList, this);
        strct.drawStructure(tempList, this);
      } catch (VisualizerLoadException e) {
        System.out.println(e.toString());
      }
      //             // You've just created a snapshot.  Need to insure that "**" is appended
      //             // to the URLList for this snapshot IF no VIEW ALGO line was parsed in the
      //             // string for the snapshot.  This could probably best be done in the
      //             // HandleViewParams method
      list_of_snapshots.append(tempList);
      Snaps++;
    }
    return (numsnaps);
  } // createericlist(string)
Example #3
0
  public void dump(EntityPlayer player) {
    String digits = getDigitString();
    if (!digits.isEmpty()) {
      logDebug(player, "    Digits: " + digits);
    }
    if (forcedDimensionSeed != 0) {
      logDebug(player, "    Forced seed: " + forcedDimensionSeed);
    }
    if (baseSeed != 0) {
      logDebug(player, "    Base seed: " + baseSeed);
    }
    logDebug(player, "    World version: " + worldVersion);
    TerrainType terrainType = getTerrainType();
    logDebug(player, "    Terrain: " + terrainType.toString());
    logDebug(
        player,
        "        Base block: "
            + new ItemStack(baseBlockForTerrain.getBlock(), 1, baseBlockForTerrain.getMeta())
                .getDisplayName());
    if (featureTypes.contains(FeatureType.FEATURE_TENDRILS)) {
      logDebug(
          player,
          "        Tendril block: "
              + new ItemStack(tendrilBlock.getBlock(), 1, tendrilBlock.getMeta()).getDisplayName());
    }
    if (featureTypes.contains(FeatureType.FEATURE_PYRAMIDS)) {
      for (BlockMeta block : pyramidBlocks) {
        if (block != null) {
          logDebug(
              player,
              "        Pyramid blocks: "
                  + new ItemStack(block.getBlock(), 1, block.getMeta()).getDisplayName());
        }
      }
    }
    if (featureTypes.contains(FeatureType.FEATURE_ORBS)) {
      for (BlockMeta block : sphereBlocks) {
        if (block != null) {
          logDebug(
              player,
              "        Orb blocks: "
                  + new ItemStack(block.getBlock(), 1, block.getMeta()).getDisplayName());
        }
      }
    }
    if (featureTypes.contains(FeatureType.FEATURE_HUGEORBS)) {
      for (BlockMeta block : hugeSphereBlocks) {
        if (block != null) {
          logDebug(
              player,
              "        Huge Orb blocks: "
                  + new ItemStack(block.getBlock(), 1, block.getMeta()).getDisplayName());
        }
      }
    }
    if (featureTypes.contains(FeatureType.FEATURE_LIQUIDORBS)) {
      for (BlockMeta block : liquidSphereBlocks) {
        if (block != null) {
          logDebug(
              player,
              "        Liquid Orb blocks: "
                  + new ItemStack(block.getBlock(), 1, block.getMeta()).getDisplayName());
        }
      }
    }
    if (featureTypes.contains(FeatureType.FEATURE_HUGELIQUIDORBS)) {
      for (BlockMeta block : hugeLiquidSphereBlocks) {
        if (block != null) {
          logDebug(
              player,
              "        Huge Liquid Orb blocks: "
                  + new ItemStack(block.getBlock(), 1, block.getMeta()).getDisplayName());
        }
      }
    }
    if (featureTypes.contains(FeatureType.FEATURE_CANYONS)) {
      logDebug(
          player,
          "        Canyon block: "
              + new ItemStack(canyonBlock.getBlock(), 1, canyonBlock.getMeta()).getDisplayName());
    }
    logDebug(player, "        Base fluid: " + new ItemStack(fluidForTerrain).getDisplayName());
    logDebug(
        player,
        "    Biome controller: " + (controllerType == null ? "<null>" : controllerType.name()));
    for (BiomeGenBase biome : getBiomes()) {
      if (biome != null) {
        logDebug(player, "    Biome: " + biome.biomeName);
      }
    }
    for (FeatureType featureType : getFeatureTypes()) {
      logDebug(player, "    Feature: " + featureType.toString());
    }
    for (BlockMeta block : extraOregen) {
      if (block != null) {
        logDebug(
            player,
            "        Extra ore: "
                + new ItemStack(block.getBlock(), 1, block.getMeta()).getDisplayName());
      }
    }
    for (Block block : fluidsForLakes) {
      logDebug(player, "        Lake fluid: " + new ItemStack(block).getDisplayName());
    }
    if (featureTypes.contains(FeatureType.FEATURE_LIQUIDORBS)) {
      for (Block fluid : liquidSphereFluids) {
        logDebug(player, "        Liquid orb fluids: " + new ItemStack(fluid).getDisplayName());
      }
    }
    if (featureTypes.contains(FeatureType.FEATURE_HUGELIQUIDORBS)) {
      for (Block fluid : hugeLiquidSphereFluids) {
        logDebug(
            player, "        Huge Liquid orb fluids: " + new ItemStack(fluid).getDisplayName());
      }
    }
    for (StructureType structureType : getStructureTypes()) {
      logDebug(player, "    Structure: " + structureType.toString());
    }
    if (structureTypes.contains(StructureType.STRUCTURE_RECURRENTCOMPLEX)) {
      for (String type : dimensionTypes) {
        logDebug(player, "    RR DimensionType: " + type);
      }
    }
    for (EffectType effectType : getEffectTypes()) {
      logDebug(player, "    Effect: " + effectType.toString());
    }
    logDebug(player, "    Sun brightness: " + skyDescriptor.getSunBrightnessFactor());
    logDebug(player, "    Star brightness: " + skyDescriptor.getStarBrightnessFactor());
    float r = skyDescriptor.getSkyColorFactorR();
    float g = skyDescriptor.getSkyColorFactorG();
    float b = skyDescriptor.getSkyColorFactorB();
    logDebug(player, "    Sky color: " + r + ", " + g + ", " + b);
    r = skyDescriptor.getFogColorFactorR();
    g = skyDescriptor.getFogColorFactorG();
    b = skyDescriptor.getFogColorFactorB();
    logDebug(player, "    Fog color: " + r + ", " + g + ", " + b);
    SkyType skyType = skyDescriptor.getSkyType();
    if (skyType != SkyType.SKY_NORMAL) {
      logDebug(player, "    Sky type: " + skyType.toString());
    }
    for (CelestialBodyType bodyType : skyDescriptor.getCelestialBodies()) {
      logDebug(player, "    Sky body: " + bodyType.name());
    }

    if (weatherDescriptor.getRainStrength() > -0.5f) {
      logDebug(player, "    Weather rain: " + weatherDescriptor.getRainStrength());
    }
    if (weatherDescriptor.getThunderStrength() > -0.5f) {
      logDebug(player, "    Weather thunder " + weatherDescriptor.getThunderStrength());
    }

    for (MobDescriptor mob : extraMobs) {
      if (mob != null) {
        if (mob.getEntityClass() == null) {
          logDebug(player, "    Mob: " + mob);
        } else {
          logDebug(player, "    Mob: " + mob.getEntityClass().getName());
        }
      }
    }
    if (peaceful) {
      logDebug(player, "    Peaceful mode");
    }
    if (noanimals) {
      logDebug(player, "    No animals mode");
    }
    if (shelter) {
      logDebug(player, "    Safe shelter");
    }
    if (respawnHere) {
      logDebug(player, "    Respawn local");
    }
    if (celestialAngle != null) {
      logDebug(player, "    Celestial angle: " + celestialAngle);
    }
    if (timeSpeed != null) {
      logDebug(player, "    Time speed: " + timeSpeed);
    }
    if (probeCounter > 0) {
      logDebug(player, "    Probes: " + probeCounter);
    }
    if (patreon1 != 0) {
      logDebug(player, "    Patreon: " + patreon1);
    }
  }
Example #4
0
  public DimensionInformation(String name, DimensionDescriptor descriptor, ByteBuf buf) {
    this.name = name;
    this.descriptor = descriptor;

    terrainType = NetworkTools.readEnum(buf, TerrainType.values());
    NetworkTools.readEnumCollection(buf, featureTypes, FeatureType.values());
    NetworkTools.readEnumCollection(buf, structureTypes, StructureType.values());
    NetworkTools.readEnumCollection(buf, effectTypes, EffectType.values());

    biomes.clear();
    int size = buf.readInt();
    for (int i = 0; i < size; i++) {
      BiomeGenBase biome = BiomeGenBase.getBiome(buf.readInt());
      if (biome != null) {
        biomes.add(biome);
      } else {
        biomes.add(BiomeGenBase.plains);
      }
    }
    controllerType = NetworkTools.readEnum(buf, ControllerType.values());
    digitString = NetworkTools.readString(buf);

    forcedDimensionSeed = buf.readLong();
    baseSeed = buf.readLong();
    worldVersion = buf.readInt();

    Block block = (Block) Block.blockRegistry.getObjectById(buf.readInt());
    int meta = buf.readInt();
    baseBlockForTerrain = new BlockMeta(block, meta);
    block = (Block) Block.blockRegistry.getObjectById(buf.readInt());
    meta = buf.readInt();
    tendrilBlock = new BlockMeta(block, meta);

    pyramidBlocks = readBlockArrayFromBuf(buf);
    sphereBlocks = readBlockArrayFromBuf(buf);
    hugeSphereBlocks = readBlockArrayFromBuf(buf);
    liquidSphereBlocks = readBlockArrayFromBuf(buf);
    liquidSphereFluids = readFluidArrayFromBuf(buf);
    hugeLiquidSphereBlocks = readBlockArrayFromBuf(buf);
    hugeLiquidSphereFluids = readFluidArrayFromBuf(buf);

    block = (Block) Block.blockRegistry.getObjectById(buf.readInt());
    meta = buf.readInt();
    canyonBlock = new BlockMeta(block, meta);
    fluidForTerrain = (Block) Block.blockRegistry.getObjectById(buf.readInt());

    extraOregen = readBlockArrayFromBuf(buf);

    fluidsForLakes = readFluidArrayFromBuf(buf);

    peaceful = buf.readBoolean();
    noanimals = buf.readBoolean();
    shelter = buf.readBoolean();
    respawnHere = buf.readBoolean();

    celestialAngle = NetworkTools.readFloat(buf);
    timeSpeed = NetworkTools.readFloat(buf);

    probeCounter = buf.readInt();
    actualRfCost = buf.readInt();

    skyDescriptor = new SkyDescriptor.Builder().fromBytes(buf).build();
    calculateCelestialBodyDescriptors();

    weatherDescriptor = new WeatherDescriptor.Builder().fromBytes(buf).build();

    patreon1 = buf.readLong();

    extraMobs.clear();
    size = buf.readInt();
    for (int i = 0; i < size; i++) {
      String className = NetworkTools.readString(buf);
      try {
        Class<? extends EntityLiving> c = (Class<? extends EntityLiving>) Class.forName(className);
        int chance = buf.readInt();
        int minGroup = buf.readInt();
        int maxGroup = buf.readInt();
        int maxLoaded = buf.readInt();
        MobDescriptor mob = new MobDescriptor(null, c, chance, minGroup, maxGroup, maxLoaded);
        extraMobs.add(mob);
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
      }
    }

    size = buf.readInt();
    dimensionTypes = new String[size];
    for (int i = 0; i < size; i++) {
      dimensionTypes[i] = NetworkTools.readString(buf);
    }

    setupBiomeMapping();
  }
Example #5
0
  private void setupFromNBT(NBTTagCompound tagCompound) {
    terrainType = TerrainType.values()[tagCompound.getInteger("terrain")];
    featureTypes = toEnumSet(getIntArraySafe(tagCompound, "features"), FeatureType.values());
    structureTypes = toEnumSet(getIntArraySafe(tagCompound, "structures"), StructureType.values());
    effectTypes = toEnumSet(getIntArraySafe(tagCompound, "effects"), EffectType.values());

    biomes.clear();
    for (int a : getIntArraySafe(tagCompound, "biomes")) {
      BiomeGenBase biome = BiomeGenBase.getBiome(a);
      if (biome != null) {
        biomes.add(biome);
      } else {
        // Protect against deleted biomes (i.e. a mod with biomes gets removed and this dimension
        // still uses it).
        // We will pick a replacement biome here.
        biomes.add(BiomeGenBase.plains);
      }
    }
    if (tagCompound.hasKey("controller")) {
      controllerType = ControllerType.values()[tagCompound.getInteger("controller")];
    } else {
      // Support for old type.
      if (biomes.isEmpty()) {
        controllerType = ControllerType.CONTROLLER_DEFAULT;
      } else {
        controllerType = ControllerType.CONTROLLER_SINGLE;
      }
    }

    digitString = tagCompound.getString("digits");

    forcedDimensionSeed = tagCompound.getLong("forcedSeed");
    baseSeed = tagCompound.getLong("baseSeed");
    worldVersion = tagCompound.getInteger("worldVersion");

    baseBlockForTerrain = getBlockMeta(tagCompound, "baseBlock");
    tendrilBlock = getBlockMeta(tagCompound, "tendrilBlock");
    canyonBlock = getBlockMeta(tagCompound, "canyonBlock");
    fluidForTerrain =
        (Block) Block.blockRegistry.getObjectById(tagCompound.getInteger("fluidBlock"));

    hugeLiquidSphereFluids = readFluidsFromNBT(tagCompound, "hugeLiquidSphereFluids");
    hugeLiquidSphereBlocks = readBlockArrayFromNBT(tagCompound, "hugeLiquidSphereBlocks");

    // Support for the old format with only one liquid block.
    Block oldLiquidSphereFluid =
        (Block) Block.blockRegistry.getObjectById(tagCompound.getInteger("liquidSphereFluid"));
    liquidSphereFluids = readFluidsFromNBT(tagCompound, "liquidSphereFluids");
    if (liquidSphereFluids.length == 0) {
      liquidSphereFluids = new Block[] {oldLiquidSphereFluid};
    }

    // Support for the old format with only one sphere block.
    BlockMeta oldLiquidSphereBlock = getBlockMeta(tagCompound, "liquidSphereBlock");
    liquidSphereBlocks = readBlockArrayFromNBT(tagCompound, "liquidSphereBlocks");
    if (liquidSphereBlocks.length == 0) {
      liquidSphereBlocks = new BlockMeta[] {oldLiquidSphereBlock};
    }

    pyramidBlocks = readBlockArrayFromNBT(tagCompound, "pyramidBlocks");
    if (pyramidBlocks.length == 0) {
      pyramidBlocks = new BlockMeta[] {BlockMeta.STONE};
    }

    // Support for the old format with only one sphere block.
    BlockMeta oldSphereBlock = getBlockMeta(tagCompound, "sphereBlock");
    sphereBlocks = readBlockArrayFromNBT(tagCompound, "sphereBlocks");
    if (sphereBlocks.length == 0) {
      sphereBlocks = new BlockMeta[] {oldSphereBlock};
    }

    hugeSphereBlocks = readBlockArrayFromNBT(tagCompound, "hugeSphereBlocks");

    extraOregen = readBlockArrayFromNBT(tagCompound, "extraOregen");
    fluidsForLakes = readFluidsFromNBT(tagCompound, "lakeFluids");

    peaceful = tagCompound.getBoolean("peaceful");
    noanimals = tagCompound.getBoolean("noanimals");
    shelter = tagCompound.getBoolean("shelter");
    respawnHere = tagCompound.getBoolean("respawnHere");
    if (tagCompound.hasKey("celestialAngle")) {
      celestialAngle = tagCompound.getFloat("celestialAngle");
    } else {
      celestialAngle = null;
    }
    if (tagCompound.hasKey("timeSpeed")) {
      timeSpeed = tagCompound.getFloat("timeSpeed");
    } else {
      timeSpeed = null;
    }
    probeCounter = tagCompound.getInteger("probes");
    actualRfCost = tagCompound.getInteger("actualCost");

    skyDescriptor = new SkyDescriptor.Builder().fromNBT(tagCompound).build();
    calculateCelestialBodyDescriptors();

    patreon1 = tagCompound.getLong("patreon1");

    weatherDescriptor = new WeatherDescriptor.Builder().fromNBT(tagCompound).build();

    extraMobs.clear();
    NBTTagList list = tagCompound.getTagList("mobs", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < list.tagCount(); i++) {
      NBTTagCompound tc = list.getCompoundTagAt(i);
      String className = tc.getString("class");
      int chance = tc.getInteger("chance");
      int minGroup = tc.getInteger("minGroup");
      int maxGroup = tc.getInteger("maxGroup");
      int maxLoaded = tc.getInteger("maxLoaded");
      Class<? extends EntityLiving> c = null;
      try {
        c = (Class<? extends EntityLiving>) Class.forName(className);
      } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
      }
      MobDescriptor mob = new MobDescriptor(null, c, chance, minGroup, maxGroup, maxLoaded);
      extraMobs.add(mob);
    }

    String ds = tagCompound.getString("dimensionTypes");
    dimensionTypes = StringUtils.split(ds, ",");
    if (dimensionTypes == null) {
      dimensionTypes = new String[0];
    }
  }