Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.15.2] Try to register custom item model
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
Liahim

[1.15.2] Try to register custom item model

By Liahim, July 28, 2020 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Liahim    1

Liahim

Liahim    1

  • Tree Puncher
  • Liahim
  • Members
  • 1
  • 22 posts
Posted July 28, 2020 (edited)

Hi!
I am creating several items with a random name and want to assign a model to them.

In the ModelBakeEvent I register a model for them. And everything works well. But the registry event fires earlier and it spammy my console:

[Server-Worker-3/WARN] [minecraft/ModelBakery]: Unable to load model: 'mod:item1#inventory' referenced from: mod:item1#inventory: java.io.FileNotFoundException: mod:models/item/item1.json

How can I prevent this?

Note: I can't create a .json model because the name is random.

Edited July 28, 2020 by Liahim
  • Like 1
  • Quote

Sorry, I don't speak English very well...

Share this post


Link to post
Share on other sites

AreUThreateningMe    1

AreUThreateningMe

AreUThreateningMe    1

  • Tree Puncher
  • AreUThreateningMe
  • Members
  • 1
  • 17 posts
Posted July 28, 2020 (edited)

What do you mean the name is random? The unlocalized name shouldn't be random, how do you register your item?

Edited July 28, 2020 by AreUThreateningMe
  • Quote

Share this post


Link to post
Share on other sites

Liahim    1

Liahim

Liahim    1

  • Tree Puncher
  • Liahim
  • Members
  • 1
  • 22 posts
Posted July 28, 2020 (edited)

Based on an external json-file.

And I don't know what can be written into it.

Edited July 28, 2020 by Liahim
  • Quote

Sorry, I don't speak English very well...

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15995 posts
Posted July 28, 2020

That is not how the game works.

The registry name should always be compile-time-constant. The fact that registry events run before your mod has access to Forge-supplied configs is intentional. Do not try and work around the system. If you want an item with a randomized display name, then override the appropriate methods to return a randomized display name, but do not fuck with its registry name.

  • Quote

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.

Share this post


Link to post
Share on other sites

Liahim    1

Liahim

Liahim    1

  • Tree Puncher
  • Liahim
  • Members
  • 1
  • 22 posts
Posted July 28, 2020

I don't want a random name, I want to register the model via code.

And no spam to the console.

How can I do this?

  • Quote

Sorry, I don't speak English very well...

Share this post


Link to post
Share on other sites

hohserg    3

hohserg

hohserg    3

  • Tree Puncher
  • hohserg
  • Members
  • 3
  • 39 posts
Posted July 28, 2020 (edited)

I try to assume more clearer.

Liahim want to set custom implementation of baked model for some item.

This item dont have base json model.

Missing of json model is desirable behavior.

And he ask: how to remove warnings from log?

Edited July 28, 2020 by hohserg
  • Like 1
  • Quote

Share this post


Link to post
Share on other sites

Liahim    1

Liahim

Liahim    1

  • Tree Puncher
  • Liahim
  • Members
  • 1
  • 22 posts
Posted July 28, 2020

1. I register my items in the RegistryEvent.Register<Item>.
2. At the moment I already have the required list of names and these are constants.

3. I register my item models in the ModelBakeEvent.

4. Everything works well.

The result is spam...

  • Quote

Sorry, I don't speak English very well...

Share this post


Link to post
Share on other sites

diesieben07    7695

diesieben07

diesieben07    7695

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7695
  • 56361 posts
Posted July 28, 2020
19 minutes ago, Liahim said:

I register my item models in the ModelBakeEvent.

This is your problem. Do not do this.

Make a custom model loader (IModelLoader) and reference it from your JSON model file.

  • Quote

Share this post


Link to post
Share on other sites

Liahim    1

Liahim

Liahim    1

  • Tree Puncher
  • Liahim
  • Members
  • 1
  • 22 posts
Posted July 28, 2020

What if I don't know the name of an item (for example, it's an item from another mod) to create a JSON model file for it?

  • Quote

Sorry, I don't speak English very well...

Share this post


Link to post
Share on other sites

diesieben07    7695

diesieben07

diesieben07    7695

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7695
  • 56361 posts
Posted July 28, 2020

Just because an item is from a different mod does not mean you don't know it's name. This is what registry names are for: they are a unique, global identifier for the registry object.

  • Quote

Share this post


Link to post
Share on other sites

Liahim    1

Liahim

Liahim    1

  • Tree Puncher
  • Liahim
  • Members
  • 1
  • 22 posts
Posted July 28, 2020

And this means that for each such item I have to create a model with my hands?
There is no other way?

The goal was to automate the process.
I cannot know which mod will be installed with mine.

  • Quote

Sorry, I don't speak English very well...

Share this post


Link to post
Share on other sites

diesieben07    7695

diesieben07

diesieben07    7695

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7695
  • 56361 posts
Posted July 28, 2020

You are a programmer, automate the process of writing the JSON files.

You can use data generators for this, which is Mojang's "framework" (enhanced and made available to mods) for generating JSON files for various things (models, block states, recipes, etc.).

 

3 minutes ago, Liahim said:

I cannot know which mod will be installed with mine.

That's fine. You can ship with models for items which will then not be present. The game will just ignore your models in that case. But it'll go looking for them (and find them) if the items are present (i.e. the other mod is installed).

  • Like 1
  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • LexManos
      forge a jar file not exe

      By LexManos · Posted 31 minutes ago

      Some zip managers like to take control of the .jar file extension away from Java. Make sure you have Java installed and try running Jarfix once, then try the installer again.   Also, 1.12 is out of support, update.
    • Modder31
      forge a jar file not exe

      By Modder31 · Posted 36 minutes ago

      i am unable to install jar files only exe files i would ask if you could change all the files to exe files, like the older versions i want the most recent version of 1.12.2 for a certain mod but cant cause its a jar file
    • diesieben07
      Forge says this file does not have an app associated with it.

      By diesieben07 · Posted 53 minutes ago

      Make sure you have Java installed.
    • ESCCarp
      Forge says this file does not have an app associated with it.

      By ESCCarp · Posted 1 hour ago

      When i try to install forge it says "This file does not have a app associated with it for preforming this action". Please help me fix it i really want to play with my friends on modded servers.
    • LexManos
      Minecraft Unexpected error on 1.7.10 forge modded

      By LexManos · Posted 1 hour ago

      1.7 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
  • Topics

    • Modder31
      1
      forge a jar file not exe

      By Modder31
      Started 36 minutes ago

    • ESCCarp
      1
      Forge says this file does not have an app associated with it.

      By ESCCarp
      Started 1 hour ago

    • JaydenB14
      1
      Minecraft Unexpected error on 1.7.10 forge modded

      By JaydenB14
      Started 2 hours ago

    • Molotove_
      1
      Problem adding RAM to a Forge Server

      By Molotove_
      Started 3 hours ago

    • Ariel David
      2
      Do i need minecraft installed

      By Ariel David
      Started 4 hours ago

  • Who's Online (See full list)

    • diesieben07
    • P3pp3rF1y
    • Sweeby
    • shadowfox
    • LexManos
    • hammy3502
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.15.2] Try to register custom item model
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community