Exemplo n.º 1
1
  /**
   * Reads the payload of a tag, given the name and type.
   *
   * @param type The type.
   * @param name The name.
   * @param depth The depth.
   * @return The tag.
   * @throws IOException if an I/O error occurs.
   */
  private Tag readTagPayload(int type, String name, int depth) throws IOException {
    switch (type) {
      case NBTConstants.TYPE_END:
        if (depth == 0) {
          throw new IOException("TAG_End found without a TAG_Compound/TAG_List tag preceding it.");
        } else {
          return new EndTag();
        }
      case NBTConstants.TYPE_BYTE:
        return new ByteTag(name, is.readByte());
      case NBTConstants.TYPE_SHORT:
        return new ShortTag(name, is.readShort());
      case NBTConstants.TYPE_INT:
        return new IntTag(name, is.readInt());
      case NBTConstants.TYPE_LONG:
        return new LongTag(name, is.readLong());
      case NBTConstants.TYPE_FLOAT:
        return new FloatTag(name, is.readFloat());
      case NBTConstants.TYPE_DOUBLE:
        return new DoubleTag(name, is.readDouble());
      case NBTConstants.TYPE_BYTE_ARRAY:
        int length = is.readInt();
        byte[] bytes = new byte[length];
        is.readFully(bytes);
        return new ByteArrayTag(name, bytes);
      case NBTConstants.TYPE_STRING:
        length = is.readShort();
        bytes = new byte[length];
        is.readFully(bytes);
        return new StringTag(name, new String(bytes, NBTConstants.CHARSET));
      case NBTConstants.TYPE_LIST:
        int childType = is.readByte();
        length = is.readInt();

        List<Tag> tagList = new ArrayList<Tag>();
        for (int i = 0; i < length; i++) {
          Tag tag = readTagPayload(childType, "", depth + 1);
          if (tag instanceof EndTag) {
            throw new IOException("TAG_End not permitted in a list.");
          }
          tagList.add(tag);
        }

        return new ListTag(name, NBTUtils.getTypeClass(childType), tagList);
      case NBTConstants.TYPE_COMPOUND:
        Map<String, Tag> tagMap = new HashMap<String, Tag>();
        while (true) {
          Tag tag = readTag(depth + 1);
          if (tag instanceof EndTag) {
            break;
          } else {
            tagMap.put(tag.getName(), tag);
          }
        }

        return new CompoundTag(name, tagMap);
      default:
        throw new IOException("Invalid tag type: " + type + ".");
    }
  }
Exemplo n.º 2
0
  protected void read(DataInputStream s) {
    try {
      ref = new WeakReference<DataBuffer>(this, Nd4j.bufferRefQueue());
      referencing = Collections.synchronizedSet(new HashSet<String>());
      dirty = new AtomicBoolean(false);
      allocationMode = AllocationMode.valueOf(s.readUTF());
      length = s.readInt();
      Type t = Type.valueOf(s.readUTF());
      if (t == Type.DOUBLE) {
        if (allocationMode == AllocationMode.HEAP) {
          if (this.dataType() == Type.FLOAT) { // DataBuffer type
            // double -> float
            floatData = new float[length()];
          } else if (this.dataType() == Type.DOUBLE) {
            // double -> double
            doubleData = new double[length()];
          } else {
            // double -> int
            intData = new int[length()];
          }
          for (int i = 0; i < length(); i++) {
            put(i, s.readDouble());
          }
        } else {
          wrappedBuffer = ByteBuffer.allocateDirect(length() * getElementSize());
          wrappedBuffer.order(ByteOrder.nativeOrder());
          for (int i = 0; i < length(); i++) {
            put(i, s.readDouble());
          }
        }
      } else {
        if (allocationMode == AllocationMode.HEAP) {
          if (this.dataType() == Type.FLOAT) { // DataBuffer type
            // float -> float
            floatData = new float[length()];
          } else if (this.dataType() == Type.DOUBLE) {
            // float -> double
            doubleData = new double[length()];
          } else {
            // float-> int
            intData = new int[length()];
          }
          for (int i = 0; i < length(); i++) {
            put(i, s.readFloat());
          }
        } else {
          wrappedBuffer = ByteBuffer.allocateDirect(length() * getElementSize());
          wrappedBuffer.order(ByteOrder.nativeOrder());
          for (int i = 0; i < length(); i++) {
            put(i, s.readFloat());
          }
        }
      }

    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
Exemplo n.º 3
0
 /**
  * Load a chunk texture from an input stream
  *
  * @param in
  * @return The loaded texture
  * @throws IOException
  */
 public static ChunkTexture load(DataInputStream in) throws IOException {
   ChunkTexture texture = new ChunkTexture();
   for (int i = 0; i < Chunk.X_MAX * Chunk.Z_MAX; ++i) {
     texture.data[i][0] = in.readFloat();
     texture.data[i][1] = in.readFloat();
     texture.data[i][2] = in.readFloat();
   }
   return texture;
 }
Exemplo n.º 4
0
 public void unmarshal(DataInputStream dis) {
   try {
     x = dis.readFloat();
     y = dis.readFloat();
     z = dis.readFloat();
   } // end try
   catch (Exception e) {
     System.out.println(e);
   }
 } // end of unmarshal method
Exemplo n.º 5
0
 /**
  * Load a map from a DataInputStream
  *
  * @param dis the stream
  * @throws IOException
  */
 public void loadMap(DataInputStream dis) throws IOException {
   lines = new Line[dis.readInt()];
   for (int i = 0; i < lines.length; i++) {
     float x1 = dis.readFloat();
     float y1 = dis.readFloat();
     float x2 = dis.readFloat();
     float y2 = dis.readFloat();
     lines[i] = new Line(x1, y1, x2, y2);
   }
   boundingRect = new Rectangle(dis.readInt(), dis.readInt(), dis.readInt(), dis.readInt());
 }
 public void func_73267_a(DataInputStream p_73267_1_) throws IOException {
   this.field_98209_a = func_73282_a(p_73267_1_, 64);
   this.field_98207_b = p_73267_1_.readFloat();
   this.field_98208_c = p_73267_1_.readFloat();
   this.field_98205_d = p_73267_1_.readFloat();
   this.field_98206_e = p_73267_1_.readFloat();
   this.field_98203_f = p_73267_1_.readFloat();
   this.field_98204_g = p_73267_1_.readFloat();
   this.field_98210_h = p_73267_1_.readFloat();
   this.field_98211_i = p_73267_1_.readInt();
 }
Exemplo n.º 7
0
 public static ScoreMenu[] loadFile() {
   MainWindow.initDataFile(SCORE_MENU_FILE);
   DataInputStream input;
   Course course;
   Class tempClass;
   Student student;
   int[] testTime;
   long[] id;
   float[] score;
   ScoreMenu[] scoreMenu = new ScoreMenu[20];
   int count = 0;
   try {
     input = new DataInputStream(new FileInputStream(SCORE_MENU_FILE));
     while (input.available() > 0) {
       if (count >= scoreMenu.length) {
         ScoreMenu[] temp = new ScoreMenu[scoreMenu.length * 2];
         for (int i = 0; i < scoreMenu.length; i++) temp[i] = scoreMenu[i];
         scoreMenu = temp;
       }
       tempClass = new Class();
       tempClass.setGrade(input.readInt());
       tempClass.setMajor(input.readUTF());
       tempClass.setClassNumber(input.readInt());
       tempClass.setStudentNumber(0);
       int num = input.readInt();
       for (int i = 0; i < num; i++) {
         student = new Student();
         student.setId(input.readLong());
         student.setName(input.readUTF());
         tempClass.addStudent(student);
       }
       course = new Course();
       course.setId(input.readUTF());
       course.setName(input.readUTF());
       course.setCredit(input.readFloat());
       course.setPeriod(input.readInt());
       testTime = new int[5];
       for (int i = 0; i < 5; i++) testTime[i] = input.readInt();
       num = input.readInt();
       id = new long[num];
       score = new float[num];
       for (int i = 0; i < num; i++) id[i] = input.readLong();
       for (int i = 0; i < num; i++) score[i] = input.readFloat();
       scoreMenu[count] = new ScoreMenu(tempClass, course, testTime, num, id, score);
       count++;
     }
     input.close();
     return scoreMenu;
   } catch (Exception e) {
     return null;
   }
 }
Exemplo n.º 8
0
  @Override
  public void readData(DataInputStream dataStream) throws IOException {
    x = dataStream.readInt();
    y = dataStream.readInt();
    z = dataStream.readInt();

    xMin = dataStream.readFloat();
    yMin = dataStream.readFloat();
    zMin = dataStream.readFloat();
    xMax = dataStream.readFloat();
    yMax = dataStream.readFloat();
    zMax = dataStream.readFloat();
  }
Exemplo n.º 9
0
  /**
   * Converts file format from gv Mary format 4 to Mary 5, the converted file will have the same
   * input name
   *
   * @param gvInFile gvInFile
   * @throws IOException IOException
   */
  public void convertGvBinaryFile(File gvInFile) throws IOException {
    int i;
    String gvInFileString = gvInFile.getName();
    // the destination file name will be the same as the input file so
    String gvOutFile = gvInFile.getAbsolutePath();
    String path = gvInFile.getParent();
    // I make a copy or the original file
    FileUtils.copy(gvInFile.getAbsolutePath(), path + "/tmp");
    gvInFile = new File(path + "/tmp");

    DataInputStream dataIn;
    DataOutputStream dataOut;
    dataIn = new DataInputStream(new BufferedInputStream(new FileInputStream(gvInFile)));

    // int numMix = data_in.readShort(); /* --NOT USED -- first short is the number of mixtures in
    // Gaussian model */
    int order = dataIn.readShort(); /* second short is the order of static vector */
    float gvmean[] = new float[order]; /* allocate memory of this size */
    float gvcov[] = new float[order];
    logger.debug("Reading from file " + gvInFileString + " order=" + order);

    for (i = 0; i < order; i++) {
      gvmean[i] = dataIn.readFloat();
      // System.out.format("gvmean[%d]=%f\n",i,gvmean[i]);
    }
    for (i = 0; i < order; i++) {
      gvcov[i] = dataIn.readFloat();
      // System.out.format("gvcov[%d]=%f\n",i,gvcov[i]);
    }
    dataIn.close();

    dataOut = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(gvOutFile)));
    /* This is the format in version 2.0 */
    // numMSDFlag
    dataOut.writeInt(0);
    // numStream
    dataOut.writeInt(1);
    // vectorSize
    dataOut.writeInt(order);
    // numDurPdf
    dataOut.writeInt(1);

    for (i = 0; i < order; i++) {
      dataOut.writeFloat(gvmean[i]);
      dataOut.writeFloat(gvcov[i]);
    }

    dataOut.close();
    gvInFile.delete();
    logger.debug("Updated format in file " + gvOutFile);
  }
Exemplo n.º 10
0
  public void load(DataInputStream dis) throws IOException {
    dis.readInt(); // name length
    this.name = dis.readUTF();

    dis.readInt(); // map_kdLength
    this.map_kd = dis.readUTF();

    if (parent.hasTexcoords() && map_kd.length() > 0) {
      parent.loadTexture(map_kd);
    }

    this.ka[0] = dis.readFloat();
    this.ka[1] = dis.readFloat();
    this.ka[2] = dis.readFloat();
    this.ka[3] = dis.readFloat();

    this.kd[0] = dis.readFloat();
    this.kd[1] = dis.readFloat();
    this.kd[2] = dis.readFloat();
    this.kd[3] = dis.readFloat();

    this.ks[0] = dis.readFloat();
    this.ks[1] = dis.readFloat();
    this.ks[2] = dis.readFloat();
    this.ks[3] = dis.readFloat();

    this.ns = dis.readFloat();
    this.illum = dis.readInt();
    this.d = dis.readFloat();
  }
 @Override
 public void publishUnserialize(DataInputStream stream) {
   // TODO Auto-generated method stub
   super.publishUnserialize(stream);
   try {
     log.unitType = stream.readByte();
     pause = stream.readBoolean();
     log.samplingPeriod = stream.readFloat();
     log.maxValue = stream.readFloat();
     log.minValue = stream.readFloat();
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
Exemplo n.º 12
0
  /**
   * Read the DataInputStream, and create an OMPoint. Assumes that the LinkPoint header has been
   * read from the link.
   *
   * @param dis DataInputStream
   * @param propertiesBuffer a LinkProperties object used to cache previous settings that can be set
   *     on the OMPoint being read.
   * @return OMPoint
   * @throws IOException
   * @see com.bbn.openmap.omGraphics.OMPoint
   */
  public static OMPoint read(DataInputStream dis, LinkProperties propertiesBuffer)
      throws IOException {
    OMPoint point = null;
    int x1, y1, radius;
    float lt, ln;

    int renderType = dis.readByte();

    switch (renderType) {
      case RENDERTYPE_LATLON:
        lt = dis.readFloat();
        ln = dis.readFloat();
        radius = dis.readInt();

        point = new OMPoint(lt, ln, radius);
        break;
      case RENDERTYPE_XY:
        x1 = dis.readInt();
        y1 = dis.readInt();
        radius = dis.readInt();

        point = new OMPoint(x1, y1, radius);
        break;
      case RENDERTYPE_OFFSET:
        lt = dis.readFloat();
        ln = dis.readFloat();

        x1 = dis.readInt();
        y1 = dis.readInt();
        radius = dis.readInt();

        point = new OMPoint(lt, ln, x1, y1, radius);
        break;
      default:
    }

    if (point != null) {
      propertiesBuffer = LinkProperties.loadPropertiesIntoOMGraphic(dis, point, propertiesBuffer);

      if (propertiesBuffer != null) {
        point.setOval(
            PropUtils.booleanFromProperties(
                propertiesBuffer, LPC_POINT_OVAL, OMPoint.DEFAULT_ISOVAL));
      }
    }

    return point;
  }
  @Override
  public void networkUnserialize(DataInputStream stream) {

    super.networkUnserialize(stream);

    short read;

    try {

      Byte b;

      hasTracker = stream.readBoolean();

      float pannelAlphaIncoming = stream.readFloat();

      if (pannelAlphaIncoming != pannelAlphaSyncValue) {
        pannelAlphaSyncValue = pannelAlphaIncoming;
        pannelAlphaSyncNew = true;
      }

      eConn.deserialize(stream);

      renderPreProcess = null;

    } catch (IOException e) {

      e.printStackTrace();
    }
  }
Exemplo n.º 14
0
  @Override
  public void load() throws Exception {
    File file = Game.getInstance().getRelativeFile(Game.FILE_BASE_USER_DATA, "${world}/world.dat");

    if (!file.exists()) {
      System.err.println("No level data found! " + file.getPath());
      return;
    }

    DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));

    _world.setTime(dis.readFloat());

    _spawnPoint = new Vec3f();
    IOUtilities.readVec3f(dis, _spawnPoint);

    readDataPointList(dis, _rawHeights);
    readDataPointList(dis, _heights);
    readDataPointList(dis, _humidities);
    readDataPointList(dis, _temperatures);

    /* Tree Definitions */
    {
      int size = dis.readInt();
      for (int i = 0; i < size; ++i) {
        TreeDefinition dp2d = new TreeDefinition(0, 0, 0, 0);
        dp2d.x = dis.readInt();
        dp2d.y = dis.readInt();
        dp2d.z = dis.readInt();
        dp2d.type = dis.readByte();
      }
    }

    dis.close();
  }
  private void readEmptyHashTableData(DataInputStream in) throws IOException {
    float loadFactor = in.readFloat();
    throwIfNotEqual(
        "loadfactor wrong?",
        MartusKeyPairDataConstants.HASHTABLE_LOADFACTOR,
        loadFactor,
        MartusKeyPairDataConstants.HASHTABLE_LOADFACTOR / 100);

    int threshold = in.readInt();
    throwIfNotEqual("threshold wrong?", MartusKeyPairDataConstants.HASHTABLE_THRESHOLD, threshold);

    byte hashTableBlockDataFlag = in.readByte();
    throwIfNotEqual(ObjectStreamConstants.TC_BLOCKDATA, hashTableBlockDataFlag);

    byte blockDataByteCount = in.readByte();
    throwIfNotEqual(
        "wrong block data byte count?",
        MartusKeyPairDataConstants.HASHTABLE_BYTE_COUNT,
        blockDataByteCount);

    // originalLength
    in.readInt();

    int elements = in.readInt();
    throwIfNotEqual(
        "Hashtable not empty?", MartusKeyPairDataConstants.HASHTABLE_NUMBER_OF_ELEMENTS, elements);

    byte hashTableEndDataFlag = in.readByte();
    throwIfNotEqual(ObjectStreamConstants.TC_ENDBLOCKDATA, hashTableEndDataFlag);
  }
 @Override
 protected void onReadTransmissionData(final DataInputStream pDataInputStream)
     throws IOException {
   this.mID = pDataInputStream.readInt();
   this.mX = pDataInputStream.readFloat();
   this.mY = pDataInputStream.readFloat();
 }
 /**
  * Tests if {@link Float#NaN} values can be correctly read from a {@link FloatArrayInputStream}
  *
  * @throws Exception
  */
 @Test
 public void nan() throws Exception {
   FloatArrayInputStream fais = new FloatArrayInputStream(new float[] {Float.NaN});
   DataInputStream dis = new DataInputStream(fais);
   assertTrue(Float.isNaN(dis.readFloat()));
   assertEquals(-1, dis.read());
 }
Exemplo n.º 18
0
  public static void main(String[] args) throws IOException {
    // Create a FileOutputStream.
    FileOutputStream outputFile = new FileOutputStream("primitives.data");

    // Create a DataOutputStream which is chained to the FileOutputStream.
    DataOutputStream outputStream = new DataOutputStream(outputFile);

    // Write Java primitive values in binary representation:
    outputStream.writeBoolean(true);
    outputStream.writeChar('A'); // int written as Unicode char
    outputStream.writeByte(Byte.MAX_VALUE); // int written as 8-bits byte
    outputStream.writeShort(Short.MIN_VALUE); // int written as 16-bits short
    outputStream.writeInt(Integer.MAX_VALUE);
    outputStream.writeLong(Long.MIN_VALUE);
    outputStream.writeFloat(Float.MAX_VALUE);
    outputStream.writeDouble(Math.PI);

    // Close the output stream, which also closes the underlying stream.
    outputStream.flush();
    outputStream.close();

    // Create a FileInputStream.
    FileInputStream inputFile = new FileInputStream("primitives.data");

    // Create a DataInputStream which is chained to the FileInputStream.
    DataInputStream inputStream = new DataInputStream(inputFile);

    // Read the binary representation of Java primitive values
    // in the same order they were written out:
    boolean v = inputStream.readBoolean();
    char c = inputStream.readChar();
    byte b = inputStream.readByte();
    short s = inputStream.readShort();
    int i = inputStream.readInt();
    long l = inputStream.readLong();
    float f = inputStream.readFloat();
    double d = inputStream.readDouble();

    // Check for end of stream:
    try {
      int value = inputStream.readByte();
      System.out.println("More input: " + value);
    } catch (EOFException eofe) {
      System.out.println("End of stream");
    } finally {
      // Close the input stream, which also closes the underlying stream.
      inputStream.close();
    }

    // Write the values read to the standard input stream:
    System.out.println("Values read:");
    System.out.println(v);
    System.out.println(c);
    System.out.println(b);
    System.out.println(s);
    System.out.println(i);
    System.out.println(l);
    System.out.println(f);
    System.out.println(d);
  }
Exemplo n.º 19
0
 public static ScoreMenu queryFromFile(Class classes, Course courses) {
   MainWindow.initDataFile(SCORE_MENU_FILE);
   DataInputStream input;
   Class tempClass = new Class();
   Student student;
   Course course = new Course();
   int[] testTime = new int[5];
   int numberOfAttendTestStudent;
   long idOfStudents[];
   float scoreOfTest[];
   try {
     input = new DataInputStream(new FileInputStream(SCORE_MENU_FILE));
     while (input.available() > 0) {
       tempClass.setGrade(input.readInt());
       tempClass.setMajor(input.readUTF());
       tempClass.setClassNumber(input.readInt());
       int studentNumber = input.readInt();
       tempClass.setStudentNumber(0);
       for (int i = 0; i < studentNumber; i++) {
         student = new Student();
         student.setId(input.readLong());
         student.setName(input.readUTF());
         tempClass.addStudent(student);
       }
       course.setId(input.readUTF());
       course.setName(input.readUTF());
       course.setCredit(input.readFloat());
       course.setPeriod(input.readInt());
       for (int i = 0; i < 5; i++) testTime[i] = input.readInt();
       numberOfAttendTestStudent = input.readInt();
       idOfStudents = new long[numberOfAttendTestStudent];
       scoreOfTest = new float[numberOfAttendTestStudent];
       for (int i = 0; i < numberOfAttendTestStudent; i++) idOfStudents[i] = input.readLong();
       for (int i = 0; i < numberOfAttendTestStudent; i++) scoreOfTest[i] = input.readFloat();
       if ((classes.equals(tempClass)) && (courses.equals(course))) {
         input.close();
         return new ScoreMenu(
             tempClass, course, testTime, numberOfAttendTestStudent, idOfStudents, scoreOfTest);
       }
     }
     input.close();
     return null;
   } catch (Exception e) {
     return null;
   }
 }
Exemplo n.º 20
0
 @Override
 public float readFloat() throws IOException {
   if (bigEndian()) {
     return dataInput.readFloat();
   } else {
     return Float.intBitsToFloat(readInt());
   }
 }
Exemplo n.º 21
0
 @SideOnly(value = Side.CLIENT)
 private void interpretClient(DataInputStream stream, Object[] extradata) {
   try {
     float x = stream.readFloat();
     float y = stream.readFloat();
     float z = stream.readFloat();
     String sound = stream.readUTF();
     boolean distort = stream.readBoolean();
     FMLClientHandler.instance()
         .getClient()
         .sndManager
         .playSound(sound, x, y, z, 10F, distort ? 1.0F / (rand.nextFloat() * 0.4F + 0.8F) : 1.0F);
   } catch (Exception e) {
     FlansMod.log("Error reading or playing sound");
     e.printStackTrace();
   }
 }
Exemplo n.º 22
0
 private float readFloat() {
   try {
     return inStream.readFloat();
   } catch (IOException e) {
     IOError();
   }
   return 0;
 }
Exemplo n.º 23
0
 @Override
 public float getFloat() {
   try {
     return in.readFloat();
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }
Exemplo n.º 24
0
  public static List readWatchableObjects(DataInputStream par0DataInputStream) throws IOException {
    ArrayList arraylist = null;

    for (byte byte0 = par0DataInputStream.readByte();
        byte0 != 127;
        byte0 = par0DataInputStream.readByte()) {
      if (arraylist == null) {
        arraylist = new ArrayList();
      }

      int i = (byte0 & 0xe0) >> 5;
      int j = byte0 & 0x1f;
      WatchableObject watchableobject = null;

      switch (i) {
        case 0:
          watchableobject = new WatchableObject(i, j, Byte.valueOf(par0DataInputStream.readByte()));
          break;

        case 1:
          watchableobject =
              new WatchableObject(i, j, Short.valueOf(par0DataInputStream.readShort()));
          break;

        case 2:
          watchableobject =
              new WatchableObject(i, j, Integer.valueOf(par0DataInputStream.readInt()));
          break;

        case 3:
          watchableobject =
              new WatchableObject(i, j, Float.valueOf(par0DataInputStream.readFloat()));
          break;

        case 4:
          watchableobject = new WatchableObject(i, j, Packet.readString(par0DataInputStream, 64));
          break;

        case 5:
          short word0 = par0DataInputStream.readShort();
          byte byte1 = par0DataInputStream.readByte();
          short word1 = par0DataInputStream.readShort();
          watchableobject = new WatchableObject(i, j, new ItemStack(word0, byte1, word1));
          break;

        case 6:
          int k = par0DataInputStream.readInt();
          int l = par0DataInputStream.readInt();
          int i1 = par0DataInputStream.readInt();
          watchableobject = new WatchableObject(i, j, new ChunkCoordinates(k, l, i1));
          break;
      }

      arraylist.add(watchableobject);
    }

    return arraylist;
  }
Exemplo n.º 25
0
 /**
  * 读取头文件
  *
  * @param dis
  * @return
  * @throws Exception
  */
 public static LPKHeader readHeader(DataInputStream dis) throws Exception {
   LPKHeader header = new LPKHeader();
   header.setPAKIdentity(dis.readInt());
   byte[] pass = readByteArray(dis, LPKHeader.LF_PASSWORD_LENGTH);
   header.setPassword(pass);
   header.setVersion(dis.readFloat());
   header.setTables(dis.readLong());
   return header;
 }
Exemplo n.º 26
0
 protected void readCache(float[] out) {
   try {
     out[0] = cacheStream.readFloat();
     out[1] = cacheStream.readFloat();
   } catch (IOException e) {
     // TODO Auto-generated catch block
     if (Camera5in1.mDebug) System.out.println("cache index:" + cacheindex);
     e.printStackTrace();
   }
 }
Exemplo n.º 27
0
  public static List readWatchableObjects(DataInputStream par0DataInputStream) throws IOException {
    ArrayList var1 = null;

    for (byte var2 = par0DataInputStream.readByte();
        var2 != 127;
        var2 = par0DataInputStream.readByte()) {
      if (var1 == null) {
        var1 = new ArrayList();
      }

      int var3 = (var2 & 224) >> 5;
      int var4 = var2 & 31;
      WatchableObject var5 = null;

      switch (var3) {
        case 0:
          var5 = new WatchableObject(var3, var4, Byte.valueOf(par0DataInputStream.readByte()));
          break;

        case 1:
          var5 = new WatchableObject(var3, var4, Short.valueOf(par0DataInputStream.readShort()));
          break;

        case 2:
          var5 = new WatchableObject(var3, var4, Integer.valueOf(par0DataInputStream.readInt()));
          break;

        case 3:
          var5 = new WatchableObject(var3, var4, Float.valueOf(par0DataInputStream.readFloat()));
          break;

        case 4:
          var5 = new WatchableObject(var3, var4, Packet.readString(par0DataInputStream, 64));
          break;

        case 5:
          short var9 = par0DataInputStream.readShort();
          byte var10 = par0DataInputStream.readByte();
          short var11 = par0DataInputStream.readShort();
          var5 = new WatchableObject(var3, var4, new ItemStack(var9, var10, var11));
          break;

        case 6:
          int var6 = par0DataInputStream.readInt();
          int var7 = par0DataInputStream.readInt();
          int var8 = par0DataInputStream.readInt();
          var5 = new WatchableObject(var3, var4, new ChunkCoordinates(var6, var7, var8));
      }

      var1.add(var5);
    }

    return var1;
  }
Exemplo n.º 28
0
  public static List a(DataInputStream datainputstream) {
    ArrayList arraylist = null;

    for (byte b0 = datainputstream.readByte(); b0 != 127; b0 = datainputstream.readByte()) {
      if (arraylist == null) {
        arraylist = new ArrayList();
      }

      int i = (b0 & 224) >> 5;
      int j = b0 & 31;
      WatchableObject watchableobject = null;

      switch (i) {
        case 0:
          watchableobject = new WatchableObject(i, j, Byte.valueOf(datainputstream.readByte()));
          break;

        case 1:
          watchableobject = new WatchableObject(i, j, Short.valueOf(datainputstream.readShort()));
          break;

        case 2:
          watchableobject = new WatchableObject(i, j, Integer.valueOf(datainputstream.readInt()));
          break;

        case 3:
          watchableobject = new WatchableObject(i, j, Float.valueOf(datainputstream.readFloat()));
          break;

        case 4:
          watchableobject = new WatchableObject(i, j, Packet.a(datainputstream, 64));
          break;

        case 5:
          short short1 = datainputstream.readShort();
          byte b1 = datainputstream.readByte();
          short short2 = datainputstream.readShort();

          watchableobject = new WatchableObject(i, j, new ItemStack(short1, b1, short2));
          break;

        case 6:
          int k = datainputstream.readInt();
          int l = datainputstream.readInt();
          int i1 = datainputstream.readInt();

          watchableobject = new WatchableObject(i, j, new ChunkCoordinates(k, l, i1));
      }

      arraylist.add(watchableobject);
    }

    return arraylist;
  }
Exemplo n.º 29
0
 // FIXME
 public static LinkedList<Float> deserializeManyFloat(byte[] buf) {
   ByteArrayInputStream stream = new ByteArrayInputStream(buf);
   DataInputStream dis = new DataInputStream(stream);
   LinkedList<Float> list = new LinkedList<Float>();
   try {
     while (list.offer(dis.readFloat())) ;
   } catch (IOException e) {
     // TODO Auto-generated catch block
     // e.printStackTrace();
   }
   return list;
 }
Exemplo n.º 30
0
  public void read(DataInputStream in) throws IOException {
    shader = in.readUTF();
    numVertices = in.readInt();
    numWeights = in.readInt();
    numTriangles = in.readInt();
    floatsPerVertex = in.readInt();
    floatsPerWeight = in.readInt();

    vertices = new float[numVertices * floatsPerVertex];
    indices = new short[numTriangles * 3];
    weights = new float[numWeights * floatsPerWeight];
    for (int i = 0; i < vertices.length; i++) {
      vertices[i] = in.readFloat();
    }
    for (int i = 0; i < indices.length; i++) {
      indices[i] = in.readShort();
    }
    for (int i = 0; i < weights.length; i++) {
      weights[i] = in.readFloat();
    }
  }