Corosus

Untitled

Jan 9th, 2014
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.45 KB | None | 0 0
  1. @Override
  2.     public void writeToNBT(NBTTagCompound var1)
  3.     {
  4.         super.writeToNBT(var1);
  5.         CoroUtilNBT.writeCoords("posPointStart", posPointStart, var1);
  6.         CoroUtilNBT.writeCoords("posPointEnd", posPointEnd, var1);
  7.         var1.setInteger("thickness", thickness);
  8.         var1.setInteger("height", height);
  9.        
  10.         NBTTagCompound data = new NBTTagCompound();
  11.         for (int i = 0; i < listConnectedIDs.size(); i++) {
  12.             data.setInteger("data_" + i, listConnectedIDs.get(i));
  13.         }
  14.         var1.setCompoundTag("listConnectedIDs", data);
  15.         data = new NBTTagCompound();
  16.         for (int i = 0; i < listConnectedLinePoints.size(); i++) {
  17.             data.setFloat("data_" + i, listConnectedLinePoints.get(i));
  18.         }
  19.         var1.setCompoundTag("listConnectedLinePoints", data);
  20.        
  21.         NBTTagCompound dataHeightMap = new NBTTagCompound();
  22.        
  23.         int writeCount = 0;
  24.         Iterator it = heightMap.entrySet().iterator();
  25.         while (it.hasNext()) {
  26.             writeCount++;
  27.             Map.Entry pairs = (Map.Entry)it.next();
  28.             long key = (Long)pairs.getKey();
  29.             int height = (Integer)pairs.getValue();
  30.             dataHeightMap.setInteger(""+key, height);
  31.         }
  32.         //System.out.println("writeCount: " + writeCount);
  33.         var1.setCompoundTag("dataHeightMap", dataHeightMap);
  34.     }
  35.    
  36.     @Override
  37.     public void readFromNBT(NBTTagCompound var1)
  38.     {
  39.         super.readFromNBT(var1);
  40.         posPointStart = CoroUtilNBT.readCoords("posPointStart", var1);
  41.         posPointEnd = CoroUtilNBT.readCoords("posPointEnd", var1);
  42.         thickness = var1.getInteger("thickness");
  43.         height = var1.getInteger("height");
  44.        
  45.         Collection dataListCl = var1.getCompoundTag("listConnectedIDs").getTags();
  46.         Iterator it = dataListCl.iterator();
  47.         while (it.hasNext()) {
  48.             NBTTagInt data = (NBTTagInt)it.next();
  49.             listConnectedIDs.add(data.data);
  50.         }
  51.        
  52.         dataListCl = var1.getCompoundTag("listConnectedLinePoints").getTags();
  53.         it = dataListCl.iterator();
  54.         while (it.hasNext()) {
  55.             NBTTagFloat data = (NBTTagFloat)it.next();
  56.             listConnectedLinePoints.add(data.data);
  57.         }
  58.        
  59.         int readCount = 0;
  60.         it = var1.getCompoundTag("dataHeightMap").getTags().iterator();
  61.         while (it.hasNext()) {
  62.             readCount++;
  63.             NBTTagInt data = (NBTTagInt)it.next();
  64.             heightMap.put(Long.valueOf(data.getName()), data.data);
  65.         }
  66.         //System.out.println("readCount: " + readCount);
  67.         updateCache = true; //mark to update, cant update till all town objects are registered
  68.     }
Advertisement
Add Comment
Please, Sign In to add comment