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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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