diff --git a/build.gradle b/build.gradle index d799c1c..ca976c0 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ buildscript { } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-1.4.4-SNAPSHOT' + classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-1.4.5-SNAPSHOT' } } @@ -88,6 +88,9 @@ task sourcesJar(type: Jar) { } jar { + manifest.attributes( + 'FMLAT': 'neenergistics_at.cfg' + ) appendix project.minecraft.version } diff --git a/gradle.properties b/gradle.properties index 6310471..48aa3c1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.daemon=false mc_version=1.7.10 nei_version=2.1.6-GTNH ae2_version=rv3-beta-52-GTNH -mod_version=1.3.3 +mod_version=1.3.4 forge_version=10.13.4.1614 mod_group=com.github.vfyjxf.neenergistics mod_id=neenergistics diff --git a/libs/NotEnoughItems-1.7.10-1.0.5.120-universal.jar b/libs/NotEnoughItems-1.7.10-1.0.5.120-universal.jar deleted file mode 100644 index 5efa527..0000000 Binary files a/libs/NotEnoughItems-1.7.10-1.0.5.120-universal.jar and /dev/null differ diff --git a/src/main/java/com/github/vfyjxf/nee/NEINeeConfig.java b/src/main/java/com/github/vfyjxf/nee/NEINeeConfig.java index 947e3b7..c6a4cd0 100644 --- a/src/main/java/com/github/vfyjxf/nee/NEINeeConfig.java +++ b/src/main/java/com/github/vfyjxf/nee/NEINeeConfig.java @@ -50,9 +50,10 @@ public class NEINeeConfig implements IConfigureNEI { ); Set identifiers = new HashSet<>(defaultIdentifiers); - for (IRecipeProcessor processor : RecipeProcessor.recipeProcessors) { - identifiers.addAll(processor.getAllOverlayIdentifier()); - } + RecipeProcessor.recipeProcessors + .stream() + .map(IRecipeProcessor::getAllOverlayIdentifier) + .forEach(identifiers::addAll); for (String ident : identifiers) { API.registerGuiOverlay(GuiPatternTerm.class, ident); @@ -103,15 +104,16 @@ public class NEINeeConfig implements IConfigureNEI { } if (controllerIndex > 0) { GuiContainerManager.inputHandlers.remove(controllerIndex); - GuiContainerManager.inputHandlers.add(controllerIndex, new NEIController() { - @Override - public boolean mouseScrolled(GuiContainer gui, int mouseX, int mouseY, int scrolled) { - if (transferBlacklist.contains(gui.getClass())) { - return false; - } - return super.mouseScrolled(gui, mouseX, mouseY, scrolled); - } - }); + GuiContainerManager.inputHandlers.add(controllerIndex, + new NEIController() { + @Override + public boolean mouseScrolled(GuiContainer gui, int mouseX, int mouseY, int scrolled) { + if (transferBlacklist.contains(gui.getClass())) { + return false; + } + return super.mouseScrolled(gui, mouseX, mouseY, scrolled); + } + }); NotEnoughEnergistics.logger.info("NEIController replaced success"); } } diff --git a/src/main/java/com/github/vfyjxf/nee/client/GuiHandler.java b/src/main/java/com/github/vfyjxf/nee/client/GuiHandler.java index aecad49..9c0b8a0 100644 --- a/src/main/java/com/github/vfyjxf/nee/client/GuiHandler.java +++ b/src/main/java/com/github/vfyjxf/nee/client/GuiHandler.java @@ -51,7 +51,7 @@ public class GuiHandler implements INEIGuiHandler { if (dWheel != 0 && (isPatternTerm || isInterface)) { int x = Mouse.getEventX() * mc.currentScreen.width / mc.displayWidth; int y = mc.currentScreen.height - Mouse.getEventY() * mc.currentScreen.height / mc.displayHeight - 1; - Slot currentSlot = GuiUtils.getSlotUnderMouse((GuiContainer) mc.currentScreen, x, y); + 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)) { @@ -156,14 +156,15 @@ public class GuiHandler implements INEIGuiHandler { @Override public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) { if (gui instanceof AEBaseGui) { - if (button != 2) { - Slot currentSlot = GuiUtils.getSlotUnderMouse(gui, mouseX, mouseY); + if (button != 2 && draggedStack != null) { + Slot currentSlot = gui.getSlotAtPosition(mouseX, mouseY); if (currentSlot instanceof SlotFake && ((SlotFake) currentSlot).isEnabled()) { List slots = new ArrayList<>(); slots.add(currentSlot.slotNumber); ItemStack copyStack = draggedStack.copy(); copyStack.stackSize = useStackSizeFromNEI ? draggedStack.stackSize : draggedStackDefaultSize; NEENetworkHandler.getInstance().sendToServer(new PacketSlotStackChange(copyStack, slots)); + draggedStack.stackSize = 0; return true; } } diff --git a/src/main/java/com/github/vfyjxf/nee/client/NEEContainerDrawHandler.java b/src/main/java/com/github/vfyjxf/nee/client/NEEContainerDrawHandler.java index b7a8cb0..f6d7b88 100644 --- a/src/main/java/com/github/vfyjxf/nee/client/NEEContainerDrawHandler.java +++ b/src/main/java/com/github/vfyjxf/nee/client/NEEContainerDrawHandler.java @@ -14,7 +14,9 @@ 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.*; +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; @@ -32,6 +34,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +/** + * Please note the difference between the GTNH NEI and the official NEI + */ public class NEEContainerDrawHandler implements IContainerDrawHandler { public static NEEContainerDrawHandler instance = new NEEContainerDrawHandler(); @@ -39,6 +44,7 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler { private Field overlayButtonsField; private Method recipesPerPageMethod; private boolean drawRequestTooltip; + private boolean drawMissingTooltip; private boolean drawCraftableTooltip; private boolean isGtnhNei; @@ -105,7 +111,11 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler { e.printStackTrace(); } } else { - overlayButtons = new ArrayList<>(Arrays.asList(guiRecipe.overlay1, guiRecipe.overlay2)); + 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) { @@ -144,6 +154,7 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler { 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; } } } @@ -168,7 +179,11 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler { e.printStackTrace(); } } else { - overlayButtons = new ArrayList<>(Arrays.asList(guiRecipe.overlay1, guiRecipe.overlay2)); + 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) { @@ -176,6 +191,7 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler { drawCraftingHelperTooltip(guiRecipe, event.mouseX, event.mouseY); this.drawCraftableTooltip = false; this.drawRequestTooltip = false; + this.drawMissingTooltip = false; } } } @@ -186,25 +202,22 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler { private void drawCraftingHelperTooltip(GuiRecipe guiRecipe, int mouseX, int mouseY) { List tooltips = new ArrayList<>(); boolean isCraftingTerm = guiRecipe.firstGui instanceof GuiCraftingTerm || GuiUtils.isGuiWirelessCrafting(guiRecipe.firstGui); - if (this.drawRequestTooltip && isCraftingTerm) { - tooltips.add(String.format("%s" + EnumChatFormatting.GRAY + " + " + - EnumChatFormatting.BLUE + I18n.format("neenergistics.gui.tooltip.helper.crafting"), - EnumChatFormatting.YELLOW + Keyboard.getKeyName(NEIClientConfig.getKeyBinding("nee.preview")))); + if (isCraftingTerm) { + if(this.drawRequestTooltip) { + tooltips.add(String.format("%s" + EnumChatFormatting.GRAY + " + " + + EnumChatFormatting.BLUE + I18n.format("neenergistics.gui.tooltip.helper.crafting"), + EnumChatFormatting.YELLOW + Keyboard.getKeyName(NEIClientConfig.getKeyBinding("nee.preview")))); + } + if(this.drawMissingTooltip){ + tooltips.add(EnumChatFormatting.RED + I18n.format("neenergistics.gui.tooltip.missing")); + } } boolean isPatternTerm = guiRecipe.firstGui instanceof GuiPatternTerm || GuiUtils.isPatternTermExGui(guiRecipe.firstGui); if (this.drawCraftableTooltip && isPatternTerm) { tooltips.add(EnumChatFormatting.BLUE + I18n.format("neenergistics.gui.tooltip.helper.pattern")); } - try { - ReflectionHelper.findMethod(GuiScreen.class, guiRecipe, - new String[]{"drawHoveringText"}, - List.class, - int.class, - int.class, - FontRenderer.class).invoke(guiRecipe, tooltips, mouseX, mouseY, Minecraft.getMinecraft().fontRenderer); - } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - } + //drawHoveringText + guiRecipe.func_146283_a(tooltips, mouseX, mouseY); } @SuppressWarnings("unchecked") @@ -214,7 +227,11 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler { //check stacks in player's inventory and crafting grid List inventoryStacks = new ArrayList<>(); for (Slot slot : (List) firstGui.inventorySlots.inventorySlots) { - boolean canGetStack = slot != null && slot.getHasStack() && slot.getStack().stackSize > 0 && slot.isItemValid(slot.getStack()) && slot.canTakeStack(Minecraft.getMinecraft().thePlayer); + boolean canGetStack = slot != null && + slot.getHasStack() && + slot.getStack().stackSize > 0 && + slot.isItemValid(slot.getStack()) && + slot.canTakeStack(Minecraft.getMinecraft().thePlayer); if (canGetStack) { inventoryStacks.add(slot.getStack().copy()); } diff --git a/src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHandler.java b/src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHandler.java index f053b0c..7407484 100644 --- a/src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHandler.java +++ b/src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHandler.java @@ -58,71 +58,74 @@ public class NEECraftingHandler implements IOverlayHandler { int outputIndex = 0; //get all recipe inputs and other stacks,use first item for (IRecipeProcessor processor : RecipeProcessor.recipeProcessors) { - List inputs = processor.getRecipeInput(recipe, recipeIndex, identifier); - List outputs = processor.getRecipeOutput(recipe, recipeIndex, identifier); - String recipeProcessorId = processor.getRecipeProcessorId(); - List tInputs = new ArrayList<>(); + if (processor.getAllOverlayIdentifier().contains(identifier)) { + List inputs = processor.getRecipeInput(recipe, recipeIndex, identifier); + List outputs = processor.getRecipeOutput(recipe, recipeIndex, identifier); + String recipeProcessorId = processor.getRecipeProcessorId(); + List tInputs = new ArrayList<>(); - if (inputs != null && outputs != null) { + if (!inputs.isEmpty() && !outputs.isEmpty()) { - 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; + 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; + } + } + if (!find) { + tInputs.add(positionedStack.copy()); } } - if (!find) { - tInputs.add(positionedStack.copy()); - } - } - for (PositionedStack positionedStack : tInputs) { - ItemStack currentStack = positionedStack.items[0]; - ItemStack preferModItem = ItemUtils.getPreferModItem(positionedStack.items); + for (PositionedStack positionedStack : tInputs) { + ItemStack currentStack = positionedStack.items[0]; + ItemStack preferModItem = ItemUtils.getPreferModItem(positionedStack.items); - if (preferModItem != null) { - currentStack = preferModItem; - currentStack.stackSize = positionedStack.items[0].stackSize; - } - - for (ItemStack stack : positionedStack.items) { - if (Platform.isRecipePrioritized(stack) || ItemUtils.isPreferItems(stack, recipeProcessorId, identifier)) { - currentStack = stack.copy(); + if (preferModItem != null) { + currentStack = preferModItem; currentStack.stackSize = positionedStack.items[0].stackSize; - break; } - } - if (ItemUtils.isInBlackList(currentStack, recipeProcessorId, identifier)) { - continue; + + for (ItemStack stack : positionedStack.items) { + if (Platform.isRecipePrioritized(stack) || ItemUtils.isPreferItems(stack, recipeProcessorId, identifier)) { + currentStack = stack.copy(); + currentStack.stackSize = positionedStack.items[0].stackSize; + break; + } + } + if (ItemUtils.isInBlackList(currentStack, recipeProcessorId, identifier)) { + continue; + } + + //Fix ItemStack with wrong meta + if (currentStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) { + currentStack.setItemDamage(0); + } + + recipeInputs.setTag("#" + inputIndex, currentStack.writeToNBT(new NBTTagCompound())); + NEECraftingHandler.ingredients.put("input" + inputIndex, positionedStack); + inputIndex++; } - //Fix ItemStack with wrong meta - if (currentStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) { - currentStack.setItemDamage(0); + for (PositionedStack positionedStack : outputs) { + if (outputIndex >= 4 || positionedStack == null || positionedStack.item == null) { + continue; + } + + ItemStack outputStack = positionedStack.item.copy(); + //Fix ItemStack with wrong meta(maybe ?) + if (outputStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) { + outputStack.setItemDamage(0); + } + + recipeOutputs.setTag(OUTPUT_KEY + outputIndex, outputStack.writeToNBT(new NBTTagCompound())); + outputIndex++; } - - recipeInputs.setTag("#" + inputIndex, currentStack.writeToNBT(new NBTTagCompound())); - NEECraftingHandler.ingredients.put("input" + inputIndex, positionedStack); - inputIndex++; - } - - for (PositionedStack positionedStack : outputs) { - if (outputIndex >= 4 || positionedStack == null || positionedStack.item == null) { - continue; - } - - ItemStack outputStack = positionedStack.item.copy(); - //Fix ItemStack with wrong meta(maybe ?) - if (outputStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) { - outputStack.setItemDamage(0); - } - - recipeOutputs.setTag(OUTPUT_KEY + outputIndex, outputStack.writeToNBT(new NBTTagCompound())); - outputIndex++; + break; } } } diff --git a/src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHelper.java b/src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHelper.java index f8d89ff..7495187 100644 --- a/src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHelper.java +++ b/src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHelper.java @@ -213,7 +213,11 @@ public class NEECraftingHelper implements IOverlayHandler { isGtnhNei = false; } if (!isGtnhNei) { - overlayButtons = new ArrayList<>(Arrays.asList(guiRecipe.overlay1, guiRecipe.overlay2)); + 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.button.id >= OVERLAY_BUTTON_ID_START && event.button.id < OVERLAY_BUTTON_ID_START + overlayButtons.size()) { boolean isPatternTerm = guiRecipe.firstGui instanceof GuiPatternTerm || GuiUtils.isPatternTermExGui(guiRecipe.firstGui); diff --git a/src/main/java/com/github/vfyjxf/nee/processor/AvaritiaRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/AvaritiaRecipeProcessor.java index 47b253b..58baf85 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/AvaritiaRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/AvaritiaRecipeProcessor.java @@ -3,9 +3,11 @@ package com.github.vfyjxf.nee.processor; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.IRecipeHandler; +import javax.annotation.Nonnull; import java.util.*; public class AvaritiaRecipeProcessor implements IRecipeProcessor { + @Nonnull @Override public Set getAllOverlayIdentifier() { return new HashSet<>(Arrays.asList( @@ -13,30 +15,31 @@ public class AvaritiaRecipeProcessor implements IRecipeProcessor { )); } + @Nonnull @Override public String getRecipeProcessorId() { return "Avaritia"; } + @Nonnull @Override public List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - return new ArrayList<>(recipe.getIngredientStacks(recipeIndex)); - } + List recipeInputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex)); + return recipeInputs; } - return null; + return recipeInputs; } + @Nonnull @Override public List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - List recipeOutput = new ArrayList<>(); - recipeOutput.add(recipe.getResultStack(recipeIndex)); - return recipeOutput; - } + List recipeOutput = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeOutput.add(recipe.getResultStack(recipeIndex)); + return recipeOutput; } - return null; + return recipeOutput; } } diff --git a/src/main/java/com/github/vfyjxf/nee/processor/BloodMagicRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/BloodMagicRecipeProcessor.java index 31ff2b6..33c52f5 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/BloodMagicRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/BloodMagicRecipeProcessor.java @@ -3,12 +3,14 @@ package com.github.vfyjxf.nee.processor; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.IRecipeHandler; +import javax.annotation.Nonnull; import java.util.*; /** * @author vfyjxf */ public class BloodMagicRecipeProcessor implements IRecipeProcessor { + @Nonnull @Override public Set getAllOverlayIdentifier() { return new HashSet<>(Arrays.asList( @@ -19,30 +21,31 @@ public class BloodMagicRecipeProcessor implements IRecipeProcessor { )); } + @Nonnull @Override public String getRecipeProcessorId() { return "BloodMagic"; } + @Nonnull @Override public List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - return new ArrayList<>(recipe.getIngredientStacks(recipeIndex)); - } + List recipeInputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex)); + return recipeInputs; } - return null; + return recipeInputs; } + @Nonnull @Override public List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - List recipeOutputs = new ArrayList<>(); - recipeOutputs.add(recipe.getResultStack(recipeIndex)); - return recipeOutputs; - } + List recipeOutputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeOutputs.add(recipe.getResultStack(recipeIndex)); + return recipeOutputs; } - return null; + return recipeOutputs; } } diff --git a/src/main/java/com/github/vfyjxf/nee/processor/BuildCraftRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/BuildCraftRecipeProcessor.java index ff749e6..74a622b 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/BuildCraftRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/BuildCraftRecipeProcessor.java @@ -5,6 +5,8 @@ import buildcraft.compat.nei.RecipeHandlerIntegrationTable; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.IRecipeHandler; +import javax.annotation.Nonnull; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -13,11 +15,13 @@ import java.util.List; */ public class BuildCraftRecipeProcessor implements IRecipeProcessor { + @Nonnull @Override public String getRecipeProcessorId() { return "BuildCraft"; } + @Nonnull @Override public List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { if (recipe instanceof RecipeHandlerAssemblyTable) { @@ -25,9 +29,10 @@ public class BuildCraftRecipeProcessor implements IRecipeProcessor { } else if (recipe instanceof RecipeHandlerIntegrationTable) { return handlerIntegrationTableRecipe((RecipeHandlerIntegrationTable) recipe, recipeIndex, true); } - return null; + return new ArrayList<>(); } + @Nonnull @Override public List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { if (recipe instanceof RecipeHandlerAssemblyTable) { @@ -35,7 +40,7 @@ public class BuildCraftRecipeProcessor implements IRecipeProcessor { } else if (recipe instanceof RecipeHandlerIntegrationTable) { return handlerIntegrationTableRecipe((RecipeHandlerIntegrationTable) recipe, recipeIndex, false); } - return null; + return new ArrayList<>(); } private List handlerAssemblyTableRecipe(RecipeHandlerAssemblyTable recipe, int recipeIndex, boolean getInput) { diff --git a/src/main/java/com/github/vfyjxf/nee/processor/EnderIORecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/EnderIORecipeProcessor.java index 744e150..9fa5cea 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/EnderIORecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/EnderIORecipeProcessor.java @@ -4,9 +4,11 @@ import codechicken.nei.PositionedStack; import codechicken.nei.recipe.IRecipeHandler; import crazypants.enderio.nei.SagMillRecipeHandler; +import javax.annotation.Nonnull; import java.util.*; public class EnderIORecipeProcessor implements IRecipeProcessor { + @Nonnull @Override public Set getAllOverlayIdentifier() { return new HashSet<>(Arrays.asList( @@ -15,38 +17,40 @@ public class EnderIORecipeProcessor implements IRecipeProcessor { )); } + @Nonnull @Override public String getRecipeProcessorId() { return "EnderIO"; } + @Nonnull @Override public List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - return new ArrayList<>(recipe.getIngredientStacks(recipeIndex)); - } - } - return null; + List recipeInputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex)); + return recipeInputs; + } + return recipeInputs; } + @Nonnull @Override public List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { - if(identifier!=null) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - List recipeOutputs = new ArrayList<>(); - recipeOutputs.add(recipe.getResultStack(recipeIndex)); - recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex)); - //remove output if it's chance != 1 - if(recipe instanceof SagMillRecipeHandler){ - SagMillRecipeHandler.MillRecipe millRecipe = (SagMillRecipeHandler.MillRecipe) ((SagMillRecipeHandler) recipe).arecipes.get(recipeIndex); - recipeOutputs.removeIf(positionedStack -> millRecipe.getChanceForOutput(positionedStack.item) != 1.0F); - } - return recipeOutputs; + List recipeOutputs = new ArrayList<>(); + if (identifier != null) { + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeOutputs.add(recipe.getResultStack(recipeIndex)); + recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex)); + //remove output if it's chance != 1 + if (recipe instanceof SagMillRecipeHandler) { + SagMillRecipeHandler.MillRecipe millRecipe = (SagMillRecipeHandler.MillRecipe) ((SagMillRecipeHandler) recipe).arecipes.get(recipeIndex); + recipeOutputs.removeIf(positionedStack -> millRecipe.getChanceForOutput(positionedStack.item) != 1.0F); } + return recipeOutputs; } } - return null; + + return recipeOutputs; } } diff --git a/src/main/java/com/github/vfyjxf/nee/processor/ForestryRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/ForestryRecipeProcessor.java index e016912..f239439 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/ForestryRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/ForestryRecipeProcessor.java @@ -4,17 +4,20 @@ import codechicken.nei.PositionedStack; import codechicken.nei.recipe.IRecipeHandler; import forestry.factory.recipes.nei.*; +import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class ForestryRecipeProcessor implements IRecipeProcessor { + @Nonnull @Override public String getRecipeProcessorId() { return "Forestry"; } + @Nonnull @Override public List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { if (recipe instanceof NEIHandlerBottler) { @@ -42,9 +45,10 @@ public class ForestryRecipeProcessor implements IRecipeProcessor { return squeezerHandler((NEIHandlerSqueezer) recipe, recipeIndex, true); } - return null; + return new ArrayList<>(); } + @Nonnull @Override public List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { if (recipe instanceof NEIHandlerBottler) { @@ -72,7 +76,7 @@ public class ForestryRecipeProcessor implements IRecipeProcessor { return squeezerHandler((NEIHandlerSqueezer) recipe, recipeIndex, false); } - return null; + return new ArrayList<>(); } private List bottlerHandler(NEIHandlerBottler base, int recipeIndex, boolean getInput) { @@ -93,7 +97,7 @@ public class ForestryRecipeProcessor implements IRecipeProcessor { return getInput ? recipeInput : Collections.singletonList(base.getResultStack(recipeIndex)); } - //Fermenter doesn't support, because it doesn't has a item output + //Fermenter doesn't support, because it doesn't have an item output private List moistenerHandler(NEIHandlerMoistener base, int recipeIndex, boolean getInput) { List recipeInput = new ArrayList<>(base.getIngredientStacks(recipeIndex)); diff --git a/src/main/java/com/github/vfyjxf/nee/processor/GTPPRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/GTPPRecipeProcessor.java index b4dda8b..dc86b0e 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/GTPPRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/GTPPRecipeProcessor.java @@ -4,12 +4,14 @@ import codechicken.nei.PositionedStack; import codechicken.nei.recipe.IRecipeHandler; import gregtech.api.util.GTPP_Recipe; +import javax.annotation.Nonnull; import java.util.*; /** * @author vfyjxf */ public class GTPPRecipeProcessor implements IRecipeProcessor { + @Nonnull @Override public Set getAllOverlayIdentifier() { HashSet identifiers = new HashSet<>(Collections.singletonList("GTPP_Decayables")); @@ -23,32 +25,33 @@ public class GTPPRecipeProcessor implements IRecipeProcessor { return identifiers; } + @Nonnull @Override public String getRecipeProcessorId() { return "GT++"; } + @Nonnull @Override public List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - List recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex)); - recipeInputs.removeIf(positionedStack -> GregTech5RecipeProcessor.getFluidFromDisplayStack(positionedStack.items[0]) != null || positionedStack.item.stackSize == 0); - return recipeInputs; - } + List recipeInputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex)); + recipeInputs.removeIf(positionedStack -> GregTech5RecipeProcessor.getFluidFromDisplayStack(positionedStack.items[0]) != null || positionedStack.item.stackSize == 0); + return recipeInputs; } - return null; + return recipeInputs; } + @Nonnull @Override public List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - List recipeOutputs = new ArrayList<>(recipe.getOtherStacks(recipeIndex)); - recipeOutputs.removeIf(positionedStack -> GregTech5RecipeProcessor.getFluidFromDisplayStack(positionedStack.items[0]) != null); - return recipeOutputs; - } + List recipeOutputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex)); + recipeOutputs.removeIf(positionedStack -> GregTech5RecipeProcessor.getFluidFromDisplayStack(positionedStack.items[0]) != null); + return recipeOutputs; } - return null; + return recipeOutputs; } } diff --git a/src/main/java/com/github/vfyjxf/nee/processor/GregTech5RecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/GregTech5RecipeProcessor.java index 282c042..27c7999 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/GregTech5RecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/GregTech5RecipeProcessor.java @@ -10,6 +10,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -35,6 +36,7 @@ public class GregTech5RecipeProcessor implements IRecipeProcessor { gtAssLineClz = gtAL; } + @Nonnull @Override public Set getAllOverlayIdentifier() { @@ -48,16 +50,18 @@ public class GregTech5RecipeProcessor implements IRecipeProcessor { return identifiers; } + @Nonnull @Override public String getRecipeProcessorId() { return "GregTech5"; } + @Nonnull @Override public List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { - + List recipeInputs = new ArrayList<>(); if (gtDefaultClz.isInstance(recipe) || gtAssLineClz.isInstance(recipe)) { - List recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex)); + recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex)); recipeInputs.removeIf(positionedStack -> getFluidFromDisplayStack(positionedStack.items[0]) != null || positionedStack.item.stackSize == 0); if (!recipeInputs.isEmpty()) { ItemStack specialItem = recipeInputs.get(recipeInputs.size() - 1).items[0]; @@ -66,20 +70,22 @@ public class GregTech5RecipeProcessor implements IRecipeProcessor { } return recipeInputs; } - return null; + return recipeInputs; } + @Nonnull @Override public List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { + List recipeOutputs = new ArrayList<>(); if (gtDefaultClz.isInstance(recipe) || gtAssLineClz.isInstance(recipe)) { - List recipeOutputs = new ArrayList<>(recipe.getOtherStacks(recipeIndex)); + recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex)); recipeOutputs.removeIf(positionedStack -> getFluidFromDisplayStack(positionedStack.items[0]) != null); //remove output if it's chance != 10000 recipeOutputs.removeIf(stack -> stack instanceof FixedPositionedStack && !(((FixedPositionedStack) stack).mChance == 10000 || ((FixedPositionedStack) stack).mChance <= 0)); return recipeOutputs; } - return null; + return recipeOutputs; } /** @@ -95,6 +101,7 @@ public class GregTech5RecipeProcessor implements IRecipeProcessor { Fluid tFluid = FluidRegistry.getFluid(ItemList.Display_Fluid.getItem().getDamage(aDisplayStack)); return new FluidStack(tFluid, (int) aDisplayStack.getTagCompound().getLong("mFluidDisplayAmount")); } + public static boolean isStackValid(Object aStack) { return (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null && ((ItemStack) aStack).stackSize >= 0; } diff --git a/src/main/java/com/github/vfyjxf/nee/processor/GregTech6RecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/GregTech6RecipeProcessor.java index afc2d71..9e6f52e 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/GregTech6RecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/GregTech6RecipeProcessor.java @@ -9,6 +9,7 @@ import gregapi.data.FL; import gregapi.recipes.Recipe; import net.minecraft.item.ItemStack; +import javax.annotation.Nonnull; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashSet; @@ -19,6 +20,7 @@ import java.util.Set; * @author vfyjxf */ public class GregTech6RecipeProcessor implements IRecipeProcessor { + @Nonnull @Override public Set getAllOverlayIdentifier() { Set identifiers = new HashSet<>(); @@ -30,54 +32,55 @@ public class GregTech6RecipeProcessor implements IRecipeProcessor { return identifiers; } + @Nonnull @Override public String getRecipeProcessorId() { return "GregTech6"; } + @Nonnull @Override public List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - List recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex)); - //remove fluid - recipeInputs.removeIf(positionedStack -> FL.getFluid(positionedStack.item, true) != null || positionedStack.item.stackSize == 0); - //try to remove machine - if (recipe instanceof NEI_RecipeMap) { - Field mRecipeMapField = ReflectionHelper.findField(NEI_RecipeMap.class, "mRecipeMap"); - Recipe.RecipeMap mRecipeMap = null; - try { - mRecipeMap = (Recipe.RecipeMap) mRecipeMapField.get(recipe); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - if (mRecipeMap != null) { - ItemStack lastItem = (recipeInputs.get(recipeInputs.size() - 1)).items[0]; - for (ItemStack stack : mRecipeMap.mRecipeMachineList) { - if (ItemStack.areItemStackTagsEqual(lastItem, stack)) { - recipeInputs.remove(recipeInputs.size() - 1); - break; - } + List recipeInputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex)); + //remove fluid + recipeInputs.removeIf(positionedStack -> FL.getFluid(positionedStack.item, true) != null || positionedStack.item.stackSize == 0); + //try to remove machine + if (recipe instanceof NEI_RecipeMap) { + Field mRecipeMapField = ReflectionHelper.findField(NEI_RecipeMap.class, "mRecipeMap"); + Recipe.RecipeMap mRecipeMap = null; + try { + mRecipeMap = (Recipe.RecipeMap) mRecipeMapField.get(recipe); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + if (mRecipeMap != null) { + ItemStack lastItem = (recipeInputs.get(recipeInputs.size() - 1)).items[0]; + for (ItemStack stack : mRecipeMap.mRecipeMachineList) { + if (ItemStack.areItemStackTagsEqual(lastItem, stack)) { + recipeInputs.remove(recipeInputs.size() - 1); + break; } } } - return recipeInputs; } + return recipeInputs; } - return null; + return recipeInputs; } + @Nonnull @Override public List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - List recipeOutput = new ArrayList<>(recipe.getOtherStacks(recipeIndex)); - recipeOutput.removeIf(positionedStack -> FL.getFluid(positionedStack.item, true) != null || positionedStack.item.stackSize == 0); - //try to remove item output if it's chance != 100% - recipeOutput.removeIf(positionedStack -> positionedStack instanceof FixedPositionedStack && ((FixedPositionedStack) positionedStack).mChance > 0 && ((FixedPositionedStack) positionedStack).mChance != ((FixedPositionedStack) positionedStack).mMaxChance); - return recipeOutput; - } + List recipeOutput = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeOutput.addAll(recipe.getOtherStacks(recipeIndex)); + recipeOutput.removeIf(positionedStack -> FL.getFluid(positionedStack.item, true) != null || positionedStack.item.stackSize == 0); + //try to remove item output if it's chance != 100% + recipeOutput.removeIf(positionedStack -> positionedStack instanceof FixedPositionedStack && ((FixedPositionedStack) positionedStack).mChance > 0 && ((FixedPositionedStack) positionedStack).mChance != ((FixedPositionedStack) positionedStack).mMaxChance); + return recipeOutput; } - return null; + return recipeOutput; } } diff --git a/src/main/java/com/github/vfyjxf/nee/processor/ICRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/ICRecipeProcessor.java index b5f5976..07c82a0 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/ICRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/ICRecipeProcessor.java @@ -3,12 +3,14 @@ package com.github.vfyjxf.nee.processor; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.IRecipeHandler; +import javax.annotation.Nonnull; import java.util.*; /** * @author vfyjxf */ public class ICRecipeProcessor implements IRecipeProcessor { + @Nonnull @Override public Set getAllOverlayIdentifier() { return new HashSet<>(Arrays.asList( @@ -18,32 +20,33 @@ public class ICRecipeProcessor implements IRecipeProcessor { )); } + @Nonnull @Override public String getRecipeProcessorId() { return "IC2"; } + @Nonnull @Override public List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - return new ArrayList<>(recipe.getIngredientStacks(recipeIndex)); - } + List recipeInputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex)); + return recipeInputs; } - return null; + return recipeInputs; } + @Nonnull @Override public List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - List recipeOutputs = new ArrayList<>(); - recipeOutputs.add(recipe.getResultStack(recipeIndex)); - recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex)); - return recipeOutputs; - } + List recipeOutputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeOutputs.add(recipe.getResultStack(recipeIndex)); + recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex)); + return recipeOutputs; } - return null; + return recipeOutputs; } diff --git a/src/main/java/com/github/vfyjxf/nee/processor/IRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/IRecipeProcessor.java index 74ae4fe..76ada52 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/IRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/IRecipeProcessor.java @@ -3,6 +3,7 @@ package com.github.vfyjxf.nee.processor; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.IRecipeHandler; +import javax.annotation.Nonnull; import java.util.Collections; import java.util.List; import java.util.Set; @@ -12,15 +13,18 @@ import java.util.Set; */ public interface IRecipeProcessor { - + @Nonnull default Set getAllOverlayIdentifier(){ return Collections.emptySet(); } + @Nonnull String getRecipeProcessorId(); + @Nonnull List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier); + @Nonnull List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier); } diff --git a/src/main/java/com/github/vfyjxf/nee/processor/ImmersiveEngineeringRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/ImmersiveEngineeringRecipeProcessor.java index 1be0c5c..4dff9d4 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/ImmersiveEngineeringRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/ImmersiveEngineeringRecipeProcessor.java @@ -3,12 +3,14 @@ package com.github.vfyjxf.nee.processor; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.IRecipeHandler; +import javax.annotation.Nonnull; import java.util.*; /** * @author vfyjxf */ public class ImmersiveEngineeringRecipeProcessor implements IRecipeProcessor { + @Nonnull @Override public Set getAllOverlayIdentifier() { return new HashSet<>(Arrays.asList( @@ -19,37 +21,37 @@ public class ImmersiveEngineeringRecipeProcessor implements IRecipeProcessor { )); } + @Nonnull @Override public String getRecipeProcessorId() { return "ImmersiveEngineering"; } + @Nonnull @Override public List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - List recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex)); - if (!("ieArcFurnace".equals(identifier) || "ieCrusher".equals(identifier) || "ieBlastFurnace".equals(identifier))) { - recipeInputs.addAll(recipe.getOtherStacks(recipeIndex)); - } - return recipeInputs; + List recipeInputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex)); + if (!("ieArcFurnace".equals(identifier) || "ieCrusher".equals(identifier) || "ieBlastFurnace".equals(identifier))) { + recipeInputs.addAll(recipe.getOtherStacks(recipeIndex)); } + return recipeInputs; } - return null; + return recipeInputs; } + @Nonnull @Override public List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - List recipeOutputs = new ArrayList<>(); - recipeOutputs.add(recipe.getResultStack(recipeIndex)); - if ("ieArcFurnace".equals(identifier) || "ieCrusher".equals(identifier)) { - recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex)); - } - return recipeOutputs; + List recipeOutputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeOutputs.add(recipe.getResultStack(recipeIndex)); + if ("ieArcFurnace".equals(identifier) || "ieCrusher".equals(identifier)) { + recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex)); } + return recipeOutputs; } - return null; + return recipeOutputs; } } diff --git a/src/main/java/com/github/vfyjxf/nee/processor/MekanismRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/MekanismRecipeProcessor.java index cc2e2ac..6d71c2f 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/MekanismRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/MekanismRecipeProcessor.java @@ -3,12 +3,14 @@ package com.github.vfyjxf.nee.processor; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.IRecipeHandler; +import javax.annotation.Nonnull; import java.util.*; /** * @author vfyjxf */ public class MekanismRecipeProcessor implements IRecipeProcessor { + @Nonnull @Override public Set getAllOverlayIdentifier() { return new HashSet<>(Arrays.asList( @@ -19,34 +21,34 @@ public class MekanismRecipeProcessor implements IRecipeProcessor { )); } + @Nonnull @Override public String getRecipeProcessorId() { return "Mekanism"; } + @Nonnull @Override public List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - List recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex)); - if (!recipe.getOtherStacks(recipeIndex).isEmpty()) { - recipeInputs.addAll(recipe.getOtherStacks(recipeIndex)); - } - return recipeInputs; + List recipeInputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex)); + if (!recipe.getOtherStacks(recipeIndex).isEmpty()) { + recipeInputs.addAll(recipe.getOtherStacks(recipeIndex)); } + return recipeInputs; } - return null; + return recipeInputs; } + @Nonnull @Override public List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - List recipeOutputs = new ArrayList<>(); - recipeOutputs.add(recipe.getResultStack(recipeIndex)); - return recipeOutputs; - } + List recipeOutputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeOutputs.add(recipe.getResultStack(recipeIndex)); + return recipeOutputs; } - return null; + return recipeOutputs; } } diff --git a/src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java index 3919b03..3eef5ca 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java @@ -46,23 +46,23 @@ public class RecipeProcessor { NotEnoughEnergistics.logger.info("Found ThermalExpansion, install ThermalExpansion support"); recipeProcessors.add(new ThermalExpansionRecipeProcessor()); } - if(Loader.isModLoaded("ImmersiveEngineering")){ + if (Loader.isModLoaded("ImmersiveEngineering")) { NotEnoughEnergistics.logger.info("Found ImmersiveEngineering, install ImmersiveEngineering support"); recipeProcessors.add(new ImmersiveEngineeringRecipeProcessor()); } - if(Loader.isModLoaded("Mekanism")){ + if (Loader.isModLoaded("Mekanism")) { NotEnoughEnergistics.logger.info("Found Mekanism, install Mekanism support"); recipeProcessors.add(new MekanismRecipeProcessor()); } - if(Loader.isModLoaded("AWWayofTime")){ + if (Loader.isModLoaded("AWWayofTime")) { NotEnoughEnergistics.logger.info("Found BloodMagic, install BloodMagic support"); recipeProcessors.add(new BloodMagicRecipeProcessor()); } - if(Loader.isModLoaded("BuildCraft|Compat")){ + if (Loader.isModLoaded("BuildCraft|Compat")) { NotEnoughEnergistics.logger.info("Found BuildCraft-Compat, install BuildCraft-Compat support"); recipeProcessors.add(new BuildCraftRecipeProcessor()); } - if(Loader.isModLoaded("miscutils")){ + if (Loader.isModLoaded("miscutils")) { NotEnoughEnergistics.logger.info("Found GT++, install GT++ support"); recipeProcessors.add(new GTPPRecipeProcessor()); } diff --git a/src/main/java/com/github/vfyjxf/nee/processor/TCNEIPluginRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/TCNEIPluginRecipeProcessor.java index 3c40681..3d885ca 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/TCNEIPluginRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/TCNEIPluginRecipeProcessor.java @@ -4,47 +4,49 @@ import codechicken.nei.PositionedStack; import codechicken.nei.recipe.IRecipeHandler; import com.djgiannuzz.thaumcraftneiplugin.items.ItemAspect; +import javax.annotation.Nonnull; import java.util.*; /** * @author vfyjxf */ -public class TCNEIPluginRecipeProcessor implements IRecipeProcessor{ +public class TCNEIPluginRecipeProcessor implements IRecipeProcessor { + @Nonnull @Override public Set getAllOverlayIdentifier() { return new HashSet<>(Arrays.asList( - "arcaneshapedrecipes","arcaneshapelessrecipes","aspectsRecipe", - "cruciblerecipe","infusionCrafting" + "arcaneshapedrecipes", "arcaneshapelessrecipes", "aspectsRecipe", + "cruciblerecipe", "infusionCrafting" )); } + @Nonnull @Override public String getRecipeProcessorId() { return "TCNEIPlugin"; } + @Nonnull @Override public List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for(String ident : getAllOverlayIdentifier()){ - if(ident.equals(identifier)){ - List recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex)); - recipeInputs.removeIf(positionedStack -> positionedStack.item.getItem() instanceof ItemAspect); - return recipeInputs; - } + List recipeInputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex)); + recipeInputs.removeIf(positionedStack -> positionedStack.item.getItem() instanceof ItemAspect); + return recipeInputs; } - return null; + return recipeInputs; } + @Nonnull @Override public List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for(String ident : getAllOverlayIdentifier()){ - if(ident.equals(identifier)){ - List recipeOutputs = new ArrayList<>(); - recipeOutputs.add(recipe.getResultStack(recipeIndex)); - return recipeOutputs; - } + List recipeOutputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeOutputs.add(recipe.getResultStack(recipeIndex)); + return recipeOutputs; } - return null; + return recipeOutputs; } } diff --git a/src/main/java/com/github/vfyjxf/nee/processor/ThermalExpansionRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/ThermalExpansionRecipeProcessor.java index c4be80b..3c8da76 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/ThermalExpansionRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/ThermalExpansionRecipeProcessor.java @@ -5,11 +5,14 @@ import codechicken.nei.recipe.IRecipeHandler; import cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase; import cpw.mods.fml.relauncher.ReflectionHelper; +import javax.annotation.Nonnull; import java.lang.reflect.Field; import java.util.*; public class ThermalExpansionRecipeProcessor implements IRecipeProcessor { + + @Nonnull @Override public Set getAllOverlayIdentifier() { return new HashSet<>(Arrays.asList( @@ -18,75 +21,75 @@ public class ThermalExpansionRecipeProcessor implements IRecipeProcessor { )); } + @Nonnull @Override public String getRecipeProcessorId() { return "ThermalExpansion"; } + @Nonnull @Override public List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - List recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex)); - if (recipe instanceof RecipeHandlerBase) { - Class NEIRecipeBase = null; + List recipeInputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex)); + if (recipe instanceof RecipeHandlerBase) { + Class NEIRecipeBase = null; + try { + NEIRecipeBase = Class.forName("cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase$NEIRecipeBase"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + if (NEIRecipeBase != null) { + Field secondaryInputField = ReflectionHelper.findField(NEIRecipeBase, "secondaryInput"); + PositionedStack secondaryInput = null; try { - NEIRecipeBase = Class.forName("cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase$NEIRecipeBase"); - } catch (ClassNotFoundException e) { + secondaryInput = (PositionedStack) secondaryInputField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex)); + } catch (IllegalAccessException e) { e.printStackTrace(); } - if (NEIRecipeBase != null) { - Field secondaryInputField = ReflectionHelper.findField(NEIRecipeBase, "secondaryInput"); - PositionedStack secondaryInput = null; - try { - secondaryInput = (PositionedStack) secondaryInputField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex)); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - if (secondaryInput != null) { - recipeInputs.add(secondaryInput); - } + if (secondaryInput != null) { + recipeInputs.add(secondaryInput); } } - return recipeInputs; } + return recipeInputs; } - return null; + return recipeInputs; } + @Nonnull @Override public List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { - for (String ident : getAllOverlayIdentifier()) { - if (ident.equals(identifier)) { - List recipeOutputs = new ArrayList<>(); - recipeOutputs.add(recipe.getResultStack(recipeIndex)); - if (recipe instanceof RecipeHandlerBase) { - Class NEIRecipeBase = null; + List recipeOutputs = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { + recipeOutputs.add(recipe.getResultStack(recipeIndex)); + if (recipe instanceof RecipeHandlerBase) { + Class NEIRecipeBase = null; + try { + NEIRecipeBase = Class.forName("cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase$NEIRecipeBase"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + if (NEIRecipeBase != null) { + Field secondaryOutputField = ReflectionHelper.findField(NEIRecipeBase, "secondaryOutput"); + Field secondaryOutputChanceField = ReflectionHelper.findField(NEIRecipeBase, "secondaryOutputChance"); + PositionedStack secondaryOutput = null; + int secondaryOutputChance = 0; try { - NEIRecipeBase = Class.forName("cofh.thermalexpansion.plugins.nei.handlers.RecipeHandlerBase$NEIRecipeBase"); - } catch (ClassNotFoundException e) { + secondaryOutput = (PositionedStack) secondaryOutputField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex)); + secondaryOutputChance = (int) secondaryOutputChanceField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex)); + } catch (IllegalAccessException e) { e.printStackTrace(); } - if (NEIRecipeBase != null) { - Field secondaryOutputField = ReflectionHelper.findField(NEIRecipeBase, "secondaryOutput"); - Field secondaryOutputChanceField = ReflectionHelper.findField(NEIRecipeBase, "secondaryOutputChance"); - PositionedStack secondaryOutput = null; - int secondaryOutputChance = 0; - try { - secondaryOutput = (PositionedStack) secondaryOutputField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex)); - secondaryOutputChance = (int) secondaryOutputChanceField.get(((RecipeHandlerBase) recipe).arecipes.get(recipeIndex)); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - if (secondaryOutput != null && secondaryOutputChance >= 100) { - recipeOutputs.add(secondaryOutput); - } + if (secondaryOutput != null && secondaryOutputChance >= 100) { + recipeOutputs.add(secondaryOutput); } } - return recipeOutputs; } + return recipeOutputs; } - return null; + return recipeOutputs; } } diff --git a/src/main/java/com/github/vfyjxf/nee/processor/VanillaRecipeProcessor.java b/src/main/java/com/github/vfyjxf/nee/processor/VanillaRecipeProcessor.java index 4c1c75b..5b60afb 100644 --- a/src/main/java/com/github/vfyjxf/nee/processor/VanillaRecipeProcessor.java +++ b/src/main/java/com/github/vfyjxf/nee/processor/VanillaRecipeProcessor.java @@ -3,40 +3,45 @@ package com.github.vfyjxf.nee.processor; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.IRecipeHandler; +import javax.annotation.Nonnull; import java.util.*; /** * @author vfyjxf */ public class VanillaRecipeProcessor implements IRecipeProcessor { + @Nonnull @Override public Set getAllOverlayIdentifier() { return new HashSet<>(Arrays.asList("brewing", "smelting", "fuel")); } + @Nonnull @Override public String getRecipeProcessorId() { return "Vanilla"; } + @Nonnull @Override public List getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) { List recipeInputs = new ArrayList<>(); - if ("brewing".equals(identifier) || "smelting".equals(identifier) || "fuel".equals(identifier)) { + if (this.getAllOverlayIdentifier().contains(identifier)) { recipeInputs.addAll(recipe.getIngredientStacks(recipeIndex)); recipeInputs.addAll(recipe.getOtherStacks(recipeIndex)); } return recipeInputs; } + @Nonnull @Override public List getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) { - if ("brewing".equals(identifier) || "smelting".equals(identifier) || "fuel".equals(identifier)) { - List recipeOutput = new ArrayList<>(); + List recipeOutput = new ArrayList<>(); + if (this.getAllOverlayIdentifier().contains(identifier)) { recipeOutput.add(recipe.getResultStack(recipeIndex)); return recipeOutput; } - return null; + return recipeOutput; } } diff --git a/src/main/java/com/github/vfyjxf/nee/utils/GuiUtils.java b/src/main/java/com/github/vfyjxf/nee/utils/GuiUtils.java index b815e99..0474d0f 100644 --- a/src/main/java/com/github/vfyjxf/nee/utils/GuiUtils.java +++ b/src/main/java/com/github/vfyjxf/nee/utils/GuiUtils.java @@ -1,39 +1,19 @@ package com.github.vfyjxf.nee.utils; -import appeng.client.gui.AEBaseGui; import appeng.container.implementations.ContainerPatternTerm; import appeng.helpers.IContainerCraftingPacket; -import cpw.mods.fml.relauncher.ReflectionHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - /** * @author vfyjxf */ public class GuiUtils { - public static Slot getSlotUnderMouse(GuiContainer guiContainer, int mouseX, int mouseY) { - - if (guiContainer instanceof AEBaseGui) { - Method getSlotMethod = ReflectionHelper.findMethod(AEBaseGui.class, (AEBaseGui) guiContainer, new String[]{"getSlot"}, int.class, int.class); - try { - return (Slot) getSlotMethod.invoke(guiContainer, mouseX, mouseY); - } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - } - } - - return null; - } - public static boolean isPatternTermExGui(GuiScreen container) { try { Class patternTermExClz = Class.forName("appeng.client.gui.implementations.GuiPatternTermEx"); diff --git a/src/main/resources/META-INF/neenergistics_at.cfg b/src/main/resources/META-INF/neenergistics_at.cfg new file mode 100644 index 0000000..e228df5 --- /dev/null +++ b/src/main/resources/META-INF/neenergistics_at.cfg @@ -0,0 +1,4 @@ +public net.minecraft.client.gui.inventory.GuiContainer field_147003_i #guiLeft +public net.minecraft.client.gui.inventory.GuiContainer field_147009_r #guiTop +public net.minecraft.client.gui.inventory.GuiContainer func_146975_c(II)Lnet/minecraft/inventory/Slot; #getSlotAtPositionv +public net.minecraft.client.gui.GuiScreen func_146283_a(Ljava/util/List;II)V #drawHoveringText \ No newline at end of file diff --git a/src/main/resources/assets/neenergistics/lang/en_US.lang b/src/main/resources/assets/neenergistics/lang/en_US.lang index 6c9c9b8..eb69258 100644 --- a/src/main/resources/assets/neenergistics/lang/en_US.lang +++ b/src/main/resources/assets/neenergistics/lang/en_US.lang @@ -1,4 +1,5 @@ neenergistics.gui.tooltip.helper.crafting=click to request missing items +neenergistics.gui.tooltip.missing=Missing Items neenergistics.gui.tooltip.helper.pattern=Autocrafting available nei.options.keys.nee=NotEnoughEnergistics nei.options.keys.nee.count=Change Item Count diff --git a/src/main/resources/assets/neenergistics/lang/zh_CN.lang b/src/main/resources/assets/neenergistics/lang/zh_CN.lang index 3ce5867..1cd2a7e 100644 --- a/src/main/resources/assets/neenergistics/lang/zh_CN.lang +++ b/src/main/resources/assets/neenergistics/lang/zh_CN.lang @@ -1,4 +1,5 @@ neenergistics.gui.tooltip.helper.crafting=点击以请求缺失的物品 +neenergistics.gui.tooltip.missing=缺失物品 neenergistics.gui.tooltip.helper.pattern=自动合成已可用 nei.options.keys.nee=NotEnoughEnergistics nei.options.keys.nee.count=修改物品数量