Search in sources :

Example 1 with JsonTexture

use of buildcraft.lib.client.model.json.JsonTexture in project BuildCraft by BuildCraft.

the class ModelHolderVariable method lookupTexture.

private TexturedFace lookupTexture(String lookup) {
    int attempts = 0;
    JsonTexture texture = new JsonTexture(lookup);
    TextureAtlasSprite sprite;
    while (texture.location.startsWith("#") && attempts < 10) {
        JsonTexture tex = rawModel.textures.get(texture.location);
        if (tex == null)
            break;
        else
            texture = texture.inParent(tex);
        attempts++;
    }
    lookup = texture.location;
    if (lookup.startsWith("~")) {
        sprite = customSprites.get(lookup.substring(1));
        if (sprite == null) {
            sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
        }
    } else {
        sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(lookup);
    }
    TexturedFace face = new TexturedFace();
    face.sprite = sprite;
    face.faceData = texture.faceData;
    return face;
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) TexturedFace(buildcraft.lib.client.model.ModelUtil.TexturedFace) JsonTexture(buildcraft.lib.client.model.json.JsonTexture)

Aggregations

TexturedFace (buildcraft.lib.client.model.ModelUtil.TexturedFace)1 JsonTexture (buildcraft.lib.client.model.json.JsonTexture)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1