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

I have a very basic AI class where if the player gets within a certain area of the entity, then the player takes damage.

ย 

So I did the usual; get the bounding box, scale it, offset it, and iterate the list for valid entities. The thing is, it works, other mobs take damage without any issue. However, I can't seem to get hit. It's in the AI class so it's not a server-client issue, plus when I print the list of entities in the AABB it does detect the server's player class. What am I missing here? This is all there is in my update method:

ย 

            List<LivingEntity> swipeEnemies = this.entity.world.getEntitiesWithinAABBExcludingEntity(entity,  entity.getEntityBoundingBox().expand(5.0,1.0,5.0).offset(-2.5D,0D,-2.5D));
            if (!swipeEnemies.isEmpty())
            {
                for (LivingEntity targ : swipeEnemies)
                {
                    targ.attackEntityFrom(DamageSource.causeMobDamage(entity),12.0F);
                }

ย 

Edited by Turtledove

  • Author
10 hours ago, Ugdhar said:

Were you in creative mode when you were trying it? Just curious, since I would imagine you wouldn't take damage in creative.

Haha nah I was in survival. Just one of those times where you can't figure out why something finally works, so you just accept it and move on lol.

  • Author

attackEntityFrom keeps returning false. When I reload the world it sometimes works, but most times it doesn't.ย 

  • Author

It appears that the damage source is the issue, when I set my custom entity as the damage source it causes attackEntityFrom to return false most of the time. But when I instead set the source as a generic type, it works 100%. Strange. Looking through the multiplayer class'sย attackEntityFrom (or its parent class) there's nothing there to indicate there'd be a problem.

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.