Jump to content

[1.15.2] Rendering One Item as Another


ChampionAsh5357

Recommended Posts

I am currently trying to create a concept where an item can be combined with another item in some sort of recipe serializer to create it so that one item is rendered like the other. The way I was approaching this was to just attach an nbt which holds an item registry name and then it gets the item when being rendered. The issue is that there is no easy way to override ItemRenderer#getItemModelWithOverrides to set this value. There are registry events but in all cases it would take removing that stack and rendering a different item in multiple different places which is just highly tedious. So, is there a way to hook into this method to have it check for the nbt first before trying to render the item? Any input is appreciated for methodology.

  • Like 1
Link to comment
Share on other sites

6 hours ago, DragonITA said:

Hope this help you @ChampionAsh5357 (P.S.: I like your videos, thanks a lot) :

 

Thanks, however, I did already look at this and try a version. I probably would've done it this way if I was only doing this for a single item. The issue is that if I were doing the one item method, there would be no way to make the item act like the actual item to the same effect as the original since ItemStack#getItem when called in each method for let's say food would say: hey look, this CustomItem does not have a Food attached to it or something like that. This has to be able to change for all items. If I wanted to use this method above, I would need to override every single item that comes into the game and add that line of code which would be more or less the same issue when trying to override the ItemRenderer method. Also, if I were to do that, the ItemOverrideList#getModelWithOverrides seems to only be called if the item has custom properties which only applies to a few items within the game. I might be missing something, so I'll look into it more. But, I doubt it will work without overriding everything.

  • Like 1
Link to comment
Share on other sites

So I tried just setting the value of the ItemRenderer to an extended version using reflection and it stopped the ModelManager from getting the splashList from the bakery resulting in a bunch of missing textures (unsurprisingly). I tried setting this during the ModelBakeEvent which fixed this issue but opened up a realm of new problems. Since I didn't change the ItemRenderer right when Minecraft was initializing, a bunch of variables set still had the regular ItemRenderer attached to it. I overwrote all of those variables using reflection as well. I know this is not a good idea but I was testing a case. The issue with the idea is that it creates a new instance each time the models are reloaded. Which means that if you refresh the models (e.g. F3 + T) all data currently being used will be reset. So, the game simply crashes whenever those buttons are pressed.

 

I still want to find a way of doing this without having to create a PR for a hook into ItemRenderer#getItemModelWithOverrides. Maybe there is another way to hook into all the itemstacks at once and update their current model.

  • Thanks 1
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
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.