update nei drag

This commit is contained in:
vfyjxf committed 2022-01-31 19:40:30 +08:00
1 parent d077b0a1f6
commit 8e48199839
2 files changed
+19 -12

No files matched your search

@@ -16,6 +16,7 @@ import com.github.vfyjxf.nee.network.NEENetworkHandler;
import com.github.vfyjxf.nee.network.packet.PacketSlotStackChange;
import com.github.vfyjxf.nee.utils.GuiUtils;
import com.github.vfyjxf.nee.utils.ItemUtils;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
@@ -161,19 +162,22 @@ public class GuiEventHandler implements INEIGuiHandler {
@Override
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
if (gui instanceof AEBaseGui) {
if (button != 2 && draggedStack != null) {
Slot currentSlot = gui.getSlotAtPosition(mouseX, mouseY);
if (currentSlot instanceof SlotFake && ((SlotFake) currentSlot).isEnabled()) {
List<Integer> slots = new ArrayList<>();
slots.add(currentSlot.slotNumber);
ItemStack copyStack = draggedStack.copy();
copyStack.stackSize = useStackSizeFromNEI ? draggedStack.stackSize : draggedStackDefaultSize;
NEENetworkHandler.getInstance().sendToServer(new PacketSlotStackChange(copyStack, slots));
if (!NEEConfig.keepGhostitems) {
draggedStack.stackSize = 0;
//When NEIAddons exist, give them to NEIAddons to handle
if(NEEConfig.enableNEIDragNDrop || Loader.isModLoaded("NEIAddons")) {
if (gui instanceof AEBaseGui) {
if (button != 2 && draggedStack != null) {
Slot currentSlot = gui.getSlotAtPosition(mouseX, mouseY);
if (currentSlot instanceof SlotFake && ((SlotFake) currentSlot).isEnabled()) {
List<Integer> slots = new ArrayList<>();
slots.add(currentSlot.slotNumber);
ItemStack copyStack = draggedStack.copy();
copyStack.stackSize = useStackSizeFromNEI ? draggedStack.stackSize : draggedStackDefaultSize;
NEENetworkHandler.getInstance().sendToServer(new PacketSlotStackChange(copyStack, slots));
if (!NEEConfig.keepGhostitems) {
draggedStack.stackSize = 0;
}
return true;
}
return true;
}
}
}
@@ -28,6 +28,7 @@ public class NEEConfig {
public static boolean matchOtherItems = true;
public static boolean drawHighlight = true;
public static boolean allowSynchronousSwitchIngredient = true;
public static boolean enableNEIDragNDrop = true;
public static boolean useStackSizeFromNEI = true;
public static boolean keepGhostitems = true;
public static boolean enableCraftAmountSettingGui = false;
@@ -73,6 +74,8 @@ public class NEEConfig {
allowSynchronousSwitchIngredient = config.get(CATEGORY_OTHER_SETTINGS, "allowSynchronousSwitchIngredient", true,
"If true, it will make all similar ingredient switch at the same time").getBoolean(true);
enableNEIDragNDrop = config.get(CATEGORY_OTHER_SETTINGS, "enableNEIDragNDrop", true, "").getBoolean();
useStackSizeFromNEI = config.get(CATEGORY_OTHER_SETTINGS, "useStackSizeFromNEI", true,
"Use the StackSize set by NEI").getBoolean();