Jump to content

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


Recommended Posts

Posted (edited)

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
Posted

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
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?

Posted

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/

Posted
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.

Posted
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/

Posted
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
Posted

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

Posted
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.

Posted
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

  • 11 months later...
Posted

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)

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

    • I want to create block with entity, that will have height of 3 or more(configurable) and I tried to change first VoxelShape by increasing collision box on height I want and for changing block height on visual side i tried to configure BlockModelBuilder:  base.element() .from(0, 0, 0) .to(16f, 48f, 16f) .face(Direction.UP).texture("#top").end() .face(Direction.DOWN).texture("#bottom").end() .face(Direction.NORTH).texture("#side").end() .face(Direction.SOUTH).texture("#side").end() .face(Direction.WEST).texture("#side").end() .face(Direction.EAST).texture("#side").end() .end(); but, getting crash with next error: Position y out of range, must be within [-16, 32]. Found: %d [48.0]; Looks like game wont to block height modified by more than 32. Is there any way to fix that problem?
    • As long as the packets you are sending aren't lost, there's nothing wrong with what you're currently doing. Although, this sounds like something that would benefit from you making your own datapack registry instead of trying to arbitrarily sync static maps. Check out `DataPackRegistryEvent.NewRegistry`.
    • Hey all, I've been working a lot with datapacks lately, and I'm wondering what the most efficient way to get said data from server to client is.  I'm currently using packets, but given that a lot of the data I'm storing involves maps along the lines of Map<ResourceLocation, CustomDataType>, it can easily start to get messy if I need to transmit a lot of that data all at once. Recently I started looking into the ReloadableServerResources class, which is where Minecraft stores its built-ins.  I see you can access it via the server from the server's resources.managers, and it seems like this can be done even from the client to appropriately retrieve data from the server, unless I'm misunderstanding.  However, from what I can tell, this only works via built-in methods such as getRecipeManager() or getLootTables(), etc.  These are all SimpleJsonResourceReloadListeners, just like my datapack entries are, so it seems like it could be possible for me to access my datapack entries similarly?  But I don't see anywhere in ReloadableServerResources that stores loaded modded entries, so either I'm looking in the wrong place or it doesn't seem to be a thing. Are packets really the best way of doing this, or am I missing a method that would let me use ReloadableServerResources or something similar?
    • Hi, everyone! I'm new to minecraft modding stuff and want ask you some questions. 1. I checked forge references and saw there com.mojang and net.minecraft (not net.minecraftforge) and as I understand it's original game packages with all minecraft logic inside including renderers and so on, right? 2. Does it mean that forge has a limited set of instruments which doesn't cover all the aspects of the game? If make my question more specific then does forge provide such instruments that allow me totally change minecraft itself, like base mechanics and etc.? Or I have to use "original game packages" to implement such things? 3. I actively learning basic concepts with forge documentation and tutorials. So in my plans make different inventory system like in diabloids. Is that possible with forge? 4. It is last question related to the second one. So how deeply I can change minecraft with forge? I guess all my questions above because of that I haven't globally understanding what forge is and how it works inside and how it works with minecraft. It would be great if you provide some links or topics about it or explain it by yourself but I guess it's to big to be explained in that post at once. Anyway, thank you all for any help!
    • Im trying add to block a hole in center, just a usual block and in center of it on up side, there is should be a hole. I tried to add it via BlockModelBuilder, but its not working. Problem is that it only can change block size outside. I tried it to do with VoxelShape and its working, but its has been on server side and looks like its just changed collision shape, but for client, there is a texture covering this hole. I tried to use: base.renderType("cutout"); and removed some pixels from texture. I thought its should work, but game optimization makes block inside looks transparent. So, only custom model?
  • Topics

×
×
  • Create New...

Important Information

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