Fix item rendering for blocks with a tinted model but non-tinted item (flax and berry_bush)

This commit is contained in:
Cheeserolls 2015-04-03 18:47:55 +01:00
parent c2b80ce5fd
commit 8ca7e90be0
25 changed files with 74 additions and 3 deletions

View File

@ -18,5 +18,6 @@ public interface IBOPBlock {
public Map<String, IBlockState> getNamedStates();
public IBlockState getNamedState(String name);
public Class<? extends ItemBlock> getItemClass();
public int getItemRenderColor(IBlockState state, int tintIndex);
}

View File

@ -43,6 +43,8 @@ public class BlockBOPDirt extends Block 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}

View File

@ -29,6 +29,8 @@ public class BlockBOPDoor extends BlockDoor 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 null;}
public int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
private Item doorItem;

View File

@ -25,6 +25,8 @@ public class BlockBOPFence extends BlockFence 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
public BlockBOPFence()
{

View File

@ -28,6 +28,8 @@ public class BlockBOPFenceGate extends BlockFenceGate 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
public BlockBOPFenceGate()
{

View File

@ -26,6 +26,8 @@ public class BlockBOPGeneric extends Block 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
public BlockBOPGeneric() {
// use rock as default material

View File

@ -54,6 +54,8 @@ public class BlockBOPGrass extends BlockGrass 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
public BlockBOPGrass()

View File

@ -43,6 +43,8 @@ public class BlockBOPLeaves extends BlockLeaves 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
private ItemStack sapling;
private ItemStack fruit;

View File

@ -37,6 +37,8 @@ public class BlockBOPLilypad extends BlockLilyPad implements IBOPBlock
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
// need to use a custom item class because of the unique way lilies are placed
public Class<? extends ItemBlock> getItemClass() {return ItemBOPLilypad.class;}
public int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
public BlockBOPLilypad()

View File

@ -31,6 +31,8 @@ public class BlockBOPLog extends BlockLog 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
public BlockBOPLog()
{

View File

@ -25,6 +25,8 @@ public class BlockBOPStairs extends BlockStairs 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
public BlockBOPStairs(IBlockState modelState)
{

View File

@ -42,6 +42,8 @@ public class BlockBOPStone extends Block 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
public BlockBOPStone()
{

View File

@ -28,6 +28,8 @@ 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
// 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

View File

@ -45,6 +45,7 @@ public class BlockBones extends Block 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
public BlockBones()

View File

@ -29,6 +29,8 @@ public class BlockCrystal extends Block 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
public BlockCrystal() {
super(Material.glass);

View File

@ -36,6 +36,8 @@ public class BlockDecoration extends Block 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
// constructor
public BlockDecoration() {

View File

@ -12,6 +12,7 @@ import java.util.List;
import java.util.Random;
import biomesoplenty.api.block.BOPBlocks;
import biomesoplenty.common.block.BlockFoliage.FoliageType;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
@ -91,6 +92,19 @@ public class BlockDoubleFoliage extends BlockDoubleDecoration implements ISheara
}
}
// flax item should not be tinted, even though the model is
@Override
public int getItemRenderColor(IBlockState state, int tintIndex)
{
switch ((FoliageType) state.getValue(VARIANT))
{
case FLAX:
return 0xFFFFFF;
default:
return this.getRenderColor(state);
}
}
// different variants have different sizes
@Override

View File

@ -39,6 +39,8 @@ public class BlockFlesh extends Block 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
public BlockFlesh() {
super(Material.sponge);

View File

@ -157,6 +157,20 @@ public class BlockFoliage extends BlockDecoration implements IShearable
return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
}
}
// berrybush item should not be tinted, even though the model is
@Override
public int getItemRenderColor(IBlockState state, int tintIndex)
{
switch ((FoliageType) state.getValue(VARIANT))
{
case BERRYBUSH:
return 0xFFFFFF;
default:
return this.getRenderColor(state);
}
}
// different variants have different sizes

View File

@ -36,6 +36,8 @@ public class BlockGem extends Block 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
public BlockGem()

View File

@ -38,6 +38,8 @@ public class BlockGemOre extends Block 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
public BlockGemOre()

View File

@ -42,6 +42,8 @@ public class BlockHive extends Block 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
public BlockHive()
{

View File

@ -45,6 +45,8 @@ public class BlockMud extends Block 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 int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
// constructor
public BlockMud() {

View File

@ -27,6 +27,8 @@ public class BlockTurnip extends BlockCrops 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 null;}
public int getItemRenderColor(IBlockState state, int tintIndex) {return this.getRenderColor(state);}
@Override
protected Item getSeed()

View File

@ -59,10 +59,11 @@ public class ItemBOPBlock extends ItemBlock
}
}
// TODO: renderPass is actually tintIndex - use for berries etc?
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int renderPass)
{
return this.block.getRenderColor(this.block.getStateFromMeta(stack.getMetadata()));
public int getColorFromItemStack(ItemStack stack, int tintIndex)
{
return this.bopBlock.getItemRenderColor(this.block.getStateFromMeta(stack.getMetadata()), tintIndex);
}
@Override