Fix colors of vine-like blocks

This commit is contained in:
Cheeserolls 2015-04-01 13:34:57 +01:00
parent f70b075211
commit f7f470be09
2 changed files with 44 additions and 8 deletions

View File

@ -16,6 +16,10 @@ import biomesoplenty.common.item.ItemBOPBlock;
import net.minecraft.block.BlockVine;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockBOPVine extends BlockVine implements IBOPBlock
{
@ -24,12 +28,44 @@ public class BlockBOPVine extends BlockVine implements IBOPBlock
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
public Class<? extends ItemBlock> getItemClass() {return ItemBOPBlock.class;}
public BlockBOPVine()
// if set to true, (the default), use BlockVine getBlockColor(), getRenderColor() and colorMultiplier() functions to color the texture based on biome
// if set to false, use 0xFFFFFF for all the color functions so that the texture is used as it is
protected boolean useGreyScaleTextures;
public BlockBOPVine(boolean useGreyScaleTextures)
{
super();
this.setHardness(0.2F);
this.useGreyScaleTextures = useGreyScaleTextures;
}
public BlockBOPVine()
{
this(true);
}
@Override
@SideOnly(Side.CLIENT)
public int getBlockColor()
{
return (this.useGreyScaleTextures ? super.getBlockColor() : 0xFFFFFF);
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderColor(IBlockState state)
{
return (this.useGreyScaleTextures ? super.getRenderColor(state) : 0xFFFFFF);
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
return (this.useGreyScaleTextures ? super.colorMultiplier(worldIn, pos, renderPass) : 0xFFFFFF);
}
}

View File

@ -156,12 +156,12 @@ public class ModBlocks
dead_log = registerBlock( new BlockBOPLog(), "dead_log" ); // no planks, stairs, etc
//vines
// TODO: colors? rendering modes? special placement rules?
flower_vine = registerBlock( new BlockBOPVine(), "flower_vine" );
ivy = registerBlock( new BlockBOPVine(), "ivy" );
moss = registerBlock( new BlockBOPVine(), "moss" );
tree_moss = registerBlock( new BlockBOPVine(), "tree_moss" );
wisteria = registerBlock( new BlockBOPVine(), "wisteria" );
// TODO: special placement rules?
flower_vine = registerBlock( new BlockBOPVine(false), "flower_vine" );
ivy = registerBlock( new BlockBOPVine(true), "ivy" );
moss = registerBlock( new BlockBOPVine(true), "moss" );
tree_moss = registerBlock( new BlockBOPVine(false), "tree_moss" );
wisteria = registerBlock( new BlockBOPVine(false), "wisteria" );
}