mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-08 12:34:53 +00:00
Merge pull request #11 from GTNewHorizons/elven-dummy
Hide dummy recipes from Elven NEI handler
This commit is contained in:
2 files changed
+30
-15
No files matched your search
@@ -7,6 +7,7 @@ repositories {
|
||||
maven {
|
||||
name 'ic2'
|
||||
url 'https://maven.ic2.player.to/'
|
||||
url 'https://maven2.ic2.player.to/'
|
||||
metadataSources {
|
||||
mavenPom()
|
||||
artifact()
|
||||
|
||||
+29
-15
@@ -2,12 +2,12 @@ package vazkii.botania.client.integration.nei.recipe;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
@@ -15,7 +15,6 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.ILexicon;
|
||||
import vazkii.botania.api.recipe.RecipeElvenTrade;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.block.BlockAlfPortal;
|
||||
@@ -115,10 +114,7 @@ public class RecipeHandlerElvenTrade extends TemplateRecipeHandler {
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if(outputId.equals("botania.elvenTrade") && hasElvenKnowledge()) {
|
||||
if(hasElvenKnowledge()) {
|
||||
for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) {
|
||||
if(recipe == null)
|
||||
continue;
|
||||
|
||||
for(RecipeElvenTrade recipe : filteredElvenTradeRecipes()) {
|
||||
arecipes.add(new CachedElvenTradeRecipe(recipe));
|
||||
}
|
||||
}
|
||||
@@ -128,10 +124,7 @@ public class RecipeHandlerElvenTrade extends TemplateRecipeHandler {
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
if(hasElvenKnowledge()) {
|
||||
for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) {
|
||||
if(recipe == null)
|
||||
continue;
|
||||
|
||||
for(RecipeElvenTrade recipe : filteredElvenTradeRecipes()) {
|
||||
if(ItemNBTHelper.areStacksSameTypeCraftingWithNBT(recipe.getOutput(), result))
|
||||
arecipes.add(new CachedElvenTradeRecipe(recipe));
|
||||
}
|
||||
@@ -141,10 +134,7 @@ public class RecipeHandlerElvenTrade extends TemplateRecipeHandler {
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
if(hasElvenKnowledge()) {
|
||||
for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) {
|
||||
if(recipe == null)
|
||||
continue;
|
||||
|
||||
for(RecipeElvenTrade recipe : filteredElvenTradeRecipes()) {
|
||||
CachedElvenTradeRecipe crecipe = new CachedElvenTradeRecipe(recipe);
|
||||
if(ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient))
|
||||
arecipes.add(crecipe);
|
||||
@@ -152,4 +142,28 @@ public class RecipeHandlerElvenTrade extends TemplateRecipeHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// hide dummy recipes
|
||||
private List<RecipeElvenTrade> filteredElvenTradeRecipes() {
|
||||
return BotaniaAPI.elvenTradeRecipes
|
||||
.stream()
|
||||
.filter(recipe -> {
|
||||
if (recipe == null) {
|
||||
return false;
|
||||
}
|
||||
if (recipe.getInputs().size() == 1) {
|
||||
return !stackSame(recipe.getOutput(), recipe.getInputs().get(0));
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private boolean stackSame(ItemStack stack, Object obj) {
|
||||
if (obj instanceof String) {
|
||||
return OreDictionary.getOres((String) obj).stream().anyMatch(s -> ItemNBTHelper.areStacksSameTypeCraftingWithNBT(stack, s));
|
||||
} else {
|
||||
return Arrays.stream(NEIServerUtils.extractRecipeItems(obj)).anyMatch(s -> ItemNBTHelper.areStacksSameTypeCraftingWithNBT(stack, s));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user