@Override public List<SectionData> getSections() { return new ArrayList<>(Arrays.asList(BookLoader.GSON .fromJson(resourceToString(getResource(getResourceLocation("index.json"))), SectionData[].class))); }
public static void init() { BookLoader.registerPageType(ContentMaterial.ID, ContentMaterial.class); BookLoader.registerPageType(ContentModifier.ID, ContentModifier.class); BookLoader.registerPageType(ContentModifierFortify.ID, ContentModifierFortify.class); BookLoader.registerPageType(ContentTool.ID, ContentTool.class); BookLoader.registerPageType(ContentSingleStatMultMaterial.ID, ContentSingleStatMultMaterial.class); BookLoader.registerPageType(ContentImageText2.ID, ContentImageText2.class); INSTANCE.addRepository(new FileRepository(Util.resource("book"))); INSTANCE.addTransformer(new ToolSectionTransformer()); INSTANCE.addTransformer(new MaterialSectionTransformer()); INSTANCE.addTransformer(new ModifierSectionTransformer()); INSTANCE.addTransformer(new BowMaterialSectionTransformer()); INSTANCE.addTransformer(BookTransformer.IndexTranformer()); } }
@Override public boolean resourceExists(ResourceLocation location) { if(location == null) { return false; } try { Minecraft.getMinecraft().getResourceManager().getResource(location); return true; } catch(IOException e) { return false; } }
@Override public ResourceLocation getResourceLocation(String path, boolean safe) { if(path == null) { return safe ? new ResourceLocation("") : null; } if(!path.contains(":")) { String langPath = Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode(); String defaultLangPath = "en_US"; ResourceLocation res = new ResourceLocation(location + "/" + langPath + "/" + path); if(resourceExists(res)) { return res; } res = new ResourceLocation(location + "/" + defaultLangPath + "/" + path); if(resourceExists(res)) { return res; } res = new ResourceLocation(location + "/" + path); if(resourceExists(res)) { return res; } return safe ? new ResourceLocation("") : null; } else { ResourceLocation res = new ResourceLocation(path); if(resourceExists(res)) { return res; } return safe ? new ResourceLocation("") : null; } }
public static void integrate() { INSTANCE.addRepository(new FileRepository(EnderIO.DOMAIN + ":eiobook")); INSTANCE.addTransformer(BookTransformer.IndexTranformer()); }
@Override public IResource getResource(ResourceLocation loc) { if(loc == null) { return null; } try { return Minecraft.getMinecraft().getResourceManager().getResource(loc); } catch(IOException e) { return null; } }
@SideOnly(Side.CLIENT) public static void integrate() { TinkerBook.INSTANCE.addRepository(new FileRepository("enderio:book")); TinkerBook.INSTANCE.addTransformer(new OurBookTransformer()); }