private List<L2ItemInstance> getItems(boolean for_real)
{
L2RecipeInstance[] recipes = recipeList.getRecipes();
Inventory inv = target.getInventory();
List<L2ItemInstance> materials=new FastList<L2ItemInstance>();
for (L2RecipeInstance recipe : recipes)
{
int quantity=(int)recipe.getQuantity();
if(recipeList.isConsumable())
quantity=(int) (quantity*Config.RATE_CONSUMABLE_COST);
if (quantity>0)
{
L2ItemInstance item=inv.getItemByItemId(recipe.getItemId());
int old_quantity=item.getCount(); // remember old quantity
// now we verify that we have enough materials
if(item.getCount()<quantity)
{
target.sendMessage("You dont have the right elements for making this item"
+ ((recipeList.isConsumable() && Config.RATE_CONSUMABLE_COST != 1) ? ".\nDue to server rates you need "
+ Config.RATE_CONSUMABLE_COST
+ "x more material than listed in recipe"
: ""));
abort(false);
return null;
}
item.setCount(quantity); // set amount we want
_log.warning("first update item "+item.getItem().getName()+" to new count: "+item.getCount());
materials.add(item); // store wanted amount
if(for_real) // for_real means really reduce amount in inventory
{
item.setCount("Manufacture",old_quantity-quantity,target,player);
_log.warning("for_real update item "+item.getItem().getName()+" to new count: "+item.getCount());
}
else
{
item.setCount(old_quantity); // restore old amount (dupe warning!)
_log.warning("update item "+item.getItem().getName()+"back to count: "+item.getCount());
}
}
}
_log.warning("at exit of getItems, materials contain: ");
itemsPrintout(materials);
return materials;
}