Jump to content

Recommended Posts

Posted

Hello,

 

I am currently trying to implement a custom 'Material' (as in Iron/Gold/etc) pipeline in my mod. To do so I am generating ores, ingots, etc. using a single base texture and a material's assigned color. I understand how to achieve desired results for coloring Items and single-layer blocks, but I am having trouble figuring out how the following can be done:

 

7ajyZdK.png

 

I have two texture files, the stone, and the white ore vein overlay.

The block would have the base layer of stone.

The overlay layer would be the ore veins post-colored.

 

Are there any classes currently in MC/MCForge that I can utilize to Color just one layer of a block's texture?

How would I go about this, or at least how could I refine my search to find information on achieving this result?

 

Once this is figured out will treating the block as any other, like creating an ItemBlock, retain the desired appearance in the player's inventory? Or will additional work be required?

Posted

The

block/grass

model already does something like this: It has one full cube with only the top coloured and another cube without a top or bottom and each side coloured. The cubes are the same size, but the second cube's texture is overlayed on the first.

 

What you need is a cube with the stone texture on all sides and another cube with the ore texture on all sides and each side coloured.

 

For a face to be coloured, specify the tint index in the model and then register an

IBlockColour

and

IItemColour

for the

Block

and

ItemBlock

. These will receive the tint index as an argument, telling them which part of the model is being coloured (though you don't need to worry about that if the model only has a single dynamic colour).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
(though you don't need to worry about that if the model only has a single dynamic colour).

 

His example has two: the ore color (blue) and the stone color (white).

 

In any case, if the OP wishes to go the custom TextureAtlasSprite route (which renders the color once) I've got some posts on this forum on how to do precisely that.  I don't know if the class has changed in 1.8+ however, and due to the nature of a custom

load()

method in that class, a lot of the "texture not found" error messages get dropped (and instead you get NPEs in later parts of the rendering code), so you'd be mostly on your own.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

(though you don't need to worry about that if the model only has a single dynamic colour).

 

His example has two: the ore color (blue) and the stone color (white).

 

The stone isn't dynamically coloured, it would just be a regular texture.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

In this case I will be opting with the tintIndex route. It seems like the easier of the two to first approach, and colors may have to change dynamically.

And yes, the backdrop of the ore itself referenced in Step 2 is a static texture, no color need be applied.

 

In saying that, would this be the correct way of setting up my JSON file for the ore block?

'ore' is just a stone backdrop and 'ore_vein' is the white vein to be tinted.

 

(I am away from my testing environment and am just clearing roadblocks I foresee when I begin work.)

 

{   "parent": "block/block",
    "elements": [
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "fi:blocks/ore",   "cullface": "down" },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "fi:blocks/ore",   "cullface": "up" },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "fi:blocks/ore",   "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "fi:blocks/ore",   "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "fi:blocks/ore",   "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "fi:blocks/ore",   "cullface": "east" }
            }
        },
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "fi:blocks/ore_vein", "tintindex": 0, "cullface": "down" },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "fi:blocks/ore_vein", "tintindex": 0, "cullface": "up" },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "fi:blocks/ore_vein", "tintindex": 0, "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "fi:blocks/ore_vein", "tintindex": 0, "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "fi:blocks/ore_vein", "tintindex": 0, "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "fi:blocks/ore_vein", "tintindex": 0, "cullface": "east" }
            }
        }
    ]
}

Posted

That looks correct, though I'd recommend using texture references like

#ore

and

#ore_vein

in the base model instead of texture paths. You can then specify the actual paths of these references in the derived models or blockstates file (if you're using Forge's blockstates format).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

I am indeed using Forge blockstates.

I set up some basic debug blocks and items to test and ran into an error-less roadblock.

 

I did not pass a tintIndex when registering, I got the following result:

 

yVbhRl1.png

 

It shows up fine in my inventory, however the block in the real world is incorrect as shown.

Is there something I am missing to correctly render the block in the world?

 

Here are my JSONs, both named 'oreDebug'

 

model

{   "parent": "block/block",
    "elements": [
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#base",   "cullface": "down" },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#base",   "cullface": "up" },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#base",   "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#base",   "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#base",   "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#base",   "cullface": "east" }
            }
        },
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "down" },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "up" },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "east" }
            }
        }
    ]
}

 

 

blockstate

{
    "forge_marker": 1,
    "defaults": {
        "uvlock": true
    },
    "variants": {
        "normal": [{ 
            "textures": {
                "base": "fenton:blocks/ore",
                "overlay": "fenton:blocks/ore_vein"
            },
            "model": "fenton:oreDebug" 
        }],
        "inventory": [{ 
            "textures": {
                "base": "fenton:blocks/ore",
                "overlay": "fenton:blocks/ore_vein"
            },
            "model": "fenton:oreDebug" 
        }]
    }
}

Posted

You'll also need to override

Block#getBlockLayer

to return

BlockRenderLayer.CUTOUT

or

BlockRenderLayer.CUTOUT_MIPPED

(

BlockGrass

uses the latter). This allows the block's textures to render with transparency.

 

The Grey Ghost explains render layers in more detail here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • 3 months later...
Posted

Hello,

 

Sorry to bump this thread but this is exactly what I'm trying to do as well. I have a block with 2 models (one for the base block with a basic texture, and another one for drawing a transparent texture with CUTOUT render) and I'm trying to find a way to apply a specific color on the transparent texture. I've searched in multiple places but I don't see how to achieve this.

 

Maybe the OP has found how to do it, idk, this is why I use this thread to ask.

 

Thanks.

Posted

Hello,

 

Sorry to bump this thread but this is exactly what I'm trying to do as well. I have a block with 2 models (one for the base block with a basic texture, and another one for drawing a transparent texture with CUTOUT render) and I'm trying to find a way to apply a specific color on the transparent texture. I've searched in multiple places but I don't see how to achieve this.

 

Maybe the OP has found how to do it, idk, this is why I use this thread to ask.

 

Thanks.

 

I already told the OP how to do this and the OP posted a model that worked apart from the render layer (which I told them how to fix). Did you read the thread?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

I did, I have a working model, everything is fine on this side. I'm just looking how to apply a color on a specific layer and I can't figure out how tintindex works here.

 

In my case I have a block with a painted line on it. The line is on a separate layer (like OP did for the ore vein):

 

(stupid imgur blocking hotlinking...)

 

And I would like to know how to taint it with another color so I don't need to make different textures for every color (even if for now I only have white and yellow lines planned). I've looked for many threads on many forums, read many docs, but still can't see how that would work (if that can be done).

 

Edit: I'm in 1.9.4 but 1.10.2 is fine too.

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.