Skip to content

Commit

Permalink
Updata EnderIO support and Forestry support
Browse files Browse the repository at this point in the history
  • Loading branch information
vfyjxf committed Aug 7, 2021
1 parent a698788 commit 1449d88
Show file tree
Hide file tree
Showing 14 changed files with 209 additions and 40 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This mod removes that functionality and allows the player to use NEI's transfer
- [x] EnderIO
- [x] Forestry(Doesn't support Fermenter and Still,because they don't have an item output)

If you want other Mod support,see [RecipeProcessor](./src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java) and [Mod support](https://github.com/vfyjxf/NotEnoughEnergistics/issues/1)
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)

## TODO

Expand All @@ -36,4 +36,4 @@ If you want other Mod support,see [RecipeProcessor](./src/main/java/com/github/v
~~Combine like stacks in processing patterns.~~

## Credits
Thanks TheRealp455w0rd and his [Just Enough Energistics](https://www.curseforge.com/minecraft/mc-mods/just-enough-energistics-jee)
Thanks TheRealp455w0rd and his [Just Enough Energistics](https://www.curseforge.com/minecraft/mc-mods/just-enough-energistics-jee)
14 changes: 12 additions & 2 deletions READNE_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,30 @@ NotEnoughEnergistics 是[Just Enough Energistics](https://www.curseforge.com/min
它替换了AE2默认的NEI集成, 默认情况下ae只能识别玩家身上或者网络里的存储物品。

本MOD允许你直接从nei获取配方并写入样板终端(shift点击[?]按钮)
并且会自动帮你切换样板模式。

## Features

- 根据配方自动切换样板终端的模式
- 如果一个物品输出为概率输出,那么NEE不会将它写入样板终端
- 在处理模式中合并同类物品

## 当前支持的Mod列表:

- [ ] AppliedEnergistics2(我们将不会支持AE2,因为AE2没有注册对应的OverlayHandler)
- [x] Vanilla
- [x] GregTech
- [x] IndustrialCraft2
- [x] Avaritia
- [x] EnderIO
- [x] Forestry(不支持发酵机和蒸馏器,因为它们没有物品输出)

如果你想要别的Mod的支持,请看[RecipeProcessor](./src/main/java/com/github/vfyjxf/nee/processor/RecipeProcessor.java) 或者[模组支持处理区](https://github.com/vfyjxf/NotEnoughEnergistics/issues/1)

## TODO
- 添加转换黑名单,使在黑名单里的物品不会被转移到样板终端
- 添加优先转换列表,在优先转换列表的物品会替换配方里的同类物品
- 在有多个同类物品的情况下,合并同类物品

~~在有多个同类物品的情况下,合并同类物品~~

## Credits
感谢 TheRealp455w0rd 和他的 [Just Enough Energistics](https://www.curseforge.com/minecraft/mc-mods/just-enough-energistics-jee)
Expand Down
11 changes: 4 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-1.4.0-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-1.4.4-SNAPSHOT'
}
}

apply plugin: 'java'
apply plugin: 'forge'

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'

Expand Down Expand Up @@ -44,9 +43,6 @@ dependencies {
compile "codechicken:CodeChickenLib:1.7.10-1.1.3.138:dev"
compile "codechicken:CodeChickenCore:1.7.10-1.0.7.+:dev"

// https://mvnrepository.com/artifact/com.alibaba/fastjson
implementation group: 'com.alibaba', name: 'fastjson', version: '1.2.76'

}

processResources {
Expand All @@ -59,7 +55,8 @@ processResources {
'mod_author': mod_author,
'mod_description': mod_description,
'mc_version': mc_version,
'mod_version': mod_version
'mod_version': mod_version,
'mod_credits': mod_credits
}

from(sourceSets.main.resources.srcDirs) {
Expand All @@ -85,4 +82,4 @@ jar{
artifacts {
archives devJar
archives sourcesJar
}
}
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.0.0
mod_version=1.1.0
forge_version=10.13.4.1614
mod_group=com.github.vfyjxf.neenergistics
mod_id=neenergistics
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/github/vfyjxf/nee/NEINeeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import com.github.vfyjxf.nee.processor.IRecipeProcessor;
import com.github.vfyjxf.nee.processor.RecipeProcessor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;


public class NEINeeConfig implements IConfigureNEI {
Expand All @@ -20,8 +18,10 @@ public void loadConfig() {

RecipeProcessor.init();

List<String> defaultIdentifiers= Arrays.asList("crafting", "crafting2x2","brewing","smelting","fuel");
List<String> identifiers = new ArrayList<>(defaultIdentifiers);
Set<String> defaultIdentifiers= new HashSet<>(
Arrays.asList("crafting", "crafting2x2","brewing","smelting","fuel",null)
);
Set<String> identifiers = new HashSet<>(defaultIdentifiers);

for(IRecipeProcessor processor : RecipeProcessor.recipeProcessors){
identifiers.addAll(processor.getAllOverlayIdentifier());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private PacketNEIPatternRecipe packProcessRecipe(IRecipeHandler recipe, int reci
}

for (PositionedStack positionedStack : outputs) {
if (outputIndex >= 4 || positionedStack.item == null) {
if (outputIndex >= 4 ||positionedStack == null || positionedStack.item == null) {
continue;
}
recipeOutputs.setTag(OUTPUT_KEY + outputIndex, positionedStack.item.writeToNBT(new NBTTagCompound()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

import java.util.*;

public class AvaritiaRecipeProcessor implements IRecipeProcessor{
public class AvaritiaRecipeProcessor implements IRecipeProcessor {
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(Arrays.asList(
"extreme","extreme_compression"
"extreme", "extreme_compression"
));
}

@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for(String ident : getAllOverlayIdentifier()){
if(ident.equals(identifier)){
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
return new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
}
}
Expand All @@ -25,8 +25,8 @@ public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeInd

@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for(String ident : getAllOverlayIdentifier()){
if(ident.equals(identifier)){
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeOutput = new ArrayList<>();
recipeOutput.add(recipe.getResultStack(recipeIndex));
return recipeOutput;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.github.vfyjxf.nee.processor;

import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import crazypants.enderio.nei.SagMillRecipeHandler;

import java.util.*;

public class EnderIORecipeProcessor implements IRecipeProcessor {
@Override
public Set<String> getAllOverlayIdentifier() {
return new HashSet<>(Arrays.asList(
"EnderIOAlloySmelter", "EIOEnchanter", "EnderIOSagMill",
"EnderIOSliceAndSplice", "EnderIOSoulBinder", "EnderIOVat"
));
}

@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
return new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
}
}
return null;
}

@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
if(identifier!=null) {
for (String ident : getAllOverlayIdentifier()) {
if (ident.equals(identifier)) {
List<PositionedStack> 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;
}
}
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.github.vfyjxf.nee.processor;

import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import forestry.factory.recipes.nei.*;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ForestryRecipeProcessor implements IRecipeProcessor {

@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
if (recipe instanceof NEIHandlerBottler) {

return bottlerHandler((NEIHandlerBottler) recipe, recipeIndex, true);

} else if (recipe instanceof NEIHandlerCarpenter) {

return carpenterHandler((NEIHandlerCarpenter) recipe, recipeIndex, true);

} else if (recipe instanceof NEIHandlerCentrifuge) {

return centrifugeHandler((NEIHandlerCentrifuge) recipe, recipeIndex, true);

} else if (recipe instanceof NEIHandlerFabricator) {

return fabricatorHandler((NEIHandlerFabricator) recipe, recipeIndex, true);

} else if (recipe instanceof NEIHandlerMoistener) {

return moistenerHandler((NEIHandlerMoistener) recipe, recipeIndex, true);

} else if (recipe instanceof NEIHandlerSqueezer) {

return squeezerHandler((NEIHandlerSqueezer) recipe, recipeIndex, true);

}
return null;
}

@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
if (recipe instanceof NEIHandlerBottler) {

return bottlerHandler((NEIHandlerBottler) recipe, recipeIndex, false);

} else if (recipe instanceof NEIHandlerCarpenter) {

return carpenterHandler((NEIHandlerCarpenter) recipe, recipeIndex, false);

} else if (recipe instanceof NEIHandlerCentrifuge) {

return centrifugeHandler((NEIHandlerCentrifuge) recipe, recipeIndex, false);

} else if (recipe instanceof NEIHandlerFabricator) {

return fabricatorHandler((NEIHandlerFabricator) recipe, recipeIndex, false);

} else if (recipe instanceof NEIHandlerMoistener) {

return moistenerHandler((NEIHandlerMoistener) recipe, recipeIndex, false);

} else if (recipe instanceof NEIHandlerSqueezer) {

return squeezerHandler((NEIHandlerSqueezer) recipe, recipeIndex, false);

}
return null;
}

private List<PositionedStack> bottlerHandler(NEIHandlerBottler base, int recipeIndex, boolean getInput) {
return getInput ? base.getIngredientStacks(recipeIndex) : Collections.singletonList(base.getResultStack(recipeIndex));
}

private List<PositionedStack> carpenterHandler(NEIHandlerCarpenter base, int recipeIndex, boolean getInput) {
return getInput ? base.getIngredientStacks(recipeIndex) : Collections.singletonList(base.getResultStack(recipeIndex));
}

private List<PositionedStack> centrifugeHandler(NEIHandlerCentrifuge base, int recipeIndex, boolean getInput) {
return getInput ? base.getIngredientStacks(recipeIndex) : base.getOtherStacks(recipeIndex);
}

private List<PositionedStack> fabricatorHandler(NEIHandlerFabricator base, int recipeIndex, boolean getInput) {
List<PositionedStack> recipeInput = new ArrayList<>(base.getIngredientStacks(recipeIndex));
recipeInput.addAll(base.getOtherStacks(recipeIndex));
return getInput ? recipeInput : Collections.singletonList(base.getResultStack(recipeIndex));
}

//Fermenter doesn't support, because it doesn't has a item output

private List<PositionedStack> moistenerHandler(NEIHandlerMoistener base, int recipeIndex, boolean getInput) {
List<PositionedStack> recipeInput = new ArrayList<>(base.getIngredientStacks(recipeIndex));
recipeInput.addAll(base.getOtherStacks(recipeIndex));
return getInput ? recipeInput : Collections.singletonList(base.getResultStack(recipeIndex));
}

private List<PositionedStack> squeezerHandler(NEIHandlerSqueezer base, int recipeIndex, boolean getInput) {
return getInput ? base.getIngredientStacks(recipeIndex) : Collections.singletonList(base.getResultStack(recipeIndex));
}
//Still doesn't need support

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import gregtech.api.enums.ItemList;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import gregtech.nei.GT_NEI_DefaultHandler.FixedPositionedStack;

import java.util.ArrayList;
import java.util.HashSet;
Expand Down Expand Up @@ -50,19 +46,23 @@ public Set<String> getAllOverlayIdentifier() {

@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {

if (gtDefaultClz.isInstance(recipe) || gtAssLineClz.isInstance(recipe)) {
List<PositionedStack> recipeInputs = new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
recipeInputs.removeIf(positionedStack -> GT_Utility.getFluidFromDisplayStack(positionedStack.items[0]) != null || positionedStack.item.stackSize == 0);
return recipeInputs;
}
return null;

}

@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
if (gtDefaultClz.isInstance(recipe) || gtAssLineClz.isInstance(recipe)) {
List<PositionedStack> recipeOutputs = new ArrayList<>(recipe.getOtherStacks(recipeIndex));
recipeOutputs.removeIf(positionedStack -> GT_Utility.getFluidFromDisplayStack(positionedStack.items[0]) != null);
//remove output if it's chance != 1
recipeOutputs.removeIf(stack -> stack instanceof FixedPositionedStack && !(((FixedPositionedStack) stack).mChance == 10000 || ((FixedPositionedStack) stack).mChance <= 0));
return recipeOutputs;
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public Set<String> getAllOverlayIdentifier() {
@Override
public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (identifier.equals(ident)) {
if (ident.equals(identifier)) {
return new ArrayList<>(recipe.getIngredientStacks(recipeIndex));
}
}
Expand All @@ -30,7 +30,7 @@ public List<PositionedStack> getRecipeInput(IRecipeHandler recipe, int recipeInd
@Override
public List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier) {
for (String ident : getAllOverlayIdentifier()) {
if (identifier.equals(ident)) {
if (ident.equals(identifier)) {
List<PositionedStack> recipeOutputs = new ArrayList<>();
recipeOutputs.add(recipe.getResultStack(recipeIndex));
recipeOutputs.addAll(recipe.getOtherStacks(recipeIndex));
Expand Down
Loading

0 comments on commit 1449d88

Please sign in to comment.