From 282a7ea4519e8f448b8fd8fa82076f48d6261688 Mon Sep 17 00:00:00 2001 From: hhhzzzsss Date: Sat, 25 May 2024 23:31:55 -0500 Subject: [PATCH] Sort gravity blocks by y level during cleanup --- .../songplayer/playing/SongHandler.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/playing/SongHandler.java b/src/main/java/com/github/hhhzzzsss/songplayer/playing/SongHandler.java index 33e7cf2..86b7f01 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/playing/SongHandler.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/playing/SongHandler.java @@ -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();