Add TCNEIPlugin support and ThaumicEnergistics support

This commit is contained in:
vfyjxf committed 2021-08-08 17:31:14 +08:00
1 parent 5b53c52f71
commit fffc512469
27 files changed
+266 -24

No files matched your search

+5 -2
View File
@@ -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)
+3
View File
@@ -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)
+14
View File
@@ -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 {
+1 -1
View File
@@ -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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,6 +7,8 @@ import codechicken.nei.api.IConfigureNEI;
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 class NEINeeConfig implements IConfigureNEI {
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
@@ -55,4 +49,36 @@ public class NEINeeConfig implements IConfigureNEI {
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);
}
}
}
@@ -8,6 +8,7 @@ import com.github.vfyjxf.nee.network.NEENetworkHandler;
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 @@ public class NEECraftingHandler implements IOverlayHandler {
}
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 @@ public class NEECraftingHandler implements IOverlayHandler {
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();
@@ -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 class NEENetworkHandler {
public static void init(){
INSTANCE.registerMessage(PacketNEIPatternRecipe.class, PacketNEIPatternRecipe.class,0, Side.SERVER);
INSTANCE.registerMessage(PacketArcaneRecipe.class, PacketArcaneRecipe.class, 1, Side.SERVER);
}
}
@@ -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;
}
}
@@ -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;
@@ -119,6 +118,7 @@ public class PacketNEIPatternRecipe implements IMessage, IMessageHandler<PacketN
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++) {
@@ -34,6 +34,10 @@ public class RecipeProcessor {
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");
}
@@ -0,0 +1,45 @@
package com.github.vfyjxf.nee.processor;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import com.djgiannuzz.thaumcraftneiplugin.items.ItemAspect;
import java.util.*;
/**
* @author vfyjxf
*/
public class TCNEIPluginRecipeProcessor implements IRecipeProcessor{
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(Arrays.asList(
"arcaneshapedrecipes","arcaneshapelessrecipes","aspectsRecipe",
"cruciblerecipe","infusionCrafting"
));
}
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for(String ident : getAllOverlayIdentifier()){
if(ident.equals(identifier)){
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
recipeInputs.removeIf(positionedStack -> positionedStack.item.getItem() instanceof ItemAspect);
return recipeInputs;
}
}
return null;
}
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for(String ident : getAllOverlayIdentifier()){
if(ident.equals(identifier)){
List<PositionedStack> recipeOutputs = new ArrayList<>();
recipeOutputs.add(recipe.getResultStack(recipeIndex));
return recipeOutputs;
}
}
return null;
}
}