// Path: src/main/java/mods/belgabor/amtweaker/helpers/InputHelper.java
// public static ItemStack toStack(IItemStack iStack) {
//     return toStack(iStack, false);
// }


import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import static mods.belgabor.amtweaker.helpers.InputHelper.toStack;
package mods.belgabor.amtweaker.mods.vanilla.handlers;



/**
 * Created by Belgabor on 03.06.2016.
 */
@ZenClass("mods.vanilla.Durability")
public class Durability {

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Change harvest level

    @ZenMethod
    public static void set(IItemStack item, int durability) {
        if (item == null) {
            MineTweakerAPI.getLogger().logError("Durability: Item must not be null!");
            return;
        }
        Item test = toStack(item).getItem();
        if (!test.isDamageable() || test.getHasSubtypes()) {
            MineTweakerAPI.getLogger().logError(String.format("Durability: Item %s has subtypes or isn't damageable!", item.toString()));
            return;
        }
        MineTweakerAPI.apply(new DurabilityChange(item, durability));
    }



    private static class DurabilityChange implements IUndoableAction {
        private final ItemStack stack;
        private final Item item;
        private final Integer durability;
        private final Integer currentDurability;
        private boolean applied = false;

        public DurabilityChange(IItemStack item, Integer durability) {
// Path: src/main/java/mods/belgabor/amtweaker/helpers/InputHelper.java
// public static ItemStack toStack(IItemStack iStack) {
//     return toStack(iStack, false);
// }


// Path: src/main/java/mods/belgabor/amtweaker/mods/vanilla/handlers/Durability.java
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import static mods.belgabor.amtweaker.helpers.InputHelper.toStack;

package mods.belgabor.amtweaker.mods.vanilla.handlers;



/**
 * Created by Belgabor on 03.06.2016.
 */
@ZenClass("mods.vanilla.Durability")
public class Durability {

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Change harvest level

    @ZenMethod
    public static void set(IItemStack item, int durability) {
        if (item == null) {
            MineTweakerAPI.getLogger().logError("Durability: Item must not be null!");
            return;
        }
        Item test = toStack(item).getItem();
        if (!test.isDamageable() || test.getHasSubtypes()) {
            MineTweakerAPI.getLogger().logError(String.format("Durability: Item %s has subtypes or isn't damageable!", item.toString()));
            return;
        }
        MineTweakerAPI.apply(new DurabilityChange(item, durability));
    }



    private static class DurabilityChange implements IUndoableAction {
        private final ItemStack stack;
        private final Item item;
        private final Integer durability;
        private final Integer currentDurability;
        private boolean applied = false;

        public DurabilityChange(IItemStack item, Integer durability) {
            this.stack = toStack(item, true);