Sort gravity blocks by y level during cleanup

This commit is contained in:
hhhzzzsss 2024-05-25 23:31:55 -05:00
parent 56d40cad32
commit 282a7ea451

View file

@ -470,7 +470,7 @@ public class SongHandler {
cleaningUp = false;
SongPlayer.addChatMessage("§6Finished restoring original blocks");
if (!cleanupUnplaceableBlocks.isEmpty()) {
SongPlayer.addChatMessage(String.format("§3%d §6blocks were not successfully restored"));
SongPlayer.addChatMessage(String.format("§3%d §6blocks could not be restored", cleanupUnplaceableBlocks.size()));
}
}
}
@ -504,6 +504,14 @@ public class SongHandler {
} else if (!a_grav && b_grav) {
return -1;
}
// If there's gravity, sort by y coordinate
if (a_grav && b_grav) {
if (a.getY() < b.getY()) {
return -1;
} else if (a.getY() > b.getY()) {
return 1;
}
}
// Then sort by distance
int a_dx = a.getX() - lastStage.position.getX();
int a_dy = a.getY() - lastStage.position.getY();
@ -541,6 +549,14 @@ public class SongHandler {
} else if (!a_grav && b_grav) {
return 1;
}
// If there's gravity, sort by y coordinate
if (a_grav && b_grav) {
if (a.getY() < b.getY()) {
return 1;
} else if (a.getY() > b.getY()) {
return -1;
}
}
// Then sort by distance
int a_dx = a.getX() - lastStage.position.getX();
int a_dy = a.getY() - lastStage.position.getY();