--- a/net/minecraft/client/gui/screen/inventory/ContainerScreen.java
+++ b/net/minecraft/client/gui/screen/inventory/ContainerScreen.java
@@ -86,6 +86,7 @@
       int i = this.field_147003_i;
       int j = this.field_147009_r;
       this.func_230450_a_(p_230430_1_, p_230430_4_, p_230430_2_, p_230430_3_);
+      net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiContainerEvent.DrawBackground(this, p_230430_1_, p_230430_2_, p_230430_3_));
       RenderSystem.disableRescaleNormal();
       RenderSystem.disableDepthTest();
       super.func_230430_a_(p_230430_1_, p_230430_2_, p_230430_3_, p_230430_4_);
@@ -111,13 +112,15 @@
             int j1 = slot.field_75223_e;
             int k1 = slot.field_75221_f;
             RenderSystem.colorMask(true, true, true, false);
-            this.func_238468_a_(p_230430_1_, j1, k1, j1 + 16, k1 + 16, -2130706433, -2130706433);
+            int slotColor = this.getSlotColor(i1);
+            this.func_238468_a_(p_230430_1_, j1, k1, j1 + 16, k1 + 16, slotColor, slotColor);
             RenderSystem.colorMask(true, true, true, true);
             RenderSystem.enableDepthTest();
          }
       }
 
       this.func_230451_b_(p_230430_1_, p_230430_2_, p_230430_3_);
+      net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiContainerEvent.DrawForeground(this, p_230430_1_, p_230430_2_, p_230430_3_));
       PlayerInventory playerinventory = this.field_230706_i_.field_71439_g.field_71071_by;
       ItemStack itemstack = this.field_147012_x.func_190926_b() ? playerinventory.func_70445_o() : this.field_147012_x;
       if (!itemstack.func_190926_b()) {
@@ -167,8 +170,10 @@
       RenderSystem.translatef(0.0F, 0.0F, 32.0F);
       this.func_230926_e_(200);
       this.field_230707_j_.field_77023_b = 200.0F;
+      net.minecraft.client.gui.FontRenderer font = p_146982_1_.func_77973_b().getFontRenderer(p_146982_1_);
+      if (font == null) font = this.field_230712_o_;
       this.field_230707_j_.func_180450_b(p_146982_1_, p_146982_2_, p_146982_3_);
-      this.field_230707_j_.func_180453_a(this.field_230712_o_, p_146982_1_, p_146982_2_, p_146982_3_ - (this.field_147012_x.func_190926_b() ? 0 : 8), p_146982_4_);
+      this.field_230707_j_.func_180453_a(font, p_146982_1_, p_146982_2_, p_146982_3_ - (this.field_147012_x.func_190926_b() ? 0 : 8), p_146982_4_);
       this.func_230926_e_(0);
       this.field_230707_j_.field_77023_b = 0.0F;
    }
@@ -278,7 +283,8 @@
       if (super.func_231044_a_(p_231044_1_, p_231044_3_, p_231044_5_)) {
          return true;
       } else {
-         boolean flag = this.field_230706_i_.field_71474_y.field_74322_I.func_197984_a(p_231044_5_);
+         InputMappings.Input mouseKey = InputMappings.Type.MOUSE.func_197944_a(p_231044_5_);
+         boolean flag = this.field_230706_i_.field_71474_y.field_74322_I.isActiveAndMatches(mouseKey);
          Slot slot = this.func_195360_a(p_231044_1_, p_231044_3_);
          long i = Util.func_211177_b();
          this.field_146993_M = this.field_146998_K == slot && i - this.field_146997_J < 250L && this.field_146992_L == p_231044_5_;
@@ -289,6 +295,7 @@
             int j = this.field_147003_i;
             int k = this.field_147009_r;
             boolean flag1 = this.func_195361_a(p_231044_1_, p_231044_3_, j, k, p_231044_5_);
+            if (slot != null) flag1 = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
             int l = -1;
             if (slot != null) {
                l = slot.field_75222_d;
@@ -314,7 +321,7 @@
                   }
                } else if (!this.field_147007_t) {
                   if (this.field_230706_i_.field_71439_g.field_71071_by.func_70445_o().func_190926_b()) {
-                     if (this.field_230706_i_.field_71474_y.field_74322_I.func_197984_a(p_231044_5_)) {
+                     if (this.field_230706_i_.field_71474_y.field_74322_I.isActiveAndMatches(mouseKey)) {
                         this.func_184098_a(slot, l, p_231044_5_, ClickType.CLONE);
                      } else {
                         boolean flag2 = l != -999 && (InputMappings.func_216506_a(Minecraft.func_71410_x().func_228018_at_().func_198092_i(), 340) || InputMappings.func_216506_a(Minecraft.func_71410_x().func_228018_at_().func_198092_i(), 344));
@@ -338,7 +345,7 @@
                         this.field_146987_F = 0;
                      } else if (p_231044_5_ == 1) {
                         this.field_146987_F = 1;
-                     } else if (this.field_230706_i_.field_71474_y.field_74322_I.func_197984_a(p_231044_5_)) {
+                     } else if (this.field_230706_i_.field_71474_y.field_74322_I.isActiveAndMatches(mouseKey)) {
                         this.field_146987_F = 2;
                      }
                   }
@@ -407,10 +414,13 @@
    }
 
    public boolean func_231048_c_(double p_231048_1_, double p_231048_3_, int p_231048_5_) {
+      super.func_231048_c_(p_231048_1_, p_231048_3_, p_231048_5_); //Forge, Call parent to release buttons
       Slot slot = this.func_195360_a(p_231048_1_, p_231048_3_);
       int i = this.field_147003_i;
       int j = this.field_147009_r;
       boolean flag = this.func_195361_a(p_231048_1_, p_231048_3_, i, j, p_231048_5_);
+      if (slot != null) flag = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
+      InputMappings.Input mouseKey = InputMappings.Type.MOUSE.func_197944_a(p_231048_5_);
       int k = -1;
       if (slot != null) {
          k = slot.field_75222_d;
@@ -424,7 +434,7 @@
          if (func_231173_s_()) {
             if (!this.field_146994_N.func_190926_b()) {
                for(Slot slot2 : this.field_147002_h.field_75151_b) {
-                  if (slot2 != null && slot2.func_82869_a(this.field_230706_i_.field_71439_g) && slot2.func_75216_d() && slot2.field_75224_c == slot.field_75224_c && Container.func_94527_a(slot2, this.field_146994_N, true)) {
+                  if (slot2 != null && slot2.func_82869_a(this.field_230706_i_.field_71439_g) && slot2.func_75216_d() && slot2.isSameInventory(slot) && Container.func_94527_a(slot2, this.field_146994_N, true)) {
                      this.func_184098_a(slot2, slot2.field_75222_d, p_231048_5_, ClickType.QUICK_MOVE);
                   }
                }
@@ -488,7 +498,7 @@
 
             this.func_184098_a((Slot)null, -999, Container.func_94534_d(2, this.field_146987_F), ClickType.QUICK_CRAFT);
          } else if (!this.field_230706_i_.field_71439_g.field_71071_by.func_70445_o().func_190926_b()) {
-            if (this.field_230706_i_.field_71474_y.field_74322_I.func_197984_a(p_231048_5_)) {
+            if (this.field_230706_i_.field_71474_y.field_74322_I.isActiveAndMatches(mouseKey)) {
                this.func_184098_a(slot, k, p_231048_5_, ClickType.CLONE);
             } else {
                boolean flag1 = k != -999 && (InputMappings.func_216506_a(Minecraft.func_71410_x().func_228018_at_().func_198092_i(), 340) || InputMappings.func_216506_a(Minecraft.func_71410_x().func_228018_at_().func_198092_i(), 344));
@@ -530,34 +540,39 @@
    }
 
    public boolean func_231046_a_(int p_231046_1_, int p_231046_2_, int p_231046_3_) {
+      InputMappings.Input mouseKey = InputMappings.func_197954_a(p_231046_1_, p_231046_2_);
       if (super.func_231046_a_(p_231046_1_, p_231046_2_, p_231046_3_)) {
          return true;
-      } else if (this.field_230706_i_.field_71474_y.field_151445_Q.func_197976_a(p_231046_1_, p_231046_2_)) {
+      } else if (this.field_230706_i_.field_71474_y.field_151445_Q.isActiveAndMatches(mouseKey)) {
          this.func_231175_as__();
          return true;
       } else {
-         this.func_195363_d(p_231046_1_, p_231046_2_);
+         boolean handled = this.func_195363_d(p_231046_1_, p_231046_2_);// Forge MC-146650: Needs to return true when the key is handled
          if (this.field_147006_u != null && this.field_147006_u.func_75216_d()) {
-            if (this.field_230706_i_.field_71474_y.field_74322_I.func_197976_a(p_231046_1_, p_231046_2_)) {
+            if (this.field_230706_i_.field_71474_y.field_74322_I.isActiveAndMatches(mouseKey)) {
                this.func_184098_a(this.field_147006_u, this.field_147006_u.field_75222_d, 0, ClickType.CLONE);
-            } else if (this.field_230706_i_.field_71474_y.field_74316_C.func_197976_a(p_231046_1_, p_231046_2_)) {
+               handled = true;
+            } else if (this.field_230706_i_.field_71474_y.field_74316_C.isActiveAndMatches(mouseKey)) {
                this.func_184098_a(this.field_147006_u, this.field_147006_u.field_75222_d, func_231172_r_() ? 1 : 0, ClickType.THROW);
+               handled = true;
             }
+         } else if (this.field_230706_i_.field_71474_y.field_74316_C.isActiveAndMatches(mouseKey)) {
+             handled = true; // Forge MC-146650: Emulate MC bug, so we don't drop from hotbar when pressing drop without hovering over a item.
          }
 
-         return true;
+         return handled;
       }
    }
 
    protected boolean func_195363_d(int p_195363_1_, int p_195363_2_) {
       if (this.field_230706_i_.field_71439_g.field_71071_by.func_70445_o().func_190926_b() && this.field_147006_u != null) {
-         if (this.field_230706_i_.field_71474_y.field_186718_X.func_197976_a(p_195363_1_, p_195363_2_)) {
+         if (this.field_230706_i_.field_71474_y.field_186718_X.isActiveAndMatches(InputMappings.func_197954_a(p_195363_1_, p_195363_2_))) {
             this.func_184098_a(this.field_147006_u, this.field_147006_u.field_75222_d, 40, ClickType.SWAP);
             return true;
          }
 
          for(int i = 0; i < 9; ++i) {
-            if (this.field_230706_i_.field_71474_y.field_151456_ac[i].func_197976_a(p_195363_1_, p_195363_2_)) {
+            if (this.field_230706_i_.field_71474_y.field_151456_ac[i].isActiveAndMatches(InputMappings.func_197954_a(p_195363_1_, p_195363_2_))) {
                this.func_184098_a(this.field_147006_u, this.field_147006_u.field_75222_d, i, ClickType.SWAP);
                return true;
             }
@@ -589,6 +604,18 @@
       return this.field_147002_h;
    }
 
+   @javax.annotation.Nullable
+   public Slot getSlotUnderMouse() { return this.field_147006_u; }
+   public int getGuiLeft() { return field_147003_i; }
+   public int getGuiTop() { return field_147009_r; }
+   public int getXSize() { return field_146999_f; }
+   public int getYSize() { return field_147000_g; }
+
+   protected int slotColor = -2130706433;
+   public int getSlotColor(int index) {
+      return slotColor;
+   }
+
    public void func_231175_as__() {
       this.field_230706_i_.field_71439_g.func_71053_j();
       super.func_231175_as__();
