From 076ddd548f3ff67b6a95d3ff5592dacaa43b270a Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Wed, 26 Feb 2014 21:56:00 -0600 Subject: [PATCH] Added Space Clicking in AE Inventories. --- client/gui/AEBaseGui.java | 25 +++++++++++ .../gui/implementations/GuiMEMonitorable.java | 3 ++ container/AEBaseContainer.java | 43 +++++++++++++++++++ 3 files changed, 71 insertions(+) diff --git a/client/gui/AEBaseGui.java b/client/gui/AEBaseGui.java index 5e7fbbfa5..dc1104c19 100644 --- a/client/gui/AEBaseGui.java +++ b/client/gui/AEBaseGui.java @@ -18,6 +18,7 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @@ -156,6 +157,30 @@ public abstract class AEBaseGui extends GuiContainer return; } + if ( Keyboard.isKeyDown( Keyboard.KEY_SPACE ) ) + { + IAEItemStack stack = null; + if ( slot instanceof SlotME ) + stack = ((SlotME) slot).getAEStack(); + + PacketInventoryAction p; + try + { + int slotNum = inventorySlots.inventorySlots.size(); + + if ( !(slot instanceof SlotME) && slot != null ) + slotNum = slot.slotNumber; + + p = new PacketInventoryAction( InventoryAction.MOVE_REGION, slotNum, stack ); + NetworkHandler.instance.sendToServer( p ); + } + catch (IOException e) + { + AELog.error( e ); + } + return; + } + if ( slot instanceof SlotME ) { InventoryAction action = null; diff --git a/client/gui/implementations/GuiMEMonitorable.java b/client/gui/implementations/GuiMEMonitorable.java index 0f9a3a5ed..150b1520d 100644 --- a/client/gui/implementations/GuiMEMonitorable.java +++ b/client/gui/implementations/GuiMEMonitorable.java @@ -227,6 +227,9 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi { if ( !this.checkHotbarKeys( key ) ) { + if ( character == ' ' && this.searchField.getText().length() == 0 ) + return; + if ( searchField.textboxKeyTyped( character, key ) ) { repo.searchString = this.searchField.getText(); diff --git a/container/AEBaseContainer.java b/container/AEBaseContainer.java index f93787977..aa624705f 100644 --- a/container/AEBaseContainer.java +++ b/container/AEBaseContainer.java @@ -3,6 +3,7 @@ package appeng.container; import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import net.minecraft.entity.player.EntityPlayer; @@ -505,6 +506,20 @@ public abstract class AEBaseContainer extends Container } } + if ( action == InventoryAction.MOVE_REGION ) + { + List from = new LinkedList(); + + for (Object j : inventorySlots) + { + if ( j instanceof Slot && j.getClass() == s.getClass() ) + from.add( (Slot) j ); + } + + for (Slot fr : from) + transferStackInSlot( player, fr.slotNumber ); + } + return; } @@ -641,6 +656,34 @@ public abstract class AEBaseContainer extends Container } break; case MOVE_REGION: + + if ( powerSrc == null || cellInv == null ) + return; + + if ( slotItem != null ) + { + for (int slotNum = 0; slotNum < player.inventory.getSizeInventory(); slotNum++) + { + IAEItemStack ais = slotItem.copy(); + ItemStack myItem = ais.getItemStack(); + + ais.setStackSize( myItem.getMaxStackSize() ); + + InventoryAdaptor adp = InventoryAdaptor.getAdaptor( player.inventory, ForgeDirection.UNKNOWN ); + myItem.stackSize = (int) ais.getStackSize(); + myItem = adp.simulateAdd( myItem ); + + if ( myItem != null ) + ais.setStackSize( ais.getStackSize() - myItem.stackSize ); + + ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc ); + if ( ais != null ) + adp.addItems( ais.getItemStack() ); + else + return; + } + } + break; default: break;