@Override public void swap(BookRepository source, DataLocation object) { object.location = object.file == "$BLOCK_ATLAS" ? TextureMap.LOCATION_BLOCKS_TEXTURE : source .getResourceLocation(object.file, true); } }.getClass());
@Override public void swap(BookRepository source, ItemStackData object) { object.source = source; object.itemListLocation = source.getResourceLocation(object.itemList); if(object.itemListLocation != null) { object.id = "->itemList"; } } }.getClass());
public abstract ResourceLocation getResourceLocation(String path, boolean safe);
@Override public void load() { if(name == null) { name = "section" + parent.unnamedSectionCounter++; } name = name.toLowerCase(); if(!data.equals("no-load")) { IResource pagesInfo = source.getResource(source.getResourceLocation(data)); if(pagesInfo != null) { String data = source.resourceToString(pagesInfo); if(!data.isEmpty()) { try { pages = new ArrayList<>(Arrays.asList(BookLoader.GSON.fromJson(data, PageData[].class))); } catch(Exception e) { pages = new ArrayList<>(); PageData pdError = new PageData(true); pdError.name = "errorrenous"; pdError.content = new ContentError("Failed to load section " + name + ".", e); pages.add(pdError); } } } } for(PageData page : pages) { page.parent = this; page.source = source; page.load(); } icon.location = source.getResourceLocation(icon.file, true); }
@Override public void load() { BookRepository repo = parent.source; if(data == null || data.isEmpty()) { return; } ResourceLocation location = repo.getResourceLocation(data); if(location != null && repo.resourceExists(location)) { ContentStructure structure = BookLoader.GSON .fromJson(repo.resourceToString(repo.getResource(location)), ContentStructure.class); structure.parent = parent; structure.load(); this.size = structure.size; this.structure = structure.structure; this.text = structure.text; } }
IResource pageInfo = source.getResource(source.getResourceLocation(data)); if(pageInfo != null) { String data = source.resourceToString(pageInfo);
ResourceLocation appearanceLocation = repo.getResourceLocation("appearance.json"); ResourceLocation itemLinkLocation = repo.getResourceLocation("items.json"); ResourceLocation languageLocation = repo.getResourceLocation("language.lang");