Fixed issues with stage breaking/placement

This commit is contained in:
hhhzzzsss 2023-06-19 19:51:33 -05:00
parent 71ae0bbcd3
commit cf5c63c7ed
2 changed files with 25 additions and 7 deletions

View file

@ -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));
}
}

View file

@ -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();
}