Search in sources :

Example 1 with TexturedFace

use of buildcraft.lib.client.model.ModelUtil.TexturedFace in project BuildCraft by BuildCraft.

the class JsonVariableFaceUV method evaluate.

public VariableFaceData evaluate(ITextureGetter spriteLookup) {
    VariableFaceData data = new VariableFaceData();
    TexturedFace face = spriteLookup.get(texture.evaluate());
    data.sprite = face.sprite;
    data.rotations = (int) textureRotation.evaluate();
    data.uvs.minU = (float) (uv[0].evaluate() / 16.0);
    data.uvs.minV = (float) (uv[1].evaluate() / 16.0);
    data.uvs.maxU = (float) (uv[2].evaluate() / 16.0);
    data.uvs.maxV = (float) (uv[3].evaluate() / 16.0);
    data.uvs = data.uvs.inParent(face.faceData);
    data.invertNormal = invert.evaluate();
    data.bothSides = bothSides.evaluate();
    return data;
}
Also used : VariableFaceData(buildcraft.lib.client.model.json.VariablePartCuboidBase.VariableFaceData) TexturedFace(buildcraft.lib.client.model.ModelUtil.TexturedFace)

Example 2 with TexturedFace

use of buildcraft.lib.client.model.ModelUtil.TexturedFace 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)

Example 3 with TexturedFace

use of buildcraft.lib.client.model.ModelUtil.TexturedFace in project BuildCraft by BuildCraft.

the class JsonVariableModel 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 = textures.get(texture.location);
        if (tex == null)
            break;
        else
            texture = texture.inParent(tex);
        attempts++;
    }
    lookup = texture.location;
    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)

Aggregations

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