Jump to content

Recommended Posts

Posted
24 minutes ago, ultra_reemun said:

Is there an event I can use to check if the player has swung their weapon?

Depends on what you want to do. How do you define "swung their weapon"? Is this any left click with the Item in their hand? You may need to use a combination of PlayerInteractEvent subclasses.

 

Elaborate a bit more.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
9 minutes ago, Animefan8888 said:

Depends on what you want to do. How do you define "swung their weapon"? Is this any left click with the Item in their hand? You may need to use a combination of PlayerInteractEvent subclasses.

 

Elaborate a bit more.

Apologies for not being specific enough.

I want to check if a player has attacked with a tool, so left clicked but not to mine a block.

I'm also looking to temporarily stop them from being able to do so, or at least stop it from inflicting damage.

Posted
6 minutes ago, ultra_reemun said:

I'm also looking to temporarily stop them from being able to do so, or at least stop it from inflicting damage.

Is it your Item? If so you can use Item::hitEntity to detect when an Entity is hit. However you can't stop the hit/damage from being processed.

If you end goal is too cancel damage/an attack you should use LivingAttackEvent and cancel it when you want the attack to not happen.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
2 minutes ago, Animefan8888 said:

Is it your Item? If so you can use Item::hitEntity to detect when an Entity is hit. However you can't stop the hit/damage from being processed.

Thank you for the advice but I simply want to detect when the player has swung one of the vanilla tools.

3 minutes ago, Animefan8888 said:

If you end goal is too cancel damage/an attack you should use LivingAttackEvent and cancel it when you want the attack to not happen.

How would I go about using this event to stop the player from being able to damage other entities?

 

Thank you for all your help.

Posted
15 minutes ago, Animefan8888 said:

What do you mean other entities? Try taking a look in the class and it's parent classes.

My bad, I missed the point of the class, I see what you mean now. Thank you!

 

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.