Jump to content

[SOLVED] [1.8] Item Rendering


ThexXTURBOXx

Recommended Posts

Hello guys,

 

I want to make a CLIENT ONLY mod.

I would like to change the texture of an item, if it has a specific name.

E.g.:

The item is an normal apple.

Its name is "Apple"

==> Normal Apple-texture

 

The item is an normal apple.

Its name is "Special Apple"

==> Own Texture

 

Is this even possible and if yes, how could I do it?

I don't find any events regarding to this (I can't just do e.setTexture(new ResourceLocation("")); ).

 

Thanks in advance

ThexXTURBOXx

Bringing the best mod back alive! Our mod REFORGED!

Balkon's Weapons for 1.8: https://github.com/TheOnlySilverClaw/Reforged/releases

Link to comment
Share on other sites

You will need to assign custom IModel (baked) to item during game startup and make it return different baked models depending on ItemStack's NBT.

I recommend searching for threads regarding this topic as it is pretty big and not that simple.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

You will need to assign custom IModel (baked) to item during game startup and make it return different baked models depending on ItemStack's NBT.

I recommend searching for threads regarding this topic as it is pretty big and not that simple.

 

Ok, thanks :)

But I don't know how to do this exactly :(

 

Update to 1.10.2. Then you can do this with ItemOverrides.

Register your own IItemPropertyGetter to the apple item. Then make an ItemOverride instance that reacts to that property and stuff it into the apple model.

 

This sounds good, but I do this for a little Server Network, which runs at 1.8 at the moment :/ Maybe we will update it... Thanks to you, too :)

 

But: Is there really no other method? :(

Bringing the best mod back alive! Our mod REFORGED!

Balkon's Weapons for 1.8: https://github.com/TheOnlySilverClaw/Reforged/releases

Link to comment
Share on other sites

Ok, we have updated our network now and I updated my mod.

I'm just following your "guide":

Quite hacky, but this should work:

 

All in preInit:

  • Register an implementation of
    IItemPropertyGetter

    to

    Items.POTIONITEM

    using

    addPropertyOverride

    with a

    ResourceLocation

    with your ModID.

    • In this
      IItemPropertyGetter

      , check if the supplied stack is your potion and return 1 if so, 0 otherwise.

    [*]Implement

    IResourceManagerReloadListener

    and register it with

    Minecraft#getResourceManager

    (you'll have to cast to

    IReloadableResourceManager

    ).

    • In this listener, call
      Minecraft.getMinecraft.getRenderItem().getItemModelMesher().getItemModel(new ItemStack(Items.POTIONITEM));

      to obtain the baked model for the potion.

    • Obtain the
      ItemOverrideList

      for the model using

      IBakedModel#getOverrides

      and get the field

      ItemOverrideList#overrides

      from it (you'll need reflection as this field is private).

    • This field gives you a
      List<ItemOverride>

      . Create your own

      ItemOverride

      and add it to the list. The constructor for

      ItemOverride

      takes 2 parameters: A

      ResourceLocation

      and a

      Map<ResourceLocation, Float>

      . The

      ResourceLocation

      is the identifier for the model you want your potion to have (like you would use when normally registering an item). The

      Map

      needs to contain a single entry, the key being the

      ResourceLocation

      that identifies your

      IItemPropertyGetter

      from the first step, the value being (as a

      Float

      ) 1.

 

You might additionally need to tell Minecraft to pre-load your Model using

ModelBakery.registerItemVariants

in preInit.

But how would I do this, if I need to set a new Texture for a block? May I just call Item.getItemFromBlock(...) or is there a other method?

 

EDIT: But there is something odd... o_O If I do this in the preInit, like you said, then I get a NullPointer at getRenderItem()... In the init - method it works, but now the textures are changed even when the item does not have the name I wrote in the IItemPropertyGetter...

 

EDIT 2: Item.getItemFromBlock works, but I don't know how to replace the texture of the block itself, when it got placed :/

Bringing the best mod back alive! Our mod REFORGED!

Balkon's Weapons for 1.8: https://github.com/TheOnlySilverClaw/Reforged/releases

Link to comment
Share on other sites

Is this still an issue? If so please post your code.

 

Yes, this is still an issue :/ My Code is here: https://github.com/Rustico-Network/RusticoHelper/tree/master/java/de/thexxturboxx/rusticohelper

 

For blocks this is quite a bit trickier. When do you want the texture change to take effect here? Blocks do not have names after all.

 

In Bukkit/Spigot, there is an option to set metadata-keys with values (see here, the code in the first post is an example: https://www.spigotmc.org/threads/meta-data-on-placed-blocks.55072/)

 

EDIT: I found something in the log:

http://pastebin.com/ngKBiKpV

But why does Forge search in the folder "rusticohelper:item/textures/items/crook.png"??? The normal folder would be "rusticohelper:items/crook", right?

Bringing the best mod back alive! Our mod REFORGED!

Balkon's Weapons for 1.8: https://github.com/TheOnlySilverClaw/Reforged/releases

Link to comment
Share on other sites

Now everything besides from the Blocks, when they got placed, works fine, thanks :) (See my code here: https://github.com/Rustico-Network/RusticoHelper )

But I had to do 2 more steps... I had to register the normal model of the vanilla-item, too.

And I had to register the ModelResourceLocation in the ItemOverride-constructor, not a normal ResourceLocation, but thank you very much!

 

I will just let the blocks be the vanilla ones xD

Bringing the best mod back alive! Our mod REFORGED!

Balkon's Weapons for 1.8: https://github.com/TheOnlySilverClaw/Reforged/releases

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.