Java Code Examples for net.minecraft.init.Items#cooked_fish()

The following examples show how to use net.minecraft.init.Items#cooked_fish() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SlotFirepitOutput.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
/**
 * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
 */
@Override
protected void onCrafting(ItemStack stack)
{
	stack.onCrafting(this.player.world, this.player, this.removeCount);

	if (!this.player.world.isRemote)
	{
		int i = this.removeCount;
		float f = FurnaceRecipes.instance().getSmeltingExperience(stack);

		if (f == 0.0F)
		{
			i = 0;
		}
		else if (f < 1.0F)
		{
			int j = MathHelper.floor((float)i * f);

			if (j < MathHelper.ceil((float)i * f) && Math.random() < (double)((float)i * f - (float)j))
			{
				++j;
			}

			i = j;
		}

		while (i > 0)
		{
			int k = EntityXPOrb.getXPSplit(i);
			i -= k;
			this.player.world.spawnEntity(new EntityXPOrb(this.player.world, this.player.posX, this.player.posY + 0.5D, this.player.posZ + 0.5D, k));
		}
	}

	this.removeCount = 0;

	net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerSmeltedEvent(player, stack);

	if (stack.getItem() == Items.IRON_INGOT)
	{
		this.player.addStat(AchievementList.ACQUIRE_IRON);
	}

	if (stack.getItem() == Items.COOKED_FISH)
	{
		this.player.addStat(AchievementList.COOK_FISH);
	}
}