Posted February 8, 20169 yr Hello guys, I want to let mobs like pigs etc. panic after you attacked them. I mean the panic when you attack them with a vanilla sword. I have set up a custom DamageSource, which works. When you attack Zombie Pigmen with my EntityThrowable (which uses the DamageSource), they will revenge you. That works, too (but I have to set it in the Entity's class, maybe is there a method to set it for the DamageSource?). How can I let the mobs panic, do I have to execute the MobAIPanic-task? Please help me Here is my code: DamageSource: https://github.com/TheOnlySilverClaw/Reforged/blob/master/java/org/silvercatcher/reforged/ReforgedRegistry.java#L92 EntityThrowable: https://github.com/TheOnlySilverClaw/Reforged/blob/master/java/org/silvercatcher/reforged/entities/EntityBulletMusket.java Own "ReforgedThrowable"-class: https://github.com/TheOnlySilverClaw/Reforged/blob/master/java/org/silvercatcher/reforged/entities/ReforgedThrowable.java Thanks for helping ^^ Bringing the best mod back alive! Our mod REFORGED! Balkon's Weapons for 1.8: https://github.com/TheOnlySilverClaw/Reforged/releases
February 8, 20169 yr Author After searching in Google I found a method in Bukkit / Spigot and tried to reproduce that in Forge and IT WORKS! Here is my answer: if(entityHit instanceof EntityLivingBase) { EntityLivingBase en = (EntityLivingBase) entityHit; if(getThrowerASave() instanceof EntityPlayer) { en.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) getThrowerASave()), 0F); } else { en.attackEntityFrom(DamageSource.causeMobDamage(getThrowerASave()), 0F); } } I just do PlayerDamage or MobDamage, dependent of the Thrower, with an amount of 0. Full code in the 3 links above. Bringing the best mod back alive! Our mod REFORGED! Balkon's Weapons for 1.8: https://github.com/TheOnlySilverClaw/Reforged/releases
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.