Skip to content

Commit

Permalink
Remove grass specific tint requirements, instead encode tint and stat…
Browse files Browse the repository at this point in the history
…e id to some extent and support any block with a tint that fits into a single byte.
  • Loading branch information
AlgorithmX2 committed Aug 26, 2018
1 parent 24de088 commit f8cc1c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Expand Up @@ -17,8 +17,9 @@ public int colorMultiplier(
final BlockPos pos,
final int tint )
{
final IBlockState tstate = ModUtil.getStateById( tint );
return Minecraft.getMinecraft().getBlockColors().colorMultiplier( tstate, worldIn, pos, 0 );
final IBlockState tstate = ModUtil.getStateById( tint >> 8 );
int tintValue = tint & 0xff;
return Minecraft.getMinecraft().getBlockColors().colorMultiplier( tstate, worldIn, pos, tintValue );
}

}
Expand Up @@ -30,21 +30,19 @@ public ModelQuadLayerBuilder(
public ModelQuadLayer build(
final int stateid,
final int color,
final int lightValue,
final boolean isGrass )
final int lightValue )
{
cache.light = Math.max( lightValue, lv.lv );
cache.uvs = uvr.quadUVs;
cache.color = cache.tint != -1 ? color : 0xffffffff;

if ( isGrass )
if ( 0x00 <= cache.tint && cache.tint <= 0xff )
{
cache.color = 0xffffffff;
cache.tint = cache.tint == -1 ? -1 : stateid;
cache.tint = ( stateid << 8 ) | cache.tint;
}
else
{
// remove tints, I'm only support grass for the time being.
cache.tint = -1;
}

Expand Down
Expand Up @@ -17,15 +17,13 @@
import mod.chiselsandbits.render.chiseledblock.ChiseledBlockBaked;
import mod.chiselsandbits.render.helpers.ModelQuadLayer.ModelQuadLayerBuilder;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
Expand Down Expand Up @@ -175,7 +173,7 @@ else if ( xf.getAxis() == Axis.X )

for ( int z = 0; z < x.size(); z++ )
{
mp[z] = x.get( z ).build( stateID, color, lv, state.getBlock() == Blocks.GRASS || state.getBlock() instanceof BlockLeaves );
mp[z] = x.get( z ).build( stateID, color, lv );
}

cache.put( cacheV, mp );
Expand Down

0 comments on commit f8cc1c6

Please sign in to comment.