Jump to content

Recommended Posts

Posted (edited)

Hi!

 

So, I'm pretty new to modding so bare with me. I've created a block for testing purposes called "Town Centre". I've then created 3 json files: 1 under blockstates, 1 under models/block, and 1 under models/item. When I test it in game, I just see the un-textured block as the black/purple no texture thing.

 

Blockstates:

{
    "variants": {
        "normal": [
            { "model": "xmt:townCentre" }
     ]
    }
}

Models/Block:

{
    "parent": "block/cube_all",
    "textures": {
        "all": "xmt:blocks/townCentre"
    }
}

Models/Item:

{
    "parent": "block/cube_all",
    "textures": {
        "all": "xmt:blocks/townCentre"
     }
}

 

Here is my ModBlocks.java file:

https://pastebin.com/mXtaDZX2

 

Here is my BlocktownCentre.java file:

https://pastebin.com/sSqNraRy

 

Here is the full log from the Minecraft test run:

https://pastebin.com/8azSBBhP

 

Thanks for the help!

Edited by xXJamie_Xx
  • Replies 58
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted
1 hour ago, Jay Avery said:

All asset names must be completely lower case - names of blockstates files, models, and textures.

I changed everything to lowercase but the problem still persists.

Posted (edited)

Do not use ItemModelMesher(Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register). It is outdated, causes bugs and obscure issues. The tutorial you saw that told you to use it is outdated. Use ModelLoader.

Blocks and items must be registered at least during pre-init. 

Models must be registered at least during pre-init. 

The best way would be to use forge's registry events to register your things.


Caused by: java.io.FileNotFoundException: xmt:blockstates/blocktowncentre.json

*looks at the screenshot posted*

xmt -> blockstates -> towncentre.json

Your blockstates file name does not match your registry name. Same goes for your itemblock as you are using the same registry name.

Edited by V0idWa1k3r
Posted (edited)
1 hour ago, V0idWa1k3r said:

Do not use ItemModelMesher. It is outdated, causes bugs and obscure issues. The tutorial you saw that told you to use it is outdated. Use ModelLoader.

Blocks and items must be registered at least during pre-init. 

Models must be registered at least during pre-init. 

The best way would be to use forge's registry events to register your things.

 


Caused by: java.io.FileNotFoundException: xmt:blockstates/blocktowncentre.json

*looks at the screenshot posted*

xmt -> blockstates -> towncentre.json

Your blockstates file name does not match your registry name. Same goes for your itemblock as you are using the same registry name.

Hi, I understand the second point you made, the tutorial was made back in January so things have obviously changed but would you be able to elaborate on that first point though?

Edited by xXJamie_Xx
Posted (edited)

Which part of it? :D

I am not sure at which stage you are registering your blocks/items as the method is called init, so I explicitly told you that you must at least register them at pre-init to avoid issues. You should really use forge's registry events(RegistryEvent.Register) - they are nicer and more understandable and guarantee that everything loads as needed. They are normal events that you can listen to using SubscribeEvent.

You are currently registering the model for your itemblock using ItemModelMesher(Minecraft.getMinecraft().getRenderItem().getItemModelMesher()). Do not. It is buggy and forge has an alternative called ModelLoader. Just call ModelLoader::setCustomModelResourceLocation. Does the same thing but without bugs or issues ;)

Edited by V0idWa1k3r
Posted
1 hour ago, V0idWa1k3r said:

Which part of it? :D

I am not sure at which stage you are registering your blocks/items as the method is called init, so I explicitly told you that you must at least register them at pre-init to avoid issues. You should really use forge's registry events(RegistryEvent.Register) - they are nicer and more understandable and guarantee that everything loads as needed. They are normal events that you can listen to using SubscribeEvent.

You are currently registering the model for your itemblock using ItemModelMesher(Minecraft.getMinecraft().getRenderItem().getItemModelMesher()). Do not. It is buggy and forge has an alternative called ModelLoader. Just call ModelLoader::setCustomModelResourceLocation. Does the same thing but without bugs or issues ;)

So if I understand you right, you are referring to this line:

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));

You are saying just to replace that line with this:?

ModelLoader::setCustomModelResourceLocation

 

Posted

Well, not with that directly, that is just the way to write method names (classname::methodname) I usually use. Maybe something like

ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));

 

Posted (edited)
1 hour ago, V0idWa1k3r said:

Well, not with that directly, that is just the way to write method names (classname::methodname) I usually use. Maybe something like


ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));

 

oh sorry, I wasn't thinking properly lol, I can see the difference, the previous piece of code made it so the untextured item was being shown in the middle of the screen and stuff so it was weird.  Also, the first point you brought up about which stage I was registering my blocks/items.

I already register them at pre-init with the following code:

	@EventHandler
	public void preInit(FMLPreInitializationEvent event)
	{
		ModItems.init();
		ModItems.register();
		
		ModBlocks.init();
		ModBlocks.register();
	}

 

Edited by xXJamie_Xx
Posted
1 hour ago, Jay Avery said:

All asset names must be completely lower case - names of blockstates files, models, and textures.

Was this a change in 1.11?  Because that's not true in 1.10.  Just want to know for when I update my mod to 1.11.

Posted
Just now, Malkierian said:

Was this a change in 1.11?  Because that's not true in 1.10.  Just want to know for when I update my mod to 1.11.

I think it was only enforced in 1.11+ (but was recommended before then).

Posted
1 hour ago, Malkierian said:

Was this a change in 1.11?  Because that's not true in 1.10.  Just want to know for when I update my mod to 1.11.

Although I cannot say for definite, I could almost be sure I heard another mod dev say that they had to do this for their mod so I believe this statement could be true.

Posted
1 hour ago, Jay Avery said:

I think it was only enforced in 1.11+ (but was recommended before then).

I still can't get the texture to load. I assume all the json files need to have "blocktowncentre" as the model/textures?

Posted
1 minute ago, xXJamie_Xx said:

I still can't get the texture to load. I assume all the json files need to have "blocktowncentre" as the model/textures?

Show your most up-to-date log and file structure. The names don't all have to be the same, they just have to be pointing to the correct resources. The blockstates file has to be the block's registry name, but the models it directs to can have any name - as long as there is a valid model file at that location. Similarly, the textures used in a model file can have any name, they just have to actually be there.

Posted
1 hour ago, V0idWa1k3r said:

Post your new log after you've made the changes.

 

1 hour ago, Jay Avery said:

Show your most up-to-date log and file structure. The names don't all have to be the same, they just have to be pointing to the correct resources. The blockstates file has to be the block's registry name, but the models it directs to can have any name - as long as there is a valid model file at that location. Similarly, the textures used in a model file can have any name, they just have to actually be there.

Latest Log: https://pastebin.com/8EpWjU7Z

File Structure: c6ZdL0h.png

Posted

Caused by: java.io.FileNotFoundException: xmt:blockstates/blocktowncentre.json

Uh, you either needed to rename the asset name or your registry name, not both :D

Your registry name and asset name must match, as I've said.

Posted
Quote

Caused by: java.io.FileNotFoundException: xmt:models/item/blocktowncentre.json

This is the file it's looking for to get the item model. Do you have an item model file at this location? (Hint: you don't)

 

Quote

Caused by: java.io.FileNotFoundException: xmt:blockstates/blocktowncentre.json

This is the file it's looking for to get the blockstates. Do you have a blockstates file at this location? (Hint: you don't)

Posted
1 hour ago, Kokkie said:

You haven't changed the name...

In your blockstates folder change the name of towncentre.json to blocktowncentre.json and the same for your model.

 

1 hour ago, V0idWa1k3r said:

Caused by: java.io.FileNotFoundException: xmt:blockstates/blocktowncentre.json

Uh, you either needed to rename the asset name or your registry name, not both :D

Your registry name and asset name must match, as I've said.

 

1 hour ago, Jay Avery said:

This is the file it's looking for to get the item model. Do you have an item model file at this location? (Hint: you don't)

 

This is the file it's looking for to get the blockstates. Do you have a blockstates file at this location? (Hint: you don't)

I think the issue is that the json files are called towncentre.json instead of blocktowncentre.json.

Posted
Just now, xXJamie_Xx said:

 

 

I think the issue is that the json files are called towncentre.json instead of blocktowncentre.json.

Yes, I think so too. Maybe you could try changing the file names?

Posted
1 hour ago, Jay Avery said:

Yes, I think so too. Maybe you could try changing the file names?

 

1 hour ago, Kokkie said:

Indeed it is...

I have changed the file names to "blocktowncentre.json", I have noticed that the texture now shows when the block is placed in the world but not in the players inventory. The latest log file or console do not show any errors.

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.