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

@ -3627,7 +3627,6 @@ public class Player extends Playable
{
playerIU.addRemovedItem(oldItem);
}
sendInventoryUpdate(playerIU);
}
else
@ -3650,7 +3649,6 @@ public class Player extends Playable
{
playerIU.addNewItem(newItem);
}
targetPlayer.sendPacket(playerIU);
}
else

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
@ -243,6 +244,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);
@ -260,12 +262,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.sendInventoryUpdate(iu);
}
}
refreshWeight();

View File

@ -475,34 +475,34 @@ public class PlayerInventory extends Inventory
{
_beautyTickets = item;
}
}
if ((item != null) && (actor != null))
{
// Send inventory update packet
if (update)
if (actor != null)
{
if (!Config.FORCE_INVENTORY_UPDATE)
// Send inventory update packet
if (update)
{
final InventoryUpdate playerIU = new InventoryUpdate();
if (item.isStackable() && (item.getCount() > count))
if (!Config.FORCE_INVENTORY_UPDATE)
{
playerIU.addModifiedItem(item);
final InventoryUpdate playerIU = new InventoryUpdate();
if (item.isStackable() && (item.getCount() > count))
{
playerIU.addModifiedItem(item);
}
else
{
playerIU.addNewItem(item);
}
actor.sendInventoryUpdate(playerIU);
}
else
{
playerIU.addNewItem(item);
actor.sendItemList(false);
}
actor.sendInventoryUpdate(playerIU);
}
else
{
actor.sendItemList(false);
}
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemAdd(actor, item), actor, item.getTemplate());
}
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemAdd(actor, item), actor, item.getTemplate());
}
return item;
}