Jump to content

CollectibleObject.DamageItem does not destroys item completely?


bzzzil
 Share

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);
        }
    }
}

 

Link to comment
Share on other sites

  • 5 weeks later...
 Share

×
×
  • 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.