Skip to content

Instantly share code, notes, and snippets.

@hilburn
Created June 13, 2015 10:28
Show Gist options
  • Select an option

  • Save hilburn/9d74c2b23473e99520a1 to your computer and use it in GitHub Desktop.

Select an option

Save hilburn/9d74c2b23473e99520a1 to your computer and use it in GitHub Desktop.
package advancedsystemsmanager.commands;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
public class NBTRecipe implements IRecipe
{
ItemStack result = new ItemStack(Blocks.cake);
@Override
public boolean matches(InventoryCrafting crafting, World world)
{
ItemStack match = crafting.getStackInSlot(0);
if (match == null || match.getItem() != Items.wheat_seeds) return false;
for (int i = 1; i < 9; i++)
{
ItemStack stack = crafting.getStackInSlot(i);
if (stack == null || !stack.isItemEqual(match) || !ItemStack.areItemStackTagsEqual(stack, match)) return false;
}
return true;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting crafting)
{
ItemStack seed = crafting.getStackInSlot(0);
ItemStack result = this.result.copy();
result.setTagCompound(seed.getTagCompound());
return result;
}
@Override
public int getRecipeSize()
{
return 9;
}
@Override
public ItemStack getRecipeOutput()
{
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment