Fix duplicate waypoint issues and bad bed positions

This commit is contained in:
Brady 2018-08-23 19:39:04 -05:00
parent 18a9206058
commit 00b0266c43
No known key found for this signature in database
GPG Key ID: 73A788379A197567
2 changed files with 4 additions and 8 deletions

View File

@ -42,16 +42,12 @@ public final class LocationTrackingBehavior extends Behavior {
@Override
public void onBlockInteract(BlockInteractEvent event) {
if (event.getType() == BlockInteractEvent.Type.USE && BlockStateInterface.getBlock(event.getPos()) instanceof BlockBed) {
createWaypointAtPlayer("bed", Waypoint.Tag.BED);
WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, event.getPos()));
}
}
@Override
public void onPlayerDeath() {
createWaypointAtPlayer("death", Waypoint.Tag.DEATH);
}
private void createWaypointAtPlayer(String name, Waypoint.Tag tag) {
WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint(name, tag, playerFeet()));
WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint("death", Waypoint.Tag.DEATH, playerFeet()));
}
}

View File

@ -55,12 +55,12 @@ public class Waypoint {
return false;
}
Waypoint w = (Waypoint) o;
return name.equals(w.name) && tag == w.tag && creationTimestamp == w.creationTimestamp && location.equals(w.location);
return name.equals(w.name) && tag == w.tag && location.equals(w.location);
}
@Override
public int hashCode() {
return name.hashCode() + tag.hashCode() + (int) creationTimestamp + location.hashCode(); //lol
return name.hashCode() + tag.hashCode() + location.hashCode(); //lol
}
public long creationTimestamp() {