diff --git a/README.md b/README.md index 61d4e08..64ae661 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,10 @@ This mod removes that functionality and allows the player to use NEI's transfer ## Features -- Automatically switch the mode of PatternTerminal +- Automatically switch the mode of PatternTerminal. - If an item is a probability output, then nee will not transfer it. -- Combine like stacks in processing patterns +- Combine like stacks in processing patterns. +- Support Processing Pattern Terminal(4 -> 16 mode). ## Compatible Modslist as followed: @@ -25,6 +26,8 @@ This mod removes that functionality and allows the player to use NEI's transfer - [x] Avaritia - [x] EnderIO - [x] Forestry(Doesn't support Fermenter and Still,because they don't have an item output) +- [x] Thaumcraft NEI Plugin +- [x] Thaumic Energistics(Allows you transform ArcaneRecipe from NEI, it requires Thaumcraft NEI Plugin) If you want other Mod support,see [RecipeProcessor](./src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java) and [Mod support Issue](https://github.com/vfyjxf/NotEnoughEnergistics/issues/1) diff --git a/READNE_CN.md b/READNE_CN.md index fa9a88d..59bea26 100644 --- a/READNE_CN.md +++ b/READNE_CN.md @@ -10,6 +10,7 @@ NotEnoughEnergistics 是[Just Enough Energistics](https://www.curseforge.com/min - 根据配方自动切换样板终端的模式 - 如果一个物品输出为概率输出,那么NEE不会将它写入样板终端 - 在处理模式中合并同类物品 +- 支持增广样板终端(4 -> 16模式) ## 当前支持的Mod列表: @@ -20,6 +21,8 @@ NotEnoughEnergistics 是[Just Enough Energistics](https://www.curseforge.com/min - [x] Avaritia - [x] EnderIO - [x] Forestry(不支持发酵机和蒸馏器,因为它们没有物品输出) +- [x] Thaumcraft NEI Plugin +- [x] Thaumic Energistics(允许你从NEI转移奥术合成台配方,需要Thaumcraft NEI Plugin) 如果你想要别的Mod的支持,请看[RecipeProcessor](./src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java) 或者[模组支持处理区](https://github.com/vfyjxf/NotEnoughEnergistics/issues/1) diff --git a/build.gradle b/build.gradle index eb8eab3..4a79878 100644 --- a/build.gradle +++ b/build.gradle @@ -6,6 +6,14 @@ buildscript { name = "github" url = "https://github.com/juanmuscaria/maven/raw/master" } + maven { + name = "gt" + url = "https://gregtech.overminddl1.com/" + } + maven { + name = "jitpack" + url = "https://jitpack.io" + } } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-1.4.4-SNAPSHOT' @@ -32,6 +40,10 @@ repositories { name 'chickenbones' url 'http://chickenbones.net/maven' } + maven { + name = "gt" + url = "http://gregtech.overminddl1.com/" + } flatDir { dirs 'libs' } @@ -43,6 +55,8 @@ dependencies { compile "codechicken:CodeChickenLib:1.7.10-1.1.3.138:dev" compile "codechicken:CodeChickenCore:1.7.10-1.0.7.+:dev" + runtime "thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev" + } processResources { diff --git a/gradle.properties b/gradle.properties index dabed7d..6e41bbc 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.1.1 +mod_version=1.1.2 forge_version=10.13.4.1614 mod_group=com.github.vfyjxf.neenergistics mod_id=neenergistics diff --git a/libs/Avaritia-1.19-deobf.jar b/libs/Avaritia-1.19-deobf.jar new file mode 100644 index 0000000..821db55 Binary files /dev/null and b/libs/Avaritia-1.19-deobf.jar differ diff --git a/libs/Baubles-1.7.10-1.0.1.11.jar b/libs/Baubles-1.7.10-1.0.1.11.jar new file mode 100644 index 0000000..6f05d62 Binary files /dev/null and b/libs/Baubles-1.7.10-1.0.1.11.jar differ diff --git a/libs/BetterCrashes-1.0.0-dev.jar b/libs/BetterCrashes-1.0.0-dev.jar new file mode 100644 index 0000000..e575138 Binary files /dev/null and b/libs/BetterCrashes-1.0.0-dev.jar differ diff --git a/libs/EnderCore-1.7.10-0.2.0.39_beta.jar b/libs/EnderCore-1.7.10-0.2.0.39_beta.jar new file mode 100644 index 0000000..1fdf703 Binary files /dev/null and b/libs/EnderCore-1.7.10-0.2.0.39_beta.jar differ diff --git a/libs/EnderIO-1.7.10-2.3.1.16_beta.32-dev.jar b/libs/EnderIO-1.7.10-2.3.1.16_beta.32-dev.jar new file mode 100644 index 0000000..53d80c6 Binary files /dev/null and b/libs/EnderIO-1.7.10-2.3.1.16_beta.32-dev.jar differ diff --git a/libs/EnderIO-1.7.10-2.3.1.16_beta.32-sources.jar b/libs/EnderIO-1.7.10-2.3.1.16_beta.32-sources.jar new file mode 100644 index 0000000..bbf2eb3 Binary files /dev/null and b/libs/EnderIO-1.7.10-2.3.1.16_beta.32-sources.jar differ diff --git a/libs/Grimoire-mc1.7.10-dev-3.2.7.jar b/libs/Grimoire-mc1.7.10-dev-3.2.7.jar new file mode 100644 index 0000000..943ab93 Binary files /dev/null and b/libs/Grimoire-mc1.7.10-dev-3.2.7.jar differ diff --git a/libs/JustEnoughCalculation-1.7.10-3.6.3.jar b/libs/JustEnoughCalculation-1.7.10-3.6.3.jar new file mode 100644 index 0000000..306b7d5 Binary files /dev/null and b/libs/JustEnoughCalculation-1.7.10-3.6.3.jar differ diff --git a/libs/StructureLib-1.0.8-deobf.jar b/libs/StructureLib-1.0.8-deobf.jar new file mode 100644 index 0000000..494f861 Binary files /dev/null and b/libs/StructureLib-1.0.8-deobf.jar differ diff --git a/libs/forestry_1.7.10-4.3.1.45-dev.jar b/libs/forestry_1.7.10-4.3.1.45-dev.jar new file mode 100644 index 0000000..173743a Binary files /dev/null and b/libs/forestry_1.7.10-4.3.1.45-dev.jar differ diff --git a/libs/forestry_1.7.10-4.3.1.45-sources.jar b/libs/forestry_1.7.10-4.3.1.45-sources.jar new file mode 100644 index 0000000..ffb7160 Binary files /dev/null and b/libs/forestry_1.7.10-4.3.1.45-sources.jar differ diff --git a/libs/gregtech-5.09.37.06-dev.jar b/libs/gregtech-5.09.37.06-dev.jar new file mode 100644 index 0000000..67af476 Binary files /dev/null and b/libs/gregtech-5.09.37.06-dev.jar differ diff --git a/libs/gregtech-5.09.37.06-sources.jar b/libs/gregtech-5.09.37.06-sources.jar new file mode 100644 index 0000000..10f01ae Binary files /dev/null and b/libs/gregtech-5.09.37.06-sources.jar differ diff --git a/libs/industrialcraft-2-2.2.790-experimental-dev.jar b/libs/industrialcraft-2-2.2.790-experimental-dev.jar new file mode 100644 index 0000000..f618195 Binary files /dev/null and b/libs/industrialcraft-2-2.2.790-experimental-dev.jar differ diff --git a/libs/thaumcraftneiplugin-1.7.10-1.7a.jar b/libs/thaumcraftneiplugin-1.7.10-1.7a.jar new file mode 100644 index 0000000..7086cc2 Binary files /dev/null and b/libs/thaumcraftneiplugin-1.7.10-1.7a.jar differ diff --git a/libs/thaumicenergistics-1.1.3.12-GTNH.jar b/libs/thaumicenergistics-1.1.3.12-GTNH.jar new file mode 100644 index 0000000..1388899 Binary files /dev/null and b/libs/thaumicenergistics-1.1.3.12-GTNH.jar differ diff --git a/src/main/java/com/github/vfyjxf/nee/NEINeeConfig.java b/src/main/java/com/github/vfyjxf/nee/NEINeeConfig.java index acc7f81..a9f81a6 100644 --- a/src/main/java/com/github/vfyjxf/nee/NEINeeConfig.java +++ b/src/main/java/com/github/vfyjxf/nee/NEINeeConfig.java @@ -7,6 +7,8 @@ import com.github.vfyjxf.nee.nei.NEECraftingHandler; import com.github.vfyjxf.nee.processor.IRecipeProcessor; import com.github.vfyjxf.nee.processor.RecipeProcessor; +import cpw.mods.fml.common.Loader; +import thaumicenergistics.client.gui.GuiKnowledgeInscriber; import java.util.*; @@ -18,32 +20,24 @@ public void loadConfig() { RecipeProcessor.init(); - Set defaultIdentifiers= new HashSet<>( - Arrays.asList("crafting", "crafting2x2","brewing","smelting","fuel",null) + Set defaultIdentifiers = new HashSet<>( + Arrays.asList("crafting", "crafting2x2", "brewing", "smelting", "fuel", null) ); Set identifiers = new HashSet<>(defaultIdentifiers); - for(IRecipeProcessor processor : RecipeProcessor.recipeProcessors){ + for (IRecipeProcessor processor : RecipeProcessor.recipeProcessors) { identifiers.addAll(processor.getAllOverlayIdentifier()); } - for(String ident : identifiers){ - API.registerGuiOverlay(GuiPatternTerm.class, ident); - API.registerGuiOverlayHandler(GuiPatternTerm.class, new NEECraftingHandler(), ident); + for (String ident : identifiers) { + API.registerGuiOverlay(GuiPatternTerm.class, ident); + API.registerGuiOverlayHandler(GuiPatternTerm.class, new NEECraftingHandler(), ident); } - try { - Class.forName("appeng.client.gui.implementations.GuiPatternTermEx"); - } catch (ClassNotFoundException e) { - return; - } + installPatternTerminalExSupport(identifiers); + + installThaumicEnergisticsSupport(); - identifiers.removeAll(defaultIdentifiers); - //PatternTermEx Support - for(String ident : identifiers){ - API.registerGuiOverlay(GuiPatternTermEx.class, ident); - API.registerGuiOverlayHandler(GuiPatternTermEx.class, new NEECraftingHandler(), ident); - } } @Override @@ -55,4 +49,36 @@ public String getName() { public String getVersion() { return NotEnoughEnergistics.VERSION; } + + private void installThaumicEnergisticsSupport() { + try { + Class.forName("thaumicenergistics.client.gui.GuiKnowledgeInscriber"); + } catch (ClassNotFoundException e) { + return; + } + if (Loader.isModLoaded("thaumcraftneiplugin")) { + NotEnoughEnergistics.logger.info("Install ThaumicEnergistics support"); + + API.registerGuiOverlay(GuiKnowledgeInscriber.class, "arcaneshapedrecipes"); + API.registerGuiOverlay(GuiKnowledgeInscriber.class, "arcaneshapelessrecipes"); + API.registerGuiOverlayHandler(GuiKnowledgeInscriber.class, new NEECraftingHandler(), "arcaneshapedrecipes"); + API.registerGuiOverlayHandler(GuiKnowledgeInscriber.class, new NEECraftingHandler(), "arcaneshapelessrecipes"); + + } + } + + private void installPatternTerminalExSupport(Set identifiers) { + try { + Class.forName("appeng.client.gui.implementations.GuiPatternTermEx"); + } catch (ClassNotFoundException e) { + return; + } + identifiers.remove("crafting"); + identifiers.remove( "crafting2x2"); + //PatternTermEx Support + for (String ident : identifiers) { + API.registerGuiOverlay(GuiPatternTermEx.class, ident); + API.registerGuiOverlayHandler(GuiPatternTermEx.class, new NEECraftingHandler(), ident); + } + } } 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 97cde55..5d124d0 100644 --- a/src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHandler.java +++ b/src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHandler.java @@ -8,6 +8,7 @@ import appeng.util.Platform; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.IRecipeHandler; +import com.github.vfyjxf.nee.network.packet.PacketArcaneRecipe; import com.github.vfyjxf.nee.network.packet.PacketNEIPatternRecipe; import com.github.vfyjxf.nee.processor.IRecipeProcessor; import com.github.vfyjxf.nee.processor.RecipeProcessor; @@ -29,8 +30,9 @@ public class NEECraftingHandler implements IOverlayHandler { public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift) { if (firstGui instanceof GuiPatternTerm || firstGui instanceof GuiPatternTermEx) { NEENetworkHandler.getInstance().sendToServer(packRecipe(recipe, recipeIndex)); + } else { + knowledgeInscriberHandler(firstGui, recipe, recipeIndex); } - } private PacketNEIPatternRecipe packRecipe(IRecipeHandler recipe, int recipeIndex) { @@ -84,7 +86,7 @@ private PacketNEIPatternRecipe packProcessRecipe(IRecipeHandler recipe, int reci } for (PositionedStack positionedStack : outputs) { - if (outputIndex >= 4 ||positionedStack == null || positionedStack.item == null) { + if (outputIndex >= 4 || positionedStack == null || positionedStack.item == null) { continue; } recipeOutputs.setTag(OUTPUT_KEY + outputIndex, positionedStack.item.writeToNBT(new NBTTagCompound())); @@ -117,6 +119,72 @@ private PacketNEIPatternRecipe packCraftingTableRecipe(IRecipeHandler recipe, in return new PacketNEIPatternRecipe(recipeInputs, null); } + private void knowledgeInscriberHandler(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex) { + Class knowledgeInscriberClz = null; + try { + knowledgeInscriberClz = Class.forName("thaumicenergistics.client.gui.GuiKnowledgeInscriber"); + } catch (ClassNotFoundException e) { + return; + } + if (knowledgeInscriberClz.isInstance(firstGui)) { + NEENetworkHandler.getInstance().sendToServer(packetArcaneRecipe(recipe, recipeIndex)); + } + } + + private PacketArcaneRecipe packetArcaneRecipe(IRecipeHandler recipe, int recipeIndex) { + final Class itemAspectClz; + Class iA = null; + try { + iA = Class.forName("com.djgiannuzz.thaumcraftneiplugin.items.ItemAspect"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + itemAspectClz = iA; + final NBTTagCompound recipeInputs = new NBTTagCompound(); + List ingredients = recipe.getIngredientStacks(recipeIndex); + ingredients.removeIf(positionedStack -> itemAspectClz.isInstance(positionedStack.item.getItem())); + + for (PositionedStack positionedStack : ingredients) { + + if (positionedStack.items != null && positionedStack.items.length > 0) { + int slotIndex = getSlotIndex(positionedStack.relx * 100 + positionedStack.rely); + final ItemStack[] currentStackList = positionedStack.items; + ItemStack stack = positionedStack.item; + for (ItemStack currentStack : currentStackList) { + if (Platform.isRecipePrioritized(currentStack)) { + stack = currentStack.copy(); + } + } + recipeInputs.setTag("#" + slotIndex, stack.writeToNBT(new NBTTagCompound())); + } + } + return new PacketArcaneRecipe(recipeInputs); + } + + private int getSlotIndex(int xy) { + switch (xy) { + case 7533: + return 1; + case 10333: + return 2; + case 4960: + return 3; + case 7660: + return 4; + case 10360: + return 5; + case 4987: + return 6; + case 7687: + return 7; + case 10387: + return 8; + case 4832: + default: + return 0; + } + } + private boolean isCraftingTableRecipe(IRecipeHandler recipe) { TemplateRecipeHandler templateRecipeHandler = (TemplateRecipeHandler) recipe; String overlayIdentifier = templateRecipeHandler.getOverlayIdentifier(); diff --git a/src/main/java/com/github/vfyjxf/nee/network/NEENetworkHandler.java b/src/main/java/com/github/vfyjxf/nee/network/NEENetworkHandler.java index 74db87d..84e195e 100644 --- a/src/main/java/com/github/vfyjxf/nee/network/NEENetworkHandler.java +++ b/src/main/java/com/github/vfyjxf/nee/network/NEENetworkHandler.java @@ -1,6 +1,7 @@ package com.github.vfyjxf.nee.network; import com.github.vfyjxf.nee.NotEnoughEnergistics; +import com.github.vfyjxf.nee.network.packet.PacketArcaneRecipe; import com.github.vfyjxf.nee.network.packet.PacketNEIPatternRecipe; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; @@ -15,6 +16,7 @@ public static SimpleNetworkWrapper getInstance(){ public static void init(){ INSTANCE.registerMessage(PacketNEIPatternRecipe.class, PacketNEIPatternRecipe.class,0, Side.SERVER); + INSTANCE.registerMessage(PacketArcaneRecipe.class, PacketArcaneRecipe.class, 1, Side.SERVER); } } diff --git a/src/main/java/com/github/vfyjxf/nee/network/packet/PacketArcaneRecipe.java b/src/main/java/com/github/vfyjxf/nee/network/packet/PacketArcaneRecipe.java new file mode 100644 index 0000000..ff3331d --- /dev/null +++ b/src/main/java/com/github/vfyjxf/nee/network/packet/PacketArcaneRecipe.java @@ -0,0 +1,77 @@ +package com.github.vfyjxf.nee.network.packet; + +import appeng.container.slot.SlotFakeCraftingMatrix; +import cpw.mods.fml.common.network.ByteBufUtils; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.relauncher.ReflectionHelper; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import thaumicenergistics.common.container.ContainerKnowledgeInscriber; + +import java.lang.reflect.Field; + +/** + * @author vfyjxf + */ +public class PacketArcaneRecipe implements IMessage, IMessageHandler { + + NBTTagCompound input; + + public PacketArcaneRecipe() {} + + public PacketArcaneRecipe(NBTTagCompound input) { + this.input = input; + } + + @Override + public void fromBytes(ByteBuf buf) { + this.input = ByteBufUtils.readTag(buf); + } + + @Override + public void toBytes(ByteBuf buf) { + ByteBufUtils.writeTag(buf, this.input); + } + + @Override + public IMessage onMessage(PacketArcaneRecipe message, MessageContext ctx) { + EntityPlayerMP player = ctx.getServerHandler().playerEntity; + Container container = player.openContainer; + if (container instanceof ContainerKnowledgeInscriber) { + ItemStack[] recipeInput = new ItemStack[9]; + NBTTagCompound currentStack; + for (int i = 0; i < recipeInput.length; i++) { + currentStack = (NBTTagCompound) message.input.getTag("#" + i); + recipeInput[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack); + } + + Field craftingSlots = ReflectionHelper.findField(ContainerKnowledgeInscriber.class, "craftingSlots"); + SlotFakeCraftingMatrix[] craftMatrix = getCraftingSlots(craftingSlots, (ContainerKnowledgeInscriber) container); + if (craftMatrix != null && message.input != null) { + for (int i = 0; i < recipeInput.length; i++) { + ItemStack currentItem = null; + if (recipeInput[i] != null) { + currentItem = recipeInput[i].copy(); + } + craftMatrix[i].putStack(currentItem); + } + ((ContainerKnowledgeInscriber) container).func_75130_a(craftMatrix[0].inventory); + } + } + return null; + } + + private SlotFakeCraftingMatrix[] getCraftingSlots(Field field, ContainerKnowledgeInscriber container) { + try { + return (SlotFakeCraftingMatrix[]) field.get(container); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/src/main/java/com/github/vfyjxf/nee/network/packet/PacketNEIPatternRecipe.java b/src/main/java/com/github/vfyjxf/nee/network/packet/PacketNEIPatternRecipe.java index 50225e5..5c9e7f6 100644 --- a/src/main/java/com/github/vfyjxf/nee/network/packet/PacketNEIPatternRecipe.java +++ b/src/main/java/com/github/vfyjxf/nee/network/packet/PacketNEIPatternRecipe.java @@ -27,8 +27,7 @@ public class PacketNEIPatternRecipe implements IMessage, IMessageHandler getAllOverlayIdentifier() { + return new HashSet<>(Arrays.asList( + "arcaneshapedrecipes","arcaneshapelessrecipes","aspectsRecipe", + "cruciblerecipe","infusionCrafting" + )); + } + + @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; + } + } + return null; + } + + @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; + } + } + return null; + } +}