Jump to content

[1.19.4] Optimal way of registering custom block/item renderer?


JimiIT92

Recommended Posts

In my mod I'm dealing with some custom chests and, for the item rendering, I came across the BlockEntityWithoutLevelRenderer to render the item model of the chest inside the inventory.
Now, everything works, but I've noticed that I have to call an instance of this class in the custom chest item, like so
 

@Override
public void initializeClient(final @NotNull Consumer<IClientItemExtensions> consumer) {
  consumer.accept(new IClientItemExtensions() {
    @Override
      public BlockEntityWithoutLevelRenderer getCustomRenderer() {
      return MineWorld.getItemsRenderer();
    }
  });
}

where the MineWorld.getItemsRenderer is a method that returns a new instance of my custom BEWLR class, or an existing one if it has been already initialized.
What got my attention is that if I want to add another item with a custom model I have to add this same method in that item class as well. Is this the optimal approach or there's a better, centralized one? Maybe one that would also prevent me from registering a custom item for the chest, and instead checks for the actual chest block item?

Don't blame me if i always ask for your help. I just want to learn to be better :)

Link to comment
Share on other sites

Yeah, but that would work if every item that I need to render in a certain way in the inventory are direct childs of Item. If I have some items that extend another vanilla item class (for example something that extends TridentItem to make some spears) I have to specify that code inside the custom trident item class as well 😅

Don't blame me if i always ask for your help. I just want to learn to be better :)

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.