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 @Override
public void onBlockInteract(BlockInteractEvent event) { public void onBlockInteract(BlockInteractEvent event) {
if (event.getType() == BlockInteractEvent.Type.USE && BlockStateInterface.getBlock(event.getPos()) instanceof BlockBed) { 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 @Override
public void onPlayerDeath() { public void onPlayerDeath() {
createWaypointAtPlayer("death", Waypoint.Tag.DEATH); WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint("death", Waypoint.Tag.DEATH, playerFeet()));
}
private void createWaypointAtPlayer(String name, Waypoint.Tag tag) {
WorldProvider.INSTANCE.getCurrentWorld().waypoints.addWaypoint(new Waypoint(name, tag, playerFeet()));
} }
} }

View File

@ -55,12 +55,12 @@ public class Waypoint {
return false; return false;
} }
Waypoint w = (Waypoint) o; 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 @Override
public int hashCode() { public int hashCode() {
return name.hashCode() + tag.hashCode() + (int) creationTimestamp + location.hashCode(); //lol return name.hashCode() + tag.hashCode() + location.hashCode(); //lol
} }
public long creationTimestamp() { public long creationTimestamp() {