BiomesOPlenty/common/biomesoplenty/blocks/BlockBOPStairs.java

129 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);
2013-08-08 20:36:53 +00:00
this.setHardness(model.blockHardness);
this.setResistance(model.blockResistance / 3.0F);
2013-05-31 10:34:02 +00:00
}
@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]);
2013-05-31 10:34:02 +00:00
}
}
else
{
textures = new Icon[woodTypes.length];
for (int i = 0; i < woodTypes.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:plank_"+woodTypes[i]);
2013-05-31 10:34:02 +00:00
}
}
}
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];
}
2013-05-03 13:00:44 +00:00
}