-
Notifications
You must be signed in to change notification settings - Fork 79
/
ItemColorPatterns.java
38 lines (31 loc) · 1001 Bytes
/
ItemColorPatterns.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package mod.chiselsandbits.client;
import mod.chiselsandbits.core.ClientSide;
import mod.chiselsandbits.helpers.ModUtil;
import mod.chiselsandbits.render.helpers.ModelUtil;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ItemColorPatterns implements IItemColor
{
@Override
public int getColorFromItemstack(
final ItemStack stack,
final int tint )
{
if ( ClientSide.instance.holdingShift() )
{
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 ) ), tintValue );
}
return 0xffffff;
}
return 0xffffffff;
}
}