Fix move item

This commit is contained in:
Zeffuro
2025-12-24 21:11:32 +01:00
parent a0fb7f5103
commit 67bd995329
4 changed files with 185 additions and 96 deletions
+52
View File
@@ -0,0 +1,52 @@
using AetherBags. Extensions;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Component. GUI;
using ValueType = FFXIVClientStructs. FFXIV. Component.GUI.ValueType;
namespace AetherBags. Helpers;
public static unsafe class InventoryMoveHelper
{
public static void MoveItem(InventoryType sourceContainer, ushort sourceSlot, InventoryType destContainer, ushort destSlot)
{
bool isCrossContainerMove = ! sourceContainer.IsSameContainerGroup(destContainer);
if (isCrossContainerMove)
{
MoveItemViaAgent(sourceContainer, sourceSlot, destContainer, destSlot);
}
else
{
InventoryManager.Instance()->MoveItemSlot(sourceContainer, sourceSlot, destContainer, destSlot, true);
}
}
private static void MoveItemViaAgent(InventoryType sourceInventory, ushort sourceSlot, InventoryType destInventory, ushort destSlot)
{
uint sourceContainerId = sourceInventory.AgentItemContainerId;
uint destContainerId = destInventory.AgentItemContainerId;
if (sourceContainerId == 0 || destContainerId == 0)
{
Services.Logger.Warning($"[MoveItemViaAgent] Invalid container IDs: src={sourceContainerId}, dst={destContainerId}");
return;
}
Services.Logger.Debug($"[MoveItemViaAgent] {sourceContainerId}:{sourceSlot} -> {destContainerId}:{destSlot}");
var atkValues = stackalloc AtkValue[4];
for (var i = 0; i < 4; i++)
atkValues[i]. Type = ValueType.UInt;
atkValues[0].SetUInt(sourceContainerId);
atkValues[1].SetUInt(sourceSlot);
atkValues[2].SetUInt(destContainerId);
atkValues[3].SetUInt(destSlot);
var retVal = stackalloc AtkValue[1];
RaptureAtkModule* atkModule = RaptureAtkModule.Instance();
atkModule->HandleItemMove(retVal, atkValues, 4);
}
}