Skip to content

Commit

Permalink
Add similar tint support to the various item types.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlgorithmX2 committed Aug 27, 2018
1 parent f8cc1c6 commit b0586cd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Expand Up @@ -10,15 +10,18 @@
public class BlockColorChisled implements IBlockColor
{

public static final int TINT_MASK = 0xff;
public static final int TINT_BITS = 8;

@Override
public int colorMultiplier(
final IBlockState state,
final IBlockAccess worldIn,
final BlockPos pos,
final int tint )
{
final IBlockState tstate = ModUtil.getStateById( tint >> 8 );
int tintValue = tint & 0xff;
final IBlockState tstate = ModUtil.getStateById( tint >> TINT_BITS );
int tintValue = tint & TINT_MASK;
return Minecraft.getMinecraft().getBlockColors().colorMultiplier( tstate, worldIn, pos, tintValue );
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/mod/chiselsandbits/client/ItemColorBits.java
Expand Up @@ -21,13 +21,14 @@ public int getColorFromItemstack(
{
if ( ClientSide.instance.holdingShift() )
{
final IBlockState state = ModUtil.getStateById( tint );
final IBlockState state = ModUtil.getStateById( tint >> BlockColorChisled.TINT_BITS );
final Block blk = state.getBlock();
final Item i = Item.getItemFromBlock( blk );
int tintValue = tint & BlockColorChisled.TINT_MASK;

if ( i != null )
{
return ModelUtil.getItemStackColor( new ItemStack( i, 1, blk.getMetaFromState( state ) ), 0 );
return ModelUtil.getItemStackColor( new ItemStack( i, 1, blk.getMetaFromState( state ) ), tintValue );
}

return 0xffffff;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/mod/chiselsandbits/client/ItemColorChisled.java
Expand Up @@ -16,13 +16,14 @@ public int getColorFromItemstack(
final ItemStack stack,
final int tint )
{
final IBlockState state = ModUtil.getStateById( tint );
final IBlockState state = ModUtil.getStateById( tint >> BlockColorChisled.TINT_BITS );
final Block blk = state.getBlock();
final Item i = Item.getItemFromBlock( blk );
int tintValue = tint & BlockColorChisled.TINT_MASK;

if ( i != null )
{
return ModelUtil.getItemStackColor( new ItemStack( i, 1, blk.getMetaFromState( state ) ), 0 );
return ModelUtil.getItemStackColor( new ItemStack( i, 1, blk.getMetaFromState( state ) ), tintValue );
}

return 0xffffff;
Expand Down
Expand Up @@ -19,13 +19,14 @@ public int getColorFromItemstack(
{
if ( ClientSide.instance.holdingShift() )
{
final IBlockState state = ModUtil.getStateById( tint );
final IBlockState state = ModUtil.getStateById( tint >> BlockColorChisled.TINT_BITS );
final Block blk = state.getBlock();
final Item i = Item.getItemFromBlock( blk );
int tintValue = tint & BlockColorChisled.TINT_MASK;

if ( i != null )
{
return ModelUtil.getItemStackColor( new ItemStack( i, 1, blk.getMetaFromState( state ) ), 0 );
return ModelUtil.getItemStackColor( new ItemStack( i, 1, blk.getMetaFromState( state ) ), tintValue );
}

return 0xffffff;
Expand Down

0 comments on commit b0586cd

Please sign in to comment.