Jump to content

Recommended Posts

Posted

So I am trying to make a recipe class that lets you attach 'spirits' to an item, and you can attach multiple spirits with different metadata, etc. But, for some reason it only works when the item you are attaching to is in a certain slot. I've tried everything I can think of, can anyone help out?

 

CLASS:

 

 

package yorkeMC.alfhomancy.api.crafting;

 

import java.util.ArrayList;

import java.util.List;

 

import javax.annotation.Nonnull;

 

import net.minecraft.entity.item.EntityItem;

import net.minecraft.inventory.InventoryCrafting;

import net.minecraft.item.ItemStack;

import net.minecraft.item.crafting.IRecipe;

import net.minecraft.world.World;

import yorkeMC.alfhomancy.common.items.ItemElvenSpirit;

import yorkeMC.alfhomancy.common.items.ItemWings;

import yorkeMC.alfhomancy.common.registry.ItemRegistry;

 

public class ISpiritRecipe implements IRecipe

{

@Override

public boolean matches(InventoryCrafting inv, World w)

{

boolean foundSpirit = false;

boolean foundItem = false;

 

for (int i = 0; i < inv.getSizeInventory(); i++)

{

ItemStack stack = inv.getStackInSlot(i);

 

if (stack != null)

{

if (stack.getItem() == ItemRegistry.ItemElvenSpirit && !foundSpirit) foundSpirit = true;

 

else if (!foundItem)

{

if (stack.getItem() == ItemRegistry.ItemWings) foundItem = true;

else return false;

}

}

}

return foundSpirit && foundItem;

}

 

@Override

public ItemStack getCraftingResult(InventoryCrafting inv)

{

ItemStack wings = null;

ItemStack copy = null;

ItemStack spirit = null;

List<ItemStack> items = new ArrayList<ItemStack>();

 

for (int a = 0; a < inv.getSizeInventory(); a++)

{

if (inv.getStackInSlot(a) != null)

{

items.add(inv.getStackInSlot(a));

if (items.size() >= 2)

{

for (int i = 0; i < items.size(); i++)

{

if ((items.get(i)).getItem() == ItemRegistry.ItemWings && items.get(i).getItemDamage() != 0)

{

wings = items.get(i);

copy = wings.copy();

}

 

for (int s = 0; s < items.size(); s++)

{

if (items.get(s).getItem() == ItemRegistry.ItemElvenSpirit)

{

spirit = items.get(s);

}

 

for (int go = 0; go < items.size(); go++)

{

if ((wings != null && spirit != null))

{

if (!ItemWings.hasSpirit(wings, spirit.getItemDamage()))

{

ItemWings.addSpirit(copy, spirit.getItemDamage());

}

}

}

}

}

}

}

}

return copy;

}

 

@Override

public int getRecipeSize()

{

return 10;

}

 

@Override

public ItemStack getRecipeOutput()

{

return null;

}

}

 

 

while(awake)

{

    coffee++;

}

Posted

Unrelated question: why does your class start with an 'I'?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.