Turtledove Posted May 17, 2020 Posted May 17, 2020 (edited) 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 May 18, 2020 by Turtledove Quote
Turtledove Posted May 17, 2020 Author Posted May 17, 2020 ...huh, rebuilding the project got it to work. The heck? Quote
Ugdhar Posted May 17, 2020 Posted May 17, 2020 2 hours ago, Turtledove said: ...huh, rebuilding the project got it to work. The heck? Were you in creative mode when you were trying it? Just curious, since I would imagine you wouldn't take damage in creative. Quote
Turtledove Posted May 17, 2020 Author Posted May 17, 2020 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. Quote
Turtledove Posted May 18, 2020 Author Posted May 18, 2020 Never mind, it's not working again. Why on earth is this happening? Quote
Turtledove Posted May 18, 2020 Author Posted May 18, 2020 attackEntityFrom keeps returning false. When I reload the world it sometimes works, but most times it doesn't. Quote
Turtledove Posted May 18, 2020 Author Posted May 18, 2020 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. Quote
Recommended Posts
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.