{"action":"closed","issue":{"url":"https://api.github.com/repos/Nukkit/Nukkit/issues/646","repository_url":"https://api.github.com/repos/Nukkit/Nukkit","labels_url":"https://api.github.com/repos/Nukkit/Nukkit/issues/646/labels{/name}","comments_url":"https://api.github.com/repos/Nukkit/Nukkit/issues/646/comments","events_url":"https://api.github.com/repos/Nukkit/Nukkit/issues/646/events","html_url":"https://github.com/Nukkit/Nukkit/issues/646","id":144712565,"number":646,"title":"Cannot use Vector3 as a hashed collection key","user":{"login":"pcbeard","id":793781,"avatar_url":"https://avatars.githubusercontent.com/u/793781?v=3","gravatar_id":"","url":"https://api.github.com/users/pcbeard","html_url":"https://github.com/pcbeard","followers_url":"https://api.github.com/users/pcbeard/followers","following_url":"https://api.github.com/users/pcbeard/following{/other_user}","gists_url":"https://api.github.com/users/pcbeard/gists{/gist_id}","starred_url":"https://api.github.com/users/pcbeard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pcbeard/subscriptions","organizations_url":"https://api.github.com/users/pcbeard/orgs","repos_url":"https://api.github.com/users/pcbeard/repos","events_url":"https://api.github.com/users/pcbeard/events{/privacy}","received_events_url":"https://api.github.com/users/pcbeard/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Nukkit/Nukkit/labels/Enhancement","name":"Enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/Nukkit/Nukkit/labels/High%20Priority","name":"High Priority","color":"e11d21"},{"url":"https://api.github.com/repos/Nukkit/Nukkit/labels/In%20Progress","name":"In Progress","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-30T20:36:15Z","updated_at":"2016-04-02T14:04:35Z","closed_at":"2016-04-02T14:04:35Z","body":"I see two flaws with the Vector3 class:\r\n\r\nIt doesn't implement these methods:\r\n\r\n    boolean equals(Object o);\r\n    int hashCode();\r\n\r\nI tried adding them,\r\n\r\n    public boolean equals(Object o) {\r\n      if (o instanceof Vector3) {\r\n        Vector3 v = (Vector3)o;\r\n        return v != null && this.x == v.x && this.y == v.y && this.z == v.z;\r\n      }\r\n      return false;\r\n    }\r\n\r\n    public int hashCode() {\r\n      // consider http://www.beosil.com/download/CollisionDetectionHashing_VMV03.pdf\r\n      return (int)(Double.doubleToLongBits(x) ^ Double.doubleToLongBits(y) ^ Double.doubleToLongBits(z));\r\n    }\r\n\r\nHowever, I could no longer log-in to the server after making these changes. Something may be relying on the default behaviors of these methods.\r\n\r\nI worked around by creating my own class to represent block locations using integer coordinates. Technically, only entities need floating point coordinates."}}