Additional InventoryUpdate when creating more than one non-stackable item.

This commit is contained in:
MobiusDevelopment
2022-06-24 21:06:46 +00:00
parent b89b99498b
commit c2baac74a3
77 changed files with 884 additions and 506 deletions

View File

@@ -36,6 +36,7 @@ import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.item.ItemTemplate;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
/**
* @author Advi
@@ -260,6 +261,7 @@ public abstract class ItemContainer
}
else // If item hasn't be found in inventory, create new one
{
final InventoryUpdate iu = new InventoryUpdate();
for (int i = 0; i < count; i++)
{
final ItemTemplate template = ItemTable.getInstance().getTemplate(itemId);
@@ -278,12 +280,24 @@ public abstract class ItemContainer
// Add item in inventory
addItem(item);
// Add additional items to InventoryUpdate.
if ((count > 1) && (i < (count - 1)))
{
iu.addNewItem(item);
}
// If stackable, end loop as entire count is included in 1 instance of item
if (template.isStackable() || !Config.MULTIPLE_ITEM_DROP)
{
break;
}
}
// If additional items where created send InventoryUpdate.
if ((count > 1) && (item != null) && !item.isStackable() && (item.getItemLocation() == ItemLocation.INVENTORY))
{
actor.sendPacket(iu);
}
}
refreshWeight();

View File

@@ -478,13 +478,21 @@ public class PlayerInventory extends Inventory
{
_ancientAdena = item;
}
if (actor != null)
{
// Send inventory update packet
if (!Config.FORCE_INVENTORY_UPDATE)
{
final InventoryUpdate playerIU = new InventoryUpdate();
playerIU.addItem(item);
if (item.isStackable() && (item.getCount() > count))
{
playerIU.addModifiedItem(item);
}
else
{
playerIU.addNewItem(item);
}
actor.sendPacket(playerIU);
}
else