This commit is contained in:
2025-12-14 01:45:02 +01:00
parent 60d509344c
commit f03e13236f
30 changed files with 260 additions and 2480 deletions

View File

@@ -1,56 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace KCM.Packets.Game.GameVillager
{
public class VillagerSnapshotPacket : Packet
{
public override ushort packetId => (ushort)Enums.Packets.VillagerSnapshot;
public List<Guid> guids { get; set; } = new List<Guid>();
public List<Vector3> positions { get; set; } = new List<Vector3>();
public override void HandlePacketClient()
{
if (KCClient.client != null && clientId == KCClient.client.Id)
return;
try
{
int count = Math.Min(guids?.Count ?? 0, positions?.Count ?? 0);
if (count == 0)
return;
for (int i = 0; i < count; i++)
{
Guid guid = guids[i];
Vector3 position = positions[i];
Villager villager = null;
try
{
villager = Villager.villagers?.data.FirstOrDefault(v => v != null && v.guid == guid);
}
catch
{
}
if (villager == null)
continue;
villager.TeleportTo(position);
}
}
catch (Exception e)
{
Main.helper.Log("Error handling villager snapshot packet: " + e.Message);
}
}
public override void HandlePacketServer()
{
}
}
}

View File

@@ -1,9 +1,8 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace KCM.Packets.Game
{
@@ -12,30 +11,18 @@ namespace KCM.Packets.Game
public override ushort packetId => (int)Enums.Packets.SetSpeed;
public int speed { get; set; }
public bool isPaused { get; set; }
public override void HandlePacketClient()
{
if (clientId == KCClient.client.Id) // Prevent speed softlock
return;
try
{
Main.helper.Log($"Received SetSpeed packet: speed={speed}, isPaused={isPaused}");
// Simply apply the speed - SpeedControlUISetSpeedHook will handle this correctly
// since we're coming from a packet (PacketHandler.IsHandlingPacket will be true)
SpeedControlUI.inst.SetSpeed(speed);
}
catch (Exception e)
{
Main.helper.Log("Error handling SetSpeed packet: " + e.Message);
}
SpeedControlUI.inst.SetSpeed(speed);
}
public override void HandlePacketServer()
{
// Server relay is handled automatically by PacketHandler unless [NoServerRelay] is used.
//throw new NotImplementedException();
}
}
}