Jump to content

How can I make a "on wear" event listener?


Recommended Posts

I've started on a mod which adds armors with special effects and I want to add them as potions effects when they're worn and to make effects disappear when you unequip the armor. Does anyone know how to make a event listener for on wear event (If it exists)?

I'll mention the person that tells me how to make it in the mod thread.

Link to comment
Share on other sites

Well, I guess you could sumulate it, in a way.

Here is the code that makes the enderman check if a player is wearing a pumpkin:



     * Checks to see if this enderman should be attacking this player
    private boolean shouldAttackPlayer(EntityPlayer par1EntityPlayer)
        ItemStack var2 = par1EntityPlayer.inventory.armorInventory[3];

        if (var2 != null && var2.itemID == Block.pumpkin.blockID)
            return false;
            Vec3 var3 = par1EntityPlayer.getLook(1.0F).normalize();
            Vec3 var4 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX - par1EntityPlayer.posX, this.boundingBox.minY + (double)(this.height / 2.0F) - (par1EntityPlayer.posY + (double)par1EntityPlayer.getEyeHeight()), this.posZ - par1EntityPlayer.posZ);
            double var5 = var4.lengthVector();
            var4 = var4.normalize();
            double var7 = var3.dotProduct(var4);
            return var7 > 1.0D - 0.025D / var5 ? par1EntityPlayer.canEntityBeSeen(this) : false;



You could add something that checks if the player is wearing a specific armour piece every few seconds, and give them a potion effect if they are wearing it.

width=300 height=100http://i.imgur.com/ivK3J.png[/img]

I'm a little surprised that I am still ranked as a "Forge Modder," having not posted a single mod since my animals mod... I have to complete Digging Deeper!, fast!

Link to comment
Share on other sites

  • 2 weeks later...

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.

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.