Jump to content

getEntitiesInAABB does not include custom entity when I resize it


fruehlingsrollen

Recommended Posts

I have a custom entity that resizes accordingly to it's contents inside.

I checked if the bounding box of the entity is correct after the resize and it is, the real problem is when I check for getEntitiesInAABB.
With IntelliJ breakpoints I inspected the code and Chunk::getEntitiesWithinAABBForEntity does not find my custom entity, even when my player is right in it's bounding box.
Whenever I spawn my entity without resizing it's contents the AABB check works fine, it only appears once I resize my entity and update it's bounding box. I really can't
explain why this is happening and my only solution would be to check if the player is inside any of the custom entities at any given time, for that I would need access
to every loaded entity in the world though, and I haven't found anything for that either.

Help would be great! If you need any specific code snippets Im glad to share them

Link to comment
Share on other sites

Your question is unanswerable if you don't show the code.

 

I can tell you that you need to call entity.refreshDimensions() to allow the game to recalculate everything size related after you change something that affects the dimensions.

e.g. the game calls that method when an Ageable mob changes from a baby to an adult.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Okay so I've found the solution, thanks warjort because you led me to the assumption that I had to somewhere update the chunks that keep track of the entity.

I took a look at Entity::resetPositionToBB and it had the line "if (this.isAddedToWorld() && !this.world.isRemote && world instanceof ServerWorld) ((ServerWorld)this.world).chunkCheck(this);"
which is the solution to all my problems, so I just added it into my setPosition Override.

Link to comment
Share on other sites

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.