Jump to content

Recommended Posts

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

Posted

"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.

Posted

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)

Posted

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...

×   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.