Damage item when mob attacks

Status
Won't fix
Type
Product/platform
MCreator/Windows
Priority
Normal
Issue description

Im trying to create an event when the mob attack it will break the item held by the player such as a sword, or just any held item in general. However i keep on getting a compile error everytime i try to add it.

Issue comments

@Override
        public void onDeath(DamageSource source) {
            super.onDeath(source);
            int i = (int) this.posX;
            int j = (int) this.posY;
            int k = (int) this.posZ;
            Entity entity = this;

            if (true) {
                getHeldItemMainhand().damageItem(3, EntityPlayer);
            }

        }

This is the code thats currently in. It does not seem to work.

As stated in issue form, coding questions belong to forums and not here. You won't get support here. Nevertheless, 1.7.9 will add new procedure system which could help you achieve this without coding.



Donate to MCreator

By donating to developers you can speed up development, as with more resources, we can dedicate more time to MCreator. It is a free project made by developers working on it in their free time.