From 8a72694a74a9f12cb78fbcd294186069d5050131 Mon Sep 17 00:00:00 2001 From: Sen Date: Thu, 7 Aug 2025 02:28:04 +0200 Subject: [PATCH] fix freecam --- client/src/main/java/client/Client.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 4abe7c6a..1c8c5eba 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -433,6 +433,7 @@ public class Client implements IThreadListener { public boolean fullscreen; public boolean interrupted; public boolean freecam; + public boolean servercam; private int leftClickCounter; private int rightClickTimer; @@ -739,7 +740,7 @@ public class Client implements IThreadListener { this.debugWorld = false; this.charEditor = false; this.viewEntity = null; - this.freecam = false; + this.freecam = this.servercam = false; this.connection = null; this.world = null; this.resetWorld(); @@ -1647,7 +1648,7 @@ public class Client implements IThreadListener { { this.resetWorld(); this.viewEntity = null; - this.freecam = false; + this.freecam = this.servercam = false; this.connection = null; this.soundManager.stopSounds(); this.world = new WorldClient(dim); @@ -1695,7 +1696,7 @@ public class Client implements IThreadListener { this.player = this.controller.createPlayerEntity(this.world, type); this.player.getDataWatcher().updateWatchedObjectsFromList(entityplayersp.getDataWatcher().getAllWatched()); this.viewEntity = this.player; - this.freecam = false; + this.freecam = this.servercam = false; this.player.preparePlayerToSpawn(); this.spawnEntity(this.player); this.player.rotYaw = -180.0F; @@ -1756,6 +1757,7 @@ public class Client implements IThreadListener { { this.viewEntity = viewingEntity; this.freecam = false; + this.servercam = viewingEntity != this.player; } public void schedule(Runnable task) { @@ -1844,7 +1846,7 @@ public class Client implements IThreadListener { if(this.viewEntity instanceof EntityCamera camera) { camera.onUpdate(); camera.setMovement(this.moveStrafe, this.moveForward, this.jump, this.sneak); - if(!this.freecam) { + if(!this.freecam && this.servercam) { this.getNetHandler().addToSendQueue(new CPacketInput(this.moveStrafe, this.moveForward, this.jump, this.sneak, true)); this.getNetHandler().addToSendQueue(new CPacketPlayerPosLook(camera.posX, camera.posY, camera.posZ, camera.rotYaw, camera.rotPitch, this.sprint).setCamera()); if(this.player != null) @@ -2736,7 +2738,7 @@ public class Client implements IThreadListener { if(Util.DEVMODE) this.registerDebug(Keysym.SPACE, "Kamera umschalten", new DebugRunner() { public void execute(Keysym key) { - if(Client.this.world != null && Client.this.player != null) { + if(Client.this.world != null && Client.this.player != null && !Client.this.servercam) { Client.this.viewEntity = Client.this.viewEntity == Client.this.player ? new EntityCamera(Client.this.world, Client.this.player.posX, Client.this.player.posY, Client.this.player.posZ, Client.this.player.rotYaw, Client.this.player.rotPitch, 256, 2.5f, CameraType.FREE, false) : Client.this.player; Client.this.freecam = Client.this.viewEntity != Client.this.player;