use of net.minecraft.item.crafting.IRecipe in project Railcraft by Railcraft.
the class CraftingPlugin method addRecipe.
public static void addRecipe(@Nullable ItemStack result, Object... recipeArray) {
ProcessedRecipe processedRecipe;
try {
processedRecipe = processRecipe(RecipeType.SHAPED, result, recipeArray);
} catch (InvalidRecipeException ex) {
Game.logTrace(Level.WARN, ex.getRawMessage());
return;
}
if (processedRecipe.isOreRecipe) {
IRecipe recipe = new ShapedOreRecipe(processedRecipe.result, processedRecipe.recipeArray);
addRecipe(recipe);
} else
GameRegistry.addRecipe(processedRecipe.result, processedRecipe.recipeArray);
}
use of net.minecraft.item.crafting.IRecipe in project Railcraft by Railcraft.
the class RollingMachinePlugin method generateRecipes.
@Override
public void generateRecipes(RecipeGenerator generator) {
ItemStack machine = EquipmentVariant.ROLLING_MACHINE_POWERED.getStack();
if (machine != null) {
RecipeTemplate template = generator.createRecipeTemplate(slots, machine, "/gui/CraftGuideRecipe.png", 163, 1, 163, 61);
for (IRecipe recipe : RailcraftCraftingManager.rollingMachine.getRecipeList()) {
Object[] array = new Object[11];
System.arraycopy(generator.getCraftingRecipe(recipe), 0, array, 0, 10);
array[10] = machine;
generator.addRecipe(template, array);
}
}
}
use of net.minecraft.item.crafting.IRecipe in project Engine by VoltzEngine-Project.
the class JsonRecipeReplacementProcessor method loadComplete.
@Override
public void loadComplete() {
//Init replacement data
Iterator it = replacementData.iterator();
while (it.hasNext()) {
JsonRecipeReplacementData data = (JsonRecipeReplacementData) it.next();
if (data.output == null) {
data.output = data.convertItemEntry(data.outputValue);
}
if (data.output == null) {
Engine.logger().error("JsonRecipeReplacementProcessor: Failed to locate item entry for '" + data.outputValue + "' ignoring value.");
it.remove();
}
}
//Loop recipes and remove entries
it = CraftingManager.getInstance().getRecipeList().iterator();
while (it.hasNext()) {
Object r = it.next();
if (r instanceof IRecipe) {
final ItemStack result = ((IRecipe) r).getRecipeOutput();
if (result != null) {
//Loop replacement data checking for match
for (JsonRecipeReplacementData data : replacementData) {
if ("grid".equalsIgnoreCase(data.craftingType) && data.doesMatchForReplacement(result)) {
Engine.logger().info("JsonRecipeReplacementProcessor: Removed recipe -> " + r);
//Remove and exit loop
it.remove();
break;
}
}
} else //Error to note broken recipe might exist
{
Engine.logger().error("JsonRecipeReplacementProcessor: Potential broken recipe with no output -> " + r);
}
}
}
//Loop to finalize data
for (JsonRecipeReplacementData data : replacementData) {
if (!data.subProcessingData.isEmpty()) {
final List<IJsonGenObject> objects = new ArrayList();
for (Map.Entry<String, JsonElement> entry : data.subProcessingData.entrySet()) {
JsonContentLoader.INSTANCE.process(entry.getKey(), entry.getValue(), objects);
}
JsonContentLoader.INSTANCE.handlePostCalls(objects);
}
}
}
use of net.minecraft.item.crafting.IRecipe in project Engine by VoltzEngine-Project.
the class ModManager method firePostInit.
/**
* Called during post init phase of mod loading
*/
public void firePostInit() {
for (Object object : temp_registry_list) {
if (object instanceof IPostInit) {
((IPostInit) object).onPostInit();
}
}
for (Object object : temp_registry_list) {
if (object instanceof IRecipeContainer) {
List<IRecipe> recipes = new ArrayList();
((IRecipeContainer) object).genRecipes(recipes);
for (IRecipe recipe : recipes) {
if (recipe.getRecipeOutput() != null) {
if (recipe.getRecipeOutput().getItem() != null) {
if (recipe.getRecipeOutput().getMaxStackSize() > 0) {
//TODO check that input -> output
//TODO check for basic errors
//TODO check size
//TODO check for missing items
//TODO check for oreName replacement
GameRegistry.addRecipe(recipe);
} else if (Engine.runningAsDev) {
throw new IllegalArgumentException("Recipe[" + recipe + "] output's stack size is less than 1");
}
} else if (Engine.runningAsDev) {
throw new IllegalArgumentException("Recipe[" + recipe + "] output's item is null");
}
} else if (Engine.runningAsDev) {
throw new IllegalArgumentException("Recipe[" + recipe + "] output is null");
}
}
}
}
}
Aggregations