Jump to content

[1.12.2] Weird missing model variant error (#null/inventory)


Recommended Posts

Posted

Okay, so I have a mod that creates "invisible" tile entities that do not go onto any creative tab. I think I initially didn't make any block state variant for "inventory" but I think that gave me some errors. So I added the "inventory" to my block state and registered accordingly. However, I must have screwed something up because (although the game works) I'm getting error in the console:

 

[09:07:05] [main/ERROR] [FML]: Exception loading model for variant movinglightsource:null#inventory for items ["movinglightsource:movinglightsource_11", "movinglightsource:movinglightsource_12", "movinglightsource:movinglightsource_13", "movinglightsource:movinglightsource_14", "movinglightsource:movinglightsource_15", "movinglightsource:movinglightsource", "movinglightsource:movinglightsource_7", "movinglightsource:movinglightsource_9"], normal location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model movinglightsource:item/null with loader VanillaLoader.INSTANCE, skipping

 

The whole console log is:

  Reveal hidden contents


So the blockstate JSON is simple:

{
    "forge_marker": 1,
    "variants": {
        "normal": { "model": "movinglightsource:movinglightsource" },
        "inventory": { "model": "movinglightsource:movinglightsource" }
    }
}

 

And block model JSON is simple:

{      

    "textures": 
    {
        "pole": "blocks/log_big_oak"
    },
   "elements":[  
      {  
         "__comment":"basically make it have no surface area so it is invisible", 
         "from":[ 0.5, 0.5, 0.5 ],
         "to":[ 0.5, 0.5, 0.5 ],
         "faces":{  
            "down":{ "uv": [ 0, 0, 15, 15 ], "texture":"#pole" },
            "up":{ "uv": [ 0, 0, 15, 15 ], "texture": "#pole" },
            "north":{ "uv": [ 0, 0, 15, 15 ], "texture":"#pole" },
            "south":{ "uv": [ 0, 0, 15, 15 ], "texture":"#pole" },
            "west":{ "uv": [ 0, 0, 15, 15 ], "texture":"#pole" },
            "east":{ "uv": [ 0, 0, 15, 15 ], "texture":"#pole" }
         }
      }
   ]
}

 

and the item model JSON is simple:

{
    "parent": "movinglightsource:block/movinglightsource",
    "display": {
        "thirdperson": {
            "rotation": [ 10, -45, 170 ],
            "translation": [ 0, 1.5, -2.75 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        }
    }
}

 

And here is my class that does all the registration:

  Reveal hidden contents

 

Summary -- what does the "null" in the "variant movinglightsource:null#inventory for items" error mean? -- what is that looking for?

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

Posted (edited)
  On 10/14/2018 at 4:27 PM, jabelar said:

public final static BlockMovingLightSource movinglightsource = null;
    public final static BlockMovingLightSource movinglightsource_15 = null;
    public final static BlockMovingLightSource movinglightsource_14 = null;
    public final static BlockMovingLightSource movinglightsource_13 = null;
    public final static BlockMovingLightSource movinglightsource_12 = null;
    public final static BlockMovingLightSource movinglightsource_11 = null;
    public final static BlockMovingLightSource movinglightsource_9 = null;
    public final static BlockMovingLightSource movinglightsource_7 = null;

Expand  

First off never visually instantiated. Which will cause an issue.

 

Edited by Animefan8888

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Try not registering null items.

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 (edited)
  On 10/14/2018 at 4:39 PM, Draco18s said:

Try not registering null items.

Expand  

If only I had thought of that! ?, but the weird thing is that it seems to know what the item is -- the item itself isn't null at least according to the error message:

 

[09:07:05] [main/ERROR] [FML]: Exception loading model for variant movinglightsource:null#inventory for items ["movinglightsource:movinglightsource_11", "movinglightsource:movinglightsource_12", "movinglightsource:movinglightsource_13", "movinglightsource:movinglightsource_14", "movinglightsource:movinglightsource_15", "movinglightsource:movinglightsource", "movinglightsource:movinglightsource_7", "movinglightsource:movinglightsource_9"], normal location exception: 
 

So it is the item variant that seems to be null. But the weird thing is that the block (and related item block) don't have any intended variants. Obviously I have done something to make it think there are variants somehow, but my block has no Property that would create non-default variants.

 

I know with JSON it is usually just a simple typographical error, but just looking at where to look for this error. Why would it think there is a variant "#null/inventory" based on my JSONs? I will try to trace my registry code execution to see if a null occurs there, but just seems weird as I use the same code setup a lot without this error.

Edited by jabelar

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

Posted
  On 10/14/2018 at 5:20 PM, jabelar said:

I know with JSON it is usually just a simple typographical error, but just looking at where to look for this error. Why would it think there is a variant "#null/inventory" based on my JSONs? I will try to trace my registry code execution to see if a null occurs there, but just seems weird as I use the same code setup a lot without this error.

Expand  

I believe it is the registry name that is null.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted (edited)
  On 10/14/2018 at 5:33 PM, Animefan8888 said:

I believe it is the registry name that is null.

Expand  

But if you look at that line of the error message it says the error is for a list of items that it properly lists out their registry names. So it is saying the problem variant is #null/inventory for a number of items which it then lists out.

 

I'll work on figuring this out, but just trying to see if anyone knows where best to look since JSON can fail in so many ways.

 

I THINK the proper way is to register an ItemBlock for a Block and I think that then the item will try to match models for each blockstate of the associated block. In my case though I don't have any custom blockstates, so it is just about the default model types (I think), which includes "inventory". I am registering the block and the item block with same registry name and I think I have the @ObjectHolder reference names matching. But of course all it takes is one typo for any of these strings to not match....

Edited by jabelar

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

Posted
  On 10/14/2018 at 4:27 PM, jabelar said:

movinglightsource:item/null

Expand  

modid:item(folder)/filename

  On 10/14/2018 at 4:27 PM, jabelar said:

movinglightsource:null#inventory

Expand  

modid:filename#variant

 

filename = your registry name for your block/item

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

All the item blocks seem to be registered. If, in the init stage, I dump all the registered items with:

        System.out.println("All registered items = "+ForgeRegistries.ITEMS.getEntries());

 

The console output lists all my items:

movinglightsource:movinglightsource=net.minecraft.item.ItemBlock@12919b7b, movinglightsource:movinglightsource_15=net.minecraft.item.ItemBlock@4901ff51, movinglightsource:movinglightsource_14=net.minecraft.item.ItemBlock@3033e54c, movinglightsource:movinglightsource_13=net.minecraft.item.ItemBlock@e31d9c2, movinglightsource:movinglightsource_12=net.minecraft.item.ItemBlock@10e5c13c, movinglightsource:movinglightsource_11=net.minecraft.item.ItemBlock@56584f06, movinglightsource:movinglightsource_9=net.minecraft.item.ItemBlock@796ed904, movinglightsource:movinglightsource_7=net.minecraft.item.ItemBlock@7991e022

 

So there does appear to be registered item with corresponding expected registry name for all my blocks.

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

Posted
  On 10/14/2018 at 6:42 PM, jabelar said:

So there does appear to be registered item with corresponding expected registry name for all my blocks.

Expand  

I don't see how this is possible seeing as how none of your Block fields are instantiated and you base all of your Items off of those fields.

  On 10/14/2018 at 4:27 PM, jabelar said:

public final static BlockMovingLightSource movinglightsource = null;
    public final static BlockMovingLightSource movinglightsource_15 = null;
    public final static BlockMovingLightSource movinglightsource_14 = null;
    public final static BlockMovingLightSource movinglightsource_13 = null;
    public final static BlockMovingLightSource movinglightsource_12 = null;
    public final static BlockMovingLightSource movinglightsource_11 = null;
    public final static BlockMovingLightSource movinglightsource_9 = null;
    public final static BlockMovingLightSource movinglightsource_7 = null;

Expand  

 

  On 10/14/2018 at 4:27 PM, jabelar said:

        public static void onEvent(final RegistryEvent.Register<Block> event)
        {
            final IForgeRegistry<Block> registry = event.getRegistry();
            
            registry.register(new BlockMovingLightSource("movinglightsource"));
            registry.register(new BlockMovingLightSource("movinglightsource_15", 1.0F));
            registry.register(new BlockMovingLightSource("movinglightsource_14", 14.0F / 15.0F));
            registry.register(new BlockMovingLightSource("movinglightsource_13", 13.0F / 15.0F));
            registry.register(new BlockMovingLightSource("movinglightsource_12", 12.0F / 15.0F));
            registry.register(new BlockMovingLightSource("movinglightsource_11", 11.0F / 15.0F));
            registry.register(new BlockMovingLightSource("movinglightsource_9", 9.0F / 15.0F));
            registry.register(new BlockMovingLightSource("movinglightsource_7", 7.0F / 15.0F));
        }
        public static void registerItemBlocks(final RegistryEvent.Register<Item> event)
        {
            final IForgeRegistry<Item> registry = event.getRegistry();

            registry.register(Utilities.setItemName(new ItemBlock(movinglightsource), movinglightsource.getRegistryName().getPath()));
            registry.register(Utilities.setItemName(new ItemBlock(movinglightsource_15), movinglightsource_15.getRegistryName().getPath()));
            registry.register(Utilities.setItemName(new ItemBlock(movinglightsource_14), movinglightsource_14.getRegistryName().getPath()));
            registry.register(Utilities.setItemName(new ItemBlock(movinglightsource_13), movinglightsource_13.getRegistryName().getPath()));
            registry.register(Utilities.setItemName(new ItemBlock(movinglightsource_12), movinglightsource_12.getRegistryName().getPath()));
            registry.register(Utilities.setItemName(new ItemBlock(movinglightsource_11), movinglightsource_11.getRegistryName().getPath()));
            registry.register(Utilities.setItemName(new ItemBlock(movinglightsource_9), movinglightsource_9.getRegistryName().getPath()));
            registry.register(Utilities.setItemName(new ItemBlock(movinglightsource_7), movinglightsource_7.getRegistryName().getPath()));
        }

Expand  

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

I don't see how this is possible seeing as how none of your Block fields are instantiated .

 

You need to study the concept of @ObjectHolder annotation. All those null fields are populated in several passes between the registry events. If you watch the console in your mods you'll see a bunch of FML messages saying "Applying holder lookups" then "Holder lookups applied".

 

Basically what happens is that after the block registry event, your code is scanned for @ObjectHolder annotations. Wherever the type and name (i.e. the actual field name in Java, no string needed) match, the null field will get populated FROM the registry. Then the process is repeated for items after they are registered.

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

Posted
  On 10/14/2018 at 6:54 PM, jabelar said:

You need to study the concept of @ObjectHolder annotation. All those null fields are populated in several passes between the registry events.

Expand  

Those fields @Animefan8888 is talking about are not annotated with @ObjectHolder though as far as I can see.

 

  On 10/14/2018 at 4:27 PM, jabelar said:

public final static BlockMovingLightSource movinglightsource = null;
    public final static BlockMovingLightSource movinglightsource_15 = null;
    public final static BlockMovingLightSource movinglightsource_14 = null;
    public final static BlockMovingLightSource movinglightsource_13 = null;
    public final static BlockMovingLightSource movinglightsource_12 = null;
    public final static BlockMovingLightSource movinglightsource_11 = null;
    public final static BlockMovingLightSource movinglightsource_9 = null;
    public final static BlockMovingLightSource movinglightsource_7 = null;

Expand  

 

Posted (edited)
  On 10/14/2018 at 6:57 PM, V0idWa1k3r said:

Those fields @Animefan8888 is talking about are not annotated with @ObjectHolder though as far as I can see.

 

 

Expand  

They don't need to be -- the whole class is. You only need annotation on the field if the Java name doesn't match the registry name. For item blocks I'm appending "itemblock_" to the Java field names so do need the @ObjectHolder annotation directly on each field.

Edited by jabelar

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

Posted (edited)

Just to emphasize that the object holder instantiation works (i.e. the blocks are not null at time I try to register item block models), I put a debug print in my registerItemBlocks() method. The method is now:

    @SideOnly(Side.CLIENT)
    public static void registerItemBlockModel(ItemBlock parBlock, int parMetaData)
    {
//        // DEBUG
        System.out.println("Registering item block model for"
                + ": " + parBlock.getRegistryName());
        
        ModelLoader.setCustomModelResourceLocation(parBlock, parMetaData,
                new ModelResourceLocation(parBlock.getRegistryName(), "inventory"));
    }

 

And the output is:

[11:49:06] [main/INFO] [STDOUT]: [com.blogspot.jabelarminecraft.movinglightsource.registries.BlockRegistry:registerItemBlockModel:191]: Registering item block model for: movinglightsource:movinglightsource
[11:49:06] [main/INFO] [STDOUT]: [com.blogspot.jabelarminecraft.movinglightsource.registries.BlockRegistry:registerItemBlockModel:191]: Registering item block model for: movinglightsource:movinglightsource_15
[11:49:06] [main/INFO] [STDOUT]: [com.blogspot.jabelarminecraft.movinglightsource.registries.BlockRegistry:registerItemBlockModel:191]: Registering item block model for: movinglightsource:movinglightsource_14
[11:49:06] [main/INFO] [STDOUT]: [com.blogspot.jabelarminecraft.movinglightsource.registries.BlockRegistry:registerItemBlockModel:191]: Registering item block model for: movinglightsource:movinglightsource_13
[11:49:06] [main/INFO] [STDOUT]: [com.blogspot.jabelarminecraft.movinglightsource.registries.BlockRegistry:registerItemBlockModel:191]: Registering item block model for: movinglightsource:movinglightsource_12
[11:49:06] [main/INFO] [STDOUT]: [com.blogspot.jabelarminecraft.movinglightsource.registries.BlockRegistry:registerItemBlockModel:191]: Registering item block model for: movinglightsource:movinglightsource_11
[11:49:06] [main/INFO] [STDOUT]: [com.blogspot.jabelarminecraft.movinglightsource.registries.BlockRegistry:registerItemBlockModel:191]: Registering item block model for: movinglightsource:movinglightsource_9
[11:49:06] [main/INFO] [STDOUT]: [com.blogspot.jabelarminecraft.movinglightsource.registries.BlockRegistry:registerItemBlockModel:191]: Registering item block model for: movinglightsource:movinglightsource_7

 

In other words, when it goes to register the item block model, the actual block must exist (non null) since it returns a registry name (which is also correct). It doesn't try to register any custom model for a "null:inventory" resource location...

Edited by jabelar

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

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.