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

Posted

Forge 1.17.1
Hello. I want to do something like scare mobs potion effect. It basically would make mobs ignore the player, just like on gamemode creative. I discovered that when I give player disableDamage ability (player.abilities.disableDamage), mobs start to ignore the player. But I don't want to make player invulnerable (I'll use tags).
Then I found this method in MobEntity class:

public boolean canAttack(LivingEntity target) {
      return target.getType() == EntityType.PLAYER && ((PlayerEntity)target).abilities.disableDamage ? false : super.canAttack(target);
   }


I just need to somehow override/change/...? it to something like

return target.getType() == EntityType.PLAYER && ((PlayerEntity)target).getTags().contains("scare_mobs") ? false && ((PlayerEntity)target).abilities.disableDamage ? false : super.canAttack(target);)

but I don't really know how. What is the best way to do this, without breaking the game?

Edited by KopoL

1.15 is no longer supported on this forum.
Please update to a modern version of Minecraft to receive support.

  • KopoL changed the title to [1.17.1] Overriding Vanilla method

only possible via coremodding
ask on the forge discord server in the non-api-modding chanel
there are the experts about coremodding

  • Author

Okay, thank you. But do you think of any other way to prevent them from attacking the player without making him invulnerable - without using abilities? Because using core modding is my final solution, If I had any other option I'd prefer to use it.

28 minutes ago, Luis_ST said:

only possible via coremodding

there is no Hook or Event where you can use

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.