Jump to content

[1.8]Annormal status , How to stun a mob ??


perromercenary00

Recommended Posts

good days

 

i wanna stun an entity, or at least inpeding this one to move for a couple of seconds

 

 

this is what i been triying

@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
{
target.setInWeb();
    stack.damageItem(1, attacker);
    return true;
}
//############################################################################################3

 

not work

Link to comment
Share on other sites

It is working I think. The only problem is that it is only aplied for one single tick. Thats why you dont noticed it.

So there are multiple solutions to this.

 

1) create an tickHandler and let it decrease(or increase) a value Every tick. Aply you "stun effect" every tick till the value reahes a certain point.

 

2) use vanilla! Yep, what I described above is actualy done by vanilla, its called potion effects. you could simply aplly slowness (with level 10 for example) to achieve your goal.

 

note, its not recommended to use ".setInWeb". its better to modify the targets motion Instead.

 

I hope this helped you out!

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

Link to comment
Share on other sites

A couple options:

1. Subscribe to LivingUpdateEvent and cancel it for the mob in question. Pros - mob will not move or attack; Cons - it cancels the mob's update tick, meaning lots of stuff that's supposed to happen doesn't

 

2. As above, but instead of canceling it, set the mob's position to its previous position, then also subscribe to LivingAttackEvent and cancel it for the mob in question. Pros - mob does not attack and mostly doesn't move, mob still gets its update tick; Cons - more work, mob still moves a little bit, for players you will also want to cancel mouse and keyboard input using the KeyInputEvent and MouseEvent.

Link to comment
Share on other sites

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.