Jump to content

Recommended Posts

Posted

I can easily detect collisions with other entities in my custom entities, but I'm trying to detect them in vanilla entities.  Since there's no EntityCollision event, I've heard of people polling for collisions via player update events or entityLiving update events, but so far I'm not seeing how I'd go about grabbing that info.  I have a pretty decent understanding of Java and the Minecraft API, so I don't need a lot of details on how to code it; I just need someone to point me in the right direction.  I'm looking for entity/entity collisions and entity/player collisions.

 

By the way, I'd like to make this work with both 1.7 and 1.12.  Would it require similar or different techniques for each version?

 

Thanks in advance!

Posted

By the way, the way I'm currently trying is Minecraft.getMinecraft().theWorld.getEntitiesWithinAABBExcludingEntity() and setting the AABB to the bounding box of the entity and excluding itself.  Seems to work most of the time, but not always.

 

Is there a better way?

Posted
  On 11/9/2018 at 4:42 PM, DocBrian said:

Minecraft.getMinecraft().theWorld.getEntitiesWithinAABBExcludingEntity() and setting the AABB to the bounding box of the entity and excluding itself.  Seems to work most of the time, but not always.

Expand  

You could try interpolating the bounding boxes based on time, this might not work very well though.

  On 11/9/2018 at 4:29 PM, DocBrian said:

1.7

Expand  

Sorry we don't support 1.7 on this forum anymore due to its age (4+ years old). We simply don't know how to help you anymore.

I think theres an onEntityCollideWithEntity method or something that you can override?

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
  On 11/9/2018 at 4:42 PM, DocBrian said:

I'm currently trying is Minecraft.getMinecraft().theWorld.getEntitiesWithinAABBExcludingEntity() and setting the AABB to the bounding box of the entity and excluding itself.  Seems to work most of the time, but not always.

Expand  

One reason that it may not always work is that I'm guessing the method only looks for entities that have their origin point within that range.  Ie. something with a large bounding box (like the ender dragon) could have its origin point (the point referred to by its posX, etc) outside your entity's bounding box, but still have a (large) part of its own bounding box overlapping that of your entity.

 

This is all assuming the method you posted doesn't account for entity bounding boxes when you give it a range.

Posted
  On 11/10/2018 at 6:08 AM, Laike_Endaril said:

One reason that it may not always work is that I'm guessing the method only looks for entities that have their origin point within that range

Expand  

World#getEntitiesWithinAABBExcludingEntity(or rather Chunk#getEntitiesWithinAABBForEntity) iterates all entities and checks whether their bounding boxes intersect with the passed one.

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.