Jump to content

[1.12.2] [SOLVED] Block model json ignored (Cannot load more than one layer to a block model)


Jantek

Recommended Posts

Hey. I'm trying to create a universal block for easier ore block creation making it a bit like the item spawn eggs. I made two different textures, one the ore without the core substance (just plain rock) and one the core substance (without the rock)  coloured to white so it can be easily coloured procedurally. The rest of each texture is transparent.

The problem I have encountered is that I cannot make the model use both of the layers of the texture. Also, I see some strange behaviour so that both the blockstate json and the model json ignore completely the texture variables and use only the #all field (currently marked as a comment) in the blockstate file. Funny and also weird thing is, the game remembers what this field was when I cut it out. So it uses a texture even if nowhere in the code is any reference to the texture itself. Creepy.
 

I  can't upload a picture (dunno why, it says "200" as an explanation) but the block is properly coloured but there is only one texture (one layer) of the block visible. The rest of the texture (which should be filled with the second texture) is transparent. [Oh, look, I can now!] The yellow item in the first slot is an Item with the "core" texture (coloured to yellow).

 

Both of the json files get loaded. I don't get any exceptions logged. Both of the textures are visible to the game (I mean I already use them during troubleshooting with this and they got loaded normally).

 

Thanks in advance for any help.


The code of  sulphur_ore.json (the blockstate file):

{
	"forge_marker": 1,
	"defaults": {
		"textures": {
			//"all": "diversitymod:blocks/ore_core",
			"layer0": "diversitymod:blocks/ore_core",
			"layer1": "diversitymod:blocks/ore_rock"
		}
	},
	"variants": {
		"normal": {
			"model": "diversitymod:multi_ore"
		},
		"inventory": {
			"model": "diversitymod:multi_ore"
		}
	}
}


The code of multi_ore.json (the model file):
 

{   
"forge_marker": 1,
"parent": "block/block",
    "textures": {
        "particle": "diversitymod:blocks/ore_rock",
		"layer0": "diversitymod:blocks/ore_core",
		"layer1": "diversitymod:blocks/ore_rock"
		
    },
    "elements": [
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#layer0", "tintindex": 0, "cullface": "down" },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#layer0", "tintindex": 0, "cullface": "up" },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#layer0", "tintindex": 0, "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#layer0", "tintindex": 0, "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#layer0", "tintindex": 0, "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#layer0", "tintindex": 0, "cullface": "east" }
            }
        },
		{   "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#layer1", "tintindex": 1, "cullface": "down" },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#layer1", "tintindex": 1, "cullface": "up" },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#layer1", "tintindex": 1, "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#layer1", "tintindex": 1, "cullface": "south" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#layer1", "tintindex": 1, "cullface": "west" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#layer1", "tintindex": 1, "cullface": "east" }
            }
        }
    ]
}

 

The code of the block:

package com.jantek.diversity.blocks;

import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.BlockRenderLayer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockMultiOre extends BlockDiverse{

	public static int COLOR;
	public BlockMultiOre(String name, int color) {
		super(Material.ROCK, name);
		COLOR=color;
		setHardness(3f);
		setResistance(5f);
	}

	@Override
	public BlockMultiOre setCreativeTab(CreativeTabs tab) {
		super.setCreativeTab(tab);
		return this;
	}
	
	@Override
    public boolean isOpaqueCube(IBlockState state) { return false; }
	
	 @Override
     public boolean isFullCube(IBlockState state) { return false; }

	 @SideOnly(Side.CLIENT)
	 public BlockRenderLayer getBlockLayer(){
	        return BlockRenderLayer.CUTOUT;
	    }
}

 

screen jedna warstwa.jpg

Edited by Jantek
problem solved
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

12 hours ago, Draco18s said:

Thanks! But after more tries I discovered that the game just ignores the model json. I don't know why. A shame it took me so long to discover that.

So, why the game ignores it? As far as I know I don't have to register a custom model for a block, the model is just referenced in the blockstate json. Assuming I am wrong, I tried to call ModelLoader#registerCustomResourceLocation along with ModelBakery#registerItemVariants but still no change. Nor an exception thrown. What am I doing wrong?

Link to comment
Share on other sites

I make a custom model for all my custom blocks, even if they are just cubes. The game certainly does not ignore them, as you can tell by the fact the texture gets properly referenced.

 

What do you mean that it ignores your model? Like if you edit things in the model that nothing changes at all? Or you mean just that the layering system isn't working?

 

Is it possible it is one of those graphics rendering ambiguities where both your layers are right on top of each other so only one gets rendered. What happens if you change the element x, y, z for the first layer to be smaller than full cube start = (0.1, 0.1, 0.1) and finish = (15.9, 15.9, 15.9)?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

2 hours ago, jabelar said:

I make a custom model for all my custom blocks, even if they are just cubes. The game certainly does not ignore them, as you can tell by the fact the texture gets properly referenced.

 

What do you mean that it ignores your model? Like if you edit things in the model that nothing changes at all? Or you mean just that the layering system isn't working?

 

Is it possible it is one of those graphics rendering ambiguities where both your layers are right on top of each other so only one gets rendered. What happens if you change the element x, y, z for the first layer to be smaller than full cube start = (0.1, 0.1, 0.1) and finish = (15.9, 15.9, 15.9)?

I made a test by changing the size of the boxes of both layers to 10 pixels. Nothing changed. That made me think the game still uses some default model like block/block. This also makes sense explaining why changing the textures.#all variable in blockstate file actually changed the texture while changing other (custom) texture variables and also the #all variable in the model file changed nothing. 

So I also checked for some spelling mistakes in the reference to the model file. Like misspelling the modid or adding additional '/models/' to the path but I found none.

Link to comment
Share on other sites

21 hours ago, Jantek said:

I made a test by changing the size of the boxes of both layers to 10 pixels. Nothing changed. 

My suggestion was actually to make each layer different sizes. If they are exact same size as each other then I can imagine that in graphics rendering terms maybe one gets culled somehow.

 

Actually, now that I'm thinking about it, is this some sort of face culling problem? Like is the inside layer being treated as something behind the outer layer that then doesn't need rendering? Maybe your cullface parameters in your model are causing this issue. 

 

Anyway, I'm not an expert in this area so just giving ideas. 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

21 hours ago, Jantek said:

I made a test by changing the size of the boxes of both layers to 10 pixels. Nothing changed.

 

I actually had the same problem more than once while using eclipse and notepad++ as editor. The problem was, that eclipse apparently holds a cached version of textfiles in its memory or something, putting the cached version to the exceuted mod. The solution I found to always have the freshest, is to select the resources folder in eclipse and press F5 (refresh) once. After that I can start the game and the model is changed properly. The same thing is with textures. Edited outside, they doesn't seem to be taken over except when refreshing the resource folder.

 

Maybe worth a try.

  • Like 1
Link to comment
Share on other sites

Fixed. As SatyPardus said, the problem happened to be so simple and stupid in fact. I was using Eclipse for coding and Notepad++ for  json files. But Eclipse doesn't always sync well with changes in the OS file system without manually refreshing. The strange behaviour was caused by the cache of Eclipse. I once thought I fixed the problem using ModelLoader.setCustomModelResourceLocation() but the point is, it forced me to copy the model also to the item folder and I did copying within Eclipse so it forced the Eclipse to reload the file and BAM! it works.

A really big pain in the ass if one is aware of this behaviour. 

Man, I was hard trying like everything for few days just because I didn't press F5...

screen dziala git.jpg

Link to comment
Share on other sites

20 minutes ago, Jantek said:

But Eclipse doesn't always sync well with changes in the OS file system without manually refreshing. The strange behaviour was caused by the cache of Eclipse.

First: http://shouldiblamecaching.com/

Second: Go to the Eclipse marketplace and download the JSON Editor plugin. Edit your JSON files inside Eclipse, then Eclipse will know that they've changed.

  • Like 2

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.

Link to comment
Share on other sites

43 minutes ago, Jantek said:

 But Eclipse doesn't always sync well with changes in the OS file system without manually refreshing. The strange behaviour was caused by the cache of Eclipse.

Or you could also refresh your projects in eclipse.

Just press "ALT+P+N" and "ENTER" :P

Always looking for new challenges, and happy to help the people where ever I can

Link to comment
Share on other sites

  • 11 months later...

Or you could use IntelliJ

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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