aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/goodgenerator/blocks/regularBlock/ComplexTextureCasing.java
blob: 0a0169d0b4a84d9d530c3073b1911a8823732a4f (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
package goodgenerator.blocks.regularBlock;

import java.util.List;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ComplexTextureCasing extends Casing {

    @SideOnly(Side.CLIENT)
    protected IIcon[] texture1, texture2;
    String[] textureSide;
    String[] textureTopAndDown;

    public ComplexTextureCasing(String name, String[] textureSide, String[] textureTopAndDown) {
        super(name);
        this.textureSide = textureSide;
        this.textureTopAndDown = textureTopAndDown;
    }

    @Override
    @SideOnly(Side.CLIENT)
    public IIcon getIcon(int side, int meta) {
        if (side < 2) {
            return meta < this.texture2.length ? this.texture2[meta] : this.texture2[0];
        } else {
            return meta < this.texture1.length ? this.texture1[meta] : this.texture1[0];
        }
    }

    @Override
    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister par1IconRegister) {
        this.texture1 = new IIcon[this.textureSide.length];
        for (int i = 0; i < this.textureSide.length; i++) {
            this.texture1[i] = par1IconRegister.registerIcon(this.textureSide[i]);
        }
        this.texture2 = new IIcon[this.textureTopAndDown.length];
        for (int i = 0; i < this.textureTopAndDown.length; i++) {
            this.texture2[i] = par1IconRegister.registerIcon(this.textureTopAndDown[i]);
        }
    }

    @Override
    @SideOnly(Side.CLIENT)
    @SuppressWarnings("unchecked")
    public void getSubBlocks(Item item, CreativeTabs tab, List list) {
        for (int i = 0; i < Math.max(this.textureSide.length, this.textureTopAndDown.length); i++) {
            list.add(new ItemStack(item, 1, i));
        }
    }
}