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

[1.10.2] How to Replace/Add to Vanilla Item Models/Textures and Potion Questions


Jedispencer21
 Share

Recommended Posts

What I am trying to do is change the texture of the potion, but only for my potions. How would I do this? I tried using setCustomMeshDefinition, but getModelLocation never seemed to be called. Also with potions, is there any way to increase/decrease mob spawns while having a custom potion effect active?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Also with potions, is there any way to increase/decrease mob spawns while having a custom potion effect active?

How do you want this to work? If a player has this potion active, mob spawns around them are reduced? Does it also happen when other (not-affected) players are nearby?
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.