Posted July 12, 201411 yr 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
July 12, 201411 yr "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.
July 12, 201411 yr He didn't ask for shortest distance, he asked for shortest path. That isn't necessary the same thing. For example in a dungeon the closest could be behind a wall but needs long path to get to. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
July 12, 201411 yr 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)
July 12, 201411 yr 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.