Jump to content

Recommended Posts

Posted

Hi guys I have got small problem with my custom item with damage bar. It's a very small problem but important for me :)

When I want to craft sth more than one time I'm not able to do it. I made one trick which help me with it. Just look at src code:

 

Item Class

 

 

 

package net.elementarydiamonds.main;

 

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

 

public class itemTestDamageItem extends Item

{

public itemTestDamageItem()

{

super();

setMaxDamage(16);

setMaxStackSize(1);

setNoRepair();

}

@Override

    public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack)

    {

        return true;

    }

@Override

    public boolean getShareTag()

    {

        return true;

    }

 

public boolean hasContainerItem(ItemStack itemStack)

 

{

return true;

}

 

@Override

public ItemStack getContainerItem(ItemStack itemStack)

{

ItemStack stack = itemStack.copy();

 

stack.setItemDamage(stack.getItemDamage() + 1);

 

stack.stackSize = 1;

 

return stack;

}

 

}

 

 

 

Crafting SRC code

 

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 0)});

 

 

 

This trick is works that i add this 0 after 1 which means value of damage from this item.

 

I saw it in ItemStack.class

 

 

 

public ItemStack(Item p_i1881_1_, int p_i1881_2_, int p_i1881_3_)

    {

        func_150996_a(p_i1881_1_);

        this.stackSize = p_i1881_2_;

        this.itemDamage = p_i1881_3_;

 

        if (this.itemDamage < 0)

        {

            this.itemDamage = 0;

        }

    }

 

 

 

int p_i1881_3_ - it means itemDamage

 

Ok but doing it in this way is very long cuz' i have to add aditional lines of code because i want to use 16 times this item until he will crash, so it looks like that.

 

 

 

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 0)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 1)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 2)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 3)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 4)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 5)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 6)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 7)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 8)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 9)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 10)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 11)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 12)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 13)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 14)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 15)});

 

GameRegistry.addShapelessRecipe(new ItemStack(ElementaryDiamondsMain.itemWaterDiamondDust, 2), new Object[]{new ItemStack(ElementaryDiamondsMain.itemWaterDiamond), new ItemStack(ElementaryDiamondsMain.itemTestDamageItem, 1, 16)});

 

 

 

 

Could anyone help me with it? Any sugestions that I could do it in other way?

 

PS: Sorry for my english :) I'm not good at all.

Posted

You can use

OreDictionary.WILDCARD_VALUE

for the item damage. That way you only need 1 recipe for all the item damages possible.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.