Search in sources :

Example 1 with Geolosys

use of com.oitsjustjose.geolosys.Geolosys in project Geolosys by oitsjustjose.

the class ItemFieldManual method translatePageText.

@SideOnly(Side.CLIENT)
public String translatePageText(int pageNumber) {
    String langFile = Minecraft.getMinecraft().gameSettings.language;
    langFile = langFile.substring(0, langFile.indexOf("_")) + langFile.substring(langFile.indexOf("_")).toUpperCase();
    InputStream in = Geolosys.class.getResourceAsStream("/assets/geolosys/book/" + langFile + ".lang");
    if (in == null) {
        langFile = "en_US";
        in = Geolosys.class.getResourceAsStream("/assets/geolosys/book/" + langFile + ".lang");
    }
    try {
        for (String s : IOUtils.readLines(in, "utf-8")) {
            if (s.indexOf("=") == -1) {
                continue;
            }
            if (s.substring(0, s.indexOf("=")).equals("page_" + pageNumber + "_text")) {
                return s.substring(s.indexOf("=") + 1);
            }
        }
    } catch (IOException e) {
    }
    return "ERROR READING PAGE " + pageNumber;
}
Also used : Geolosys(com.oitsjustjose.geolosys.Geolosys) InputStream(java.io.InputStream) NBTTagString(net.minecraft.nbt.NBTTagString) IOException(java.io.IOException) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with Geolosys

use of com.oitsjustjose.geolosys.Geolosys in project Geolosys by oitsjustjose.

the class ItemFieldManual method getNumEntries.

@SideOnly(Side.CLIENT)
public int getNumEntries() {
    String langFile = Minecraft.getMinecraft().gameSettings.language;
    langFile = langFile.substring(0, langFile.indexOf("_")) + langFile.substring(langFile.indexOf("_")).toUpperCase();
    InputStream in = Geolosys.class.getResourceAsStream("/assets/geolosys/book/" + langFile + ".lang");
    int numLines = 0;
    if (in == null) {
        langFile = "en_US";
        in = Geolosys.class.getResourceAsStream("/assets/geolosys/lang/" + langFile + ".lang");
    }
    try {
        for (String s : IOUtils.readLines(in, "utf-8")) {
            if (s.indexOf("=") == -1) {
                continue;
            }
            if (s.contains("_title")) {
                numLines++;
            }
        }
    } catch (IOException e) {
    }
    return numLines;
}
Also used : Geolosys(com.oitsjustjose.geolosys.Geolosys) InputStream(java.io.InputStream) NBTTagString(net.minecraft.nbt.NBTTagString) IOException(java.io.IOException) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with Geolosys

use of com.oitsjustjose.geolosys.Geolosys in project Geolosys by oitsjustjose.

the class ItemFieldManual method translateTitle.

@SideOnly(Side.CLIENT)
public String translateTitle(int pageNumber) {
    String langFile = Minecraft.getMinecraft().gameSettings.language;
    langFile = langFile.substring(0, langFile.indexOf("_")) + langFile.substring(langFile.indexOf("_")).toUpperCase();
    InputStream in = Geolosys.class.getResourceAsStream("/assets/geolosys/book/" + langFile + ".lang");
    if (in == null) {
        langFile = "en_US";
        in = Geolosys.class.getResourceAsStream("/assets/geolosys/book/" + langFile + ".lang");
    }
    try {
        for (String s : IOUtils.readLines(in, "utf-8")) {
            if (s.indexOf("=") == -1) {
                continue;
            }
            if (s.substring(0, s.indexOf("=")).equals("page_" + pageNumber + "_title")) {
                return s.substring(s.indexOf("=") + 1);
            }
        }
    } catch (IOException e) {
    }
    return "ERROR READING PAGE " + pageNumber;
}
Also used : Geolosys(com.oitsjustjose.geolosys.Geolosys) InputStream(java.io.InputStream) NBTTagString(net.minecraft.nbt.NBTTagString) IOException(java.io.IOException) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with Geolosys

use of com.oitsjustjose.geolosys.Geolosys in project Geolosys by oitsjustjose.

the class HelperFunctions method getTranslation.

@SideOnly(Side.CLIENT)
public static String getTranslation(String toTranslate) {
    String langFile = Minecraft.getMinecraft().gameSettings.language;
    langFile = langFile.substring(0, langFile.indexOf("_")) + langFile.substring(langFile.indexOf("_")).toUpperCase();
    InputStream in = Geolosys.class.getResourceAsStream("/assets/geolosys/lang/" + langFile + ".lang");
    if (in == null) {
        langFile = "en_US";
        in = Geolosys.class.getResourceAsStream("/assets/geolosys/lang/" + langFile + ".lang");
    }
    try {
        for (String s : IOUtils.readLines(in, "utf-8")) {
            if (s.indexOf("=") == -1) {
                continue;
            }
            if (s.contains(toTranslate)) {
                return s.substring(s.indexOf("=") + 1);
            }
        }
    } catch (IOException e) {
    }
    return toTranslate;
}
Also used : Geolosys(com.oitsjustjose.geolosys.Geolosys) InputStream(java.io.InputStream) IOException(java.io.IOException) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

Geolosys (com.oitsjustjose.geolosys.Geolosys)4 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 NBTTagString (net.minecraft.nbt.NBTTagString)3