1package com.runehive.game.world.items.containers.equipment;
3import com.google.common.collect.ImmutableSet;
4import com.runehive.content.emote.Skillcape;
5import com.runehive.content.skillcape.SkillCape;
6import com.runehive.game.Graphic;
7import com.runehive.game.UpdatePriority;
8import com.runehive.game.world.entity.combat.CombatType;
9import com.runehive.game.world.entity.combat.attack.listener.CombatListenerManager;
10import com.runehive.game.world.entity.combat.ranged.RangedAmmunition;
11import com.runehive.game.world.entity.combat.ranged.RangedWeaponDefinition;
12import com.runehive.game.world.entity.combat.ranged.RangedWeaponType;
13import com.runehive.game.world.entity.combat.weapon.WeaponInterface;
14import com.runehive.game.world.entity.mob.UpdateFlag;
15import com.runehive.game.world.entity.mob.player.Player;
16import com.runehive.game.world.items.Item;
17import com.runehive.game.world.items.containers.ItemContainer;
18import com.runehive.game.world.items.containers.ItemContainerAdapter;
19import com.runehive.game.world.items.containers.inventory.Inventory;
20import com.runehive.game.world.items.ground.GroundItem;
21import com.runehive.net.packet.out.SendItemOnInterface;
22import com.runehive.net.packet.out.SendMessage;
23import com.runehive.net.packet.out.SendString;
24import com.runehive.util.Items;
25import com.runehive.util.Utility;
27import java.util.Arrays;
28import java.util.Optional;
29import java.util.stream.IntStream;
31import static com.runehive.game.world.entity.mob.MobAnimation.*;
41 public static final int SIZE = 14;
47 public static final int
63 public static final int
80 private static final int[]
BONUS_IDS = IntStream.rangeClosed(15130, 15143).toArray();
106 private static final String
EXCEPTION_MESSAGE =
"Please use { equipment.set(index, Item) } instead";
131 Arrays.fill(
player.getBonuses(), 0);
132 for (
int index = 0; index <
getItems().length; index++) {
147 player.interfaceManager.open(15106);
173 public boolean remove(
Item item,
int preferredIndex,
boolean refresh) {
174 boolean removed = super.remove(item, preferredIndex,
refresh);
189 for (
Item item :
player.inventory.toArray()) {
192 weight += item.getWeight();
221 set(type.
getSlot(), item,
false);
226 int index =
player.inventory.computeIndexForId(item.
getId());
230 public boolean equip(
int inventoryIndex) {
231 if (inventoryIndex == -1)
249 if (item.
getId() == 21633)
254 Item toRemove =
null;
258 if (Integer.MAX_VALUE - current.
getAmount() < amount) {
259 amount = Integer.MAX_VALUE - current.
getAmount();
275 if (toRemove !=
null && !
inventory.hasCapacityFor(toRemove)) {
280 set(type.
getSlot(), item,
true);
281 if (current !=
null) {
292 player.getCombat().reset();
295 if (toRemove !=
null) {
297 set(
slot,
null,
true);
299 inventory.add(toRemove, inventoryIndex,
true);
302 if (
player.interfaceManager.isInterfaceOpen(15106)) {
330 if (equipmentIndex == -1)
337 if (!container.
add(
unequip, preferredIndex,
true)) {
341 set(equipmentIndex,
null,
true);
350 player.getCombat().reset();
353 if (!
player.interfaceManager.isClear() && !
player.interfaceManager.isInterfaceOpen(15106)) {
354 player.interfaceManager.close(
false);
357 if (
player.interfaceManager.isInterfaceOpen(15106)) {
375 for (
int index = 0; index < item.
getBonuses().length; index++) {
381 for (
int index = 0; index < item.
getBonuses().length; index++) {
388 for (
int i = 0; i <
player.getBonuses().length; i++) {
391 if (
player.getBonus(i) >= 0)
394 bonus +=
player.getBonus(i);
500 Arrays.fill(
player.getBonuses(), 0);
505 return item !=
null && item.
getId() == itemId;
515 set(type.
getSlot(),
null,
true);
525 double boostedExperience = 0.2;
565 boolean isBlowpipe = item.
matchesId(12_926);
567 if (isBlowpipe &&
player.blowpipeDarts !=
null) {
583 if (isBlowpipe ||
getWeapon().getRangedDefinition()
603 player.rangedDefinition =
null;
608 player.rangedDefinition = def;
610 switch (def.getType()) {
629 int stand = PLAYER_STAND;
630 int walk = PLAYER_WALK;
631 int run = PLAYER_RUN;
647 player.mobAnimation.setStand(stand);
648 player.mobAnimation.setWalk(walk);
649 player.mobAnimation.setRun(run);
653 if (!
player.equipment.hasShield()) {
659 return shield.
getId() == 11283 || shield.
getId() == 11284 ||
660 shield.
getId() == 21633 || shield.
getId() == 21634 ||
661 shield.
getId() == 22002 || shield.
getId() == 22003;
719 private static final int[]
ZAMORAK_ITEMS = {1033, 1035, 2414, 2417, 2653, 2655, 2657, 2659, 3478, 4039, 6764, 10368, 10370, 10372, 10374, 10444, 10450, 10456, 10460, 10468, 10474, 10776, 10786, 10790, 11808, 11824, 11889, 11892, 12638, 13333, 13334, 19936, 20374, 21780, 21782, 21795, 1724, 3842, 20223, 11791, 12904};
720 private static final int[]
SARADOMIN_ITEMS = {2412, 2415, 2661, 2663, 2665, 2667, 3479, 4037, 6762, 10384, 10386, 10388, 10390, 10440, 10446, 10452, 10458, 10464, 10470, 10778, 10784, 10792, 11806, 11838, 11891, 12637, 12809, 13331, 13332, 19933, 20372, 21776, 21778, 21791, 3840, 12598, 20220, 19997};
721 private static final int[]
BANDOS_ITEMS = {11804, 11832, 11834, 11836, 12265, 12267, 12269, 12271, 12273, 12275, 12480, 12482, 12484, 12486, 12488, 12498, 12500, 12502, 12504, 19924, 20370, 20782, 20232, 11061, 12608, 21733};
722 private static final int[]
ARMADYL_ITEMS = {84, 87, 11785, 11802, 11826, 11830, 12253, 12255, 12257, 12259, 12261, 12263, 12470, 12472, 12474, 12476, 12478, 12506, 12508, 12511, 12512, 19930, 20368, 20229, 12610};
724 public static final int []
PICKAXES = {1265, 1267, 1269, 1273, 1271, 1275, 13243, 20014, 11920, 12797};
749 public boolean contains(
int[] bowsWithNoArrowsRequired) {
750 return containsAny(22550, 25865, 25867, 25884, 25886, 25890, 25892, 25894, 25896, 25888);
773 if (oldItem.equals(newItem))
777 oldItem.filter(item -> item.getWeaponInterface() !=
null)
778 .orElse(newItem.filter(item -> item.getWeaponInterface() !=
null)
779 .orElse(
null)) !=
null;
781 oldItem.ifPresent(item -> {
787 newItem.ifPresent(item -> {
793 if (weapon && !
login)
Represents a single graphic that can be used by entities.
static void addListener(Player player, int id)
static void removeListener(Player player, int id)
This class represents a character controlled by a player.
The container class that represents an item that can be interacted with.
Optional< RangedWeaponDefinition > getRangedDefinition()
final int getId()
Gets the identification of this item.
static boolean valid(Item item)
Determines if item is valid.
final int getAmount()
Gets the quantity of this item.
Item createAndIncrement(int addAmount)
Creates a new item with amount + addAmount and the same identifier.
boolean matchesId(int id)
EquipmentType getEquipmentType()
void sendItemsToWidget(ItemContainer container)
Queues a message that displays items from an ItemContainer on a widget.
ItemContainerAdapter(Player player)
Creates a new ItemContainerAdapter.
final Player player
The Player instance.
final void fireItemUpdatedEvent(Item oldItem, Item newItem, int index, boolean refresh)
Fires the ItemContainerListener.itemUpdated(ItemContainer, int) event.
ItemContainer(int capacity, StackPolicy policy, Item[] items)
Creates a new ItemContainer.
Item[] items
The Items within this container.
boolean add(Item item)
Attempts to deposit item into this container.
final boolean addListener(ItemContainerListener listener)
Adds an ItemContainerListener to this container.
final Optional< Item > retrieve(int index)
Retrieves the item located on index.
final boolean containsAny(int... identifiers)
Determines if this container contains any identifiers.
final void ifPresent(int index, Consumer< Item > action)
Consumes an action if the index is a valid item index in this container.
final Item[] toArray()
Returns a shallow copy of the backing array.
An ItemContainerAdapter implementation that listens for changes to equipment.
String getCapacityExceededMsg()
void itemUpdated(ItemContainer container, Optional< Item > oldItem, Optional< Item > newItem, int index, boolean refresh, boolean login)
Fired when an Item is added, removed, or replaced.
void bulkItemsUpdated(ItemContainer container)
Fired when an Items are added, removed, or replaced in bulk.
EquipmentListener()
Creates a new EquipmentListener.
boolean unequip(int equipmentIndex)
Unequips an Item from the underlying player's Equipment.
boolean isItem(int slot, int itemId)
static final int CRUSH_DEFENCE
static final int MAGIC_DEFENSE
boolean contains(int[] bowsWithNoArrowsRequired)
static final int[][] LUMBERJACK_PIECES
static final int CHEST_SLOT
void openInterface()
Handles opening the equipment screen itemcontainer.
static final int MAGIC_OFFENSE
static final int[] BANDOS_ITEMS
static boolean hasAccumulator(Player player)
static final int PRAYER_BONUS
void clear()
Removes all of the items from this container.
static boolean hasAttractor(Player player)
static final int RING_SLOT
void updateAnimation()
Updates the weapon animation.
static final int EQUIPMENT_DISPLAY_ID
The equipment item display widget identifier.
void appearanceForIndex(int equipmentIndex)
Flags the APPEARANCE update block, only if the equipment piece on equipmentIndex requires an appearan...
static final int[] SHAYZIEN_ITEMS
static final int[] ARMADYL_ITEMS
static final int CRUSH_OFFENSE
static final int[][] SHAYZIEN_PIECES
static final int AMULET_SLOT
boolean equip(int inventoryIndex)
static boolean isWearingDFS(Player player)
static final int[] BONUS_IDS
An array of bonus ids.
static final int WEAPON_SLOT
Equipment(Player player)
Creates a new Equipment.
static final double SKILLING_SETS_EXPERIENCE_BOOST_PER_PIECE
boolean add(Item item, int preferredIndex, boolean refresh)
Adds an item to the equipment container.
static final int[] SARADOMIN_ITEMS
static final int HEAD_SLOT
Equipment slot constants.
static final int SIZE
The size of all equipment instances.
static final int SLASH_DEFENSE
static final int[][] PROSPECTOR_PIECES
Mining.
static final int SLASH_OFFENSE
static final int MAGIC_STRENGTH
void manualWear(Item item)
Manually wears an item (does not have any restrictions).
void refresh()
Forces a refresh of Equipment items to the EQUIPMENT_DISPLAY_ID widget.
static final int SHIELD_SLOT
void updateRangedEquipment()
void removeBonus(Item item)
void manualWearAll(Item[] items)
Manually wears multiple items (does not have any restrictions).
boolean unequip(int equipmentIndex, int preferredIndex, ItemContainer container)
Unequips an Item from the underlying player's Equipment.
static final int RANGED_OFFENSE
static final int FEET_SLOT
void login()
Handles refreshing all the equipment items.
static final String[] BONUS_NAMES
Item bonus names.
static final int LEGS_SLOT
static final int STRENGTH_BONUS
static final int[] PICKAXES
static final int ARROWS_SLOT
final Player player
The player who's equipment is being managed.
static final int HELM_SLOT
static final int HANDS_SLOT
static final int[][] ANGLER_PIECES
Fishing.
static final int STAB_OFFENSE
Equipment bonus constants.
static final int[] ZAMORAK_ITEMS
static final int CAPE_SLOT
void writeBonuses()
Writes a specific the bonus value on the equipment itemcontainer.
static final int STAB_DEFENSE
static final int RANGED_STRENGTH
void refresh(Player player, int widget)
Forces a refresh of Equipment items to the EQUIPMENT_DISPLAY_ID widget.
static final ImmutableSet< Integer > NO_APPEARANCE
An ImmutableSet containing equipment indexes that don't require appearance updates.
static final int RANGED_DEFENSE
static final String EXCEPTION_MESSAGE
The error message printed when certain functions from the superclass are utilized.
static boolean hasAssembler(Player player)
An ItemContainer implementation that manages the inventory for a Player.
Represents a single Ground item on the world map.
static GroundItem create(Player player, Item item)
Creates a new GroundItem object for a player and an item.
The OutgoingPacket that sends a message to a Players chatbox in the client.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
static final int SHAYZIEN_BOOTS_5_
static final int SHAYZIEN_HELM_5_
static final int SHAYZIEN_GLOVES_5_
static final int SHAYZIEN_GREAVES_5_
static final int SHAYZIEN_PLATEBODY_5_
Handles miscellaneous methods.
static String formatDigits(final int amount)
Formats digits for integers.
static boolean checkRequirements(Player player, int[] requirements, String action)
Holds the data for skillcape emotes.
static boolean equip(Player player, Item item)
static boolean isEquipped(Player player, SkillCape cape)
Represents different priorities for updating.
VERY_HIGH
A very high priority.
static RangedAmmunition find(Item weapon, Item item)
The enumerated type whose elements represent the weapon interfaces.
static void execute(Player player, Item item)
The method executed when weapon item is equipped or unequipped that assigns a weapon interface to pla...
An enumerated type defining policies for stackable Items.
STANDARD
The STANDARD policy, items are only stacked if they are defined as stackable in their ItemDefinition ...
The enumerated types of a players equipped item slots.