Added Space Clicking in AE Inventories.

This commit is contained in:
AlgorithmX2 2014-02-26 21:56:00 -06:00
parent ef729e7365
commit 076ddd548f
3 changed files with 71 additions and 0 deletions

View file

@ -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;

View file

@ -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();

View file

@ -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<Slot> 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;