# 1.7.10 - total Path distance

## Recommended Posts

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

##### Share on other sites

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

##### Share on other sites

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/

##### Share on other sites

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.

##### Share on other sites

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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

• ### Posts

• I have every compat (wood good) along with other mods, so when i try them in creative the game crashes when sliding tabs in the inventory screen (key E), particularly when reaching the 4th section of the inventory. The mod version is 1.6.4 (1.18.2). Is there any way to solve it? Crash log in the link. https://github.com/MehVahdJukaar/WoodGood/issues/567
• My skin was stuck to alex and wasn't switching over to my custom skins, can anyone help me figure out how to fix this issue, in the minecraft launcher? thanks.
• I'm making an all-in-one tool, so I figured it would be best to extend DiggerItem and then implement the functionality of each integrated tool in my item's class.
• why do you need DiggerItem, just use Pickaxe/AxeItem etc.
• Hi, I created a custom tool that extends the DiggerItem class, but I am unable to give it enchantments as with other tools. For example, when I try to use the /enchant command, it says that my item "cannot support that enchantment". Similarly, the anvil does not allow me to add book enchantments to the item. I have tried overwriting the methods relating to enchantments, as shown below. What are the steps that I need to take to enable vanilla enchantments on my custom tool? Current code: public class MyItem extends DiggerItem { public MyItem(Tier tier, Properties pProperties) { super(tier, MyTags.Blocks.MINEABLE_WITH_MYITEM, pProperties); } @Override public boolean canPerformAction(ItemStack stack, ToolAction toolAction) { return true; } @Override public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { return true; } @Override public boolean isBookEnchantable(ItemStack stack, ItemStack book) { return true; } @Override public boolean isEnchantable(@SuppressWarnings("null") ItemStack pStack) { return true; } }

• ### Who's Online (See full list)

×

• #### Activity

×
• Create New...