Skip to content

Commit 53b149d

Browse files
committed
fix errors handling shields
1 parent a04e459 commit 53b149d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/main/java/org/mcmonkey/sentinel/SentinelItemHelper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,14 @@ public boolean swapToShield() {
176176
break;
177177
}
178178
}
179-
// Index 40 is offhand.
179+
// Index 40 is offhand on some versions, but it later changed to be a non-inventory magic slot.
180180
if (index != -1 && index != 40) {
181181
ItemStack oldItem = SentinelUtilities.getOffhandItem(sentinel.getLivingEntity()).clone();
182182
ItemStack newItem = items[index].clone();
183183
items[index] = oldItem;
184-
items[40] = newItem;
184+
if (items.length >= 40) {
185+
items[40] = newItem;
186+
}
185187
inv.setContents(items);
186188
sentinel.getLivingEntity().getEquipment().setItemInOffHand(newItem);
187189
return true;

0 commit comments

Comments
 (0)