Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8.9] Different item model for inventory/held in hand


Roboguy99
 Share

Recommended Posts

  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

No, I mean you must return the result of getting the Model for a ResourceLocatino that is NOT your IPAM.

 

Ah, right. I see what you're saying.

So the problem is, currently I'm setting the model to itself, which you obviously can't do.

 

How do I actually get the model then?

 

Bare in mind that this is the first time, other than learning how to give an item a texture yesterday, that I've used any of the 'new' 1.8 rendering system. I am pretty confused right now :|

I have no idea what I'm doing.

Link to comment
Share on other sites

How do I actually get the model then?

You do it just 2 lines above...

 

Maybe I'm brain-dead, but I'm still not getting you.

 

When you say return, are you referring to setting

model

on the else line or the actual method return? What's the significant difference between those two lines? If I simply return the model from the first of the 2 lines, I get the same crash. Why? What were Mojang thinking when they switched to blockstates from the perfectly adequate previous system?

 

Apologies for the high-levels of brain-deaded-ness and inevitable face-palms

I have no idea what I'm doing.

Link to comment
Share on other sites

I'd like to say this is over and I get it, but I still don't. I slept on it, came back to it and I still can't make proper sense of what you're saying. I feel like this thread has reached a point where we're getting nowhere. As much as I hate to say this, I think it might just benefit the both of us if you just outright tell me what should be where.

 

Basically I don't understand what the significant difference between those two lines is - surely they both point to a JSON model? Also, if I hard-code the return of the first one, the game still crashes with the same error. Maybe I'm still not getting it at all.

 

Sorry...

I have no idea what I'm doing.

Link to comment
Share on other sites

Basically I don't understand what the significant difference between those two lines is - surely they both point to a JSON model?
No, they do not!

The first one does, as indicated by the red arrow.

 

However the 2nd one (as far as I can see it) points to your loader. But now that I check your loader again, it is completely broken. Do not store anything in fields in your loader! Also the loader is intercepting every single one of your item models to be loaded. This is bad!!

 

Again, here is the process:

- Bind Item to IPAM's location using setCustomModelResourceLocation

- Check for that location in the loader and return the IModel that then produces the IPAM.

- Reference two different JSON models from the IPAM using the methods you already use. These JSON models must be registered using registerItemVariants. You do NOT need to register the IPAM's model using registerItemVariants (currently you do, don't).

 

Edit:

I made you something in paint:

 

9f6spi9.png

 

Link to comment
Share on other sites

That image helped a lot, and cleared quite a bit up, but I still don't understand *how* I should be "choosing the proper JSON model" for each element. After quite a lot of thinking (maybe over-thinking) and researching, I've possibly understood what you mean.

But probably not.

 

Here goes:

 

Do I need to have 2 JSON models - one which points straight to the texture for when the item is held, and one which points to all of the element JSON files (like how fire works, I think...)?

 

Or:

 

Do I just need to change the syntax of that second line? If so, could you please tell me EXACTLY what it should be. My understanding of the JSON model system is (evidently) very lacking, so although I'm understanding what you're saying, I don't know what I actually should be doing to fix it.

 

Or:

 

Something else? If so, how am I doing such a bad job of understanding what on earth is going on?

 

I feel at this point, before I'm banned from the modding community forever for sheer stupidity and you quit the forums due to frustration (there must be people worse than me sometimes, no?), we need to get this over and done with. Again, I'm sorry for the pain you undergo.

I have no idea what I'm doing.

Link to comment
Share on other sites

Ok, so.

There are 3 models here. One for when the item is held (might be different for each type of item, but I will ignore that for now). One for when the item is rendered everywhere else. These two are not bound to any item at all.

 

Then there is your IPAM Model, which you bind to your Item. This model then selects (based on held or not) one of the other two models.

Link to comment
Share on other sites

Ok, so.

There are 3 models here. One for when the item is held (might be different for each type of item, but I will ignore that for now). One for when the item is rendered everywhere else. These two are not bound to any item at all.

 

Then there is your IPAM Model, which you bind to your Item. This model then selects (based on held or not) one of the other two models.

 

Ok, I think (at long last!) I've gotcha and it's *almost* working. The biggest indication of this is that a) the game no longer crashes and b) items are rendered differently in the inventory than anywhere else (they're flat). I've hardcoded the inventory JSON file for now so there's only one.

 

Two problems exist now: 1) Nothing is textured (and in the case of held items they're rendered in the same way anything without a JSON file are) and 2) Any elements on the floor crash the game with a NullPointerException in RenderEntityItem

 

If you wouldn't mind helping me with that I'd be very grateful.

I have no idea what I'm doing.

Link to comment
Share on other sites

Again, your ModelLoader matches all item models in your mod! Every item model location starts with "models/item"!

You need to check for the MRL you bind to the item here. What I linked there is saying "use this MRL for that item". Now your ModelLoader needs to step and say "hey, I can load that!". But it must not do that for everything, since otherwise normal JSON models will not work, since your loader will just say "here, i got this!" and provide your IPAM again.

Moreover you need to register the models you return from your IPAM (these two) using ModelBakery.registerItemVariants, otherwise Minecraft will simply say "I do not know these".

Link to comment
Share on other sites

I've appropriately re-named everything so that I'm not registering every item in my mod, and the held textures are now showing up in-game. The models are being rendered separately. I think I did everything you said.

 

But:

 

Things in the GUI are still not being textured, and throwing things on the floor still crash the game.

 

Did I miss something or is it something else?

 

EDIT: I tried using

elementModel

and

testModel

to pass to

ModelLoader.setCustomModelResourceLocation

, both of which had the exact same result.

I have no idea what I'm doing.

Link to comment
Share on other sites

- You register these models multiple times (in the for loop below). Only register every model once.

 

- This model does not exist and you do not (try to) register it either.

 

Well I've just completely removed the loop for now and corrected the incorrect model path, and now I'm back to the same crash as before...

 

Did I actually break something in the process or is there something else wrong?

I have no idea what I'm doing.

Link to comment
Share on other sites

I really don't know at this point. All I can see is: this model still doesn't exist. Use a debugger to find out what's happening.

 

It seems that you're right, but I have no idea why...

 

The JSON file for it is in the same place as all the others. The contents of the JSON file is literally a copied+pasted version of one of the elements in which I have changed nothing at all.

I tried fully disabling all of the model code and just sticking to a static model like I was using before this whole thread, and putting in the ModelResourceLocation of the model and it just completely ignored it. I then tried using on of the standard element models, and it worked fine.

 

Sticking a breakpoint on getting the ModelResourceLocation showed a message variable saying that the path was null. Which I presume it shouldn't...

 

When you say "use a debugger" is there some tool other than outputting variables + breakpoints I should know about?

 

EDIT: The elementHeld model, which *was* working absolutely fine now isn't working. I changed nothing. I am beyond confused.

I have no idea what I'm doing.

Link to comment
Share on other sites

Sorry to bring this thread up again. I've got everything working (helps if you don't name every model with the prefix used to in the loader :/) except I still can't throw anything on the floor - as soon as they're turned to

EntityItems

the game crashes rendering them.

 

As can be seen in the crash report.

 

The only occurrence I've found of this happening before after a Google (with 4 results) was here, but this seems unlikely for something as simple as what I've done.

 

Do I need to follow what you said to do in that guide or have I just done something really stupid again?

 

If yes to following that post, could you explain the steps in a little more detail. I've sorta realised I was obviously doing something wrong, but wasn't sure where to go and what to fix and got stumped (see here).

I have no idea what I'm doing.

Link to comment
Share on other sites

Eh?

 

Maybe if I explained a little better:

 

-Textures switch correctly in the inventory or when the item is held. This works absolutely fine. There are no errors about missing models or anything.

-The game crashes when I drop the item, and it becomes an EntityItem.

 

In terms of the models:

-In the first instance, every element's name starts with the "element_" prefix. That is the registered model, but it does not actually exist as a resource because its never rendered.

-The second instance is checking that it's an element, because every element name starts with "element_" and so do all of the registered model locations.

-The third instance, where I used "element-" is the model when it is displayed in the GUI, and it does exist.

 

I understand it's pretty poor and confusing at the moment, and I am slowly going through and tidying everything up. Perhaps it's because one of the models doesn't exist, but surely that wouldn't crash the game, because it should either return one of the two IBakedModel models or display as if the model wasn't found?

 

And the loop - I'm registering 118 different items; surely I can't register 118 different items without looping, and surely it's therefore not the same thing being registered twice?

I have no idea what I'm doing.

Link to comment
Share on other sites

-Textures switch correctly in the inventory or when the item is held. This works absolutely fine. There are no errors about missing models or anything.

-The game crashes when I drop the item, and it becomes an EntityItem.

Yes, because when it's held you are using the correct model.

 

-In the first instance, every element's name starts with the "element_" prefix. That is the registered model, but it does not actually exist as a resource because its never rendered.

Of course it is rendered! It is just not loaded by the JSON-Model loader but by your custom model loader.

But yes, you are right about the prefixes. Except that the "element-" version does exist, but you never register it. You register this unrelated "baseModel" instead here

And the loop - I'm registering 118 different items; surely I can't register 118 different items without looping, and surely it's therefore not the same thing being registered twice?

The thing I linked is registering the same two things 118 times.
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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

 Share




×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.