summaryrefslogtreecommitdiff
path: root/ihl/model/RenderInfo.java
blob: 4e85f6fbea7db01c57351344c417f671a93cd156 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package ihl.model;

import java.util.Arrays;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;

@SideOnly(value=Side.CLIENT)
public class RenderInfo {

    public Block template = Blocks.stone;
    public IIcon[] texture = null;
    public IIcon override = null;
    public float minX = 0;
    public float minY = 0;
    public float minZ = 0;
    public float maxX = 1;
    public float maxY = 1;
    public float maxZ = 1;
    public boolean[] renderSide = new boolean[6];
    public float light = -1f;
    public int brightness = -1;

    public RenderInfo() {
        setRenderAllSides();
    }

    public RenderInfo(Block template, IIcon[] texture) {
        this();
        this.template = template;
        this.texture = texture;
    }

    public RenderInfo(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
        this();
        setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
    }

    public final void setBlockBounds(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
        this.minX = minX;
        this.minY = minY;
        this.minZ = minZ;
        this.maxX = maxX;
        this.maxY = maxY;
        this.maxZ = maxZ;
    }

    public final void setRenderSingleSide(int side) {
        Arrays.fill(renderSide, false);
        renderSide[side] = true;
    }

    public final void setRenderAllSides() {
        Arrays.fill(renderSide, true);
    }
    
    public IIcon getBlockTextureFromSide(int i) {
        if (override != null)
            return override;
        if (texture == null || texture.length == 0)
            return template.getBlockTextureFromSide(i);
        else {
            if (i >= texture.length)
                i = 0;
            return texture[i];
        }
    }
}