diff --git a/Server/src/main/content/global/skill/runecrafting/PouchManager.kt b/Server/src/main/content/global/skill/runecrafting/PouchManager.kt index 087478bfc..22cc1865f 100644 --- a/Server/src/main/content/global/skill/runecrafting/PouchManager.kt +++ b/Server/src/main/content/global/skill/runecrafting/PouchManager.kt @@ -75,11 +75,11 @@ class PouchManager(val player: Player) { pouch.currentCap = pouch.capacity pouch.charges = pouch.maxCharges pouch.remakeContainer() + replaceAllItems(player, itemId, itemId - 1) //in case the player had more copies } } else { if (!isDecayedPouch(itemId)) { - val slot = player.inventory.getSlot(Item(itemId)) - replaceSlot(player, slot, Item(itemId + 1)) + replaceAllItems(player, itemId, itemId + 1) } sendMessage(player, "Your pouch has decayed through use.") //https://www.youtube.com/watch?v=FUcPYrgPUlQ pouch.charges = 9 * pouch.currentCap //implied by multiple contemporaneous sources, quantified only by https://oldschool.runescape.wiki/w/Large_pouch diff --git a/Server/src/main/content/global/skill/runecrafting/abyss/DarkMageDialogue.java b/Server/src/main/content/global/skill/runecrafting/abyss/DarkMageDialogue.java index 0348f19c8..a7b6450cd 100644 --- a/Server/src/main/content/global/skill/runecrafting/abyss/DarkMageDialogue.java +++ b/Server/src/main/content/global/skill/runecrafting/abyss/DarkMageDialogue.java @@ -6,6 +6,8 @@ import core.game.node.entity.player.Player; import core.game.node.item.Item; import org.rs09.consts.Items; +import static core.api.ContentAPIKt.replaceAllItems; + /** * Handles the dark mages dialogue. * @author Vexia @@ -153,14 +155,7 @@ public final class DarkMageDialogue extends DialoguePlugin { pouch.getContainer().add(essItem); } if (id != Items.SMALL_POUCH_5509) { - if (player.getInventory().contains(id + 1, 1)) { - player.getInventory().remove(new Item(id + 1, 1)); - player.getInventory().add(new Item(id, 1)); - } - if (player.getBank().contains(id + 1, 1)) { - player.getBank().remove(new Item(id + 1, 1)); - player.getBank().add(new Item(id, 1)); - } + replaceAllItems(player, id + 1, id); } }); return true; diff --git a/Server/src/main/core/api/ContentAPI.kt b/Server/src/main/core/api/ContentAPI.kt index 0f1bae085..f11ca49ac 100644 --- a/Server/src/main/core/api/ContentAPI.kt +++ b/Server/src/main/core/api/ContentAPI.kt @@ -408,14 +408,21 @@ fun replaceSlot(player: Player, slot: Int, item: Item, currentItem: Item? = null */ fun replaceAllItems(player: Player, itemId: Int, replaceId: Int) { val item = Item(itemId) - for (container in arrayOf(player.inventory, player.equipment, player.bankPrimary, player.bankSecondary)) { + val containers = if (player.familiarManager.hasFamiliar() && player.familiarManager.familiar.isBurdenBeast()) { + arrayOf(player.inventory, player.equipment, player.bankPrimary, player.bankSecondary, (player.familiarManager.familiar as BurdenBeast).container) + } else { + arrayOf(player.inventory, player.equipment, player.bankPrimary, player.bankSecondary) + } + for (container in containers) { val hasItems = container.getAll(item) - if (!item.definition.isStackable && (container == player.inventory || container == player.equipment)) { + if (!item.definition.isStackable && container != player.bankPrimary && container != player.bankSecondary) { + // just replace for (target in hasItems) { val newItem = Item(replaceId, target.amount) container.replace(newItem, target.slot, true) } } else { + // add to existing stack if possible if (hasItems.size > 0) { val target = hasItems[0] var count = 0 diff --git a/Server/src/main/core/cache/def/impl/ItemDefinition.java b/Server/src/main/core/cache/def/impl/ItemDefinition.java index 6935833f6..0474e11f8 100644 --- a/Server/src/main/core/cache/def/impl/ItemDefinition.java +++ b/Server/src/main/core/cache/def/impl/ItemDefinition.java @@ -605,8 +605,13 @@ public class ItemDefinition extends Definition { * @return {@code True} if so. */ public static boolean canEnterEntrana(Player player) { - Container[] container = new Container[] { player.getInventory(), player.getEquipment() }; - for (Container c : container) { + Container[] containers; + if (player.getFamiliarManager().hasFamiliar() && player.getFamiliarManager().getFamiliar().isBurdenBeast()) { + containers = new Container[] { player.getInventory(), player.getEquipment(), ((BurdenBeast) player.getFamiliarManager().getFamiliar()).getContainer() }; + } else { + containers = new Container[] { player.getInventory(), player.getEquipment() }; + } + for (Container c : containers) { for (Item i : c.toArray()) { if (i == null) { continue;