package squeek.veganoption.items;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class ItemSoap extends Item
{
	public ItemSoap()
	{
		super();
		setMaxStackSize(1);
		setMaxDamage(3); // 4 uses
	}

	@Override
	public EnumAction getItemUseAction(ItemStack itemStack)
	{
		return EnumAction.eat;
	}

	@Override
	public int getMaxItemUseDuration(ItemStack itemStack)
	{
		return 32;
	}

	@Override
	public ItemStack onEaten(ItemStack itemStack, World world, EntityPlayer player)
	{
		if (!world.isRemote)
		{
			// I can not figure out how the curative item system
			// is meant to be used at all. PotionEffects each hold their own
			// curative items list but PotionEffects are created as needed;
			// they are not registered anywhere and there is no event for them
			// being created
			//
			// so.. just clear all potion effects instead of calling curePotionEffects
			player.clearActivePotions();
		}

		itemStack.damageItem(1, player);

		return super.onEaten(itemStack, world, player);
	}

	@Override
	public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
	{
		player.setItemInUse(itemStack, getMaxItemUseDuration(itemStack));
		return super.onItemRightClick(itemStack, world, player);
	}
}

@@ -28,16 +28,233 @@
 items;%0A%0A
+import java.util.List;%0Aimport net.minecraft.block.BlockDispenser;%0Aimport net.minecraft.dispenser.BehaviorDefaultDispenseItem;%0Aimport net.minecraft.dispenser.IBlockSource;%0Aimport net.minecraft.entity.EntityLivingBase;%0A
 import n
@@ -426,19 +426,146 @@
 aft.
-world.World
+util.AxisAlignedBB;%0Aimport net.minecraft.util.EnumFacing;%0Aimport net.minecraft.world.World;%0Aimport squeek.veganoption.helpers.RandomHelper
 ;%0A%0Ap
@@ -684,16 +684,109 @@
  4 uses%0A
+%09%09BlockDispenser.dispenseBehaviorRegistry.putObject(this, new ItemSoap.DispenserBehavior());%0A
 %09%7D%0A%0A%09@Ov
@@ -1814,11 +1814,1401 @@
 yer);%0A%09%7D
+%0A%0A%09public static class DispenserBehavior extends BehaviorDefaultDispenseItem%0A%09%7B%0A%09%09@Override%0A%09%09public ItemStack dispenseStack(IBlockSource blockSource, ItemStack itemStack)%0A%09%09%7B%0A%09%09%09EnumFacing enumfacing = BlockDispenser.func_149937_b(blockSource.getBlockMetadata());%0A%09%09%09int x = blockSource.getXInt() + enumfacing.getFrontOffsetX();%0A%09%09%09int y = blockSource.getYInt() + enumfacing.getFrontOffsetY();%0A%09%09%09int z = blockSource.getZInt() + enumfacing.getFrontOffsetZ();%0A%09%09%09AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox((double) x, (double) y, (double) z, (double) (x + 1), (double) (y + 1), (double) (z + 1));%0A%0A%09%09%09@SuppressWarnings(%22unchecked%22)%0A%09%09%09List%3CEntityLivingBase%3E entitiesInFront = blockSource.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);%0A%0A%09%09%09EntityLivingBase mostDirtyEntity = null;%0A%09%09%09for (EntityLivingBase entityInFront : entitiesInFront)%0A%09%09%09%7B%0A%09%09%09%09if (mostDirtyEntity == null %7C%7C entityInFront.getActivePotionEffects().size() %3E mostDirtyEntity.getActivePotionEffects().size())%0A%09%09%09%09%09mostDirtyEntity = entityInFront;%0A%09%09%09%7D%0A%09%09%09if (mostDirtyEntity != null)%0A%09%09%09%7B%0A%09%09%09%09mostDirtyEntity.clearActivePotions();%0A%0A%09%09%09%09itemStack.attemptDamageItem(1, RandomHelper.random);%0A%09%09%09%09if (itemStack.getItemDamage() %3E= itemStack.getMaxDamage())%0A%09%09%09%09%7B%0A%09%09%09%09%09itemStack.stackSize = 0;%0A%09%09%09%09%7D%0A%09%09%09%09return itemStack;%0A%09%09%09%7D%0A%09%09%09return super.dispenseStack(blockSource, itemStack);%0A%09%09%7D%0A%09%7D
 %0A%7D%0A

Add dispenser behavior to soap