/*
 * This file is part of LanternServer, licensed under the MIT License (MIT).
 *
 * Copyright (c) LanternPowered <https://www.lanternpowered.org>
 * Copyright (c) SpongePowered <https://www.spongepowered.org>
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the Software), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.lanternpowered.server.inventory.vanilla;

import org.lanternpowered.server.inventory.AbstractInventorySlot;
import org.lanternpowered.server.inventory.IInventory;
import org.lanternpowered.server.inventory.LanternContainer;
import org.lanternpowered.server.inventory.behavior.AbstractShiftClickBehavior;

public class PlayerInventoryShiftClickBehavior extends AbstractShiftClickBehavior {

    public static final PlayerInventoryShiftClickBehavior INSTANCE = new PlayerInventoryShiftClickBehavior();

    @Override
    public IInventory getTarget(LanternContainer container, AbstractInventorySlot slot) {
        IInventory target = getDefaultTarget(container, slot);
        // Just shift click to the top inventory as well by default, and
        // block shift clicking when the top is full
        if (container.getPlayerInventory().getMain().containsInventory(slot)) {
            // Only query to the equipment inventory
            target = container.getPlayerInventory().getEquipment().union(target);
        }
        return target;
    }
}

@@ -1623,16 +1623,156 @@
 ehavior;
+%0Aimport org.lanternpowered.server.inventory.transformation.InventoryTransforms;%0Aimport org.spongepowered.api.item.inventory.slot.OutputSlot;
 %0A%0Apublic
@@ -2077,62 +2077,191 @@
     
-IInventory target = getDefaultTarget(container, 
+final LanternMainPlayerInventory main = container.getPlayerInventory().getMain();%0A        // Check if the slot isn't in the main inventory%0A        if (!main.containsInventory(
 slot)
-;
+) %7B
 %0A   
@@ -2269,72 +2269,152 @@
     
-// Just shift click to the top inventory as well by default, and
+    if (slot instanceof OutputSlot) %7B%0A                return main.transform(InventoryTransforms.REVERSE);%0A            %7D%0A            return main;
 %0A   
@@ -2425,15 +2425,9 @@
  // 
-block s
+S
 hift
@@ -2436,166 +2436,219 @@
 lick
-ing when the top is full%0A        if (container.getPlayerInventory().getMain().containsInventory(slot)) %7B%0A            // Only query to the equipment inventory%0A
+ from the hotbar to the main inventory%0A        %7D else %7B%0A            IInventory target;%0A            if (main.getHotbar().containsInventory(slot)) %7B%0A                target = main.getGrid();%0A            %7D else %7B%0A  
     
@@ -2655,24 +2655,26 @@
         
+  
 target =
  contain
@@ -2665,16 +2665,67 @@
 target =
+ main.getHotbar();%0A            %7D%0A            return
  contain
@@ -2755,17 +2755,13 @@
 .get
-Equipment
+Armor
 ().u
@@ -2788,31 +2788,8 @@
   %7D%0A
-        return target;%0A
     

Fix player inventory shift click behavior.