Fixed Fake Slot Dragging Behavior ( Fixed Bug: #1108 )

This commit is contained in:
AlgorithmX2 2014-09-19 20:34:25 -05:00
parent d9060b7ca5
commit 68cc7fd5f7
3 changed files with 31 additions and 5 deletions

View file

@ -4,9 +4,11 @@ import java.io.IOException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.ParseException; import java.text.ParseException;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -159,6 +161,8 @@ public abstract class AEBaseGui extends GuiContainer
@Override @Override
protected void mouseClicked(int xCoord, int yCoord, int btn) protected void mouseClicked(int xCoord, int yCoord, int btn)
{ {
drag_click.clear();
if ( btn == 1 ) if ( btn == 1 )
{ {
for (Object o : this.buttonList) for (Object o : this.buttonList)
@ -171,6 +175,7 @@ public abstract class AEBaseGui extends GuiContainer
} }
} }
} }
super.mouseClicked( xCoord, yCoord, btn ); super.mouseClicked( xCoord, yCoord, btn );
} }
@ -179,6 +184,9 @@ public abstract class AEBaseGui extends GuiContainer
ItemStack dbl_whichItem; ItemStack dbl_whichItem;
Slot bl_clicked; Slot bl_clicked;
// dragy
Set<Slot> drag_click = new HashSet();
@Override @Override
protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int key) protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int key)
{ {
@ -189,6 +197,9 @@ public abstract class AEBaseGui extends GuiContainer
InventoryAction action = null; InventoryAction action = null;
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN; action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN;
if ( drag_click.size() > 1 )
return;
if ( action != null ) if ( action != null )
{ {
try try
@ -418,13 +429,18 @@ public abstract class AEBaseGui extends GuiContainer
if ( slot instanceof SlotFake && itemstack != null ) if ( slot instanceof SlotFake && itemstack != null )
{ {
if ( c == 0 ) drag_click.add( slot );
if ( drag_click.size() > 1 )
{ {
try try
{ {
PacketInventoryAction p = new PacketInventoryAction( InventoryAction.PICKUP_OR_SETDOWN, slot.slotNumber, 0 ); for (Slot dr : drag_click)
{
PacketInventoryAction p = new PacketInventoryAction( c == 0 ? InventoryAction.PICKUP_OR_SETDOWN : InventoryAction.PLACE_SINGLE,
dr.slotNumber, 0 );
NetworkHandler.instance.sendToServer( p ); NetworkHandler.instance.sendToServer( p );
} }
}
catch (IOException e) catch (IOException e)
{ {
AELog.error( e ); AELog.error( e );

View file

@ -731,6 +731,16 @@ public abstract class AEBaseContainer extends Container
else else
s.putStack( hand.copy() ); s.putStack( hand.copy() );
break;
case PLACE_SINGLE:
if ( hand != null )
{
ItemStack is = hand.copy();
is.stackSize = 1;
s.putStack( is );
}
break; break;
case SPLIT_OR_PLACESINGLE: case SPLIT_OR_PLACESINGLE:

View file

@ -9,5 +9,5 @@ public enum InventoryAction
CRAFT_STACK, CRAFT_ITEM, CRAFT_SHIFT, CRAFT_STACK, CRAFT_ITEM, CRAFT_SHIFT,
// extra... // extra...
MOVE_REGION, PICKUP_SINGLE, UPDATE_HAND, ROLLUP, ROLLDOWN, AUTOCRAFT MOVE_REGION, PICKUP_SINGLE, UPDATE_HAND, ROLLUP, ROLLDOWN, AUTOCRAFT, PLACE_SINGLE
} }