Jump to content

[1.10.2] Recoloring block with IBlockColor


Recommended Posts

Posted

To avoid having to create an insane amount of item models for my ingots, nuggets, dusts and plates, I decided to use an IItemColor implementation for them which works great. To make the ores look exactly the same as the materials, I wanted to use an IBlockColor implementation for the ore blocks. My problem now is that not only the little chunks in the texture get recolored but also the stone background (the chunks and the stone background are seperate textures).

 

This is my IBlockColor implementation:

package XFactHD.advtech.client.utils.blockColoring;

import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;

import javax.annotation.Nullable;

public class ColorHandlerBlockOre implements IBlockColor, IItemColor
{
    private static final int[] colors = new int[]{
            0xb4713d, //Copper
            0xe8e8e8, //Tin
            0xdbf0f3, //Silver
            0x818ebe, //Lead
            0xd3d8ec, //Nickel
            0xb9d6d9, //Lithium
            0x87a6e8, //Cadmium
            0xf1eef5, //Zinc
            0xb3e9f7, //Platinum
            0x383241, //Tungsten
            0x9fa100  //Sulfur
    };

    @Override
    public int colorMultiplier(IBlockState state, @Nullable IBlockAccess world, @Nullable BlockPos pos, int tintIndex)
    {
        return tintIndex == 1 ? colors[state.getBlock().getMetaFromState(state)] : -1;
    }

    @Override
    public int getColorFromItemstack(ItemStack stack, int layer)
    {
        return layer == 1 ? colors[stack.getMetadata()] : -1;
    }
}

 

This is my block model:

{
  "parent": "block/cube_all",
  "textures": {
    "all": "blocks/stone",
    "colored": "advtech:blocks/ore_chunk"
  },
  "elements": [
    {
      "from": [ 0, 0, 0 ],
      "to": [ 16, 16, 16 ],
      "faces": {
        "down":  { "tintindex": 0, "texture": "#all", "cullface": "down" },
        "up":    { "tintindex": 0, "texture": "#all", "cullface": "up" },
        "north": { "tintindex": 0, "texture": "#all", "cullface": "north" },
        "south": { "tintindex": 0, "texture": "#all", "cullface": "south" },
        "west":  { "tintindex": 0, "texture": "#all", "cullface": "west" },
        "east":  { "tintindex": 0, "texture": "#all", "cullface": "east" }
      }
    },
    {
      "from": [ 0, 0, 0 ],
      "to": [ 16, 16, 16 ],
      "faces": {
        "down":  { "tintindex": 1, "texture": "#colored", "cullface": "down" },
        "up":    { "tintindex": 1, "texture": "#colored", "cullface": "up" },
        "north": { "tintindex": 1, "texture": "#colored", "cullface": "north" },
        "south": { "tintindex": 1, "texture": "#colored", "cullface": "south" },
        "west":  { "tintindex": 1, "texture": "#colored", "cullface": "west" },
        "east":  { "tintindex": 1, "texture": "#colored", "cullface": "east" }
      }
    }
  ]
}

 

This is the underlying blockstate file:

{
  "variants": {
    "normal": { "model": "advtech:ore" }
  }
}

Posted

Remove the

tintindex

from your "stone" cube, and only have the

tintindex

on the "colored" cube.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

I'm currently doing my ores the same way as you intend on doing, so this link to my model file might help: model.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

The only differences between my model and your model are that you are defining the UVs per face and that the tintindex tag is after the texture tag. Swapping the texture and the tintindex tag didn't fix stuff, neither did defining the UVs fix it.

Posted

I just saw a little but significant difference between your and my mod: You are using MC 1.11 and I am using MC 1.10.2.

Posted

i would try first to delete the tintindex option at all from the stone that you dont want colored and make trhe colored part tintindex of 0. if that doesnt work try replacing block/cube_all with block/block

Posted

I did already remove the tintindex from the stone part and changing the tintindex of the coloured part changes anything then this system is horribly broken in my opinion. Why should changing the parent from block/cube_all to block/block have any impact?

  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.