Jump to content

Recommended Posts

Posted

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

Posted

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.