Skip to content

Advanced API Example

Uristqwerty edited this page Apr 6, 2016 · 6 revisions

Here is a modified version of the API usage example that demonstrates more of the slot types provided by the API.

class DoohickeyRecipes extends CraftGuideAPIObject implements RecipeProvider
{
	@Override
	public void generateRecipes(RecipeGenerator generator)
	{
		ItemStack doohickeyMachine = MyAPI.getBlockItem("doohickey");
		
		RecipeTemplate template = generator.createRecipeTemplate(
				new Slot[]{
						new ItemSlot(12, 12, 16, 16, true).drawOwnBackground(true),
						new LiquidSlot(12, 30),
						new ItemSlot(50, 13, 16, 16, true).setSlotType(SlotType.OUTPUT_SLOT).drawOwnBackground(true),
						new ChanceSlot(50, 30, 16, 16).setSlotType(SlotType.OUTPUT_SLOT).drawOwnBackground(true)
						new ItemSlot(31, 21, 16, 16, true).setSlotType(SlotType.MACHINE_SLOT).drawOwnBackground(false),
				}, doohickeyMachine);
			
		for(DoohickeyRecipe recipe: MyAPI.getDoohickeyRecipes())
		{
			recipeGenerator.addRecipe(template,
					new Object[] {
							recipe.getInputItem(),
							recipe.getInputFluidStack(),
							recipe.getPrimaryOutput(),
							new Object[] {
								recipe.getSecondaryOutput(),
								recipe.getSecondaryChance(),
							},
							doohickeyMachine
					});
		}
	}
}

Clone this wiki locally