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




  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • that happens every time I enter a new dimension.
    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } my entire project:https://github.com/kevin051606/DERP-Mod/tree/Derp-1.0-1.20
  • Topics

×
×
  • Create New...

Important Information

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