Jump to content
Sign in to follow this  
bzzzil

CollectibleObject.DamageItem does not destroys item completely?

Recommended Posts

Hi,

I'm trying to do own mod and stuck with strange behavior issue. I'm creating special usage to several items on right click. My custom action is performed and used tool should be damaged. And? of course, once tool's durability is reached it cracks. Crack sound is played, tool disappears from toolbar. BUT if i click with mouse into empty cell in toolbar that tool reappears with full durability.

I suppose that in spite it is removed from ItemSlot, some references are still somewhere and I can't find what else I should do to permanently destroy broken tool.

Any suggestions?

Here is a short mod example for easier reproducing of described problem. Just take any spear in hand and right click. It will break. But if you left click with mouse into inventory slot it will resurrect.

namespace SampleMod
{
    public class SampleMod : ModSystem
    {
        public override bool ShouldLoad(EnumAppSide side)
        {
            return true;
        }

        public override void Start(ICoreAPI api)
        {
            api.RegisterItemClass("ItemSpear", typeof(Spear));
        }
    }


    public class Spear : Item
    {
        public override void OnHeldInteractStart(ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, bool firstEvent, ref EnumHandHandling handling)
        {
            this.DamageItem(byEntity.World, byEntity, slot, 1000);
            base.OnHeldInteractStart(slot, byEntity, blockSel, entitySel, firstEvent, ref handling);
        }
    }
}

 

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.