public void beforeReadEntityFromNBT(NBTTagCompound tags) { if (player.worldObj.isRemote) return; NBTTagCompound customData = new NBTTagCompound(); try { // Load the data File file = new File(FlansModHandler.getSaveDirectory(player.worldObj), "Flan.dat"); customData = CompressedStreamTools.readCompressed(new FileInputStream(file)); // Fill the unlocks list NBTTagList unlocks = customData.getTagList("Unlocks"); for (int i = 0; i < unlocks.tagCount(); ++i) { NBTTagString string = (NBTTagString) unlocks.tagAt(i); FlansMod.blueprintsUnlocked = new ArrayList<PlaneType>(); FlansMod.blueprintsUnlocked.add(PlaneType.getPlane(string.toString())); } NBTTagList vehicleUnlocks = customData.getTagList("VehicleUnlocks"); for (int i = 0; i < vehicleUnlocks.tagCount(); ++i) { NBTTagString string = (NBTTagString) vehicleUnlocks.tagAt(i); FlansMod.vehicleBlueprintsUnlocked = new ArrayList<VehicleType>(); FlansMod.vehicleBlueprintsUnlocked.add(VehicleType.getVehicle(string.toString())); } FlansMod.doneTutorial = customData.getBoolean("DoneTutorial"); } catch (IOException ioexception) { System.out.println("Failed to read data for Flan's mod. Using defaults."); } }
public NBTTagCompound loadAnim(String name) { File file = new File(animDirectory, name + ".dat"); try { return (NBTTagCompound) CompressedStreamTools.readCompressed(new FileInputStream(file)).getTag("main"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
public static void load() { if (DATAFILE.exists()) { try { mainData = CompressedStreamTools.readCompressed(new FileInputStream(DATAFILE)); } catch (FileNotFoundException e) { OutputHandler.SOP("Failed in reading file: " + DATAFILE.getName()); e.printStackTrace(); } catch (IOException e) { OutputHandler.SOP("Failed in reading file: " + DATAFILE.getName()); e.printStackTrace(); } } else { mainData = new NBTTagCompound(); save(); } }
public AnimFactory loadAnim(File file) { try { NBTTagCompound list = (NBTTagCompound) CompressedStreamTools.readCompressed(new FileInputStream(file)).getTag("main"); if (list != null) { AnimFactory anim = new AnimFactory(list); anims.put(anim.getId(), anim); } else return null; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }