2016-09-06 09:53:19 +00:00
|
|
|
package gregtech.common;
|
|
|
|
|
|
|
|
import ic2.api.recipe.IMachineRecipeManager;
|
|
|
|
import ic2.api.recipe.IRecipeInput;
|
|
|
|
import ic2.api.recipe.RecipeOutput;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
public class GT_IC2RecipesHandler implements IMachineRecipeManager {
|
|
|
|
|
2016-09-12 11:07:17 +00:00
|
|
|
private ArrayList<RecipeIoContainer> recipes = new ArrayList<>();
|
2016-09-06 09:53:19 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean addRecipe(IRecipeInput iRecipeInput, NBTTagCompound metadata, boolean replace, ItemStack... itemStacks) {
|
|
|
|
RecipeIoContainer ioContainer = new RecipeIoContainer(iRecipeInput, new RecipeOutput(metadata, itemStacks));
|
2016-09-12 11:07:17 +00:00
|
|
|
recipes.add(ioContainer);
|
2016-09-06 09:53:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public RecipeOutput getOutputFor(ItemStack input, boolean adjustInput) {
|
2016-09-12 11:07:17 +00:00
|
|
|
for(RecipeIoContainer ioContainer : recipes) {
|
|
|
|
if (ioContainer.input.matches(input)) {
|
|
|
|
if (adjustInput) {
|
|
|
|
if (input.getItem().hasContainerItem(input)) {
|
|
|
|
ItemStack container = input.getItem().getContainerItem(input);
|
|
|
|
input.setItem(container.getItem());
|
|
|
|
input.stackSize = container.stackSize;
|
|
|
|
input.setItemDamage(container.getItemDamage());
|
|
|
|
input.setTagCompound(container.getTagCompound());
|
|
|
|
} else {
|
|
|
|
input.stackSize -= ioContainer.input.getAmount();
|
|
|
|
}
|
2016-09-06 09:53:19 +00:00
|
|
|
}
|
2016-09-12 11:07:17 +00:00
|
|
|
return ioContainer.output;
|
2016-09-06 09:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-12 11:07:17 +00:00
|
|
|
return null;
|
2016-09-06 09:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Iterable<RecipeIoContainer> getRecipes() {
|
2016-09-12 11:07:17 +00:00
|
|
|
return recipes;
|
2016-09-06 09:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isIterable() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|