From 68cc7fd5f71ad3877287bbf7853cc4b2e9d135a4 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Fri, 19 Sep 2014 20:34:25 -0500 Subject: [PATCH] Fixed Fake Slot Dragging Behavior ( Fixed Bug: #1108 ) --- client/gui/AEBaseGui.java | 22 +++++++++++++++++++--- container/AEBaseContainer.java | 12 +++++++++++- helpers/InventoryAction.java | 2 +- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/client/gui/AEBaseGui.java b/client/gui/AEBaseGui.java index 9195e7a6..65bafe00 100644 --- a/client/gui/AEBaseGui.java +++ b/client/gui/AEBaseGui.java @@ -4,9 +4,11 @@ import java.io.IOException; import java.text.DecimalFormat; import java.text.ParseException; import java.util.Collection; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Set; import java.util.concurrent.TimeUnit; import net.minecraft.client.Minecraft; @@ -159,6 +161,8 @@ public abstract class AEBaseGui extends GuiContainer @Override protected void mouseClicked(int xCoord, int yCoord, int btn) { + drag_click.clear(); + if ( btn == 1 ) { for (Object o : this.buttonList) @@ -171,6 +175,7 @@ public abstract class AEBaseGui extends GuiContainer } } } + super.mouseClicked( xCoord, yCoord, btn ); } @@ -179,6 +184,9 @@ public abstract class AEBaseGui extends GuiContainer ItemStack dbl_whichItem; Slot bl_clicked; + // dragy + Set drag_click = new HashSet(); + @Override protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int key) { @@ -189,6 +197,9 @@ public abstract class AEBaseGui extends GuiContainer InventoryAction action = null; action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN; + if ( drag_click.size() > 1 ) + return; + if ( action != null ) { try @@ -418,12 +429,17 @@ public abstract class AEBaseGui extends GuiContainer if ( slot instanceof SlotFake && itemstack != null ) { - if ( c == 0 ) + drag_click.add( slot ); + if ( drag_click.size() > 1 ) { try { - PacketInventoryAction p = new PacketInventoryAction( InventoryAction.PICKUP_OR_SETDOWN, slot.slotNumber, 0 ); - NetworkHandler.instance.sendToServer( p ); + 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 ); + } } catch (IOException e) { diff --git a/container/AEBaseContainer.java b/container/AEBaseContainer.java index 05735d60..9cf1dc2e 100644 --- a/container/AEBaseContainer.java +++ b/container/AEBaseContainer.java @@ -676,7 +676,7 @@ public abstract class AEBaseContainer extends Container else addSlotToContainer( new SlotPlayerHotBar( inventoryPlayer, i, 8 + i * 18 + offset_x, 58 + offset_y ) ); } - + for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) @@ -731,6 +731,16 @@ public abstract class AEBaseContainer extends Container else s.putStack( hand.copy() ); + break; + case PLACE_SINGLE: + + if ( hand != null ) + { + ItemStack is = hand.copy(); + is.stackSize = 1; + s.putStack( is ); + } + break; case SPLIT_OR_PLACESINGLE: diff --git a/helpers/InventoryAction.java b/helpers/InventoryAction.java index 661a1e3b..de758931 100644 --- a/helpers/InventoryAction.java +++ b/helpers/InventoryAction.java @@ -9,5 +9,5 @@ public enum InventoryAction CRAFT_STACK, CRAFT_ITEM, CRAFT_SHIFT, // extra... - MOVE_REGION, PICKUP_SINGLE, UPDATE_HAND, ROLLUP, ROLLDOWN, AUTOCRAFT + MOVE_REGION, PICKUP_SINGLE, UPDATE_HAND, ROLLUP, ROLLDOWN, AUTOCRAFT, PLACE_SINGLE }