Skip to content

Commit a456c08

Browse files
authored
[Savestates] Fix GuiRenameScreen desyncing (#276)
The fix is really dumb... - Fix NPE with SubtickableGui
2 parents 596c0b3 + 613a08a commit a456c08

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

src/main/java/com/minecrafttas/tasmod/savestates/SavestateHandlerServer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,7 @@ public void onServerPacket(PacketID id, ByteBuffer buf, String username) throws
457457
* Once the player is done renaming the savestate, the screens are cleared for all players.
458458
*/
459459
try {
460-
// TODO Currently desyncs the savestates... Bigger investigation necessary
461-
// TASmod.server.sendTo(player, new TASmodBufferBuilder(TASmodPackets.SAVESTATE_RENAME_SCREEN).writeInt(paths.getSavestate().index));
460+
TASmod.server.sendTo(player, new TASmodBufferBuilder(TASmodPackets.SAVESTATE_RENAME_SCREEN).writeInt(paths.getSavestate().index));
462461
} catch (Exception e) {
463462
LOGGER.catching(e);
464463
}

src/main/java/com/minecrafttas/tasmod/savestates/handlers/SavestateGuiHandlerClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ else if (state == SavestateState.LOADING)
5656
break;
5757
case SAVESTATE_RENAME_SCREEN:
5858
int index = TASmodBufferBuilder.readInt(buf);
59+
mc.displayGuiScreen(null);
5960
TASmodClient.tickSchedulerClient.add(() -> {
6061
displayGuiRename(index);
6162
});

src/main/java/com/minecrafttas/tasmod/virtual/VirtualInterpolationHandler.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,10 @@ public class VirtualInterpolationHandler implements EventVirtualInput.EventVirtu
3333
* Is updated in {@link #onVirtualCameraTick()}
3434
*/
3535
private final List<VirtualCameraAngle> cameraAngleStates = new ArrayList<>();
36-
// private int debugFinalIndex = 0;
3736

3837
@Override
3938
public VirtualMouse onVirtualMouseTick(VirtualMouse vmouse) {
4039
this.nextMouse = vmouse;
41-
// if (TASmodClient.controller.isPlayingback()) {
42-
// System.out.println(debugFinalIndex == mousePointerInterpolationStates.size() - 1);
43-
// }
4440
mousePointerStates.clear();
4541
TASmodClient.controller.getNextMouse().getStates(mousePointerStates);
4642
return null;
@@ -69,7 +65,6 @@ public MouseInterpolation getInterpolatedMouseCursor(float partialTick, boolean
6965
if (enable && !mousePointerStates.isEmpty()) {
7066
partialTick = dynamicallyRound(partialTick, TASmodClient.tickratechanger.ticksPerSecond);
7167
int index = (int) MathHelper.clampedLerp(0, mousePointerStates.size() - 1, partialTick); // Get interpolate index
72-
// debugFinalIndex = index;
7368
VirtualMouse interpolatedCamera = mousePointerStates.get(index);
7469

7570
interpolatedPointerX = interpolatedCamera.getCursorX();
@@ -79,7 +74,7 @@ public MouseInterpolation getInterpolatedMouseCursor(float partialTick, boolean
7974
Minecraft mc = Minecraft.getMinecraft();
8075
GuiScreenDuck gui = (GuiScreenDuck) mc.currentScreen;
8176

82-
if (gui != null) {
77+
if (gui != null && !(mc.currentScreen instanceof SubtickGuiScreen)) {
8378
interpolatedPointerX = gui.rescaleX(PointerNormalizer.reapplyScalingX(interpolatedPointerX));
8479
interpolatedPointerY = gui.rescaleY(PointerNormalizer.reapplyScalingY(interpolatedPointerY));
8580
}

0 commit comments

Comments
 (0)