BiomesOPlenty/src/minecraft/biomesoplenty/blocks/BlockBOPStairs.java

133 lines
2.9 KiB
Java
Raw Normal View History

2013-05-03 13:00:44 +00:00
package biomesoplenty.blocks;
import java.util.Arrays;
import java.util.List;
2013-05-03 13:00:44 +00:00
import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import biomesoplenty.BiomesOPlenty;
2013-05-03 13:00:44 +00:00
public class BlockBOPStairs extends BlockStairs
{
public static enum Category
{
ACACIA ("wood"), CHERRY ("wood"), DARK ("wood"), FIR ("wood"), HOLY ("wood"), MAGIC ("wood"), MANGROVE ("wood"), PALM ("wood"), REDWOOD ("wood"), WILLOW ("wood"), PINE ("wood"), HELL_BARK ("wood"), JACARANDA ("wood"), RED_COBBLE ("stone"), RED_BRICKS ("stone"), MUD_BRICKS ("stone"), HOLY_COBBLE ("stone"), HOLY_BRICKS ("stone");
private final List<String> values;
private String type;
2013-05-31 10:34:02 +00:00
private Category(String type)
{
this.type = type;
2013-05-31 10:34:02 +00:00
values = Arrays.asList(type);
}
}
2013-05-31 10:34:02 +00:00
private static final String[] woodTypes = new String[] {"acacia", "cherry", "dark", "fir", "holy", "magic", "mangrove", "palm", "redwood", "willow", "pine", "hell_bark", "jacaranda"};
private static final String[] stoneTypes = new String[] {"redcobble", "redbrick", "mudbrick", "holycobble", "holybrick"};
private Icon[] textures;
private final Category category;
public BlockBOPStairs(int blockID, Block model, Category cat)
{
super(blockID, model, 0);
category = cat;
setBurnProperties(this.blockID, 5, 20);
this.setLightOpacity(0);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
public void registerIcons(IconRegister iconRegister)
{
if (isStoneCategory(category.toString()))
{
textures = new Icon[stoneTypes.length];
for (int i = 0; i < stoneTypes.length; ++i) {
textures[i] = iconRegister.registerIcon("BiomesOPlenty:"+stoneTypes[i]);
}
}
else
{
textures = new Icon[woodTypes.length];
for (int i = 0; i < woodTypes.length; ++i) {
textures[i] = iconRegister.registerIcon("BiomesOPlenty:plank_"+woodTypes[i]);
}
}
}
public boolean isWoodCategory(String block)
{
String type = Category.valueOf(block).type;
if (type == "wood")
return true;
else
return false;
}
public boolean isStoneCategory(String block)
{
String type = Category.valueOf(block).type;
if (type == "stone")
return true;
else
return false;
}
public static int getWoodCategoryAmount()
{
int woodCatNo = 0;
for (Category cat : Category.values())
{
if (cat.values.contains("wood"))
{
++woodCatNo;
}
}
return woodCatNo;
}
public static int getStoneCategoryAmount()
{
int woodCatNo = 0;
for (Category cat : Category.values())
{
if (cat.values.contains("stone"))
{
++woodCatNo;
}
}
return woodCatNo;
}
@Override
public Icon getIcon(int side, int meta)
{
int adjCat = category.ordinal();
if (isStoneCategory(category.toString()))
{
adjCat = adjCat - getWoodCategoryAmount();
}
return textures[adjCat];
}
@Override
public int damageDropped(int meta)
{
return meta;
}
2013-05-03 13:00:44 +00:00
}