Jump to content

RESOLVED [1.7.10-10.13.0.1180] Damaging crafting item bug?


DiabolusNeil

Recommended Posts

Okay. I've tried everything, and I cannot figure out what I'm doing wrong. This seems like the only help there is on this subject: http://pastebin.com/SnPaAvUd, and it doesn't work. Instead of the item being damaged, it gets used up. This is my code that I'm working with:

 

// My item class.

public class ItemKnifeBase extends Item {

public ItemKnifeBase(ToolMaterial material) {
	this.setCreativeTab(ToolForgeryMod.tabToolForgery);
	this.setUnlocalizedName(ToolForgeryMod.MOD_ID + ":knife_" + material.toString().toLowerCase());
	this.setTextureName(ToolForgeryMod.RESOURCES_PREFIX + "knife_" + material.toString().toLowerCase());
	this.setMaxDamage(material.getMaxUses());
}

@Override
public ItemStack getContainerItem(ItemStack itemStack) {
	ItemStack result = itemStack.copy();
	result.setItemDamage(result.getItemDamage() + 1);
	result.stackSize = 1;
	return result;
}

@Override
public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) {
	return false;
}

}

 

// Registering the crafting recipe in the preInit() method.

GameRegistry.addShapelessRecipe(new ItemStack(Blocks.planks, 4, 0), new ItemStack(Blocks.log, 1, 0), new ItemStack(TFItems.knife_stone, 1, OreDictionary.WILDCARD_VALUE));

 

To clarify, the recipe shows up, and I can use it, but instead of damaging the knife, the knife gets used up. And I'm registering the item before the recipe.

 

SOLUTION: You need to add

 

@Override
public boolean hasContainerItem() {
return true;
}

 

to the item's class.

if (user.hasKnowledgeOfJava) {

    if (user.question.hasCode) {

        return interpetHelpfulResponse(user.getQuestion());

    } else {

        return "Could you post your code please?";

    }

} else {

    return "Learn some freaking Java!";

}

Link to comment
Share on other sites

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.