# ArmorChange

`com.jsmacrosce.jsmacros.client.api.event.impl.player.EventArmorChange`

**Since:** 1.2.7

**Cancellable:** No. Calling `event.cancel()` throws `UnsupportedOperationException`.

Fires when client-tick polling detects a change to one of the local player's four armor slots.  
For a damage-only change, [EventItemDamage](../inventory/EventItemDamage.md)
fires first.  
```js
JsMacros.on("ArmorChange", JavaWrapper.methodToJava(function (event) {
  const now = event.item.isEmpty() ? "empty" : `${event.item.getItemId()} x${event.item.getCount()}`;  
  const before = event.oldItem.isEmpty() ? "empty" : `${event.oldItem.getItemId()} x${event.oldItem.getCount()}`;  
  Chat.log(`Armor ${event.slot}: ${before} to ${now}`);  
}))
```

## Constructors

### new EventArmorChange {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventArmorChange_constructor-String-ItemStack-ItemStack-}

```js
new EventArmorChange(String slot, ItemStack item, ItemStack old)
```

Stores the supplied slot label and wraps the current and previous raw stacks in helpers.  
The slot is stored verbatim without validation; either raw stack may be `null`,  
and is passed to its helper unchanged.

**Parameters:**
- `slot`: supplied armor-slot label, possibly `null`
- `item`: current raw item stack, possibly `null`
- `old`: previous raw item stack, possibly `null`

## Fields

### item {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventArmorChange_item}

```js
item: ItemStackHelper
```

The item currently in the slot. An empty slot is represented by an empty
[ItemStackHelper](../../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/inventory/ItemStackHelper.md), so check
[isEmpty()](../../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/inventory/ItemStackHelper.md#com.jsmacrosce.jsmacros.client.api.helper.inventory.ItemStackHelper_isEmpty-)
before reading the id or the count.

### oldItem {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventArmorChange_oldItem}

```js
oldItem: ItemStackHelper
```

The item previously recorded for the slot by polling, represented by an empty
[ItemStackHelper](../../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/inventory/ItemStackHelper.md) if the slot was
empty.

### slot {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventArmorChange_slot}

```js
slot: String
```

The changed armor slot: `HEAD`, `CHEST`, `LEGS`, or
`FEET`.

## Methods

### toString {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventArmorChange_toString-}

```js
toString(): String
```

Returns a diagnostic string containing the event name and slot label; the item values
are omitted. The format is `%s:{"slot": %s}` with standard `String.format`
conversion, so the slot is not quoted or escaped as JSON.

**Returns:** diagnostic event-name and slot string
