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

Hi :)

 

I have a chest list and one entity.

 

I currently try to know how find the nearest chest to my entity.

 

I have thought to choose the shortest path beetween all chest from my list and my entity.

But I don't think we can calculate the total path distance.

 

Have you got an idea to do that ?

 

Must I use reflection ?

 

Thanks :)

 

edit reason : correct somes english language mistakes

"I currently try to know how find the nearest chest to my entity."

And how do you do that? Maybe we could make your code a little bit more optimal.

 

"choose the shortest path"

Thats perfectly good option and probably only one.

 

"I don't think we can calculate (...) distance."

And why is that?

You have Entity with x,y,z, you have chest list.

I assume that if you have chest you do have its coord (x,y,z) so you just use math. Vectors sir, vectors.

 

And why do you even ask about reflection, there is no connection here.

 

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Thanks for your replies :)

Sorry for my bad english, yes I would say " the shortest" :)

 

Currently it's an ArrayList of chest, I think about what kind of data structure will be the best effective.

I know I can use vector but as Jabelar say, I need the path distance, not the distance beetween 2 coordinates :/

 

And why do you even ask about reflection, there is no connection here.

I don't understand, I was speaking about this : http://en.wikipedia.org/wiki/Reflection_(computer_programming)

Hi

 

You might find some inspiration in the Minecraft package net.minecraft.pathfinding, eg PathFinder.

 

Never used them myself but they look promising.

 

PathFinding can be an extremely expensive operation (it has to search a very large number of possible path options) so you might need to apply some rules or short-cuts to make sure it doesn't get too high.  Are you sure that "shortest distance" isn't good enough for what you want?

 

Don't worry about whether your ArrayList of chest should be some other data structure, it will make absolutely no difference to the speed.

 

-TGG

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.