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

Hello, I want to find an Entity at a set of coordinates specified. I need will need to access the fields of that Entity class. I am already using World.getClosestPlayer(X,Y,Z,4.0), but I don't want to access an Entity standing behind me. I have code written to try to figure out if that Entity is standing in view by comparing it to my look vector, but I don't think that the look vector would work completely. Is there some world function that finds the Entity at XYZ Coordinates and returns a reference to that Entity?

player.getLookVec()?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Hi

 

You can get all entities within a certain x,y,z range by defining an AxisAlignedBoundingBox and calling the function below

 

Snippet taken from EntityLiving.onLivingUpdate::

            List list = this.worldObj.getEntitiesWithinAABB(EntityItem.class, this.boundingBox.expand(1.0D, 0.0D, 1.0D));

 

You can tell if an entity is behind the player by:

1) calculating the direction vector from the player to the entity

2) calculating the dot product of this vector with the player's look vector

3) if the dot product is negative, the entity is behind the player.

 

Let us know if you need more help?

 

-TGG

 

 

  • Author

player.getLookVec()?

Yes that was the method I was talking about.

You can offset AABBs by the look vector so that the AABB is only in front of the player.

 

It's like f*cking magic.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.