fix: camera and outdated cache

This commit is contained in:
Octol1ttle 2024-05-06 23:23:32 +05:00
parent 8dd209899f
commit d70b2b5974
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
4 changed files with 23 additions and 18 deletions

View file

@ -117,7 +117,7 @@ public class KnockdownsClientEvents {
|| client.player.getEyePos().distanceTo(eyePosition) > 64.0
|| client.world
.raycast(new RaycastContext(
client.player.getEyePos(),
client.getEntityRenderDispatcher().camera.getPos(),
eyePosition,
RaycastContext.ShapeType.VISUAL,
RaycastContext.FluidHandling.SOURCE_ONLY,

View file

@ -4,6 +4,7 @@ import dev.architectury.networking.NetworkManager;
import java.util.Optional;
import java.util.UUID;
import java.util.function.Supplier;
import net.minecraft.client.MinecraftClient;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.math.Vec3d;
import ru.octol1ttle.knockdowns.common.api.RemotePlayer;
@ -37,6 +38,13 @@ public class RemotePlayerS2CPacket extends KnockdownsPacket {
@Override
public void apply(Supplier<NetworkManager.PacketContext> contextSupplier) {
NetworkManager.PacketContext context = contextSupplier.get();
context.queue(() -> KnockdownsClientEvents.remotePlayers.put(targetUuid, Optional.of(new RemotePlayer(this.eyePosition, this.knockedDown))));
context.queue(() -> {
//noinspection DataFlowIssue
if (MinecraftClient.getInstance().player.getUuid().equals(targetUuid)) {
KnockdownsClientEvents.remotePlayers.clear();
} else {
KnockdownsClientEvents.remotePlayers.put(targetUuid, Optional.of(new RemotePlayer(this.eyePosition, this.knockedDown)));
}
});
}
}