Fixed a bug with colorised leaves

This commit is contained in:
Adubbz 2013-11-16 12:45:36 +11:00
parent c043fb318a
commit 3931a4a29e
4 changed files with 20 additions and 11 deletions

View File

@ -134,9 +134,14 @@ public class BlockBOPColorizedLeaves extends BlockLeavesBase implements IShearab
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) { public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list)
for (int i = 0; i < textures[0].length; ++i) { {
list.add(new ItemStack(blockID, 1, i)); for (int i = 0; i < 4; ++i)
{
if (category != ColourizedLeafCategory.CAT2 || i < 2)
{
list.add(new ItemStack(blockID, 1, i));
}
} }
} }
@ -186,7 +191,7 @@ public class BlockBOPColorizedLeaves extends BlockLeavesBase implements IShearab
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);
if ((meta & 8) != 0/* && (meta & 4) == 0*/) if ((meta & 4) != 0/* && (meta & 4) == 0*/)
{ {
byte b0 = 4; byte b0 = 4;
int i1 = b0 + 1; int i1 = b0 + 1;
@ -336,9 +341,10 @@ public class BlockBOPColorizedLeaves extends BlockLeavesBase implements IShearab
return ret; return ret;
} }
public String getLeafType(int meta) public String getLeafType(int metadata)
{ {
return leaves[getTypeFromMeta(meta)]; int type = getTypeFromMeta(metadata) + (category.ordinal() * 4);
return leaves[type >= leaves.length ? 0 : type];
} }
private static int getTypeFromMeta(int meta) private static int getTypeFromMeta(int meta)

View File

@ -213,7 +213,7 @@ public class BOPBlocks
Blocks.hellBarkStairs = Optional.of((new BlockBOPStairs(BOPConfigurationIDs.hellBarkStairsID, Blocks.planks.get(), Category.HELL_BARK)).setUnlocalizedName("bop.hellBarkStairs")); Blocks.hellBarkStairs = Optional.of((new BlockBOPStairs(BOPConfigurationIDs.hellBarkStairsID, Blocks.planks.get(), Category.HELL_BARK)).setUnlocalizedName("bop.hellBarkStairs"));
Blocks.jacarandaStairs = Optional.of((new BlockBOPStairs(BOPConfigurationIDs.jacarandaStairsID, Blocks.planks.get(), Category.JACARANDA)).setUnlocalizedName("bop.jacarandaStairs")); Blocks.jacarandaStairs = Optional.of((new BlockBOPStairs(BOPConfigurationIDs.jacarandaStairsID, Blocks.planks.get(), Category.JACARANDA)).setUnlocalizedName("bop.jacarandaStairs"));
Blocks.leavesColorized1 = Optional.of((new BlockBOPColorizedLeaves(BOPConfigurationIDs.colourizedLeavesID, ColourizedLeafCategory.CAT1)).setUnlocalizedName("bop.leavesColorized1")); Blocks.leavesColorized1 = Optional.of((new BlockBOPColorizedLeaves(BOPConfigurationIDs.colourizedLeaves1ID, ColourizedLeafCategory.CAT1)).setUnlocalizedName("bop.leavesColorized1"));
Blocks.leavesColorized2 = Optional.of((new BlockBOPColorizedLeaves(BOPConfigurationIDs.colourizedLeaves2ID, ColourizedLeafCategory.CAT2)).setUnlocalizedName("bop.leavesColorized2")); Blocks.leavesColorized2 = Optional.of((new BlockBOPColorizedLeaves(BOPConfigurationIDs.colourizedLeaves2ID, ColourizedLeafCategory.CAT2)).setUnlocalizedName("bop.leavesColorized2"));
//Blocks.leavesColorized3 = Optional.of((new BlockBOPColorizedLeaves(BOPConfigurationIDs.colourizedLeaves3ID, ColourizedLeafCategory.CAT3)).setUnlocalizedName("bop.leavesColorized3")); //Blocks.leavesColorized3 = Optional.of((new BlockBOPColorizedLeaves(BOPConfigurationIDs.colourizedLeaves3ID, ColourizedLeafCategory.CAT3)).setUnlocalizedName("bop.leavesColorized3"));
//Blocks.leavesColorized4 = Optional.of((new BlockBOPColorizedLeaves(BOPConfigurationIDs.colourizedLeaves4ID, ColourizedLeafCategory.CAT4)).setUnlocalizedName("bop.leavesColorized4")); //Blocks.leavesColorized4 = Optional.of((new BlockBOPColorizedLeaves(BOPConfigurationIDs.colourizedLeaves4ID, ColourizedLeafCategory.CAT4)).setUnlocalizedName("bop.leavesColorized4"));

View File

@ -94,8 +94,10 @@ public class BOPConfigurationIDs
public static int hellBarkStairsID; public static int hellBarkStairsID;
public static int jacarandaStairsID; public static int jacarandaStairsID;
public static int colourizedLeavesID; public static int colourizedLeaves1ID;
public static int colourizedLeaves2ID; public static int colourizedLeaves2ID;
public static int colourizedLeaves3ID;
public static int colourizedLeaves4ID;
public static int crystalID; public static int crystalID;
public static int cloudID; public static int cloudID;
@ -352,8 +354,10 @@ public class BOPConfigurationIDs
leaves2ID = config.getBlock("Leaf Block ID 2", 1951, null).getInt(); leaves2ID = config.getBlock("Leaf Block ID 2", 1951, null).getInt();
leaves3ID = config.getBlock("Leaf Block ID 3", 1952, null).getInt(); leaves3ID = config.getBlock("Leaf Block ID 3", 1952, null).getInt();
leaves4ID = config.getBlock("Leaf Block ID 4", 1953, null).getInt(); leaves4ID = config.getBlock("Leaf Block ID 4", 1953, null).getInt();
colourizedLeavesID = config.getBlock("Colourized Leaves ID", 1955, null).getInt(); colourizedLeaves1ID = config.getBlock("Colourized Leaves 1 ID", 1955, null).getInt();
colourizedLeaves2ID = config.getBlock("Colourized Leaves 2 ID", 1956, null).getInt(); colourizedLeaves2ID = config.getBlock("Colourized Leaves 2 ID", 1956, null).getInt();
colourizedLeaves2ID = config.getBlock("Colourized Leaves 3 ID", 1957, null).getInt();
colourizedLeaves2ID = config.getBlock("Colourized Leaves 4 ID", 1958, null).getInt();
leavesFruitID = config.getBlock("Fruit Leaf Block ID", 1960, null).getInt(); leavesFruitID = config.getBlock("Fruit Leaf Block ID", 1960, null).getInt();
leavesFruit2ID = config.getBlock("Fruit Leaf Block 2 ID", 1961, null).getInt(); leavesFruit2ID = config.getBlock("Fruit Leaf Block 2 ID", 1961, null).getInt();
petalsID = config.getBlock("Petal ID", 1962, null).getInt(); petalsID = config.getBlock("Petal ID", 1962, null).getInt();

View File

@ -23,8 +23,7 @@ public class ItemBlockColorizedLeaves extends ItemBlock
@Override @Override
public String getUnlocalizedName(ItemStack itemStack) public String getUnlocalizedName(ItemStack itemStack)
{ {
BlockBOPColorizedLeaves block = (BlockBOPColorizedLeaves)Block.blocksList[itemStack.itemID]; BlockBOPColorizedLeaves block = (BlockBOPColorizedLeaves)Block.blocksList[itemStack.itemID];
return super.getUnlocalizedName() + "." + block.getLeafType(itemStack.getItemDamage()); return super.getUnlocalizedName() + "." + block.getLeafType(itemStack.getItemDamage());
} }
} }