Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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.

  • Author
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.

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.

  • Author
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.

9 minutes ago, ultra_reemun said:

damage other entities?

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

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.

  • Author
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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.