Good Morning People,
maybe someone can help me with a Mod I'm triying to program right now. The mod also includes a grindstone which applies Sharpness every time used.
The class looks like this till now:
public class katanasharpening implements IRecipe {
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
Boolean meitouexistend = false;
Boolean grindstoneexistend = false;
for(int slot = 0; slot < inv.getSizeInventory(); slot++)
{
if(inv.getStackInSlot(slot).getItem().getUnlocalizedName() == "meitoukokuhikari")
{
meitouexistend = true;
}
if(inv.getStackInSlot(slot).getItem().getUnlocalizedName() == "grindstone")
{
grindstoneexistend = true;
}
}
if(grindstoneexistend && meitouexistend)
{
return true;
}
else
{
return false;
}
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
int meitouposition = 0;
int currentlevel = 0;
for(int slot = 0; slot < inv.getSizeInventory(); slot++)
{
if(inv.getStackInSlot(slot).getItem().getUnlocalizedName() == "meitoukokuhikari")
{
meitouposition = slot;
}
}
NBTTagList tags = inv.getStackInSlot(meitouposition).getEnchantmentTagList();
if(tags != null)
{
for (int i = 0; i < tags.tagCount(); ++i)
{
int j = tags.getCompoundTagAt(i).getShort("id");
int k = tags.getCompoundTagAt(i).getShort("lvl");
if(j == 16)
{
currentlevel = k;
}
}
}
inv.removeStackFromSlot(meitouposition);
ItemStack kokumeitou = new ItemStack(HikariTouMod.meitoukokuhikari);
kokumeitou.addEnchantment(Enchantments.SHARPNESS, currentlevel +1);
return kokumeitou;
}
Questions:
Is inv.getStackInSlot(slot).getItem().getUnlocalizedName() == "something" a good way to check if the right items inside?
Through debugging it seems 16 is the id for sharpness?
How would I now register the recipe?
GameRegistry.addShaplessRecipe(katanasharpening); ??
addShapelessRecipe has a optional ResourceLocation parameter, is that it?
Happy for anyone who can give me some hints.