public void Create()
{
for (int index1 = 0; index1 < Recipe.maxRequirements; ++index1)
{
Item compareItem = this.requiredItem[index1];
if (compareItem.itemId != 0)
{
int num1 = compareItem.stack;
if (this.alchemy && Main.player[Main.myPlayer].alchemyTable)
{
if (num1 > 1)
{
int num2 = 0;
for (int index2 = 0; index2 < num1; ++index2)
{
if (Main.rand.Next(3) == 0)
++num2;
}
num1 -= num2;
}
else if (Main.rand.Next(3) == 0)
num1 = 0;
}
if (num1 > 0)
{
Item[] objArray = Main.player[Main.myPlayer].inventory;
for (int index2 = 0; index2 < 58; ++index2)
{
Item obj = objArray[index2];
if (num1 > 0)
{
if (obj.IsTheSameAs(compareItem) || this.useWood(obj.itemId, compareItem.itemId) || (this.useSand(obj.itemId, compareItem.itemId) || this.useFragment(obj.itemId, compareItem.itemId)) || (this.useIronBar(obj.itemId, compareItem.itemId) || this.usePressurePlate(obj.itemId, compareItem.itemId)))
{
if (obj.stack > num1)
{
obj.stack -= num1;
num1 = 0;
}
else
{
num1 -= obj.stack;
objArray[index2] = new Item();
}
}
}
else
break;
}
if (Main.player[Main.myPlayer].chest != -1)
{
if (Main.player[Main.myPlayer].chest > -1)
objArray = Main.chest[Main.player[Main.myPlayer].chest].item;
else if (Main.player[Main.myPlayer].chest == -2)
objArray = Main.player[Main.myPlayer].bank.item;
else if (Main.player[Main.myPlayer].chest == -3)
objArray = Main.player[Main.myPlayer].bank2.item;
for (int index2 = 0; index2 < 40; ++index2)
{
Item obj = objArray[index2];
if (num1 > 0)
{
if (obj.IsTheSameAs(compareItem) || this.useWood(obj.itemId, compareItem.itemId) || (this.useSand(obj.itemId, compareItem.itemId) || this.useIronBar(obj.itemId, compareItem.itemId)) || (this.usePressurePlate(obj.itemId, compareItem.itemId) || this.useFragment(obj.itemId, compareItem.itemId)))
{
if (obj.stack > num1)
{
obj.stack -= num1;
if (Main.netMode == 1 && Main.player[Main.myPlayer].chest >= 0)
NetMessage.SendData(32, -1, -1, "", Main.player[Main.myPlayer].chest, (float)index2, 0.0f, 0.0f, 0, 0, 0);
num1 = 0;
}
else
{
num1 -= obj.stack;
objArray[index2] = new Item();
if (Main.netMode == 1 && Main.player[Main.myPlayer].chest >= 0)
NetMessage.SendData(32, -1, -1, "", Main.player[Main.myPlayer].chest, (float)index2, 0.0f, 0.0f, 0, 0, 0);
}
}
}
else
break;
}
}
}
}
else
break;
}
AchievementsHelper.NotifyItemCraft(this);
AchievementsHelper.NotifyItemPickup(Main.player[Main.myPlayer], this.createItem);
Recipe.FindRecipes();
}