From 383cb078929132e57e648249639e8fc7cd507ea4 Mon Sep 17 00:00:00 2001
From: Joseph Hirschfeld <joe@ibj.io>
Date: Thu, 3 Mar 2016 02:33:53 -0600
Subject: [PATCH] Ensure inv drag is in bounds


diff --git a/src/main/java/net/minecraft/server/Container.java b/src/main/java/net/minecraft/server/Container.java
index 0ae0b5ed8..1573c0559 100644
--- a/src/main/java/net/minecraft/server/Container.java
+++ b/src/main/java/net/minecraft/server/Container.java
@@ -139,7 +139,7 @@ public abstract class Container {
                     this.c();
                 }
             } else if (this.g == 1) {
-                Slot slot = (Slot) this.slots.get(i);
+                Slot slot = i < this.slots.size() ? this.slots.get(i) : null; // Paper - Ensure drag in bounds
 
                 itemstack1 = playerinventory.getCarried();
                 if (slot != null && a(slot, itemstack1, true) && slot.isAllowed(itemstack1) && (this.dragType == 2 || itemstack1.getCount() > this.h.size()) && this.b(slot)) {
-- 
2.18.0