mirror of
https://github.com/GTNewHorizons/NotEnoughEnergistics.git
synced 2026-11-17 19:05:01 +00:00
update nei drag
This commit is contained in:
1 parent
37f181a8bd
commit
a983a36e2f
2 files changed
+93
-33
No files matched your search
@@ -25,6 +25,7 @@ import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.github.vfyjxf.nee.config.NEEConfig.draggedStackDefaultSize;
|
||||
@@ -163,20 +164,43 @@ public class GuiEventHandler implements INEIGuiHandler {
|
||||
@Override
|
||||
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
|
||||
//When NEIAddons exist, give them to NEIAddons to handle
|
||||
if(NEEConfig.enableNEIDragNDrop || !Loader.isModLoaded("NEIAddons")) {
|
||||
if(Loader.isModLoaded("NEIAddons") && NEEConfig.useNEIDragFromNEIAddons){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NEEConfig.enableNEIDragNDrop) {
|
||||
if (gui instanceof AEBaseGui) {
|
||||
if (button != 2 && draggedStack != null) {
|
||||
if (draggedStack != null) {
|
||||
Slot currentSlot = gui.getSlotAtPosition(mouseX, mouseY);
|
||||
if (currentSlot instanceof SlotFake && ((SlotFake) currentSlot).isEnabled()) {
|
||||
List<Integer> slots = new ArrayList<>();
|
||||
slots.add(currentSlot.slotNumber);
|
||||
if (currentSlot instanceof SlotFake) {
|
||||
ItemStack slotStack = currentSlot.getStack();
|
||||
ItemStack copyStack = draggedStack.copy();
|
||||
copyStack.stackSize = useStackSizeFromNEI ? draggedStack.stackSize : draggedStackDefaultSize;
|
||||
NEENetworkHandler.getInstance().sendToServer(new PacketSlotStackChange(copyStack, slots));
|
||||
if (!NEEConfig.keepGhostitems) {
|
||||
draggedStack.stackSize = 0;
|
||||
boolean sendPacket = false;
|
||||
int copySize = useStackSizeFromNEI ? copyStack.stackSize : draggedStackDefaultSize;
|
||||
if (button == 0) {
|
||||
boolean areStackEqual = slotStack != null && slotStack.isItemEqual(copyStack) && ItemStack.areItemStackTagsEqual(slotStack, copyStack);
|
||||
copyStack.stackSize = areStackEqual ? Math.min(slotStack.stackSize + copySize, 127) : Math.min(copySize, 127);
|
||||
sendPacket = true;
|
||||
} else if (button == 1) {
|
||||
boolean areStackEqual = slotStack != null && slotStack.isItemEqual(copyStack) && ItemStack.areItemStackTagsEqual(slotStack, copyStack);
|
||||
if (areStackEqual) {
|
||||
copyStack.stackSize = Math.min(slotStack.stackSize + 1, 127);
|
||||
} else {
|
||||
copyStack.stackSize = slotStack == null ? 1 : copySize;
|
||||
}
|
||||
sendPacket = true;
|
||||
}
|
||||
return true;
|
||||
|
||||
if (sendPacket) {
|
||||
NEENetworkHandler.getInstance().sendToServer(new PacketSlotStackChange(copyStack, Collections.singletonList(currentSlot.slotNumber)));
|
||||
if (!NEEConfig.keepGhostitems) {
|
||||
draggedStack.stackSize = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (button == 2) {
|
||||
draggedStack.stackSize = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 useNEIDragFromNEIAddons = false;
|
||||
public static boolean enableNEIDragNDrop = true;
|
||||
public static boolean useStackSizeFromNEI = true;
|
||||
public static boolean keepGhostitems = true;
|
||||
@@ -60,6 +61,7 @@ public class NEEConfig {
|
||||
itemCombinationWhitelist = config.get(CATEGORY_PATTERN_TRANSFER, "itemCombinationWhitelist", itemCombinationWhitelist,
|
||||
"Whitelist for item combination").getStringList();
|
||||
}
|
||||
|
||||
{
|
||||
matchOtherItems = config.get(CATEGORY_CRAFTING_HELPER, "matchOnCraftableItems", true,
|
||||
"If true, Crafting Helper will match other items even they can't auto-crafting").getBoolean();
|
||||
@@ -70,6 +72,63 @@ public class NEEConfig {
|
||||
enableCraftAmountSettingGui = config.get(CATEGORY_CRAFTING_HELPER, "enableCraftAmountSettingGui", false,
|
||||
"If true, it will open a gui to set craft amount after ctrl + click [?] button").getBoolean();
|
||||
}
|
||||
|
||||
{
|
||||
allowSynchronousSwitchIngredient = config.get(CATEGORY_OTHER_SETTINGS, "allowSynchronousSwitchIngredient", true,
|
||||
"If true, it will make all similar ingredient switch at the same time").getBoolean(true);
|
||||
|
||||
useNEIDragFromNEIAddons = config.get(CATEGORY_OTHER_SETTINGS, "useNEIDragFromNEIAddons", false, "Use the NEI Drag from NEI Addons").getBoolean();
|
||||
|
||||
enableNEIDragNDrop = config.get(CATEGORY_OTHER_SETTINGS, "enableNEIDragNDrop", true, "").getBoolean();
|
||||
|
||||
useStackSizeFromNEI = config.get(CATEGORY_OTHER_SETTINGS, "useStackSizeFromNEI", true,
|
||||
"Use the StackSize set by NEI").getBoolean();
|
||||
|
||||
keepGhostitems = config.get(CATEGORY_OTHER_SETTINGS, "keepGhostitems", true, "keep ghost items after click").getBoolean();
|
||||
|
||||
draggedStackDefaultSize = config.get(CATEGORY_OTHER_SETTINGS, "draggedStackDefaultSize", 1,
|
||||
"The default size of the dragged ItemStack when it is put in slot(Used when useStackSizeFromNEI is false)", 1, 64).getInt();
|
||||
}
|
||||
|
||||
if (config.hasChanged()) config.save();
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
config.load();
|
||||
|
||||
{
|
||||
transformBlacklist = config.get(CATEGORY_PATTERN_TRANSFER, "transformItemBlacklist", new String[0],
|
||||
"If item in the blacklist, it will not be transferred.\n" +
|
||||
"the format is \" {modid:modid,name:name,meta:meta,recipeProcessor:recipeProcessorID,identifier:identifier}\"\n" +
|
||||
"example: \"{modid:minecraft,name:iron_ingot,recipeProcessor:EnderIO,identifier:EnderIOAlloySmelter}\"").getStringList();
|
||||
transformPriorityList = config.get(CATEGORY_PATTERN_TRANSFER, "transformItemPriorityList", new String[0],
|
||||
"If item in the priority list, it will be transferred first.").getStringList();
|
||||
|
||||
transformPriorityModList = config.get(CATEGORY_PATTERN_TRANSFER, "transformPriorityModList", new String[0],
|
||||
"if oredict has this mod's item, use it first").getStringList();
|
||||
|
||||
noShift = config.get(CATEGORY_PATTERN_TRANSFER, "noShift", true,
|
||||
"if true, you don't need to press shift to use NEI's transfer system in CratingTerminal and PatternTerminal").getBoolean();
|
||||
|
||||
itemCombinationMode = config.get(CATEGORY_PATTERN_TRANSFER, "itemCombinationMode", itemCombinationMode,
|
||||
"Item Combination Mode Setting, here are all the modes. \n"
|
||||
+ "\"ENABLED\"" + " " + "\"DISABLED\"" + " " + "WHITELIST").getString();
|
||||
|
||||
itemCombinationWhitelist = config.get(CATEGORY_PATTERN_TRANSFER, "itemCombinationWhitelist", itemCombinationWhitelist,
|
||||
"Whitelist for item combination").getStringList();
|
||||
}
|
||||
|
||||
{
|
||||
matchOtherItems = config.get(CATEGORY_CRAFTING_HELPER, "matchOnCraftableItems", true,
|
||||
"If true, Crafting Helper will match other items even they can't auto-crafting").getBoolean();
|
||||
|
||||
drawHighlight = config.get(CATEGORY_CRAFTING_HELPER, "drawHighlight", true,
|
||||
"if true,it will draw highlight for missing items and item which can autocraft in nei").getBoolean();
|
||||
|
||||
enableCraftAmountSettingGui = config.get(CATEGORY_CRAFTING_HELPER, "enableCraftAmountSettingGui", false,
|
||||
"If true, it will open a gui to set craft amount after ctrl + click [?] button").getBoolean();
|
||||
}
|
||||
|
||||
{
|
||||
allowSynchronousSwitchIngredient = config.get(CATEGORY_OTHER_SETTINGS, "allowSynchronousSwitchIngredient", true,
|
||||
"If true, it will make all similar ingredient switch at the same time").getBoolean(true);
|
||||
@@ -84,30 +143,7 @@ public class NEEConfig {
|
||||
draggedStackDefaultSize = config.get(CATEGORY_OTHER_SETTINGS, "draggedStackDefaultSize", 1,
|
||||
"The default size of the dragged ItemStack when it is put in slot(Used when useStackSizeFromNEI is false)", 1, 64).getInt();
|
||||
}
|
||||
if (config.hasChanged()) config.save();
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
config.load();
|
||||
transformBlacklist = config.get(CATEGORY_PATTERN_TRANSFER, "transformItemBlacklist", new String[0],
|
||||
"If item in the blacklist, it will not be transferred.\n" +
|
||||
"the format is \" {modid:modid,name:name,meta:meta,recipeProcessor:recipeProcessorID,identifier:identifier}\"\n" +
|
||||
"example: \"{modid:minecraft,name:iron_ingot,recipeProcessor:EnderIO,identifier:EnderIOAlloySmelter}\"").getStringList();
|
||||
transformPriorityList = config.get(CATEGORY_PATTERN_TRANSFER, "transformItemPriorityList", new String[0],
|
||||
"If item in the priority list, it will be transferred first.").getStringList();
|
||||
|
||||
transformPriorityModList = config.get(CATEGORY_PATTERN_TRANSFER, "transformPriorityModList", new String[0],
|
||||
"if oredict has this mod's item, use it first").getStringList();
|
||||
|
||||
noShift = config.get(CATEGORY_PATTERN_TRANSFER, "noShift", true,
|
||||
"if true, you don't need to press shift to use NEI's transfer system in CratingTerminal and PatternTerminal").getBoolean();
|
||||
|
||||
itemCombinationMode = config.get(CATEGORY_PATTERN_TRANSFER, "itemCombinationMode", itemCombinationMode,
|
||||
"Item Combination Mode Setting, here are all the modes. \n"
|
||||
+ "\"ENABLED\"" + " " + "\"DISABLED\"" + " " + "WHITELIST").getString();
|
||||
|
||||
itemCombinationWhitelist = config.get(CATEGORY_PATTERN_TRANSFER, "itemCombinationWhitelist", itemCombinationWhitelist,
|
||||
"Whitelist for item combination").getStringList();
|
||||
ItemUtils.reloadConfig();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user