the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 75 lines 1.4 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.entity.h" 3#include "net.minecraft.world.level.pathfinder.h" 4 5// 4J - added for common ctor code 6// Do all the default initialisations done in the java class 7void Node::_init() 8{ 9 heapIdx = -1; 10 11 closed = false; 12 13 cameFrom = NULL; 14} 15 16Node::Node(const int x, const int y, const int z) : 17x(x), 18y(y), 19z(z), 20hash(createHash(x, y, z)) 21{ 22 _init(); 23 24 //this->x = x; 25 //this->y = y; 26 //this->z = z; 27 28 //hash = createHash(x, y, z); 29} 30 31int Node::createHash(const int x, const int y, const int z) 32{ 33 return (y & 0xff) | ((x & 0x7fff) << 8) | ((z & 0x7fff) << 24) | ((x < 0) ? 0x0080000000 : 0) | ((z < 0) ? 0x0000008000 : 0); 34} 35 36float Node::distanceTo(Node *to) 37{ 38 float xd = (float) ( to->x - x ); 39 float yd = (float) ( to->y - y ); 40 float zd = (float) ( to->z - z ); 41 return Mth::sqrt(xd * xd + yd * yd + zd * zd); 42} 43 44float Node::distanceToSqr(Node *to) 45{ 46 float xd = to->x - x; 47 float yd = to->y - y; 48 float zd = to->z - z; 49 return xd * xd + yd * yd + zd * zd; 50} 51 52bool Node::equals(Node *o) 53{ 54 //4J Jev, never used anything other than a node. 55 //if (dynamic_cast<Node *>((Node *) o) != NULL) 56 //{ 57 return hash == o->hash && x == o->x && y == o->y && z == o->z; 58 //} 59 //return false; 60} 61 62int Node::hashCode() 63{ 64 return hash; 65} 66 67bool Node::inOpenSet() 68{ 69 return heapIdx >= 0; 70} 71 72wstring Node::toString() 73{ 74 return _toString<int>(x) + L", " + _toString<int>(y) + L", " + _toString<int>(z); 75}