Java Code Examples for net.minecraft.item.Item.getMaxDamage()

The following are Jave code examples for showing how to use getMaxDamage() of the net.minecraft.item.Item class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: minecraft-quiverbow   File: Helper.java   Source Code and License Vote up 5 votes
public static void registerAmmoRecipe(Class<? extends _AmmoBase> ammoBase, Item weapon)
{
	ArrayList list = new ArrayList();
	
	Item ammo = getAmmoByClass(ammoBase);
	
	ItemStack weaponStack = new ItemStack(weapon, 1, weapon.getMaxDamage());
	ItemStack ammoStack = new ItemStack(ammo);
	
	list.add(weaponStack);
	list.add(ammoStack);
	
	GameRegistry.addRecipe(new Recipe_Ammo(ammo, weapon, list));
}
 
Example 2
Project: Technical   File: TileEntityMachineRepairingForge.java   Source Code and License Vote up 5 votes
public void smeltItem() {
	if((Boolean) canSmelt()[1]) {
		Item tool = machineItemStacks[0].getItem();
		int durability = tool.getMaxDamage() - tool.getDamage(machineItemStacks[0]);
		int newDurability = tool.getMaxDamage() / 3 + durability;
		if(newDurability > tool.getMaxDamage())
			newDurability = tool.getMaxDamage();
		machineItemStacks[0].setItemDamage(tool.getMaxDamage() - newDurability);
		machineItemStacks[1].stackSize--;
		if(machineItemStacks[1].stackSize <= 0)
			machineItemStacks[1] = null;
	}
}
 
Example 3
Project: BaseClient   File: RecipeRepairItem.java   Source Code and License Vote up 4 votes
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    List<ItemStack> list = Lists.<ItemStack>newArrayList();

    for (int i = 0; i < inv.getSizeInventory(); ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack != null)
        {
            list.add(itemstack);

            if (list.size() > 1)
            {
                ItemStack itemstack1 = (ItemStack)list.get(0);

                if (itemstack.getItem() != itemstack1.getItem() || itemstack1.stackSize != 1 || itemstack.stackSize != 1 || !itemstack1.getItem().isDamageable())
                {
                    return null;
                }
            }
        }
    }

    if (list.size() == 2)
    {
        ItemStack itemstack2 = (ItemStack)list.get(0);
        ItemStack itemstack3 = (ItemStack)list.get(1);

        if (itemstack2.getItem() == itemstack3.getItem() && itemstack2.stackSize == 1 && itemstack3.stackSize == 1 && itemstack2.getItem().isDamageable())
        {
            Item item = itemstack2.getItem();
            int j = item.getMaxDamage() - itemstack2.getItemDamage();
            int k = item.getMaxDamage() - itemstack3.getItemDamage();
            int l = j + k + item.getMaxDamage() * 5 / 100;
            int i1 = item.getMaxDamage() - l;

            if (i1 < 0)
            {
                i1 = 0;
            }

            return new ItemStack(itemstack2.getItem(), 1, i1);
        }
    }

    return null;
}
 
Example 4
Project: BaseClient   File: RecipeRepairItem.java   Source Code and License Vote up 4 votes
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    List<ItemStack> list = Lists.<ItemStack>newArrayList();

    for (int i = 0; i < inv.getSizeInventory(); ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack != null)
        {
            list.add(itemstack);

            if (list.size() > 1)
            {
                ItemStack itemstack1 = (ItemStack)list.get(0);

                if (itemstack.getItem() != itemstack1.getItem() || itemstack1.stackSize != 1 || itemstack.stackSize != 1 || !itemstack1.getItem().isDamageable())
                {
                    return null;
                }
            }
        }
    }

    if (list.size() == 2)
    {
        ItemStack itemstack2 = (ItemStack)list.get(0);
        ItemStack itemstack3 = (ItemStack)list.get(1);

        if (itemstack2.getItem() == itemstack3.getItem() && itemstack2.stackSize == 1 && itemstack3.stackSize == 1 && itemstack2.getItem().isDamageable())
        {
            Item item = itemstack2.getItem();
            int j = item.getMaxDamage() - itemstack2.getItemDamage();
            int k = item.getMaxDamage() - itemstack3.getItemDamage();
            int l = j + k + item.getMaxDamage() * 5 / 100;
            int i1 = item.getMaxDamage() - l;

            if (i1 < 0)
            {
                i1 = 0;
            }

            return new ItemStack(itemstack2.getItem(), 1, i1);
        }
    }

    return null;
}
 
Example 5
Project: Zombe-Modpack   File: ZWrapper.java   Source Code and License Vote up 4 votes
public static int getItemDmgCap(Item item) {
    return item.getMaxDamage();
}
 
Example 6
Project: Backmemed   File: RecipeRepairItem.java   Source Code and License Vote up 4 votes
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    List<ItemStack> list = Lists.<ItemStack>newArrayList();

    for (int i = 0; i < inv.getSizeInventory(); ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (!itemstack.func_190926_b())
        {
            list.add(itemstack);

            if (list.size() > 1)
            {
                ItemStack itemstack1 = (ItemStack)list.get(0);

                if (itemstack.getItem() != itemstack1.getItem() || itemstack1.func_190916_E() != 1 || itemstack.func_190916_E() != 1 || !itemstack1.getItem().isDamageable())
                {
                    return ItemStack.field_190927_a;
                }
            }
        }
    }

    if (list.size() == 2)
    {
        ItemStack itemstack2 = (ItemStack)list.get(0);
        ItemStack itemstack3 = (ItemStack)list.get(1);

        if (itemstack2.getItem() == itemstack3.getItem() && itemstack2.func_190916_E() == 1 && itemstack3.func_190916_E() == 1 && itemstack2.getItem().isDamageable())
        {
            Item item = itemstack2.getItem();
            int j = item.getMaxDamage() - itemstack2.getItemDamage();
            int k = item.getMaxDamage() - itemstack3.getItemDamage();
            int l = j + k + item.getMaxDamage() * 5 / 100;
            int i1 = item.getMaxDamage() - l;

            if (i1 < 0)
            {
                i1 = 0;
            }

            return new ItemStack(itemstack2.getItem(), 1, i1);
        }
    }

    return ItemStack.field_190927_a;
}
 
Example 7
Project: BetterBeginningsReborn   File: AdvancedCraftingHandler.java   Source Code and License Vote up 4 votes
public ItemStack findMatchingRecipeResult(InventoryCrafting crafting,
	InventoryWorkbenchAdditionalMaterials materials, World world)
{
	int i = 0;
	ItemStack itemstack = null;
	ItemStack itemstack1 = null;
	int j;

	for (j = 0; j < crafting.getSizeInventory(); ++j)
	{
		ItemStack itemstack2 = crafting.getStackInSlot(j);

		if (itemstack2 != null)
		{
			if (i == 0)
			{
				itemstack = itemstack2;
			}

			if (i == 1)
			{
				itemstack1 = itemstack2;
			}

			++i;
		}
	}

	if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.getCount() == 1 &&
			itemstack1.getCount() == 1 && itemstack.getItem().isRepairable())
	{
		Item item = itemstack.getItem();
		int j1 = item.getMaxDamage(itemstack) - itemstack.getItemDamage();
		int k = item.getMaxDamage(itemstack) - itemstack1.getItemDamage();
		int l = j1 + k + item.getMaxDamage(itemstack) * 5 / 100;
		int i1 = item.getMaxDamage(itemstack) - l;

		if (i1 < 0)
		{
			i1 = 0;
		}

		return new ItemStack(itemstack.getItem(), 1, i1);
	}
	else
	{
		for (j = 0; j < recipes.size(); ++j)
		{
			AdvancedRecipe advrecipe = recipes.get(j);

			if (advrecipe.matches(crafting, materials, world))
			{
				return advrecipe.getCraftingResult(crafting);
			}
		}

		return null;
	}
}
 
Example 8
Project: BetterBeginningsReborn   File: AdvancedCraftingHandler.java   Source Code and License Vote up 4 votes
public AdvancedRecipe findMatchingRecipe(InventoryCrafting crafting,
	InventoryWorkbenchAdditionalMaterials materials, World world)
{
	int i = 0;
	ItemStack itemstack = null;
	ItemStack itemstack1 = null;
	int j;

	for (j = 0; j < crafting.getSizeInventory(); ++j)
	{
		ItemStack itemstack2 = crafting.getStackInSlot(j);

		if (itemstack2 != null)
		{
			if (i == 0)
			{
				itemstack = itemstack2;
			}

			if (i == 1)
			{
				itemstack1 = itemstack2;
			}

			++i;
		}
	}

	if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.getCount() == 1 &&
		itemstack1.getCount() == 1 && itemstack.getItem().isRepairable())
	{
		Item item = itemstack.getItem();
		int j1 = item.getMaxDamage(itemstack) - itemstack.getItemDamage();
		int k = item.getMaxDamage(itemstack) - itemstack1.getItemDamage();
		int l = j1 + k + item.getMaxDamage(itemstack) * 5 / 100;
		int i1 = item.getMaxDamage(itemstack) - l;

		if (i1 < 0)
		{
			i1 = 0;
		}

		return null;
	}
	else
	{
		for (j = 0; j < recipes.size(); ++j)
		{
			AdvancedRecipe advrecipe = recipes.get(j);

			if (advrecipe.matches(crafting, materials, world))
			{
				return advrecipe;
			}
		}

		return null;
	}
}