Split up the colorised leaves into separate ids (hopefully)

This commit is contained in:
Adubbz 2013-11-16 11:20:29 +11:00
parent 455d36e788
commit 499133137b
4 changed files with 345 additions and 316 deletions

View file

@ -72,7 +72,12 @@ public class Blocks
public static Optional<? extends Block> leaves2 = Optional.absent();
public static Optional<? extends Block> leaves3 = Optional.absent();
public static Optional<? extends Block> leaves4 = Optional.absent();
public static Optional<? extends Block> leavesColorized = Optional.absent();
public static Optional<? extends Block> leavesColorized1 = Optional.absent();
public static Optional<? extends Block> leavesColorized2 = Optional.absent();
public static Optional<? extends Block> leavesColorized3 = Optional.absent();
public static Optional<? extends Block> leavesColorized4 = Optional.absent();
public static Optional<? extends Block> leavesFruit = Optional.absent();
public static Optional<? extends Block> leavesFruit2 = Optional.absent();
public static Optional<? extends Block> foliage = Optional.absent();

View file

@ -18,19 +18,27 @@ import net.minecraftforge.common.IShearable;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks;
import biomesoplenty.asm.BOPBiomeColourBlending;
import biomesoplenty.blocks.BlockBOPLeaves.LeafCategory;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBOPColorizedLeaves extends BlockLeavesBase implements IShearable
{
public static enum ColourizedLeafCategory
{
CAT1, CAT2, CAT3, CAT4;
}
private static final String[] leaves = new String[] {"acacia", "mangrove", "palm", "redwood", "willow", "pine"};
private Icon[][] textures;
private final ColourizedLeafCategory category;
int[] adjacentTreeBlocks;
public BlockBOPColorizedLeaves(int blockID)
public BlockBOPColorizedLeaves(int blockID, ColourizedLeafCategory cat)
{
super(blockID, Material.leaves, false);
category = cat;
setBurnProperties(this.blockID, 30, 60);
this.setTickRandomly(true);
setHardness(0.2F);
@ -60,15 +68,16 @@ public class BlockBOPColorizedLeaves extends BlockLeavesBase implements IShearab
public Icon getIconBetterLeaves(int metadata, float randomIndex)
{
return textures[2][getTypeFromMeta(metadata)];
int type = getTypeFromMeta(metadata) + (category.ordinal() * 4);
return textures[2][type >= leaves.length ? 0 : type];
}
public Icon getIconFallingLeaves(int metadata)
{
return textures[1][getTypeFromMeta(metadata)];
int type = getTypeFromMeta(metadata) + (category.ordinal() * 4);
return textures[1][type >= leaves.length ? 0 : type];
}
@Override
public int getBlockColor()
{
@ -100,9 +109,10 @@ public class BlockBOPColorizedLeaves extends BlockLeavesBase implements IShearab
}
@Override
public Icon getIcon(int side, int meta)
public Icon getIcon(int side, int metadata)
{
return textures[(!isOpaqueCube() ? 0 : 1)][getTypeFromMeta(meta)];
int type = getTypeFromMeta(metadata) + (category.ordinal() * 4);
return textures[(!isOpaqueCube() ? 0 : 1)][type >= leaves.length ? 0 : type];
}
@Override
@ -287,7 +297,13 @@ public class BlockBOPColorizedLeaves extends BlockLeavesBase implements IShearab
@Override
public int damageDropped(int meta)
{
return getTypeFromMeta(meta);
return (getTypeFromMeta(meta) + category.ordinal() * 4) + 1;
}
@Override
public int getDamageValue(World par1World, int par2, int par3, int par4)
{
return getTypeFromMeta(par1World.getBlockMetadata(par2, par3, par4));
}
@Override
@ -317,7 +333,7 @@ public class BlockBOPColorizedLeaves extends BlockLeavesBase implements IShearab
private static int getTypeFromMeta(int meta)
{
meta = meta & 7;
meta = meta & 3;
if (meta < 0 || meta >= leaves.length) {
meta = 0;
}
@ -339,7 +355,7 @@ public class BlockBOPColorizedLeaves extends BlockLeavesBase implements IShearab
@Override
public void beginLeavesDecay(World world, int x, int y, int z)
{
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4);
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 4, 4);
}
@Override

View file

@ -364,7 +364,7 @@ public class BlockBOPLeaves extends BlockLeavesBase implements IShearable
private static int getTypeFromMeta(int meta)
{
meta = meta & 7;
meta = meta & 3;
if (meta < 0 || meta >= leaves.length) {
meta = 0;
}
@ -386,7 +386,7 @@ public class BlockBOPLeaves extends BlockLeavesBase implements IShearable
@Override
public void beginLeavesDecay(World world, int x, int y, int z)
{
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4);
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 4, 4);
}
@Override

View file

@ -16,6 +16,7 @@ import biomesoplenty.blocks.BlockBOPFlower;
import biomesoplenty.blocks.BlockBOPFlower2;
import biomesoplenty.blocks.BlockBOPFoliage;
import biomesoplenty.blocks.BlockBOPGeneric;
import biomesoplenty.blocks.BlockBOPColorizedLeaves.ColourizedLeafCategory;
import biomesoplenty.blocks.BlockBOPGeneric.BlockType;
import biomesoplenty.blocks.BlockBOPGrass;
import biomesoplenty.blocks.BlockBOPLeaves;
@ -210,7 +211,11 @@ public class BOPBlocks
Blocks.pineStairs = Optional.of((new BlockBOPStairs(BOPConfigurationIDs.pineStairsID, Blocks.planks.get(), Category.PINE)).setUnlocalizedName("bop.pineStairs"));
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.leavesColorized = Optional.of((new BlockBOPColorizedLeaves(BOPConfigurationIDs.colourizedLeavesID)).setUnlocalizedName("bop.leavesColorized"));
Blocks.leavesColorized1 = Optional.of((new BlockBOPColorizedLeaves(BOPConfigurationIDs.colourizedLeavesID, ColourizedLeafCategory.CAT1)).setUnlocalizedName("bop.leavesColorized1"));
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.leavesColorized4 = Optional.of((new BlockBOPColorizedLeaves(BOPConfigurationIDs.colourizedLeaves4ID, ColourizedLeafCategory.CAT4)).setUnlocalizedName("bop.leavesColorized4"));
}
private static void registerBlocks()
@ -304,7 +309,10 @@ public class BOPBlocks
registerBlock(Blocks.hellBarkStairs.get());
registerBlock(Blocks.jacarandaStairs.get());
registerBlock(Blocks.leavesColorized.get(), ItemBlockColorizedLeaves.class);
registerBlock(Blocks.leavesColorized1.get(), ItemBlockColorizedLeaves.class);
registerBlock(Blocks.leavesColorized2.get(), ItemBlockColorizedLeaves.class);
//registerBlock(Blocks.leavesColorized3.get(), ItemBlockColorizedLeaves.class);
//registerBlock(Blocks.leavesColorized4.get(), ItemBlockColorizedLeaves.class);
}
private static void registerTileEntities()