use of crazypants.enderio.base.recipe.painter.AbstractPainterTemplate in project EnderIO by SleepyTrousers.
the class PainterRecipeCategory method splitRecipes.
// ------------ Recipes
@SuppressWarnings("null")
@Nonnull
private static List<PainterRecipeWrapper> splitRecipes(@Nonnull Collection<IMachineRecipe> recipes, List<ItemStack> validItems) {
long start = System.nanoTime();
List<AbstractPainterTemplate<?>> basicPainterTemplates = new ArrayList<AbstractPainterTemplate<?>>();
for (IMachineRecipe recipe : recipes) {
if (recipe instanceof AbstractPainterTemplate<?>) {
basicPainterTemplates.add((AbstractPainterTemplate<?>) recipe);
}
}
List<PainterRecipeWrapper> recipesWrappers = new ArrayList<PainterRecipeWrapper>();
for (ItemStack target : validItems) {
for (AbstractPainterTemplate<?> basicPainterTemplate : basicPainterTemplates) {
if (basicPainterTemplate.isValidTarget(target)) {
recipesWrappers.add(new PainterRecipeWrapper(basicPainterTemplate, target, new ArrayList<ItemStack>(), new ArrayList<ItemStack>()));
}
}
}
List<ItemStack> paints = ClientConfig.jeiUseShortenedPainterRecipes.get() ? getLimitedItems(validItems) : validItems;
int count = 0;
for (ItemStack paint : paints) {
try {
for (PainterRecipeWrapper painterRecipeWrapper : recipesWrappers) {
if (painterRecipeWrapper.recipe.isRecipe(paint, painterRecipeWrapper.target)) {
for (ResultStack result : painterRecipeWrapper.recipe.getCompletedResult(paint, painterRecipeWrapper.target)) {
painterRecipeWrapper.results.add(result.item);
painterRecipeWrapper.paints.add(paint);
count++;
}
}
}
} catch (Exception e) {
Log.warn("PainterRecipeCategory: Error while accessing item '" + paint + "': " + e);
e.printStackTrace();
}
}
long end = System.nanoTime();
for (PainterRecipeWrapper painterRecipeWrapper : recipesWrappers) {
if (painterRecipeWrapper.results.isEmpty()) {
Log.warn("PainterRecipeCategory: Empty recipe group: " + painterRecipeWrapper.recipe + " for " + painterRecipeWrapper.target);
}
}
Log.info(String.format("PainterRecipeCategory: Added %d painter recipes in %d groups to JEI in %.3f seconds.", count, recipesWrappers.size(), (end - start) / 1000000000d));
return recipesWrappers;
}
use of crazypants.enderio.base.recipe.painter.AbstractPainterTemplate in project EnderIO by SleepyTrousers.
the class TileEntityPainter method isMachineItemValidForSlot.
@Override
public boolean isMachineItemValidForSlot(int i, @Nonnull ItemStack itemStack) {
if (i > 1) {
return false;
}
ItemStack paint = i == 0 ? getStackInSlot(1) : itemStack;
ItemStack targt = i == 0 ? itemStack : getStackInSlot(0);
Map<String, IMachineRecipe> recipes = MachineRecipeRegistry.instance.getRecipesForMachine(getMachineName());
for (IMachineRecipe rec : recipes.values()) {
if (rec instanceof AbstractPainterTemplate<?>) {
AbstractPainterTemplate<?> temp = (AbstractPainterTemplate<?>) rec;
if (temp.isPartialRecipe(paint, targt)) {
return true;
}
}
}
return false;
}
Aggregations