package romelo333.notenoughwands.Items;


import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import romelo333.notenoughwands.ProtectedBlocks;

public class ProtectionWand extends GenericWand{
    public ProtectionWand() {
        setup("ProtectionWand", "protectionWand").xpUsage(10).availability(AVAILABILITY_CREATIVE).loot(0);
    }

    @Override
    public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float sx, float sy, float sz) {
        if (!world.isRemote) {
            ProtectedBlocks protectedBlocks = ProtectedBlocks.getProtectedBlocks(world);
            if (player.isSneaking()) {
                protectedBlocks.unprotect(world,x,y,z);
            } else {
                if (!checkUsage(stack, player, 1.0f)) {
                    return true;
                }
                protectedBlocks.protect(world,x,y,z);
                registerUsage(stack, player, 1.0f);
            }
        }
        return true;
    }

    @Override
    protected void setupCraftingInt(Item wandcore) {
        GameRegistry.addRecipe(new ItemStack(this), "re ", "ew ", "  w", 'r', Items.comparator, 'e', Items.ender_eye, 'w', wandcore);
    }

}

@@ -318,16 +318,61 @@
 dBlocks;
+%0Aimport romelo333.notenoughwands.varia.Tools;
 %0A%0Apublic
@@ -418,150 +418,917 @@
 nd%7B%0A
-    public ProtectionWand() %7B%0A        setup(%22ProtectionWand%22, %22protectionWand%22).xpUsage(10).availability(AVAILABILITY_CREATIVE).loot(0);%0A    %7D
+%0A    public static final int MODE_FIRST = 0;%0A    public static final int MODE_PROTECT = 0;%0A    public static final int MODE_UNPROTECT = 1;%0A    public static final int MODE_LAST = MODE_UNPROTECT;%0A%0A    public static final String%5B%5D descriptions = new String%5B%5D %7B%0A            %22protect%22, %22unprotect%22%0A    %7D;%0A%0A    public ProtectionWand() %7B%0A        setup(%22ProtectionWand%22, %22protectionWand%22).xpUsage(10).availability(AVAILABILITY_CREATIVE).loot(0);%0A    %7D%0A%0A    @Override%0A    public void toggleMode(EntityPlayer player, ItemStack stack) %7B%0A        int mode = getMode(stack);%0A        mode++;%0A        if (mode %3E MODE_LAST) %7B%0A            mode = MODE_FIRST;%0A        %7D%0A        Tools.notify(player, %22Switched to %22 + descriptions%5Bmode%5D + %22 mode%22);%0A        Tools.getTagCompound(stack).setInteger(%22mode%22, mode);%0A    %7D%0A%0A    private int getMode(ItemStack stack) %7B%0A        return Tools.getTagCompound(stack).getInteger(%22mode%22);%0A    %7D%0A
 %0A%0A  
@@ -1622,105 +1622,39 @@
 if (
-player.isSneaking()) %7B%0A                protectedBlocks.unprotect(world,x,y,z);%0A            %7D else
+getMode(stack) == MODE_PROTECT)
  %7B%0A 
@@ -1865,16 +1865,93 @@
  1.0f);%0A
+            %7D else %7B%0A                protectedBlocks.unprotect(world,x,y,z);%0A
         

Use the mode key instead of sneaking for protection/unprotection