private void BrewPotions() { if (!CanBrew()) { return; } ItemStack itemstack = BrewingItemStacks[3]; for (int i = 0; i < 3; i++) { if (BrewingItemStacks[i] == null || BrewingItemStacks[i].ItemID != Item.Potion.ShiftedIndex) { continue; } int j = BrewingItemStacks[i].GetItemDamage(); int k = GetPotionResult(j, itemstack); List <PotionEffect> list = Item.Potion.GetEffects(j); List <PotionEffect> list1 = Item.Potion.GetEffects(k); if (j > 0 && list == list1 || list != null && (list.Equals(list1) || list1 == null)) { if (!ItemPotion.IsSplash(j) && ItemPotion.IsSplash(k)) { BrewingItemStacks[i].SetItemDamage(k); } continue; } if (j != k) { BrewingItemStacks[i].SetItemDamage(k); } } if (Item.ItemsList[itemstack.ItemID].HasContainerItem()) { BrewingItemStacks[3] = new ItemStack(Item.ItemsList[itemstack.ItemID].GetContainerItem()); } else { BrewingItemStacks[3].StackSize--; if (BrewingItemStacks[3].StackSize <= 0) { BrewingItemStacks[3] = null; } } }
private bool CanBrew() { if (BrewingItemStacks[3] == null || BrewingItemStacks[3].StackSize <= 0) { return(false); } ItemStack itemstack = BrewingItemStacks[3]; if (!Item.ItemsList[itemstack.ItemID].IsPotionIngredient()) { return(false); } bool flag = false; for (int i = 0; i < 3; i++) { if (BrewingItemStacks[i] == null || BrewingItemStacks[i].ItemID != Item.Potion.ShiftedIndex) { continue; } int j = BrewingItemStacks[i].GetItemDamage(); int k = GetPotionResult(j, itemstack); if (!ItemPotion.IsSplash(j) && ItemPotion.IsSplash(k)) { flag = true; break; } List <PotionEffect> list = Item.Potion.GetEffects(j); List <PotionEffect> list1 = Item.Potion.GetEffects(k); if (j > 0 && list == list1 || list != null && (list.Equals(list1) || list1 == null) || j == k) { continue; } flag = true; break; } return(flag); }
/// <summary> /// dispenses an item from a randomly selected item stack from the blocks inventory into the game world. /// </summary> private void DispenseItem(World par1World, int par2, int par3, int par4, Random par5Random) { int i = par1World.GetBlockMetadata(par2, par3, par4); int j = 0; int k = 0; if (i == 3) { k = 1; } else if (i == 2) { k = -1; } else if (i == 5) { j = 1; } else { j = -1; } TileEntityDispenser tileentitydispenser = (TileEntityDispenser)par1World.GetBlockTileEntity(par2, par3, par4); if (tileentitydispenser != null) { ItemStack itemstack = tileentitydispenser.GetRandomStackFromInventory(); float d = par2 + j * 0.59999999999999998F + 0.5F; float d1 = par3 + 0.5F; float d2 = par4 + k * 0.59999999999999998F + 0.5F; if (itemstack == null) { par1World.PlayAuxSFX(1001, par2, par3, par4, 0); } else { if (itemstack.ItemID == Item.Arrow.ShiftedIndex) { EntityArrow entityarrow = new EntityArrow(par1World, d, d1, d2); entityarrow.SetArrowHeading(j, 0.10000000149011612F, k, 1.1F, 6F); entityarrow.DoesArrowBelongToPlayer = true; par1World.SpawnEntityInWorld(entityarrow); par1World.PlayAuxSFX(1002, par2, par3, par4, 0); } else if (itemstack.ItemID == Item.Egg.ShiftedIndex) { EntityEgg entityegg = new EntityEgg(par1World, d, d1, d2); entityegg.SetThrowableHeading(j, 0.10000000149011612F, k, 1.1F, 6F); par1World.SpawnEntityInWorld(entityegg); par1World.PlayAuxSFX(1002, par2, par3, par4, 0); } else if (itemstack.ItemID == Item.Snowball.ShiftedIndex) { EntitySnowball entitysnowball = new EntitySnowball(par1World, d, d1, d2); entitysnowball.SetThrowableHeading(j, 0.10000000149011612F, k, 1.1F, 6F); par1World.SpawnEntityInWorld(entitysnowball); par1World.PlayAuxSFX(1002, par2, par3, par4, 0); } else if (itemstack.ItemID == Item.Potion.ShiftedIndex && ItemPotion.IsSplash(itemstack.GetItemDamage())) { EntityPotion entitypotion = new EntityPotion(par1World, d, d1, d2, itemstack.GetItemDamage()); entitypotion.SetThrowableHeading(j, 0.10000000149011612F, k, 1.375F, 3F); par1World.SpawnEntityInWorld(entitypotion); par1World.PlayAuxSFX(1002, par2, par3, par4, 0); } else if (itemstack.ItemID == Item.ExpBottle.ShiftedIndex) { EntityExpBottle entityexpbottle = new EntityExpBottle(par1World, d, d1, d2); entityexpbottle.SetThrowableHeading(j, 0.10000000149011612F, k, 1.375F, 3F); par1World.SpawnEntityInWorld(entityexpbottle); par1World.PlayAuxSFX(1002, par2, par3, par4, 0); } else if (itemstack.ItemID == Item.MonsterPlacer.ShiftedIndex) { ItemMonsterPlacer.Func_48440_a(par1World, itemstack.GetItemDamage(), d + j * 0.29999999999999999F, d1 - 0.29999999999999999F, d2 + k * 0.29999999999999999F); par1World.PlayAuxSFX(1002, par2, par3, par4, 0); } else if (itemstack.ItemID == Item.FireballCharge.ShiftedIndex) { EntitySmallFireball entitysmallfireball = new EntitySmallFireball(par1World, d + j * 0.29999999999999999F, d1, d2 + k * 0.29999999999999999F, j + par5Random.NextGaussian() * 0.050000000000000003F, par5Random.NextGaussian() * 0.050000000000000003F, k + par5Random.NextGaussian() * 0.050000000000000003F); par1World.SpawnEntityInWorld(entitysmallfireball); par1World.PlayAuxSFX(1009, par2, par3, par4, 0); } else { EntityItem entityitem = new EntityItem(par1World, d, d1 - 0.29999999999999999F, d2, itemstack); float d3 = par5Random.NextFloat() * 0.10000000000000001F + 0.20000000000000001F; entityitem.MotionX = j * d3; entityitem.MotionY = 0.20000000298023224F; entityitem.MotionZ = k * d3; entityitem.MotionX += par5Random.NextGaussian() * 0.0074999998323619366F * 6; entityitem.MotionY += par5Random.NextGaussian() * 0.0074999998323619366F * 6; entityitem.MotionZ += par5Random.NextGaussian() * 0.0074999998323619366F * 6; par1World.SpawnEntityInWorld(entityitem); par1World.PlayAuxSFX(1000, par2, par3, par4, 0); } par1World.PlayAuxSFX(2000, par2, par3, par4, j + 1 + (k + 1) * 3); } } }