Skip to content

Commit

Permalink
Add TCNEIPlugin support and ThaumicEnergistics support
Browse files Browse the repository at this point in the history
  • Loading branch information
vfyjxf committed Aug 8, 2021
1 parent 5b53c52 commit fffc512
Show file tree
Hide file tree
Showing 27 changed files with 266 additions and 24 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions READNE_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ NotEnoughEnergistics 是[Just Enough Energistics](https://www.curseforge.com/min
- 根据配方自动切换样板终端的模式
- 如果一个物品输出为概率输出,那么NEE不会将它写入样板终端
- 在处理模式中合并同类物品
- 支持增广样板终端(4 -> 16模式)

## 当前支持的Mod列表:

Expand All @@ -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)

Expand Down
14 changes: 14 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -32,6 +40,10 @@ repositories {
name 'chickenbones'
url 'http://chickenbones.net/maven'
}
maven {
name = "gt"
url = "http://gregtech.overminddl1.com/"
}
flatDir {
dirs 'libs'
}
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added libs/Avaritia-1.19-deobf.jar
Binary file not shown.
Binary file added libs/Baubles-1.7.10-1.0.1.11.jar
Binary file not shown.
Binary file added libs/BetterCrashes-1.0.0-dev.jar
Binary file not shown.
Binary file added libs/EnderCore-1.7.10-0.2.0.39_beta.jar
Binary file not shown.
Binary file added libs/EnderIO-1.7.10-2.3.1.16_beta.32-dev.jar
Binary file not shown.
Binary file added libs/EnderIO-1.7.10-2.3.1.16_beta.32-sources.jar
Binary file not shown.
Binary file added libs/Grimoire-mc1.7.10-dev-3.2.7.jar
Binary file not shown.
Binary file added libs/JustEnoughCalculation-1.7.10-3.6.3.jar
Binary file not shown.
Binary file added libs/StructureLib-1.0.8-deobf.jar
Binary file not shown.
Binary file added libs/forestry_1.7.10-4.3.1.45-dev.jar
Binary file not shown.
Binary file added libs/forestry_1.7.10-4.3.1.45-sources.jar
Binary file not shown.
Binary file added libs/gregtech-5.09.37.06-dev.jar
Binary file not shown.
Binary file added libs/gregtech-5.09.37.06-sources.jar
Binary file not shown.
Binary file not shown.
Binary file added libs/thaumcraftneiplugin-1.7.10-1.7a.jar
Binary file not shown.
Binary file added libs/thaumicenergistics-1.1.3.12-GTNH.jar
Binary file not shown.
60 changes: 43 additions & 17 deletions src/main/java/com/github/vfyjxf/nee/NEINeeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand All @@ -18,32 +20,24 @@ public void loadConfig() {

RecipeProcessor.init();

Set<String> defaultIdentifiers= new HashSet<>(
Arrays.asList("crafting", "crafting2x2","brewing","smelting","fuel",null)
Set<String> defaultIdentifiers = new HashSet<>(
Arrays.asList("crafting", "crafting2x2", "brewing", "smelting", "fuel", null)
);
Set<String> 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
Expand All @@ -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<String> 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);
}
}
}
72 changes: 70 additions & 2 deletions src/main/java/com/github/vfyjxf/nee/nei/NEECraftingHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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<PositionedStack> 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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -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<PacketArcaneRecipe, IMessage> {

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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public class PacketNEIPatternRecipe implements IMessage, IMessageHandler<PacketN
NBTTagCompound input;
NBTTagCompound output;

public PacketNEIPatternRecipe() {
}
public PacketNEIPatternRecipe() {}

public PacketNEIPatternRecipe(@Nonnull NBTTagCompound input, NBTTagCompound output) {
this.input = input;
Expand Down Expand Up @@ -119,6 +118,7 @@ private void processRecipeHandler(ContainerPatternTerm container, PacketNEIPatte
for (int i = 0; i < recipeInput.length; i++) {
NBTTagCompound currentStack = (NBTTagCompound) message.input.getTag("#" + i);
recipeInput[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack);
System.out.println(currentStack);
}

for (int i = 0; i < recipeOutput.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public static void init() {
NotEnoughEnergistics.logger.info("Found Forestry, install Forestry support");
recipeProcessors.add(new ForestryRecipeProcessor());
}
if(Loader.isModLoaded("thaumcraftneiplugin")){
NotEnoughEnergistics.logger.info("Found TCNEIPlugin, install TCNEIPlugin support");
recipeProcessors.add(new TCNEIPluginRecipeProcessor());
}
if (Loader.isModLoaded("appliedenergistics2")) {
NotEnoughEnergistics.logger.info("Applied Energistics 2 will not be supported");
}
Expand Down
Loading

0 comments on commit fffc512

Please sign in to comment.