Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "chestWood" Ore Dictionary values rather than hardcoding the item. #3899

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;

import javax.annotation.Nonnull;
import java.util.HashMap;
Expand All @@ -15,5 +16,5 @@ public interface INasaWorkbenchRecipe
@Nonnull
ItemStack getRecipeOutput();

HashMap<Integer, ItemStack> getRecipeInput();
HashMap<Integer, Ingredient> getRecipeInput();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import micdoodle8.mods.galacticraft.api.recipe.INasaWorkbenchRecipe;
import micdoodle8.mods.galacticraft.core.GCItems;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -32,9 +33,9 @@ public static int countStorage(INasaWorkbenchRecipe recipe)
{
int count = 0;
ItemStack storage = new ItemStack(GCItems.partBuggy, 1, 2);
for (Entry<Integer, ItemStack> e : recipe.getRecipeInput().entrySet())
for (Entry<Integer, Ingredient> e : recipe.getRecipeInput().entrySet())
{
if (ItemStack.areItemsEqual(storage, e.getValue()))
if (e.getValue().apply(storage))
count++;
}
return count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import micdoodle8.mods.galacticraft.api.recipe.INasaWorkbenchRecipe;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -32,9 +33,9 @@ public static int countChests(INasaWorkbenchRecipe recipe)
{
int count = 0;
ItemStack chest = new ItemStack(Blocks.CHEST);
for (Entry<Integer, ItemStack> e : recipe.getRecipeInput().entrySet())
for (Entry<Integer, Ingredient> e : recipe.getRecipeInput().entrySet())
{
if (ItemStack.areItemsEqual(chest, e.getValue()))
if (e.getValue().apply(chest))
count++;
}
return count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public boolean isItemValid(ItemStack par1ItemStack)
List<INasaWorkbenchRecipe> recipes = GalacticraftRegistry.getBuggyBenchRecipes();
for (INasaWorkbenchRecipe recipe : recipes)
{
if (ItemStack.areItemsEqual(par1ItemStack, recipe.getRecipeInput().get(this.index)))
if (recipe.getRecipeInput().get(this.index).apply(par1ItemStack))
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public boolean isItemValid(ItemStack par1ItemStack)
List<INasaWorkbenchRecipe> recipes = GalacticraftRegistry.getRocketT1Recipes();
for (INasaWorkbenchRecipe recipe : recipes)
{
if (ItemStack.areItemsEqual(par1ItemStack, recipe.getRecipeInput().get(this.index)))
if (recipe.getRecipeInput().get(this.index).apply(par1ItemStack))
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import micdoodle8.mods.galacticraft.api.recipe.INasaWorkbenchRecipe;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.oredict.OreDictionary;

import java.util.HashMap;
Expand All @@ -11,14 +12,14 @@
public class NasaWorkbenchRecipe implements INasaWorkbenchRecipe
{
private ItemStack output;
private HashMap<Integer, ItemStack> input;
private HashMap<Integer, Ingredient> input;

public NasaWorkbenchRecipe(ItemStack output, HashMap<Integer, ItemStack> input)
public NasaWorkbenchRecipe(ItemStack output, HashMap<Integer, Ingredient> input)
{
this.output = output;
this.input = input;

for (Entry<Integer, ItemStack> entry : this.input.entrySet())
for (Entry<Integer, Ingredient> entry : this.input.entrySet())
{
if (entry.getValue() == null)
{
Expand All @@ -30,11 +31,11 @@ public NasaWorkbenchRecipe(ItemStack output, HashMap<Integer, ItemStack> input)
@Override
public boolean matches(IInventory inventory)
{
for (Entry<Integer, ItemStack> entry : this.input.entrySet())
for (Entry<Integer, Ingredient> entry : this.input.entrySet())
{
ItemStack stackAt = inventory.getStackInSlot(entry.getKey());

if (!this.checkItemEquals(stackAt, entry.getValue()))
if (!entry.getValue().apply(stackAt))
{
return false;
}
Expand All @@ -43,15 +44,6 @@ public boolean matches(IInventory inventory)
return true;
}

private boolean checkItemEquals(ItemStack target, ItemStack input)
{
if (input.isEmpty() && !target.isEmpty() || !input.isEmpty() && target.isEmpty())
{
return false;
}
return target.isEmpty() && input.isEmpty() || target.getItem() == input.getItem() && (target.getItemDamage() == OreDictionary.WILDCARD_VALUE || target.getItemDamage() == input.getItemDamage());
}

@Override
public int getRecipeSize()
{
Expand All @@ -65,7 +57,7 @@ public ItemStack getRecipeOutput()
}

@Override
public HashMap<Integer, ItemStack> getRecipeInput()
public HashMap<Integer, Ingredient> getRecipeInput()
{
return this.input;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,14 @@
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.RecipeSorter.Category;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.*;

import appeng.api.AEApi;
import appeng.api.features.IGrinderRegistry;
Expand Down Expand Up @@ -106,132 +103,121 @@ public static void addUniversalRecipes()
FurnaceRecipes.instance().addSmeltingRecipe(new ItemStack(GCItems.foodItem, 1, 6), new ItemStack(GCItems.foodItem, 1, 7), 1.0F);
FurnaceRecipes.instance().addSmeltingRecipe(new ItemStack(GCBlocks.blockMoon, 1, 6), new ItemStack(GCItems.itemBasicMoon, 1, 2), 1.0F);

HashMap<Integer, ItemStack> input = new HashMap<>();
input.put(1, new ItemStack(GCItems.partNoseCone));
input.put(2, new ItemStack(GCItems.heavyPlatingTier1));
input.put(3, new ItemStack(GCItems.heavyPlatingTier1));
input.put(4, new ItemStack(GCItems.heavyPlatingTier1));
input.put(5, new ItemStack(GCItems.heavyPlatingTier1));
input.put(6, new ItemStack(GCItems.heavyPlatingTier1));
input.put(7, new ItemStack(GCItems.heavyPlatingTier1));
input.put(8, new ItemStack(GCItems.heavyPlatingTier1));
input.put(9, new ItemStack(GCItems.heavyPlatingTier1));
input.put(10, new ItemStack(GCItems.partFins));
input.put(11, new ItemStack(GCItems.partFins));
input.put(12, new ItemStack(GCItems.rocketEngine));
input.put(13, new ItemStack(GCItems.partFins));
input.put(14, new ItemStack(GCItems.partFins));
input.put(15, ItemStack.EMPTY);
input.put(16, ItemStack.EMPTY);
input.put(17, ItemStack.EMPTY);
HashMap<Integer, Ingredient> input = new HashMap<>();
input.put(1, Ingredient.fromStacks(new ItemStack(GCItems.partNoseCone)));
input.put(2, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(3, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(4, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(5, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(6, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(7, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(8, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(9, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(10, Ingredient.fromStacks(new ItemStack(GCItems.partFins)));
input.put(11, Ingredient.fromStacks(new ItemStack(GCItems.partFins)));
input.put(12, Ingredient.fromStacks(new ItemStack(GCItems.rocketEngine)));
input.put(13, Ingredient.fromStacks(new ItemStack(GCItems.partFins)));
input.put(14, Ingredient.fromStacks(new ItemStack(GCItems.partFins)));
input.put(15, Ingredient.fromStacks(ItemStack.EMPTY));
input.put(16, Ingredient.fromStacks(ItemStack.EMPTY));
input.put(17, Ingredient.fromStacks(ItemStack.EMPTY));
RecipeUtil.addRocketBenchRecipe(new ItemStack(GCItems.rocketTier1, 1, 0), input);

HashMap<Integer, ItemStack> input2 = new HashMap<Integer, ItemStack>(input);
input2.put(15, new ItemStack(Blocks.CHEST));
input2.put(16, ItemStack.EMPTY);
input2.put(17, ItemStack.EMPTY);
RecipeUtil.addRocketBenchRecipe(new ItemStack(GCItems.rocketTier1, 1, 1), input2);
ItemStack[] chests = new ItemStack[OreDictionary.getOres("chestWood").size()];
for (int i = 0; i < chests.length; i++) {
chests[i] = OreDictionary.getOres("chestWood").get(i);
}


input2 = new HashMap<Integer, ItemStack>(input);
input2.put(15, ItemStack.EMPTY);
input2.put(16, new ItemStack(Blocks.CHEST));
input2.put(17, ItemStack.EMPTY);
HashMap<Integer, Ingredient> input2 = new HashMap<>(input);
input2.put(15, Ingredient.fromStacks(chests));
RecipeUtil.addRocketBenchRecipe(new ItemStack(GCItems.rocketTier1, 1, 1), input2);

input2 = new HashMap<>(input);
input2.put(16, Ingredient.fromStacks(chests));
RecipeUtil.addRocketBenchRecipe(new ItemStack(GCItems.rocketTier1, 1, 1), input2);

input2 = new HashMap<Integer, ItemStack>(input);
input2.put(15, ItemStack.EMPTY);
input2.put(16, ItemStack.EMPTY);
input2.put(17, new ItemStack(Blocks.CHEST));
input2 = new HashMap<>(input);
input2.put(17, Ingredient.fromStacks(chests));
RecipeUtil.addRocketBenchRecipe(new ItemStack(GCItems.rocketTier1, 1, 1), input2);

input2 = new HashMap<Integer, ItemStack>(input);
input2.put(15, new ItemStack(Blocks.CHEST));
input2.put(16, new ItemStack(Blocks.CHEST));
input2.put(17, ItemStack.EMPTY);
input2 = new HashMap<>(input);
input2.put(15, Ingredient.fromStacks(chests));
input2.put(16, Ingredient.fromStacks(chests));
RecipeUtil.addRocketBenchRecipe(new ItemStack(GCItems.rocketTier1, 1, 2), input2);

input2 = new HashMap<Integer, ItemStack>(input);
input2.put(15, new ItemStack(Blocks.CHEST));
input2.put(16, ItemStack.EMPTY);
input2.put(17, new ItemStack(Blocks.CHEST));
input2 = new HashMap<>(input);
input2.put(15, Ingredient.fromStacks(chests));
input2.put(17, Ingredient.fromStacks(chests));
RecipeUtil.addRocketBenchRecipe(new ItemStack(GCItems.rocketTier1, 1, 2), input2);

input2 = new HashMap<Integer, ItemStack>(input);
input2.put(15, ItemStack.EMPTY);
input2.put(16, new ItemStack(Blocks.CHEST));
input2.put(17, new ItemStack(Blocks.CHEST));
input2 = new HashMap<>(input);
input2.put(16, Ingredient.fromStacks(chests));
input2.put(17, Ingredient.fromStacks(chests));
RecipeUtil.addRocketBenchRecipe(new ItemStack(GCItems.rocketTier1, 1, 2), input2);

input2 = new HashMap<Integer, ItemStack>(input);
input2.put(15, new ItemStack(Blocks.CHEST));
input2.put(16, new ItemStack(Blocks.CHEST));
input2.put(17, new ItemStack(Blocks.CHEST));
input2 = new HashMap<>(input);
input2.put(15, Ingredient.fromStacks(chests));
input2.put(16, Ingredient.fromStacks(chests));
input2.put(17, Ingredient.fromStacks(chests));
RecipeUtil.addRocketBenchRecipe(new ItemStack(GCItems.rocketTier1, 1, 3), input2);

//

input = new HashMap<Integer, ItemStack>();
input.put(1, new ItemStack(GCItems.heavyPlatingTier1));
input.put(2, new ItemStack(GCItems.heavyPlatingTier1));
input.put(3, new ItemStack(GCItems.heavyPlatingTier1));
input.put(4, new ItemStack(GCItems.heavyPlatingTier1));
input.put(5, new ItemStack(GCItems.heavyPlatingTier1));
input.put(6, new ItemStack(GCItems.partBuggy, 1, 1));
input.put(7, new ItemStack(GCItems.heavyPlatingTier1));
input.put(8, new ItemStack(GCItems.heavyPlatingTier1));
input.put(9, new ItemStack(GCItems.heavyPlatingTier1));
input.put(10, new ItemStack(GCItems.heavyPlatingTier1));
input.put(11, new ItemStack(GCItems.heavyPlatingTier1));
input.put(12, new ItemStack(GCItems.heavyPlatingTier1));
input.put(13, new ItemStack(GCItems.partBuggy));
input.put(14, new ItemStack(GCItems.partBuggy));
input.put(15, new ItemStack(GCItems.partBuggy));
input.put(16, new ItemStack(GCItems.partBuggy));
input.put(17, ItemStack.EMPTY);
input.put(18, ItemStack.EMPTY);
input.put(19, ItemStack.EMPTY);
input = new HashMap<>();
input.put(1, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(2, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(3, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(4, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(5, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(6, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy, 1, 1)));
input.put(7, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(8, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(9, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(10, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(11, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(12, Ingredient.fromStacks(new ItemStack(GCItems.heavyPlatingTier1)));
input.put(13, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy)));
input.put(14, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy)));
input.put(15, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy)));
input.put(16, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy)));
input.put(17, Ingredient.fromStacks(ItemStack.EMPTY));
input.put(18, Ingredient.fromStacks(ItemStack.EMPTY));
input.put(19, Ingredient.fromStacks(ItemStack.EMPTY));
RecipeUtil.addBuggyBenchRecipe(new ItemStack(GCItems.buggy, 1, 0), input);

input2 = new HashMap<Integer, ItemStack>(input);
input2.put(17, new ItemStack(GCItems.partBuggy, 1, 2));
input2.put(18, ItemStack.EMPTY);
input2.put(19, ItemStack.EMPTY);
input2 = new HashMap<>(input);
input2.put(17, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy, 1, 2)));

RecipeUtil.addBuggyBenchRecipe(new ItemStack(GCItems.buggy, 1, 1), input2);

input2 = new HashMap<Integer, ItemStack>(input);
input2.put(17, ItemStack.EMPTY);
input2.put(18, new ItemStack(GCItems.partBuggy, 1, 2));
input2.put(19, ItemStack.EMPTY);
input2 = new HashMap<>(input);
input2.put(18, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy, 1, 2)));
RecipeUtil.addBuggyBenchRecipe(new ItemStack(GCItems.buggy, 1, 1), input2);

input2 = new HashMap<Integer, ItemStack>(input);
input2.put(17, ItemStack.EMPTY);
input2.put(18, ItemStack.EMPTY);
input2.put(19, new ItemStack(GCItems.partBuggy, 1, 2));
input2 = new HashMap<>(input);
input2.put(19, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy, 1, 2)));
RecipeUtil.addBuggyBenchRecipe(new ItemStack(GCItems.buggy, 1, 1), input2);

input2 = new HashMap<Integer, ItemStack>(input);
input2.put(17, new ItemStack(GCItems.partBuggy, 1, 2));
input2.put(18, new ItemStack(GCItems.partBuggy, 1, 2));
input2.put(19, ItemStack.EMPTY);
input2 = new HashMap<>(input);
input2.put(17, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy, 1, 2)));
input2.put(18, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy, 1, 2)));
RecipeUtil.addBuggyBenchRecipe(new ItemStack(GCItems.buggy, 1, 2), input2);

input2 = new HashMap<Integer, ItemStack>(input);
input2.put(17, new ItemStack(GCItems.partBuggy, 1, 2));
input2.put(18, ItemStack.EMPTY);
input2.put(19, new ItemStack(GCItems.partBuggy, 1, 2));
input2 = new HashMap<>(input);
input2.put(17, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy, 1, 2)));
input2.put(19, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy, 1, 2)));
RecipeUtil.addBuggyBenchRecipe(new ItemStack(GCItems.buggy, 1, 2), input2);

input2 = new HashMap<Integer, ItemStack>(input);
input2.put(17, ItemStack.EMPTY);
input2.put(18, new ItemStack(GCItems.partBuggy, 1, 2));
input2.put(19, new ItemStack(GCItems.partBuggy, 1, 2));
input2 = new HashMap<>(input);
input2.put(18, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy, 1, 2)));
input2.put(19, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy, 1, 2)));
RecipeUtil.addBuggyBenchRecipe(new ItemStack(GCItems.buggy, 1, 2), input2);

input2 = new HashMap<Integer, ItemStack>(input);
input2.put(17, new ItemStack(GCItems.partBuggy, 1, 2));
input2.put(18, new ItemStack(GCItems.partBuggy, 1, 2));
input2.put(19, new ItemStack(GCItems.partBuggy, 1, 2));
input2 = new HashMap<>(input);
input2.put(17, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy, 1, 2)));
input2.put(18, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy, 1, 2)));
input2.put(19, Ingredient.fromStacks(new ItemStack(GCItems.partBuggy, 1, 2)));
RecipeUtil.addBuggyBenchRecipe(new ItemStack(GCItems.buggy, 1, 3), input2);

aluminumIngots.addAll(OreDictionary.getOres("ingotAluminum"));
Expand Down
Loading