Posted November 26, 201212 yr 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.
November 28, 201212 yr 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; } else { 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. http://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!
December 8, 201212 yr create a tick handler server side, and them just do a check to see if the player have equipped that armor, if haves u give the potion effects if not just do nothing
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.