From cf5c63c7ed2c3d20082e1f2b13e8a81a02518c45 Mon Sep 17 00:00:00 2001 From: hhhzzzsss Date: Mon, 19 Jun 2023 19:51:33 -0500 Subject: [PATCH] Fixed issues with stage breaking/placement --- .../songplayer/playing/SongHandler.java | 6 ++++- .../hhhzzzsss/songplayer/playing/Stage.java | 26 ++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) 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 2131d32..7474e71 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/playing/SongHandler.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/playing/SongHandler.java @@ -229,6 +229,7 @@ public class SongHandler { return; } else { stage.checkBuildStatus(currentSong); + stage.sendMovementPacketToStagePosition(); } } @@ -481,7 +482,10 @@ public class SongHandler { SongPlayer.fakePlayer.setYaw(yaw); SongPlayer.fakePlayer.setHeadYaw(yaw); } - SongPlayer.MC.player.networkHandler.getConnection().send(new PlayerMoveC2SPacket.LookAndOnGround(yaw, pitch, true)); + SongPlayer.MC.player.networkHandler.getConnection().send(new PlayerMoveC2SPacket.Full( + stage.position.getX() + 0.5, stage.position.getY(), stage.position.getZ() + 0.5, + yaw, pitch, + true)); } } diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/playing/Stage.java b/src/main/java/com/github/hhhzzzsss/songplayer/playing/Stage.java index 4fa652b..5ee12c2 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/playing/Stage.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/playing/Stage.java @@ -42,7 +42,18 @@ public class Stage { } public void sendMovementPacketToStagePosition() { - SongPlayer.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(position.getX()+0.5, position.getY(), position.getZ()+0.5, true)); + if (SongPlayer.fakePlayer != null) { + SongPlayer.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.Full( + position.getX() + 0.5, position.getY(), position.getZ() + 0.5, + SongPlayer.fakePlayer.getYaw(), SongPlayer.fakePlayer.getPitch(), + true)); + } + else { + SongPlayer.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.Full( + position.getX() + 0.5, position.getY(), position.getZ() + 0.5, + SongPlayer.MC.player.getYaw(), SongPlayer.MC.player.getPitch(), + true)); + } } public void checkBuildStatus(Song song) { @@ -132,11 +143,10 @@ public class Stage { for (int noteId : missingNotes) { BlockPos bp = unusedNoteblockLocations.get(idx++); noteblockPositions.put(noteId, bp); - int dy = bp.getY() - position.getY(); - // Optional break locations - if (dy < -1 || dy > 2) { - breakLocations.add(bp.up()); - } + } + + for (BlockPos bp : noteblockPositions.values()) { // Optional break locations + breakLocations.add(bp.up()); } requiredBreaks = breakLocations @@ -177,6 +187,10 @@ public class Stage { }) .collect(Collectors.toCollection(LinkedList::new)); + if (requiredBreaks.stream().allMatch(bp -> !withinBreakingDist(bp.getX()-position.getX(), bp.getY()-position.getY(), bp.getZ()-position.getZ()))) { + requiredBreaks.clear(); + } + // Set total missing notes totalMissingNotes = missingNotes.size(); }