mirror of
https://github.com/GTNewHorizons/NotEnoughEnergistics.git
synced 2026-11-19 19:49:43 +00:00
1 parent
00a7b9d014
commit
8866310f92
27 files changed
+769
-341
No files matched your search
@@ -28,13 +28,17 @@ public class NEECommands extends CommandBase {
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender) {
|
||||
return "";
|
||||
return "See /nee help";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) {
|
||||
if (args.length != 0) {
|
||||
if ("processor".equalsIgnoreCase(args[0])) {
|
||||
if ("help".equalsIgnoreCase(args[0])) {
|
||||
sender.addChatMessage(new ChatComponentText("Usage:"));
|
||||
sender.addChatMessage(new ChatComponentText("/nee add blacklist/priorityItem processor_id identifier"));
|
||||
sender.addChatMessage(new ChatComponentText("/nee add blacklist/priorityItem/itemCombination identifier"));
|
||||
} else if ("processor".equalsIgnoreCase(args[0])) {
|
||||
for (IRecipeProcessor processor : RecipeProcessor.recipeProcessors) {
|
||||
logger.info("RecipeProcessor:" + processor.getRecipeProcessorId() + " identifier:");
|
||||
for (String ident : processor.getAllOverlayIdentifier()) {
|
||||
@@ -47,10 +51,14 @@ public class NEECommands extends CommandBase {
|
||||
if (currentStack != null) {
|
||||
String currentItemJsonString = ItemUtils.toItemJsonString(currentStack);
|
||||
JsonObject itemJsonObject = new JsonParser().parse(currentItemJsonString).getAsJsonObject();
|
||||
if (args.length == 3) {
|
||||
if (args.length >= 3) {
|
||||
boolean hasRecipeProcessor = ItemUtils.hasRecipeProcessor(args[2]);
|
||||
boolean hasOverlayIdentifier = ItemUtils.hasOverlayIdentifier(args[2]);
|
||||
|
||||
if (args.length == 4) {
|
||||
hasOverlayIdentifier = ItemUtils.hasOverlayIdentifier(args[3]);
|
||||
}
|
||||
|
||||
if (hasRecipeProcessor) {
|
||||
itemJsonObject.addProperty("recipeProcessor", args[2]);
|
||||
} else if (!hasOverlayIdentifier) {
|
||||
@@ -58,7 +66,7 @@ public class NEECommands extends CommandBase {
|
||||
}
|
||||
|
||||
if (hasOverlayIdentifier) {
|
||||
itemJsonObject.addProperty("identifier", args[2]);
|
||||
itemJsonObject.addProperty("identifier", args.length == 4 ? args[3] : args[2]);
|
||||
} else if (!hasRecipeProcessor) {
|
||||
sender.addChatMessage(new ChatComponentText("Can't find identifier: " + args[2]));
|
||||
}
|
||||
@@ -66,7 +74,6 @@ public class NEECommands extends CommandBase {
|
||||
}
|
||||
String newJsonString = new Gson().toJson(itemJsonObject);
|
||||
String[] oldList = "blacklist".equalsIgnoreCase(args[1]) ? NEEConfig.transformBlacklist : NEEConfig.transformPriorityList;
|
||||
String key = "blacklist".equalsIgnoreCase(args[1]) ? "transformItemBlacklist" : "transformItemPriorityList";
|
||||
List<String> newList = new ArrayList<>(Arrays.asList(oldList));
|
||||
for (String currentJsonString : oldList) {
|
||||
if (currentJsonString.equals(newJsonString)) {
|
||||
@@ -74,18 +81,29 @@ public class NEECommands extends CommandBase {
|
||||
}
|
||||
}
|
||||
newList.add(newJsonString);
|
||||
NEEConfig.config.getCategory("client").get(key).set(newList.toArray(new String[0]));
|
||||
NEEConfig.config.save();
|
||||
NEEConfig.reload();
|
||||
if ("blacklist".equalsIgnoreCase(args[1])) {
|
||||
NEEConfig.setTransformBlacklist(newList.toArray(new String[0]));
|
||||
} else {
|
||||
NEEConfig.setTransformPriorityList(newList.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
} else if ("priorityMod".equalsIgnoreCase(args[1]) && args.length == 3) {
|
||||
String modid = args[2];
|
||||
if (!ItemUtils.hasModId(modid)) {
|
||||
List<String> newList = new ArrayList<>(Arrays.asList(NEEConfig.transformPriorityModList));
|
||||
newList.add(modid);
|
||||
NEEConfig.config.getCategory("client").get("transformPriorityModList").set(newList.toArray(new String[0]));
|
||||
NEEConfig.config.save();
|
||||
NEEConfig.reload();
|
||||
NEEConfig.setTransformPriorityModList(newList.toArray(new String[0]));
|
||||
}
|
||||
} else if ("itemCombination".equalsIgnoreCase(args[1]) && args.length == 3) {
|
||||
String identifier = args[2];
|
||||
if (!Arrays.asList(NEEConfig.itemCombinationWhitelist).contains(identifier)) {
|
||||
if (ItemUtils.hasOverlayIdentifier(args[2])) {
|
||||
List<String> newLists = new ArrayList<>(Arrays.asList(NEEConfig.itemCombinationWhitelist));
|
||||
newLists.add(identifier);
|
||||
NEEConfig.setItemCombinationWhitelist(newLists.toArray(new String[0]));
|
||||
} else {
|
||||
sender.addChatMessage(new ChatComponentText("Can't find identifier: " + args[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ("reload".equalsIgnoreCase(args[0])) {
|
||||
@@ -98,8 +116,8 @@ public class NEECommands extends CommandBase {
|
||||
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender sender, String[] args) {
|
||||
return args.length <= 1 ? CommandBase.getListOfStringsMatchingLastWord(args, "reload", "add", "processor") :
|
||||
args.length == 2 ? CommandBase.getListOfStringsMatchingLastWord(args, "blacklist", "priorityItem", "priorityMod") : null;
|
||||
return args.length <= 1 ? CommandBase.getListOfStringsMatchingLastWord(args, "help", "reload", "add", "processor") :
|
||||
args.length == 2 ? CommandBase.getListOfStringsMatchingLastWord(args, "blacklist", "priorityItem", "priorityMod", "itemCombination") : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,7 +9,7 @@ import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerInputHandler;
|
||||
import com.github.vfyjxf.nee.client.GuiHandler;
|
||||
import com.github.vfyjxf.nee.client.GuiEventHandler;
|
||||
import com.github.vfyjxf.nee.client.NEEContainerDrawHandler;
|
||||
import com.github.vfyjxf.nee.config.NEEConfig;
|
||||
import com.github.vfyjxf.nee.nei.NEECraftingHandler;
|
||||
@@ -89,7 +89,7 @@ public class NEINeeConfig implements IConfigureNEI {
|
||||
}
|
||||
|
||||
private void registerGuiHandler() {
|
||||
API.registerNEIGuiHandler(GuiHandler.instance);
|
||||
API.registerNEIGuiHandler(GuiEventHandler.instance);
|
||||
//disable MouseScrollTransfer in some gui
|
||||
replaceNEIController();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.github.vfyjxf.nee.asm;
|
||||
|
||||
import appeng.client.gui.implementations.GuiInterface;
|
||||
import appeng.client.gui.implementations.GuiPatternTerm;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import com.github.vfyjxf.nee.config.NEEConfig;
|
||||
import com.github.vfyjxf.nee.nei.NEECraftingHandler;
|
||||
import com.github.vfyjxf.nee.network.NEENetworkHandler;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketSlotStackChange;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketStackCountChange;
|
||||
import com.github.vfyjxf.nee.utils.GuiUtils;
|
||||
import com.github.vfyjxf.nee.utils.ItemUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AppengHelper {
|
||||
|
||||
/**
|
||||
* Prevent the scroll bar from being triggered when modifying the number of items
|
||||
* This method is not intended to be called by NEE.
|
||||
* Do not use this method for any reason.
|
||||
*/
|
||||
public static boolean handleMouseWheelInput(int dWheel) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
boolean isPatternTerm = mc.currentScreen instanceof GuiPatternTerm || GuiUtils.isPatternTermExGui(mc.currentScreen);
|
||||
boolean isInterface = mc.currentScreen instanceof GuiInterface;
|
||||
if (isPatternTerm || isInterface) {
|
||||
if (dWheel != 0) {
|
||||
int x = Mouse.getEventX() * mc.currentScreen.width / mc.displayWidth;
|
||||
int y = mc.currentScreen.height - Mouse.getEventY() * mc.currentScreen.height / mc.displayHeight - 1;
|
||||
Slot currentSlot = ((GuiContainer) mc.currentScreen).getSlotAtPosition(x, y);
|
||||
if (currentSlot instanceof SlotFake && currentSlot.getHasStack()) {
|
||||
//try to change current itemstack to next ingredient;
|
||||
if (Keyboard.isKeyDown(NEIClientConfig.getKeyBinding("nee.ingredient")) && GuiUtils.isCraftingSlot(currentSlot)) {
|
||||
handleRecipeIngredientChange((GuiContainer) mc.currentScreen, currentSlot, dWheel);
|
||||
return true;
|
||||
} else if (Keyboard.isKeyDown(NEIClientConfig.getKeyBinding("nee.count"))) {
|
||||
int changeCount = dWheel / 120;
|
||||
NEENetworkHandler.getInstance().sendToServer(new PacketStackCountChange(currentSlot.slotNumber, changeCount));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void handleRecipeIngredientChange(GuiContainer gui, Slot currentSlot, int dWheel) {
|
||||
List<Integer> craftingSlots = new ArrayList<>();
|
||||
int currentSlotIndex = currentSlot.getSlotIndex();
|
||||
PositionedStack currentIngredients = NEECraftingHandler.ingredients.get("input" + currentSlotIndex);
|
||||
if (currentIngredients != null && currentIngredients.items.length > 1) {
|
||||
int currentStackIndex = ItemUtils.getIngredientIndex(currentSlot.getStack(), currentIngredients);
|
||||
if (currentStackIndex >= 0) {
|
||||
int nextStackIndex = dWheel / 120;
|
||||
for (int j = 0; j < Math.abs(nextStackIndex); j++) {
|
||||
currentStackIndex = nextStackIndex > 0 ? currentStackIndex + 1 : currentStackIndex - 1;
|
||||
if (currentStackIndex >= currentIngredients.items.length) {
|
||||
currentStackIndex = 0;
|
||||
} else if (currentStackIndex < 0) {
|
||||
currentStackIndex = currentIngredients.items.length - 1;
|
||||
}
|
||||
|
||||
ItemStack currentStack = currentIngredients.items[currentStackIndex].copy();
|
||||
currentStack.stackSize = currentSlot.getStack().stackSize;
|
||||
|
||||
if (NEEConfig.allowSynchronousSwitchIngredient) {
|
||||
for (Slot slot : getCraftingSlots(gui)) {
|
||||
|
||||
PositionedStack slotIngredients = NEECraftingHandler.ingredients.get("input" + slot.getSlotIndex());
|
||||
|
||||
boolean areItemStackEqual = currentSlot.getHasStack() &&
|
||||
slot.getHasStack() &&
|
||||
currentSlot.getStack().isItemEqual(slot.getStack()) &&
|
||||
ItemStack.areItemStackTagsEqual(currentSlot.getStack(), slot.getStack());
|
||||
|
||||
boolean areIngredientEqual = slotIngredients != null && currentIngredients.contains(slotIngredients.items[0]);
|
||||
|
||||
if (areItemStackEqual && areIngredientEqual) {
|
||||
craftingSlots.add(slot.slotNumber);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
craftingSlots.add(currentSlot.slotNumber);
|
||||
}
|
||||
NEENetworkHandler.getInstance().sendToServer(new PacketSlotStackChange(currentStack, craftingSlots));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static List<Slot> getCraftingSlots(GuiContainer gui) {
|
||||
List<Slot> craftingSlots = new ArrayList<>();
|
||||
for (Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots) {
|
||||
if (GuiUtils.isCraftingSlot(slot)) {
|
||||
craftingSlots.add(slot);
|
||||
}
|
||||
}
|
||||
return craftingSlots;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.github.vfyjxf.nee.asm;
|
||||
|
||||
import codechicken.lib.asm.ASMInit;
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
import com.github.vfyjxf.nee.NotEnoughEnergistics;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
@@ -13,11 +15,19 @@ import static org.objectweb.asm.Opcodes.*;
|
||||
|
||||
public class NEEClassTransformer implements IClassTransformer {
|
||||
|
||||
static {
|
||||
ASMInit.init();
|
||||
}
|
||||
|
||||
private static final List<String> transformedClassNames = Arrays.asList(
|
||||
"appeng/integration/modules/NEIHelpers/NEIInscriberRecipeHandler",
|
||||
"appeng/integration/modules/NEIHelpers/NEIGrinderRecipeHandler"
|
||||
);
|
||||
|
||||
private static final String TARGET_CLASS_NAME = "appeng/client/gui/AEBaseGui";
|
||||
|
||||
private static final ObfMapping TARGET_METHOD_MAPPING = new ObfMapping(TARGET_CLASS_NAME, "func_146274_d", "()V").toClassloading();
|
||||
|
||||
private static final String METHOD_OWNER = "codechicken/nei/recipe/TemplateRecipeHandler";
|
||||
|
||||
private static final String METHOD_NAME_1 = "getOverlayHandler";
|
||||
@@ -34,9 +44,7 @@ public class NEEClassTransformer implements IClassTransformer {
|
||||
|
||||
//rewrite ae2's methods to support recipe transfer.
|
||||
if (transformedClassNames.contains(internalName)) {
|
||||
ClassNode classNode = new ClassNode();
|
||||
ClassReader classReader = new ClassReader(basicClass);
|
||||
classReader.accept(classNode, 0);
|
||||
ClassNode classNode = createClassNode(basicClass);
|
||||
for (MethodNode methodNode : classNode.methods) {
|
||||
if (METHOD_NAME_1.equals(methodNode.name) && METHOD_TARGET_1.equals(methodNode.desc)) {
|
||||
NotEnoughEnergistics.logger.info("Transforming : " + internalName + methodNode.name + methodNode.desc);
|
||||
@@ -81,9 +89,45 @@ public class NEEClassTransformer implements IClassTransformer {
|
||||
classNode.accept(classWriter);
|
||||
return classWriter.toByteArray();
|
||||
}
|
||||
|
||||
|
||||
if (TARGET_CLASS_NAME.equals(internalName)) {
|
||||
ClassNode classNode = createClassNode(basicClass);
|
||||
for (MethodNode methodNode : classNode.methods) {
|
||||
if (TARGET_METHOD_MAPPING.matches(methodNode)) {
|
||||
NotEnoughEnergistics.logger.info("Transforming : " + internalName + methodNode.name + methodNode.desc);
|
||||
AbstractInsnNode aLoad = methodNode.instructions.getLast().getPrevious();
|
||||
while (aLoad.getOpcode() != ALOAD) {
|
||||
aLoad = aLoad.getPrevious();
|
||||
}
|
||||
InsnList insnList = new InsnList();
|
||||
insnList.add(new VarInsnNode(ILOAD, 1));
|
||||
insnList.add(new MethodInsnNode(INVOKESTATIC,
|
||||
"com/github/vfyjxf/nee/asm/AppengHelper",
|
||||
"handleMouseWheelInput",
|
||||
"(I)Z", false));
|
||||
LabelNode label = new LabelNode();
|
||||
insnList.add(new JumpInsnNode(IFEQ, label));
|
||||
insnList.add(new InsnNode(RETURN));
|
||||
insnList.add(label);
|
||||
methodNode.instructions.insertBefore(aLoad, insnList);
|
||||
}
|
||||
}
|
||||
ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
|
||||
classNode.accept(classWriter);
|
||||
return classWriter.toByteArray();
|
||||
}
|
||||
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
private ClassNode createClassNode(byte[] basicClass) {
|
||||
ClassNode classNode = new ClassNode();
|
||||
ClassReader classReader = new ClassReader(basicClass);
|
||||
classReader.accept(classNode, 0);
|
||||
return classNode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+51
-49
@@ -1,35 +1,26 @@
|
||||
package com.github.vfyjxf.nee.client;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.implementations.GuiCraftConfirm;
|
||||
import appeng.client.gui.implementations.GuiCraftingTerm;
|
||||
import appeng.client.gui.implementations.GuiInterface;
|
||||
import appeng.client.gui.implementations.GuiPatternTerm;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.VisiblityData;
|
||||
import codechicken.nei.api.INEIGuiHandler;
|
||||
import codechicken.nei.api.TaggedInventoryArea;
|
||||
import com.github.vfyjxf.nee.config.ItemCombination;
|
||||
import com.github.vfyjxf.nee.config.NEEConfig;
|
||||
import com.github.vfyjxf.nee.gui.widgets.GuiImgButtonEnableCombination;
|
||||
import com.github.vfyjxf.nee.nei.NEECraftingHandler;
|
||||
import com.github.vfyjxf.nee.network.NEENetworkHandler;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketCraftingRequest;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketSlotStackChange;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketStackCountChange;
|
||||
import com.github.vfyjxf.nee.utils.GuiUtils;
|
||||
import com.github.vfyjxf.nee.utils.ItemUtils;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -37,52 +28,62 @@ import java.util.List;
|
||||
|
||||
import static com.github.vfyjxf.nee.config.NEEConfig.draggedStackDefaultSize;
|
||||
import static com.github.vfyjxf.nee.config.NEEConfig.useStackSizeFromNEI;
|
||||
import static com.github.vfyjxf.nee.nei.NEECraftingHelper.*;
|
||||
|
||||
public class GuiHandler implements INEIGuiHandler {
|
||||
public class GuiEventHandler implements INEIGuiHandler {
|
||||
|
||||
public static GuiHandler instance = new GuiHandler();
|
||||
public static GuiEventHandler instance = new GuiEventHandler();
|
||||
|
||||
private GuiImgButtonEnableCombination buttonCombination;
|
||||
private boolean hasDoubleBtn = true;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SubscribeEvent
|
||||
public void onRenderTick(TickEvent.RenderTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.START) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
boolean isPatternTerm = mc.currentScreen instanceof GuiPatternTerm || GuiUtils.isPatternTermExGui(mc.currentScreen);
|
||||
boolean isInterface = mc.currentScreen instanceof GuiInterface;
|
||||
if (isPatternTerm || isInterface) {
|
||||
int dWheel = Mouse.getDWheel();
|
||||
if (dWheel != 0) {
|
||||
int x = Mouse.getEventX() * mc.currentScreen.width / mc.displayWidth;
|
||||
int y = mc.currentScreen.height - Mouse.getEventY() * mc.currentScreen.height / mc.displayHeight - 1;
|
||||
Slot currentSlot = ((GuiContainer) mc.currentScreen).getSlotAtPosition(x, y);
|
||||
if (currentSlot instanceof SlotFake && currentSlot.getHasStack()) {
|
||||
//try to change current itemstack to next ingredient;
|
||||
if (Keyboard.isKeyDown(NEIClientConfig.getKeyBinding("nee.ingredient")) && GuiUtils.isCraftingSlot(currentSlot)) {
|
||||
handleRecipeIngredientChange((GuiContainer) mc.currentScreen, currentSlot, dWheel);
|
||||
} else if (Keyboard.isKeyDown(NEIClientConfig.getKeyBinding("nee.count"))) {
|
||||
int changeCount = dWheel / 120;
|
||||
NEENetworkHandler.getInstance().sendToServer(new PacketStackCountChange(currentSlot.slotNumber, changeCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onInitGui(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
if (event.gui instanceof GuiPatternTerm) {
|
||||
GuiPatternTerm gui = (GuiPatternTerm) event.gui;
|
||||
try {
|
||||
GuiPatternTerm.class.getDeclaredField("doubleBtn");
|
||||
} catch (NoSuchFieldException e) {
|
||||
hasDoubleBtn = false;
|
||||
}
|
||||
if (hasDoubleBtn) {
|
||||
buttonCombination = new GuiImgButtonEnableCombination(gui.guiLeft + 84, gui.guiTop + gui.ySize - 153, ItemCombination.valueOf(NEEConfig.itemCombinationMode));
|
||||
} else {
|
||||
buttonCombination = new GuiImgButtonEnableCombination(gui.guiLeft + 74, gui.guiTop + gui.ySize - 153, ItemCombination.valueOf(NEEConfig.itemCombinationMode));
|
||||
|
||||
}
|
||||
event.buttonList.add(buttonCombination);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onGuiOpen(GuiOpenEvent event) {
|
||||
GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
|
||||
boolean isGuiCraftingTerm = event.gui instanceof GuiCraftingTerm || GuiUtils.isGuiWirelessCrafting(event.gui);
|
||||
boolean isGuiCraftConfirm = currentScreen instanceof GuiCraftConfirm || GuiUtils.isWirelessGuiCraftConfirm(currentScreen);
|
||||
if (isGuiCraftingTerm && isGuiCraftConfirm && tracker != null) {
|
||||
if (!tracker.getRequireStacks().isEmpty() && stackIndex < tracker.getRequireStacks().size()) {
|
||||
IAEItemStack stack = AEItemStack.create(tracker.getRequireStacks().get(stackIndex));
|
||||
NEENetworkHandler.getInstance().sendToServer(new PacketCraftingRequest(stack, noPreview));
|
||||
stackIndex++;
|
||||
public void onActionPerformed(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
||||
if (event.button == this.buttonCombination) {
|
||||
GuiImgButtonEnableCombination button = (GuiImgButtonEnableCombination) event.button;
|
||||
int ordinal = Mouse.getEventButton() != 2 ? button.getCurrentValue().ordinal() + 1 : button.getCurrentValue().ordinal() - 1;
|
||||
|
||||
if (ordinal >= ItemCombination.values().length) {
|
||||
ordinal = 0;
|
||||
}
|
||||
if (ordinal < 0) {
|
||||
ordinal = ItemCombination.values().length - 1;
|
||||
}
|
||||
button.setValue(ItemCombination.values()[ordinal]);
|
||||
NEEConfig.setItemCombinationMode(ItemCombination.values()[ordinal].name());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDrawScreen(GuiScreenEvent.DrawScreenEvent.Post event) {
|
||||
if (event.gui instanceof GuiPatternTerm) {
|
||||
ContainerPatternTerm container = (ContainerPatternTerm) ((GuiPatternTerm) event.gui).inventorySlots;
|
||||
if (container.isCraftingMode()) {
|
||||
buttonCombination.enabled = false;
|
||||
buttonCombination.visible = false;
|
||||
} else {
|
||||
buttonCombination.enabled = true;
|
||||
buttonCombination.visible = true;
|
||||
}
|
||||
} else if (!isGuiCraftingTerm && isGuiCraftConfirm && tracker != null) {
|
||||
//Prevent opening the gui during normal use
|
||||
tracker = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,3 +183,4 @@ public class GuiHandler implements INEIGuiHandler {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.github.vfyjxf.nee.client;
|
||||
import appeng.client.gui.implementations.GuiCraftingTerm;
|
||||
import appeng.client.gui.implementations.GuiPatternTerm;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.guihook.IContainerDrawHandler;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
@@ -13,25 +12,21 @@ import com.github.vfyjxf.nee.utils.Ingredient;
|
||||
import com.github.vfyjxf.nee.utils.IngredientTracker;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Please note the difference between the GTNH NEI and the official NEI
|
||||
@@ -40,15 +35,29 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler {
|
||||
|
||||
public static NEEContainerDrawHandler instance = new NEEContainerDrawHandler();
|
||||
|
||||
private Field overlayButtonsField;
|
||||
private Method recipesPerPageMethod;
|
||||
public static final Map<String, IngredientTracker> trackerMap = new HashMap<>();
|
||||
|
||||
public static boolean isGtnhNei;
|
||||
|
||||
private final List<GuiButton> overlayButtons = new ArrayList<>();
|
||||
|
||||
public Field overlayButtonsField;
|
||||
public Method recipesPerPageMethod;
|
||||
private boolean drawRequestTooltip;
|
||||
private boolean drawMissingTooltip;
|
||||
private boolean drawCraftableTooltip;
|
||||
private boolean isGtnhNei;
|
||||
|
||||
public NEEContainerDrawHandler() {
|
||||
|
||||
//gtnh nei support
|
||||
isGtnhNei = true;
|
||||
try {
|
||||
this.overlayButtonsField = GuiRecipe.class.getDeclaredField("overlayButtons");
|
||||
this.recipesPerPageMethod = GuiRecipe.class.getDeclaredMethod("getRecipesPerPage");
|
||||
this.overlayButtonsField.setAccessible(true);
|
||||
this.recipesPerPageMethod.setAccessible(true);
|
||||
} catch (NoSuchMethodException | NoSuchFieldException e) {
|
||||
isGtnhNei = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,103 +83,46 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler {
|
||||
@SuppressWarnings("ALL")
|
||||
@Override
|
||||
public void renderSlotOverlay(GuiContainer gui, Slot slot) {
|
||||
|
||||
if (NEEConfig.drawHighlight && gui instanceof GuiRecipe) {
|
||||
//gtnh nei support
|
||||
this.isGtnhNei = true;
|
||||
if (this.overlayButtonsField == null || this.recipesPerPageMethod == null) {
|
||||
try {
|
||||
this.overlayButtonsField = GuiRecipe.class.getDeclaredField("overlayButtons");
|
||||
this.recipesPerPageMethod = GuiRecipe.class.getDeclaredMethod("getRecipesPerPage");
|
||||
this.overlayButtonsField.setAccessible(true);
|
||||
this.recipesPerPageMethod.setAccessible(true);
|
||||
} catch (NoSuchMethodException | NoSuchFieldException e) {
|
||||
this.isGtnhNei = false;
|
||||
}
|
||||
}
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (NEEConfig.drawHighlight && gui instanceof GuiRecipe && !overlayButtons.isEmpty()) {
|
||||
GuiRecipe guiRecipe = (GuiRecipe) gui;
|
||||
GuiContainer firstGui = guiRecipe.firstGui;
|
||||
boolean isGuiPatternTerm = firstGui instanceof GuiPatternTerm || GuiUtils.isPatternTermExGui(firstGui);
|
||||
boolean isCraftingTerm = firstGui instanceof GuiCraftingTerm || GuiUtils.isGuiWirelessCrafting(firstGui);
|
||||
if (isGuiPatternTerm || isCraftingTerm) {
|
||||
final ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
int i = scaledresolution.getScaledWidth();
|
||||
int j = scaledresolution.getScaledHeight();
|
||||
final int mouseX = Mouse.getX() * i / mc.displayWidth;
|
||||
final int mouseY = j - Mouse.getY() * j / mc.displayHeight - 1;
|
||||
for (GuiButton overlayButton : overlayButtons) {
|
||||
if (GuiUtils.isMouseOverButton(overlayButton)) {
|
||||
IngredientTracker tracker = trackerMap.get("button" + overlayButton.id);
|
||||
if (tracker != null) {
|
||||
for (Ingredient ingredient : tracker.getIngredients()) {
|
||||
Point point = guiRecipe.getRecipePosition(tracker.getRecipeIndex());
|
||||
Slot currentSlot = guiRecipe.slotcontainer.getSlotWithStack(ingredient.getIngredient(), point.x, point.y);
|
||||
if (slot.equals(currentSlot)) {
|
||||
if (!NEEConfig.enableCraftAmountSettingGui) {
|
||||
GuiContainer firstGui = guiRecipe.firstGui;
|
||||
boolean renderAutoAbleItems = (firstGui instanceof GuiCraftingTerm || GuiUtils.isGuiWirelessCrafting(firstGui)) && ingredient.isCraftable() && ingredient.requiresToCraft();
|
||||
boolean renderCraftableItems = (firstGui instanceof GuiPatternTerm || GuiUtils.isPatternTermExGui(firstGui)) && ingredient.isCraftable();
|
||||
boolean renderMissingItems = (firstGui instanceof GuiCraftingTerm || GuiUtils.isGuiWirelessCrafting(firstGui)) && !ingredient.isCraftable() && ingredient.requiresToCraft();
|
||||
if (renderAutoAbleItems || renderCraftableItems) {
|
||||
Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition,
|
||||
slot.xDisplayPosition + 16, slot.yDisplayPosition + 16,
|
||||
new Color(0.0f, 0.0f, 1.0f, 0.4f).getRGB());
|
||||
this.drawCraftableTooltip = renderCraftableItems;
|
||||
this.drawRequestTooltip = renderAutoAbleItems;
|
||||
}
|
||||
if (renderMissingItems) {
|
||||
Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition,
|
||||
slot.xDisplayPosition + 16, slot.yDisplayPosition + 16,
|
||||
new Color(1.0f, 0.0f, 0.0f, 0.4f).getRGB());
|
||||
this.drawMissingTooltip = true;
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
List<GuiButton> overlayButtons = null;
|
||||
if (isGtnhNei) {
|
||||
try {
|
||||
overlayButtons = new ArrayList<>(Arrays.asList((GuiButton[]) this.overlayButtonsField.get(guiRecipe)));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
overlayButtons = new ArrayList<>();
|
||||
GuiButton overlay1 = ReflectionHelper.getPrivateValue(GuiRecipe.class, guiRecipe, "overlay1");
|
||||
GuiButton overlay2 = ReflectionHelper.getPrivateValue(GuiRecipe.class, guiRecipe, "overlay2");
|
||||
overlayButtons.add(overlay1);
|
||||
overlayButtons.add(overlay2);
|
||||
}
|
||||
|
||||
if (overlayButtons != null) {
|
||||
for (GuiButton button : overlayButtons) {
|
||||
if (button.visible && button.enabled && GuiUtils.isMouseOverButton(button, mouseX, mouseY)) {
|
||||
final int OVERLAY_BUTTON_ID_START = 4;
|
||||
IRecipeHandler handler = guiRecipe.currenthandlers.get(guiRecipe.recipetype);
|
||||
int recipesPerPage = 2;
|
||||
if (isGtnhNei) {
|
||||
try {
|
||||
recipesPerPage = (int) this.recipesPerPageMethod.invoke(guiRecipe);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (recipesPerPage >= 0 && handler != null) {
|
||||
int recipeIndex = guiRecipe.page * recipesPerPage + button.id - OVERLAY_BUTTON_ID_START;
|
||||
List<PositionedStack> ingredients = handler.getIngredientStacks(recipeIndex);
|
||||
IngredientTracker tracker = new IngredientTracker(guiRecipe.firstGui, handler, recipeIndex);
|
||||
|
||||
for (int var1 = 0; var1 < ingredients.size(); var1++) {
|
||||
PositionedStack stack = ingredients.get(var1);
|
||||
Ingredient ingredient = tracker.getIngredients().get(var1);
|
||||
Slot stackSlot = guiRecipe.slotcontainer.getSlotWithStack(stack, guiRecipe.getRecipePosition(recipeIndex).x, guiRecipe.getRecipePosition(recipeIndex).y);
|
||||
if (stackSlot.equals(slot)) {
|
||||
if (!NEEConfig.enableCraftAmountSettingGui) {
|
||||
boolean renderAutoAbleItems = (firstGui instanceof GuiCraftingTerm || GuiUtils.isGuiWirelessCrafting(firstGui)) && ingredient.isCraftable() && ingredient.requiresToCraft();
|
||||
boolean renderCraftableItems = (firstGui instanceof GuiPatternTerm || GuiUtils.isPatternTermExGui(firstGui)) && ingredient.isCraftable();
|
||||
boolean renderMissingItems = (firstGui instanceof GuiCraftingTerm || GuiUtils.isGuiWirelessCrafting(firstGui)) && !ingredient.isCraftable() && ingredient.requiresToCraft();
|
||||
if (renderAutoAbleItems || renderCraftableItems) {
|
||||
Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition,
|
||||
slot.xDisplayPosition + 16, slot.yDisplayPosition + 16,
|
||||
new Color(0.0f, 0.0f, 1.0f, 0.4f).getRGB());
|
||||
this.drawCraftableTooltip = renderCraftableItems;
|
||||
this.drawRequestTooltip = renderAutoAbleItems;
|
||||
}
|
||||
if (renderMissingItems) {
|
||||
Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition,
|
||||
slot.xDisplayPosition + 16, slot.yDisplayPosition + 16,
|
||||
new Color(1.0f, 0.0f, 0.0f, 0.4f).getRGB());
|
||||
this.drawMissingTooltip = true;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (ingredient.isCraftable()) {
|
||||
Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition,
|
||||
slot.xDisplayPosition + 16, slot.yDisplayPosition + 16,
|
||||
new Color(0.0f, 0.0f, 1.0f, 0.4f).getRGB());
|
||||
this.drawRequestTooltip = true;
|
||||
} else {
|
||||
Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition,
|
||||
slot.xDisplayPosition + 16, slot.yDisplayPosition + 16,
|
||||
new Color(1.0f, 0.0f, 0.0f, 0.4f).getRGB());
|
||||
this.drawMissingTooltip = true;
|
||||
}
|
||||
}
|
||||
if (ingredient.isCraftable()) {
|
||||
Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition,
|
||||
slot.xDisplayPosition + 16, slot.yDisplayPosition + 16,
|
||||
new Color(0.0f, 0.0f, 1.0f, 0.4f).getRGB());
|
||||
this.drawRequestTooltip = true;
|
||||
} else {
|
||||
Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition,
|
||||
slot.xDisplayPosition + 16, slot.yDisplayPosition + 16,
|
||||
new Color(1.0f, 0.0f, 0.0f, 0.4f).getRGB());
|
||||
this.drawMissingTooltip = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,37 +135,41 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDrawScreen(GuiScreenEvent.DrawScreenEvent.Post event) {
|
||||
if (this.drawCraftableTooltip || this.drawRequestTooltip || this.drawMissingTooltip) {
|
||||
if (event.gui instanceof GuiRecipe) {
|
||||
GuiRecipe guiRecipe = (GuiRecipe) event.gui;
|
||||
List<GuiButton> overlayButtons = null;
|
||||
if (this.isGtnhNei) {
|
||||
try {
|
||||
overlayButtons = new ArrayList<>(Arrays.asList((GuiButton[]) this.overlayButtonsField.get(guiRecipe)));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
overlayButtons = new ArrayList<>();
|
||||
GuiButton overlay1 = ReflectionHelper.getPrivateValue(GuiRecipe.class, guiRecipe, "overlay1");
|
||||
GuiButton overlay2 = ReflectionHelper.getPrivateValue(GuiRecipe.class, guiRecipe, "overlay2");
|
||||
overlayButtons.add(overlay1);
|
||||
overlayButtons.add(overlay2);
|
||||
if (event.gui instanceof GuiRecipe) {
|
||||
GuiRecipe guiRecipe = (GuiRecipe) event.gui;
|
||||
GuiContainer firstGui = guiRecipe.firstGui;
|
||||
boolean isGuiPatternTerm = firstGui instanceof GuiPatternTerm || GuiUtils.isPatternTermExGui(firstGui);
|
||||
boolean isCraftingTerm = firstGui instanceof GuiCraftingTerm || GuiUtils.isGuiWirelessCrafting(firstGui);
|
||||
if (isCraftingTerm || isGuiPatternTerm) {
|
||||
if (overlayButtons.isEmpty()) {
|
||||
setOverlayButtons(guiRecipe);
|
||||
}
|
||||
if (overlayButtons != null) {
|
||||
|
||||
if (!checkTracker()) {
|
||||
trackerMap.clear();
|
||||
for (GuiButton button : overlayButtons) {
|
||||
if (button.visible && button.enabled && GuiUtils.isMouseOverButton(button, event.mouseX, event.mouseY)) {
|
||||
if (GuiUtils.isMouseOverButton(button)) {
|
||||
trackerMap.put("button" + button.id, getTracker(guiRecipe, button, isCraftingTerm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.drawCraftableTooltip || this.drawRequestTooltip || this.drawMissingTooltip) {
|
||||
for (GuiButton button : overlayButtons) {
|
||||
if (button.visible && button.enabled && GuiUtils.isMouseOverButton(button)) {
|
||||
drawCraftingHelperTooltip(guiRecipe, event.mouseX, event.mouseY);
|
||||
this.drawCraftableTooltip = false;
|
||||
this.drawRequestTooltip = false;
|
||||
this.drawMissingTooltip = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void drawCraftingHelperTooltip(GuiRecipe guiRecipe, int mouseX, int mouseY) {
|
||||
List<String> tooltips = new ArrayList<>();
|
||||
boolean isCraftingTerm = guiRecipe.firstGui instanceof GuiCraftingTerm || GuiUtils.isGuiWirelessCrafting(guiRecipe.firstGui);
|
||||
@@ -234,4 +190,53 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler {
|
||||
//drawHoveringText
|
||||
guiRecipe.func_146283_a(tooltips, mouseX, mouseY);
|
||||
}
|
||||
|
||||
private void setOverlayButtons(GuiRecipe guiRecipe) {
|
||||
List<GuiButton> overlayButtons = null;
|
||||
if (isGtnhNei) {
|
||||
try {
|
||||
overlayButtons = new ArrayList<>(Arrays.asList((GuiButton[]) NEEContainerDrawHandler.instance.overlayButtonsField.get(guiRecipe)));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
overlayButtons = new ArrayList<>();
|
||||
GuiButton overlay1 = ReflectionHelper.getPrivateValue(GuiRecipe.class, guiRecipe, "overlay1");
|
||||
GuiButton overlay2 = ReflectionHelper.getPrivateValue(GuiRecipe.class, guiRecipe, "overlay2");
|
||||
overlayButtons.add(overlay1);
|
||||
overlayButtons.add(overlay2);
|
||||
}
|
||||
if (overlayButtons != null) {
|
||||
this.overlayButtons.addAll(overlayButtons);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkTracker() {
|
||||
for (GuiButton overlayButton : overlayButtons) {
|
||||
if (trackerMap.get("button" + overlayButton.id) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private IngredientTracker getTracker(GuiRecipe guiRecipe, GuiButton overlayButton, boolean isCraftingTerm) {
|
||||
if (overlayButton.enabled && overlayButton.visible) {
|
||||
final int OVERLAY_BUTTON_ID_START = 4;
|
||||
IRecipeHandler handler = guiRecipe.currenthandlers.get(guiRecipe.recipetype);
|
||||
int recipesPerPage = 2;
|
||||
if (isGtnhNei) {
|
||||
try {
|
||||
recipesPerPage = (int) NEEContainerDrawHandler.instance.recipesPerPageMethod.invoke(guiRecipe);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (recipesPerPage >= 0 && handler != null) {
|
||||
int recipeIndex = guiRecipe.page * recipesPerPage + overlayButton.id - OVERLAY_BUTTON_ID_START;
|
||||
return isCraftingTerm ? new IngredientTracker(guiRecipe.firstGui, handler, recipeIndex) : new IngredientTracker(guiRecipe, handler, recipeIndex);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.github.vfyjxf.nee.config;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum ItemCombination {
|
||||
DISABLED, ENABLED, WHITELIST;
|
||||
|
||||
public String getLocalName() {
|
||||
return I18n.format("gui.neenergistics.button.name" + "." + this.name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
@@ -14,17 +14,22 @@ import java.io.File;
|
||||
public class NEEConfig {
|
||||
|
||||
public static Configuration config;
|
||||
public static final String CATEGORY_PATTERN_TRANSFER = "transfer";
|
||||
public static final String CATEGORY_CRAFTING_HELPER = "helper";
|
||||
public static final String CATEGORY_OTHER_SETTINGS = "other";
|
||||
|
||||
public static String[] transformBlacklist = new String[0];
|
||||
public static String[] transformPriorityList = new String[0];
|
||||
public static String[] transformPriorityModList = new String[0];
|
||||
public static String itemCombinationMode = "ENABLED";
|
||||
public static String[] itemCombinationWhitelist = new String[0];
|
||||
|
||||
public static boolean noShift = true;
|
||||
public static boolean matchOtherItems = true;
|
||||
public static boolean drawHighlight = true;
|
||||
public static boolean allowSynchronousSwitchIngredient = true;
|
||||
public static boolean useStackSizeFromNEI = false;
|
||||
public static boolean enableCraftAmountSettingGui = true;
|
||||
public static boolean useStackSizeFromNEI = true;
|
||||
public static boolean enableCraftAmountSettingGui = false;
|
||||
|
||||
public static int draggedStackDefaultSize = 1;
|
||||
|
||||
@@ -32,70 +37,109 @@ public class NEEConfig {
|
||||
config = new Configuration(configFile);
|
||||
config.load();
|
||||
|
||||
transformBlacklist = config.get("client", "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("client", "transformItemPriorityList", new String[0],
|
||||
"If item in the priority list, it will be transferred first.").getStringList();
|
||||
{
|
||||
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("client", "transformPriorityModList", new String[0],
|
||||
"if oredict has this mod's item, use it 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("client", "noShift", true,
|
||||
"if true, you don't need to press shift to use NEI's transfer system in CratingTerminal and PatternTerminal").getBoolean();
|
||||
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();
|
||||
|
||||
matchOtherItems = config.get("client", "matchOnCraftableItems", true,
|
||||
"If true, Crafting Helper will match other items even they can't auto-crafting").getBoolean();
|
||||
itemCombinationMode = config.get(CATEGORY_PATTERN_TRANSFER, "itemCombinationMode", itemCombinationMode,
|
||||
"Item Combination Mode Setting, here are all the modes. \n"
|
||||
+ "\"ENABLED\"" + " " + "\"DISABLED\"" + " " + "WHITELIST").getString();
|
||||
|
||||
drawHighlight = config.get("client", "drawHighlight", true,
|
||||
"if true,it will draw highlight for missing items and item which can autocraft in nei").getBoolean();
|
||||
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();
|
||||
|
||||
allowSynchronousSwitchIngredient = config.get("client", "allowSynchronousSwitchIngredient", true,
|
||||
"If true, it will make all similar ingredient switch at the same time").getBoolean(true);
|
||||
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();
|
||||
|
||||
useStackSizeFromNEI = config.get("client", "useStackSizeFromNEI", false,
|
||||
"Use the StackSize set by 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);
|
||||
|
||||
enableCraftAmountSettingGui = config.get("client", "enableCraftAmountSettingGui", true,
|
||||
"If true, it will open a gui to set craft amount after ctrl + click [?] button").getBoolean();
|
||||
|
||||
draggedStackDefaultSize = config.get("client", "draggedStackDefaultSize", 1,
|
||||
"The default size of the dragged ItemStack when it is put in slot(Used when useStackSizeFromNEI is false)", 1, 64).getInt();
|
||||
useStackSizeFromNEI = config.get(CATEGORY_OTHER_SETTINGS, "useStackSizeFromNEI", true,
|
||||
"Use the StackSize set by NEI").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("client", "transformItemBlacklist", new String[0],
|
||||
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("client", "transformItemPriorityList", new String[0],
|
||||
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("client", "transformPriorityModList", new String[0],
|
||||
transformPriorityModList = config.get(CATEGORY_PATTERN_TRANSFER, "transformPriorityModList", new String[0],
|
||||
"if oredict has this mod's item, use it first").getStringList();
|
||||
|
||||
matchOtherItems = config.get("client", "matchOnCraftableItems", false,
|
||||
"If false, Crafting Helper will not match other items").getBoolean();
|
||||
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();
|
||||
|
||||
allowSynchronousSwitchIngredient = config.get("client", "allowSynchronousSwitchIngredient", true,
|
||||
"If true, it will make all similar ingredient switch at the same time").getBoolean(true);
|
||||
|
||||
useStackSizeFromNEI = config.get("client", "useStackSizeFromNEI", false,
|
||||
"Use the StackSize set by NEI").getBoolean();
|
||||
|
||||
enableCraftAmountSettingGui = config.get("client", "enableCraftAmountSettingGui", true,
|
||||
"If true, it will open a gui to set craft amount after ctrl + click [?] button").getBoolean();
|
||||
|
||||
draggedStackDefaultSize = config.get("client", "draggedStackDefaultSize", 1,
|
||||
"The default size of the dragged ItemStack when it is put in slot(Used when useStackSizeFromNEI is false)", 1, 64).getInt();
|
||||
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();
|
||||
}
|
||||
|
||||
public static void setItemCombinationMode(String itemCombinationMode) {
|
||||
NEEConfig.itemCombinationMode = itemCombinationMode;
|
||||
config.get(CATEGORY_PATTERN_TRANSFER, "itemCombinationMode", itemCombinationMode, "Item Combination Mode Setting, here are all the modes. \n" + "\"ENABLED\"" + " " + "\"DISABLED\"" + " " + "WHITELIST").set(itemCombinationMode);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public static void setItemCombinationWhitelist(String[] itemCombinationWhitelist) {
|
||||
NEEConfig.itemCombinationWhitelist = itemCombinationWhitelist;
|
||||
config.get(CATEGORY_PATTERN_TRANSFER, "itemCombinationWhitelist", itemCombinationWhitelist, "Whitelist for item combination").set(itemCombinationWhitelist);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public static void setTransformBlacklist(String[] transformBlacklist) {
|
||||
NEEConfig.transformBlacklist = transformBlacklist;
|
||||
config.get("client", "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}\"").set(transformBlacklist);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public static void setTransformPriorityList(String[] transformPriorityList) {
|
||||
NEEConfig.transformPriorityList = transformPriorityList;
|
||||
config.get("client", "transformPriorityModList", new String[0],
|
||||
"if oredict has this mod's item, use it first").set(transformPriorityList);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public static void setTransformPriorityModList(String[] transformPriorityModList) {
|
||||
NEEConfig.transformPriorityModList = transformPriorityModList;
|
||||
config.get("client", "transformPriorityModList", new String[0],
|
||||
"if oredict has this mod's item, use it first").set(transformPriorityModList);
|
||||
config.save();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
|
||||
if (NotEnoughEnergistics.MODID.equals(event.modID)) {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.github.vfyjxf.nee.gui;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.implementations.GuiCraftConfirm;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.github.vfyjxf.nee.network.NEENetworkHandler;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketCraftingRequest;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import static com.github.vfyjxf.nee.nei.NEECraftingHelper.*;
|
||||
|
||||
public class GuiCraftingConfirm extends GuiCraftConfirm {
|
||||
|
||||
public GuiCraftingConfirm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super(inventoryPlayer, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
if (tracker != null && tracker.getRequireStacks().size() > 1 && stackIndex < tracker.getRequireStacks().size()) {
|
||||
IAEItemStack stack = AEItemStack.create(tracker.getRequiredStack(stackIndex));
|
||||
NEENetworkHandler.getInstance().sendToServer(new PacketCraftingRequest(stack, noPreview));
|
||||
stackIndex++;
|
||||
} else {
|
||||
tracker = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import appeng.api.parts.IPartHost;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.implementations.ContainerCraftConfirm;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import com.github.vfyjxf.nee.container.ContainerCraftingAmount;
|
||||
import com.github.vfyjxf.nee.utils.ModIDs;
|
||||
@@ -28,7 +29,8 @@ import static com.github.vfyjxf.nee.NotEnoughEnergistics.instance;
|
||||
public class NEEGuiHandler implements IGuiHandler {
|
||||
|
||||
public static final int CRAFTING_AMOUNT_ID = 0;
|
||||
public static final int CRAFTING_AMOUNT_WIRELESS_ID = 1;
|
||||
public static final int CRAFTING_CONFIRM_ID = 1;
|
||||
public static final int CRAFTING_AMOUNT_WIRELESS_ID = 2;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -41,10 +43,20 @@ public class NEEGuiHandler implements IGuiHandler {
|
||||
if (tile instanceof IPartHost) {
|
||||
IPartHost partHost = (IPartHost) tile;
|
||||
IPart part = partHost.getPart(side);
|
||||
if (guiId == CRAFTING_AMOUNT_ID) {
|
||||
if (part instanceof PartCraftingTerminal) {
|
||||
return updateGui(new ContainerCraftingAmount(player.inventory, part), world, x, y, z, side, part);
|
||||
}
|
||||
switch (guiId) {
|
||||
case CRAFTING_AMOUNT_ID:
|
||||
if (part instanceof PartCraftingTerminal) {
|
||||
return updateGui(new ContainerCraftingAmount(player.inventory, part), world, x, y, z, side, part);
|
||||
}
|
||||
return null;
|
||||
case CRAFTING_CONFIRM_ID:
|
||||
if (part instanceof PartCraftingTerminal) {
|
||||
return updateGui(new ContainerCraftConfirm(player.inventory, (ITerminalHost) part), world, x, y, z, side, part);
|
||||
}
|
||||
return null;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,10 +80,20 @@ public class NEEGuiHandler implements IGuiHandler {
|
||||
if (tile instanceof IPartHost) {
|
||||
IPartHost partHost = (IPartHost) tile;
|
||||
IPart part = partHost.getPart(side);
|
||||
if (guiId == CRAFTING_AMOUNT_ID) {
|
||||
if (part instanceof PartCraftingTerminal) {
|
||||
return updateGui(new GuiCraftingAmount(player.inventory, (ITerminalHost) part), world, x, y, z, side, part);
|
||||
}
|
||||
switch (guiId) {
|
||||
case CRAFTING_AMOUNT_ID:
|
||||
if (part instanceof PartCraftingTerminal) {
|
||||
return updateGui(new GuiCraftingAmount(player.inventory, (ITerminalHost) part), world, x, y, z, side, part);
|
||||
}
|
||||
return null;
|
||||
case CRAFTING_CONFIRM_ID:
|
||||
if (part instanceof PartCraftingTerminal) {
|
||||
return updateGui(new GuiCraftingConfirm(player.inventory, (ITerminalHost) part), world, x, y, z, side, part);
|
||||
}
|
||||
return null;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.github.vfyjxf.nee.gui.widgets;
|
||||
|
||||
import appeng.client.gui.widgets.ITooltip;
|
||||
import com.github.vfyjxf.nee.config.ItemCombination;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiImgButtonEnableCombination extends GuiButton implements ITooltip {
|
||||
|
||||
private ItemCombination currentValue;
|
||||
|
||||
public GuiImgButtonEnableCombination(int x, int y, ItemCombination value) {
|
||||
super(0, x, y, "");
|
||||
this.xPosition = x;
|
||||
this.yPosition = y;
|
||||
this.width = 8;
|
||||
this.height = 8;
|
||||
this.currentValue = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int mouseX, int mouseY) {
|
||||
if (this.visible) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(this.xPosition, this.yPosition, 0.0F);
|
||||
GL11.glScalef(0.5f, 0.5f, 0.5f);
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
minecraft.renderEngine.bindTexture(new ResourceLocation("neenergistics", "textures/gui/states.png"));
|
||||
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||
this.drawTexturedModalRect(0, 0, 0, 0, 16, 16);
|
||||
if (this.currentValue == ItemCombination.ENABLED) {
|
||||
this.drawTexturedModalRect(0, 0, 16, 16, 16, 16);
|
||||
}
|
||||
if (this.currentValue == ItemCombination.DISABLED) {
|
||||
this.drawTexturedModalRect(0, 0, 16, 0, 16, 16);
|
||||
}
|
||||
if (this.currentValue == ItemCombination.WHITELIST) {
|
||||
this.drawTexturedModalRect(0, 0, 0, 16, 16, 16);
|
||||
}
|
||||
this.mouseDragged(minecraft, mouseX, mouseY);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
public void setValue(ItemCombination currentValue) {
|
||||
this.currentValue = currentValue;
|
||||
}
|
||||
|
||||
public ItemCombination getCurrentValue() {
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return I18n.format("gui.neenergistics.button.title.combination") +
|
||||
"\n" +
|
||||
I18n.format("gui.neenergistics.button.tooltip.combination", currentValue.getLocalName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.xPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.yPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import com.github.vfyjxf.nee.config.ItemCombination;
|
||||
import com.github.vfyjxf.nee.config.NEEConfig;
|
||||
import com.github.vfyjxf.nee.network.NEENetworkHandler;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketArcaneRecipe;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketExtremeRecipe;
|
||||
@@ -18,10 +20,7 @@ import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
@@ -77,12 +76,18 @@ public class NEECraftingHandler implements IOverlayHandler {
|
||||
for (PositionedStack positionedStack : inputs) {
|
||||
ItemStack currentStack = positionedStack.items[0];
|
||||
boolean find = false;
|
||||
for (PositionedStack storedStack : tInputs) {
|
||||
ItemStack firstStack = storedStack.items[0];
|
||||
boolean areItemStackEqual = firstStack.isItemEqual(currentStack) && ItemStack.areItemStackTagsEqual(firstStack, currentStack);
|
||||
if (areItemStackEqual && (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) {
|
||||
find = true;
|
||||
storedStack.items[0].stackSize = firstStack.stackSize + currentStack.stackSize;
|
||||
ItemCombination currentValue = ItemCombination.valueOf(NEEConfig.itemCombinationMode);
|
||||
if (currentValue != ItemCombination.DISABLED) {
|
||||
boolean isWhitelist = currentValue == ItemCombination.WHITELIST && Arrays.asList(NEEConfig.itemCombinationWhitelist).contains(identifier);
|
||||
if (currentValue == ItemCombination.ENABLED || isWhitelist) {
|
||||
for (PositionedStack storedStack : tInputs) {
|
||||
ItemStack firstStack = storedStack.items[0];
|
||||
boolean areItemStackEqual = firstStack.isItemEqual(currentStack) && ItemStack.areItemStackTagsEqual(firstStack, currentStack);
|
||||
if (areItemStackEqual && (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) {
|
||||
find = true;
|
||||
storedStack.items[0].stackSize = firstStack.stackSize + currentStack.stackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!find) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.github.vfyjxf.nee.proxy;
|
||||
|
||||
import com.github.vfyjxf.nee.NEECommands;
|
||||
import com.github.vfyjxf.nee.client.GuiHandler;
|
||||
import com.github.vfyjxf.nee.client.GuiEventHandler;
|
||||
import com.github.vfyjxf.nee.client.NEEContainerDrawHandler;
|
||||
import com.github.vfyjxf.nee.config.NEEConfig;
|
||||
import com.github.vfyjxf.nee.nei.NEECraftingHelper;
|
||||
@@ -15,8 +15,8 @@ public class ClientProxy extends CommonProxy {
|
||||
@Override
|
||||
public void init(FMLInitializationEvent event) {
|
||||
ClientCommandHandler.instance.registerCommand(new NEECommands());
|
||||
FMLCommonHandler.instance().bus().register(GuiHandler.instance);
|
||||
MinecraftForge.EVENT_BUS.register(GuiHandler.instance);
|
||||
FMLCommonHandler.instance().bus().register(GuiEventHandler.instance);
|
||||
MinecraftForge.EVENT_BUS.register(GuiEventHandler.instance);
|
||||
if (NEEConfig.noShift) {
|
||||
MinecraftForge.EVENT_BUS.register(NEECraftingHelper.INSTANCE);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,11 @@ import appeng.helpers.IContainerCraftingPacket;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
@@ -47,7 +49,14 @@ public class GuiUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isMouseOverButton(GuiButton button, int mouseX, int mouseY) {
|
||||
public static boolean isMouseOverButton(GuiButton button) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
final ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
int i = scaledresolution.getScaledWidth();
|
||||
int j = scaledresolution.getScaledHeight();
|
||||
final int mouseX = Mouse.getX() * i / mc.displayWidth;
|
||||
final int mouseY = j - Mouse.getY() * j / mc.displayHeight - 1;
|
||||
|
||||
return mouseX >= button.xPosition &&
|
||||
mouseY >= button.yPosition &&
|
||||
mouseX < button.xPosition + button.width &&
|
||||
|
||||
@@ -5,6 +5,7 @@ import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.implementations.GuiMEMonitorable;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import com.github.vfyjxf.nee.config.NEEConfig;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
@@ -23,12 +24,14 @@ public class IngredientTracker {
|
||||
private int craftingAmount = 1;
|
||||
private final GuiContainer termGui;
|
||||
private List<ItemStack> requireStacks;
|
||||
private final int recipeIndex;
|
||||
|
||||
/**
|
||||
* For NEECraftingHelper
|
||||
*/
|
||||
public IngredientTracker(GuiContainer termGui, IRecipeHandler recipe, int recipeIndex) {
|
||||
this.termGui = termGui;
|
||||
this.recipeIndex = recipeIndex;
|
||||
|
||||
for (PositionedStack requiredIngredient : recipe.getIngredientStacks(recipeIndex)) {
|
||||
Ingredient ingredient = new Ingredient(requiredIngredient);
|
||||
@@ -46,6 +49,26 @@ public class IngredientTracker {
|
||||
this.calculateIngredients();
|
||||
}
|
||||
|
||||
public IngredientTracker(GuiRecipe guiRecipe, IRecipeHandler recipe, int recipeIndex) {
|
||||
this.termGui = guiRecipe.firstGui;
|
||||
this.recipeIndex = recipeIndex;
|
||||
getCraftableStacks();
|
||||
|
||||
for (PositionedStack requiredIngredient : recipe.getIngredientStacks(recipeIndex)) {
|
||||
Ingredient ingredient = new Ingredient(requiredIngredient);
|
||||
ingredients.add(ingredient);
|
||||
}
|
||||
|
||||
for (Ingredient ingredient : this.ingredients) {
|
||||
for (IAEItemStack stack : getCraftableStacks()) {
|
||||
if (ingredient.getIngredient().contains(stack.getItemStack())) {
|
||||
ingredient.setCraftableIngredient(stack.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<IAEItemStack> getCraftableStacks() {
|
||||
@@ -160,6 +183,10 @@ public class IngredientTracker {
|
||||
return this.getRequireStacks().get(index);
|
||||
}
|
||||
|
||||
public int getRecipeIndex() {
|
||||
return recipeIndex;
|
||||
}
|
||||
|
||||
public void setCraftingAmount(int craftingAmount) {
|
||||
this.craftingAmount = craftingAmount;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user