Skip to content

Instantly share code, notes, and snippets.

@macalinao
Created December 22, 2011 22:12
Show Gist options
  • Save macalinao/1512078 to your computer and use it in GitHub Desktop.
Save macalinao/1512078 to your computer and use it in GitHub Desktop.
/**
* Stores the ItemStack at the given index. Notifies all attached
* InventoryViewers of the change.
*
* @param index The index where to put the ItemStack
* @param item The ItemStack to set
*/
@Override
public void setItem(int index, SpoutItemStack item) {
super.setItem(index, item);
if (index != RESULT_SLOT) {
ItemStack[] items = new ItemStack[4];
for (int i = 0; i < 4; ++i) {
items[i] = getItem(i);
}
Recipe recipe = ((SpoutServer) Bukkit.getServer()).getCraftingManager().getCraftingRecipe(items);
if (recipe == null) {
setItem(RESULT_SLOT, null);
} else {
setItem(RESULT_SLOT, recipe.getResult());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment